def drawContents(self):

        self.deleteAllWidgets()

        # Create a new screen, called FinanceAdvisor, using the file FinanceAdvisor.py for input
        screen = self.getScreen()

        player = gc.getPlayer(self.iActiveLeader)

        numCities = player.getNumCities()

        totalUnitCost = player.calculateUnitCost()
        totalUnitSupply = player.calculateUnitSupply()
        totalMaintenance = player.getTotalMaintenance()
        totalCivicUpkeep = player.getCivicUpkeep([], False)
        totalPreInflatedCosts = player.calculatePreInflatedCosts()
        totalInflatedCosts = player.calculateInflatedCosts()
        goldCommerce = player.getCommerceRate(CommerceTypes.COMMERCE_GOLD)
        if not player.isCommerceFlexible(CommerceTypes.COMMERCE_RESEARCH):
            goldCommerce += player.calculateBaseNetResearch()
        gold = player.getGold()
        goldFromCivs = player.getGoldPerTurn()
        goldPerTurn = player.calculateGoldRate()

        szTreasuryPanel = self.getNextWidgetName()
        screen.addPanel(
            szTreasuryPanel,
            u"",
            "",
            True,
            True,
            self.X_SLIDERS,
            self.Y_TREASURY,
            self.X_EXPENSES + self.PANE_WIDTH - self.X_SLIDERS,
            self.H_TREASURY,
            PanelStyles.PANEL_STYLE_MAIN,
        )
        szText = localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TREASURY", (gold,)).upper()
        if gold < 0:
            if goldPerTurn != 0:
                if gold + goldPerTurn >= 0:
                    szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", goldPerTurn)
                elif goldPerTurn >= 0:
                    szText += BugUtil.getText("TXT_KEY_MISC_POS_WARNING_GOLD_PER_TURN", goldPerTurn)
                else:
                    szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN", goldPerTurn)
        else:
            if goldPerTurn != 0:
                if goldPerTurn >= 0:
                    szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", goldPerTurn)
                elif gold + goldPerTurn >= 0:
                    szText += BugUtil.getText("TXT_KEY_MISC_NEG_WARNING_GOLD_PER_TURN", goldPerTurn)
                else:
                    szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN", goldPerTurn)
        screen.setLabel(
            self.getNextWidgetName(),
            szTreasuryPanel,
            u"<font=4>" + szText + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY,
            (self.X_SLIDERS + self.PANE_WIDTH + self.X_EXPENSES) / 2,
            self.Y_TREASURY + self.H_TREASURY / 2 - self.Y_SPACING / 2,
            self.Z_CONTROLS,
            FontTypes.TITLE_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_GOLD_RESERVE,
            -1,
            -1,
        )

        szCommercePanel = self.getNextWidgetName()
        screen.addPanel(
            szCommercePanel,
            u"",
            "",
            True,
            True,
            self.X_SLIDERS,
            self.Y_LOCATION,
            self.PANE_WIDTH,
            self.PANE_HEIGHT,
            PanelStyles.PANEL_STYLE_MAIN,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_COMMERCE", ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY,
            self.X_SLIDERS + self.PANE_WIDTH / 2,
            self.Y_LOCATION + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )

        szIncomePanel = self.getNextWidgetName()
        screen.addPanel(
            szIncomePanel,
            u"",
            "",
            True,
            True,
            self.X_INCOME,
            self.Y_LOCATION,
            self.PANE_WIDTH,
            self.PANE_HEIGHT,
            PanelStyles.PANEL_STYLE_MAIN,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME_HEADER", ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY,
            self.X_INCOME + self.PANE_WIDTH / 2,
            self.Y_LOCATION + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )

        szExpensePanel = self.getNextWidgetName()
        screen.addPanel(
            szExpensePanel,
            u"",
            "",
            True,
            True,
            self.X_EXPENSES,
            self.Y_LOCATION,
            self.PANE_WIDTH,
            self.PANE_HEIGHT,
            PanelStyles.PANEL_STYLE_MAIN,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES_HEADER", ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY,
            self.X_EXPENSES + self.PANE_WIDTH / 2,
            self.Y_LOCATION + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )

        # Commerce
        yLocation = self.Y_LOCATION
        iCommerce = 0

        # sum all worked tiles' commerce yields for player
        # move to MapUtil?
        iWorkedTileCount = 0
        iWorkedTiles = 0
        for city in PlayerUtil.playerCities(player):
            if not city.isDisorder():
                for i in range(gc.getNUM_CITY_PLOTS()):
                    plot = city.getCityIndexPlot(i)
                    if plot and not plot.isNone() and plot.hasYield():
                        if city.isWorkingPlot(plot):
                            iWorkedTileCount += 1
                            iWorkedTiles += plot.getYield(YieldTypes.YIELD_COMMERCE)

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_WORKED_TILES", (iWorkedTileCount,)) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_SLIDERS + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(iWorkedTiles) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )
        iCommerce += iWorkedTiles

        # trade
        iDomesticTrade, _, iForeignTrade, _ = TradeUtil.calculateTradeRoutes(player)

        if iDomesticTrade > 0:
            if TradeUtil.isFractionalTrade():
                iDomesticTrade //= 100
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_DOMESTIC_TRADE", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_DOMESTIC_TRADE", self.iActiveLeader, 1)
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(iDomesticTrade) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_DOMESTIC_TRADE", self.iActiveLeader, 1)
            )
            iCommerce += iDomesticTrade

        if iForeignTrade > 0:
            if TradeUtil.isFractionalTrade():
                iForeignTrade //= 100
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_FOREIGN_TRADE", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_FOREIGN_TRADE", self.iActiveLeader, 1)
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(iForeignTrade) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_FOREIGN_TRADE", self.iActiveLeader, 1)
            )
            iCommerce += iForeignTrade

            # corporations
        iCorporations = 0
        for city in PlayerUtil.playerCities(player):
            if not city.isDisorder():
                iCorporations += city.getCorporationYield(YieldTypes.YIELD_COMMERCE)

        if iCorporations > 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_CORPORATIONS", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(iCorporations) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            iCommerce += iCorporations

            # specialists
        iSpecialists = 0
        for city in PlayerUtil.playerCities(player):
            if not city.isDisorder():
                for eSpec in range(gc.getNumSpecialistInfos()):
                    iSpecialists += player.specialistYield(eSpec, YieldTypes.YIELD_COMMERCE) * (
                        city.getSpecialistCount(eSpec) + city.getFreeSpecialistCount(eSpec)
                    )

        if iSpecialists > 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_SPECIALISTS", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(iSpecialists) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            iCommerce += iSpecialists

            # buildings
        iTotalCommerce = player.calculateTotalYield(YieldTypes.YIELD_COMMERCE)
        # buildings includes 50% capital bonus for Bureaucracy civic
        iBuildings = iTotalCommerce - iCommerce
        if iBuildings > 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_BUILDINGS", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(iBuildings) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            iCommerce += iBuildings

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_BUG_FINANCIAL_ADVISOR_COMMERCE", ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_SLIDERS + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(iCommerce) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )

        # Slider percentages

        yLocation += 0.5 * self.Y_SPACING
        for iI in range(CommerceTypes.NUM_COMMERCE_TYPES):
            eCommerce = (iI + 1) % CommerceTypes.NUM_COMMERCE_TYPES

            if player.isCommerceFlexible(eCommerce):
                yLocation += self.Y_SPACING
                screen.setButtonGFC(
                    self.getNextWidgetName(),
                    u"",
                    "",
                    self.X_SLIDERS + self.TEXT_MARGIN,
                    int(yLocation) + self.TEXT_MARGIN,
                    20,
                    20,
                    WidgetTypes.WIDGET_CHANGE_PERCENT,
                    eCommerce,
                    gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"),
                    ButtonStyles.BUTTON_STYLE_CITY_PLUS,
                )
                screen.setButtonGFC(
                    self.getNextWidgetName(),
                    u"",
                    "",
                    self.X_SLIDERS + self.TEXT_MARGIN + 24,
                    int(yLocation) + self.TEXT_MARGIN,
                    20,
                    20,
                    WidgetTypes.WIDGET_CHANGE_PERCENT,
                    eCommerce,
                    -gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"),
                    ButtonStyles.BUTTON_STYLE_CITY_MINUS,
                )

                szText = (
                    u"<font=3>"
                    + gc.getCommerceInfo(eCommerce).getDescription()
                    + u" ("
                    + unicode(player.getCommercePercent(eCommerce))
                    + u"%)</font>"
                )
                screen.setLabel(
                    self.getNextWidgetName(),
                    "Background",
                    szText,
                    CvUtil.FONT_LEFT_JUSTIFY,
                    self.X_SLIDERS + self.TEXT_MARGIN + 50,
                    yLocation + self.TEXT_MARGIN,
                    self.Z_CONTROLS + self.DZ,
                    FontTypes.GAME_FONT,
                    WidgetTypes.WIDGET_GENERAL,
                    -1,
                    -1,
                )
                szRate = u"<font=3>" + unicode(player.getCommerceRate(CommerceTypes(eCommerce))) + u"</font>"
                screen.setLabel(
                    self.getNextWidgetName(),
                    "Background",
                    szRate,
                    CvUtil.FONT_RIGHT_JUSTIFY,
                    self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                    yLocation + self.TEXT_MARGIN,
                    self.Z_CONTROLS + self.DZ,
                    FontTypes.GAME_FONT,
                    WidgetTypes.WIDGET_GENERAL,
                    -1,
                    -1,
                )

        yLocation += self.Y_SPACING
        szText = (
            u"<font=3>"
            + gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getDescription()
            + u" ("
            + unicode(player.getCommercePercent(CommerceTypes.COMMERCE_GOLD))
            + u"%)</font>"
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            szText,
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_SLIDERS + self.TEXT_MARGIN + 50,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )
        szCommerce = u"<font=3>" + unicode(goldCommerce) + u"</font>"
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            szCommerce,
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )

        # Income
        yLocation = self.Y_LOCATION
        iTaxRate = player.getCommercePercent(CommerceTypes.COMMERCE_GOLD)

        multipliers = []
        for eBldg in range(gc.getNumBuildingInfos()):
            info = gc.getBuildingInfo(eBldg)
            iMultiplier = info.getCommerceModifier(CommerceTypes.COMMERCE_GOLD)
            if iMultiplier > 0:
                multipliers.append([eBldg, iMultiplier, 0, 0.0])

        iBuildingCount = 0
        iHeadquartersCount = 0
        iShrinesCount = 0
        fTaxes = 0.0
        fBuildings = 0.0
        fHeadquarters = 0.0
        fShrines = 0.0
        fCorporations = 0.0
        fSpecialists = 0.0
        iWealthCount = 0
        fWealth = 0.0
        eWealth = gc.getInfoTypeForString("PROCESS_WEALTH")
        # ignores
        #   CyCity.getReligionCommerce() -- excludes shrines
        #   CyPlayer.getFreeCityCommerce()
        #   CyPlayer.getSpecialistExtraCommerce() * (CyCity.getSpecialistPopulation() + CyCity.getNumGreatPeople())
        for city in PlayerUtil.playerCities(player):
            if not city.isDisorder():
                fCityTaxes = city.getYieldRate(YieldTypes.YIELD_COMMERCE) * iTaxRate / 100.0
                fTaxes += fCityTaxes

                fCityBuildings = 0.0
                fCityHeadquarters = 0.0
                fCityShrines = 0.0
                for eBldg in range(gc.getNumBuildingInfos()):
                    iCount = city.getNumRealBuilding(eBldg)
                    if iCount > 0:
                        iBuildingGold = city.getBuildingCommerceByBuilding(CommerceTypes.COMMERCE_GOLD, eBldg)
                        if iBuildingGold > 0:
                            info = gc.getBuildingInfo(eBldg)
                            if info.getFoundsCorporation() != -1:
                                fCityHeadquarters += iBuildingGold
                                iHeadquartersCount += 1
                            elif info.getGlobalReligionCommerce() != -1:
                                fCityShrines += iBuildingGold
                                iShrinesCount += 1
                            else:
                                fCityBuildings += iBuildingGold
                                iBuildingCount += iCount
                fBuildings += fCityBuildings
                fHeadquarters += fCityHeadquarters
                fShrines += fCityShrines

                fCityCorporations = city.getCorporationCommerce(CommerceTypes.COMMERCE_GOLD)
                fCorporations += fCityCorporations

                fCitySpecialists = city.getSpecialistCommerce(CommerceTypes.COMMERCE_GOLD)
                fSpecialists += fCitySpecialists

                fCityWealth = 0.0
                if city.isProductionProcess() and city.getProductionProcess() == eWealth:
                    fCityWealth = (
                        city.getProductionToCommerceModifier(CommerceTypes.COMMERCE_GOLD)
                        * city.getYieldRate(YieldTypes.YIELD_PRODUCTION)
                        / 100.0
                    )
                    fWealth += fCityWealth
                    iWealthCount += 1

                    # buildings don't multiply wealth
                fCityTotel = fCityTaxes + fCityBuildings + fCityHeadquarters + fCityCorporations + fCitySpecialists
                for entry in multipliers:
                    eBldg, iMultiplier, _, _ = entry
                    iCount = city.getNumRealBuilding(eBldg)
                    if iCount > 0:
                        entry[2] += iCount
                        entry[3] += iCount * fCityTotel * iMultiplier / 100.0

        iTotalMinusTaxes = int(fBuildings) + int(fCorporations) + int(fSpecialists) + int(fWealth)
        for _, _, _, fGold in multipliers:
            iTotalMinusTaxes += int(fGold)

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TAXES", ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_INCOME + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(goldCommerce - iTotalMinusTaxes) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )

        if fBuildings > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_BUILDINGS", ()) + " (%d)</font>" % iBuildingCount,
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(int(fBuildings)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )

        if fHeadquarters > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>"
                + localText.getText("TXT_KEY_CORPORATION_HEADQUARTERS", ())
                + " (%d)</font>" % iHeadquartersCount,
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(int(fHeadquarters)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )

        if fCorporations > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_CORPORATIONS", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(int(fCorporations)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )

        if fShrines > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>"
                + localText.getText("TXT_KEY_CONCEPT_RELIGIOUS_SHRINES", ())
                + " (%d)</font>" % iShrinesCount,
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(int(fShrines)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )

        if fSpecialists > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_SPECIALISTS", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_SPECIALISTS", self.iActiveLeader, 1)
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(int(fSpecialists)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_SPECIALISTS", self.iActiveLeader, 1)
            )

        for eBldg, iMultiplier, iCount, fGold in multipliers:
            if iCount > 0 and fGold > 0.0:
                fAverage = fGold / iCount
                szDescription = (
                    gc.getBuildingInfo(eBldg).getDescription()
                    + u" "
                    + localText.getText(
                        "TXT_KEY_BUG_FINANCIAL_ADVISOR_BUILDING_COUNT_AVERAGE",
                        (iCount, BugUtil.formatFloat(fAverage, 2)),
                    )
                )
                yLocation += self.Y_SPACING
                screen.setLabel(
                    self.getNextWidgetName(),
                    "Background",
                    u"<font=3>" + szDescription + "</font>",
                    CvUtil.FONT_LEFT_JUSTIFY,
                    self.X_INCOME + self.TEXT_MARGIN,
                    yLocation + self.TEXT_MARGIN,
                    self.Z_CONTROLS + self.DZ,
                    FontTypes.GAME_FONT,
                    WidgetTypes.WIDGET_GENERAL,
                    -1,
                    -1,
                )
                screen.setLabel(
                    self.getNextWidgetName(),
                    "Background",
                    u"<font=3>" + unicode(int(fGold)) + "</font>",
                    CvUtil.FONT_RIGHT_JUSTIFY,
                    self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                    yLocation + self.TEXT_MARGIN,
                    self.Z_CONTROLS + self.DZ,
                    FontTypes.GAME_FONT,
                    WidgetTypes.WIDGET_GENERAL,
                    -1,
                    -1,
                )

        if fWealth > 0.0 and iWealthCount > 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_PROCESS_WEALTH", ()) + " (%d)</font>" % iWealthCount,
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(int(fWealth)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )

        iIncome = goldCommerce
        if goldFromCivs > 0:
            yLocation += self.Y_SPACING
            szText = unicode(goldFromCivs) + " : " + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ())
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME,
                self.iActiveLeader,
                1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(goldFromCivs) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME,
                self.iActiveLeader,
                1,
            )
            iIncome += goldFromCivs

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME", ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_INCOME + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(iIncome) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )

        # Expenses
        yLocation = self.Y_LOCATION
        iExpenses = 0

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITCOST", ()) + u"</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST,
            self.iActiveLeader,
            1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(totalUnitCost) + u"</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST,
            self.iActiveLeader,
            1,
        )
        iExpenses += totalUnitCost

        yLocation += self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITSUPPLY", ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY,
            self.iActiveLeader,
            1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(totalUnitSupply) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY,
            self.iActiveLeader,
            1,
        )
        iExpenses += totalUnitSupply

        yLocation += self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_MAINTENANCE", ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT,
            self.iActiveLeader,
            1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(totalMaintenance) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT,
            self.iActiveLeader,
            1,
        )
        iExpenses += totalMaintenance

        yLocation += self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_CIVICS", ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP,
            self.iActiveLeader,
            1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(totalCivicUpkeep) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP,
            self.iActiveLeader,
            1,
        )
        iExpenses += totalCivicUpkeep

        if goldFromCivs < 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_COST_PER_TURN", ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY,
                self.X_EXPENSES + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME,
                self.iActiveLeader,
                1,
            )
            screen.setLabel(
                self.getNextWidgetName(),
                "Background",
                u"<font=3>" + unicode(-goldFromCivs) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME,
                self.iActiveLeader,
                1,
            )
            iExpenses -= goldFromCivs

        yLocation += self.Y_SPACING
        iInflation = totalInflatedCosts - totalPreInflatedCosts
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INFLATION", ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS,
            self.iActiveLeader,
            1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(iInflation) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS,
            self.iActiveLeader,
            1,
        )
        iExpenses += iInflation

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES", ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )
        screen.setLabel(
            self.getNextWidgetName(),
            "Background",
            u"<font=3>" + unicode(iExpenses) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL,
            -1,
            -1,
        )

        return 0
