A "Special" Domestic Advisor (Please try out!)

Requies

Prince
Joined
Nov 15, 2005
Messages
381
Ok, some people were asking if I could update SpecialDomesticAdvisor for patch 1.52.

So, here it is. Unfortunately, there are some issues with it (for example city selection goes rather slow and I don't use the new city jump search), but since people have asked for it, here' s one that will work ok with 1.52.

README:

Code:
Special Domestic Advisor
________________________

	This advisor came about as an offshoot of the New Domestic Advisor I created. Take a look at the readme for that file for more information.

Credits: Homegrown - for the original idea of the Better Domestic Advisor and the basis of a lot of the code changes (including combining Happiness/Unhappiness, Health/Unhealth, Food/Food Used, adding City Maintenance, and Garrison Strength, for full list see below)
	 terrasol - for the changes to the color of the text to indicate problem values and for changes which fix the non-English language problems and additional small changes
	 Arkeide - for the base code to jumping to a city on the list.
	 rendermad - for the suggestion of making garrison colored when < 1
	 =DOCTOR= - for the suggestion of putting in Culture and GP Thresholds
	 Tubby Rower - for the unfortunately unimplementable mouseover idea
	 eotinb - for the suggestion of putting in the city automation information and for some general comments and ideas
	 sportybrian - for the suggestion of highlighting with different colors for the 0, and very positive levels.

Features
________

Columns and symbol meaning (also column order from left to right). Note: symbolsand words might be different depending on any mods you might have installed or your language.
Automation	= Is the City automated in citizens and/or production and is there an emphasis on anything?
Name		= Name
Buildings 	= Landmarks
POP		= Population
Arm Flexing	= Garrison
Happy Face	= Net Happiness (Happy faces - Unhappy faces)
Red Cross	= Net Health (Health - Unhealth)
Red Bread Slice	= Turns Until City Growth
Bread Slice	= Net Food (Food - Food Used)
Hammer		= Net Production (including any bonuses)
Red Gold Piece	= Maintenance Cost
Arrow Triangle	= Trade (from all trade routes)
Commerce	= Commerce (Total Commerce gained in city)
Gold		= Total Gold
Beaker		= Total Research
Musical Note	= Culture gained per turn
TOT		= Total Culture
Figurehead	= Great Person points gained per turn
TOT		= Great Person points accumulated toward next Great Person
Producing	= (How many turns until production is done) What the city is producing

Founded		= Date Founded
Religions	= Religions in city
Specialists	= Specialists in city

Citizen Button	= Toggle from Specialist/Default Viewing Mode
Exit		= Allows you to exit the Domestic Advisor
View		= Allows you to view a selected city from the Domestic Advisor screen with a caveat (see Known Problem #2
Redraw		= Allows you to get the table back to the "original" state

Features from the NewDomesticAdvisor
	1. Removed the Capital Star from the Date
	2. Add a Religions column
	3. Add a City Garrison column
	4. Combine Happy/Unhappy/Angry into "Net Happiness"
	5. Combine Food produced/eaten into "Food Turns until Growth"
	6. Combine Healthy/Unhealthy into "Net Healthiness"
	7. Add City Maintenance Cost
	8. Add Turns til Production Complete
	9. Institute Landmarks

Landmarks are to visually represent which cities contain special buildings or special situations. Examples are Versaille/Forbidden Palace, National Wonders, Power Plants, Revolt, Occupation.

Landmarks are represented as following:
Gold Star = Palace
Silver Star = Versailles/Forbidden Palace
Bullet Point = One National Wonder
Lightning Bolt = Power Available
Fist = Occupation
Rebel = Revolt

Additional Features (including work by terrasol and Arkeide):
	10. Added coloring of text to problem values (e.g., starvation, unhealthy city, angry citizens, etc.).
	11. Added code to allow jumping to the city screen of a city on the list according to where it is on the ORIGINAL list.
	12. Added a Net Food Column in addition to the Turns Until Food Growth
	13. Actually calculated how many turns until the city will lose a person to starvation and added it to the Turns Until Food Growth column if the Net Food is negative.
	14. Added a Trade Column which lists the total trade a city takes in
	15. Separated out the Commerce and Gold columns (and changed the icons to reflect this) so that you can tell how much of each you're actually making.
	16. Removed Net Gold as it didn't really indicate how much a city was contributing.
	17. Combined the Producing and # of rounds until production is complete into one column (and instead of having it at the end like in patch 1.09, added the # of rounds to the front so that you won't miss how many turns you have left).
	18. Fixed problems with the Production column not showing the complete amount of production.
	19. Re-wrote a lot of the code so that it is easily integratable with other mods.
	20. Stretched out the Advisor so that there's a little more space for information.
	21. Added in code so that updates work (somewhat) when changing production items while in the Domestic Advisor.
	22. Re-wrote code so that it is easier to change in case of future new ideas or better access to data in cIV.
	23. Documented a LOT of the class so that it is easier for others to change.

Additional Features of Special Domestic Advisor
	24. Added in Culture and GP thresholds onto the base screen
	25. Added in a SECOND screen to allow more data to be viewed including...
	26. Added Religion back in
	27. Added Specialists and the ability to CHANGE specialists from the Domestic Advisor screen and the ability to see the RESULTS from those changes.
        28. Added in keyboard shortcuts ("V" for View city and "R" for Redraw screen)
	29. Added in documentation for the changes in CvScreensInterface so that it is easier to figure out the differences for modding.
	30. Re-wrote a LOT of code so that changing it becomes MUCH easier (yes, even more than the New Domestic Advisor).
	31. Added in city automation.
	32. Added in code so that specialists are not shown individually but grouped together.
	33. Added in coloring of neutral and great values.
	34. Added in other language support.

Installation
____________

	Special Domestic Advisor should NOT be installed in your main Civ IV location, as it will overwrite one necessary file.
        Instead, it should be installed at:  "My Documents\My Games\Civilization 4\.
	Prior to installation make sure you have upgraded to patch 1.09 as the compatibility changed when Civ IV upgraded (some functions were renamed).
	Please note that you MAY have to clear your cache once or twice before the installation/uninstallation will be complete. To do this, hold down the SHIFT button right after you launch Civ IV (i.e., double click the icon). Or go to your cache folder (for me it's My Documents\TempSettings\(UserName)\AppData\My Games\Civilization 4\cache) and delete everything from the directory (this is the recommended method).
	To install: Just unzip the zip file with the target being the above indicated directory (may be different for different languages).
	Installation will create four new files (CvSpecialDomesticAdvisor.py in subdirectory CustomAssets\python\screen, DomPyHelpers.py in subdirectory CustomAssets\python, CvReqScreensInterface.py in subdirectory CustomAssets\python\entrypoints, and Civ4AdvisorInfo in subdirectory CustomAssets\xml\text) and will create a new copy of CvScreensInterface.py in CustomAssets\python\entrypoints. To uninstall, all that is needed is to move, remove, or rename the CvScreensInterface.py from the My Documents\My Games\Civilization 4\ directory AND ANY SUBDIRECTORIES OF IT.
	Note: If you have BOTH the Special Domestic Advisor and the Exotic Foreign Advisor, install the CvReqScreensInterface.py AS CvScreensInterface.py in the aforementioned directory.
	To combine this mod to another mod, just add the new files CvSpecialDomesticAdvisor.py, DomPyHelpers.py, and Civ4AdvisorInfo to the aforementioned My Documents directory (or your mod directory) and make the changes documented in CvScreensInterface.py if you have changed it in your mod.

Known Problems
______________

1. If you choose another production item for a city to make while in the Domestic Advisor, and then you attempt to sort by Net Food, Growth, or Production, the sorting will be alphanumerically rather than by Number (i.e., "123" will be before "98" when sorting ascending). This occurs because 1) Sorting is ubiquitous to the Python modder and 2) the interface doesn't allow the Python modder access to data being displayed. As such, you need to use a key to change the correct fields. However, the only way to update using a key is through CyGInterfaceScreen's setTableTextKey method. There is NO equivalent for Ints. Therefore the sorting is by text.

Workaround: Basically, if you want to sort using those columns, exit the Domestic Advisor and come back in again. Sorting will work fine, then.

NEW: Okay, this might be fixed depending on what the response is. It should be trivial to fix what with the new behavior, but there MAY be a performance hit for it.

2. Because of the limitations specified in KP #1 above, after you sort your cities by any criteria except Date Founded ascending, you will NOT be able to correct jump to a City Screen from the Domestic Advisor.

Workaround: To jump to the City Screen. Click on the Redraw word in the lower part of the Domestic Advisor. This should set the table back to the order that the Python code can know about. After that, select the city you want to jump to and click on View, you should be able to jump to the correct city screen.

NEW: Ok, this should be feasible to implement as you just need to keep track of what sorting is being run. This is NOT trivial, however, and for now, I'm holding off on actually implementing this.

3. Clicking on one of the automation buttons or the emphasize buttons does NOT cause ANY update function to be called. I'm not sure how to update the code so that it's updated immediately when a new automation button is clicked.

Workaround: Press 'R' or the Redraw button and all the information should be updated.

Future TODO
___________

1) Create a table to keep track of sorting and keep updated with the sorts.
2) Handle updates so that each line is targeted specifically if it's updated (IOW, we don't have to modify the whole table). This requires being able to sort the cities manually or getting the information from the C++ part of the code.

