   Level Editor Interface
  I want to make a level editor for a 2D scrolling shooter I'm making. I'm pretty sure I understand the concept fairly well but I'm sort of lost as to how to implement the interface.I've seen a lot of tile editors that are seemingly written using the WinAPI or something similar. Since I've never really done anything substantial in WinAPI before I'm hesitant to start learning that halfway through doing my DirectX 2D scroller.So considering the limited requirements I have, would it seem practical to just cobble together a crude UI using rectangle graphics for buttons and implement the interaction with the buttons and whatnot myself from scratch?Of course, I might end up having to start over halfway through because I forgot something and presumably using a "proper" system like WinAPI or whatever would be a lot more straightforward and malleable if I knew how to use it.The kind of interface I was thinking about would be something like the one here: http://photos1.blogger.com/blogger/2754/2691/1600/mapedit.png. Is WinAPI a good choice for something like that or is that possibly using something else? Anyone have a link to some tutorials that focus on interfaces of that style?I just need something that preferably most easily lets me make an editor that can load up tiles, let me click them to select, click to place etc. etc.   
  In general, creating your own UI system is not desirable.  There's a whole lot of things you'd need to implement, and they've all been implemented (and tested) already in other UI toolkits.  Things like buttons can be simple, but then you start throwing in scroll bars, lists, splitters, tabs, menus....and things get complicated really quickly.That screenshot you posted appears to be using WinForms, which is part of the .NET Framework.  This means it was most likely written in C#.  What he has there is MenuStrip (the main menu at the top), a StatusStrip (the status bar at the bottom), vertical and horizontal ScrollBar's, a bunch of RadioButton's, a GroupBox surrounding the RadioButton's, and what is probably a custom Control where the tile map is actually rendered.WinForms is really nice in that it's pretty easy to use, and Visual Studio has a great visual designer which lets you set up the layout and handle events.  The problem is that since it sounds like your rendering code is written in native C++, you would have to handle interfacing native code with managed code.  This can sometimes be easy, but usually isn't trivial.Without WinForms, you could use the raw Windows API but I can guarantee you it won't be a fun experience.  If you don't already know how windows and controls work at a low level, you'll have to read up on all of that.  Then you'll have to write a whole lot of tedious code for setting up and handling the controls at runtime.  You're almost always better off using some sort of toolkit that wraps this stuff for you.You might want to consider a C++ UI framework like WxWidgets or Qt.  I haven't used them myself, but I've heard good things about them.  Those would spare you from having to directly work with the WinAPI stuff, but would let you stay with native code.   ;Quote:Original post by MJPIn general, creating your own UI system is not desirable.  There's a whole lot of things you'd need to implement, and they've all been implemented (and tested) already in other UI toolkits.  Things like buttons can be simple, but then you start throwing in scroll bars, lists, splitters, tabs, menus....and things get complicated really quickly.Yeah, I figured something to that effect.Quote:Original post by MJPYou might want to consider a C++ UI framework like WxWidgets or Qt.  I haven't used them myself, but I've heard good things about them.  Those would spare you from having to directly work with the WinAPI stuff, but would let you stay with native code.Cool... that sounds like probably the best solution.I've heard of wxWidgets before... it was suggested for us to use for an assignment in college and I was going to use it but didn't in the end. I think I had some trouble in the small amount of time I tried getting it to work but I'll have to give it a proper look now. Thanks.   ;  If all you need to do is draw a 1 or 2 layer tile map and place down enemies (that have pre-defined behaviors, no parameters to edit), then I'd probably go with an in-game editor. It's nice to have immediate and interactive results instead of having to work in the editor, save, run the game, close the game, repeat. And the UI controls might come in handy for making menus for the game itself too.But if you think you'll need text entry with copy/paste/undo, or drop-down boxes and other more complex controls, then it would probably be better to go with a separate editor using a UI framework. I used FLTK on my last editor, but wxWidgets is probably better. Both are a royal pain to get working, since you have to compile them yourself. I kind of like the old C-style WinAPI too. It's easy to get working and straightforward to use, but the documentation isn't great, and it tends to take a lot more code to do something than wx or FLTK.   ;Original post by DekuTree64If all you need to do is draw a 1 or 2 layer tile map and place down enemies (that have pre-defined behaviors, no parameters to edit), then I'd probably go with an in-game editor. It's nice to have immediate and interactive results instead of having to work in the editor, save, run the game, close the game, repeat. And the UI controls might come in handy for making menus for the game itself too./quote]That's probably more or less what I need to do. I'll need to place map tiles and then place enemies and that's basically it, though for saving levels as a certain file I suppose I'd need text entry.What exactly do you have in mind by an in-game editor? Wouldn't that still require you to create a whole set of GUI elements like buttons and whatnot? A scrollbar too since the level wouldn't be big enough for 1 screen. I was also looking at that program Tiled that I've heard a bit about before... might not be a bad choice just to get the game done more quickly. Has anyone here used it? Just kind of wondering how flexible it is... does it just save the maps in its own way or can you have it save files as xml and be formatted in a certain way?;Quote:Original post by Sean_SeanstonWhat exactly do you have in mind by an in-game editor? Wouldn't that still require you to create a whole set of GUI elements like buttons and whatnot?Yeah, you'd still need some buttons and things, but buttons are pretty easy to make.I was imagining moving the player around rather than using a scrollbar. So you can just go into "edit mode" wherever you are in the game, place down some enemies, maybe move the player back a bit, and start back up again. Probably reset all the enemies to their starting positions whenever you go into edit mode, because it could get confusing if you could modify enemies that had moved from their starting positions.Have some tool buttons to click on, maybe with hotkeys too. Tile edit, sprite move, enemy place. And buttons to show/hide the tileset and enemy selection windows. Those windows might need scrollbars, or you could just have row up/down and page up/down buttons to click.In sprite move mode, click on the player and drag to scroll around the map quickly, rather than having to "unpause" the game and wait for the normal game-speed movement.You don't really need any filename entry. Just have a single project file for the game, with a hard-coded filename. Copy and rename the project file from windows explorer to make backups.You'd also need some way to make new maps though, and edit the dimensions of a map. But text/number entry without undo/redo/cursor isn't too hard (that is, always add or remove characters at the end of the string, no moving the cursor back without backspacing characters).Hey, maybe you could make a separate text file for map names, dimensions, and level order, that you could edit from notepad. To make a new map, just add an entry in that file, and the game's level select screen could display it. And when you go to load the level in the game, if it doesn't exist in the project data file yet, just make a blank map with the dimensions from the text file.And when loading a level, check the dimensions from the text file versus the dimensions in the project data file to see if you need to resize the map.   ;  Also, consider using win32++, it has easy to follow tutorials and it sounds to me like it's suitable for your needs. Good luck.   ;  What are the issues when using a WinForms project together with native C++? Say you have a static library that is your games "back end", can your Winforms project not use those classes? (Sorry, know nothing about managed C++, wondering whether this is worth investigating.)An alternative would be to use a game GUI library for both the editor and the game. I don't know of many however, one example is CEGUI: http://www.cegui.org.uk/wiki/index.php/Main_Page   ;  I don't know if anyone has already mentioned this, but have you thought of taking someone else's (open source) editor and adapting it to your needs? Or even one that isn't open source and just writing a loader to convert the levels created into a format that is compatible with your game? I can say from experience that you can easily get sucked into going overboard with level editors and forget that, once upon a time, you were making a game. I'm presuming there would be a few level editors out there, and if not, most people who have created one probably wouldn't mind giving you the code for it.   ;Quote:Original post by SomniaWhat are the issues when using a WinForms project together with native C++? Say you have a static library that is your games "back end", can your Winforms project not use those classes? (Sorry, know nothing about managed C++, wondering whether this is worth investigating.)If you're writing the editor in a purely managed language like C#, then that managed code can't consume or interact with the classes defined in your native C++ library.  The only thing you can do with pure managed code is call free functions that are declared as extern "C", and that are exported from a DLL.C++/CLI is a bit different (Managed C++ is dead by the way, C++/CLI is the replacement) in that it can freely interact with both managed and native code.  Many people use it to write managed wrappers around classes in native libraries, rather than writing actual managed applications with it.  This is because it can be rather awkward to use, and can have a lot of pitfalls.