Platy's Peculiar Pleasant Posh Python

Maybe you can give me some advice. I am trying to put the great person icon into my great person bar, but it doesn't seem to work. I thought all I needed to do is a simple replacement, but id doesn't work:
Code:
szText = (CyGame().getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR), 0) + pGreatPersonCity.getName() + " (%d)" %(iGPTurns)
instead of:
Code:
szText = "GreatPerson: " + pGreatPersonCity.getName() + " (%d)" %(iGPTurns)

Code:
############################################################
##########=MSM===GP Bar (Impaler)===3/4===0===
############################################################
				if (not CyInterface().isCityScreenUp()):
					if CyUserProfile().getGraphicOption(gc.getInfoTypeForString("GRAPHICOPTION_GREAT_PERSON_BAR")):
						pGreatPersonCity, iGPTurns = self.getnextGPCity()
						if (iGPTurns < 10000000 and pGreatPersonCity):
							[COLOR="Magenta"]szText = "GreatPerson: " + pGreatPersonCity.getName() + " (%d)" %(iGPTurns)[/COLOR]					
							screen.setText( "GreatPersonBarText", "Background", szText, CvUtil.FONT_CENTER_JUSTIFY, screen.centerX(565), 31, -0.4, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_GREAT_PEOPLE, -1, -1 )
							screen.show( "GreatPersonBarText" )
							fThreshold = float( gc.getPlayer( pGreatPersonCity.getOwner() ).greatPeopleThreshold(false) )
							fRate = float(pGreatPersonCity.getGreatPeopleRate())
							iFirst = float(pGreatPersonCity.getGreatPeopleProgress()) / fThreshold

							screen.setBarPercentage( "GreatPersonBar", InfoBarTypes.INFOBAR_STORED, iFirst )
							if ( iFirst == 1 ):
								screen.setBarPercentage( "GreatPersonBar", InfoBarTypes.INFOBAR_RATE, fRate / fThreshold )
							else:
								screen.setBarPercentage( "GreatPersonBar", InfoBarTypes.INFOBAR_RATE, fRate / fThreshold / ( 1 - iFirst ) )				
							screen.show( "GreatPersonBar" )					
						else:	
							screen.hide( "GreatPersonBar" )
							screen.hide( "GreatPersonBarText" )
############################################################
##########=MSM===GP Bar (Impaler)===3/4===X===
############################################################
 
Symbol is a char, not a str.
You can't merge them simply like that.
Use Cytranslator().getText("[ICON_GREATPEOPLE]", ())

The alternative if you insist on using char would look like this:
Code:
szText = (%c: %s(%d)) % (CyGame().getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR), pGreatPersonCity.getName(), iGPTurns)
 
Well, I figured it out by using PAE's version of the bar. One more question. I want to set some hover text. Where exactly is it in your code please?

