[✓][SUG][ED] NXLV to INI exporting

Started by WillLem, March 11, 2022, 03:00:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

WillLem

Is possible? :lemcat:

namida

Theoretically.

You'd essentially need a "reverse translation table", to map the piece names back to index numbers. You could autogenerate most of this from the regular translation tables (and presumably, you'd need to take into account any remapping in the alias files too). Some parts couldn't really be auto-generated any sensible way, and would need to be filled in manually - for example, splitting the exit back into a seperate main part / animated top. This could either be "modify the reverse translation tables by hand", or just "modify the output level to manually add back the missing part".

I'd note that there's very little point in doing this. If, as I suspect, the intended use case is SuperLemmini level creation, it would likely be not that much more effort - and a far more useful result - to create a fork of the NL level editor that instead loads and saves SuperLemmini levels directly.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

WillLem

#2
Quote from: namidaYou'd essentially need a "reverse translation table", to map the piece names back to index numbers

Would there need to be 2 copies of each style, one named (as per .nxlv) and one indexed (as per .lvl)? Or, does this depend on the player (NL/SL)?

Quote from: namidait would likely be not that much more effort - and a far more useful result - to create a fork of the NL level editor that instead loads and saves SuperLemmini levels directly

That's the dream, for sure. I even have some ideas for how I'd want the UI to look:

Potential Editor Layout
(Note that the tool panel on the upper right is for: Normal mouse pointer action / Selection mode (an advanced version of normal select which allows you to highlight and switch between pieces using the cursor/pgup & pgdown keys - great for fine-detail editing, as well as perform multi-selections, etc) / Paintbrush mode (which paints continuously using the currently selected piece whilst LMB pressed, or paints pieces edge-to-edge with RMB pressed) / Erase mode (erases continuously whilst LMB pressed, or turns pieces into eraser pieces whilst RMB is pressed) / rulers (for splat distance, etc) / skill mask sketches - all of this is dreamland at the moment, but it's what I'd want the editor to be able to do)

Thing is, I don't know anything about C# (which I believe is what the editor is written in?) I'm willing to learn, though. Realistically, how long do you think it would take (and how much work do you think it would be) for me to reverse-engineer a simplified version of the current NL editor which only deals with the classic 8 skills and L1/ONML objects, saves to .lvl and .nxlv (if possible), and give it something like the above UI?

Obviously, I'd start by just simplifying the editor (by removing stuff it doesn't need). That seems like a good place to start. Then, I'd need to re-introduce it to the .lvl format via .nxlv.

Worthwhile learning project, do we think? Or horrendous amount of work for very little gain? Or both? :crylaugh:

namida

QuoteWould there need to be 2 copies of each style, one named (as per .nxlv) and one indexed (as per .lvl)? Or, does this depend on the player (NL/SL)?

Theoretically you don't need an old-formats copy of the style, though there's not really much point converting it to LVL without one. On the other hand, if the ultimate intent is NXLV to (SuperLemmini) INI, then there's no reason to go via LVL. Make a convertor that goes straight from NXLV to INI. You'd still need a translation table (to be clear: this does not literally have to be in the exact existing format; I simply mean a file that serves the same purpose) unless the piece names in both engines mix exactly, but this would instead be one that maps NeoLemmix piece names to SuperLemmini ones, rather than NeoLemmix piece names to an index number.
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

WillLem

#4
A dedicated level editor for RetroLemmini may well happen someday (ar, at least, the ability for the current Editor to handle both formats), but for now I've decided to have a go at implementing a simple "Export to INI" tool built-in to the current Editor which spits out a Lemmini-compatible .ini file:

Preview

It's working well so far, just need to finish the translation tables for the default styles (these tables can be built via the GUI so users can add their own styles) and fix up a few other cross-platform quirks and it's ready to go! This means that some* .nxlv levels can now be back-ported to the Lemmini family.

*Those which only use a single Lemmini-compatible style set, only OG skills and objects, and no pre-placed lemmings, zombies, etc. I'll publish a full list once this feature is finished. For now it's still a WIP.

WillLem

A step or two closer. We can now preview pieces when building a translation table, and it's possible to add the ID for each piece directly (if known), or by browsing to find the corresponding piece in the RetroLemmini styles folder (directory is remembered for each browse, so the process is fairly quick):

Preview

The next step is to account for transparent pixels at the edge of the linked pieces. We can calculate this and generate an offset value for x, y, flipped x and inverted y. After that it's just making sure piece flags are correct (Erase, No Overwrite, etc).

WillLem

