Author Topic: Fixing Lem3Edit {v0.4 - 12/11/2017}  (Read 217 times)

0 Members and 1 Guest are viewing this topic.

Online kieranmillar

  • Posts: 115
    • View Profile
Fixing Lem3Edit {v0.4 - 12/11/2017}
« on: November 10, 2017, 10:01:32 pm »
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.

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!
« Last Edit: November 14, 2017, 09:31:36 pm by kieranmillar »

Offline namida

  • Administrator
  • Posts: 7934
    • View Profile
    • NeoLemmix Website
Re: Fixing Lem3Edit
« Reply #1 on: November 11, 2017, 12:22:10 am »
Quote
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!

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.

Offline mobius

  • Posts: 2015
  • The Owls are not what they seem
    • View Profile
Re: Fixing Lem3Edit
« Reply #2 on: November 11, 2017, 01:56:29 am »
:thumbsup:
:thumbsup:
:thumbsup:

Online kieranmillar

  • Posts: 115
    • View Profile
Re: Fixing Lem3Edit {v0.4 - 12/11/2017}
« Reply #3 on: November 12, 2017, 08:42:19 pm »
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!

Online kieranmillar

  • Posts: 115
    • View Profile
Re: Fixing Lem3Edit {v0.4 - 12/11/2017}
« Reply #4 on: November 13, 2017, 10:31:54 pm »
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.

Small Tasks
  • Increase transparency of selection boxes as Classic backgrounds too hard to see when selected
  • More sensible construction of the megatexture to make it way smaller
  • Prevent loading game-crashing extra monster so can't be put into levels
  • Zoom keyboard commands
  • Scroll speed dependent on zoom level

Medium Tasks
  • Center zoom on mouse, scrolling level as necessary, keyboard zoom to centre of screen
  • Remove autoscroll at border and implement right-click drag to scroll like lgl2
  • Draggable level borders to allow resizing(divisible by 8x4, max 2048x400)
  • Move to front/back
  • Update lemming and monster counts automatically when saving level file
  • Validate level on load for invalid objects and remove them before trying to draw them causes potential crash
  • Validate level on save for objects entirely out of level area and remove them, prevents in-game crash if trapdoor out of level borders
  • Move keyboard event checks out of main and into own function.
  • If hovering over a box, show how much of the tool is on that square by checking for more copies of the box at same coordinates. Requires text drawing

Big Tasks
  • Way to add objects directly onto level, interface like lgl2?
  • Look into how to use source control and migrate project to github
  • Allow resizing of window. Destroy and recreate screen texture + handler events
  • ini file to load and save things between program runs
  • Look into drawing text on screen, program appears to load L3's font?
  • Ask geoo how he got l2suite to autorun in dosbox and set up quick testing facility. Requires ini file
  • Investigate why lemming and monster palettes are wrong

Enormous Tasks
  • Proper level loading interface + creating new levels from scratch.
  • Program appears to load animations. Show these?
  • Proper interface for setting options like file paths, setting level time and release rate etc. Improve level loading interface.
  • Customizable controls
  • Proper level management interface. Due to levels being made out of 3 files with specific file names, need way to manage this easily. Ideally can name files whatever you want, with way to "publish" a level pack that converts filenames to what the game expects.
« Last Edit: November 14, 2017, 11:30:55 pm by kieranmillar »

Offline Raymanni

  • Posts: 213
  • Indeed.
    • View Profile
Re: Fixing Lem3Edit {v0.4 - 12/11/2017}
« Reply #5 on: November 14, 2017, 02:07:45 pm »
I really love what you're doing here. Maybe I should try to make some L3 levels? ;)

Offline Simon

  • Administrator
  • Posts: 1975
    • View Profile
    • Lix
Re: Fixing Lem3Edit {v0.4 - 12/11/2017}
« Reply #6 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

Online kieranmillar

  • Posts: 115
    • View Profile
Re: Fixing Lem3Edit {v0.4 - 12/11/2017}
« Reply #7 on: November 14, 2017, 08:27:02 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.

Online kieranmillar

  • Posts: 115
    • View Profile
Re: Fixing Lem3Edit {v0.4 - 12/11/2017}
« Reply #8 on: November 14, 2017, 09:31:58 pm »