History
_______

v0.93
- Made it so that it can run with patch 1.52.

v0.92
- Added in Color coding of neutral and great values
- Added in other language support
- Added in documentation in the code so it's easier to follow and modify.

v0.91
- Added in the automation for cities into the information
- Added in the counting up and grouping of specialists.
- Switched Date Founded to the Specialist View
- Cleaned up the update code in CvScreensInterface so that there's no exception just for the Domestic Advisor
- Changed the update code so that it will stop when the changed information is actually on the right number of specialists instead of if there's a change AT ALL for specialist
- Improved the speed of the update and update screen code so that the lag between a user action and the update is minimized.

v0.9
- beta version of release (might add in one more feature before final v1.0).
 

Attachments

Questions:
1) Should the Religion and Specialist spaces be cut down or is the current size ok? I'm thinking of adding in one more thing (whether a city has production/citizens automated, whether food, production, commerce, research, GP are emphasized, and whether no growth is enabled), but currently the only possible space available is from Religions and Specialist, so I want to gauge how much I can cut them down (if at all)....

2) How important is sorting AFTER an update to you (i.e., production change, IOW. Known Problem #2)? Would you want to take the possible processing hit to have it changed?

3) Any other ideas/thoughts/problems?

Hmmm, thought I had more questions, but I guess not :p.

