Updating Lem3Edit {v2.1 - 05/05/2018}

Started by kieranmillar, November 10, 2017, 10:01:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kieranmillar

Now on Github: https://github.com/kieranmillar/lem3edit

I promised myself next time I had a day off, I'd spend it trying to do some programming. I'm seriously amateur-hour at programming so wanted to edit an existing program to as a way to learn.

About 8 years ago Mindless made a Lemmings 3 level editor, lem3edit, then before finishing it decided to redo it in C++, but unfortunately abandoned it before re-implementing some key features... like the ability to save! So I sat down with a tutorial on how to get SDL to work in your environment and today's project became adding in a save ability to Lem3Edit. You can find Mindless's original source code here: https://bitbucket.org/mindless/lemmings-tools

It turns out it was pretty easy to add in the save feature, you just do the opposite of loading the level, hah!

So I looked to do a few more things because the save feature got implemented pretty quickly. Now you can cycle an object through all of the object ids so you can actually change what is in the level, this was a heck of a lot tougher to implement because the object ids are not contiguous and jump all over the place! But I got there in the end.

Lastly I made a quick "backgrounds only" view because it was quick to do and it's nice to be able to properly select and edit the backgrounds when they hide behind the terrain.

Unfortunately, making levels looks like it will be an unbelievable pain in the ass with the current interface, so I'll have to revisit this on my next day off and work on this some more. But at least now, if you also use a hex editor to edit some of the other level properties, you can actually make a fully-functioning mod!

P.S. If you want to play around, make sure to read the README file for controls. Note that you can't create new objects or terrain from scratch without copying and pasting existing ones then cycling through the object ids to change what they are. All objects are one of two types, terrain, and everything else.

To use the program, it needs to be put in the folder one step up from the GRAPHICS, LEVELS and STYLES folders. Those are on the CD, so copy your CD contents to your harddrive. And backup all of the files in your level folder! The program only loads levels via a command line argument, so make a shortcut to the exe file and put the level number (e.g. 123) directly after the link to the exe in your shortcut's properties.
EDIT: This is no longer how the program works. Read the README file!

I don't know how to use source control, so have uploaded my source to comply with the licencing. Maybe learning source control should be my next mini-project!

namida

QuoteI don't know how to use source control, so have uploaded my source to comply with the licencing. Maybe learning source control should be my next mini-project!

I thought it seemed like a lot of effort when I first heard about it, but I don't know how I lived without it now.
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)

mobius

everything by me: https://www.lemmingsforums.net/index.php?topic=5982.msg96035#msg96035

"Not knowing how near the truth is, we seek it far away."
-Hakuin Ekaku

"I have seen a heap of trouble in my life, and most of it has never come to pass" - Mark Twain


kieranmillar

I was enjoying this too much, so I just spent the whole weekend on it too!

I've attached v0.4 and its source code to the opening post. This feature comes with what I think is a really important addition for usability, a zoom feature!

Adding this was not so simple. Everything I could see online suggested I use SDL2 instead of SDL1.2 that lem3edit was coded in, so I could easily scale up the graphics using textures instead of manually duplicating the bits to the screen. I figured an update of SDL would be good practice and it's not like this is a huge program, so that's what I did. It ended up being quite a significant task as the paletted graphics the game uses were not immediately suited for it, but as you can see I got there in the end! This may mean for those of you who have computers with graphics cards (and not this integrated chipset nonsense my 10-year-old laptop uses) you might see some significant speed increases on complex levels like level 110, which seems to have about 900 objects in it for some nonsensical reason, just object after object layered on top of one another.

The change to SDL2 came with a few other minor changes. Gone is full screen mode, but I plan to eventually allow a resizable window so you won't need fullscreen. The selection boxes are no longer complicated marching ants selection boxes but much simpler semi-transparent rectangles, because hey with SDL2 we have easy alpha rendering now!

The zoom is triggered with only the mouse-wheel so far. It currently uses the top-left corner as the centre of zoom which is almost always not what you actually want, but that will be for another day.

Happy editing, this time without lots of squinting!

kieranmillar

#4
I want to write a ToDo list to make the time I spend on this more efficient, so might as well post it here. Tasks higher up their respective list are higher priority for me. If you have any plans to use this program sometime soon and have some suggestions or would like to see something earlier, post about it and I'm happy to reprioritise. Besides, posting it here lets me do funky strikethroughs in the text! This post will change over time as I do things, make releases or think of more things to add.

Smaller Tasks


Medium Tasks

  • Test level button.
  • Investigate why lemming and monster palettes are wrong

Larger Tasks

  • Program appears to load animations. Show these?

Ryemanni

I really love what you're doing here. Maybe I should try to make some L3 levels? ;)

Simon

Very nice. I've skimmed the source, but haven't bulit it yet. I assume the build instructions are: Install SDL2, build all cpp files of the editor, and link against SDL2.

Proper hosting on github would be lovely. I've played git helpdesk for Lix development back in 2011 and will happily answer questions in IRC about the git command line. If you prefer a GUI over command-line git, Nepster and namida have used Sourcetree.

