1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

XML GUI progress

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

  1. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    Just a short update to state that this is not dead, but I have been short on time and energy lately, which has hurt progress.

    The plan is as follows:
    1. Finish the editor itself (currently working on the last item on the TODO list)
    2. Make a new mod for Colonization containing just the editor
    3. Add the ability to set a path to the mod to edit xml files in
    4. Convert the mod to BTS
    Things shouldn't be too time consuming once I reach step 2. The code is designed to be moved between mods with minimum effort.

    It should be noted that I recommend using the Colonization version of the editor (step 3) even for modding BTS mods since the BTS exe lacks drag-n-drop support. Step 4 is a slightly inferior version of the editor meant for people without Colonization.

    With standalone versions of the editor, I'm no longer convinced it's a good idea to add this editor to existing mods themselves. It does make the DLL bigger and it serves no purpose for the players, just modders.
     
  2. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,671
    Location:
    UK
    That will be quite cool actually as it will give the ability to run your mod and the editor side by side so you can work on both at the same time not to mention making it far more accessible to modders as there is no integration requirements.
     
  3. AbsintheRed

    AbsintheRed Chieftain

    Joined:
    Jul 27, 2009
    Messages:
    8,212
    Location:
    Szeged, Hungary
    I'm not even sure if number 4 is necessary.
    I think nowadays all modders who have BtS also have access to Colonization.
     
  4. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    I thought the same thing considering that you can't buy BTS today without also getting Colonization. However I asked the C2C modders and at least one core modder lacks Colonization. It doesn't really matter if it's one person, 10% or 50%. What matters is that there is some people and it matters alot for those. Besides doing step 4 should be fairly quick and easy once step 3 is complete.
     
  5. Kailric

    Kailric Jack of All Trades

    Joined:
    Mar 25, 2008
    Messages:
    3,094
    Location:
    Marooned, Y'isrumgone
  6. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    Common to all of those are that they are missing from the schema file and is as such a bug in CivEffect (M:C specific). The editor itself is fine, but it relies on the schema files to build the list of tags, meaning it by design displays whatever bugs you include in the schema files.
     
  7. chickenx4

    chickenx4 Chieftain

    Joined:
    Jul 21, 2016
    Messages:
    550
    Gender:
    Male
    Location:
    Cobb county,GA
    Question: does this work in Windows and where can I get it?
     
  8. Lib.Spi't

    Lib.Spi't Overlord of the Wasteland

    Joined:
    Feb 12, 2009
    Messages:
    3,671
    Location:
    UK
    It works through the game itself (So yes it does work on windows, but not mac)

    It is still being polished off and finished up. Progress has slowed a bit due to a lack of time. The 'Standalone' Version of it is not yet done, it is currently a branch of the Medieval Conquest Mod.
     
  9. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    Technically it's not even a branch. It's in the development (unstable) version and you need to compile it yourself right now. I plan to finish this ASAP, but it's unlikely that I will have time to do anything before the weekend.
     
  10. chickenx4

    chickenx4 Chieftain

    Joined:
    Jul 21, 2016
    Messages:
    550
    Gender:
    Male
    Location:
    Cobb county,GA
    What your going to do in the weekend?
     
  11. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    Hopefully finish the XML editor. I have a 3 step plan:
    1. Finish the features in M:C
    2. Make a standalone version
    3. Allow setting paths to XML/exe, hence allowing working on mods other than itself
    My goal is to finish the first step this weekend. 2+3 should follow soon after.
     
    orlanth likes this.
  12. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    Things are not progressing as fast as I had hoped, which is mainly due to lack of time to mod. One distraction is that I started teaching somebody about modding and rather than explaining it to one person, I started writing tutorials for everybody. So far there is one, but more will likely come as needed. Check it out https://forums.civfanatics.com/threads/how-to-avoid-multiplayer-desyncs.620471/

    The XML editor is progressing nicely in the past few days and I have made the last window.
    Name input.jpg

    More work is needed to make everything work as intended, but the layout is present. The idea is that you select a checkbox and keyboard input will take place in that line. You can then fill out one or more lines, meaning one TXT_KEY can be used to tell gender of object (mainly LeaderHeads) or number (one or more). In this case both singular and plural is used, in which case the game will select the correct version based on the value of an int argument when used. I will write about how to use this once everything is working as intended.

    Testing as revealed one issue, which I also want to fix before releasing anything. The editor correctly highlights tags, which needs to be filled out in red, but if the modder ignore this, the game will fail to read the file at next startup. It will tell of an error in the file in question while presenting a line number. The editor is not as picky and will open the file anyway (just as planned), but then the problem starts: how to find the tag with the error. Line 2468 doesn't help when you are in a GUI editor. I need to find some sort of function, which loops through all tags in the file and stops at the first one encountered, which is marked red.
     
    orlanth likes this.
  13. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    I finished the string input system.

    I added a button called "Find Error", which loops through all tags in a file and stops at the first one, which is marked red. That is, the first one where the schema file requires the file to be filled out, but it has no value. I optimized this to be done within seconds (if not less than a second), meaning it will be fairly easy and fast to test if the game will accept the file in question. The editor will load xml files, which doesn't comply with the schema file, meaning finding and fixing errors has now become fairly strait forward and quite fast.

    To my knowledge the editor is done, but I need to do some more testing and fix the bugs, which I encounter (if any) before starting to make a standalone editor.
     
    orlanth likes this.
  14. devolution

    devolution Chieftain

    Joined:
    Oct 7, 2016
    Messages:
    241
    Gender:
    Male
    Location:
    Stavanger, Norway
    @Nightinggale I just wanted to commend you on this work :goodjob: This editor could be very helpful for further development of RaR as well :crazyeye:
     
  15. Hecur

    Hecur Chieftain

    Joined:
    Jun 24, 2017
    Messages:
    52
    Just wanted to know if you could manage to get any progress, as this project looks very promising.
     
  16. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    Finishing this editor is on the top of my list and I won't do any other modding until it's done. It's just that stuff happened and then I got low on modding time. Status right now is that it would appear that everything is working, except keyboard input. The issue is that python gets a notification about which key is pressed, which is just some int. This int can be used to tell which button is pressed, but only on US keyboards. This means if you use a keyboard from anywhere else in the world, it won't do as expected. I have made code to get around that and it will make a guess on the keys. Odds are that some corrections will be needed and I'm half way through making a menu to do just that.

    While it sounds scary with keyboard calibration, it really isn't because I thought a lot about this. All you have to do is to open the keyboard edit menu, use arrow keys to select the character you can't type and then you press the key combo you want to use for that key and it will be saved automatically. This means you will only have to do this once. Even better the config file is named based on the ID windows has to the keyboard layout, meaning if people send me their config files, then I can add them to the distributed mod (hence editor). This means no need for a setup if people use a layout somebody else have set up already.

    The obvious question is why not use a text input field like in name city? Well I did try, but I couldn't get it to work reliably and what I have made should work 100% of the time after setup. I didn't think keyboard input would be a problem, but it has turned out to be quite time consuming.
     
  17. Hecur

    Hecur Chieftain

    Joined:
    Jun 24, 2017
    Messages:
    52
    Thanks for the news.
     
  18. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    I created a git repository for a standalone XML editor, which can be viewed here.

    Status is that I have been trying to edit RaR and while testing is limited, it would appear that it's mostly working. There are a few known issues remaining, hence no release yet.

    It works like a standard Colonization mod. You drop it in the MODS directory. There is a file called EditorSettings.xml in Assets containing the path to the mod you want to edit.
    PHP:
    <?xml version="1.0"?>
    <Editor>
        <!-- ModPath links to the Assets directory of the mod you want to edit -->
        <ModPath>../../Religion-and-Revolution/Assets</ModPath>
    </Editor>
    Once set, all you have to do is to load the mod and open the editor from the main menu (see screenshot). No screenshots from the editor itself because it's identical to the previous screenshots... more or less anyway. There is a button to copy graphics and GameFont from the mod into the editor mod, which allows graphical previews of what you are doing. It only works with unpacked files though, but you should be able to manually copy those big packed files if you really want to.

    No BTS support for the time being since I want to get it stable for Colonization first. However I'm planning for this and a significant part of the code is BTS ready, like reading the mod/vanilla are all loops, meaning those functions will hopefully work unmodified once the list contains all 3 vanilla locations for BTS.

    Making an editor, which runs in BTS rather than Colonization is a bit of an issue and will be the last thing I do regarding an editor. The main issue is that as long as I'm fixing bugs and fine tuning all the features, I really only want one source code. Fixing the same bug for both BTS and Colonization means making the code change in two different mods and commit/release both. Not only is this more time consuming, it's also really annoying and a big motivation killer. Another issue is that Firaxis added drag-n-drop support to Colonization, meaning the editor is currently using some python functions not available in BTS.

    I haven't quite figured out how to most efficiently test this. Most likely I will make some pre-release and make the testing and possibly even guide writing a community effort. It has already taken way longer than planned to make this editor, which is partly because it's a one man project.

    One thing, which has to be a community task is setting up the tags. When you right click on a box, you will get a window for editor setup for the tag in question. Here you can set how the editor should view the tag in question and how it should act to make it most efficient for the user. If you type while the editor window is open, it will write a string. This string is then the help text, which will be used for mouse over text, which can then tell what the tag is used for ingame.
    Example: (names are from memory)
    In a BuildingClassInfo, you right click on DefaultBuilding. You select that it's of type "Type" and it's linked to BuildingInfo. You make sure not to check the "allow none" checkbox. Now whenever anybody left click on the DefaultBuilding box, a window will open with a pulldown menu where it lists all BuildingInfos. No typing, just select from the menu. You can click on the first character to jump in the menu (vanilla feature), which is why the BUILDING_ prefix is not part of the menu.
    Next you right click on the BuildingClassInfo box and select which child tag to get the preview from. You select DefaultBuilding. Now whenever the editor requires a preview for a BuildingClassInfo, it will read from Default Building, which will then read the preview from the BuildingClass it's pointing to. The BuildingInfo is then set up similarly and points to a BuildingArtInfo, which has a tag, which is set to be a button. It contains the actual file path.
    This mean whenever you get a list of BuildingClassInfos (like editing the file), each index will display a dds file, which it reads through that chain. Since all files are stored efficiently in memory, reading everything for a file is instant even if the file is big and each chain goes through multiple files.
    Available options and default behavior of a box depends on the schema, meaning an int will have a different set of types than a string and ints can't be set to be a button or a Type from another xml file. The schema is also used to display tags even if they have minOccur=0 and not present in the xml file (a problem with every single xml editor I have seen elsewhere, hence the reason why I started my own)

    I'm thinking of making one default set, which will (hopefully) apply to BTS as well as Colonization. Most of the tags are identical and the difference is all about new tags. For instance if a BTS mod has rules for ProfessionInfo, it won't use them because it doesn't care what it has rules for. It looks in the settings for a specific string and ignore the rest. It will never notice if there is a string, which can't be accessed because it's not in the schema file.

    While it's designed to be adjusted for each mod, it would be nice to have a default set to prevent each mod from having to start from scratch. It would be nice if somebody familiar with a lot of xml settings would make a default setup to include in the distribution.

    If anybody is interested in assisting, please let me know.
     

    Attached Files:

    AbsintheRed likes this.
  19. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    I managed to get BTS support up and running. It wasn't too difficult because it would appear my plan worked perfectly and most of the code accepts either version without being modified. You will still have to load it as a Colonization mod even if you mod a BTS mod. In theory you can mod original and warlords mods as well, but I haven't tested it. Odds are nobody will actively develop those anymore anyway.

    My plan now is testing and fix any issues uncovered by testing. The best approach I can think of for this would be to get people to test it on their own mods and report back if it works as intended and any feedback regarding anything, which could be done differently. If you are interested, the git repository is here, which is also the link to the readme, which for now is the only documentation and it's far from complete. It's a very feature rich editor.
    Anybody using this should work on a backup!!! (Ideally git or svn). In fact you should have a proper backup system for all your mods even if you do not use any editor.

    Right now you need to compile the DLL yourself. I will do it automatically at some point, most likely within a few days (I haven't set it up to do so yet). I will still encourage you to compile yourself if you can.

    Known issues:
    - Doesn't work with Caveman 2 Cosmos because that mod uses a different schema syntax than vanilla. (might be fixable, but will for sure take a while)

    Feedback is most welcome, both bug reports and ideas. Tell me what you think, both good and bad. If there are people who want to really dig into this, I could set up a chat dedicated for this purpose.

    Posts with lots of text and no graphics are boring. To spice up this post, I added a few screenshots from editing Fall From Heaven 2 (which we all know is a BTS mod)
     

    Attached Files:

    Last edited: Aug 17, 2018
    f1rpo likes this.
  20. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    3,986
    Links:
    GIT repository
    Compiled DLL
    GIT wiki guide

    There is a readme in the git repository, which should help getting started. You can compile the DLL yourself and the wiki will help you with that as well. However since a number of people seem to have problems compiling themselves, I also added a compiled DLL, which I will update as needed.

    It would be nice to get feedback from people, but since I haven't received anything from this thread, I suspect something is holding back people from trying the editor. What is holding you back?

    Status right now is that I seem to have gotten rid of the bugs, the editor can be used to edit xml files. However while using it, new ideas show up, like the last one I just added. Say we have a unit and it has a tag called UnitClass. The editor setup is told it's of type UnitClassInfo and when you click it, you get a list of UnitClass types to select from (no typing). What I just added is the ability to control click and the view will jump to the UnitClass file. Next step is a back and forward setup for jumping through the files, like you can jump between Unit and UnitClass or whatever you need to modify to match.

    The project had one setback though. I can't get proper keyboard support when starting the editor in the main menu (vanilla issue?). Because of this people now have to start a game (new, load, whatever) and then open pedia (like hit F12) to get the editor. Hopefully I will at some point figure out a way to force the mod to load a specific (tiny) savegame on startup, meaning automate going from main view to the editor, meaning in reality you start directly into the editor and ideally fairly fast. However for the time being I'm focusing on getting the editor itself to work as well as possible, not streamlining how to start it.

    I'm preparing a BTS version and have a plan, which allows both Colonization and BTS to share the same source code. It should make make it easier to maintain both versions if it's a question of copying (overwriting) 4 files and nothing else. I'm not there yet though. Are there people out there who are interested in trying out the editor now, but lack Colonization?

    A post with a wall of text and no graphics is dull, so here is a screenshot of the PlayerColor selector. It will likely be made more pretty in the future, but the main point is that the editor is able to read the RGB values. It's actually reading from the mod's xml files and supports if a mod has customized the colors.
     

    Attached Files:

    KaTiON_PT likes this.

Share This Page