How to add a new page to sevopedia?

NotSoGood

Emperor
Joined
Jan 25, 2009
Messages
1,077
Location
Finland
This is part of my sevopedia improving where I'm trying to modify the sevopedia how I would like it to be. But now I have stumbled into a problem adding a new page to sevopedia. I want there to be a Traits page. I've tried to look for tutorials, but haven't found any and basicly I have no idea how to do this. I would appreciate someone's help very much.
 
I remembered that dale added a new page to civilopedia so I took a look into RoM's SDK and found dales comments there. But I didn't notice any definitions to traits page, so how is it possible to add a new screen to civilopedia without modding the DLL?
 
I added a Traits page to the Sevopedia for BUG. You could try yanking it from there, but beware that it makes use of a new Python module--TraitUtil.py--and may be tied a bit to BugUtil.py. TraitUtil allows you to register an icon (font glyphs/symbols) and button for each trait. These show up in the list of traits and on the page itself. I also pulled in Sisiutil's strategy text for the pedia entries.
 
I remembered that dale added a new page to civilopedia so I took a look into RoM's SDK and found dales comments there. But I didn't notice any definitions to traits page, so how is it possible to add a new screen to civilopedia without modding the DLL?

I guess you could add a page without SDK changes, but it wouldn't function like the Concept Pages, which is what you are looking for. Basically, you need SDK changes.

If you are ready to take the plunge:

I'd look at the RevDCM sources & RoM Python to see exactly how to mimic it, but here's a run down of the SDK files that need editing:


  • CvDLLWidgetData
  • CvEnums
  • CvGlobals
  • CvXMLLoadUtilitySet
  • CyEnumsInterface
  • CyGlobalContext
  • CyGlobalContextInterface3
Most of those files will need changes to the cpp and header file, be warned.