## Great People Bar ##
Code:
					if CyUserProfile().getGraphicOption(gc.getInfoTypeForString("GRAPHICOPTION_GREAT_PEOPLE_BAR")):
						iMinTurns = 99999
						iCityID = -1
						(loopCity, iter) = pPlayer.firstCity(False)
						while(loopCity):
							iRate = loopCity.getGreatPeopleRate()
							if iRate > 0:
								iTurns = (pPlayer.greatPeopleThreshold(false) - loopCity.getGreatPeopleProgress() + iRate - 1) / iRate
								if iTurns < iMinTurns:
									iMinTurns = iTurns
									iCityID = loopCity.getID()
							(loopCity, iter) = pPlayer.nextCity(iter, False)
						if iCityID > -1:
							pCity = pPlayer.getCity(iCityID)
							screen.addStackedBarGFC( "MainGPBar", xResolution /2 - iBarWidth /2 + 32, 3 + 24, iBarWidth - 36, iStackBarHeight, InfoBarTypes.NUM_INFOBAR_TYPES, WidgetTypes.WIDGET_PYTHON, 7200 + ePlayer, iCityID)
							screen.setStackedBarColors( "MainGPBar", InfoBarTypes.INFOBAR_STORED, gc.getInfoTypeForString("COLOR_GREAT_PEOPLE_STORED") )
							screen.setStackedBarColors( "MainGPBar", InfoBarTypes.INFOBAR_RATE, gc.getInfoTypeForString("COLOR_GREAT_PEOPLE_RATE") )
							screen.setStackedBarColors( "MainGPBar", InfoBarTypes.INFOBAR_RATE_EXTRA, gc.getInfoTypeForString("COLOR_EMPTY") )
							screen.setStackedBarColors( "MainGPBar", InfoBarTypes.INFOBAR_EMPTY, gc.getInfoTypeForString("COLOR_EMPTY") )

							fGreatProgress = float(pCity.getGreatPeopleProgress()) / pPlayer.greatPeopleThreshold(false)
							screen.setBarPercentage( "MainGPBar", InfoBarTypes.INFOBAR_STORED, fGreatProgress)
							screen.setBarPercentage( "MainGPBar", InfoBarTypes.INFOBAR_RATE, 0.0)
							if fGreatProgress < 1:
								screen.setBarPercentage( "MainGPBar", InfoBarTypes.INFOBAR_RATE, ( float(pCity.getGreatPeopleRate()) / (pPlayer.greatPeopleThreshold(false) - pCity.getGreatPeopleProgress())))
							
							iGreatUnit = -1
							iMaxProgress = 0
							for i in xrange(len(self.lGreatPeople)):
								iUnitClass = self.lGreatPeople[i]
								iUnit = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getCivilizationUnits(iUnitClass)
								if iUnit == -1: continue
								iProgress = pCity.getGreatPeopleUnitProgress(iUnit)
								if iProgress > iMaxProgress:
									iMaxProgress = iProgress
									iGreatUnit = iUnit
							screen.addTableControlGFC( "MainGPText", 1, xResolution /2 - iBarWidth /2, 4 + 24, iBarWidth, iStackBarHeight, False, False, 28, 28, TableStyles.TABLE_STYLE_EMPTY )
							screen.setTableColumnHeader( "MainGPText", 0, u"", iBarWidth)
							screen.appendTableRow( "MainGPText" )
							sUnit = ""
							sButton = ""
							if iGreatUnit > -1:
								sUnit = gc.getUnitInfo(iGreatUnit).getDescription()
								sButton = gc.getUnitInfo(iGreatUnit).getButton()
							sText = u"<font=3>%s: %s (%d)</font>" %(pCity.getName(), sUnit, iMinTurns)
							screen.setTableText( "MainGPText", 0, 0, sText, sButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY)
							screen.setHitTest( "MainGPText", HitTestTypes.HITTEST_NOHIT )
## Great People Bar ##
 
In the History Rewritten thread you mentioned some fixes/extensions to Kathy's Goody Islands that we might try. Basically loop through the plots to find the generated units and replace them with the best sea unit available. We are doing the first (C2C & HR) but use a hard coded solution.

1) Can you point me to one of your modules that does the bit that finds the best available unit?

2) While the above approach works for the generated barbarians it is not as useful for the player ones since you may have a transport with those units in it also on the plot. Is there a way to tell if the (land) unit is not on board a transport?
 
Actually, I am not sure why you need to find the best available unit, if you are using a hard coded solution.

Anyway, the advisors pop up in BTS are already doing it, where they are looping through all units which the city can build, and assign a value based on Unit AI, to decide which is the best unit to advise you.
Look into the BTS CvAdvisorUitls since mine no longer do that.

isCargo()
 
Thank you.

(If you don't hard code it it becomes usable in other mods. So if I can come up with a generic solution that woks in C2C then I can give it back to Kathy so others can also use it.)
 
Ultrapack

Replace non naval units spawned from goody huts spawned in water.
In BTS, this will never happen, so it is mainly for mods with island goody huts.
 
Developing Traits

Features:
Gains Points towards Individual Trait XP for certain events.
Additional Trait Benefits based on Individual Trait Level



Rate Multiplier:
1) Era Advance (50%)
2) Golden Age (100%)

Effect Multiplier:
1) Has Trait (50%)

So a Creative Leader with Level 10 Creative is as good as another Leader with Level 15 Creative.
 
@Platyping, elsewhere you asked why BUG used localText = CvTranslator() since it does not save much typing for the programmer.

One reason is exactly the same as why you calculate an equation that is used often up front and store it in a variable. It is faster for the player.