#6
This is coming along nicely. Improved the interface a bit and added support for steel areas, level speed (superlemming, etc) and calculating piece position offsets for transparent edge pixels.

We now also write the .nxlv level ID and version into the .ini file for reference.

Still need to incorporate individual piece flags, but that should be fairly straightforward. Also need to make sure that the offsets are calculated and written into the table with every session, in case pieces are updated.

Preview

NOTE: Piece linking is remembered between sessions on a per-ini-style basis, so once a piece has been linked for a target style, it never needs to be linked again. The translation tables are stored in SLXEditorTranslationTables.ini. This file will be provided fully populated with all OG style translation tables (for Crystal, Fire, Marble, etc). Custom styles will need to be linked by the style and/or level author, but - again - this should only need to be done once.

WillLem

#7
This feature is now complete and ready for testing!

I've added a feature where pressing F1 automatically updates all transparent edge offsets for the currently-selected style (a folder prompt opens to ensure that the correct target folder is selected) - particularly useful for if styles are updated between sessions (unlikely to happen with the OG ones, but custom styles may need this feature).

Implemented between commits ecc604a and 6bdc581.
Translation tables for OG styles (orig, ohno and slx) added in commit 2ffee5c.

Simon

Interesting that you continued with this feature. The gut feeling was that the formats are too different.

What do you do with tile groups? With resizable water? With unsupported tile types (teleporters)? Hard error and export nothing (the gut feeling), or warn and export the remainder of the level? Sounds like a list of violating tiles would be nice with the error/warning, or some other editor feature to hunt for violations.

-- Simon

WillLem

#9


Quote from: Simon on December 12, 2025, 01:48:46 AMWhat do you do with tile groups?

Nothing, currently. The screenshot above shows how a group appears in the Exporter. The author is asked to link each piece to a corresponding piece in the target Lemmini style. For groups, then, it's not really possible.

I can think of 2 possibilities here:

1) When loading the Exporter, use a clone of the level (probably best practice anyway in case we need to mod anything else), and ungroup all grouped pieces.

2) Ask the author to manually ungroup all grouped pieces before exporting (and, don't show groups in the list) - definitely the least user-friendly option, but at least the author will see exactly how the level will be translated in the output.

Quote from: Simon on December 12, 2025, 01:48:46 AMWith resizable water?

It comes through as a single default-sized water piece. Two possibilities:

1) First, measure the water piece (as sized in the level) and compare it to its linked counterpart. Then, draw as many water pieces as are necessary to recreate the resized piece. As each piece is drawn, check the drawing flag of the water piece at the original X, Y and ensure the target piece matches. Accept that smaller-than-default water and remainders will not be translated.

2) Send it through as it is. Ask the author to manually edit the water in the exported level (by adding more pieces as necessary).

Quote from: Simon on December 12, 2025, 01:48:46 AMWith unsupported tile types (teleporters)?

Any piece can be linked to any piece in the target style (see screenshot). It's up to the author if they want to link it to something, or just leave it if it's unsupported in RetroLemmini.

NOTE: The level can be exported even if it contains unlinked pieces; these will simply not appear in the output level.

WillLem

#10
OK, added very basic support for grouped pieces. It works if all pieces in the group are drawn solid, and it works for some groups involving erasers and/or no-overwrite pieces; the more complex, the less likely it is to translate correctly in the output, particularly if the grouped piece is adjacent to other pieces.

There isn't really a sensible way to preserve groups exactly as they are in the original .nxlv - for now, we should always try to do so, but accept occasional failures. We'll warn the user that their level might not export correctly if it contains grouped pieces.

Implemented in commit 514716b.

EDIT: Also added a warning that resized objects/terrain will appear at their orginal size. After looking into it quickly, it just isn't sensible to try and auto-build a resized piece using default-sized pieces; it will nearly always require the author to manually edit the output anyway.

Added in commit 979d5f8.

WillLem

#11
So, to be very clear, the feature as it currently stands supports levels that meet the following criteria:

:tal-gold: Fully supported

• Lemmini-compatible styles
• Classic 8 skillset
• Classic objects (traps, water, fire, one-way arrows, entrances & exits)
• All piece drawing types (eraser, no overwrite, etc)
• Superlemming speed
• Autosteel

:tal-silver: Partly supported

• Grouped pieces (must be ungrouped before exporting, so will work if ungrouping doesn't affect the layout)

:tal-bronze: Unsupported

• New skills (Jumper, Glider, Swimmer, etc)
• New objects (Buttons, Teleporters, etc)
• Resized pieces

Please note that the Editor will always try to export the level, but the output may need to be manually edited if it contains any partly supported or unsupported elements.