Jump to content
Sign in to follow this  
s0600204

Tech/Structure Tree Visualisation

Recommended Posts

<...> As I understand it, UI elements and layout are specified in XML files which are parsed by the (c++) engine and used to create what you see. JavaScript can manipulate these elements (change textual content, change image used, set visibility, etc.) but can't call into being a new element that hasn't been specified in the XML file of the currently loaded UI. Or at least that's the impression I got from reading through the (possible slightly out-of-date) documentation on trac and the XML files currently used ingame.

<...>, otherwise it might be a bit too cumbersome if all possible elements have to be hardcoded (i.e. the max number that could possibly appear). <...>

I believe you both are right and that's how for example the summary page was originally (and still is) done:

summary.xml?rev=15927#L121

there is a 'repeat' element, which contains layout which will be repeated "count" times; in each copy "n" in element names is replaced with the counter index (so all elements are accessible in JS, see e.g. summary.js?rev=15927#L667 )

Share this post


Link to post
Share on other sites

Aye, but it appears 'repeat' elements cannot be nested, and so there would still be a lot of duplicated XML; and to minimise duplication, I'd have to go three deep.

Share this post


Link to post
Share on other sites

Looking at the code it should be easy to make the code match another letter. Currently it is hard-coded to use [n], but just specifying what to use in another xml attribute for the repeat tag doesn't sound hard to do.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, that'll make life a little easier!

Out of curiosity, how hard would it be to implement a horizontal scrollbar? (To scroll multiple smallish <object>s within a parent <object>)

  • Like 1

Share this post


Link to post
Share on other sites

That'd be a bit more involved. Mostly because we don't even support scroll bars for objects, but just for lists (and some similar elements). I'll see if I can take a closer look sometime.

  • Like 2

Share this post


Link to post
Share on other sites

Hello s0600204! Thanks for adding my mod!

All of the building icons don't seem to be showing up. Is there something I can change to fix that for you? :)

I like how your project can support more than 3 ages. Good job on that. Would be very useful for a mod that has a lot more ages (like a Rise of Nations).

Edited by wowgetoffyourcellphone

Share this post


Link to post
Share on other sites

@leper: Fair enough. I know you're busy, so I appreciate you taking the time to do what you've done thus far.

@Pureon: Thank you. I took a few artistic liberties, but I'm glad you like it.

@wowgetoffyourcellphone: No problem!

The reason why structure icons weren't showing up for your mod is because your mod doesn't have 0AD as one of its dependencies, and so 0AD's assets are not included when determining image locations. I've pushed a more up-to-date version of your mod to the live interactable version, at a state after you added/copied structure icons into your mod, so they should appear now.

  • Like 1

Share this post


Link to post
Share on other sites

:newyear:
Merry Christmas!1


I have a gift for you all! Introducing (by popular demand) this:

fEKop0d.png


Yes, that is the structure/tech diagram. And yes, that is running inside 0AD. (Well, who didn't see this coming?)

If you're running A17, you can grab this: https://github.com/s0600204/0ad-structree-mod/archive/master.zip
If you're running SVN, (or have a time machine2 and are running A18), you will need this version: https://github.com/s0600204/0ad-structree-mod/archive/A18.zip

To use: download the appropriate version, move it to one of your mods folder, see Game Data Paths for the appropriate path, and extract the contents. Rename the resultant folder "structree", start up 0AD, and enable the mod through the interface found through "Tools & Options" > "Mod Selection" on the Main menu.

You'll find the structure tree on the main menu under "Learn"/"Learn to Play"3 > "Structure Tree". I would advise disabling all other mods (except the core 0ad one, duh) before trying the mod. Otherwise, make sure it is last in the list of loaded mods.

Known problems:
  • On resolutions narrower than 1280px 1360px(?), the entire structree will not fit horizontally on the screen, and the current lack of a horizontal scrollbar means that you can't scroll.
  • Some building names are too long to fit in their boxes. I'm considering removing them and only having them in tooltips
  • The structree doesn't like the Rise of the East mod. I like it, it's a great looking mod, but the structree turns its nose up at it. This appears to be because the wallset templates (chin_wallset_stone & chin_wall_*) are encoded in utf-16 rather than utf-8. The fact that I can't use Engine.ReadXMLFile()4 and so coded a crude substitute may have something to do with it as well. Meh. Problem resolved. This now works with Rise of the East fine. :) Haven't tested any other mods yet. :(
  • prodigalson and wowgetoffyourcellphone have both got mods that have a fourth phase. I have an idea as to how to support this, but it might not work and I haven't had time to implement/test my theory. Therefore their mods may cause a lot of errors if you attempt to use my structree with either of their mods. Sorry! :sorry:
Anyhow, enjoy, and I hope you have (had) a good day! :xmas:



1 - Disclaimer: other mid-winter celebrations are available.
2 - Wibbley-wobbley timey-wimey... TardisGif.gif
3 - While coding, I was using windowed mode in 1024x768 to ease going back and forth, and found that simply adding a new button to the main menu caused an overlap with the box directly below the buttons. So I created a new submenu and moved the original "Learn to Play" and "History" options inside to join my structree.
4 - Because it's not exposed to GUI scripts.

Edit: Problem resolved with regards to Rise of the East, and adding in the "Game Data Paths" option in the "to use" paragraph.
Edit2: To coincide with recent changes. Edited by s0600204
  • Like 8

Share this post


Link to post
Share on other sites
  • prodigalson and wowgetoffyourcellphone have both got mods that have a fourth phase. I have an idea as to how to support this, but it might not work and I haven't had time to implement/test my theory. Therefore their mods may cause a lot of errors if you attempt to use my structree with either of their mods. Sorry! :sorry:

I confirm this. Lots of errors that break it. However, this is still really cool for vanilla version ofg the game! Works perfectly with vanilla version.

Edited by wowgetoffyourcellphone
  • Like 1

Share this post


Link to post
Share on other sites

[...]

  • The structree doesn't like the Rise of the East mod. I like it, it's a great looking mod, but the structree turns its nose up at it. This appears to be because the wallset templates (chin_wallset_stone & chin_wall_*) are encoded in utf-16 rather than utf-8. The fact that I can't use Engine.ReadXMLFile()5 and so coded a crude substitute may have something to do with it as well. Meh.

[...]

utf-16 encoding isn't the case for sure, line 1 of every file you say reads this:

<?xml version="1.0" encoding="utf-8"?>

Share this post


Link to post
Share on other sites
I was looking for a page that describes the default installation location on various systems, rather than the location where the game stores its save-games/screenshots/logs/cache/etc. That said, the page you linked does imply that you can place mods in a subfolder in much the same location, so maybe I doth protest too much. ;)

(On a slightly unrelated note, http://trac.wildfiregames.com/wiki/Modding_Guide#Howaremodsused really needs to be updated. "At some point we plan to have a graphical menu for selecting mods.")

utf-16 encoding isn't the case for sure, line 1 of every file you say reads this:

<?xml version="1.0" encoding="utf-8"?>
That doesn't mean the file is actually encoded in utf-8, only that the content within the file should be treated by the parser as if it is utf-8 encoded. The very first character in each of these files appears to be unprintable, which I'm going to make an educated guess and say might be a byte-order-mark, which from skimming the xml rfc I'm going to say isn't required if the file truly was utf-8, and may be partly why my hacked-together parser is throwing a wobbler.

Checking the han_china repository, I notice that leper has been and converted the files to utf-8 properly. So problem solved. (And thank you, leper! :D)

Share this post


Link to post
Share on other sites

I was looking for a page that describes the default installation location on various systems, rather than the location where the game stores its save-games/screenshots/logs/cache/etc. That said, the page you linked does imply that you can place mods in a subfolder in much the same location, so maybe I doth protest too much. ;)

The user-writeable mod folder is where mods should be installed (as that should be user-writeable on all systems). If someone wants to install a mod system-wide they can surely find the installation folder anyways.

(On a slightly unrelated note, http://trac.wildfiregames.com/wiki/Modding_Guide#Howaremodsused really needs to be updated. "At some point we plan to have a graphical menu for selecting mods.")

I knew I missed some documentation. Thanks for pointing that out.

Nice work (haven't tested the mod yet, but looked at the code a bit)! Might it be easier to just create a simulation to query it? Or should we just expose the template loader to the GUI? It seems like quite some code is at least partially duplicated from functionality already implemented in the simulation.

I might have to take a look at scrolling of gui objects now... (pesky contributors contributing :P) Thanks for a nice testcase :). Also using the nested repeats might help with making the GUI XML files a bit more readable.

  • Like 1

Share this post


Link to post
Share on other sites

The user-writeable mod folder is where mods should be installed (as that should be user-writeable on all systems). If someone wants to install a mod system-wide they can surely find the installation folder anyways.

Good point.

Nice work (haven't tested the mod yet, but looked at the code a bit)! Might it be easier to just create a simulation to query it? Or should we just expose the template loader to the GUI? It seems like quite some code is at least partially duplicated from functionality already implemented in the simulation.

Thank you! :) Yes, some of the code does duplicate simulation functionality. Some of the logic probably differs, but it comes to a similar enough result.

How would I go about running a simulation for the <1 second it takes to load the data? I mean I wouldn't need it running for any length of time, just long enough to populate the JS object that I use to cache the data I need to draw the structree. At one point I did try tracing the match setup scripts to try to work out how they start up the simulation, or call it into being or whatever, but I seem to recall I was discouraged as the scripts seemed to require an initialisation of players before hand.

On a similar note, I notice that the {civ}.json files contain information about things like Heroes and Special Technologies that (a.) only seems to be used in the civinfo page, and (b.) might be better loaded straight out the files that describe said Heroes/Technologies in-game. In order to do this, the GUI scripts would require access to an XML/template loader/parser of some form as well as the JSON parser. (Stripping out the duplicated data in those files and replacing them with references to the relevant XML/JSON files is something I've recently been considering.)

I might have to take a look at scrolling of gui objects now... (pesky contributors contributing :P) Thanks for a nice testcase :). Also using the nested repeats might help with making the GUI XML files a bit more readable.

No problem. I do have a branch in my local git repo that uses the nested repeats (and they are indeed a lot more readable), but I don't have a SVN-based copy of 0AD installed so I haven't had a chance to test it (and I really don't like pushing untested code (or in this case markup) on the community). I'll push the branch to GitHub, and someone can test if for me if they desire (else, I'll wait until A18 drops and test it myself then).

Share this post


Link to post
Share on other sites

Cool :)

Would be possible to make it dynamic? I mean to be able to access it during a game and see the researched techs coloured, while the one still to be researched on a grey scale.

Maybe also adding the count of every building already built.

  • Like 2

Share this post


Link to post
Share on other sites

Secret stuff.

(Still needs some cleanup to remove some code duplication, but I'll commit that to my fork soon)

Great job leeper. +1

Cool :)

Would be possible to make it dynamic? I mean to be able to access it during a game and see the researched techs coloured, while the one still to be researched on a grey scale.

Maybe also adding the count of every building already built.

I think this would be ultimate goal?

Share this post


Link to post
Share on other sites

I think this would be ultimate goal?

It's a potential goal, certainly, although not one I had when I started work on the mod.

(Deja vu, much? - server failure/transition erased my response... ;))

  • Like 3

Share this post


Link to post
Share on other sites

Very nice job (y)

This might also get to be a part of the (AFAIK planned) detailed civilization description.

If clicking a unit/building a more depth stat frame would show up e.g. below the techtree.

(Though I'd prefer a table with all units/buildings)

That'd be a bit more involved. Mostly because we don't even support scroll bars for objects, but just for lists (and some similar elements). I'll see if I can take a closer look sometime.

IMO scrollbars should be available for all GUI objects that could make use of it, yes. :acute:

That could enable us to get rid of several (though likely not all) cases of "things not fitting on the screen" and would be much more sane then several other proposals I've seen so far.

Edited by FeXoR
  • Like 1

Share this post


Link to post
Share on other sites

Did you hear that? Something happened, didn't it?

(More seriously: r16276. Small resolutions aren't supported yet, and that will not be fixed for A18. Apart from that try to break it and report back, else have fun with it.)

And again a huge thank you to s0600204 for both creating it and letting us merge it!

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...