Req
 
Ok, getting an error on load up of this version. All other versions worked totally ok.

Failed to load python module CVEventInerface.

Any ideas? Thanks!
 
AstroCat said:
Ok, getting an error on load up of this version. All other versions worked totally ok.

Failed to load python module CVEventInerface.

Any ideas? Thanks!

From the README (the new one, not the old one :p)

Please note that you MAY have to clear your cache once or twice before the installation/uninstallation will be complete. To do this, hold down the SHIFT button right after you launch Civ IV (i.e., double click the icon).

Also, if you're not quick enough, it can be more than once or twice :rolleyes:. I know because I was not quick enough a couple of times :aargh:.

The specific reason is probably because the old CvScreensInterface loaded CvNewDomesticAdvisor while this one loads CvSpecialDomesticAdvisor.

At least, that's my answer unless multiple (meaning 10+) clearings of the cache don't work :satan:.

Req
 
i've got the same error. i used the old one flawlessly.

tried reloading a dozen times,holding shift from the beginning. the "cannot load" warning comes up during the "Init Python" not "Init XML (uncached)" message, so I dont think it's related to the cache - but i dont know anything about the modding.

however, i can say i've duplicated the problem :)

i've tried running it with the old .py files in and after removing them, didnt make a difference.

ew
 
Enkidu_Warrior said:
i've got the same error. i used the old one flawlessly.

