Author Topic: Map Editor/Creator  (Read 5954 times)

Offline MadHaTr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Map Editor/Creator
« on: May 10, 2017, 03:57:20 am »
I've started a new project using WPF/C# to create a map editor for x-com/open x-com maps.

Goals
  • Create intuitive UI
  • Write a tile engine to load the maps into and display to a canvas
  • Use tile engine to load tile sets to a different canvas in the main window
  • Undo/Redo
  • Write the file loading/writing module
  • create a git project once more than the UI is in place
Extended Goals
  • Custom window and interface graphic

User suggestions/requests
  • Take user feedback
« Last Edit: May 13, 2017, 02:30:15 am by MadHaTr »

Offline MadHaTr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Re: Map Editor/Creator
« Reply #1 on: May 10, 2017, 03:57:32 am »
Here is the prototype I have for the user interface.  I am looking for feedback for what people think should go where and what shall be added or removed.

The area between the left upper, left lower and the right canvas I was thinking of using for the buttons, like copy, paste, delete.  The rest is mostly self explanatory. 

Show me the feedback!
« Last Edit: May 10, 2017, 04:01:50 am by MadHaTr »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 9840
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Map Editor/Creator
« Reply #2 on: May 10, 2017, 08:27:34 pm »
It's a very interesting idea. But we already have MapEdit, so to put it bluntly: you would have to make something better than MapEdit to get people to use it.

Of course MapEdit is not perfect, there are a number of issues with it. Can you please give a rough outline of how your program will be different from MapEdit, functionality-wise?

Offline MadHaTr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Re: Map Editor/Creator
« Reply #3 on: May 10, 2017, 10:00:50 pm »
Hey Solarius, thanks for responding. We're a bit far from me worrying about how many people will use this software.  This project will be a good learning adventure for me, especially since I have always be interested in tile maps and more importantly have loved X-Com from the day my buddy let me get a copy of his back in 94. 

I was dismayed ever so slightly that all the content creators here are having to use a partially broken tool. 

The one big difference, would be that the entire program will be in one window, with all the extra maps(tileset, routes) available in the smaller viewport on the left with a click of a button or hotkey.  Mapedit uses WinForm, this project will use WindowsPresentationFoundation which as it sounds is better at dealing with graphics. There are pros and cons.

So as I said I am looking for feedback on the entirety of the GUI.

Spoiler Windows Presentation Foundation:
WPF is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of standalone and browser-hosted applications. Although releases for WPF were stagnant for a while, Microsoft recently announced the future roadmap for WPF.

PROS

Powerful styling and skinning structure
Easy to create an own look and feel
It’s very flexible so you can re design your own controls without buying new controls
It's newer and thereby more in tune with current standards of technology
Does support Windows Forms
XAML makes it easy to create and edit your GUI, and allows the work to be split between a designer (XAML) and a programmer
Highly advanced data binding possible.
Uses hardware acceleration for drawing the GUI, for better performance
The ability to reuse existing code
Declarative vs. procedural code

CONS

Requires .NET Framework 3.0
Compared to Windows Forms, still in evolving phases.
Requires Dx9 compatible video card for advanced graphics

Spoiler Winforms:
WinForms applications have always been used to develop desktop applications where you want the entire processing burden to be rested on the client machine. This includes everything from drawing of graphics applications to data-entry systems to point-of-sale systems and games.

PROS

Extensive documentation can be found on the Internet
Plenty of examples and tested thoroughly for years
Supports WPF
There are lot of 3rd party controls in the market to make the job easier
The designer in Visual Studio is still, as of writing, better for WinForms than for WPF, where you will have to do more of the work yourself with WPF
 
CONS

Designing your own look and feel in an application is a lot of work
Extra cost incurred to buy third party controls


Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6386
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Map Editor/Creator
« Reply #4 on: May 10, 2017, 10:23:41 pm »
Compared to Windows Forms, still in evolving phases.

Considering WPF is more than 10 years old and no major improvements have been done since like 2012... I'd say it's beyond "evolving phases" :)
(just saying those quoted pros and cons are very old and by now most of them not true anymore)

Really... technology is the least of our worries in such a project (in a sense: it makes no difference at the end of the day).

So as I said I am looking for feedback on the entirety of the GUI.

You'll need to provide a more realistic screenshot, preferably with a real example (even if just put together in Paint), if you want any reasonable feedback.
« Last Edit: May 10, 2017, 10:35:02 pm by Meridian »

Offline Hobbes

  • Commander
  • *****
  • Posts: 3502
  • Infiltration subroutine in progress
    • View Profile
Re: Map Editor/Creator
« Reply #5 on: May 10, 2017, 10:38:02 pm »
I was dismayed ever so slightly that all the content creators here are having to use a partially broken tool.

Been using MapView for more than a decade and I agree it isn't perfect. But, like Solarius said, you'll need to create something more useful because I might have designed over 1000 individual maps with it :)

