deepnight / ldtk

Modern, lightweight and efficient 2D level editor
https://ldtk.io
MIT License
3.44k stars 192 forks source link

Enum Importation from files is broken #1122

Open weierstrass1 opened 5 months ago

weierstrass1 commented 5 months ago

I tried differents enum files but neither of them worked:

File1, a json:

{
    "TileMaskType": "Solid"
}

File2, a json with other format:

{
    "TileMaskType": [
        "Solid"
    ]
}

File 3 a txt:

Enum0: T1,T2

Any of this says "Unsupported External Enum", also they have a lot of issues when you try to import, for example some of them do 2 copies of the file, or doesn't return any enum value.

another file that i tried was this didn't work:

{
    "TileMaskType": [
        "Solid",
        "T16x16_XS_Slope_R_1",
        "T16x16_XS_Slope_R_2",
        "T16x16_XS_Slope_R_3",
        "T16x16_XS_Slope_R_4",
        "T16x16_XS_Slope_L_1",
        "T16x16_XS_Slope_L_2",
        "T16x16_XS_Slope_L_3",
        "T16x16_XS_Slope_L_4",
        "T16x16_XS_Slope_UDR_1",
        "T16x16_XS_Slope_UDR_2",
        "T16x16_XS_Slope_UDR_3",
        "T16x16_XS_Slope_UDR_4",
        "T16x16_XS_Slope_UDL_1",
        "T16x16_XS_Slope_UDL_2",
        "T16x16_XS_Slope_UDL_3",
        "T16x16_XS_Slope_UDL_4",
        "T16x16_S_Slope_R_1",
        "T16x16_S_Slope_R_2",
        "T16x16_S_Slope_R_3",
        "T16x16_S_Slope_L_1",
        "T16x16_S_Slope_L_2",
        "T16x16_S_Slope_L_3",
        "T16x16_S_Slope_UDR_1",
        "T16x16_S_Slope_UDR_2",
        "T16x16_S_Slope_UDR_3",
        "T16x16_S_Slope_UDL_1",
        "T16x16_S_Slope_UDL_2",
        "T16x16_S_Slope_UDL_3",
        "T16x16_M_Slope_R_1",
        "T16x16_M_Slope_R_2",
        "T16x16_M_Slope_L_1",
        "T16x16_M_Slope_L_2",
        "T16x16_M_Slope_UDR_1",
        "T16x16_M_Slope_UDR_2",
        "T16x16_M_Slope_UDL_1",
        "T16x16_M_Slope_UDL_2",
        "T16x16_L_Slope_R_1",
        "T16x16_L_Slope_L_1",
        "T16x16_L_Slope_UDR_1",
        "T16x16_L_Slope_UDL_1",
        "T16x16_XL_Slope_R_1",
        "T16x16_XL_Slope_R_2",
        "T16x16_XL_Slope_L_1",
        "T16x16_XL_Slope_L_2",
        "T16x16_XL_Slope_UDR_1",
        "T16x16_XL_Slope_UDR_2",
        "T16x16_XL_Slope_UDL_1",
        "T16x16_XL_Slope_UDL_2",
        "T16x16_XXL_Slope_R_1",
        "T16x16_XXL_Slope_R_2",
        "T16x16_XXL_Slope_R_3",
        "T16x16_XXL_Slope_L_1",
        "T16x16_XXL_Slope_L_2",
        "T16x16_XXL_Slope_L_3",
        "T16x16_XXL_Slope_UDR_1",
        "T16x16_XXL_Slope_UDR_2",
        "T16x16_XXL_Slope_UDR_3",
        "T16x16_XXL_Slope_UDL_1",
        "T16x16_XXL_Slope_UDL_2",
        "T16x16_XXL_Slope_UDL_3",
        "T16x16_XXXL_Slope_R_1",
        "T16x16_XXXL_Slope_R_2",
        "T16x16_XXXL_Slope_R_3",
        "T16x16_XXXL_Slope_R_4",
        "T16x16_XXXL_Slope_L_1",
        "T16x16_XXXL_Slope_L_2",
        "T16x16_XXXL_Slope_L_3",
        "T16x16_XXXL_Slope_L_4",
        "T16x16_XXXL_Slope_UDR_1",
        "T16x16_XXXL_Slope_UDR_2",
        "T16x16_XXXL_Slope_UDR_3",
        "T16x16_XXXL_Slope_UDR_4",
        "T16x16_XXXL_Slope_UDL_1",
        "T16x16_XXXL_Slope_UDL_2",
        "T16x16_XXXL_Slope_UDL_3",
        "T16x16_XXXL_Slope_UDL_4"
    ]
}
tannerntannern commented 5 months ago

I'm also having issues on v1.5.3 with importing enums. Jotting down some issues I encountered here in case they are helpful for troubleshooting.

