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 ##