Using localText creates the object CvTranslator() once then uses that instance further down the code. Rather that recreating the object every time. It is probably only a small saving but as you know small savings add up.
 
Ultrapack Tech Screen

1) Fix "Add Tech" button shown behind bottom panel, thus unable to click.

2) "Add Tech" button no longer shown when cost > points.
In BTS it is still shown, just that clicking it has no effect.
 
EDIT:
Nope apparently this has nothing to do with anything...would be nice to fix (or at least understand) the asserts but apparently they don't break anything.


Hey Platy, So once again I am trying the great headache to get your GUI to work.

When I run it I get this assert at load up:
File: CvGlobals.cpp
Line: 1773
Expression: eGraphicOptionNum < NUM_GRAPHICOPTION_TYPES
Message:

It happens 4 times.

Now when I did some searching for 'GraphicOptionTypes' I got 20 hits in 9 files with your version, and 6 hits in 3 files in my working BUG version.

6 of your files don't seem important to this, which leaves me with:
CvOptionsScreenCallbackInterface.py (which I do not have in my working BUG version) [it also has the +4 reference in it]
CvMainInterface.py
CvOptionsScreen.py

One of the most notable differences I found between the 2 was in CvOptionsScreen.py
You have added a new line with a + 4 in it.(line 273) and I get the assert message 4 times..
So I am thinking this is not a coincidence, of course I don't understand enough of what this is doing, etc. to formulate any kind of an action. Do I need to add more NUMs in the game core, do I need to expose/unexpose some thing to python, or something else entirely...

Line 108: for iOptionLoop in xrange(GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES):
Line 273: for iOptionLoop in xrange(GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES, GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES + 4):
Line 547: for iOptionLoop in xrange(GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES):

I could really use some help in understanding what this line is doing, what it connects to and how I might resolve the issue.

here also is the graphic Options section of code from CvEnums.h:
Spoiler :
Code:
enum GraphicOptionTypes			// Exposed to Python
{
	NO_GRAPHICOPTION = -1,

	GRAPHICOPTION_SINGLE_UNIT_GRAPHICS,
	GRAPHICOPTION_HEALTH_BARS,
	GRAPHICOPTION_CITY_DETAIL,
	GRAPHICOPTION_NO_COMBAT_ZOOM,
	GRAPHICOPTION_NO_ENEMY_GLOW,
	GRAPHICOPTION_FROZEN_ANIMATIONS,
	GRAPHICOPTION_EFFECTS_DISABLED,
	GRAPHICOPTION_GLOBE_VIEW_BUILDINGS_DISABLED,
	GRAPHICOPTION_FULLSCREEN,
	GRAPHICOPTION_LOWRES_TEXTURES,
	GRAPHICOPTION_HIRES_TERRAIN,
	GRAPHICOPTION_NO_MOVIES,
	GRAPHICOPTION_CITY_RADIUS,
 
Frankly speaking, I have no idea what is your question...
 
Hey platy,

I am working on a new project with your UI, and I get this error.

It happens when I found a religion and open the city screen. I currently only have 1 religion, if that could be connected.

Any thoughts on what might be the issue would be welcome.
 

Attachments