Exemplo n.º 2
0
	def translate(self):
		self.title = BugUtil.getPlainText(self.xmlKey + "_TEXT", self.title)
		self.tooltip = BugUtil.getPlainText(self.xmlKey + "_HOVER", self.tooltip)
		if self.isDll():
			if BugDll.isVersion(self.dll):
				self.tooltip = RE_DLL_ALL_TAGS.sub("", self.tooltip)
			else:
				if not BugDll.isPresent():
					dllText = BugUtil.getPlainText("TXT_KEY_BULL_REQUIRED")
				else:
					dllText = BugUtil.getPlainText("TXT_KEY_BULL_REQUIRED_NEWER")
				if self.tooltip.find("[DLL") >= 0:
					self.tooltip = RE_DLL_START_END_TAGS.sub("", self.tooltip)
					self.tooltip = RE_DLL_MSG_TAG.sub(dllText, self.tooltip)
				else:
					self.tooltip += "\n" + dllText
		elif self.tooltip.find("[DLL") >= 0:
			if not BugDll.isPresent():
				# no DLL, ignore all minimum versions and use standard error message
				self.tooltip = RE_DLL_START_END_TAGS.sub("", self.tooltip)
				self.tooltip = RE_DLL_MSG_TAG.sub(BugUtil.getPlainText("TXT_KEY_BULL_REQUIRED"), self.tooltip)
			else:
				dllText = BugUtil.getPlainText("TXT_KEY_BULL_REQUIRED_NEWER")
				def repl(matchobj):
					try:
						if BugDll.isVersion(int(matchobj.group(1))):
							return ""
						else:
							return RE_DLL_MSG_TAG.sub(dllText, matchobj.group(2))
					except:
						# invalid version
						return ""
				self.tooltip = RE_DLL_CAPTURE_VERSION_MESSAGE.sub(repl, self.tooltip)
		self.translated = True
