def updateSelectionButtons( self ):
global SELECTION_BUTTON_COLUMNS
global MAX_SELECTION_BUTTONS
global g_pSelectedUnit
screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )
pHeadSelectedCity = CyInterface().getHeadSelectedCity()
pHeadSelectedUnit = CyInterface().getHeadSelectedUnit()
global g_NumEmphasizeInfos
global g_NumCityTabTypes
global g_NumHurryInfos
global g_NumUnitClassInfos
global g_NumBuildingClassInfos
global g_NumProjectInfos
global g_NumProcessInfos
global g_NumActionInfos
# Find out our resolution
xResolution = screen.getXResolution()
yResolution = screen.getYResolution()
# BUG - Build/Action Icon Size - start
if MainOpt.isBuildIconSizeLarge():
screen.addMultiListControlGFC( "BottomButtonContainer", u"", iMultiListXL, yResolution - 113 + 18, xResolution - (iMultiListXL+iMultiListXR), 64, 4, 64, 64, TableStyles.TABLE_STYLE_STANDARD )
elif MainOpt.isBuildIconSizeMedium():
screen.addMultiListControlGFC( "BottomButtonContainer", u"", iMultiListXL, yResolution - 113, xResolution - (iMultiListXL+iMultiListXR), 100, 4, 48, 48, TableStyles.TABLE_STYLE_STANDARD )
else:
screen.addMultiListControlGFC( "BottomButtonContainer", u"", iMultiListXL, yResolution - 113, xResolution - (iMultiListXL+iMultiListXR), 114, 4, 36, 36, TableStyles.TABLE_STYLE_STANDARD )
# EF: minimum icon size for disabled buttons to work is 33 so these sizes won't fly
# screen.addMultiListControlGFC( "BottomButtonContainer", u"", iMultiListXL, yResolution - 113, xResolution - (iMultiListXL+iMultiListXR), 102, 4, 32, 32, TableStyles.TABLE_STYLE_STANDARD )
# screen.addMultiListControlGFC( "BottomButtonContainer", u"", iMultiListXL, yResolution - 113, xResolution - (iMultiListXL+iMultiListXR), 104, 4, 24, 24, TableStyles.TABLE_STYLE_STANDARD )
# BUG - Build/Action Icon Size - end
screen.clearMultiList( "BottomButtonContainer" )
screen.hide( "BottomButtonContainer" )
# All of the hides...
self.setMinimapButtonVisibility(False)
screen.hideList( 0 )
for i in range (g_NumEmphasizeInfos):
szButtonID = "Emphasize" + str(i)
screen.hide( szButtonID )
# Hurry button show...
for i in range( g_NumHurryInfos ):
szButtonID = "Hurry" + str(i)
screen.hide( szButtonID )
# Conscript Button Show
screen.hide( "Conscript" )
#screen.hide( "Liberate" )
screen.hide( "AutomateProduction" )
screen.hide( "AutomateCitizens" )
if (not CyEngine().isGlobeviewUp() and pHeadSelectedCity):
self.setMinimapButtonVisibility(True)
if ((pHeadSelectedCity.getOwner() == gc.getGame().getActivePlayer()) or gc.getGame().isDebugMode()):
iBtnX = xResolution - 284
iBtnY = yResolution - 177
iBtnW = 64
iBtnH = 30
# Liberate button
#szText = "<font=1>" + localText.getText("TXT_KEY_LIBERATE_CITY", ()) + "</font>"
#screen.setButtonGFC( "Liberate", szText, "", iBtnX, iBtnY, iBtnW, iBtnH, WidgetTypes.WIDGET_LIBERATE_CITY, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
#screen.setStyle( "Liberate", "Button_CityT1_Style" )
#screen.hide( "Liberate" )
iBtnSX = xResolution - 284
iBtnX = iBtnSX
iBtnY = yResolution - 140
iBtnW = 64
iBtnH = 30
# Conscript button
szText = "<font=1>" + localText.getText("TXT_KEY_DRAFT", ()) + "</font>"
screen.setButtonGFC( "Conscript", szText, "", iBtnX, iBtnY, iBtnW, iBtnH, WidgetTypes.WIDGET_CONSCRIPT, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
screen.setStyle( "Conscript", "Button_CityT1_Style" )
screen.hide( "Conscript" )
iBtnY += iBtnH
iBtnW = 32
iBtnH = 28
# Hurry Buttons
screen.setButtonGFC( "Hurry0", "", "", iBtnX, iBtnY, iBtnW, iBtnH, WidgetTypes.WIDGET_HURRY, 0, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
screen.setStyle( "Hurry0", "Button_CityC1_Style" )
screen.hide( "Hurry0" )
iBtnX += iBtnW
screen.setButtonGFC( "Hurry1", "", "", iBtnX, iBtnY, iBtnW, iBtnH, WidgetTypes.WIDGET_HURRY, 1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
screen.setStyle( "Hurry1", "Button_CityC2_Style" )
screen.hide( "Hurry1" )
iBtnX = iBtnSX
iBtnY += iBtnH
# Automate Production Button
screen.addCheckBoxGFC( "AutomateProduction", "", "", iBtnX, iBtnY, iBtnW, iBtnH, WidgetTypes.WIDGET_AUTOMATE_PRODUCTION, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
screen.setStyle( "AutomateProduction", "Button_CityC3_Style" )
iBtnX += iBtnW
# Automate Citizens Button
screen.addCheckBoxGFC( "AutomateCitizens", "", "", iBtnX, iBtnY, iBtnW, iBtnH, WidgetTypes.WIDGET_AUTOMATE_CITIZENS, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
screen.setStyle( "AutomateCitizens", "Button_CityC4_Style" )
iBtnY += iBtnH
iBtnX = iBtnSX
iBtnW = 22
iBtnWa = 20
iBtnH = 24
iBtnHa = 27
# Set Emphasize buttons
i = 0
szButtonID = "Emphasize" + str(i)
screen.addCheckBoxGFC( szButtonID, "", "", iBtnX, iBtnY, iBtnW, iBtnH, WidgetTypes.WIDGET_EMPHASIZE, i, -1, ButtonStyles.BUTTON_STYLE_LABEL )
szStyle = "Button_CityB" + str(i+1) + "_Style"
screen.setStyle( szButtonID, szStyle )
screen.hide( szButtonID )
i+=1
szButtonID = "Emphasize" + str(i)
screen.addCheckBoxGFC( szButtonID, "", "", iBtnX+iBtnW, iBtnY, iBtnWa, iBtnH, WidgetTypes.WIDGET_EMPHASIZE, i, -1, ButtonStyles.BUTTON_STYLE_LABEL )
szStyle = "Button_CityB" + str(i+1) + "_Style"
screen.setStyle( szButtonID, szStyle )
screen.hide( szButtonID )
i+=1
szButtonID = "Emphasize" + str(i)
screen.addCheckBoxGFC( szButtonID, "", "", iBtnX+iBtnW+iBtnWa, iBtnY, iBtnW, iBtnH, WidgetTypes.WIDGET_EMPHASIZE, i, -1, ButtonStyles.BUTTON_STYLE_LABEL )
szStyle = "Button_CityB" + str(i+1) + "_Style"
screen.setStyle( szButtonID, szStyle )
screen.hide( szButtonID )
iBtnY += iBtnH
i+=1
szButtonID = "Emphasize" + str(i)
screen.addCheckBoxGFC( szButtonID, "", "", iBtnX, iBtnY, iBtnW, iBtnHa, WidgetTypes.WIDGET_EMPHASIZE, i, -1, ButtonStyles.BUTTON_STYLE_LABEL )
szStyle = "Button_CityB" + str(i+1) + "_Style"
screen.setStyle( szButtonID, szStyle )
screen.hide( szButtonID )
i+=1
szButtonID = "Emphasize" + str(i)
screen.addCheckBoxGFC( szButtonID, "", "", iBtnX+iBtnW, iBtnY, iBtnWa, iBtnHa, WidgetTypes.WIDGET_EMPHASIZE, i, -1, ButtonStyles.BUTTON_STYLE_LABEL )
szStyle = "Button_CityB" + str(i+1) + "_Style"
screen.setStyle( szButtonID, szStyle )
screen.hide( szButtonID )
i+=1
szButtonID = "Emphasize" + str(i)
screen.addCheckBoxGFC( szButtonID, "", "", iBtnX+iBtnW+iBtnWa, iBtnY, iBtnW, iBtnHa, WidgetTypes.WIDGET_EMPHASIZE, i, -1, ButtonStyles.BUTTON_STYLE_LABEL )
szStyle = "Button_CityB" + str(i+1) + "_Style"
screen.setStyle( szButtonID, szStyle )
screen.hide( szButtonID )
g_pSelectedUnit = 0
screen.setState( "AutomateCitizens", pHeadSelectedCity.isCitizensAutomated() )
screen.setState( "AutomateProduction", pHeadSelectedCity.isProductionAutomated() )
for i in range (g_NumEmphasizeInfos):
szButtonID = "Emphasize" + str(i)
screen.show( szButtonID )
if ( pHeadSelectedCity.AI_isEmphasize(i) ):
screen.setState( szButtonID, True )
else:
screen.setState( szButtonID, False )
# City Tabs
for i in range( g_NumCityTabTypes ):
szButtonID = "CityTab" + str(i)
screen.show( szButtonID )
# Hurry button show...
for i in range( g_NumHurryInfos ):
szButtonID = "Hurry" + str(i)
screen.show( szButtonID )
screen.enable( szButtonID, pHeadSelectedCity.canHurry(i, False) )
# Conscript Button Show
screen.show( "Conscript" )
if (pHeadSelectedCity.canConscript()):
screen.enable( "Conscript", True )
else:
screen.enable( "Conscript", False )
# Liberate Button Show
#screen.show( "Liberate" )
#if (-1 != pHeadSelectedCity.getLiberationPlayer()):
# screen.enable( "Liberate", True )
#else:
# screen.enable( "Liberate", False )
iCount = 0
iRow = 0
bFound = False
# Units to construct
for i in range ( g_NumUnitClassInfos ):
eLoopUnit = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType()).getCivilizationUnits(i)
if (pHeadSelectedCity.canTrain(eLoopUnit, False, True)):
szButton = gc.getPlayer(pHeadSelectedCity.getOwner()).getUnitButton(eLoopUnit)
screen.appendMultiListButton( "BottomButtonContainer", szButton, iRow, WidgetTypes.WIDGET_TRAIN, i, -1, False )
screen.show( "BottomButtonContainer" )
if ( not pHeadSelectedCity.canTrain(eLoopUnit, False, False) ):
screen.disableMultiListButton( "BottomButtonContainer", iRow, iCount, szButton)
iCount = iCount + 1
bFound = True
iCount = 0
if (bFound):
iRow = iRow + 1
bFound = False
# Buildings to construct
for i in range ( g_NumBuildingClassInfos ):
if (not isLimitedWonderClass(i)):
eLoopBuilding = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType()).getCivilizationBuildings(i)
if (pHeadSelectedCity.canConstruct(eLoopBuilding, False, True, False)):
screen.appendMultiListButton( "BottomButtonContainer", gc.getBuildingInfo(eLoopBuilding).getButton(), iRow, WidgetTypes.WIDGET_CONSTRUCT, i, -1, False )
screen.show( "BottomButtonContainer" )
if ( not pHeadSelectedCity.canConstruct(eLoopBuilding, False, False, False) ):
screen.disableMultiListButton( "BottomButtonContainer", iRow, iCount, gc.getBuildingInfo(eLoopBuilding).getButton() )
iCount = iCount + 1
bFound = True
iCount = 0
if (bFound):
iRow = iRow + 1
bFound = False
# Wonders to construct
i = 0
for i in range( g_NumBuildingClassInfos ):
if (isLimitedWonderClass(i)):
eLoopBuilding = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType()).getCivilizationBuildings(i)
if (pHeadSelectedCity.canConstruct(eLoopBuilding, False, True, False)):
[COLOR="Red"]screen.appendMultiListButton( "BottomButtonContainer", gc.getBuildingInfo(eLoopBuilding).getButton(), iRow, WidgetTypes.WIDGET_CONSTRUCT, i, -1, False )[/COLOR]
screen.show( "BottomButtonContainer" )
if ( not pHeadSelectedCity.canConstruct(eLoopBuilding, False, False, False) ):
screen.disableMultiListButton( "BottomButtonContainer", iRow, iCount, gc.getBuildingInfo(eLoopBuilding).getButton() )
iCount = iCount + 1
bFound = True
iCount = 0
if (bFound):
iRow = iRow + 1
bFound = False
# Projects
i = 0
for i in range( g_NumProjectInfos ):
if (pHeadSelectedCity.canCreate(i, False, True)):
screen.appendMultiListButton( "BottomButtonContainer", gc.getProjectInfo(i).getButton(), iRow, WidgetTypes.WIDGET_CREATE, i, -1, False )
screen.show( "BottomButtonContainer" )
if ( not pHeadSelectedCity.canCreate(i, False, False) ):
screen.disableMultiListButton( "BottomButtonContainer", iRow, iCount, gc.getProjectInfo(i).getButton() )
iCount = iCount + 1
bFound = True
# Processes
i = 0
for i in range( g_NumProcessInfos ):
if (pHeadSelectedCity.canMaintain(i, False)):
screen.appendMultiListButton( "BottomButtonContainer", gc.getProcessInfo(i).getButton(), iRow, WidgetTypes.WIDGET_MAINTAIN, i, -1, False )
screen.show( "BottomButtonContainer" )
iCount = iCount + 1
bFound = True
screen.selectMultiList( "BottomButtonContainer", CyInterface().getCityTabSelectionRow() )
elif (not CyEngine().isGlobeviewUp() and pHeadSelectedUnit and CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_HIDE_ALL and CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_MINIMAP_ONLY):
self.setMinimapButtonVisibility(True)
if (CyInterface().getInterfaceMode() == InterfaceModeTypes.INTERFACEMODE_SELECTION):
if ( pHeadSelectedUnit.getOwner() == gc.getGame().getActivePlayer() and g_pSelectedUnit != pHeadSelectedUnit ):
g_pSelectedUnit = pHeadSelectedUnit
iCount = 0
actions = CyInterface().getActionsToShow()
for i in actions:
screen.appendMultiListButton( "BottomButtonContainer", gc.getActionInfo(i).getButton(), 0, WidgetTypes.WIDGET_ACTION, i, -1, False )
screen.show( "BottomButtonContainer" )
if ( not CyInterface().canHandleAction(i, False) ):
screen.disableMultiListButton( "BottomButtonContainer", 0, iCount, gc.getActionInfo(i).getButton() )
if ( pHeadSelectedUnit.isActionRecommended(i) ):#or gc.getActionInfo(i).getCommandType() == CommandTypes.COMMAND_PROMOTION ):
screen.enableMultiListPulse( "BottomButtonContainer", True, 0, iCount )
else:
screen.enableMultiListPulse( "BottomButtonContainer", False, 0, iCount )
iCount = iCount + 1
if (CyInterface().canCreateGroup()):
screen.appendMultiListButton( "BottomButtonContainer", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_CREATEGROUP").getPath(), 0, WidgetTypes.WIDGET_CREATE_GROUP, -1, -1, False )
screen.show( "BottomButtonContainer" )
iCount = iCount + 1
if (CyInterface().canDeleteGroup()):
screen.appendMultiListButton( "BottomButtonContainer", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_SPLITGROUP").getPath(), 0, WidgetTypes.WIDGET_DELETE_GROUP, -1, -1, False )
screen.show( "BottomButtonContainer" )
iCount = iCount + 1
# Immigration Mod
# ##### Join City Button ######
iUnitType = g_pSelectedUnit.getUnitType()
iUnitOwner = g_pSelectedUnit.getOwner( )
pUnitOwner = gc.getPlayer(iUnitOwner)
if pUnitOwner.isTurnActive( ):
if gc.getMap().plot(g_pSelectedUnit.getX(), g_pSelectedUnit.getY() ).isCity():
# Immigration Mod
if iUnitType == gc.getInfoTypeForString("UNIT_IMMIGRANT"):
if Immigration.showJoinCityButton(g_pSelectedUnit):
screen.appendMultiListButton( "BottomButtonContainer", ArtFileMgr.getInterfaceArtInfo("INTERFACE_JOIN_CITY").getPath(), 0, WidgetTypes.WIDGET_GENERAL, 680, 680, False )
screen.show("BottomButtonContainer")
iCount = iCount + 1
return
# End Immigration Mod
elif (CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_HIDE_ALL and CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_MINIMAP_ONLY):
self.setMinimapButtonVisibility(True)
return 0
# Will update the research buttons