-- Simon

kieranmillar

Quote from: Simon on November 14, 2017, 03:42:15 PM
Very nice. I've skimmed the source, but haven't bulit it yet. I assume the build instructions are: Install SDL2, build all cpp files of the editor, and link against SDL2.

Proper hosting on github would be lovely. I've played git helpdesk for Lix development back in 2011 and will happily answer questions in IRC about the git command line. If you prefer a GUI over command-line git, Nepster and namida have used Sourcetree.

-- Simon
Yes that sounds about right for setting up SDL2. I followed this tutorial:
http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php
And it was easy as hell. And if I can do it I imagine you will have no problems at all. The editor is currently pretty simple and only has this single dependency, so there's not much to it.

I'll definitely give Sourcetree a look over. Maybe it's what I need to help me get over the hump on learning how to use git.


kieranmillar

After spending most of the week encountering some coding challenges for the first time, messing it up, and reverting back to where I started, I decided to push out a few quick updates so those unwilling to compile from the latest source can take advantage of the latest features. These are not major updates, but are nice to have.

The Windows binary for version 0.4.1 can be found attached to the opening post. I will no longer be attaching the source code to the latest post as it is now on Github.

v0.4.1 changelog:

  • Program window can now be resized. It's also a bit larger by default.
  • Unimplemented monster that crashes the game can no longer be added to your levels.
  • Dashed lines now help make the level borders more visible given objects and terrain can go over the edges.

The next version will be more useful, my current focus is on two things; a) an interface to browse and add objects and terrain pieces instead of copying existing ones and then cycling through all possibilities and b) dragging the dashed lines at the level border to resize the level.

kieranmillar

Here comes a new major update, the object bar!

This lets you browse through all of the available objects and terrain pieces, and you can place new pieces onto the level by clicking on them to pick one up and clicking again in the level to place it.

Use the 1 and 2 keys on the keyboard to choose either backgrounds and objects, or terrain.

If you're wondering why there is a big grey square to the left of the bar, that is reserved space for a panel that will have buttons on it to do things that are currently only available by keyboard commands, like save or toggle background view. But that will have to be in a future update.

The Windows binary for version 0.5 can be found attached to the opening post.

v0.5 changelog:

  • New object bar!
  • Z and X no longer cycle through object types, but instead scroll the object bar.
  • Scrolling at screen edges disabled. Currently can only scroll with IJKL keys.

kieranmillar

I'm such an idiot sometimes. Can't believe this has been present since my first release!

v0.5.1 changelog:

  • Levels now save to the correct file, instead of always saving to level number 0.

kieranmillar

Another important update, resizable level and much better camera control!

v0.6 changelog:

  • Level borders can be dragged to resize them, constrained to L3's maximum and minimum width and height. Levels can't be all that tall, but can be ridiculously wide. Selecting objects under the cursor takes priority over grabbing a level border, so sometimes it's worthwhile to zoom out and grab the border far away from the main level.
  • You can now scroll with the mouse by holding down the right mouse button
  • Zooming now properly focusses on the mouse cursor
  • Re-added cycling ids of selected objects, as sometimes useful, e.g. to make easier changes to Classic's organic backgrounds. Now set to the [ and ] keys.

kieranmillar

I always knew there was something about this program that was causing massive lag, and this started to get very severe when there are lots of objects in the level. Level 016 is the worst example, with over 1,000 objects. And the lag got so bad that the program became basically unresponsive, not even closing when you tried to close the window unless you sat and waited for a couple of minutes.

Anyway I found the culprit, looking up object properties by iterating through every object instead of using a sensible searching method. Fixing this lowered the time per frame by about 75%! The program now remains mostly responsive at all times, but there are further improvements that can be made here.

Also Ctrl got busted at some point so I fixed it!

v0.6.1 changelog:

  • Fixed Ctrl-click which broke at some point. Handling of selecting and dragging objects is also much improved.
  • When saving, the number of extra lemmings and number of monsters are saved as required by the level format.
  • Major optimisation to looking up object properties, resulting in very large speed increases in a number of places.
  • If drawing is taking too long, drawing is skipped for a frame to allow the program to catch up and not get swamped in events, resulting in the program becoming unresponsive.
  • SDL2 prevents std::cout and similar from working, so now uses SDL_Log to display debug information in the console.

kieranmillar

A new major update, with the start of the graphical button interface for executing some important commands. No longer do you need to remember a million keyboard hotkeys.

v0.7 changelog:

  • Tool and Creature objects split onto their own separate layer.
  • Each layer's visibility can be toggled separately, instead of background-only mode.
  • Buttons in the bottom-left of the screen can be clicked to execute common commands, such as changing the type of object showing in the bar, and saving.
  • Move to Front and Move to Back added to change draw order of selected objects.
  • Feedback when saving to prove it did something. Currently just a standard SDL Simple Message Box.
  • Program can now drop multiple frames in a row instead of just one in moments of extreme lag to remain responsive.