Now the Python Files that will need additions (I'm assuming you are using BUG, if not, it will be different):


  • SevoPediaHistory
  • SevoPediaIndex
  • SevoPediaMain
  • SevoPediaEnums
  • CvScreensInterface
  • CvPediaHistory
  • CvPediaMain
  • CvScreensEnum

There may be one or two files I missed, I hope not.


Also, you are going to need to do a fair bit of Schema/XML work, since you will be creating an entirely new XML file. Luckily, It isn't too hard. You can pretty much copy-n-paste Dales work.
 
Maybe I misunderstood. NotSoGood, are you talking about Leader Traits like Aggressive, Spiritual, and Expansive? If not, ignore my post. Though you might find some ideas in BUG.
 
I added a Traits page to the Sevopedia for BUG. You could try yanking it from there, but beware that it makes use of a new Python module--TraitUtil.py--and may be tied a bit to BugUtil.py. TraitUtil allows you to register an icon (font glyphs/symbols) and button for each trait. These show up in the list of traits and on the page itself. I also pulled in Sisiutil's strategy text for the pedia entries.
Oh, that explains why I didn't find it from the SDK files. :D But unfortunately I'm not using BUG in my mod, so I don't think I can use it.
I guess you could add a page without SDK changes, but it wouldn't function like the Concept Pages, which is what you are looking for. Basically, you need SDK changes.
What do you mean with "Concept Pages"?
Also, you are going to need to do a fair bit of Schema/XML work, since you will be creating an entirely new XML file. Luckily, It isn't too hard. You can pretty much copy-n-paste Dales work.
Why do I need to create a new xml file if I'm just going to add a page for Leader Traits? :confused: I thought civilopedia pages are created in python/DLL. Seems I'm kinda lost here. :help:
Maybe I misunderstood. NotSoGood, are you talking about Leader Traits like Aggressive, Spiritual, and Expansive? If not, ignore my post. Though you might find some ideas in BUG.
That's exactly what I would like to have. :yup:
 
I looked at BUG's module, and you're in luck. SevoPediaTrait.py uses only TraitUtil.py from BUG, and that module doesn't need any BUG stuff at all. You'll also need the code to deal with traits that's in BUG's SevoPediaMain.py.

You could probably use that module as well to get the index without too much editing. It uses BugUtil (you can delete every line that calls BugUtil.debug() to remove that requirement) and BugCore (again, remove that line). The options that need it are referenced in only one place: isSortLists(). Just return True or False from that function as you wish.

Finally, you'll need to grab some stuff from a couple of BUG's XML files:

  • CIV4NewConceptInfos.xml - This lists each of the traits and links them to their civilopedia entry. Even if you don't want Sisiutil's strategy text, you need these entries. Just leave the civiolopedia texts empty.
  • TraitsPedia_CIV4GameText.xml - Sisiutil's strategy text.
 
I looked at BUG's module, and you're in luck. SevoPediaTrait.py uses only TraitUtil.py from BUG, and that module doesn't need any BUG stuff at all. You'll also need the code to deal with traits that's in BUG's SevoPediaMain.py.

You could probably use that module as well to get the index without too much editing. It uses BugUtil (you can delete every line that calls BugUtil.debug() to remove that requirement) and BugCore (again, remove that line). The options that need it are referenced in only one place: isSortLists(). Just return True or False from that function as you wish.

Finally, you'll need to grab some stuff from a couple of BUG's XML files:

  • CIV4NewConceptInfos.xml - This lists each of the traits and links them to their civilopedia entry. Even if you don't want Sisiutil's strategy text, you need these entries. Just leave the civiolopedia texts empty.
  • TraitsPedia_CIV4GameText.xml - Sisiutil's strategy text.

That's great! I'll look at it. :goodjob:
BTW, I did some tests and actually managed to create a new page without any changes in SDK, but sadly it won't do anything. I just copied things from leader head page, but I might get it work if i take a look into BUG's python files.
 
Somehow I can't get it work. I get python error when trying to wiew the traits page
Code:
Traceback (most recent call last):

  File "CvScreensInterface", line 211, in pediaMain

  File "CvPediaMain", line 211, in pediaJump

  File "CvPediaMain", line 443, in placeTraits

  File "CvPediaMain", line 447, in getTraitList

  File "CvPediaMain", line 687, in getSortedList

AttributeError: 'NoneType' object has no attribute 'getDescription'
ERR: Python function pediaMain failed, module CvScreensInterface
Seems like I'm passing a null here
Code:
	def getTraitList(self):
		return self.getSortedList(gc.getNumNewConceptInfos(), self.getTraitInfo)
I copied lots of the code from BUG and most likely did something wrong. I copied the TraitUtil and SevoPediaTrait to my mod, i had to do some minor changes to the SevoPediaTrait file to get it work. I just changed the imported files. I also copy-n-pasted parts of the SevoPediaMain into mine.

The problem might actually be here
Code:
	def getTraitList(self):
		return self.getSortedList(gc.getNumNewConceptInfos(), self.getTraitInfo)

	def getTraitInfo(self, id):
		info = gc.getNewConceptInfo(id)
		[B]if self.isTraitInfo(info):[/B]
			
...
			
			[B]return TraitInfo(info)
		return None[/B]
	
	def isTraitInfo(self, info):
		return info.getType().find("_TRAIT_") != -1
It checks if it's trait info and if not returns none. Any ideas?
 
Did you copy SevoPediaMain's modified getSortedList() function from BUG? That function checks that each element is not None before adding it to the list.
 
Did you copy SevoPediaMain's modified getSortedList() function from BUG? That function checks that each element is not None before adding it to the list.

Oh, missed that. Testing...

EDIT: It seems to require also this
Code:
	[B]def isSortLists(self):
		return AdvisorOpt.SevopediaSortItemList()[/B]

	def getSortedList(self, numInfos, getInfo, noSort=False):
		list = []
		for i in range(numInfos):
			item = getInfo(i)
			if item:
				list.append((item.getDescription(), i))
		if [B]self.isSortLists()[/B] and not noSort:
			list.sort()
		return list
But AdvisorOpt is BUG advisor. So should I just remove the isSortList() part like this?
Code:
	def getSortedList(self, numInfos, getInfo, noSort=False):
		list = []
		for i in range(numInfos):
			item = getInfo(i)
			if item:
				list.append((item.getDescription(), i))
		if not noSort:
			list.sort()
		return list
Sorry if that's a stupid question, I'm not to good with python.

EDIT2: But if I do it that way, when getTraitList calls it, it skips totally that list.sort(). What does that part do?
 
:woohoo: :woohoo: [party] It works! :king: <----Ignore this, it doesn't work
It was so close and so minor change needed, but still it took so long. :D I attached a screen shot of it. I know, it requires still some fixes but now it's easier to concentrate to aesthetic issues.
But one thing is weird, why it doesn't show my own traits. :confused: I did put them in the TraitUtil
Code:
	addTrait("AGGRESSIVE", game.getSymbolID(FontSymbols.STRENGTH_CHAR), "Art/Interface/Buttons/Promotions/Combat1.dds")
	addTrait("CHARISMATIC", game.getSymbolID(FontSymbols.HAPPY_CHAR), "Art/Interface/Buttons/TechTree/MassMedia.dds")
	addTrait("CREATIVE", gc.getCommerceInfo(CommerceTypes.COMMERCE_CULTURE).getChar(), "Art/Interface/Buttons/TechTree/Music.dds")
	addTrait("EXPANSIVE", game.getSymbolID(FontSymbols.HEALTHY_CHAR), "Art/Interface/Buttons/Actions/Heal.dds")
	addTrait("FINANCIAL", gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getChar(), "Art/Interface/Buttons/TechTree/Banking.dds")
	addTrait("IMPERIALIST", game.getSymbolID(FontSymbols.OCCUPATION_CHAR), "Art/Interface/Buttons/Actions/FoundCity.dds")
	addTrait("INDUSTRIOUS", gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar(), "Art/Interface/Buttons/TechTree/Industrialism.dds")
	addTrait("ORGANIZED", game.getSymbolID(FontSymbols.TRADE_CHAR), "Art/Interface/Buttons/Buildings/Courthouse.dds")
	addTrait("PHILOSOPHICAL", game.getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR), "Art/Interface/Buttons/TechTree/Philosophy.dds")
	addTrait("PROTECTIVE", game.getSymbolID(FontSymbols.DEFENSE_CHAR), "Art/Interface/Buttons/Promotions/CityGarrison1.dds")
	addTrait("SPIRITUAL", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")
	addTrait("AGRICULTURAL", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")
	addTrait("INFLUENTIAL", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")
	addTrait("NOMADIC", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")
	addTrait("SCIENTIFIC", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")
	addTrait("FANATIC", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")
	addTrait("SEAFARING", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")
	addTrait("SPY", game.getSymbolID(FontSymbols.RELIGION_CHAR), "Art/Interface/Buttons/TechTree/Meditation.dds")
Do they have to be somewhere else too?

EDIT: It's getting weird. Somehow BUG's war Guide is in my mod same with the trait texts. I don't remember adding them. :confused:

EDIT2: The BUG in custom assets was over writing my mod's files. But when I remove the BUG, the traits page doesn't work anymore, but I don't get any python errors. :sad:
 
Finally, you'll need to grab some stuff from a couple of BUG's XML files:

  • CIV4NewConceptInfos.xml - This lists each of the traits and links them to their civilopedia entry. Even if you don't want Sisiutil's strategy text, you need these entries. Just leave the civiolopedia texts empty.
  • TraitsPedia_CIV4GameText.xml - Sisiutil's strategy text.

I can't find that file from BUG. :confused: And seems like none of the other files does what you describe. Are you sure it should be there?
 
Yes, I should probably have started with the background on this, but it was hazy. We had to stuff extra stuff we wanted in the pedia into NewConceptInfos to avoid rewriting a lot of the pedia code. There was already a mechanism for this, so it seemed logical.

Actually, the reason we went that route is we needed to be able to attach pedia text to each trait, and I didn't want to modify the TraitInfo (SDK). Of course that could have gone into TraitUtil just as easily. :( Maybe I should redo that part as having to create NewConcepts for each trait is silly.
 
Actually I still have a question, how do I change the icons and buttons to be shown properly for traits in TraitUtil? I think I have an idea how it needs to be done but I'm not sure.
Code:
	addTrait("AGGRESSIVE", [COLOR="Blue"]game.getSymbolID(FontSymbols.STRENGTH_CHAR)[/COLOR], [COLOR="Red"]"Art/Interface/Buttons/Promotions/Combat1.dds")[/COLOR]
The blue part seems to define the icon shown in the sevopedia where I right now have the (*). And the third part adds the button shown in the trait's page. Am I right?
But where does that second part get the icon, because it doesn't show them right in my mod? And will the button path work if I just put there a path to a button in art folder? Just to be sure.
 
Ah yes, you'll need to add a little to your blue code:

Code:
unicode(<blue-code-here>)

of if that doesn't work

Code:
u"%c" % <blue-code-here>

The button art path should be okay there since that's what I'm using, only from a getButton() function call, right?
 
Ah yes, you'll need to add a little to your blue code:

Code:
unicode(<blue-code-here>)

of if that doesn't work

Code:
u"%c" % <blue-code-here>
So you suggest it to look like this
Code:
def init():
	"Performs one-time initialization after the game starts up."
	game = gc.getGame()
	global GENERIC_ICON
	GENERIC_ICON = u"%c" % game.getSymbolID(FontSymbols.MAP_CHAR)

	[COLOR="Red"]addTrait("AGGRESSIVE", unicode(<game.getSymbolID(FontSymbols.STRENGTH_CHAR)>), "Art/Interface/Buttons/Promotions/Combat1.dds")[/COLOR]
The button art path should be okay there since that's what I'm using, only from a getButton() function call, right?
Well I assume they point to the buttons that are in normal civ, but have no idea why they don't show up. :dunno:

EDIT: No, doesn't work that way, I get a syntax error. Mayby I misunderstood you.
 
You have a syntax problem: You should not actually have any pointy brackets in there. In the examples, they are part of what should be replaced with your code.

So
Code:
unicode(game.getSymbolID(FontSymbols.STRENGTH_CHAR))
not
Code:
unicode(<game.getSymbolID(FontSymbols.STRENGTH_CHAR)>)
 
The < and > were just meant to make the description stand out. Remove them:

Code:
unicode(game.getSymbolID(FontSymbols.STRENGTH_CHAR))

[Ninja'd by God-Emperor while I was writing the BUG tutorial.]

As for the buttons, I have no idea why they would show up fine in BUG but not in your version. These images are available in the normal game, as you said. :confused:
 
Back
Top Bottom