Platypedia

Found what looks to be a couple of minor bugs:

The first issue is in placeIndex. If an entry has no text the code to collate all the entries throws an index out of bounds error. I added the following check to get round it

Code:
lIndex = {}
for item in listSorted:
  [COLOR="DarkRed"]if not unicode(item[0]): continue[/COLOR]
  sKey = unicode(item[0])[0]
  if not sKey in lIndex:
    lIndex[sKey] = []
  lIndex[sKey].append(item)
lIndex = lIndex.items()
lIndex.sort()

The second issue is because the mod I am helping with has no Projects. This throws an index out of bounds error in the sortProjects() method, which was easy enough to resolve with the following:

Code:
def sortProjects(self, iType):
  lSorted = []
 [COLOR="DarkRed"] if gc.getNumProjectInfos() == 0: return lSorted[/COLOR]
  lItems = []
  .....

This then required another change in the placeIndex method as it doesn't handle empty arrays when processing all the different objects types. I changed this:

Code:
for item in self.sortProjects(0)[0][2]:
  listSorted.append([item[0], gc.getProjectInfo(item[1]).getButton(), "", WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROJECT, item[1], 1])
to this:
Code:
sublist = self.sortProjects(0)
if len(sublist):
  for item in sublist[0][2]:
    listSorted.append([item[0], gc.getProjectInfo(item[1]).getButton(), "", WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROJECT, item[1], 1])

to fix it.
 
Version 3.01

1) Fix to index for items with null description.
Rather than skipping those items, I decided that they should still show up in the index under " ", since they are still valid items, unless graphical only.
For instance, a project with no name, is still a project which can be built, give benefits and show up in the project pedia page itself. Thus, it should still show up in the index.

Code:
		lIndex = {}
		for item in listSorted:
			sKey = unicode(" ")
			sDescription = unicode(item[0])
			if sDescription:
				sKey = sDescription[0]
			if not sKey in lIndex:
				lIndex[sKey] = []
			lIndex[sKey].append(item)
		lIndex = lIndex.items()
		lIndex.sort()

2) Fix sorting methods for empty lists. (Ex mod with no projects)
Rather than return right at the beginning based on the gc.getNumXXXInfos(), I still let it loop through to get lItems.
A mod with no wonders can still have normal buildings, so gc.getNumBuildingInfos() will still be valid, but the list will still end up empty.

Code:
	def sortTechs(self, iType):
		lSorted = []
		lItems = []
		for iItem in xrange(gc.getNumTechInfos()):
			ItemInfo = gc.getTechInfo(iItem)
			if ItemInfo.isGraphicalOnly() and not CyGame().isDebugMode(): continue
			lItems.append([ItemInfo.getDescription(), iItem, ItemInfo.getButton()])
		if not lItems: return lSorted
		lItems.sort()

Applied to all items, for other weird mods with no bonuses, no religions, no corporations whatever.

Thanks
 
In SevoPedia anything, well almost everything, with a null description gets its TXT_KEY_ as its description. This is because it is probably something that someone forgot.

This puts these "errors" way down the list so I would put a space or underscore at the front so that it appears at the top of the index list so it can be found and fixed quickly. If you do thgis before appending the item then there is no need for special treatment in the sort.
 
This is different from what you mentioned.
When you have say a building with TXT_KEY_HOUSE as description, if the corresponding text entry cannot be found as you described, the description will display as "TXT_KEY_HOUSE".

It is when the translated text of TXT_KEY_HOUSE is null such as <english></english>, that's when the description will display as "".
 
Version 3.02

1) Modified Building Chart to display more values, such as Trade, Commerce %, Defense Modifier etc with color coding for values.

2) Modified Unit Chart in similar fashion.
 

Attachments

  • Pedia Building Chart0000.JPG
    Pedia Building Chart0000.JPG
    124 KB · Views: 220
As best as I can tell nothing ever appears in the Processes Pedia Page. I have tried this with 2 different mods and a clean mod with nothing but the Platypedia. I love this mod and just wish this portion worked correctly.
 
For some reasons, processes will only appear in ongoing games and not menu.
 
hey raen,

there you go,

compare the python folder to yours,
see the platypediaciviliztion.py
platyperdiacivics.py
and the dawn of man file,

you see that i pushed the civics info under the unique units (and renamed the header)

enjoy.

p.s. it uses the civics you created :)
 

Attachments

  • Python_uc.rar
    442.5 KB · Views: 155
hey raen,

there you go,

compare the python folder to yours,
see the platypediaciviliztion.py
platyperdiacivics.py
and the dawn of man file,

you see that i pushed the civics info under the unique units (and renamed the header)

enjoy.

p.s. it uses the civics you created :)


Many thanks! I gave it a try but still not working.

Then I tried another aproach, having same phyton as unique civics (with no platypedia), and I noticed that this doesnt work also! maybe because my mod is not modular = 1?

Maybe doesnt find the xml files?

The question is that UI doesnt change with my mod, wich suggests that someting in phyton is not working in some place.

Still going to do more tests when I can. Some clues people?

Thanks.
 
hi,
i took the unique civics that you edited raen, "more fun with civics" or something like that,
and i merged it in platy uuuu,

if you wish to merge it to your platypedia/ mod,
just compare the files you made to the ones i uploaded -
look at the platypediacivic and platypediaciviliztion,
my merges are there.
if you have trouble - upload your files here, ill take a look.
 
hi,
i took the unique civics that you edited raen, "more fun with civics" or something like that,
and i merged it in platy uuuu,

if you wish to merge it to your platypedia/ mod,
just compare the files you made to the ones i uploaded -
look at the platypediacivic and platypediaciviliztion,
my merges are there.
if you have trouble - upload your files here, ill take a look.

I got arround and arround with it and it is really strange, I tried your code in many ways. Then I simply had my mod empty of phyton and then I put phyton of uniquecivics I did in it, and doesnt work also...

Which makes me think that is something wrong with the data (xml) of my mod or because it is not modular=1.

You can help if you grab my mod (at link at my signature) and integrate unique civics in it.

I suggest you to test with only a civic and a particular civ, since I added 9 more and civilization_portugal is no more (uniquecivics.py).

Take your time, thanks in advance!
 
hi,
i took the unique civics that you edited raen, "more fun with civics" or something like that,
and i merged it in platy uuuu,

if you wish to merge it to your platypedia/ mod,
just compare the files you made to the ones i uploaded -
look at the platypediacivic and platypediaciviliztion,
my merges are there.
if you have trouble - upload your files here, ill take a look.


Many thanks for your code, I just did it, as I suspected doesnt work with:

"; Modular XML Loading
ModularLoading = 0"

Only works with ModularLoading = 1.

Therefore I am modifying my mod ti be totally modular.

Many thanks again, I just had to copy the you files platypediacivic and platypediaciviliztion. But also important o edit CvGameUtils civics screens like you did :goodjob:
 
Modules only affect xml. It shouldn't be hard to convert from modular to non modular
 
Top Bottom