Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[RESOLVED] Editor Maps and Tree Order

Hello,

Before I start I'd like to put you guys in context.
I'm making my own editor based on RMXP that reads .rxdata. I'm recreating the maps tree and everything is going fine.
Up to now it works like a charm. It displays all the maps and their child maps in the right order.

I'm now working on the drag and drop function which works fine too... Until I drag an older map into a newer map.
Why? Because the maps "order" property doesn't change when I drag and drop them. It doesn't change when I create/delete maps either.

Each maps have an RPG::MapInfo data associated to them which contains information on the tree expansion flag, the tree display order and other things used internally.

My problem is, I have absolutely no clue on how I can successfully update the maps order property, mainly because there is no internal hierarchy in the data itself. It's just data with parent id property place in whatever order they were when the object was created. I cam display them in the right order, but I don't know who I would "recalculate" the order.

Any idea on how I can do that?

Thank you very much
- Dargor
 
Bumpring this, I really need help.

Ok, let me explain this a bit more clearly:
The map order designates the order in which the tree object of the map will be drawn.
Here an example where M# represents the map and it's id, and where O# represents this map's display order in the tree.


Original Order:

M1:O1
|--M2:O2
|--M3:O3
|--M4:04
M5:O5
M6:O6
|--M7:O7


New Order:

M1:O1
|--M2:O2
|--M5:O3
|--M7:O4
M3:O5
M6:O6
|--M4:O7


You can notice that the maps have moved in the tree and so their order changed. But the order did not changed in the tree, it's the actual "order" property/variable of the map that has changed.

Maybe it's still confusing but if anyone is willing to solve this problem with me I'll be more than happy to explain it with even more details.

Thank you
-Dargor
 
I may be looking at this too simplistically, but every time you move an object update it's 'parent_id' property, then just cycle through all the objects in your hierarchy & reassign the 'order' property.
 
Thanks Brew. I finally managed to get it to work by doing something similar, but it was way more complex than that.
The problem was mainly that I didn't had any internal structure so I finally changed the way it works.

I made a DataInfo and a DataInfo::Folder class. DataInfo contains an array of folders and these folders have an array of sub folders (which containt DataInfo::Folder classes). Folders also includes an array of database object ID. Every database objects including the folders have an ID and a Parent ID. The tree will draw items based on the "depth" of this item included in the sub folder array.

In the end I don't need the #order property anymore. Only shifting objects in an array and changing these objects's parent_ID property correctly does the trick.

Thank you!
- Dargor
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top