Exemplo n.º 3
0
	def __init__(self, mod, id, andId=None, dll=None):
		self.mod = mod
		self.id = id
		self.andId = andId
		self.andOption = None
		self.dll = BugDll.decode(dll)
		if self.dll is not None and self.dll <= 0:
			BugUtil.warn("BugOptions - %s has invalid dll value %r, ignoring", id, dll)
			self.dll = None
		self.enabled = True
		if self.dll > 0:
			if not BugDll.isVersion(self.dll):
				self.enabled = False
Exemplo n.º 4
0
def isWillingToTalk(playerOrID, toPlayerOrID):
	"""
	Returns True if <player> is willing to talk to <toPlayer>.
	
	- Every player is willing to talk to themselves
	- All human players are willing to talk
	- Uses BUG DLL if present, otherwise scans attitude hover text
	  for "Refuses to Talk!!!" in the current language
	
	Note: This function does not check if the two players can make contact.
	"""
	playerID, player = PlayerUtil.getPlayerAndID(playerOrID)
	toPlayerID = PlayerUtil.getPlayerID(toPlayerOrID)
	if playerID == toPlayerID or player.isHuman():
		# all players talk to themselves, and all humans talk
		return True
	if BugDll.isPresent():
		return player.AI_isWillingToTalk(toPlayerID)
	else:
		hover = AttitudeUtil.getAttitudeString(playerID, toPlayerID)
		if hover:
			return (hover.find(BugUtil.getPlainText("TXT_KEY_MISC_REFUSES_TO_TALK")) == -1)
		else:
			# haven't met yet
			return False
Exemplo n.º 5
0
def isWillingToTalk(playerOrID, toPlayerOrID):
	"""
	Returns True if <player> is willing to talk to <toPlayer>.
	
	- Every player is willing to talk to themselves
	- All human players are willing to talk
	- Uses BUG DLL if present, otherwise scans attitude hover text
	  for "Refuses to Talk!!!" in the current language
	
	Note: This function does not check if the two players can make contact.
	"""
	playerID, player = PlayerUtil.getPlayerAndID(playerOrID)
	toPlayerID = PlayerUtil.getPlayerID(toPlayerOrID)
	if playerID == toPlayerID or player.isHuman():
		# all players talk to themselves, and all humans talk
		return True
	if BugDll.isPresent():
		return player.AI_isWillingToTalk(toPlayerID)
	else:
		hover = AttitudeUtil.getAttitudeString(playerID, toPlayerID)
		if hover:
			return (hover.find(BugUtil.getPlainText("TXT_KEY_MISC_REFUSES_TO_TALK")) == -1)
		else:
			# haven't met yet
			return False
Exemplo n.º 6
0
 def turnsToCancel(self, eByPlayer=-1):
     if BugDll.isPresent():
         return self.deal.turnsToCancel(eByPlayer)
     else:
         # this is exactly what CvDeal does
         return self.getInitialGameTurn() + gc.getDefineINT(
             "PEACE_TREATY_LENGTH") - gc.getGame().getGameTurn()
Exemplo n.º 7
0
	def isCancelable(self, eByPlayer, bIgnoreWaitingPeriod=False):
		if BugDll.isPresent():
			return self.deal.isCancelable(eByPlayer, bIgnoreWaitingPeriod)
		else:
			if self.isUncancelableVassalDeal(eByPlayer):
				return False
			return self.turnsToCancel(eByPlayer) <= 0
Exemplo n.º 8
0
 def handle(self, element, module, dll):
     dll = BugDll.decode(dll)
     element.setState("dll", dll)
     if module and dll:
         BugUtil.debug(
             "BugConfig - configuration for module %s requires DLL version %s",
             module, dll)
Exemplo n.º 9
0
 def handle(self, element, how, module, function, toModule, asName, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         BugUtil.extendFunction(module, function, toModule, asName, how)
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> %s.%s, requires dll version %s",
             element.tag, module, function, self.resolveDll(element, dll))
	def handleInput (self, inputClass):
		if (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
			if (inputClass.getFunctionName() == self.UNIT_LOC_TAB_ID):
				self.iScreen = UNIT_LOCATION_SCREEN
				self.showUnitLocation()
				return 1

			elif (inputClass.getFunctionName() == self.SIT_REP_TAB_ID):
				self.iScreen = SITUATION_REPORT_SCREEN
				self.showSituationReport()
				return 1

			elif (inputClass.getFunctionName() == self.STRAT_ADV_TAB_ID):
				self.iScreen = STRATEGIC_ADVANTAGES_SCREEN
				self.showStrategicAdvantages()
				return 1

			elif (inputClass.getFunctionName() == self.UNIT_BUTTON_ID):
				self.bUnitDetails = not self.bUnitDetails
				self.UL_refreshUnitSelection(True, True)
				return 1

			# RJG Start - following line added as per RJG (http://forums.civfanatics.com/showpost.php?p=6997192&postcount=16)
			elif (inputClass.getButtonType() == WidgetTypes.WIDGET_LEADERHEAD or BugDll.isWidgetVersion(2, inputClass.getButtonType(), "WIDGET_LEADERHEAD_RELATIONS")):
				if (inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP):
					if (self.iActivePlayer != inputClass.getData1()):
						self.getScreen().hideScreen()
						return 1
			# RJG End
		
		elif (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CHARACTER):
			if (inputClass.getData() == int(InputTypes.KB_LSHIFT)
			or  inputClass.getData() == int(InputTypes.KB_RSHIFT)):
				self.iShiftKeyDown = inputClass.getID()
				return 1

		elif ( inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED ):
			if self.iScreen == UNIT_LOCATION_SCREEN:
				iSelected = inputClass.getData()
				control = inputClass.getFunctionName() + str(inputClass.getID())
				BugUtil.debug("Selected item %d from list %s" % (iSelected, control))
				if control in self.groupDropDowns:
					iGroup = self.groupDropDowns.index(control)
					key = self.grouper[iSelected].key
					self.groupingKeys[iGroup] = key
					self.selectedGroups.clear()
					BugUtil.debug("Switched grouping %d to %s" % (iGroup, key))
					self.UL_refresh(False, True)
					return 1
			elif (inputClass.getButtonType() == WidgetTypes.WIDGET_LEADERHEAD):
				if (self.iActivePlayer != inputClass.getData1()):
					self.getScreen().hideScreen()
					return 1
		
		if self.iconGrid:
			return self.iconGrid.handleInput(inputClass)
		
		return 0
Exemplo n.º 11
0
	def handleInput (self, inputClass):
		if (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
			if (inputClass.getFunctionName() == self.UNIT_LOC_TAB_ID):
				self.iScreen = UNIT_LOCATION_SCREEN
				self.showUnitLocation()
				return 1

			elif (inputClass.getFunctionName() == self.SIT_REP_TAB_ID):
				self.iScreen = SITUATION_REPORT_SCREEN
				self.showSituationReport()
				return 1

			elif (inputClass.getFunctionName() == self.STRAT_ADV_TAB_ID):
				self.iScreen = STRATEGIC_ADVANTAGES_SCREEN
				self.showStrategicAdvantages()
				return 1

			elif (inputClass.getFunctionName() == self.UNIT_BUTTON_ID):
				self.bUnitDetails = not self.bUnitDetails
				self.UL_refreshUnitSelection(True, True)
				return 1

			# RJG Start - following line added as per RJG (http://forums.civfanatics.com/showpost.php?p=6997192&postcount=16)
			elif (inputClass.getButtonType() == WidgetTypes.WIDGET_LEADERHEAD or BugDll.isWidgetVersion(2, inputClass.getButtonType(), "WIDGET_LEADERHEAD_RELATIONS")):
				if (inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP):
					if (self.iActivePlayer != inputClass.getData1()):
						self.getScreen().hideScreen()
						return 1
			# RJG End
		
		elif (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CHARACTER):
			if (inputClass.getData() == int(InputTypes.KB_LSHIFT)
			or  inputClass.getData() == int(InputTypes.KB_RSHIFT)):
				self.iShiftKeyDown = inputClass.getID()
				return 1

		elif ( inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED ):
			if self.iScreen == UNIT_LOCATION_SCREEN:
				iSelected = inputClass.getData()
				control = inputClass.getFunctionName() + str(inputClass.getID())
				BugUtil.debug("Selected item %d from list %s" % (iSelected, control))
				if control in self.groupDropDowns:
					iGroup = self.groupDropDowns.index(control)
					key = self.grouper[iSelected].key
					self.groupingKeys[iGroup] = key
					self.selectedGroups.clear()
					BugUtil.debug("Switched grouping %d to %s" % (iGroup, key))
					self.UL_refresh(False, True)
					return 1
			elif (inputClass.getButtonType() == WidgetTypes.WIDGET_LEADERHEAD):
				if (self.iActivePlayer != inputClass.getData1()):
					self.getScreen().hideScreen()
					return 1
		
		if self.iconGrid:
			return self.iconGrid.handleInput(inputClass)
		
		return 0
	def Grid_WorstEnemy(self, iRow, iLeader):
		pWorstEnemy = PlayerUtil.getWorstEnemy(iLeader, self.iActivePlayer)
		if pWorstEnemy:
			self.iconGrid.addIcon(iRow, self.Col_WEnemy,
									gc.getLeaderHeadInfo(pWorstEnemy.getLeaderType()).getButton(), 45,  
									*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLeader, pWorstEnemy.getID(),
														WidgetTypes.WIDGET_LEADERHEAD, iLeader, pWorstEnemy.getID()))
		else:
			pass
Exemplo n.º 13
0
				def repl(matchobj):
					try:
						if BugDll.isVersion(int(matchobj.group(1))):
							return ""
						else:
							return RE_DLL_MSG_TAG.sub(dllText, matchobj.group(2))
					except:
						# invalid version
						return ""
Exemplo n.º 14
0
	def Grid_WorstEnemy(self, iRow, iLeader):
		pWorstEnemy = PlayerUtil.getWorstEnemy(iLeader, self.iActivePlayer)
		if pWorstEnemy:
			self.iconGrid.addIcon(iRow, self.Col_WEnemy,
									gc.getLeaderHeadInfo(pWorstEnemy.getLeaderType()).getButton(), 45,  
									*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLeader, pWorstEnemy.getID(),
														WidgetTypes.WIDGET_LEADERHEAD, iLeader, pWorstEnemy.getID()))
		else:
			pass
