Platypedia

Yes. I do not know if you remember , but I use the old code of the original group who worked on the NW . Up to now I added your code - complete - including Platypedie . Old group features I use for my new system victories . Your code placed on a map of additional features . Buildings which adds your system to the cities are great. Amazing idea.

All what I need now is a page in Platypedie what display features called FEATURE_HROCH_xyz

and

Page National Palaces what display building BUILDING_HROCH_xyz.

It is possible, please?
 
Doable, but nowadays I don't have time for personal requests.
 
I understand. I tried it , but without success. My brain is constantly ignores the intricate corners of python. :(

I have wait , or try a general request in the first thread?
 
Well, frankly speaking, I doubt anyone else has experience creating a new page with my pedia.
It is much more tedious compared to Sevo, because sorting is involved, as well as links which Sevo got rid of, resulting in the 2 column layout.

Hence, posting in a general request thread won't help much.
There are directions on how to add a new page directly on the second post, though I don't think anyone bothered to try.
 
I understand . I thought , is it so :)
I'll be patient.
I hope you find time for me .
From my first query to a new page in pedia passed more than a year. I think I Can I still wait :) :)
Thanks for you answer :)
 
I understand . I thought , is it so :)
I'll be patient.
I hope you find time for me .
From my first query to a new page in pedia passed more than a year. I think I Can I still wait :) :)
Thanks for you answer :)
 
great work platy.

anyway my concerns. when sorting the list of leaders by civilization, two issues:

1. it's not sorted alphabetically by civilization. official civs are place alphabetically in the XML. but doesn't take into account custom civs. which brings us to issue #2:
2. custom civs not shown properly. custom civs are placed at the end, however, their civ names are replaced by the titles "minor civs" and "barbarians".

so i created a solution, which is pretty simple once i got the hang of sorting in python. this will sort all playable civs, including custom civs (not minor civs and barbarians), alphabetically in the leaders list. it also works for sorting by traits.

i tried to apply the same solution to sorting by favorite religion alphabetically. however, two other issues:

3. some civs don't have a favorite religion, i.e. possible null reference when grabbing the description.
4. i still don't have a good grasp of python arrays and subsets, etc. solution should work once i learn this. so i can sort the religions but ignore the ones in issue #3.

let me know if you want to put this in your official releases. quite simple and elegant, if i do say so myself.
 
Version 2.21

1) Fix Leaders sorting via Civilizations to be displayed under wrong Civilizations for Modular Civilizations. (Didn't test, but should fix)

2) Civics sorting via Era now display those without techs as None rather than Ancient, just to standardize.

P.S.
Actually, none of the category headings are sorted alphabetically, not just sorting via Civs or Religions. They are all displayed via their ID directly, for simplicity sake :D

There are situations where the category headings should be sorted alphabetically, such as civ, traits and fav religions you mentioned, plus others like unit combats, fav civics, domain.

Yet some category headings should remain sorted via ID, such as Era, Civic Option, Upkeep.

But for those which should be sorted alphabetically, "None" should still remain out of the sorting.

Which is why, to standardize, I didn't bother to do extra work, (ahem or a bit lazy) to sort just certain category headings.

I can look at your solution though, to see what to do with "None"
 
the main idea is to add a temporary item to the leaders sub-lists which acts as the section header. when the list is printed, that item is popped (simultaneously removed and stored in a variable). the remaining items in the list are the leaders.

here is the code for sorting leaders by civilization (in def sortLeaders() in PlatyPediaMain.py):

Code:
		if iType == 1:
			lList0 = []
			for iCivilization in xrange(gc.getNumCivilizationInfos()):
				CivInfo = gc.getCivilizationInfo(iCivilization)
				if CivInfo.isGraphicalOnly(): continue
				if not CivInfo.isPlayable(): continue
				lItem = []
				## CA START
				lItem.append(CivInfo)
				## CA END
				for item in lList:
					if CivInfo.isLeaders(item[1]):
						lItem.append(item)
				lList0.append(lItem)
			## CA START
			lList0.sort(key=lambda x: x[0].getDescription() )
			## CA END
			return lList0

