def updateSpecialists(self):
        """ Function which shows the specialists."""
        screen = CyGInterfaceScreen("DomesticAdvisor",
                                    CvScreenEnums.DOMESTIC_ADVISOR)

        if (CyInterface().isOneCitySelected()):

            city = CyInterface().getHeadSelectedCity()
            nPopulation = city.getPopulation()
            nFreeSpecial = city.totalFreeSpecialists()

            for i in xrange(gc.getNumSpecialistInfos()):
                if (gc.getSpecialistInfo(i).isVisible()):
                    szName = "SpecialistImage" + str(i)
                    screen.show(szName)

                    szName = "SpecialistText" + str(i)
                    screen.setLabel(
                        szName, "Background",
                        str(city.getSpecialistCount(i)) + "/" +
                        str(city.getMaxSpecialistCount(i)),
                        CvUtil.FONT_LEFT_JUSTIFY, self.nFirstSpecialistX +
                        (self.nSpecialistDistance * i) + self.nSpecTextOffsetX,
                        self.nSpecialistY + self.nSpecTextOffsetY, 0,
                        FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1,
                        -1)
                    screen.show(szName)

                    # If the specialist is valid and we can increase it
                    szName = "SpecialistPlus" + str(i)
                    if (city.isSpecialistValid(i, 1)
                            and (city.getForceSpecialistCount(i) <
                                 (nPopulation + nFreeSpecial))):
                        screen.show(szName)
                    else:
                        screen.hide(szName)

                    # if we HAVE specialists already and they're not forced.
                    szName = "SpecialistMinus" + str(i)
                    if (city.getSpecialistCount(i) > 0
                            or city.getForceSpecialistCount(i) > 0):
                        screen.show(szName)
                    else:
                        screen.hide(szName)
        else:
            self.hideSpecialists()
    def drawSpecialists(self):
        screen = CyGInterfaceScreen("DomesticAdvisor",
                                    CvScreenEnums.DOMESTIC_ADVISOR)

        for i in xrange(gc.getNumSpecialistInfos()):
            if (gc.getSpecialistInfo(i).isVisible()):
                szName = "SpecialistImage" + str(i)
                screen.setImageButton(
                    szName,
                    gc.getSpecialistInfo(i).getTexture(),
                    self.nFirstSpecialistX + (self.nSpecialistDistance * i),
                    self.nSpecialistY, self.nSpecialistWidth,
                    self.nSpecialistLength, WidgetTypes.WIDGET_CITIZEN, i, -1)
                screen.hide(szName)

                szName = "SpecialistPlus" + str(i)
                screen.setButtonGFC(
                    szName, u"", "", self.nFirstSpecialistX +
                    (self.nSpecialistDistance * i) + self.nPlusOffsetX,
                    self.nSpecialistY + self.nPlusOffsetY, self.nPlusWidth,
                    self.nPlusHeight, WidgetTypes.WIDGET_CHANGE_SPECIALIST, i,
                    1, ButtonStyles.BUTTON_STYLE_CITY_PLUS)
                screen.hide(szName)

                szName = "SpecialistMinus" + str(i)
                screen.setButtonGFC(
                    szName, u"", "", self.nFirstSpecialistX +
                    (self.nSpecialistDistance * i) + self.nMinusOffsetX,
                    self.nSpecialistY + self.nMinusOffsetY, self.nMinusWidth,
                    self.nMinusHeight, WidgetTypes.WIDGET_CHANGE_SPECIALIST, i,
                    -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS)
                screen.hide(szName)

                szName = "SpecialistText" + str(i)
                screen.setLabel(
                    szName, "Background", "", CvUtil.FONT_LEFT_JUSTIFY,
                    self.nFirstSpecialistX + (self.nSpecialistDistance * i) +
                    self.nSpecTextOffsetX,
                    self.nSpecialistY + self.nSpecTextOffsetY, 0,
                    FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
                screen.hide(szName)
    def interfaceScreen (self, iFinishedProject):

        #create screen
        screen = CyGInterfaceScreen( "SpaceShipScreen", CvScreenEnums.SPACE_SHIP_SCREEN)

        #setup panel
        self.windowWidth = screen.getXResolution()
        self.windowHeight = screen.getYResolution()
        screen.setDimensions(0, 0, self.windowWidth, self.windowHeight)
        self.W_SCREEN = 400
        self.X_SCREEN = self.windowWidth - self.W_SCREEN - 10
        self.H_SCREEN = 768
        self.Y_SCREEN = self.windowHeight / 2 - self.H_SCREEN / 2
        self.Y_TITLE = self.Y_SCREEN + 20
        self.activeProject = iFinishedProject

        self.PADDING = 15
        self.W_EXIT = 120
        self.H_EXIT = 40
        self.X_EXIT = self.X_SCREEN + self.W_SCREEN - self.W_EXIT - self.PADDING
        self.Y_EXIT = self.Y_SCREEN + self.H_SCREEN - self.H_EXIT - self.PADDING

        self.W_LAUNCH = 100
        self.H_LAUNCH = 60
        self.X_LAUNCH = self.X_SCREEN - self.PADDING - self.W_LAUNCH
        self.Y_LAUNCH = self.Y_SCREEN + self.H_SCREEN - self.H_LAUNCH - self.PADDING

        self.X_LAUNCH_LABEL1 = self.X_SCREEN + self.PADDING
        self.Y_LAUNCH_LABEL1 = self.Y_LAUNCH + 8
        self.X_LAUNCH_LABEL2 = self.X_LAUNCH_LABEL1
        self.Y_LAUNCH_LABEL2 = self.Y_LAUNCH + 32

        self.TYPE_BUTTON = 0
        self.ZOOM_BUTTON = 1
        self.ADD_BUTTON = 2
        self.LAUNCH_BUTTON = 3

        #main panel
        screen.addPanel("SpaceShipMainPanel", "", "", True, True, self.X_SCREEN, self.Y_SCREEN, self.W_SCREEN, self.H_SCREEN, PanelStyles.PANEL_STYLE_EMPTY)

        #create list of spaceship components
        self.componentProjects = []
        self.spaceVictory = -1
        for i in xrange(gc.getNumProjectInfos()):
            component = gc.getProjectInfo(i)
            if (component.isSpaceship()):
                self.spaceVictory = component.getVictoryPrereq()
                self.componentProjects.append(i);

        #title text
        self.finishedLabelX = 10
        self.finishedLabelY = 10
        self.finishedLabelX2 = self.finishedLabelX
        self.finishedLabelY2 = self.finishedLabelY + 30
        if(self.activeProject >= 0):
            screen.setLabel("FinishedLabel", "SpaceShipMainPanel", "<color=255,255,0><font=4>" + localText.getText("TXT_KEY_WONDER_SCREEN_TEXT", (gc.getProjectInfo(self.activeProject).getDescription(),)) + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.finishedLabelX, self.finishedLabelY, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel("FinishedLabel2", "SpaceShipMainPanel", "<color=255,255,0><font=4>" + localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_ADD_COMPONENT", ()) + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.finishedLabelX2, self.finishedLabelY2, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
        else:
            #check if landed on alpha centauri
            activeTeam = gc.getGame().getActiveTeam()
            victoryCountdown = gc.getTeam(activeTeam).getVictoryCountdown(self.spaceVictory)
            gameState = gc.getGame().getGameState()
            if(((gameState == GameStateTypes.GAMESTATE_EXTENDED) and (victoryCountdown > 0)) or (victoryCountdown == 0)):
                screen.setLabel("FinishedLabel", "SpaceShipMainPanel", "<color=255,255,0><font=4>" + localText.getText("TXT_KEY_SPACE_SHIP_ALPHA_CENTAURI", ()) + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.finishedLabelX, self.finishedLabelY, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            else: #normal welcome
                screen.setLabel("FinishedLabel", "SpaceShipMainPanel", "<color=255,255,0><font=4>" + localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_WELCOME", ()) + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.finishedLabelX, self.finishedLabelY, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
                if (victoryCountdown > 0): # K-Mod (success chance is now shown near the launch button)
                    screen.setLabel("FinishedLabel2", "SpaceShipMainPanel", "<color=255,255,0><font=4>" + localText.getText("TXT_KEY_SPACESHIP_CHANCE_OF_SUCCESS", (gc.getTeam(gc.getGame().getActiveTeam()).getLaunchSuccessRate(self.spaceVictory), )) + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.finishedLabelX2, self.finishedLabelY2, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        #component panels
        self.numComponents = len(self.componentProjects)
        self.componentPanelYOffset = 10
        self.componentPanelXOffset = 10
        self.componentPanelHeight = self.H_SCREEN / (self.numComponents + 1)
        self.componentPanelHeightExtra = 10
        self.componentPanelWidth = self.W_SCREEN - 2 * self.componentPanelXOffset
        self.componentNameXOffset = 12
        self.componentNameYOffset = 10
        self.componentTypeWidth = 60
        self.componentTypeHeight = 30
        self.componentTypeXOffset = self.componentPanelWidth - self.componentTypeWidth - 10
        self.componentTypeYOffset = 35
        self.componentZoomWidth = 60
        self.componentZoomHeight = 30
        self.componentZoomXOffset = self.componentPanelWidth - self.componentZoomWidth - 10
        self.componentZoomYOffset = 65
        self.componentAddWidth = 60
        self.componentAddHeight = 60
        self.componentAddXOffset = 10
        self.componentAddYOffset = 35
        self.componentModelHeight = self.componentPanelHeight
        self.componentModelWidth = 2 * self.componentModelHeight
        self.componentModelXOffset = (self.componentPanelWidth - self.componentModelWidth) / 2
        self.componentModelYOffset = 0
        self.componentCompletedLabelXOffset = 12
        self.componentCompletedLabelYOffset = 40
        self.componentRequiredLabelXOffset = 12
        self.componentRequiredLabelYOffset = 55
        self.componentInProductionLabelXOffset = 12
        self.componentInProductionLabelYOffset = 70

        screen.setSpaceShip(self.activeProject)
        self.rebuildComponentPanel()

        #show spaceship screen
        screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)

        return 0
    def rebuildComponentPanel(self):
        screen = CyGInterfaceScreen( "SpaceShipScreen", CvScreenEnums.SPACE_SHIP_SCREEN)
        self.removeComponentsPanel()

        #check if already landed spaceship
        activeTeam = gc.getGame().getActiveTeam()
        victoryCountdown = gc.getTeam(activeTeam).getVictoryCountdown(self.spaceVictory)
        gameState = gc.getGame().getGameState()
        if(not (((gameState == GameStateTypes.GAMESTATE_EXTENDED) and (victoryCountdown > 0)) or (victoryCountdown == 0))):

            #loop through each panel
            for i in xrange(self.numComponents):
                index = self.componentProjects[i]
                component = gc.getProjectInfo(index)
                xPosition = self.X_SCREEN + self.componentPanelXOffset
                yPosition = self.Y_SCREEN + self.componentPanelYOffset + i * self.componentPanelHeight

                #panel
                xPositionOffset = 0
                if(index == self.activeProject):
                    xPositionOffset = 80
                screen.addPanel("ComponentPanel" + str(i), "", "", True, True, xPosition - xPositionOffset, yPosition, self.componentPanelWidth + xPositionOffset, self.componentPanelHeight + self.componentPanelHeightExtra, PanelStyles.PANEL_STYLE_TECH)
                screen.setLabel("ComponentLabel" + str(i), "ComponentPanel" + str(i), "<color=255,255,0><font=3b>" + component.getDescription() + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, xPosition - xPositionOffset + self.componentNameXOffset, yPosition + self.componentNameYOffset, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                #completed
                completed = gc.getTeam(activeTeam).getProjectCount(index)
                totalAllowed = component.getMaxTeamInstances()
                screen.setLabel("ComponentCompletedLabel" + str(i), "ComponentPanel" + str(i), localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_COMPLETED_LABEL", (completed, totalAllowed)), CvUtil.FONT_LEFT_JUSTIFY, xPosition + self.componentCompletedLabelXOffset, yPosition + self.componentCompletedLabelYOffset, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                #required
                required = component.getVictoryMinThreshold(self.spaceVictory)
                screen.setLabel("ComponentRequiredLabel" + str(i), "ComponentPanel" + str(i), localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_REQUIRED_LABEL", (required,)), CvUtil.FONT_LEFT_JUSTIFY, xPosition + self.componentRequiredLabelXOffset, yPosition + self.componentRequiredLabelYOffset, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                #in production
                inProduction = gc.getTeam(activeTeam).getProjectMaking(index)
                screen.setLabel("ComponentInProductionLabel" + str(i), "ComponentPanel" + str(i), localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_IN_PRODUCTION_LABEL", (inProduction,)), CvUtil.FONT_LEFT_JUSTIFY, xPosition + self.componentInProductionLabelXOffset, yPosition + self.componentInProductionLabelYOffset, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                #panel color
                if(completed >= required): #green
                    screen.setPanelColor("ComponentPanel" + str(i), 85, 150, 87)
                else: #check if can build
                    canBuild = True
                    if(not gc.getTeam(activeTeam).isHasTech(component.getTechPrereq())):
                        canBuild = False
                    else:
                        for j in xrange(gc.getNumProjectInfos()):
                            if(gc.getTeam(activeTeam).getProjectCount(j) < component.getProjectsNeeded(j)):
                                canBuild = False

                    if(not canBuild): #grey
                        screen.setPanelColor("ComponentPanel" + str(i), 128, 128, 128)

                #type button if necessary
                if(screen.spaceShipCanChangeType(index) and (victoryCountdown < 0)):
                    screen.setButtonGFC("ComponentTypeButton" + str(i), localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_TYPE_BUTTON", ()), "", xPosition + self.componentTypeXOffset, yPosition + self.componentTypeYOffset, self.componentTypeWidth, self.componentTypeHeight, WidgetTypes.WIDGET_GENERAL, self.TYPE_BUTTON, i, ButtonStyles.BUTTON_STYLE_STANDARD )

                #zoom button
                if(victoryCountdown < 0):
                    screen.setButtonGFC("ComponentZoomButton" + str(i), localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_ZOOM_BUTTON", ()), "", xPosition + self.componentZoomXOffset, yPosition + self.componentZoomYOffset, self.componentZoomWidth, self.componentZoomHeight, WidgetTypes.WIDGET_GENERAL, self.ZOOM_BUTTON, i, ButtonStyles.BUTTON_STYLE_STANDARD )

                #add button
                if(index == self.activeProject):
                    screen.setButtonGFC("ComponentAddButton", localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_ADD_BUTTON", ()), "", xPosition - xPositionOffset + self.componentAddXOffset, yPosition + self.componentAddYOffset, self.componentAddWidth, self.componentAddHeight, WidgetTypes.WIDGET_GENERAL, self.ADD_BUTTON, i, ButtonStyles.BUTTON_STYLE_STANDARD )

                #component model
                modelType = gc.getTeam(activeTeam).getProjectDefaultArtType(index)
                screen.addSpaceShipWidgetGFC("ComponentModel" + str(i), xPosition + self.componentModelXOffset, yPosition + self.componentModelYOffset, self.componentModelWidth, self.componentModelHeight, index, modelType, WidgetTypes.WIDGET_GENERAL, -1, -1)

            #launch button
            activeTeam = gc.getGame().getActiveTeam()
            if(victoryCountdown > 0):
                victoryDate = CyGameTextMgr().getTimeStr(gc.getGame().getGameTurn() + victoryCountdown, False)
                screen.setLabel("ArrivalLabel1", "SpaceShipMainPanel", "<color=255,255,0><font=3b>" + localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_ARRIVAL", ()) + ": " + victoryDate + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.X_LAUNCH_LABEL1, self.Y_LAUNCH_LABEL1, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
                screen.setLabel("ArrivalLabel2", "SpaceShipMainPanel", "<color=255,255,0><font=3b>" + localText.getText("TXT_KEY_REPLAY_SCREEN_TURNS", ()) + ": " + str(victoryCountdown) + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.X_LAUNCH_LABEL2, self.Y_LAUNCH_LABEL2, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            elif(gc.getTeam(gc.getGame().getActiveTeam()).canLaunch(self.spaceVictory)):
                delay = gc.getTeam(gc.getGame().getActiveTeam()).getVictoryDelay(self.spaceVictory)
                screen.setLabel("LaunchLabel1", "SpaceShipMainPanel", "<color=255,255,0><font=3b>" + localText.getText("TXT_KEY_SPACESHIP_CHANCE_OF_SUCCESS", (gc.getTeam(gc.getGame().getActiveTeam()).getLaunchSuccessRate(self.spaceVictory), )) + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.X_LAUNCH_LABEL1, self.Y_LAUNCH_LABEL1, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
                screen.setLabel("LaunchLabel2", "SpaceShipMainPanel", "<color=255,255,0><font=3b>" + localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_TRAVEL_TIME_LABEL", (delay,)) + "</font></color>", CvUtil.FONT_LEFT_JUSTIFY, self.X_LAUNCH_LABEL2, self.Y_LAUNCH_LABEL2, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
                screen.setButtonGFC("LaunchButton", localText.getText("TXT_KEY_SPACE_SHIP_SCREEN_LAUNCH_BUTTON", ()), "", self.X_LAUNCH, self.Y_LAUNCH, self.W_LAUNCH, self.H_LAUNCH, WidgetTypes.WIDGET_GENERAL, self.LAUNCH_BUTTON, -1, ButtonStyles.BUTTON_STYLE_STANDARD )



        #exit button
        screen.setButtonGFC("ExitButton", localText.getText("TXT_KEY_PEDIA_SCREEN_EXIT", ()), "", self.X_EXIT, self.Y_EXIT, self.W_EXIT, self.H_EXIT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
示例#5
0
class CvTopCivs:
    "The Greatest Civilizations screen"

    def __init__(self):

        self.X_SCREEN = 0  #205
        self.Y_SCREEN = 0  #27
        self.W_SCREEN = 1024  #426
        self.H_SCREEN = 768  #470

        self.X_MAIN_PANEL = 250  #250
        self.Y_MAIN_PANEL = 70
        self.W_MAIN_PANEL = 550  #550
        self.H_MAIN_PANEL = 500

        self.iMarginSpace = 15

        self.X_HEADER_PANEL = self.X_MAIN_PANEL + self.iMarginSpace
        self.Y_HEADER_PANEL = self.Y_MAIN_PANEL + self.iMarginSpace
        self.W_HEADER_PANEL = self.W_MAIN_PANEL - (self.iMarginSpace * 2)
        self.H_HEADER_PANEL = self.H_MAIN_PANEL - (self.iMarginSpace * 2)

        #        iWHeaderPanelRemainingAfterLeader = self.W_HEADER_PANEL - self.W_LEADER_ICON + (self.iMarginSpace * 3)
        #        iXHeaderPanelRemainingAfterLeader = self.X_LEADER_ICON + self.W_LEADER_ICON + self.iMarginSpace
        self.X_LEADER_TITLE_TEXT = 500  #iXHeaderPanelRemainingAfterLeader + (iWHeaderPanelRemainingAfterLeader / 2)
        self.Y_LEADER_TITLE_TEXT = self.Y_HEADER_PANEL + self.iMarginSpace
        self.W_LEADER_TITLE_TEXT = self.W_HEADER_PANEL / 3
        self.H_LEADER_TITLE_TEXT = self.H_HEADER_PANEL / 3

        self.X_TEXT_PANEL = self.X_HEADER_PANEL + self.iMarginSpace
        self.Y_TEXT_PANEL = self.Y_HEADER_PANEL + 132
        self.W_TEXT_PANEL = self.W_HEADER_PANEL - (self.iMarginSpace * 2)
        self.H_TEXT_PANEL = 265  #self.H_MAIN_PANEL - self.H_HEADER_PANEL - (self.iMarginSpace * 3) + 10 #10 is the fudge factor
        self.iTEXT_PANEL_MARGIN = 35

        self.X_RANK_TEXT = self.X_MAIN_PANEL + 100  #PAE
        self.Y_RANK_TEXT = 230
        self.W_RANK_TEXT = 500
        self.H_RANK_TEXT = 30

        self.X_EXIT = 460
        self.Y_EXIT = self.Y_MAIN_PANEL + 440
        self.W_EXIT = 120
        self.H_EXIT = 30

    def showScreen(self):

        'Use a popup to display the opening text'
        if (CyGame().isPitbossHost()):
            return

        # Text
        self.TITLE_TEXT = u"<font=3>" + localText.getText(
            "TXT_KEY_TOPCIVS_TITLE", ()).upper() + u"</font>"
        self.EXIT_TEXT = localText.getText("TXT_KEY_PEDIA_SCREEN_EXIT",
                                           ()).upper()

        self.HistorianList = [
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN1", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN2", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN3", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN4", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN5", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN6", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN7", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN8", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN9", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN10", ()),
            localText.getText("TXT_KEY_TOPCIVS_HISTORIAN11", ())
        ]

        self.RankList = [
            localText.getText("TXT_KEY_TOPCIVS_RANK1", ()),
            localText.getText("TXT_KEY_TOPCIVS_RANK2", ()),
            localText.getText("TXT_KEY_TOPCIVS_RANK3", ()),
            localText.getText("TXT_KEY_TOPCIVS_RANK4", ()),
            localText.getText("TXT_KEY_TOPCIVS_RANK5", ()),
            localText.getText("TXT_KEY_TOPCIVS_RANK6", ()),
            localText.getText("TXT_KEY_TOPCIVS_RANK7", ()),
            localText.getText("TXT_KEY_TOPCIVS_RANK8", ())
        ]

        self.TypeList = [
            localText.getText("TXT_KEY_TOPCIVS_WEALTH", ()),
            localText.getText("TXT_KEY_TOPCIVS_POWER", ()),
            localText.getText("TXT_KEY_TOPCIVS_TECH", ()),
            localText.getText("TXT_KEY_TOPCIVS_CULTURE", ()),
            localText.getText("TXT_KEY_TOPCIVS_SIZE", ()),
        ]

        # Randomly choose what category and what historian will be used
        szTypeRand = random.choice(self.TypeList)
        szHistorianRand = random.choice(self.HistorianList)

        # Create screen

        self.screen = CyGInterfaceScreen("CvTopCivs", CvScreenEnums.TOP_CIVS)

        self.screen.setSound("AS2D_TOP_CIVS")
        self.screen.showScreen(PopupStates.POPUPSTATE_QUEUED, False)
        self.screen.showWindowBackground(False)
        self.screen.setDimensions(self.screen.centerX(self.X_SCREEN),
                                  self.screen.centerY(self.Y_SCREEN),
                                  self.W_SCREEN, self.H_SCREEN)

        # Create panels

        # Main
        szMainPanel = "TopCivsMainPanel"
        self.screen.addPanel(szMainPanel, "", "", True, True,
                             self.X_MAIN_PANEL, self.Y_MAIN_PANEL,
                             self.W_MAIN_PANEL, self.H_MAIN_PANEL,
                             PanelStyles.PANEL_STYLE_MAIN)

        # Top
        szHeaderPanel = "TopCivsHeaderPanel"
        szHeaderText = ""  #gc.getLeaderHeadInfo(self.player.getLeaderType()).getDescription() + "\n-" + self.player.getCivilizationDescription(0) + "-"
        self.screen.addPanel(szHeaderPanel, szHeaderText, "", True, True,
                             self.X_HEADER_PANEL, self.Y_HEADER_PANEL,
                             self.W_HEADER_PANEL, self.H_HEADER_PANEL,
                             PanelStyles.PANEL_STYLE_DAWNBOTTOM)

        # Bottom
        szTextPanel = "TopCivsTextPanel"
        szHeaderText = ""  #self.Text_Title
        self.screen.addPanel(szTextPanel, szHeaderText, "", True, True,
                             self.X_TEXT_PANEL, self.Y_TEXT_PANEL,
                             self.W_TEXT_PANEL, self.H_TEXT_PANEL,
                             PanelStyles.PANEL_STYLE_DAWNTOP)

        self.screen.setButtonGFC("Exit", self.EXIT_TEXT, "", self.X_EXIT,
                                 self.Y_EXIT, self.W_EXIT, self.H_EXIT,
                                 WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1,
                                 ButtonStyles.BUTTON_STYLE_STANDARD)

        # Title Text
        self.X_TITLE_TEXT = self.X_HEADER_PANEL + (self.W_HEADER_PANEL / 2)
        self.Y_TITLE_TEXT = self.Y_HEADER_PANEL + 15
        self.screen.setLabel("DawnTitle", "Background", self.TITLE_TEXT,
                             CvUtil.FONT_CENTER_JUSTIFY, self.X_TITLE_TEXT,
                             self.Y_TITLE_TEXT, -2.0, FontTypes.GAME_FONT,
                             WidgetTypes.WIDGET_GENERAL, -1, -1)

        # 1 Text
        self.X_INFO_TEXT = self.X_TITLE_TEXT - 260  #self.X_HEADER_PANEL + (self.W_HEADER_PANEL / 2)
        self.Y_INFO_TEXT = self.Y_TITLE_TEXT + 50
        self.W_INFO_TEXT = self.W_HEADER_PANEL
        self.H_INFO_TEXT = 70
        szText = localText.getText(
            "TXT_KEY_TOPCIVS_TEXT1",
            (szHistorianRand, )) + u"\n" + localText.getText(
                "TXT_KEY_TOPCIVS_TEXT2", (szTypeRand, ))
        self.screen.addMultilineText("InfoText1", szText, self.X_INFO_TEXT,
                                     self.Y_INFO_TEXT, self.W_INFO_TEXT,
                                     self.H_INFO_TEXT,
                                     WidgetTypes.WIDGET_GENERAL, -1, -1,
                                     CvUtil.FONT_CENTER_JUSTIFY)

        self.makeList(szTypeRand)

    def makeList(self, szType):

        # Determine the list of top civs

        # Will eventually Store [iValue, iPlayerID]
        self.aiTopCivsValues = []

        # Loop through all players except the barbs
        for iPlayerLoop in xrange(gc.getMAX_PLAYERS() - 1):

            if (gc.getPlayer(iPlayerLoop).isAlive()):

                if (szType == localText.getText("TXT_KEY_TOPCIVS_WEALTH", ())):

                    self.aiTopCivsValues.append(
                        [gc.getPlayer(iPlayerLoop).getGold(), iPlayerLoop])
                    CvUtil.pyPrint(
                        "Player %d Num Gold: %d" %
                        (iPlayerLoop, gc.getPlayer(iPlayerLoop).getGold()))

                if (szType == localText.getText("TXT_KEY_TOPCIVS_POWER", ())):

                    self.aiTopCivsValues.append(
                        [gc.getPlayer(iPlayerLoop).getPower(), iPlayerLoop])

                if (szType == localText.getText("TXT_KEY_TOPCIVS_TECH", ())):

                    iPlayerNumTechs = 0
                    iNumTotalTechs = gc.getNumTechInfos()

                    for iTechLoop in xrange(iNumTotalTechs):

                        bPlayerHasTech = gc.getTeam(
                            gc.getPlayer(iPlayerLoop).getTeam()).isHasTech(
                                iTechLoop)

                        if (bPlayerHasTech):
                            iPlayerNumTechs = iPlayerNumTechs + 1

                    self.aiTopCivsValues.append([iPlayerNumTechs, iPlayerLoop])

                if (szType == localText.getText("TXT_KEY_TOPCIVS_CULTURE",
                                                ())):

                    self.aiTopCivsValues.append([
                        gc.getPlayer(iPlayerLoop).countTotalCulture(),
                        iPlayerLoop
                    ])

                if (szType == localText.getText("TXT_KEY_TOPCIVS_SIZE", ())):

                    self.aiTopCivsValues.append([
                        gc.getPlayer(iPlayerLoop).getTotalLand(), iPlayerLoop
                    ])

        # Lowest to Highest
        self.aiTopCivsValues.sort()
        # Switch it around - want the best to be first
        self.aiTopCivsValues.reverse()

        self.printList(szType)

    def printList(self, szType):

        # Print out the list
        for iRankLoop in xrange(8):

            if (iRankLoop > len(self.aiTopCivsValues) - 1):
                return

            iPlayer = self.aiTopCivsValues[iRankLoop][1]
            #             iValue = self.aiTopCivsValues[iRankLoop][0]

            szPlayerName = gc.getPlayer(iPlayer).getNameKey()

            if (szPlayerName != ""):

                pActivePlayerTeam = gc.getTeam(
                    gc.getPlayer(CyGame().getActivePlayer()).getTeam())
                iPlayerTeam = gc.getPlayer(iPlayer).getTeam()
                szCivText = ""

                # Does the Active player know this player exists?
                if (iPlayer == CyGame().getActivePlayer()
                        or pActivePlayerTeam.isHasMet(iPlayerTeam)):
                    szCivText = localText.getText(
                        "TXT_KEY_TOPCIVS_TEXT3",
                        (szPlayerName, self.RankList[iRankLoop]))

                else:
                    szCivText = localText.getText("TXT_KEY_TOPCIVS_UNKNOWN",
                                                  ())

                szWidgetName = "Text" + str(iRankLoop)
                szWidgetDesc = "%d) %s" % (iRankLoop + 1, szCivText)
                iXLoc = self.X_RANK_TEXT
                iYLoc = self.Y_RANK_TEXT + (iRankLoop * self.H_RANK_TEXT)
                #self.screen.setText(szWidgetName, "Background", szWidgetDesc, CvUtil.FONT_LEFT_JUSTIFY, iXLoc, iYLoc, TEXT_Z, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
                self.screen.addMultilineText(szWidgetName,
                                             unicode(szWidgetDesc), iXLoc,
                                             iYLoc, self.W_RANK_TEXT,
                                             self.H_RANK_TEXT,
                                             WidgetTypes.WIDGET_GENERAL, -1,
                                             -1, CvUtil.FONT_LEFT_JUSTIFY)

    def turnChecker(self, iTurnNum):

        # Check to see if this is a turn when the screen should pop up (every 50 turns)
        if (not CyGame().isNetworkMultiPlayer()
                and CyGame().getActivePlayer() >= 0):
            if (iTurnNum % 50 == 0 and iTurnNum > 0
                    and gc.getPlayer(CyGame().getActivePlayer()).isAlive()):
                self.showScreen()

    #####################################################################################################################################

    def handleInput(self, inputClass):
        self.screen = CyGInterfaceScreen("CvTopCivs", CvScreenEnums.TOP_CIVS)

        if (inputClass.getFunctionName() == "Exit"
                and inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
            self.screen.hideScreen()
            return 1
        elif (inputClass.getData() == int(InputTypes.KB_RETURN)):
            self.screen.hideScreen()
            return 1
        return 0

    def update(self, fDelta):
        return