Exemplo n.º 15
0
 def handle(self, element, module, clazz, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         BugUtil.callFunction(module, clazz,
                              CvEventInterface.getEventManager(),
                              *element.args, **element.kwargs)
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> from %s.%s, requires dll version %s",
             element.tag, module, clazz, self.resolveDll(element, dll))
Exemplo n.º 16
0
	def resolveDll(self, element, dll):
		dll = BugDll.decode(dll)
		inherited = element.getState("dll")
		if dll is None:
			return inherited
		if inherited is None:
			return dll
		if inherited > dll:
			BugUtil.warn("BugConfig - element <%s>.dll attribute %s overrides newer inherited dll attribute %s" % (element.tag, dll, inherited))
		return dll
Exemplo n.º 17
0
	def resolveDll(self, element, dll):
		dll = BugDll.decode(dll)
		inherited = element.getState("dll")
		if dll is None:
			return inherited
		if inherited is None:
			return dll
		if inherited > dll:
			BugUtil.warn("BugConfig - element <%s>.dll attribute %s overrides newer inherited dll attribute %s" % (element.tag, dll, inherited))
		return dll
Exemplo n.º 18
0
	def handle(self, element, module, function, immediate, dll):
		immediate = self.isTrue(immediate)
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			func = BugUtil.getFunction(module, function, True, *element.args, **element.kwargs)
			if immediate:
				func()
			else:
				BugInit.addInit(module, func)
		else:
			BugUtil.info("BugConfig - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, function, self.resolveDll(element, dll))
Exemplo n.º 19
0
	def handle(self, element, module, function, immediate, dll):
		immediate = self.isTrue(immediate)
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			func = BugUtil.getFunction(module, function, True, *element.args, **element.kwargs)
			if immediate:
				func()
			else:
				BugInit.addInit(module, func)
		else:
			BugUtil.info("BugConfig - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, function, self.resolveDll(element, dll))
Exemplo n.º 20
0
 def handle(self, element, type, module, function, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         CvEventInterface.getEventManager().addEventHandler(
             type,
             BugUtil.getFunction(module, function, True, *element.args,
                                 **element.kwargs))
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> %s, requires dll version %s",
             element.tag, type, self.resolveDll(element, dll))
Exemplo n.º 21
0
 def handle(self, element, keys, module, function, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         CvEventInterface.getEventManager().addShortcutHandler(
             keys,
             BugUtil.getFunction(module, function, *element.args,
                                 **element.kwargs))
     else:
         BugUtil.info(
             "InputUtil - ignoring <%s> %s, requires dll version %s",
             element.tag, keys, self.resolveDll(element, dll))
Exemplo n.º 22
0
 def handle(self, element, how, module, function, toModule, asName, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         BugUtil.extendFunction(module, function, toModule, asName, how)
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> %s.%s, requires dll version %s",
             element.tag,
             module,
             function,
             self.resolveDll(element, dll),
         )
Exemplo n.º 23
0
 def handle(self, element, module, clazz, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         BugUtil.callFunction(module, clazz, CvEventInterface.getEventManager(), *element.args, **element.kwargs)
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> from %s.%s, requires dll version %s",
             element.tag,
             module,
             clazz,
             self.resolveDll(element, dll),
         )
Exemplo n.º 24
0
 def handle(self, element, type, module, function, dll):
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         CvEventInterface.getEventManager().addEventHandler(
             type, BugUtil.getFunction(module, function, True, *element.args, **element.kwargs)
         )
     else:
         BugUtil.info(
             "BugConfig - ignoring <%s> %s, requires dll version %s",
             element.tag,
             type,
             self.resolveDll(element, dll),
         )
Exemplo n.º 25
0
	def handle(self, element, id, name, fromKey, offset, dll):
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			if not fromKey:
				if not self.lastSymbol:
					raise BugUtil.ConfigError("<%s> %s requires an offset symbol" % (element.tag, id))
				fromKey = self.lastSymbol
			if offset is None:
				offset = 1
			else:
				offset = int(offset)
			self.lastSymbol = addOffsetSymbol(id, fromKey, offset, name)
		else:
			BugUtil.info("FontUtil - ignoring <%s> %s, requires dll version %s", element.tag, id, self.resolveDll(element, dll))
Exemplo n.º 26
0
 def handle(self, element, module, clazz, handlers, listeners, override,
            log, dll):
     override = self.isTrue(override)
     dll = BugDll.decode(dll)
     if self.isDllOkay(element, dll):
         if clazz:
             utils = BugUtil.callFunction(module, clazz)
             element.setState("gameutils", utils)
             if handlers or listeners:
                 if handlers:
                     for handler in handlers.replace(",", " ").split():
                         addHandler(BugUtil.bindFunction(utils, handler),
                                    override, log)
                 if listeners:
                     for listener in listeners.replace(",", " ").split():
                         func = None
                         if not listener.endswith(LISTENER_SUFFIX):
                             try:
                                 func = BugUtil.bindFunction(
                                     utils, listener + LISTENER_SUFFIX)
                             except BugUtil.ConfigError:
                                 pass
                         if not func:
                             try:
                                 func = BugUtil.bindFunction(
                                     utils, listener)
                             except BugUtil.ConfigError:
                                 raise BugUtil.ConfigError(
                                     "Game utils %s.%s must define function %s or %s",
                                     module, clazz, listener,
                                     listener + "Listener")
                         addListener(func, log)
             else:
                 addClassUtils(utils, override, log)
         else:
             if handlers or listeners:
                 if handlers:
                     for handler in handlers.replace(",", " ").split():
                         addHandler(BugUtil.lookupFunction(module, handler),
                                    override, log)
                 if listeners:
                     for listener in listeners.replace(",", " ").split():
                         addListener(
                             BugUtil.lookupFunction(module, listener), log)
             else:
                 addModuleUtils(BugUtil.lookupModule(module), override, log)
     else:
         BugUtil.info(
             "BugGameUtils - ignoring <%s> %s.%s, requires dll version %s",
             element.tag, module, clazz, self.resolveDll(element, dll))
Exemplo n.º 27
0
	def handle(self, element, name, type, default, module, handler, listener, log, dll):
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			utils = element.getState("gameutils")
			if utils:
				func = BugUtil.bindFunction(utils, handler)
				if listener:
					listenerFunc = BugUtil.bindFunction(utils, listener)
			elif not module:
				raise BugUtil.ConfigError("Element <%s> requires attribute module or be enclosed in <gameutils> that defines a class", element.tag)
			else:
				func = BugUtil.lookupFunction(module, handler)
				if listener:
					listenerFunc = BugUtil.lookupFunction(module, listener)
			createCallback(name, func, self.createValue(type, default), log)
			if listener:
				addNamedListener(name, listenerFunc, log)
		else:
			BugUtil.info("BugGameUtils - ignoring <%s> %s, requires dll version %s", element.tag, name, self.resolveDll(element, dll))
Exemplo n.º 28
0
	def handle(self, element, module, clazz, handlers, listeners, override, log, dll):
		override = self.isTrue(override)
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			if clazz:
				utils = BugUtil.callFunction(module, clazz)
				element.setState("gameutils", utils)
				if handlers or listeners:
					if handlers:
						for handler in handlers.replace(",", " ").split():
							addHandler(BugUtil.bindFunction(utils, handler), override, log)
					if listeners:
						for listener in listeners.replace(",", " ").split():
							func = None
							if not listener.endswith(LISTENER_SUFFIX):
								try:
									func = BugUtil.bindFunction(utils, listener + LISTENER_SUFFIX)
								except BugUtil.ConfigError:
									pass
							if not func:
								try:
									func = BugUtil.bindFunction(utils, listener)
								except BugUtil.ConfigError:
									raise BugUtil.ConfigError("Game utils %s.%s must define function %s or %s", 
											module, clazz, listener, listener + "Listener")
							addListener(func, log)
				else:
					addClassUtils(utils, override, log)
			else:
				if handlers or listeners:
					if handlers:
						for handler in handlers.replace(",", " ").split():
							addHandler(BugUtil.lookupFunction(module, handler), override, log)
					if listeners:
						for listener in listeners.replace(",", " ").split():
							addListener(BugUtil.lookupFunction(module, listener), log)
				else:
					addModuleUtils(BugUtil.lookupModule(module), override, log)
		else:
			BugUtil.info("BugGameUtils - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, clazz, self.resolveDll(element, dll))
Exemplo n.º 29
0
	def handle(self, element, module, dll):
		dll = BugDll.decode(dll)
		element.setState("dll", dll)
		if module and dll:
			BugUtil.debug("BugConfig - configuration for module %s requires DLL version %s", module, dll)
Exemplo n.º 30
0
	def handle(self, element, id, name, dll, author, version, build, date, url):
		dll = BugDll.decode(dll)
		element.setState("mod", BugCore.game._getMod(id))
		element.setState("dll", BugDll.decode(dll))
Exemplo n.º 31
0
	def handle(self, element, id, name, dll, author, version, build, date, url):
		dll = BugDll.decode(dll)
		element.setState("mod", BugCore.game._getMod(id))
		element.setState("dll", BugDll.decode(dll))
Exemplo n.º 32
0
	def isDllOkay(self, element, dll):
		dll = self.resolveDll(element, dll)
		if dll is not None:
			element.setState("dll", dll)
			return BugDll.isVersion(dll)
		return True
Exemplo n.º 33
0
def enforceDll():
    if not BugDll.isPresent():
        raise MapFinderError("TXT_KEY_MAPFINDER_REQUIRES_BULL")
Exemplo n.º 34
0
def enforceDll():
    if not BugDll.isPresent():
        raise MapFinderError("TXT_KEY_MAPFINDER_REQUIRES_BULL")
Exemplo n.º 35
0
 def setTrade(self):
     self._set(
         TRADE, True,
         BugDll.widget("WIDGET_TRADE_ROUTES", self._activePlayer,
                       self._currPlayerScore.getID(),
                       *self._getContactWidget()))
Exemplo n.º 36
0
	def showSituationReport(self):

		self.timer.start()
		self.deleteAllWidgets()
		screen = self.getScreen()
		
		# get Player arrays
		pVassals = [[]] * gc.getMAX_PLAYERS()
		pDefPacts = [[]] * gc.getMAX_PLAYERS()
		bVassals = False
		bDefPacts = False
		for iLoopPlayer in range(gc.getMAX_PLAYERS()):
			pPlayer = gc.getPlayer(iLoopPlayer)

			if (pPlayer.isAlive()
			and (gc.getTeam(pPlayer.getTeam()).isHasMet(gc.getPlayer(self.iActivePlayer).getTeam())
			or gc.getGame().isDebugMode())
			and iLoopPlayer != self.iActivePlayer
			and not pPlayer.isBarbarian()
			and not pPlayer.isMinorCiv()):
				pVassals[iLoopPlayer] = PlayerUtil.getVassals(iLoopPlayer, self.iActivePlayer)
				pDefPacts[iLoopPlayer] = PlayerUtil.getDefensivePacts(iLoopPlayer, self.iActivePlayer)

				if len(pVassals[iLoopPlayer]) > 0:
					bVassals = True

				if len(pDefPacts[iLoopPlayer]) > 0:
					bDefPacts = True

		bVassals = True
		bDefPacts = True
		self.initIconGrid(screen, bVassals, bDefPacts)
		self.initPower()
		
		activePlayer = gc.getPlayer(self.iActivePlayer)		
		
		# Assemble the panel
		iPANEL_X = 5
		iPANEL_Y = 60
		iPANEL_WIDTH = self.W_SCREEN - 20
		iPANEL_HEIGHT = self.H_SCREEN - 120

		self.tradePanel = self.getNextWidgetName()
		screen.addPanel(self.tradePanel, "", "", True, True, iPANEL_X, iPANEL_Y, iPANEL_WIDTH, iPANEL_HEIGHT, PanelStyles.PANEL_STYLE_MAIN )
		
		self.iconGrid.createGrid()
		self.iconGrid.clearData()

		iRow = 0
		for iLoopPlayer in range(gc.getMAX_PLAYERS()):
			pPlayer = gc.getPlayer(iLoopPlayer)

			if (pPlayer.isAlive()
			and (gc.getTeam(pPlayer.getTeam()).isHasMet(gc.getPlayer(self.iActivePlayer).getTeam())
			or gc.getGame().isDebugMode())
			and iLoopPlayer != self.iActivePlayer
			and not pPlayer.isBarbarian()
			and not pPlayer.isMinorCiv()):


#				szPlayerName = pPlayer.getName() + "/" + pPlayer.getCivilizationShortDescription(0)
#				BugUtil.debug("Grid_ThreatIndex - Start %i %s" % (iLoopPlayer, szPlayerName))
#				BugUtil.debug("Grid_ThreatIndex - Start %i" % (iLoopPlayer))

				self.iconGrid.appendRow(pPlayer.getCivilizationShortDescription(0), "", 3)

				# add leaderhead icon
				self.iconGrid.addIcon(iRow, self.Col_Leader,
										gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getButton(), 64, 
										WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, self.iActivePlayer)

				# add worst enemy
				self.Grid_WorstEnemy(iRow, iLoopPlayer)

				# add current war opponents
				pActiveWars = PlayerUtil.getActiveWars(iLoopPlayer, self.iActivePlayer)
				bCurrentWar = len(pActiveWars) > 0
				for pLoopPlayer in pActiveWars:
					self.iconGrid.addIcon(iRow, self.Col_Curr_Wars, 
											gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
											*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))

				# show vassals
				if bVassals:
					for pLoopPlayer in pVassals[iLoopPlayer]:
						self.iconGrid.addIcon(iRow, self.Col_Vassals, 
												gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
												*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																	WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))

				# show defensive pacts
				if bDefPacts:
					for pLoopPlayer in pDefPacts[iLoopPlayer]:
						self.iconGrid.addIcon(iRow, self.Col_DefPacts, 
												gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
												*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																	WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))

				# show players that the current player will declare on
				bWHEOOH, pPossibleWars = PlayerUtil.getPossibleWars(iLoopPlayer, self.iActivePlayer)
				for pLoopPlayer in pPossibleWars:
					self.iconGrid.addIcon(iRow, self.Col_WillDeclareOn, 
											gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
											*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))
				# show WHEOOH
				if bWHEOOH:
					sWHEOOH = u" %c" % CyGame().getSymbolID(FontSymbols.OCCUPATION_CHAR)
				else:
					sWHEOOH = ""
				
				# show possible trade embargos
				pPossibleEmbargos = PlayerUtil.getPossibleEmbargos(iLoopPlayer, self.iActivePlayer)
				for pLoopPlayer in pPossibleEmbargos:
					self.iconGrid.addIcon(iRow, self.Col_WillEmbargo, 
											gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
											*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))

				self.iconGrid.setText(iRow, self.Col_WHEOOH, sWHEOOH, 3)

				# add the threat index
				self.Grid_ThreatIndex(iRow, iLoopPlayer, bCurrentWar, bWHEOOH)

				iRow += 1

		self.iconGrid.refresh()
		self.drawTabs()
		self.timer.log("SitRep")
	def showSituationReport(self):

		self.timer.start()
		self.deleteAllWidgets()
		screen = self.getScreen()
		
		# get Player arrays
		pVassals = [[]] * gc.getMAX_PLAYERS()
		pDefPacts = [[]] * gc.getMAX_PLAYERS()
		bVassals = False
		bDefPacts = False
		for iLoopPlayer in range(gc.getMAX_PLAYERS()):
			pPlayer = gc.getPlayer(iLoopPlayer)

			if (pPlayer.isAlive()
			and (gc.getTeam(pPlayer.getTeam()).isHasMet(gc.getPlayer(self.iActivePlayer).getTeam())
			or gc.getGame().isDebugMode())
			and iLoopPlayer != self.iActivePlayer
			and not pPlayer.isBarbarian()
			and not pPlayer.isMinorCiv()):
				pVassals[iLoopPlayer] = PlayerUtil.getVassals(iLoopPlayer, self.iActivePlayer)
				pDefPacts[iLoopPlayer] = PlayerUtil.getDefensivePacts(iLoopPlayer, self.iActivePlayer)

				if len(pVassals[iLoopPlayer]) > 0:
					bVassals = True

				if len(pDefPacts[iLoopPlayer]) > 0:
					bDefPacts = True

		bVassals = True
		bDefPacts = True
		self.initIconGrid(screen, bVassals, bDefPacts)
		self.initPower()
		
		activePlayer = gc.getPlayer(self.iActivePlayer)		
		
		# Assemble the panel
		iPANEL_X = 5
		iPANEL_Y = 60
		iPANEL_WIDTH = self.W_SCREEN - 20
		iPANEL_HEIGHT = self.H_SCREEN - 120

		self.tradePanel = self.getNextWidgetName()
		screen.addPanel(self.tradePanel, "", "", True, True, iPANEL_X, iPANEL_Y, iPANEL_WIDTH, iPANEL_HEIGHT, PanelStyles.PANEL_STYLE_MAIN )
		
		self.iconGrid.createGrid()
		self.iconGrid.clearData()

		iRow = 0
		for iLoopPlayer in range(gc.getMAX_PLAYERS()):
			pPlayer = gc.getPlayer(iLoopPlayer)

			if (pPlayer.isAlive()
			and (gc.getTeam(pPlayer.getTeam()).isHasMet(gc.getPlayer(self.iActivePlayer).getTeam())
			or gc.getGame().isDebugMode())
			and iLoopPlayer != self.iActivePlayer
			and not pPlayer.isBarbarian()
			and not pPlayer.isMinorCiv()):