Neither JSON nor text are working quite right. In both cases when I import the enum for the first time, I'm unable to see the enum until I close the enums list and reopen it. When I do, the UI says the enum needs to be synced, which results in two enums with the same name (as @weierstrass1 already noted).

When I tried to edit my enum text file then went back to the editor to reload it, the editor crashed with the splash screen saying to file a GitHub issue. In my case the enum text file was

MyEnum: Foo, Bar
MyEnum2: Foo2, Bar2
Here are the details logs copied from the crash screen Stack: ``` LDtk version: 1.5.3-64bits Cannot read properties of undefined (reading 'getValueIndex') TypeError TypeError: Cannot read properties of undefined (reading 'getValueIndex') at importer_enu_TextFileEnum.preserveEnumValuesOrder (file:///C:/Users/Tanner/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:224177:22) at importer_enu_TextFileEnum.importToProject (file:///C:/Users/Tanner/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:224076:10) at importer_enu_TextFileEnum.load (file:///C:/Users/Tanner/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:223636:9) at importer_ExternalEnum.sync (file:///C:/Users/Tanner/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:223406:6) at HTMLAnchorElement. (file:///C:/Users/Tanner/AppData/Local/Programs/ldtk/resources/app.asar/assets/js/renderer.js:304498:28) at HTMLAnchorElement.dispatch (C:\Users\Tanner\AppData\Local\Programs\ldtk\resources\app.asar\assets\js\jquery.min.js:2:43064) at v.handle (C:\Users\Tanner\AppData\Local\Programs\ldtk\resources\app.asar\assets\js\jquery.min.js:2:41048) ``` Processes: ``` #0 App |--- #3 page.Editor |--- #4 misc.FileWatcher |--- #5 display.WorldRender |--- #6 display.LevelRender |--- #7 display.Camera |--- #8 display.Rulers[--] |--- #9 tool.SelectionTool[--] |--- #10 tool.lt.DoNothing[--] |--- #11 WorldTool |--- #12 tool.PanView[--] |--- #13 tool.lt.IntGridTool[--] |--- #27 ui.modal.panel.EditEnumDefs |--- #33 ui.Tip ``` Log: ``` [BOOT] App started [BOOT] Version: 1.5.3-64bits (build 473703) [BOOT] ExePath: C:/Users/Tanner/AppData/Local/Programs/ldtk [BOOT] Assets: C:/Users/Tanner/AppData/Local/Programs/ldtk/resources/app.asar/assets [BOOT] ExtraFiles: C:/Users/Tanner/AppData/Local/Programs/ldtk/extraFiles [BOOT] CWD: C:\Users\Tanner\AppData\Local\Programs\ldtk\ [BOOT] Display: 1290x860 [BOOT] Args: soloValues=[], args=[] [FILE] Loading settings from C:/Users/Tanner/AppData/Roaming/LDtk/settings... [BOOT] AppZoomFactor: 1 [BOOT] Calling appReady... [UPDATE] Looking for update [BOOT] Start args: path=null levelIndex=null [BOOT] Loading Home... [GENERAL] Page started: page.Home() [FILE] Loading page template: home from C:/Users/Tanner/AppData/Local/Programs/ldtk/resources/app.asar/assets/tpl/pages/home.html [DEBUG] samplesDir=C:/Users/Tanner/AppData/Local/Programs/ldtk/extraFiles/samples [GENERAL] Progress created. [GENERAL] Progress started: : "levels.ldtk: Project...", 5 operation(s) [LOAD] Loading project levels.ldtk... [LOAD] Project appBuildId=473703 appJsonVersion=1.5.3 jsonVersion=1.5.3 [LOAD] Loading complete. [GENERAL] Page started: page.Editor() [FILE] Loading page template: editor from C:/Users/Tanner/AppData/Local/Programs/ldtk/resources/app.asar/assets/tpl/pages/editor.html [FILE] Cleared all file watches [EVENT] LayerInstanceSelected 1 [FILE] Reloading tileset: Placeholder_tiles path=placeholder_tiles.png [FILE] Loading atlas image: placeholder_tiles.png... [CACHE] Caching image placeholder_tiles.png... [CACHE] -> identified as Png [CACHE] -> base64 1652 [CACHE] -> pixels 64x72 [FILE] -> Loaded 1238 bytes. [FILE] -> Decoded 64x72 pixels. [FILE] -> Old size: 64x72 -> 64x72 [WARNING] Tileset Placeholder_tiles remapping (image size changed)... [FILE] -> Reload result: Ok [FILE] -> pixelData: Ok [EVENT] TilesetImageLoaded [EVENT] ProjectSelected [WARNING] Full level render requested [RENDER] Rendering all world... [RENDER] Rendering world bg... [RENDER] Rendering world bounds... [FILE] Watching file: /placeholder_tiles.png [RENDER] Rendering world level data.Level#e3add4c0-25d0-11ef-be3a-2bc6b791be28 "Level_0"... ```