NX-Editor / NxEditor.EpdPlugin

EPD plugin for NX-Editor
GNU Affero General Public License v3.0
2 stars 1 forks source link

Update msbt library #1

Closed jordanbtucker closed 1 year ago

jordanbtucker commented 1 year ago

When opening an MSBT file, it is converted to YAML, however the generated YAML uses Literal Style blocks without the Block Chomping Indicator, so the text always includes an ending line break. When converting the YAML to something else, like JSON, this preserves the ending line breaks that don't actually exist in the MSBT.

For example, ActorMsg/PouchContent.msbt inside Mals/USen.Product.110.sarc.zs contains item names and descriptions when viewing them from the inventory. Here's a snippet of YAML produced by NxEditor.

Armor_035_Head_Caption: |
  According to legend, this cap was crafted for
  a hero who travels the wild lands. A Great
  Fairy has increased its defense by one level.
Armor_042_Head_Name: |
  Stealth Mask

When converting this YAML to JSON, you get the following.

{
  "Armor_035_Head_Caption": "According to legend, this cap was crafted for\na hero who travels the wild lands. A Great\nFairy has increased its defense by one level.\n",
  "Armor_042_Head_Name": "Stealth Mask\n"
}

Notice that both entries contain ending line breaks (\n) which aren't present in the original MSBT file.

This fix for this is to use YAML's Block Chomping Indicator like this.

Armor_035_Head_Caption: |-
  According to legend, this cap was crafted for
  a hero who travels the wild lands. A Great
  Fairy has increased its defense by one level.
Armor_042_Head_Name: |-
  Stealth Mask

Note the |- literal indicators instead of |. When converting this to JSON, you get the correct result.

{
  "Armor_035_Head_Caption": "According to legend, this cap was crafted for\na hero who travels the wild lands. A Great\nFairy has increased its defense by one level.",
  "Armor_042_Head_Name": "Stealth Mask"
}

Note that the line breaks inside the text are preserved as they exist in the original MSBT, but the ending line breaks are removed as they should be.

jordanbtucker commented 1 year ago

On deeper investigation, it looks like this issue stems from the implementation of ToText in https://github.com/EPD-Libraries/msbt. Let me know if you'd like me to open an issue there, or if you are able to transfer this one.

ArchLeaders commented 1 year ago

I can't transfer across organizations, so that'd be great if you can.

jordanbtucker commented 1 year ago

Can we re-open this? cs-msbt needs to update its msbt submodule, then this repo needs to update its cs-mbst submodule before this is actually fixed.

ArchLeaders commented 1 year ago

When I re-implement the MSBT editor I'll make sure to update the library. Next release won't be for a bit though cause there's some major changes being made.

ArchLeaders commented 1 year ago

Fixed in https://github.com/NX-Editor/NxEditor.EpdPlugin/commit/79d9c34a5e9714a9195561818b9b427279ab9912