#				szPlayerName = pPlayer.getName() + "/" + pPlayer.getCivilizationShortDescription(0)
#				BugUtil.debug("Grid_ThreatIndex - Start %i %s" % (iLoopPlayer, szPlayerName))
#				BugUtil.debug("Grid_ThreatIndex - Start %i" % (iLoopPlayer))

				self.iconGrid.appendRow(pPlayer.getCivilizationShortDescription(0), "", 3)

				# add leaderhead icon
				self.iconGrid.addIcon(iRow, self.Col_Leader,
										gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getButton(), 64, 
										WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, self.iActivePlayer)

				# add worst enemy
				self.Grid_WorstEnemy(iRow, iLoopPlayer)

				# add current war opponents
				pActiveWars = PlayerUtil.getActiveWars(iLoopPlayer, self.iActivePlayer)
				bCurrentWar = len(pActiveWars) > 0
				for pLoopPlayer in pActiveWars:
					self.iconGrid.addIcon(iRow, self.Col_Curr_Wars, 
											gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
											*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))

				# show vassals
				if bVassals:
					for pLoopPlayer in pVassals[iLoopPlayer]:
						self.iconGrid.addIcon(iRow, self.Col_Vassals, 
												gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
												*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																	WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))

				# show defensive pacts
				if bDefPacts:
					for pLoopPlayer in pDefPacts[iLoopPlayer]:
						self.iconGrid.addIcon(iRow, self.Col_DefPacts, 
												gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
												*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																	WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))

				# show players that the current player will declare on
				bWHEOOH, pPossibleWars = PlayerUtil.getPossibleWars(iLoopPlayer, self.iActivePlayer)
				for pLoopPlayer in pPossibleWars:
					self.iconGrid.addIcon(iRow, self.Col_WillDeclareOn, 
											gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
											*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))
				# show WHEOOH
				if bWHEOOH:
					sWHEOOH = u" %c" % CyGame().getSymbolID(FontSymbols.OCCUPATION_CHAR)
				else:
					sWHEOOH = ""
				
				# show possible trade embargos
				pPossibleEmbargos = PlayerUtil.getPossibleEmbargos(iLoopPlayer, self.iActivePlayer)
				for pLoopPlayer in pPossibleEmbargos:
					self.iconGrid.addIcon(iRow, self.Col_WillEmbargo, 
											gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32, 
											*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
																WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))

				self.iconGrid.setText(iRow, self.Col_WHEOOH, sWHEOOH, 3)

				# add the threat index
				self.Grid_ThreatIndex(iRow, iLoopPlayer, bCurrentWar, bWHEOOH)

				iRow += 1

		self.iconGrid.refresh()
		self.drawTabs()
		self.timer.log("SitRep")