My additions are in between the ## CA START and ## CA END. In this case, I add the CivInfo to the top of lItem. Then before returning the whole list lList0, sort it by that same item we just added. This works the same for Traits.

then when we print the leaders lists (in both PlatyPediaMain.py and PlatyPediaLeader.py), we use this code:

Code:
				if self.iSortLeaders == 1:
					## CA MODIFIED START
					CivInfo = list.pop(0)
					sList = CivInfo.getShortDescription(0)
					sButton = CivInfo.getButton()
					## CA MODIFIED END

I modified this whole section. list.pop(0) removes the first item from list and returns its value. from the previous code, the first item in the list is the CivInfo, and the rest are leaders info (after we modified the code). here we save it in a variable with the same name, and we can use it for other purposes, such as retrieving the description and button.

here is how it looks when sorting by traits:

Code:
				elif self.iSortLeaders == 2:
					## CA MODIFIED START
					sList = CyTranslator().getText(self.sTraitIcon, ()) + list.pop(0).getDescription()
					#sList = CyTranslator().getText(self.top.sTraitIcon, ()) + gc.getTraitInfo(iList).getDescription()
					## CA MODIFIED END

(I commented out the original line so you can compare). We just pop in the middle of the assignment since we just need to use it once (i.e. no button).

For Religion, it's a bit different due to an extra unidentified value. In this case, we just check for this exception, like so (in def sortLeaders() in PlatyPediaMain.py):
Code:
		if iType == 4:
			lList0 = []
			for iReligion in xrange(-1, gc.getNumReligionInfos()):
				lItem = []
				## CA START
				if iReligion == -1:
					lItem.append( None )
				else:
					lItem.append( gc.getReligionInfo(iReligion) )
				## CA END
				for item in lList:
					Info = gc.getLeaderHeadInfo(item[1])
					if iReligion == Info.getFavoriteReligion():
						lItem.append(item)
				lList0.append(lItem)
			## CA START
			lList1 = sorted( lList0[1:], key=lambda x: x[0].getDescription() )
			lList1.insert(0, lList0[0])
			return lList1
			## CA END

obviously if iReligion == -1 is the NONE criteria, so we append the python None. At the end, sort the rest of the list starting from the second item--hence lList0[1:]. Finally, we re-insert the NONE item anywhere. in this case, before all other lists to retain same functionality. (or if you want, after other lists if we consider it miscellaneous.)

so when we print the leaders sorted by religions, we use this code (again in both PlatyPediaMain.py and PlatyPediaLeader.py):
Code:
				else:
					## CA MODIFIED START
					Religion = list.pop(0)
					if Religion:
						sList = Religion.getDescription()
						sButton = Religion.getButton()
					else:
						sList = CyTranslator().getText("TXT_KEY_MAIN_MENU_NONE", ())
						sButton = CyArtFileMgr().getInterfaceArtInfo("INTERFACE_BUTTONS_CANCEL").getPath()
					## CA MODIFIED END

again, we pop the first item and store it. then we check if it's None or not, and act accordingly.

that's all we have to change. so each sort type is independent and can be sorted by XML order, alphabetical, or whatever. for instance, we didn't change sorting by civics, which works just like before, i.e. by civic categories as written in the XML, which i think is just fine. we can use the same methodology for other pages, not just leaders.

(P.S. Through this, I learned a lot about Python and how powerfully it handles arrays with compact code.)
 
Same method as I thought before. I didn't want to implement it because the sort function itself is already pretty complicated compared to Sevo or BTS, such that it is not easy for newbies to figure out how to add new pages to the pedia for their own mod.

Implementing a sort within the sort function will make it less understandable plus it involves additional codes in 3 places for each sort.
 
you could try generalizing the sort. so you don't have to duplicate the same code across multiple files. take me, i wouldn't know about updating PlatyPediaLeader.py if i didn't randomly click on the leaders, and saw that the list in the side was messed up. with a general sort function, you just call it once and the list is already sorted, then you just print the list. right now, you are telling the user to do several extra steps: call sortleaders, then manage the list in the main.py for each subsort (by civ, trait, etc.), then duplicate this code in the leaders.py.

