def hideSpecialists(self):
     screen = CyGInterfaceScreen("DomesticAdvisor",
                                 CvScreenEnums.DOMESTIC_ADVISOR)
     for i in xrange(gc.getNumSpecialistInfos()):
         if (gc.getSpecialistInfo(i).isVisible()):
             screen.hide("SpecialistImage" + str(i))
             screen.hide("SpecialistPlus" + str(i))
             screen.hide("SpecialistMinus" + str(i))
             screen.hide("SpecialistText" + str(i))
Ejemplo n.º 2
0
    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 handleInput(self, inputClass):
        ' Calls function mapped in DomesticAdvisorInputMap'
        # only get from the map if it has the key

        if (inputClass.getNotifyCode() ==
                NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED):
            if (inputClass.getMouseX() == 0):
                screen = CyGInterfaceScreen("DomesticAdvisor",
                                            CvScreenEnums.DOMESTIC_ADVISOR)
                screen.hideScreen()

                CyInterface().selectCity(
                    gc.getPlayer(inputClass.getData1()).getCity(
                        inputClass.getData2()), True)

                popupInfo = CyPopupInfo()
                popupInfo.setButtonPopupType(
                    ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
                popupInfo.setText(u"showDomesticAdvisor")
                popupInfo.addPopup(inputClass.getData1())
            else:
                self.updateAppropriateCitySelection()
                self.updateSpecialists()
        elif (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
            if (inputClass.getFunctionName() == "DomesticSplit"):
                screen = CyGInterfaceScreen("DomesticAdvisor",
                                            CvScreenEnums.DOMESTIC_ADVISOR)
                screen.hideScreen()

        return 0
Ejemplo n.º 4
0
    def interfaceScreen(self):
        "Initial creation of the screen"
        title = BugUtil.getPlainText("TXT_KEY_BUG_OPT_TITLE",
                                     "BUG Mod Options")
        self.pTabControl = CyGTabCtrl(title, False, False)
        self.pTabControl.setModal(1)
        screen = CyGInterfaceScreen("MainInterface",
                                    CvScreenEnums.MAIN_INTERFACE)
        resolutionWidth = screen.getXResolution()
        # resolutionHeigth = screen.getYResolution()
        self.pTabControl.setSize(resolutionWidth - 60, 750)
        # self.pTabControl.setSize(1000, 750)
        self.pTabControl.setControlsExpanding(False)
        self.pTabControl.setColumnLength(self.iScreenHeight)

        if self.options.isLoaded():
            self.createTabs()
        else:
            BugErrorOptionsTab.BugErrorOptionsTab(self).create(
                self.pTabControl)
 def updateAppropriateCitySelection(self):
     nCities = gc.getPlayer(gc.getGame().getActivePlayer()).getNumCities()
     screen = CyGInterfaceScreen("DomesticAdvisor",
                                 CvScreenEnums.DOMESTIC_ADVISOR)
     screen.updateAppropriateCitySelection("CityListBackground", nCities, 1)
     self.listSelectedCities = []
     for i in xrange(nCities):
         if screen.isRowSelected("CityListBackground", i):
             self.listSelectedCities.append(
                 screen.getTableText("CityListBackground", 2, i))
Ejemplo n.º 6
0
 def getScreen(self):
     return CyGInterfaceScreen(self.SCREEN_NAME, CvScreenEnums.ESPIONAGE_ADVISOR)
    def interfaceScreen(self, iEra):

        # K-Mod note: I've taken out all reference to X_SCREEN and Y_SCREEN, and instead set it up to be automatically centered. (I haven't left the old code in. I've just deleted it.)
        self.W_SCREEN = 775
        self.H_SCREEN = 660
        self.Y_TITLE = 20

        self.X_EXIT = self.W_SCREEN / 2 - 50
        self.Y_EXIT = self.H_SCREEN - 50
        self.W_EXIT = 120
        self.H_EXIT = 30

        if (CyInterface().noTechSplash()):
            return 0

        # player = PyPlayer(CyGame().getActivePlayer())

        screen = CyGInterfaceScreen("EraMovieScreen" + str(iEra),
                                    CvScreenEnums.ERA_MOVIE_SCREEN)
        #screen.setDimensions(screen.centerX(0), screen.centerY(0), self.W_SCREEN, self.H_SCREEN) # This doesn't work. Those 'center' functions assume a particular window size. (not original code)
        screen.setDimensions(screen.getXResolution() / 2 - self.W_SCREEN / 2,
                             screen.getYResolution() / 2 - self.H_SCREEN / 2 -
                             70, self.W_SCREEN, self.H_SCREEN)  # K-Mod
        screen.addPanel("EraMoviePanel", "", "", True, True, 0, 0,
                        self.W_SCREEN, self.H_SCREEN,
                        PanelStyles.PANEL_STYLE_MAIN)

        screen.showWindowBackground(True)
        screen.setRenderInterfaceOnly(False)
        screen.setSound("AS2D_NEW_ERA")
        screen.showScreen(PopupStates.POPUPSTATE_MINIMIZED, False)

        # Header...
        szHeader = localText.getText("TXT_KEY_ERA_SPLASH_SCREEN",
                                     (gc.getEraInfo(iEra).getTextKey(), ))
        szHeaderId = "EraTitleHeader" + str(iEra)
        screen.setText(szHeaderId, "Background", szHeader,
                       CvUtil.FONT_CENTER_JUSTIFY, self.W_SCREEN / 2,
                       self.Y_TITLE, 0, FontTypes.TITLE_FONT,
                       WidgetTypes.WIDGET_GENERAL, -1, -1)

        screen.setButtonGFC("EraExit" + str(iEra),
                            localText.getText("TXT_KEY_MAIN_MENU_OK", ()), "",
                            self.X_EXIT, self.Y_EXIT, self.W_EXIT, self.H_EXIT,
                            WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1,
                            ButtonStyles.BUTTON_STYLE_STANDARD)

        # Play the movie
        if iEra == 1:
            szMovie = "Art/Movies/Era/Era01-Classical.dds"
        elif iEra == 2:
            szMovie = "Art/Movies/Era/Era02-Medeival.dds"
        elif iEra == 3:
            szMovie = "Art/Movies/Era/Era03-Renaissance.dds"
        elif iEra == 4:
            szMovie = "Art/Movies/Era/Era04-Industrial.dds"
        else:
            szMovie = "Art/Movies/Era/Era05-Modern.dds"

        screen.addDDSGFC("EraMovieMovie" + str(iEra), szMovie, 27, 50, 720,
                         540, WidgetTypes.WIDGET_GENERAL, -1, -1)

        return 0
Ejemplo n.º 8
0
 def getScreen(self):
     """
     Returns the CyGInterfaceScreen object for this screen.
     """
     return CyGInterfaceScreen(self.SCREEN_NAME, self.screenID)
    def interfaceScreen(self):

        player = gc.getPlayer(gc.getGame().getActivePlayer())

        # Create a new screen, called DomesticAdvisor, using the file CvDomesticAdvisor.py for input
        screen = CyGInterfaceScreen("DomesticAdvisor",
                                    CvScreenEnums.DOMESTIC_ADVISOR)

        self.nScreenWidth = screen.getXResolution() - 30
        self.nScreenHeight = screen.getYResolution() - 250
        self.nTableWidth = self.nScreenWidth - 35
        self.nTableHeight = self.nScreenHeight - 85
        self.nNormalizedTableWidth = 970

        self.nFirstSpecialistX = 30
        self.nSpecialistY = self.nScreenHeight - 55
        self.nSpecialistWidth = 32
        self.nSpecialistLength = 32
        self.nSpecialistDistance = 100

        # Offset from Specialist Image/Size for the Specialist Plus/Minus buttons
        self.nPlusOffsetX = -4
        self.nMinusOffsetX = 16
        self.nPlusOffsetY = self.nMinusOffsetY = 30
        self.nPlusWidth = self.nPlusHeight = self.nMinusWidth = self.nMinusHeight = 20

        # Offset from Specialist Image for the Specialist Text
        self.nSpecTextOffsetX = 40
        self.nSpecTextOffsetY = 10

        screen.setRenderInterfaceOnly(True)
        screen.setDimensions(15, 100, self.nScreenWidth, self.nScreenHeight)
        screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)

        # Here we set the background widget and exit button, and we show the screen
        screen.addPanel("DomesticAdvisorBG", u"", u"", True, False, 0, 0,
                        self.nScreenWidth, self.nScreenHeight,
                        PanelStyles.PANEL_STYLE_MAIN)
        screen.setText(
            "DomesticExit", "Background",
            localText.getText("TXT_KEY_PEDIA_SCREEN_EXIT",
                              ()).upper(), CvUtil.FONT_RIGHT_JUSTIFY,
            self.nScreenWidth - 25, self.nScreenHeight - 45, -0.1,
            FontTypes.TITLE_FONT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1)

        bCanLiberate = False
        (loopCity, iter) = player.firstCity(False)
        while loopCity:
            if loopCity.getLiberationPlayer(False) != -1:
                # UNOFFICIAL_PATCH begin
                if not gc.getTeam(
                        gc.getPlayer(loopCity.getLiberationPlayer(False)).
                        getTeam()).isAtWar(CyGame().getActiveTeam()):
                    bCanLiberate = True
                    break
                # UNOFFICIAL_PATCH end
            (loopCity, iter) = player.nextCity(iter, False)

        if bCanLiberate or player.canSplitEmpire():
            screen.setImageButton(
                "DomesticSplit", "", self.nScreenWidth - 180,
                self.nScreenHeight - 45, 28, 28, WidgetTypes.WIDGET_ACTION,
                gc.getControlInfo(
                    ControlTypes.CONTROL_FREE_COLONY).getActionInfoIndex(), -1)
            screen.setStyle("DomesticSplit", "Button_HUDAdvisorVictory_Style")

        # Erase the flag?
        CyInterface().setDirty(InterfaceDirtyBits.MiscButtons_DIRTY_BIT, True)

        # Draw the city list...
        self.drawContents()
Ejemplo n.º 10
0
 def getScreen(self):
     screen = CyGInterfaceScreen(self.SCREEN_NAME + str(self.iTech), self.nScreenId)
     return screen
    def handleInput (self, inputClass):
        if(inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
            data1 = inputClass.getData1()
            data2 = inputClass.getData2()
            if(data1 == self.TYPE_BUTTON):
                screen = CyGInterfaceScreen( "SpaceShipScreen", CvScreenEnums.SPACE_SHIP_SCREEN)
                xPosition = self.X_SCREEN + self.componentPanelXOffset
                yPosition = self.Y_SCREEN + self.componentPanelYOffset + data2 * self.componentPanelHeight
                index = self.componentProjects[data2]
                screen.spaceShipChangeType(index)
                activeTeam = gc.getGame().getActiveTeam()
                modelType = gc.getTeam(activeTeam).getProjectDefaultArtType(index)
                screen.addSpaceShipWidgetGFC("ComponentModel" + str(data2), xPosition + self.componentModelXOffset, yPosition + self.componentModelYOffset, self.componentModelWidth, self.componentModelHeight, index, modelType, WidgetTypes.WIDGET_GENERAL, -1, -1)
            elif(data1 == self.ZOOM_BUTTON):
                screen = CyGInterfaceScreen( "SpaceShipScreen", CvScreenEnums.SPACE_SHIP_SCREEN)
                screen.spaceShipZoom(self.componentProjects[data2])
            elif(data1 == self.ADD_BUTTON):
                screen = CyGInterfaceScreen( "SpaceShipScreen", CvScreenEnums.SPACE_SHIP_SCREEN)
                screen.spaceShipFinalize()

                #adjust interface
                screen.deleteWidget("ComponentAddButton")
                self.activeProject = -1
                self.rebuildComponentPanel()
            elif(data1 == self.LAUNCH_BUTTON):
                screen = CyGInterfaceScreen( "SpaceShipScreen", CvScreenEnums.SPACE_SHIP_SCREEN)
                screen.spaceShipLaunch()

                self.removeComponentsPanel()

        return 0
    def removeComponentsPanel(self):
        screen = CyGInterfaceScreen( "SpaceShipScreen", CvScreenEnums.SPACE_SHIP_SCREEN)
        screen.deleteWidget("SpaceShipMainPanel")
        screen.deleteWidget("ComponentAddButton")
        screen.deleteWidget("LaunchLabel")
        screen.deleteWidget("LaunchButton")
        screen.deleteWidget("ExitButton")

        for i in xrange(self.numComponents):
            screen.deleteWidget("ComponentPanel" + str(i))
            screen.deleteWidget("ComponentLabel" + str(i))
            screen.deleteWidget("ComponentCompletedLabel" + str(i))
            screen.deleteWidget("ComponentRequiredLabel" + str(i))
            screen.deleteWidget("ComponentInProductionLabel" + str(i))
            screen.deleteWidget("ComponentTypeButton" + str(i))
            screen.deleteWidget("ComponentZoomButton" + str(i))
            screen.deleteWidget("ComponentModel" + str(i))
Ejemplo n.º 13
0
 def getScreen(self):
     return CyGInterfaceScreen(self.PEDIA_MAIN_SCREEN,
                               SevoScreenEnums.PEDIA_MAIN)
 def getScreen(self):
     return CyGInterfaceScreen(self.SCREEN_NAME,
                               CvScreenEnums.FINANCE_ADVISOR)
    def drawHeaders(self):

        # Get the screen and the player
        screen = CyGInterfaceScreen("DomesticAdvisor",
                                    CvScreenEnums.DOMESTIC_ADVISOR)

        # Zoom to City
        screen.setTableColumnHeader("CityListBackground", 0, "",
                                    (20 * self.nTableWidth) /
                                    self.nNormalizedTableWidth)

        # Name Column
        screen.setTableColumnHeader(
            "CityListBackground", 1,
            "<font=2>" + localText.getText("TXT_KEY_DOMESTIC_ADVISOR_NAME",
                                           ()) + "</font>",
            (120 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Population Column
        # BTS: localText.getText("TXT_KEY_POPULATION", ())
        screen.setTableColumnHeader(
            "CityListBackground", 2, "<font=2>" +
            u"%c" % CyGame().getSymbolID(FontSymbols.ANGRY_POP_CHAR) +
            "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Cultivation status
        screen.setTableColumnHeader(
            "CityListBackground", 3, "<font=2>" +
            (u"%c" %
             gc.getBonusInfo(gc.getInfoTypeForString("BONUS_COW")).getChar()) +
            "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Settled Slaves Column
        screen.setTableColumnHeader(
            "CityListBackground", 4, "<font=2>" + (u"%c" % gc.getBonusInfo(
                gc.getInfoTypeForString("BONUS_SLAVES")).getChar()) +
            "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Settled Glads Column
        screen.setTableColumnHeader(
            "CityListBackground", 5, "<font=2>" + u"%c" % gc.getBonusInfo(
                gc.getInfoTypeForString("BONUS_BRONZE")).getChar() + "</font>",
            (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Happiness Column
        screen.setTableColumnHeader(
            "CityListBackground", 6, "<font=2>" +
            (u"%c" % CyGame().getSymbolID(FontSymbols.HAPPY_CHAR)) + "</font>",
            (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Health Column
        screen.setTableColumnHeader(
            "CityListBackground", 7, "<font=2>" +
            (u"%c" % CyGame().getSymbolID(FontSymbols.HEALTHY_CHAR)) +
            "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Food Column
        screen.setTableColumnHeader(
            "CityListBackground", 8, "<font=2>" +
            (u"%c" % gc.getYieldInfo(YieldTypes.YIELD_FOOD).getChar()) +
            "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Production Column
        screen.setTableColumnHeader(
            "CityListBackground", 9, "<font=2>" +
            (u"%c" % gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar()) +
            "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Gold Column
        screen.setTableColumnHeader(
            "CityListBackground", 10, "<font=2>" +
            (u"%c" % gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getChar())
            + "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Research Column
        szText = u"%c" % (gc.getCommerceInfo(
            CommerceTypes.COMMERCE_RESEARCH).getChar())
        screen.setTableColumnHeader(
            "CityListBackground", 11, "<font=2>" + szText,
            (40 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Espionage Column
        szText = u"%c" % (gc.getCommerceInfo(
            CommerceTypes.COMMERCE_ESPIONAGE).getChar())
        screen.setTableColumnHeader(
            "CityListBackground", 12, "<font=2>" + szText,
            (40 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Culture Column
        screen.setTableColumnHeader(
            "CityListBackground", 13, "<font=2>" +
            (u"%c" %
             gc.getCommerceInfo(CommerceTypes.COMMERCE_CULTURE).getChar()) +
            "</font>", (60 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Trade Column
        screen.setTableColumnHeader(
            "CityListBackground", 14, "<font=2>" +
            (u"%c" % CyGame().getSymbolID(FontSymbols.TRADE_CHAR)) + "</font>",
            (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Maintenance Column
        screen.setTableColumnHeader(
            "CityListBackground", 15, "<font=2>" +
            (u"%c" % CyGame().getSymbolID(FontSymbols.BAD_GOLD_CHAR)) +
            "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Great Person Column
        screen.setTableColumnHeader(
            "CityListBackground", 16, "<font=2>" +
            (u"%c" % CyGame().getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR)) +
            "</font>", (70 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Garrison Column
        screen.setTableColumnHeader(
            "CityListBackground", 17, "<font=2>" +
            (u"%c" % CyGame().getSymbolID(FontSymbols.DEFENSE_CHAR)) +
            "</font>", (35 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Production Column
        screen.setTableColumnHeader(
            "CityListBackground", 18, "<font=2>" +
            localText.getText("TXT_KEY_DOMESTIC_ADVISOR_PRODUCING",
                              ()) + "</font>",
            (105 * self.nTableWidth) / self.nNormalizedTableWidth)

        # Liberate Column
        screen.setTableColumnHeader("CityListBackground", 19, "",
                                    (25 * self.nTableWidth) /
                                    self.nNormalizedTableWidth)

        # Stop Growth Column
        screen.setTableColumnHeader(
            "CityListBackground", 20,
            "<font=2>" + localText.getText("TXT_KEY_DOM_ADVISOR_GROWTH1",
                                           ()) + "</font>",
            (90 * self.nTableWidth) / self.nNormalizedTableWidth)
    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 drawContents(self):

        # Get the screen and the player
        screen = CyGInterfaceScreen("DomesticAdvisor",
                                    CvScreenEnums.DOMESTIC_ADVISOR)
        player = gc.getPlayer(CyGame().getActivePlayer())

        screen.moveToFront("Background")

        # Build the table
        screen.addTableControlGFC("CityListBackground", 21, 18, 21,
                                  self.nTableWidth, self.nTableHeight, True,
                                  False, 24, 24,
                                  TableStyles.TABLE_STYLE_STANDARD)
        screen.enableSelect("CityListBackground", True)
        screen.enableSort("CityListBackground")
        screen.setStyle("CityListBackground", "Table_StandardCiv_Style")

        # Loop through the cities
        i = 0
        (loopCity, iter) = player.firstCity(False)
        while loopCity:
            screen.appendTableRow("CityListBackground")
            if (loopCity.getName() in self.listSelectedCities):
                screen.selectRow("CityListBackground", i, True)
            self.updateTable(loopCity, i)
            i += 1
            (loopCity, iter) = player.nextCity(iter, False)

        self.drawHeaders()

        self.drawSpecialists()

        screen.moveToBack("DomesticAdvisorBG")

        self.updateAppropriateCitySelection()

        CyInterface().setDirty(InterfaceDirtyBits.Domestic_Advisor_DIRTY_BIT,
                               True)
    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)
Ejemplo n.º 19
0
 def getScreen(self):
     return CyGInterfaceScreen(self.SCREEN_NAME,
                               CvScreenEnums.CIVICS_SCREEN)
Ejemplo n.º 20
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
    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 )
 def getScreen(self):
     return CyGInterfaceScreen(self.SCREEN_NAME, CvScreenEnums.RELIGION_SCREEN)
    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
Ejemplo n.º 24
0
    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)
Ejemplo n.º 25
0
 def getScreen(self):
     return CyGInterfaceScreen(self.SCREEN_NAME, CvScreenEnums.TRADEROUTE_ADVISOR2)
 def getScreen(self):
     return CyGInterfaceScreen(self.SCREEN_NAME,
                               CvScreenEnums.CORPORATION_SCREEN)
Ejemplo n.º 27
0
 def getScreen(self):
     return CyGInterfaceScreen(self.SCREEN_NAME, self.screenId)
    def updateTable(self, pLoopCity, i):

        screen = CyGInterfaceScreen("DomesticAdvisor",
                                    CvScreenEnums.DOMESTIC_ADVISOR)
        # Flunky TODO use PAE_City.getCityStatus
        # City status (button)
        iBuildingSiedlung = gc.getInfoTypeForString("BUILDING_SIEDLUNG")
        iBuildingKolonie = gc.getInfoTypeForString("BUILDING_KOLONIE")
        iBuildingCity = gc.getInfoTypeForString("BUILDING_STADT")
        iBuildingProvinz = gc.getInfoTypeForString("BUILDING_PROVINZ")
        iBuildingMetropole = gc.getInfoTypeForString("BUILDING_METROPOLE")
        if pLoopCity.getNumRealBuilding(iBuildingMetropole):
            buttonCityStatus = gc.getBuildingInfo(
                iBuildingMetropole).getButton()
        elif pLoopCity.getNumRealBuilding(iBuildingProvinz):
            buttonCityStatus = gc.getBuildingInfo(iBuildingProvinz).getButton()
        elif pLoopCity.getNumRealBuilding(iBuildingCity):
            buttonCityStatus = gc.getBuildingInfo(iBuildingCity).getButton()
        elif pLoopCity.getNumRealBuilding(iBuildingKolonie):
            buttonCityStatus = gc.getBuildingInfo(iBuildingKolonie).getButton()
        else:
            buttonCityStatus = gc.getBuildingInfo(
                iBuildingSiedlung).getButton()

        # BTS: buttonCityStatus = ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_CITYSELECTION").getPath()
        screen.setTableText("CityListBackground", 0, i, "", buttonCityStatus,
                            WidgetTypes.WIDGET_ZOOM_CITY, pLoopCity.getOwner(),
                            pLoopCity.getID(), CvUtil.FONT_LEFT_JUSTIFY)

        # City Name
        szName = pLoopCity.getName()
        # If city is in Civil War
        if pLoopCity.getNumRealBuilding(
                gc.getInfoTypeForString("BUILDING_CIVIL_WAR")):
            szName += (u"%c" %
                       CyGame().getSymbolID(FontSymbols.OCCUPATION_CHAR))
        # Capital or provincial palace
        if pLoopCity.isCapital():
            szName += (u"%c" % CyGame().getSymbolID(FontSymbols.STAR_CHAR))
        elif pLoopCity.isGovernmentCenter():
            szName += (u"%c" %
                       CyGame().getSymbolID(FontSymbols.SILVER_STAR_CHAR))

        for iReligion in xrange(gc.getNumReligionInfos()):
            if pLoopCity.isHasReligion(iReligion):
                if pLoopCity.isHolyCityByType(iReligion):
                    szName += (u"%c" %
                               gc.getReligionInfo(iReligion).getHolyCityChar())
                else:
                    szName += (u"%c" % gc.getReligionInfo(iReligion).getChar())

        for iCorporation in xrange(gc.getNumCorporationInfos()):
            if pLoopCity.isHeadquartersByType(iCorporation):
                szName += (
                    u"%c" %
                    gc.getCorporationInfo(iCorporation).getHeadquarterChar())
            elif pLoopCity.isActiveCorporation(iCorporation):
                szName += (u"%c" %
                           gc.getCorporationInfo(iCorporation).getChar())

        # City name...
        screen.setTableText("CityListBackground", 1, i, szName, "",
                            WidgetTypes.WIDGET_GENERAL, -1, -1,
                            CvUtil.FONT_LEFT_JUSTIFY)

        # Population
        screen.setTableInt("CityListBackground", 2, i,
                           unicode(pLoopCity.getPopulation()), "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Cultivation status
        text = u"%d/%d" % (PAE_Cultivation.getCityCultivatedBonuses(
            pLoopCity,
            0), PAE_Cultivation.getCityCultivationAmount(pLoopCity, 0))
        screen.setTableInt("CityListBackground", 3, i, text, "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Settled Slaves
        iCitySlaves1 = pLoopCity.getFreeSpecialistCount(16)  # SPECIALIST_SLAVE
        iCitySlaves2 = pLoopCity.getFreeSpecialistCount(
            17)  # SPECIALIST_SLAVE_FOOD
        iCitySlaves3 = pLoopCity.getFreeSpecialistCount(
            18)  # SPECIALIST_SLAVE_PROD
        text = u"%d/%d/%d" % (iCitySlaves1, iCitySlaves2, iCitySlaves3)
        screen.setTableInt("CityListBackground", 4, i, text, "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Settled Gladiators
        iCityGlads = pLoopCity.getFreeSpecialistCount(
            15)  # SPECIALIST_GLADIATOR
        screen.setTableInt("CityListBackground", 5, i, unicode(iCityGlads), "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Happiness...
        iNetHappy = pLoopCity.happyLevel() - pLoopCity.unhappyLevel(0)
        szText = unicode(iNetHappy)
        if iNetHappy > 0:
            szText = localText.getText("TXT_KEY_COLOR_POSITIVE",
                                       ()) + szText + localText.getText(
                                           "TXT_KEY_COLOR_REVERT", ())
        elif iNetHappy < 0:
            szText = localText.getText("TXT_KEY_COLOR_NEGATIVE",
                                       ()) + szText + localText.getText(
                                           "TXT_KEY_COLOR_REVERT", ())
        screen.setTableInt("CityListBackground", 6, i, szText, "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Health...
        iNetHealth = pLoopCity.goodHealth() - pLoopCity.badHealth(0)
        szText = unicode(iNetHealth)
        if iNetHealth > 0:
            szText = localText.getText("TXT_KEY_COLOR_POSITIVE",
                                       ()) + szText + localText.getText(
                                           "TXT_KEY_COLOR_REVERT", ())
        elif iNetHealth < 0:
            szText = localText.getText("TXT_KEY_COLOR_NEGATIVE",
                                       ()) + szText + localText.getText(
                                           "TXT_KEY_COLOR_REVERT", ())
        screen.setTableInt("CityListBackground", 7, i, szText, "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Food status...
        iNetFood = pLoopCity.foodDifference(True)

        # PAE city supply
        #pCityPlot = gc.getMap().plot( pLoopCity.getX(), pLoopCity.getY() )
        #iCityMaintainUnits = (pCityPlot.getNumDefenders(pLoopCity.getOwner()) - (pLoopCity.getPopulation() * 2)) / 2
        #if iCityMaintainUnits > 0: iNetFood -= iCityMaintainUnits

        szText = unicode(iNetFood)
        if iNetFood > 0:
            szText = localText.getText("TXT_KEY_COLOR_POSITIVE",
                                       ()) + szText + localText.getText(
                                           "TXT_KEY_COLOR_REVERT", ())
        elif iNetFood < 0:
            szText = localText.getText("TXT_KEY_COLOR_NEGATIVE",
                                       ()) + szText + localText.getText(
                                           "TXT_KEY_COLOR_REVERT", ())
        screen.setTableInt("CityListBackground", 8, i, szText, "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Production status...
        screen.setTableInt(
            "CityListBackground", 9, i,
            unicode(pLoopCity.getYieldRate(YieldTypes.YIELD_PRODUCTION)), "",
            WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

        # Gold status...
        screen.setTableInt(
            "CityListBackground", 10, i,
            unicode(pLoopCity.getCommerceRate(CommerceTypes.COMMERCE_GOLD)),
            "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

        # Science rate...
        screen.setTableInt(
            "CityListBackground", 11, i,
            unicode(pLoopCity.getCommerceRate(
                CommerceTypes.COMMERCE_RESEARCH)), "",
            WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

        # Espionage rate...
        screen.setTableInt(
            "CityListBackground", 12, i,
            unicode(pLoopCity.getCommerceRate(
                CommerceTypes.COMMERCE_ESPIONAGE)), "",
            WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

        # Culture status...
        szCulture = unicode(
            pLoopCity.getCommerceRate(CommerceTypes.COMMERCE_CULTURE))
        iCultureTimes100 = pLoopCity.getCultureTimes100(
            CyGame().getActivePlayer())
        iCultureRateTimes100 = pLoopCity.getCommerceRateTimes100(
            CommerceTypes.COMMERCE_CULTURE)
        if iCultureRateTimes100 > 0:
            iCultureLeftTimes100 = 100 * pLoopCity.getCultureThreshold(
            ) - iCultureTimes100
            if iCultureLeftTimes100 > 0:
                szCulture += u" (" + unicode(
                    (iCultureLeftTimes100 + iCultureRateTimes100 - 1) /
                    iCultureRateTimes100) + u")"

        screen.setTableInt("CityListBackground", 13, i, szCulture, "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Trade
        screen.setTableInt(
            "CityListBackground", 14, i,
            unicode(pLoopCity.getTradeYield(YieldTypes.YIELD_COMMERCE)), "",
            WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

        # Maintenance...
        screen.setTableInt("CityListBackground", 15, i,
                           unicode(pLoopCity.getMaintenance()), "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Great Person
        iGreatPersonRate = pLoopCity.getGreatPeopleRate()
        szGreatPerson = unicode(iGreatPersonRate)
        if iGreatPersonRate > 0:
            iGPPLeft = gc.getPlayer(
                gc.getGame().getActivePlayer()).greatPeopleThreshold(
                    False) - pLoopCity.getGreatPeopleProgress()
            if iGPPLeft > 0:
                iTurnsLeft = iGPPLeft / pLoopCity.getGreatPeopleRate()
                if iTurnsLeft * pLoopCity.getGreatPeopleRate() < iGPPLeft:
                    iTurnsLeft += 1
                szGreatPerson += u" (" + unicode(iTurnsLeft) + u")"

        screen.setTableInt("CityListBackground", 16, i, szGreatPerson, "",
                           WidgetTypes.WIDGET_GENERAL, -1, -1,
                           CvUtil.FONT_LEFT_JUSTIFY)

        # Garrison
        screen.setTableInt(
            "CityListBackground", 17, i,
            unicode(pLoopCity.plot().getNumDefenders(pLoopCity.getOwner())),
            "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

        # Producing
        screen.setTableText(
            "CityListBackground", 18, i,
            pLoopCity.getProductionName() + " (" +
            str(pLoopCity.getGeneralProductionTurnsLeft()) + ")", "",
            WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

        # Liberation
        if pLoopCity.getLiberationPlayer(False) != -1:
            # UNOFFICIAL_PATCH begin
            if not gc.getTeam(
                    gc.getPlayer(pLoopCity.getLiberationPlayer(
                        False)).getTeam()).isAtWar(CyGame().getActiveTeam()):
                screen.setTableText(
                    "CityListBackground", 19, i, "<font=2>" +
                    (u"%c" % CyGame().getSymbolID(FontSymbols.OCCUPATION_CHAR))
                    + "</font>", "", WidgetTypes.WIDGET_GENERAL, -1, -1,
                    CvUtil.FONT_LEFT_JUSTIFY)
            # UNOFFICIAL_PATCH end

        # Stop Growth
        if pLoopCity.AI_isEmphasize(5):
            szText = localText.getText("TXT_KEY_DOM_ADVISOR_GROWTH2", ())
            szText = localText.getText("TXT_KEY_COLOR_NEGATIVE",
                                       ()) + szText + localText.getText(
                                           "TXT_KEY_COLOR_REVERT", ())
        else:
            szText = localText.getText("TXT_KEY_DOM_ADVISOR_GROWTH3", ())
            szText = localText.getText("TXT_KEY_COLOR_POSITIVE",
                                       ()) + szText + localText.getText(
                                           "TXT_KEY_COLOR_REVERT", ())

        screen.setTableText("CityListBackground", 20, i, szText, "",
                            WidgetTypes.WIDGET_GENERAL, -1, -1,
                            CvUtil.FONT_CENTER_JUSTIFY)