You'll receive better feedback once you have something working for us to see and experiment :)
« Last Edit: May 10, 2017, 10:41:30 pm by Hobbes »

Offline MadHaTr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Re: Map Editor/Creator
« Reply #6 on: May 11, 2017, 01:37:21 am »
Thanks for the replies guys. I'm just a guy wanting to write a tool. You all seem kind of hostile.

Meridian.
I just quickly googled WPF vs WinForms, and threw in the info here. The article had no date, though checking google the date appears as 2015. I'm aware WPF was introduced in 2010. Here is another article from 5 days ago giving good reasons for WPF over WinForms; I'm mostly interested in the databinding and enhanced visual abilities. Obviously anyone should go do their own research if they are worried about it. As to the GUI, that was a screen shot from inside the msvc2015 project. It is a rough idea I had on how the layout might go.  So possibly elaborate on a realistic screenshot.

Hobbes.
I am not saying anything bad about MapEdit or it's developer. I understand it has been around for a very long time.  I'm just looking for feedback on what everyone thinks would be a good user interface. Which requires no functionality.  Just ideas.

Like none of you have ever said oh I wish this was here or that control was over there or I wish I could do.  Like or maybe I wish the whole screen was the map editor and i had 10 squares along the bottom with my most used tiles and i just have to click a tab somewhere to open the tileset view and switch them out or grab a new tile. 

Offline ivandogovich

  • Commander
  • *****
  • Posts: 2409
  • X-Com Afficionado
    • View Profile
    • Ivan Dogovich Youtube
Re: Map Editor/Creator
« Reply #7 on: May 11, 2017, 01:49:58 am »
Just to chime in...  I have not done any Map creation due to the difficulty of getting the previous mapeditor working.  I'd be interested in a more accessible tool if you build one.  I unfortunately can't speak to features/usability due to lack of experience.

Hobbes, Dioxine, Solarius Scorch, Robin, and hellrazor are some of the community members that I am aware of that have a pretty solid handle on map building as it currently works.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 6386
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Map Editor/Creator
« Reply #8 on: May 11, 2017, 06:58:30 am »
Didn't want to sound hostile, sorry.
Good luck with the new tool.

As Solarius said, we'd be interested to know more about functional changes, not technology changes.
If you can describe that, you'll probably get more feedback.

PS: WPF is from 2006, not 2010

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2337
  • Developer
    • View Profile
Re: Map Editor/Creator
« Reply #9 on: May 12, 2017, 12:49:25 am »
if you have any questions about the file or data structures, feel free to ask.

Offline MadHaTr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Re: Map Editor/Creator
« Reply #10 on: May 14, 2017, 12:22:47 am »
I was probably just inferring hostility, I don't believe anyone meant me to feel that way.

Warboy, 
I was going over the data files today and reading on ufopedia.  I am using a hex editor to get a rough idea of things which worked great for the MCD files, they are very straight forward in each set of 62 bytes.   The BAT and PCK files on the other hand I am having difficulty locking them down. 

As I understand the BAT info about UFO from ufopedia, BAT files detail the start of sprite files inside the PCK files using 2 bytes of info(converted to dec/pixels?). It's not explained if the 2 byte data sets begins at the start of the file or later; I think they start right at the beginning because they each have 00 00. More importantly if the file references an uncompressed PCK file or the compressed PCK file.

The PCK file info explains decompressing by reading the first byte and skipping down the following rows, do I assume the rows are 32 bytes in length to match the sprite dimensions? Not sure how to know how large I should organize my rows so I can count downwards.

Offline Stoddard

  • Colonel
  • ****
  • Posts: 477
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Map Editor/Creator
« Reply #11 on: May 14, 2017, 02:18:19 am »
MadHaTr, if you read Python, you might find this useful:

https://github.com/StoddardOXC/minicom/blob/master/fileformats.py


Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2153
    • View Profile
Re: Map Editor/Creator
« Reply #12 on: May 20, 2017, 03:46:13 pm »
Considering WPF is more than 10 years old and no major improvements have been done since like 2012... I'd say it's beyond "evolving phases" :)
(just saying those quoted pros and cons are very old and by now most of them not true anymore)

Really... technology is the least of our worries in such a project (in a sense: it makes no difference at the end of the day).
Well WinForms is as old as Windows itself. :P As a shameless WPF fanboy I will say it is much easier for making custom UIs and controls like you would find in editors, rather than trying to hack around boilerplate Windows UI with Forms. It's true that the Visual Studio designer is better at WinForms than WPF, but it feels better to write WPF by hand anyways.

Sure, technology is not that important to the end-user, but it is important to the developer so these projects will actually end up somewhere besides the cutting room floor...
One thing I would suggest is looking into being more cross-platform. MapEdit's biggest gripe has always been its Windows-ness, so even if you're using .NET I would suggest checking what technologies are/will be easier to port in the future as Microsoft develops .NET Core / Xamarin. Being able to make maps on the go on a tablet would be amazing. ;)