instead, have a general sort function that takes in several parameters, some of which would be predefined constants. something like this:
Ex. #1
Code:
def sortPedia ( self.LEADERS, self.TRAITS, self.SORT_DESCRIPTION )

or alternatively, pass in functions:
Ex. #2
Code:
def sortPedia ( gc.getLeaderInfo, gc.getTraitInfo, self.SORT_DESCRIPTION )

this way, the headers are already included in the lists and sorted accordingly. so when users print the list, users can omit blocks of if-else statements like these:
Ex. #3
Code:
def placeLeaders()
...
				if self.iSortLeaders == 1:
#get headers
				elif self.iSortLeaders == 2:
#get headers
#now print the headers and list

instead should be
Ex. #4
Code:
def placeLeaders()
#now print the headers and list

even if general sort is not feasible (e.g. must still use sortLeaders, not sortPedia), at least discourage forcing the user to duplicate the same code across multiple files. like with my method in previous post, i can pretty much use Ex #4 and delete all the if-else statements that are there, as long as the processing in sortLeaders is done properly and completely.

in short, the list returned by the sort function should be final and sorted accordingly with headers. when it's time to print the list, no need to fuss with the headers based on the sort conditions, and no need to look at multiple files to update any changes to the sort function.
 
Gotta blame it on Vincent :)
Initially when this pedia was done, there was just one sort method for each page.
Then he suggested multiple sorting methods and it grew complicated.

So by the time I see the complications involved, it is already pretty mature, and simplifying it means rewriting everything but which would have no benefits at all for the end users (players), though it will benefit modders like you.

Currently I am too busy with other stuff. Minor changes like bug fixing or additional sort methods, can be done easily. But revamping the whole sort function, or writing a new upgrade tree codes are definitely no time :)
 
Version 3.0

1) Section Headers are now sorted alphabetically, where necessary.



2) Able to view Graphical Only Items during Debug Mode.



3) Massive Codes Revamp, no point elaborating for players.

4) New Sorting Methods
- Corporations: Great People
- Buildings, Wonders, Projects: Victory
- Civilizations: Starting Techs
- Processes: Commerce Type
 
for that matter, printing the list onto tables can be simplified and merged into a single function. theres no reason to cut and paste that code all over the place. ideally theres an optional parameter for the desired number of columns or rows. this reduces the logic to simply:

printList(sortLeaders(), panel)
printList(sortCivics(), panel)
etc.
 
For generic pages such as Promotions or Corporations, it is true that certain functions can be simplified further.

For the sake of complicated pages such as Unit Categories, Game Infos and Index, it is better to leave them alone.
 
those can be handled by preparing the list beforehand. index may be the exception. the problem i see is the widget jump, but i think even that can be solved.

one thing to look out for i have found are out of bounds errors. Cv/Cy functions don't check for them. so must wrap in try/error blocks.
 
Personally, I don't see much benefits of wasting time to attempt simplifying further due to those pages. Wasting time to code stuff where the outcome is similar doesn't justify the time spent.

You may of course go ahead if you prefer that way.
 
it greatly benefits and simplifies the process for new categories that come up, e.g. a mod adds new fields which are worth sorting by. or any way of sorting one can come up with, e.g. sort leaders by flavor, sort civs by starting techs, etc. once the framework is in place, then all you have to update in the future is the sort function (e.g. sortLeaders()), and that's it. you never have to touch side files (like *Leaders.py) again. and other fringe benefits: reduce file size, use less computer resources, speed up game, etc.
 
At the moment, addition of new sorting methods no longer require modifications to the individual pages.

File size is insignificant. The whole pedia is less than 200kb.
Artwork is the one that matters for size.

It is not going to speed up anything either.
Whether you execute 5 lines of codes directly, or you call a function and then execute the same 5 lines of codes, I don't see how the latter will be faster.
 
Top Bottom