1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Perl GUI progress

Discussion in 'Civ4Col - Medieval: Conquests' started by Nightinggale, Jan 19, 2016.

  1. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    A bit off topic, but I'm actually about to look into unit art now. Multiple people have asked for a modcomp for BTS where you can set the art for each era, instead of the 3 predefined settings. Looking at the code I think I have nailed how to code that and plan to do it soon (actually today, but something came up). Once I get it working, I plan to move it to M:C. This will provide the bonus that I get some insights on how the DLL handles this.

    If it is an area, which needs simplification, then we need to simplify it, either by perl GUI or DLL or both. I think we should look into that problem once we get there.

    Another simplification I plan to do is to add a text xml file for each field, which needs one. Something like TXT_KEY_AUTO_*_* where first * is the Type and the second is the tag, like TXT_KEY_AUTO_UNIT_SERF_DESCRIPTION. This will then be placed in the unit description xml file. With the GUI knowing this, The string you enter for Description is written for English in the text file. This provides full translation support while we have direct, quick and easy access to write the text while editing in English only.
     
  2. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    I ran into issues regarding this editor. It turned out that moving it from one computer to another is really tricky. Since it turned out to be broken by design (library dependencies), I decided to stop working on this.

    Thinking hard what to do to be able to get the editor out to all the people who needs it, I realized that the one thing everybody have in common is the mod itself. Everybody can run the mod just fine (or it won't be the editor, which is the main concern). As a result I decided to see how far I can go with the game GUI.

    First I investigated the XML interface in the game EXE. It can load the XML files for the mod, which would make it natural to use it to load the same XML files for modding. However it turns out that it can't read attributes and without those it's impossible to figure out what the XML schema say about the different tags.

    I found tinyxml2, which is a C++ library for reading and writing XML files. It's designed to be easy to handle and have low impact on memory and CPU as the creator planned to use it on Android. It consists of a cpp and a header file. The last part makes it perfect, because it allows adding the library source at compile time and compile the library itself into the game DLL file and not need extra DLL files at runtime. It had to be modified slightly to be compiled and linked with the DLL though, but only regarding header includes and defines.

    I used this to create a few new C++ classes, which are python exposed. Much of the real workload is done in the DLL, such as finding the correct element in the schema to match a certain tag because such work is based on pointers to tinyxml2 objects and as such C++ can do it really fast compared to python. I even added cache to the interface to ensure a virtually instant response time.

    Next I built a new python screen from scratch (first time ever I built python from scratch).

    Current status is that I can select a file, get the tags from that and clicking either opens a new column with the children of said tag or a string editor. When a new string is inserted using the editor, it's saved into the file right away. No need to remember to do that and no lag because the save code is fast.

    I plan on adding types as dropDown menus because typing those correctly is a time consuming task and prone to typos. Also by adding a menu, people no longer enter Unit instead of UnitClass and and so on. The DLL collects all the strings for such menus, but I haven't implemented it in python yet.

    Screenshot of progress (the green/red dots are placeholders for bools)
    Spoiler :
    with_bools.jpg
     
  3. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    It's working (though not complete yet). Now it's possible to edit strings, add more strings to lists tags missing due to minOccurs=0. Clicking on a bool toggles the setting. It's possible to right click on a tag and it will bring up a setup menu, which currently only contains the ability to assign the tag to point to types in a specific file. Once set to a file, instead of a string editor, it will bring up a list of tags in target file and you can select one (see screenshot). Once set up for a tag, it will work like that for all tags with the name in question and using a schema file from the same location.

    Spoiler :
    type selector.jpg
     
  4. Kailric

    Kailric Jack of All Trades

    Joined:
    Mar 25, 2008
    Messages:
    3,092
    Location:
    Marooned, Y'isrumgone
    I user tested this and I have to say what you already have is brilliant. When you implement all that you have planned they will have to invent a new word for it :) This is a modders dream come true.

    What about the ability to click a unit and have options available to edit its XML file? And other objects on the map as well. That could be handy too.
     
  5. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    Interesting idea. I guess it would be possible to add two strings (or char pointers) arguments to opening the editor. One is a type for the file (like UnitInfo) while the other is getType() of the unit you want. The editor will then open, set file to whatever file is picked and open the element containing the type. This should be generic enough to open everything and it will just be a matter of add the opening code whereever you want it.

    I'm not sure how useful it would be, but adding an edit button to the pedia pages would be a nice touch. I have planned an on/off switch for the editor, meaning the edit buttons will vanish in a release build. It would likely be a good idea to wait until I have that working before adding buttons everywhere and then go back and edit all of them later. For now I will focus on perfecting the editor rather than providing more ways to opening it.
     
  6. Kailric

    Kailric Jack of All Trades

    Joined:
    Mar 25, 2008
    Messages:
    3,092
    Location:
    Marooned, Y'isrumgone
    Yeah, it just seems like it would be neat for editing units. Say you are play testing unit combat abilities and you think a unity is a bit to powerful, you could click an edit unit button somewhere and change its starting xml stats. When I start play testing I'll keep that in mind.

    For buttons in the pedia, yeah, that could be useful too. What about say a shift click on a pedia entry brings open the editor to that entry? That would be very useful. Right now for anyone without the mod if you see you need to make a change you have to go to the exact xml file and search for the entry, so a neat feature like that would save much time.
     
  7. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    That sounds quite useful. Perhaps it can be an extra command meaning the button row will contain an edit button. Perhaps right clicking on a promotion can open that one. Also it might be useful to have a jump to promotion from a free promotion in the editor. It should be generic to allow jump to UnitClass and so on. Pages are however not stored and it would make it tricky to add a return button. I wonder if I can get clever and add layers of editors :think:

    I do see a number of potential issues with editing units/promotions in a running game. The main one being that the old stats are more likely cached, meaning it would have to be combined with a flush cache to be really effective. A player gaining/losing a civeffect, which allows promotions or even grants free promotions will loop all units and force some cache recalculation. It might be as simple as calling this function, but it's something, which needs to be checked.

    Adding a new promotion to XML or something like that will break a running game and I can't recommend actually playing a game after editing XML. However I have added code to M:C to "upgrade" savegames on load to match a new xml layout, meaning it should be possible to add a new promotion, restart the game and then load the savegame should work. Having said that, I do agree that it could be beneficial to alter something while running a game to get some trial and error until it looks right. Tech tree placement and stuff like that really benefits from not having to restart the game :)
     
  8. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    I added support for help text. Right clicking on a tag brings up a menu where different properties for the tag type is set. One of them is help text. This means it's now possible to tell what each tag does without messing with either code or pref files.

    Spoiler :
    HelpText.jpg
     
    orlanth likes this.
  9. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    Another update. Now it should be possible to make a mod using the editor only without actually opening the XML files and edit them directly. There are still features to add to make the interface easier/faster to use, but there should no longer be issues with something it can't do at all.
    New additions:
    1. Writing in a tag not present in XML will create it (like due to MinOccurs=0)
    2. Lists always ends with an empty tag, which allows adding more items to the list
    3. Added delete button to remove optional tags (like list elements)
    4. Added up/down buttons for quickly change int values
    Spoiler :
    int arrows.jpg
     
  10. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    I added an icon to list elements (uses Button child tag if possible) and drag-n-drop support to reorder lists. If you for some reason want the elements to appear in a different order, just drag the icon to the line where you want it to be.

    It turns out that there is an unexpected issue with this. It uses addDragableButtonAt to create the dragabe buttons. It turns out that this function or anything similar to it only exist in Colonization. This means drag-n-drop can't be moved to BTS.

    Spoiler :
    drag-n-drop.jpg
     
    JosEPh_II and Kailric like this.
  11. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    11,447
    Gender:
    Male
    Location:
    Western IL. cornfields
    This is fascinating and is this available for use? I see it's still a wip, but did not see a D/L link so I ask.

    I can see where this would save the Caveman2Cosmos Team sooo much work! We are going thru some extensive Tech tree changes and adding new Eras. And a whole new set of Leader traits as well.

    Agree 100%!

    I do hope you will release this.
     
  12. Nightinggale

    Nightinggale Chieftain

    Joined:
    Feb 2, 2009
    Messages:
    3,483
    M:C is using a public git repository, meaning you can always get the latest version if you can compile yourself. It is being developed in the branch called "develop".

    https://sourceforge.net/p/colonizationmodcollection/Medieval_Conquest/ci/master/tree/

    Guide on how to use git and compile. Highly recommended reading because there are some unique conditions, like git submodules and the modified makefile assumes perl to be installed.
    https://sourceforge.net/p/colonizationmodcollection/wiki/GIT/
    (note that there are 4 pages if you follow links)

    The same thing goes for Medieval Conquest. In addition to that Colonization 2071 is going to start over using the same DLL file, meaning more or less all XML files will need to be redone. I figured that if I'm ever to make an XML GUI, I better do it now before those huge tasks start.
     
    Last edited: Mar 23, 2017 at 11:13 AM

Share This Page