I was probably just inferring hostility, I don't believe anyone meant me to feel that way.

Warboy, 
I was going over the data files today and reading on ufopedia.  I am using a hex editor to get a rough idea of things which worked great for the MCD files, they are very straight forward in each set of 62 bytes.   The BAT and PCK files on the other hand I am having difficulty locking them down. 

As I understand the BAT info about UFO from ufopedia, BAT files detail the start of sprite files inside the PCK files using 2 bytes of info(converted to dec/pixels?). It's not explained if the 2 byte data sets begins at the start of the file or later; I think they start right at the beginning because they each have 00 00. More importantly if the file references an uncompressed PCK file or the compressed PCK file.

The PCK file info explains decompressing by reading the first byte and skipping down the following rows, do I assume the rows are 32 bytes in length to match the sprite dimensions? Not sure how to know how large I should organize my rows so I can count downwards.
PCK files are super straightforward:
- TAB files (if available) are just a list of offsets for each sprite. They index directly into the PCK bytes, so to load sprite 3 you just start reading from PCK[offset3] until you reach PCK[offset4] (or the end of file).
The only catch is that while UFO only uses 2-byte offsets, TFTD sometimes uses 4-byte offsets, but you can just hardcode or guess it.
- PCK files are just a list of pixels (compressed or otherwise). They always have the same dimensions, so you can assume they're always 32px in width. In fact if you're loading the whole file at once you don't even need the offsets, as every sprite has an explicit "end of sprite" delimiter byte.

Offline MadHaTr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Re: Map Editor/Creator
« Reply #13 on: May 21, 2017, 05:12:22 pm »
MadHaTr, if you read Python, you might find this useful:

https://github.com/StoddardOXC/minicom/blob/master/fileformats.py

Thanks, I did have a look but I do not read py.  From what I could pick up it seemed that the code I needed to see was in some other files/structs which I could not locate.

Well WinForms is as old as Windows itself. :P As a shameless WPF fanboy I will say it is much easier for making custom UIs and controls like you would find in editors, rather than trying to hack around boilerplate Windows UI with Forms. It's true that the Visual Studio designer is better at WinForms than WPF, but it feels better to write WPF by hand anyways.

Sure, technology is not that important to the end-user, but it is important to the developer so these projects will actually end up somewhere besides the cutting room floor...
One thing I would suggest is looking into being more cross-platform. MapEdit's biggest gripe has always been its Windows-ness, so even if you're using .NET I would suggest checking what technologies are/will be easier to port in the future as Microsoft develops .NET Core / Xamarin. Being able to make maps on the go on a tablet would be amazing. ;)
I have to say I am really starting to enjoy the WPF, this is my first time using it and I like how flexible it is while coding up the interface.  Cross-platform is on the burner, I noted here on the forum people trying to get things working on their various systems.  I'd have to do some research like you say, while I know .NET is cross-platform I am not up on the details.

PCK files are super straightforward:
- TAB files (if available) are just a list of offsets for each sprite. They index directly into the PCK bytes, so to load sprite 3 you just start reading from PCK[offset3] until you reach PCK[offset4] (or the end of file).
The only catch is that while UFO only uses 2-byte offsets, TFTD sometimes uses 4-byte offsets, but you can just hardcode or guess it.
- PCK files are just a list of pixels (compressed or otherwise). They always have the same dimensions, so you can assume they're always 32px in width. In fact if you're loading the whole file at once you don't even need the offsets, as every sprite has an explicit "end of sprite" delimiter byte.
Thanks for this, I was able to see that the pck files were one image right after the other with the FF ending each of them.  I also figured out the tab file offset thing by looking at mapedits code.   I probably would have been lost for a long time,  sure I knew it was all in 2 or 4 byte sets but I didn't realize I had to toss these into a 16bit or 32 bit integer to see the proper numbers.  This is probably from my lack of formal education on the matter. I did have a comp sci class in HS and had 1 course in UNI but this was years(many) ago lol.

For the moment I think I will continue on with just reading/decompressing the pck file and getting the sprites rendered to an on screen tile map with some tool functionality.   When it comes time for the save files i'll get back to the proper formatting of files.



Offline MadHaTr

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Re: Map Editor/Creator
« Reply #14 on: May 22, 2017, 07:05:00 pm »
I seem to have my PCK file decompression algo working correctly. Where can in find the details on how to colour the pixels? I seen the palettes info page that and using 3 bytes to make a colour but I don't see where the reference is for what each byte in my PCK file means.

Here is a pic of the decompress(in hex) of the blanks.pck.  You can make out the diamond(isometric?) shape in the first sprite(in hex) (floor portion of tile?)

I've noted that none of the sprites in the pck files ive look at so far are 1,280 pixels(32x40).  In this included pic you can see the first sprite in the blanks.pck is 32x15.  So are these all just parts of potential 32x40 tiles? I guess once i start drawing them it may make more sense.