tried reloading a dozen times,holding shift from the beginning. the "cannot load" warning comes up during the "Init Python" not "Init XML (uncached)" message, so I dont think it's related to the cache - but i dont know anything about the modding.

however, i can say i've duplicated the problem :)

i've tried running it with the old .py files in and after removing them, didnt make a difference.

ew

Hmmmm, that's strange.... Can I ask you guys to do something. In your "My Documents/My Games/Civilization IV/CivilizationIV.ini" file, change "Logging enabled" to 1 and "MessageLog" to 1 (and "Overwrite Logs" to 1 if you don't want a mass of Network Logs) and tell me what the "My Documents/My Games/Civilization IV/Logs/PythonErr.txt" file says.

If it has the same message over and over, just tell me what the first part says (before it repeats itself :p).

Thanks a lot! And hopefully I'll get this up and running for you guys!

Req
 
Enkidu_Warrior said:
i've got the same error. i used the old one flawlessly.

tried reloading a dozen times,holding shift from the beginning. the "cannot load" warning comes up during the "Init Python" not "Init XML (uncached)" message, so I dont think it's related to the cache - but i dont know anything about the modding.

however, i can say i've duplicated the problem :)

i've tried running it with the old .py files in and after removing them, didnt make a difference.

ew

Oh yeah, the error WILL come up on the Init Python part. The cache hold BOTH Python AND XML data. So, just because it happens on the Init Python part does not mean that the problem is not cache related (though your trying it a dozen times and it not working does suggest that that might be the case :p).

Eagerly awaiting the contents of that file.

Req
 
well, i'm holding the shift from the moment i double-click my civ4 desktop icon, so if it is time-based, it should be clearing everything ;)

i dont know python, but the programmer in me suspects either a syntax error in an edit causing a problem with the "factory" code, or that there's another mod you have installed that allows this to work okay... but like I said, I'm far from even deserving the high praise of being called incompetent on these matters. :D

ew

edit - just saw your post, where do i find pythonerr files?

edit2 - found it:

Traceback (most recent call last):
File "<string>", line 1, in ?
File "<string>", line 52, in load_module
File "CvEventInterface", line 13, in ?
File "<string>", line 52, in load_module
File "CvEventManager", line 12, in ?
File "<string>", line 52, in load_module
File "CvScreensInterface", line 98, in ?
File "CvSpecialDomesticAdvisor", line 75, in __init__
NameError
:
global name 'help' is not defined

ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
 
Enkidu_Warrior said:
well, i'm holding the shift from the moment i double-click my civ4 desktop icon, so if it is time-based, it should be clearing everything ;)

i dont know python, but the programmer in me suspects either a syntax error in an edit causing a problem with the "factory" code, or that there's another mod you have installed that allows this to work okay... but like I said, I'm far from even deserving the high praise of being called incompetent on these matters. :D

ew

edit - just saw your post, where do i find pythonerr files?

"My Documents/My Games/Civilization IV/Logs/PythonErr.txt"
 
just in case you missed it, i cross posted the log as an edit to my previous post...

ew
 
Enkidu_Warrior said:
just in case you missed it, i cross posted the log as an edit to my previous post...

ew

Awww, crap.

Just some of my debugging code, though it's strange why help doesn't work for you guys since it's native to Python (shrug).....

Ok, I'll load up a new file without the debugging code, and hopefully that's the only problem there'll be.

Req
 
got it, worked first time. happy to be a guinea pig, i love your work! thanks for the quick fix!

ew
 
Just curious... why couldn't the "praying hands" be the religious specialist symbol. Also what happens when a GP is added as a super-specialist. Does he show up?
 
Back
Top Bottom