Exemplo n.º 38
0
	def setTrade(self):
		self._set(TRADE, True, 
				  BugDll.widget("WIDGET_TRADE_ROUTES", self._activePlayer, self._currPlayerScore.getID(),
								*self._getContactWidget()))
Exemplo n.º 39
0
	def isDllOkay(self, element, dll):
		dll = self.resolveDll(element, dll)
		if dll is not None:
			element.setState("dll", dll)
			return BugDll.isVersion(dll)
		return True
Exemplo n.º 40
0
	def handle(self, element, keys, module, function, dll):
		dll = BugDll.decode(dll)
		if self.isDllOkay(element, dll):
			CvEventInterface.getEventManager().addShortcutHandler(keys, BugUtil.getFunction(module, function, *element.args, **element.kwargs))
		else:
			BugUtil.info("InputUtil - ignoring <%s> %s, requires dll version %s", element.tag, keys, self.resolveDll(element, dll))
    def drawContents(self):

        self.deleteAllWidgets()

        # Create a new screen, called FinanceAdvisor, using the file FinanceAdvisor.py for input
        screen = self.getScreen()

        player = gc.getPlayer(self.iActiveLeader)

        numCities = player.getNumCities()

        totalUnitCost = player.calculateUnitCost()
        totalUnitSupply = player.calculateUnitSupply()
        totalMaintenance = player.getTotalMaintenance()
        totalCivicUpkeep = player.getCivicUpkeep([], False)
        totalPreInflatedCosts = player.calculatePreInflatedCosts()
        totalInflatedCosts = player.calculateInflatedCosts()
        goldCommerce = player.getCommerceRate(CommerceTypes.COMMERCE_GOLD)
        if (not player.isCommerceFlexible(CommerceTypes.COMMERCE_RESEARCH)):
            goldCommerce += player.calculateBaseNetResearch()
        gold = player.getGold()
        goldFromCivs = player.getGoldPerTurn()
        goldPerTurn = player.calculateGoldRate()

        szTreasuryPanel = self.getNextWidgetName()
        screen.addPanel(szTreasuryPanel, u"", "", True, True, self.X_SLIDERS,
                        self.Y_TREASURY,
                        self.X_EXPENSES + self.PANE_WIDTH - self.X_SLIDERS,
                        self.H_TREASURY, PanelStyles.PANEL_STYLE_MAIN)
        szText = localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TREASURY",
                                   (gold, )).upper()
        if gold < 0:
            if goldPerTurn != 0:
                if gold + goldPerTurn >= 0:
                    szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN",
                                              goldPerTurn)
                elif goldPerTurn >= 0:
                    szText += BugUtil.getText(
                        "TXT_KEY_MISC_POS_WARNING_GOLD_PER_TURN", goldPerTurn)
                else:
                    szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN",
                                              goldPerTurn)
        else:
            if goldPerTurn != 0:
                if goldPerTurn >= 0:
                    szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN",
                                              goldPerTurn)
                elif gold + goldPerTurn >= 0:
                    szText += BugUtil.getText(
                        "TXT_KEY_MISC_NEG_WARNING_GOLD_PER_TURN", goldPerTurn)
                else:
                    szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN",
                                              goldPerTurn)
        screen.setLabel(
            self.getNextWidgetName(), szTreasuryPanel,
            u"<font=4>" + szText + u"</font>", CvUtil.FONT_CENTER_JUSTIFY,
            (self.X_SLIDERS + self.PANE_WIDTH + self.X_EXPENSES) / 2,
            self.Y_TREASURY + self.H_TREASURY / 2 - self.Y_SPACING / 2,
            self.Z_CONTROLS, FontTypes.TITLE_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_GOLD_RESERVE, -1, -1)

        szCommercePanel = self.getNextWidgetName()
        screen.addPanel(szCommercePanel, u"", "", True, True, self.X_SLIDERS,
                        self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT,
                        PanelStyles.PANEL_STYLE_MAIN)
        screen.setLabel(
            self.getNextWidgetName(), "Background",
            u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_COMMERCE",
                                            ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH / 2,
            self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        szIncomePanel = self.getNextWidgetName()
        screen.addPanel(szIncomePanel, u"", "", True, True, self.X_INCOME,
                        self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT,
                        PanelStyles.PANEL_STYLE_MAIN)
        screen.setLabel(
            self.getNextWidgetName(), "Background", u"<font=3>" +
            localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME_HEADER",
                              ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY, self.X_INCOME + self.PANE_WIDTH / 2,
            self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        szExpensePanel = self.getNextWidgetName()
        screen.addPanel(szExpensePanel, u"", "", True, True, self.X_EXPENSES,
                        self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT,
                        PanelStyles.PANEL_STYLE_MAIN)
        screen.setLabel(
            self.getNextWidgetName(), "Background", u"<font=3>" +
            localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES_HEADER",
                              ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH / 2,
            self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        # Commerce
        yLocation = self.Y_LOCATION
        iCommerce = 0

        # sum all worked tiles' commerce yields for player
        # move to MapUtil?
        iWorkedTileCount = 0
        iWorkedTiles = 0
        for city in PlayerUtil.playerCities(player):
            if not city.isDisorder():
                for i in range(gc.getNUM_CITY_PLOTS()):
                    plot = city.getCityIndexPlot(i)
                    if plot and not plot.isNone() and plot.hasYield():
                        if city.isWorkingPlot(plot):
                            iWorkedTileCount += 1
                            iWorkedTiles += plot.getYield(
                                YieldTypes.YIELD_COMMERCE)

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background",
            u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_WORKED_TILES",
                                            (iWorkedTileCount, )) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(iWorkedTiles) + "</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_GENERAL, -1, -1)
        iCommerce += iWorkedTiles

        # trade
        iDomesticTrade, _, iForeignTrade, _ = TradeUtil.calculateTradeRoutes(
            player)

        if iDomesticTrade > 0:
            if TradeUtil.isFractionalTrade():
                iDomesticTrade //= 100
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background", u"<font=3>" +
                localText.getText("TXT_KEY_CONCEPT_DOMESTIC_TRADE",
                                  ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
                self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_DOMESTIC_TRADE",
                               self.iActiveLeader, 1))
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(iDomesticTrade) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_DOMESTIC_TRADE",
                               self.iActiveLeader, 1))
            iCommerce += iDomesticTrade

        if iForeignTrade > 0:
            if TradeUtil.isFractionalTrade():
                iForeignTrade //= 100
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background", u"<font=3>" +
                localText.getText("TXT_KEY_CONCEPT_FOREIGN_TRADE",
                                  ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
                self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_FOREIGN_TRADE",
                               self.iActiveLeader, 1))
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(iForeignTrade) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_FOREIGN_TRADE",
                               self.iActiveLeader, 1))
            iCommerce += iForeignTrade

        # corporations
        iCorporations = 0
        for city in PlayerUtil.playerCities(player):
            if not city.isDisorder():
                iCorporations += city.getCorporationYield(
                    YieldTypes.YIELD_COMMERCE)

        if iCorporations > 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_CORPORATIONS",
                                                ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(iCorporations) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            iCommerce += iCorporations

        # specialists
        iSpecialists = 0
        for city in PlayerUtil.playerCities(player):
            if not city.isDisorder():
                for eSpec in range(gc.getNumSpecialistInfos()):
                    iSpecialists += player.specialistYield(
                        eSpec, YieldTypes.YIELD_COMMERCE) * (
                            city.getSpecialistCount(eSpec) +
                            city.getFreeSpecialistCount(eSpec))

        if iSpecialists > 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_SPECIALISTS",
                                                ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(iSpecialists) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            iCommerce += iSpecialists

        # buildings
        iTotalCommerce = player.calculateTotalYield(YieldTypes.YIELD_COMMERCE)
        # buildings includes 50% capital bonus for Bureaucracy civic
        iBuildings = iTotalCommerce - iCommerce
        if iBuildings > 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_BUILDINGS",
                                                ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(iBuildings) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            iCommerce += iBuildings

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background", u"<font=3>" +
            localText.getText("TXT_KEY_BUG_FINANCIAL_ADVISOR_COMMERCE",
                              ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
            self.X_SLIDERS + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL, -1, -1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(iCommerce) + "</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_GENERAL, -1, -1)

        # Slider percentages

        yLocation += 0.5 * self.Y_SPACING
        for iI in range(CommerceTypes.NUM_COMMERCE_TYPES):
            eCommerce = (iI + 1) % CommerceTypes.NUM_COMMERCE_TYPES

            if (player.isCommerceFlexible(eCommerce)):
                yLocation += self.Y_SPACING
                screen.setButtonGFC(
                    self.getNextWidgetName(), u"", "",
                    self.X_SLIDERS + self.TEXT_MARGIN,
                    int(yLocation) + self.TEXT_MARGIN, 20, 20,
                    WidgetTypes.WIDGET_CHANGE_PERCENT, eCommerce,
                    gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"),
                    ButtonStyles.BUTTON_STYLE_CITY_PLUS)
                screen.setButtonGFC(
                    self.getNextWidgetName(), u"", "",
                    self.X_SLIDERS + self.TEXT_MARGIN + 24,
                    int(yLocation) + self.TEXT_MARGIN, 20, 20,
                    WidgetTypes.WIDGET_CHANGE_PERCENT, eCommerce,
                    -gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"),
                    ButtonStyles.BUTTON_STYLE_CITY_MINUS)

                szText = u"<font=3>" + gc.getCommerceInfo(
                    eCommerce).getDescription() + u" (" + unicode(
                        player.getCommercePercent(eCommerce)) + u"%)</font>"
                screen.setLabel(self.getNextWidgetName(), "Background", szText,
                                CvUtil.FONT_LEFT_JUSTIFY,
                                self.X_SLIDERS + self.TEXT_MARGIN + 50,
                                yLocation + self.TEXT_MARGIN,
                                self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                                WidgetTypes.WIDGET_GENERAL, -1, -1)
                szRate = u"<font=3>" + unicode(
                    player.getCommerceRate(
                        CommerceTypes(eCommerce))) + u"</font>"
                screen.setLabel(
                    self.getNextWidgetName(), "Background", szRate,
                    CvUtil.FONT_RIGHT_JUSTIFY,
                    self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                    yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                    FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        yLocation += self.Y_SPACING
        szText = u"<font=3>" + gc.getCommerceInfo(
            CommerceTypes.COMMERCE_GOLD).getDescription() + u" (" + unicode(
                player.getCommercePercent(
                    CommerceTypes.COMMERCE_GOLD)) + u"%)</font>"
        screen.setLabel(self.getNextWidgetName(), "Background", szText,
                        CvUtil.FONT_LEFT_JUSTIFY,
                        self.X_SLIDERS + self.TEXT_MARGIN + 50,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_GENERAL, -1, -1)
        szCommerce = u"<font=3>" + unicode(goldCommerce) + u"</font>"
        screen.setLabel(self.getNextWidgetName(), "Background", szCommerce,
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_GENERAL, -1, -1)

        # Income
        yLocation = self.Y_LOCATION
        iTaxRate = player.getCommercePercent(CommerceTypes.COMMERCE_GOLD)

        multipliers = []
        for eBldg in range(gc.getNumBuildingInfos()):
            info = gc.getBuildingInfo(eBldg)
            iMultiplier = info.getCommerceModifier(CommerceTypes.COMMERCE_GOLD)
            if iMultiplier > 0:
                multipliers.append([eBldg, iMultiplier, 0, 0.0])

        iBuildingCount = 0
        iHeadquartersCount = 0
        iShrinesCount = 0
        fTaxes = 0.0
        fBuildings = 0.0
        fHeadquarters = 0.0
        fShrines = 0.0
        fCorporations = 0.0
        fSpecialists = 0.0
        iWealthCount = 0
        fWealth = 0.0
        eWealth = gc.getInfoTypeForString("PROCESS_WEALTH")
        # ignores
        #   CyCity.getReligionCommerce() -- excludes shrines
        #   CyPlayer.getFreeCityCommerce()
        #   CyPlayer.getSpecialistExtraCommerce() * (CyCity.getSpecialistPopulation() + CyCity.getNumGreatPeople())
        for city in PlayerUtil.playerCities(player):
            if not city.isDisorder():
                fCityTaxes = city.getYieldRate(
                    YieldTypes.YIELD_COMMERCE) * iTaxRate / 100.0
                fTaxes += fCityTaxes

                fCityBuildings = 0.0
                fCityHeadquarters = 0.0
                fCityShrines = 0.0
                for eBldg in range(gc.getNumBuildingInfos()):
                    iCount = city.getNumRealBuilding(eBldg)
                    if iCount > 0:
                        iBuildingGold = city.getBuildingCommerceByBuilding(
                            CommerceTypes.COMMERCE_GOLD, eBldg)
                        if iBuildingGold > 0:
                            info = gc.getBuildingInfo(eBldg)
                            if info.getFoundsCorporation() != -1:
                                fCityHeadquarters += iBuildingGold
                                iHeadquartersCount += 1
                            elif info.getGlobalReligionCommerce() != -1:
                                fCityShrines += iBuildingGold
                                iShrinesCount += 1
                            else:
                                fCityBuildings += iBuildingGold
                                iBuildingCount += iCount
                fBuildings += fCityBuildings
                fHeadquarters += fCityHeadquarters
                fShrines += fCityShrines

                fCityCorporations = city.getCorporationCommerce(
                    CommerceTypes.COMMERCE_GOLD)
                fCorporations += fCityCorporations

                fCitySpecialists = city.getSpecialistCommerce(
                    CommerceTypes.COMMERCE_GOLD)
                fSpecialists += fCitySpecialists

                fCityWealth = 0.0
                if city.isProductionProcess() and city.getProductionProcess(
                ) == eWealth:
                    fCityWealth = city.getProductionToCommerceModifier(
                        CommerceTypes.COMMERCE_GOLD) * city.getYieldRate(
                            YieldTypes.YIELD_PRODUCTION) / 100.0
                    fWealth += fCityWealth
                    iWealthCount += 1

                # buildings don't multiply wealth
                fCityTotel = fCityTaxes + fCityBuildings + fCityHeadquarters + fCityCorporations + fCitySpecialists
                for entry in multipliers:
                    eBldg, iMultiplier, _, _ = entry
                    iCount = city.getNumRealBuilding(eBldg)
                    if iCount > 0:
                        entry[2] += iCount
                        entry[3] += iCount * fCityTotel * iMultiplier / 100.0

        iTotalMinusTaxes = int(fBuildings) + int(fCorporations) + int(
            fSpecialists) + int(fWealth)
        for _, _, _, fGold in multipliers:
            iTotalMinusTaxes += int(fGold)

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TAXES",
                                            ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
        screen.setLabel(
            self.getNextWidgetName(), "Background",
            u"<font=3>" + unicode(goldCommerce - iTotalMinusTaxes) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        if fBuildings > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background", u"<font=3>" +
                localText.getText("TXT_KEY_CONCEPT_BUILDINGS",
                                  ()) + " (%d)</font>" % iBuildingCount,
                CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel(self.getNextWidgetName(), "Background",
                            u"<font=3>" + unicode(int(fBuildings)) + "</font>",
                            CvUtil.FONT_RIGHT_JUSTIFY,
                            self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                            yLocation + self.TEXT_MARGIN,
                            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                            WidgetTypes.WIDGET_GENERAL, -1, -1)

        if fHeadquarters > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background", u"<font=3>" +
                localText.getText("TXT_KEY_CORPORATION_HEADQUARTERS",
                                  ()) + " (%d)</font>" % iHeadquartersCount,
                CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(int(fHeadquarters)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        if fCorporations > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_CORPORATIONS",
                                                ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(int(fCorporations)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        if fShrines > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background", u"<font=3>" +
                localText.getText("TXT_KEY_CONCEPT_RELIGIOUS_SHRINES",
                                  ()) + " (%d)</font>" % iShrinesCount,
                CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel(self.getNextWidgetName(), "Background",
                            u"<font=3>" + unicode(int(fShrines)) + "</font>",
                            CvUtil.FONT_RIGHT_JUSTIFY,
                            self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                            yLocation + self.TEXT_MARGIN,
                            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                            WidgetTypes.WIDGET_GENERAL, -1, -1)

        if fSpecialists > 0.0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_SPECIALISTS",
                                                ()) + "</font>",
                CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_SPECIALISTS",
                               self.iActiveLeader, 1))
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(int(fSpecialists)) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                *BugDll.widget("WIDGET_HELP_FINANCE_SPECIALISTS",
                               self.iActiveLeader, 1))

        for eBldg, iMultiplier, iCount, fGold in multipliers:
            if iCount > 0 and fGold > 0.0:
                fAverage = fGold / iCount
                szDescription = gc.getBuildingInfo(
                    eBldg).getDescription() + u" " + localText.getText(
                        "TXT_KEY_BUG_FINANCIAL_ADVISOR_BUILDING_COUNT_AVERAGE",
                        (iCount, BugUtil.formatFloat(fAverage, 2)))
                yLocation += self.Y_SPACING
                screen.setLabel(self.getNextWidgetName(), "Background",
                                u"<font=3>" + szDescription + "</font>",
                                CvUtil.FONT_LEFT_JUSTIFY,
                                self.X_INCOME + self.TEXT_MARGIN,
                                yLocation + self.TEXT_MARGIN,
                                self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                                WidgetTypes.WIDGET_GENERAL, -1, -1)
                screen.setLabel(
                    self.getNextWidgetName(), "Background",
                    u"<font=3>" + unicode(int(fGold)) + "</font>",
                    CvUtil.FONT_RIGHT_JUSTIFY,
                    self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                    yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                    FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        if fWealth > 0.0 and iWealthCount > 0:
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background", u"<font=3>" +
                localText.getText("TXT_KEY_PROCESS_WEALTH",
                                  ()) + " (%d)</font>" % iWealthCount,
                CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
            screen.setLabel(self.getNextWidgetName(), "Background",
                            u"<font=3>" + unicode(int(fWealth)) + "</font>",
                            CvUtil.FONT_RIGHT_JUSTIFY,
                            self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                            yLocation + self.TEXT_MARGIN,
                            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                            WidgetTypes.WIDGET_GENERAL, -1, -1)

        iIncome = goldCommerce
        if (goldFromCivs > 0):
            yLocation += self.Y_SPACING
            szText = unicode(goldFromCivs) + " : " + localText.getText(
                "TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ())
            screen.setLabel(
                self.getNextWidgetName(), "Background", u"<font=3>" +
                localText.getText("TXT_KEY_FINANCIAL_ADVISOR_PER_TURN",
                                  ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
                self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN,
                self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME,
                self.iActiveLeader, 1)
            screen.setLabel(self.getNextWidgetName(), "Background",
                            u"<font=3>" + unicode(goldFromCivs) + "</font>",
                            CvUtil.FONT_RIGHT_JUSTIFY,
                            self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                            yLocation + self.TEXT_MARGIN,
                            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                            WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME,
                            self.iActiveLeader, 1)
            iIncome += goldFromCivs

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME",
                                            ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(iIncome) + "</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_GENERAL, -1, -1)

        # Expenses
        yLocation = self.Y_LOCATION
        iExpenses = 0

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background", u"<font=3>" +
            localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITCOST",
                              ()) + u"</font>", CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST, self.iActiveLeader, 1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(totalUnitCost) + u"</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST,
                        self.iActiveLeader, 1)
        iExpenses += totalUnitCost

        yLocation += self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background", u"<font=3>" +
            localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITSUPPLY",
                              ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY, self.iActiveLeader, 1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(totalUnitSupply) + "</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY,
                        self.iActiveLeader, 1)
        iExpenses += totalUnitSupply

        yLocation += self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background", u"<font=3>" +
            localText.getText("TXT_KEY_FINANCIAL_ADVISOR_MAINTENANCE",
                              ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT, self.iActiveLeader, 1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(totalMaintenance) + "</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT,
                        self.iActiveLeader, 1)
        iExpenses += totalMaintenance

        yLocation += self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background",
            u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_CIVICS",
                                            ()) + "</font>",
            CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN,
            yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
            FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP,
            self.iActiveLeader, 1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(totalCivicUpkeep) + "</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP,
                        self.iActiveLeader, 1)
        iExpenses += totalCivicUpkeep

        if (goldFromCivs < 0):
            yLocation += self.Y_SPACING
            screen.setLabel(
                self.getNextWidgetName(), "Background", u"<font=3>" +
                localText.getText("TXT_KEY_FINANCIAL_ADVISOR_COST_PER_TURN",
                                  ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
                self.X_EXPENSES + self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME,
                self.iActiveLeader, 1)
            screen.setLabel(
                self.getNextWidgetName(), "Background",
                u"<font=3>" + unicode(-goldFromCivs) + "</font>",
                CvUtil.FONT_RIGHT_JUSTIFY,
                self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
                yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                FontTypes.GAME_FONT,
                WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME,
                self.iActiveLeader, 1)
            iExpenses -= goldFromCivs

        yLocation += self.Y_SPACING
        iInflation = totalInflatedCosts - totalPreInflatedCosts
        screen.setLabel(
            self.getNextWidgetName(), "Background", u"<font=3>" +
            localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INFLATION",
                              ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS, self.iActiveLeader,
            1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(iInflation) + "</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS,
                        self.iActiveLeader, 1)
        iExpenses += iInflation

        yLocation += 1.5 * self.Y_SPACING
        screen.setLabel(
            self.getNextWidgetName(), "Background", u"<font=3>" +
            localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES",
                              ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY,
            self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN,
            self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
            WidgetTypes.WIDGET_GENERAL, -1, -1)
        screen.setLabel(self.getNextWidgetName(), "Background",
                        u"<font=3>" + unicode(iExpenses) + "</font>",
                        CvUtil.FONT_RIGHT_JUSTIFY,
                        self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN,
                        yLocation + self.TEXT_MARGIN,
                        self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_GENERAL, -1, -1)

        return 0
Exemplo n.º 42
0
	def getCannotCancelReason(self, eByPlayer):
		if BugDll.isPresent():
			return self.deal.getCannotCancelReason(eByPlayer)
		else:
			return ""
Exemplo n.º 43
0
	def turnsToCancel(self, eByPlayer=-1):
		if BugDll.isPresent():
			return self.deal.turnsToCancel(eByPlayer)
		else:
			# this is exactly what CvDeal does
			return self.getInitialGameTurn() + gc.getDefineINT("PEACE_TREATY_LENGTH") - gc.getGame().getGameTurn()