  • division by zero error.png
    division by zero error.png
    37.2 KB · Views: 160
And... Another Question!

I am trying to merge in your Equipment Mod, but I am stuck on a section.

PlatyPediaBonus.py
Equipment:
Spoiler :
Code:
## Equipments ##		
	def placeAllows(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel( panelName, CyTranslator().getText("TXT_KEY_PEDIA_ALLOWS", ()), "", false, true, self.top.X_ITEMS_PANE, self.Y_ALLOWS, self.W_MAIN_PANE, self.H_REQUIRES, PanelStyles.PANEL_STYLE_BLUE50 )

		for eLoopUnit in xrange(gc.getNumUnitInfos()):
			bFound = False
			if (eLoopUnit >= 0):
				if (gc.getUnitInfo(eLoopUnit).getPrereqAndBonus() == self.iBonus):
					bFound = True	
				else:
					j = 0
					while (not bFound and j < gc.getNUM_UNIT_PREREQ_OR_BONUSES()):
						if (gc.getUnitInfo(eLoopUnit).getPrereqOrBonuses(j) == self.iBonus):
							bFound = True
						j += 1
			if bFound:
				szButton = gc.getUnitInfo(eLoopUnit).getButton()
				if self.top.iActivePlayer != -1:
					szButton = gc.getPlayer(self.top.iActivePlayer).getUnitButton(eLoopUnit)
				screen.attachImageButton( panelName, "", szButton, GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_UNIT, eLoopUnit, 1, False )

		for eLoopBuilding in xrange(gc.getNumBuildingInfos()):
			bFound = False
			if (gc.getBuildingInfo(eLoopBuilding).getPrereqAndBonus() == self.iBonus):
				bFound = True	
			else:
				j = 0
				while (not bFound and j < gc.getNUM_BUILDING_PREREQ_OR_BONUSES()):
					if (gc.getBuildingInfo(eLoopBuilding).getPrereqOrBonuses(j) == self.iBonus):
						bFound = True
					j += 1
			if bFound:
				screen.attachImageButton( panelName, "", gc.getBuildingInfo(eLoopBuilding).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, eLoopBuilding, 1, False )
## Equipments ##

Latest Platy Pedia:
Spoiler :
Code:
	def placeAllows(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel( panelName, CyTranslator().getText("TXT_KEY_PEDIA_ALLOWS", ()), "", false, true, self.top.X_ITEMS_PANE, self.Y_ALLOWS, self.W_MAIN_PANE, self.H_REQUIRES, PanelStyles.PANEL_STYLE_BLUE50 )

		for i in xrange(gc.getNumUnitClassInfos()):
			item = gc.getUnitClassInfo(i).getDefaultUnitIndex()
			if CyGame().getActiveCivilizationType() > -1:
				item = gc.getCivilizationInfo(CyGame().getActiveCivilizationType()).getCivilizationUnits(i)
			if item == -1: continue
			bFound = False
			Info = gc.getUnitInfo(item)
			if Info.getPrereqAndBonus() == self.iBonus:
				bFound = True	
			else:
				for j in xrange(gc.getNUM_UNIT_PREREQ_OR_BONUSES()):
					if Info.getPrereqOrBonuses(j) == self.iBonus:
						bFound = True
						break
			if bFound:
				szButton = Info.getButton()
				if self.top.iActivePlayer > -1:
					szButton = gc.getPlayer(self.top.iActivePlayer).getUnitButton(item)
				screen.attachImageButton(panelName, "", szButton, GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_UNIT, item, 1, False )

		for i in xrange(gc.getNumBuildingClassInfos()):
			item = gc.getBuildingClassInfo(i).getDefaultBuildingIndex()
			if CyGame().getActiveCivilizationType() > -1:
				item = gc.getCivilizationInfo(CyGame().getActiveCivilizationType()).getCivilizationBuildings(i)
			if item == -1: continue
			bFound = False
			Info = gc.getBuildingInfo(item)
			if Info.getPrereqAndBonus() == self.iBonus:
				bFound = True	
			else:
				for j in xrange(gc.getNUM_BUILDING_PREREQ_OR_BONUSES()):
					if Info.getPrereqOrBonuses(j) == self.iBonus:
						bFound = True
						break
			if bFound:
				screen.attachImageButton(panelName, "", Info.getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, item, 1, False )

		for item in xrange(gc.getNumRouteInfos()):
			bFound = False
			Info = gc.getRouteInfo(item)
			if Info.getPrereqBonus() == self.iBonus:
				bFound = True	
			else:
				for j in xrange(gc.getNUM_ROUTE_PREREQ_OR_BONUSES()):
					if Info.getPrereqOrBonus(j) == self.iBonus:
						bFound = True
						break
			if bFound:
				screen.attachImageButton(panelName, "", Info.getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PYTHON, 6788, item, False)

I don't know what bits are for the equipment specifically, and which bits are old conflicting platypedia code...
 
AND..... Another Question!

This time it's Manufactured Resources.

Again it is the pediabonus file

this one uses standard pedia files, but in platy pedia many of the functions that manufactured resources uses have been removed.

placeYield
placeSpecial

I think, and maybe some more.
So I have no idea where to put the MR code..

Also it comes with a pedia tech file, but I can't actually find any MR marked bits of code from this file..
 
Top Bottom