# BUG - city specialist - start
def updateCitizenButtons_Stacker( self ):
if not CyInterface().isCityScreenUp(): return 0
pHeadSelectedCity = CyInterface().getHeadSelectedCity()
if not (pHeadSelectedCity and CyInterface().getShowInterface() == InterfaceVisibility.INTERFACE_SHOW): return 0
global g_iSuperSpecialistCount
global g_iCitySpecialistCount
global g_iAngryCitizensCount
bHandled = False
screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )
# Find out our resolution
xResolution = screen.getXResolution()
yResolution = screen.getYResolution()
pHeadSelectedCity = CyInterface().getHeadSelectedCity()
currentAngryCitizenCount = pHeadSelectedCity.angryPopulation(0)
if(currentAngryCitizenCount > 0):
stackWidth = 220 / currentAngryCitizenCount
if (stackWidth > MAX_SPECIALIST_BUTTON_SPACING):
stackWidth = MAX_SPECIALIST_BUTTON_SPACING
for i in range(currentAngryCitizenCount):
bHandled = True
szName = "AngryCitizen" + str(i)
screen.setImageButton( szName, ArtFileMgr.getInterfaceArtInfo("INTERFACE_ANGRYCITIZEN_TEXTURE").getPath(), xResolution - SPECIALIST_AREA_MARGIN - (stackWidth * i), yResolution - (282- SPECIALIST_ROW_HEIGHT), 30, 30, WidgetTypes.WIDGET_ANGRY_CITIZEN, -1, -1 )
screen.show( szName )
# update the max ever citizen counts
if g_iAngryCitizensCount < currentAngryCitizenCount:
g_iAngryCitizensCount = currentAngryCitizenCount
iCount = 0
bHandled = False
currentSuperSpecialistCount = 0
for i in range(gc.getNumSpecialistInfos()):
if(pHeadSelectedCity.getFreeSpecialistCount(i) > 0):
currentSuperSpecialistCount = currentSuperSpecialistCount + pHeadSelectedCity.getFreeSpecialistCount(i)
if(currentSuperSpecialistCount > 0):
stackWidth = 220 / currentSuperSpecialistCount
if (stackWidth > MAX_SPECIALIST_BUTTON_SPACING):
stackWidth = MAX_SPECIALIST_BUTTON_SPACING
for i in range(gc.getNumSpecialistInfos()):
for j in range( pHeadSelectedCity.getFreeSpecialistCount(i) ):
szName = "FreeSpecialist" + str(iCount)
screen.setImageButton( szName, gc.getSpecialistInfo(i).getTexture(), (xResolution - SPECIALIST_AREA_MARGIN - (stackWidth * iCount)), yResolution - (282 - SPECIALIST_ROW_HEIGHT * 2), 30, 30, WidgetTypes.WIDGET_FREE_CITIZEN, i, 1 )
screen.show( szName )
bHandled = true
iCount = iCount + 1
# update the max ever citizen counts
if g_iSuperSpecialistCount < iCount:
g_iSuperSpecialistCount = iCount
iXShiftVal = 0
iYShiftVal = 0
iSpecialistCount = 0
for i in range( gc.getNumSpecialistInfos() ):
bHandled = False
if( iSpecialistCount > SPECIALIST_ROWS ):
iXShiftVal = 115
iYShiftVal = (iSpecialistCount % SPECIALIST_ROWS) + 1
else:
iYShiftVal = iSpecialistCount
if (gc.getSpecialistInfo(i).isVisible()):
iSpecialistCount = iSpecialistCount + 1
if (gc.getPlayer(pHeadSelectedCity.getOwner()).isSpecialistValid(i) or i == 0):
iCount = (pHeadSelectedCity.getPopulation() - pHeadSelectedCity.angryPopulation(0)) + pHeadSelectedCity.totalFreeSpecialists()
else:
iCount = pHeadSelectedCity.getMaxSpecialistCount(i)
# update the max ever citizen counts
if g_iCitySpecialistCount < iCount:
g_iCitySpecialistCount = iCount
RowLength = 110
if (i == 0):
#if (i == gc.getInfoTypeForString(gc.getDefineSTRING("DEFAULT_SPECIALIST"))):
RowLength *= 2
HorizontalSpacing = MAX_SPECIALIST_BUTTON_SPACING
if (iCount > 0):
HorizontalSpacing = RowLength / iCount
if (HorizontalSpacing > MAX_SPECIALIST_BUTTON_SPACING):
HorizontalSpacing = MAX_SPECIALIST_BUTTON_SPACING
for k in range (iCount):
if (k >= pHeadSelectedCity.getSpecialistCount(i)):
szName = "IncresseCitizenBanner" + str((i * 100) + k)
screen.addCheckBoxGFC( szName, gc.getSpecialistInfo(i).getTexture(), "", xResolution - (SPECIALIST_AREA_MARGIN + iXShiftVal) - (HorizontalSpacing * k), (yResolution - 282 - (SPECIALIST_ROW_HEIGHT * iYShiftVal)), 30, 30, WidgetTypes.WIDGET_CHANGE_SPECIALIST, i, 1, ButtonStyles.BUTTON_STYLE_LABEL )
screen.enable( szName, False )
screen.show( szName )
szName = "IncresseCitizenButton" + str((i * 100) + k)
screen.addCheckBoxGFC( szName, "", "", xResolution - (SPECIALIST_AREA_MARGIN + iXShiftVal) - (HorizontalSpacing * k), (yResolution - 282 - (SPECIALIST_ROW_HEIGHT * iYShiftVal)), 30, 30, WidgetTypes.WIDGET_CHANGE_SPECIALIST, i, 1, ButtonStyles.BUTTON_STYLE_LABEL )
screen.show( szName )
else:
szName = "DecresseCitizenButton" + str((i * 100) + k)
screen.addCheckBoxGFC( szName, gc.getSpecialistInfo(i).getTexture(), "", xResolution - (SPECIALIST_AREA_MARGIN + iXShiftVal) - (HorizontalSpacing * k), (yResolution - 282 - (SPECIALIST_ROW_HEIGHT * iYShiftVal)), 30, 30, WidgetTypes.WIDGET_CHANGE_SPECIALIST, i, -1, ButtonStyles.BUTTON_STYLE_LABEL )
screen.show( szName )
screen.show( "SpecialistBackground" )
screen.show( "SpecialistLabel" )
return 0
# BUG - city specialist - end