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

Customizable Domestic Advisor - comments welcome

Discussion in 'Civ4 - Mod Components' started by Taelis, Dec 27, 2005.

  1. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    Inspired by the fantastic work of Homegrown and Requies, I thought I'd try to extend what they've done and add in game customization - including the ability to add new pages, to add and remove columns from pages, and change the order and width of columns, all from within the advisor itself.

    Version 0.93 is ready - this release fixes "Failed to load python module CvEventInterface" errors, adds support for exchanging configuration files across languages, and prevents an incompatiblity in the C++ API between the specialists buttons and resource icons.

    The first time you run this, don't use any mods. If mods are active the first time the domestic advisor is loaded the default pages will have the wrong columns for buildings.

    README information is actually contained in CvDomesticAdvisor.py itself, so it can never be seperated or lost. ;)

    Editions
    I've tried to create two independent editions of the advisor - a "flavorful" one for those who'd like to remain immersed in the game, and a purely functional one for those who enjoy looking "under the hood". At the moment, the only differences between the two are the initial pages created when the advisor is first installed, and that the flavorful version hides most of the customization buttons until you click on the first one.

    If you've already installed a previous version of the advisor and saved customizations, those customizations will be retained. That also means neither edition will create the default pages, so in that case the only difference is the visibility of the customization buttons.

    Features

    All the improvements Homegrown and Requies made (thanks, guys!), plus:

    Customizable tables
    Independent columns for production and turns remaining for easy sorting
    Support for the city zoom button from patch 1.52
    Correct sorting by date founded
    Accurate city selections in sorted lists
    City rankings
    Real advice (which still needs more work!)​

    New columns

    Threats, which displays an angry icon if enemy units are nearby
    Defense bonus, including terrain and bombardment
    X and Y location
    "Real" population (the "population" displayed on the info screen)
    Best conscript unit, and best potential conscript
    Electric power
    National city ranks
    Global city ranks
    Can hurry (both slavery and gold)
    All the buildings and wonders
    All the resources
    Advisors (VERY basic at the moment - consult at your own risk!)​

    Buildings

    This advisor includes fields for all the buildings, National Wonders, and World Wonders, with their effects. For example, the advisor displays a food icon for a granary (saved food). It also displays a health icon if the city has a granary AND rice, wheat, corn, or bananas connected; and the health icon disappears if the last of those resources is lost.

    The following information is available for buildings:

    Working building - (see the next list)
    No known benefits - "+"
    In production - the icons from the list below surrounded by "()"
    Obsolete - "X"
    Can't be built - "-"
    Just not there - blank​
    Effects displayed:

    Bread slice - stored food or extra food from water tiles
    Gold star on the left - capital
    Silver star - other government center (e.g. Forbidden Palace, Versailles)
    Gold star on the right - World Wonder or shrine
    Religion icons - religious buildings
    Flexing arm - free experience or promotions for new units
    Keep (defense icon) - land, air, or nuke defense bonus
    Red cross - health bonuses
    Happy face - happiness bonuses
    Lightning bolt - electric power
    [Angry person] - reduced war weariness or anarchy
    Music note - culture bonus
    Gold - gold bonus
    Beaker - research bonus
    Hammer - increase production (general or specific)
    3 Arrows (trade icon) - extra trade routes or increased trade income
    Coin - reduced maintenance
    Green sick face - unhealthiness
    Figurehead - great person points​

    None of this is hardcoded, so the advisor should work with any mod, even fantasy mods and others that redefine the game. It will even display new fields for the buildings from a mod and hide the fields for buildings from the original game.

    Installation

    To install this mod, simply copy CvDomesticAdvisor.py to CustomAssets\python\screens in your personal Civ4 folder. Don't copy it to Assets\python\screens - the original will be gone and future patches will overwrite this file.

    If you've installed another domestic advisor that modifies CvScreensInterface.py, you'll need to remove it. Usually you can just delete CvScreensInterface.py from CustomAssets\python\screens. DO NOT delete CvScreensInterface.py from the main CivIV Assets\python\screens folder, or the game won't work! :eek:

    Controls

    The controls along the bottom of the advisor interface, from left to right, are:

    Page selection drop-down list
    Customize columns on page
    Rename active page
    Add new page
    Remove active page
    Save current configuration
    Restore last saved configuration​

    The controls on the customization interface, from left to right, are:

    Shrink column(s)
    Widen column(s)
    Promote selected column(s) (moves them toward the left on the main interface)
    Demote selected column(s) (moves them toward the right on the main interface)
    Add column(s) (adds all columns selected in the list on the right side)
    Remove selected column(s)​

    Columns
    Spoiler Columns :

    NAME - The name of the city
    AUTOMATION - What's automated in the city?
    BASE_COMMERCE - Base (unmodified) commerce/turn (of all kinds)
    CONSCRIPT_UNIT - The best unit the city can conscript
    COULD_CONSCRIPT_UNIT - The best unit the city could conscript, if it could conscript
    CULTURE - Total culture
    CULTURE_RATE - Culture/turn generated
    DEFENSE - Defense bonus
    FEATURES - Capital, national Wonders, disorder, and trade status
    FOOD - Surplus food/turn
    FOUNDED - Date founded
    GARRISON - Number of military units in the city
    GOLD - Gold/turn generated
    GREATPEOPLE - Total great people points
    GREATPEOPLE_RATE - Great people points/turn
    GROWTH - Turns until the city grows
    HAPPY - Extra happiness in the city (above the current population)
    HEALTH - Extra health in the city (above the current population)
    LOCATION_X - Horizontal location of the city
    LOCATION_Y - Vertical location of the city
    MAINTENANCE - Maintenance costs/turn
    POPULATION - Population of the city
    POPULATION_REAL - Population of the city in "real" numbers
    POWER - Does the city have power?
    PRODUCING - What's being built?
    PRODUCING_TURNS - How long will it take?
    PRODUCTION - Hammers/turn
    RELIGIONS - Religions present in the city
    RESEARCH - Beakers/turn generated
    SPECIALISTS - What kind of specialists are in the city?
    THREATS - How many enemy units are in the area?
    TRADE - Income from trade routes

    Plus columns for every building, National Wonder, and World Wonder


    Known Issues

    Forges, factories, and the Ironworks aren't displaying hammer icons, and nuclear plants aren't displaying power icons. And forges, factories, etc. display single unhealthy faces even after recycling centers are built. I'm working on it. ;)

    When changing the width or order of columns, the first selected column description scrolls to the top.

    Triggering a Python module reload (by changing a Python file for example) with the game running causes the advisor to go blank, and lose any unsaved customizations. Unless you're modding with Python, you'll probably never run into this. If you are, be sure to save any customizations before changing Python files. And simply close the advisor and press F1 again to fix any funkiness.

    If a mod that changes buildings is active the first time the Domestic Advisor is loaded, the wrong buildings are displayed on the default pages.

    History

    Version 0.90 - Dec 27, 2005:
    Initial public beta​

    Version 0.91 - Dec 28, 2005:
    Fixed automation and culture columns, and added ranking, hurry, and advice columns.
    Added a more "flavorful" edition​

    Version 0.92 - Dec 29, 2005:
    Fixed a few issues with non-English support
    Fixed the display of national wonders in mods
    Added columns for the resources​

    Version 0.93 - Dec 29, 2005:
    Fixed a "failed to load python module CvEventInterface" error
    Added support for exchanging configuration files across languages​
     

    Attached Files:

  2. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    Screenshots

    1. The main page, based on Homegrown's. The flavorful edition calls this "Executive Summary"
    2. A specialists page, like Requies'. The flavorful edition calls this "Specialization"
    3. The growth page - this and a fourth page are created when the functional advisor is installed, but can easily be changed or removed.
    4. The customization interface.
    5. "Top Cities - Global". - Global city rankings. See how your cities compare to your rivals'. This page is only created by the flavorful edition, but all the fields are also available in the functional edition.
     

    Attached Files:

  3. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    How to Customize It

    General

    Save Changes: The fifth button in the bottom left corner saves your changes.

    Cancel Changes: The sixth button in the bottom left corner reloads your last saved configuration, or the initial configuration if you've never saved one.

    Pages

    Choose Pages: The drop down list in the bottom left corner selects the active page.

    Rename Page: The second button in the bottom left corner brings up a popup that allows you to rename the active page.

    Add Page: The third button in the bottom left corner (the + sign) adds a new page.

    Remove Page: The fourth button in the bottom left corner removes the active page.

    Fields

    The customization screen includes two tables. The table on the left side lists the fields that will be displayed on the selected page. The table on the right side lists all available fields.

    Start Customizing Fields: Click on the first button in the bottom left (the scroll) to start customizing fields. Click on it again to finish and view the results.

    Add Fields: Choose one or more fields from the table on the right and click on the third button in the upper row of buttons (the + sign) to add the selected fields to the active page.

    Remove Fields: Choose one or more fields in the list on the left and click on the fourth button in the upper row (the - sign) to remove the selected fields from the selected page.

    Shrink Fields: Select one or more fields in the list on the left and click on the first button in the upper row (the arrow pointing left) to make all the selected fields narrower.

    Expand Fields: Select one or more fields in the list on the left and click on the second button in the upper row (the arrow pointing right) to make all the selected fields wider.

    Promote Fields: Select one or more fields in the list on the left and click on the fifth button in the upper row (the arrow pointing up) to promote all the selected fields, which moves them to the left on the page.

    Demote Fields: Select one or more fields in the list on the left and click on the sixth button in the upper row (the arrow pointing down) to demote all the selected fields, which moves them to the right on the page.

    Advanced

    The advisor's configuration is saved in a file called CustomDomAdv.txt in the main Civ4 directory (usually C:\Program Files\Firaxis Games\Sid Meier's Civilization 4).

    You can copy this file to a different computer to transfer configuration (this requires the same version of the domestic advisor on both computers, naturally).

    You can also delete this file to force the domestic advisor to restore the default pages.
     
  4. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    Featured Customizations
     

    Attached Files:

  5. NeverMind

    NeverMind Proud to be Russian

    Joined:
    Apr 29, 2005
    Messages:
    618
    Gender:
    Male
    Location:
    Moscow, Russia
    That looks nice. I'll try it in my next game for sure. :)
     
  6. Impaler[WrG]

    Impaler[WrG] Civ4:Col UI programmer

    Joined:
    Dec 5, 2005
    Messages:
    1,750
    Location:
    Vallejo, California
    It just keeps getting better and better I too will give this thingy a whirl :D
     
  7. Cammagno

    Cammagno King

    Joined:
    Dec 15, 2005
    Messages:
    712
    Location:
    Genoa (Italy)
    I've tried it a bit and... it is wonderful! :)
    I'm very surprised that you have managed to obtain such a result using a single file: you are great!

    I suggest to put into the zip a readme file with all the useful information you have given us in this thread.
    I also suggest (if this is possible) to choose a different location for the CustomDomAdv.txt, not into the main Civ4 directory. I think that it's better to put it into My Doccuments\My Games\Sid Meier's Civilization 4\ (maybe into ...\Saves\??? ).

    I've noted a minor (very little indeed) bug (but it may depend on some problem with my Italian localization). The title for the Automation column is wrongly reported as: "TXT_KEY_DOMES...".

    Thanks for your great work :)
     
  8. Cammagno

    Cammagno King

    Joined:
    Dec 15, 2005
    Messages:
    712
    Location:
    Genoa (Italy)
    Another suggestion: it will be wonderfull if instead of the names of the buildings (or before them), it is possible to have as title of the columns their icons, as it is in the "ModifiedSpecialDomesticAdvisor" mod. So one can reduce the size of their columns to be able to have more of them in the same page.

    Obviously instead of this (and even better), it will be great to have the possibility to introduce as many columns as one desires, being able to scroll them with an arrow (again, as in the "ModifiedSpecialDomesticAdvisor" mod) if the resulting total size is greater of the page's one.
     
  9. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    You're welcome. I just started making a few minor changes, and discovered lots of advanced Python toys to play with, and couldn't stop programming. Python's come a long way since the last time I used it. :lol:

    I appreciate the feedback (from everyone), I'm still into this project and will probably spend a couple more days making it perfect. Right now I'm thinking about adding actual ADVICE - recommendations, things that need attention, maybe even info about the possible development of a city.

    I'm not entirely sure how to safely move the configuration file, but you're right, the personal folder would be better, if I can do it.

    And thanks for the info about the automation column - I didn't realize that text was coming from Requies' XML file.

    Being Italian, would you prefer having localized column names, or a single file for the mod? I'm not sure I want to add an XML file - especially after hearing all the trouble people have with the cache!

    More great ideas - thanks! I'll take a look at the "ModifiedSpecialDomesticAdvisor" mod.
     
  10. Cammagno

    Cammagno King

    Joined:
    Dec 15, 2005
    Messages:
    712
    Location:
    Genoa (Italy)
    Oh, obviously this isn't an important matter, just an idea, to leave the file in the same directory where all other personal configurations are. But otherwise it works great as it is, so if it's a problem to realize it in a safe way, it can stay as it is now :)


    These are great ideas :)
    It will be very good if the new version of the mod will be somehow compatible with the CustomDomAdv.txt generated by the previos ones, so who (like me :lol: ) has spent the full afternoon customizing the mod doesn't have to bang their head on the wall :crazyeye:
    Obviously I'm joking ;) If the improvement of the mod requires the non-compatibility, it's ok, of course!

    Oh, I strongly prefer the way as it is now, I don't bother localization, particulary if this has to cause a more complex structure of the needed files. Furthermore, the titles of the columns are in Italian right now :D
    with the exception of the "new" ones (such as "threats")... so it's ok as it is, IMHO.

    Thanks again for your work! (And sorry for my not-so-good English)
     
  11. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    Don't worry, any future versions will be fully backwards compatible. Even if I make a lot of huge changes, I can still fix the configuration when I read it from the file. ;)
     
  12. Cammagno

    Cammagno King

    Joined:
    Dec 15, 2005
    Messages:
    712
    Location:
    Genoa (Italy)
    Great! ;) ;)

    Possible bug: the column of the "Cultural rating per turn" doesn't show any value, it remain blank; I've noted that it's the same also in your screenshot.
     
  13. terrasol

    terrasol Chieftain

    Joined:
    Jun 20, 2004
    Messages:
    33
    i have a probelm with this
    if i try to use it,the game exit with following error
    Runtime Error...pure virtuale call...R6025

    i hope this helps you
     
  14. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    Are you using patch 1.52, and is the saved game from patch 1.52? I hope that's the problem, because I've seen this error before, but only once with an old game.

    Edit: Nevermind, I think I found it. Were you using the specialist buttons when that crash occurred?
     
  15. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    Version 0.91 is ready (see above). I fixed the automation and culture columns (thanks Cammagno!) and I believe I fixed the crash you saw terrasol. :)
     
  16. Cammagno

    Cammagno King

    Joined:
    Dec 15, 2005
    Messages:
    712
    Location:
    Genoa (Italy)
    I've tried it, and I confirm that it solves the two minor bugs of automation and culture ;)
    There is a problem, though. Now, the personalization window (the one in which one can choose the columns and regulate their size) appears as a sort of "demi-trasparent layer" over the normal page, making difficult to read and to use it. :confused: This happens with both the new editions (the functional one and the flavorful one).

    About the "flavorful" edition, I haven't managed to understand how to personalize it. But maybe it's intended as a "view only" edition: one can use the functional edition to personalize the configuration file and then switch to the flavorful edition for the normal game use. But in this case, what's the utility of the personalizing button if, clicking it, one can only see the list of the columns but can't change them? If this is the case, maybe it's better to completly remove the personalization botton from the flavorful edition. But I don't know if I've understood the true meaning of the flavorful edition... :confused:

    Thanks for yor attention
     
  17. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    That probably indicates there was a Python error, so the script wasn't able to finish displaying the customization screen. It's strange that you see that error but I do not - would you be willing to enable Python logging?

    If you would, in the config file, change ShowPythonDebugMsgs to 1. That will popup messages in the game if any Python errors occur.

    Or change both LoggingEnabled and OverwriteLogs to 1, which will create a log file in My Games\Sid Meier's Civilization 4\Logs called PythonErr.log.
     
  18. Cammagno

    Cammagno King

    Joined:
    Dec 15, 2005
    Messages:
    712
    Location:
    Genoa (Italy)
    Well, the log says:

    #####
    Traceback (most recent call last):
    File "CvScreensInterface", line 545, in handleInput
    File "CvDomesticAdvisor", line 1850, in handleInput
    File "CvDomesticAdvisor", line 1935, in ModifyPage
    File "CvDomesticAdvisor", line 1061, in drawScreen
    File "CvDomesticAdvisor", line 1661, in drawContents
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)
    ERR: Python function handleInput failed, module CvScreensInterface
    #####

    The customization screen appears and it's usable (I mean, I can scroll the lines, for example), but without buttons (there are only the main buttons, thouse in the inferior part of the window) and this screen is semi-trasparent, (I see the normal page "under" it).
    I've tried to put the old file in, and it works normaly (meaning: no "trasparent effect"); then I've tried with the new one again, and that strange effect is back in. :confused:

    Note: using the old version, the log is empty, no error is reported.
     
  19. terrasol

    terrasol Chieftain

    Joined:
    Jun 20, 2004
    Messages:
    33
    with v0.91 it was better but the growth-page was empty, i tried to change something there(in customization) and then i got the same error before
     
  20. Taelis

    Taelis Warlord

    Joined:
    Dec 1, 2005
    Messages:
    112
    Thanks for that log - as I thought, that indicates that a localized string is causing trouble.

    It's clear what's happening now, but not how to fix it. But I'll have version 0.92 with this fixed (plus some other minor changes) soon. :)
     

Share This Page