示例#1
0
def writeLog():

    if gc.getActivePlayer():
        iID = gc.getActivePlayer().getID()
    else:
        iID = -1
    pFile = open((szFilename % iID), "w")
    # pFile = open(szFilename, "w")

    #
    # Global data
    #
    pFile.write(SEPERATOR)
    pFile.write(SEPERATOR)

    pFile.write("  GLOBALS  \n")

    pFile.write(SEPERATOR)
    pFile.write(SEPERATOR)
    pFile.write("\n\n")

    pFile.write("Next Map Rand Value: %d\n" %
                CyGame().getMapRand().get(10000, "OOS Log"))
    pFile.write("Next Soren Rand Value: %d\n" %
                CyGame().getSorenRand().get(10000, "OOS Log"))

    pFile.write("Total num cities: %d\n" % CyGame().getNumCities())
    pFile.write("Total population: %d\n" % CyGame().getTotalPopulation())
    pFile.write("Total Deals: %d\n" % CyGame().getNumDeals())

    pFile.write("Total owned plots: %d\n" % CyMap().getOwnedPlots())
    pFile.write("Total num areas: %d\n" % CyMap().getNumAreas())

    pFile.write("\n\n")

    #
    # Player data
    #
    iPlayer = 0
    for iPlayer in xrange(gc.getMAX_PLAYERS()):
        pPlayer = gc.getPlayer(iPlayer)
        pTeam = gc.getTeam(pPlayer.getTeam())
        if (pPlayer.isEverAlive()):
            pFile.write(SEPERATOR)
            pFile.write(SEPERATOR)

            pFile.write("  PLAYER %d  \n" % iPlayer)

            pFile.write(SEPERATOR)
            pFile.write(SEPERATOR)
            pFile.write("\n\n")

            pFile.write("Basic data:\n")
            pFile.write("-----------\n")
            pFile.write("Player %d Score: %d\n" %
                        (iPlayer, gc.getGame().getPlayerScore(iPlayer)))
            pFile.write("Player %d Tech Score: %d\n" %
                        (iPlayer, pPlayer.getTechScore()))

            pFile.write("Player %d Population: %d\n" %
                        (iPlayer, pPlayer.getTotalPopulation()))
            pFile.write("Player %d Total Land: %d\n" %
                        (iPlayer, pPlayer.getTotalLand()))
            pFile.write("Player %d Gold: %d\n" % (iPlayer, pPlayer.getGold()))
            pFile.write("Player %d Assets: %d\n" %
                        (iPlayer, pPlayer.getAssets()))
            pFile.write("Player %d Power: %d\n" %
                        (iPlayer, pPlayer.getPower()))
            pFile.write("Player %d Num Cities: %d\n" %
                        (iPlayer, pPlayer.getNumCities()))
            pFile.write("Player %d Num Units: %d\n" %
                        (iPlayer, pPlayer.getNumUnits()))
            pFile.write("Player %d Num Selection Groups: %d\n" %
                        (iPlayer, pPlayer.getNumSelectionGroups()))

            pFile.write("\n\n")

            pFile.write("Yields:\n")
            pFile.write("-------\n")
            for iYield in xrange(int(YieldTypes.NUM_YIELD_TYPES)):
                pFile.write(
                    "Player %d %s Total Yield: %d\n" %
                    (iPlayer,
                     gc.getYieldInfo(iYield).getDescription().encode('utf-8'),
                     pPlayer.calculateTotalYield(iYield)))

            pFile.write("\n\n")

            pFile.write("Commerce:\n")
            pFile.write("---------\n")
            for iCommerce in xrange(int(CommerceTypes.NUM_COMMERCE_TYPES)):
                pFile.write(
                    "Player %d %s Total Commerce: %d\n" %
                    (iPlayer, gc.getCommerceInfo(
                        iCommerce).getDescription().encode('utf-8'),
                     pPlayer.getCommerceRate(CommerceTypes(iCommerce))))

            pFile.write("\n\n")

            pFile.write("Bonus Info:\n")
            pFile.write("-----------\n")
            for iBonus in xrange(gc.getNumBonusInfos()):
                pFile.write(
                    "Player %d, %s, Number Available: %d\n" %
                    (iPlayer,
                     gc.getBonusInfo(iBonus).getDescription().encode('utf-8'),
                     pPlayer.getNumAvailableBonuses(iBonus)))
                pFile.write(
                    "Player %d, %s, Import: %d\n" %
                    (iPlayer,
                     gc.getBonusInfo(iBonus).getDescription().encode('utf-8'),
                     pPlayer.getBonusImport(iBonus)))
                pFile.write(
                    "Player %d, %s, Export: %d\n" %
                    (iPlayer,
                     gc.getBonusInfo(iBonus).getDescription().encode('utf-8'),
                     pPlayer.getBonusExport(iBonus)))
                pFile.write("\n")

            pFile.write("\n\n")

            pFile.write("Improvement Info:\n")
            pFile.write("-----------------\n")
            for iImprovement in xrange(gc.getNumImprovementInfos()):
                pFile.write("Player %d, %s, Improvement count: %d\n" %
                            (iPlayer, gc.getImprovementInfo(
                                iImprovement).getDescription().encode('utf-8'),
                             pPlayer.getImprovementCount(iImprovement)))

            pFile.write("\n\n")

            pFile.write("Building Class Info:\n")
            pFile.write("--------------------\n")
            for iBuildingClass in xrange(gc.getNumBuildingClassInfos()):
                pFile.write(
                    "Player %d, %s, Building class count plus building: %d\n" %
                    (iPlayer, gc.getBuildingClassInfo(
                        iBuildingClass).getDescription().encode('utf-8'),
                     pPlayer.getBuildingClassCountPlusMaking(iBuildingClass)))

            pFile.write("\n\n")

            pFile.write("Unit Class Info:\n")
            pFile.write("--------------------\n")
            for iUnitClass in xrange(gc.getNumUnitClassInfos()):
                pFile.write(
                    "Player %d, %s, Unit class count plus training: %d\n" %
                    (iPlayer, gc.getUnitClassInfo(
                        iUnitClass).getDescription().encode('utf-8'),
                     pPlayer.getUnitClassCountPlusMaking(iUnitClass)))

            pFile.write("\n\n")

            pFile.write("UnitAI Types Info:\n")
            pFile.write("------------------\n")
            for iUnitAIType in xrange(int(UnitAITypes.NUM_UNITAI_TYPES)):
                pFile.write(
                    "Player %d, %s, Unit AI Type count: %d\n" %
                    (iPlayer, gc.getUnitAIInfo(
                        iUnitAIType).getDescription().encode('utf-8'),
                     pPlayer.AI_totalUnitAIs(UnitAITypes(iUnitAIType))))

            pFile.write("\n\n")

            pFile.write("Technologies:\n")
            pFile.write("------------------\n")
            for iTech in xrange(gc.getNumTechInfos()):
                if pTeam.isHasTech(iTech):
                    szTech = "Yes"
                else:
                    szTech = "No"
                pFile.write(
                    "Player %d, %s, Research rate: %d, Possess: %s\n" %
                    (iPlayer,
                     gc.getTechInfo(iTech).getDescription().encode('utf-8'),
                     pPlayer.calculateResearchRate(iTech), szTech))

            pFile.write("\n\n")

            pFile.write("Unit Info:\n")
            pFile.write("----------\n")
            iNumUnits = pPlayer.getNumUnits()

            if (iNumUnits == 0):
                pFile.write("No Units")
            else:
                pLoopUnitTuple = pPlayer.firstUnit(False)
                while (pLoopUnitTuple[0] is not None):
                    pUnit = pLoopUnitTuple[0]
                    pFile.write("Player %d, Unit ID: %d, %s\n" %
                                (iPlayer, pUnit.getID(),
                                 pUnit.getName().encode('utf-8')))
                    pFile.write("X: %d, Y: %d\n" %
                                (pUnit.getX(), pUnit.getY()))
                    pFile.write("Damage: %d\n" % pUnit.getDamage())
                    pFile.write("Experience: %d\n" % pUnit.getExperience())
                    pFile.write("Level: %d\n" % pUnit.getLevel())

                    pLoopUnitTuple = pPlayer.nextUnit(pLoopUnitTuple[1], False)
                    pFile.write("\n")

            # Space at end of player's info
            pFile.write("\n\n")

    # Close file

    pFile.close()
示例#2
0
def writeLog():
    import SystemPaths as SP
    import CvUtil
    GC = CyGlobalContext()
    MAP = GC.getMap()
    GAME = GC.getGame()
    iPlayer = GAME.getActivePlayer()
    szName = CvUtil.convertToStr(GC.getActivePlayer().getName())
    szName = SP.userDir + "\\Logs\\%s - Player %d - Turn %d OOSLog.txt" % (
        szName, iPlayer, GAME.getGameTurn())
    pFile = open(szName, "w")

    SEP = "-----------------------------------------------------------------\n"

    # Backup current language
    iLanguage = GAME.getCurrentLanguage()
    # Force english language for logs
    GAME.setCurrentLanguage(0)

    # Global data
    pFile.write(2 * SEP + "\tGLOBALS\n" + 2 * SEP + "\n")

    pFile.write("Last MapRand Value: %d\n" % GAME.getMapRand().getSeed())
    pFile.write("Last SorenRand Value: %d\n" % GAME.getSorenRand().getSeed())

    pFile.write("Total num cities: %d\n" % GAME.getNumCities())
    pFile.write("Total population: %d\n" % GAME.getTotalPopulation())
    pFile.write("Total Deals: %d\n" % GAME.getNumDeals())

    pFile.write("Total owned plots: %d\n" % MAP.getOwnedPlots())
    pFile.write("Total num areas: %d\n\n\n" % MAP.getNumAreas())

    # Player data
    for iPlayer in xrange(GC.getMAX_PLAYERS()):
        pPlayer = GC.getPlayer(iPlayer)
        if pPlayer.isEverAlive():

            pFile.write(2 * SEP + "%s player %d: %s\n" %
                        (['NPC', 'Human'][pPlayer.isHuman()], iPlayer,
                         CvUtil.convertToStr(pPlayer.getName())))
            pFile.write(
                "  Civilization: %s\n" %
                CvUtil.convertToStr(pPlayer.getCivilizationDescriptionKey()))
            pFile.write("  Alive: %s\n" % pPlayer.isAlive())

            pFile.write(2 * SEP + "\n\nBasic data:\n-----------\n")

            pFile.write("Player %d Score: %d\n" %
                        (iPlayer, GAME.getPlayerScore(iPlayer)))
            pFile.write("Player %d Population: %d\n" %
                        (iPlayer, pPlayer.getTotalPopulation()))
            pFile.write("Player %d Total Land: %d\n" %
                        (iPlayer, pPlayer.getTotalLand()))
            pFile.write("Player %d Gold: %d\n" % (iPlayer, pPlayer.getGold()))
            pFile.write("Player %d Assets: %d\n" %
                        (iPlayer, pPlayer.getAssets()))
            pFile.write("Player %d Power: %d\n" %
                        (iPlayer, pPlayer.getPower()))
            pFile.write("Player %d Num Cities: %d\n" %
                        (iPlayer, pPlayer.getNumCities()))
            pFile.write("Player %d Num Units: %d\n" %
                        (iPlayer, pPlayer.getNumUnits()))
            pFile.write("Player %d Num Selection Groups: %d\n" %
                        (iPlayer, pPlayer.getNumSelectionGroups()))
            pFile.write("Player %d Difficulty: %d\n" %
                        (iPlayer, pPlayer.getHandicapType()))
            pFile.write(
                "Player %d State Religion: %s\n" %
                (iPlayer, CvUtil.convertToStr(pPlayer.getStateReligionKey())))
            pFile.write("Player %d Culture: %d\n" %
                        (iPlayer, pPlayer.getCulture()))

            pFile.write("\n\nYields:\n-------\n")

            for iYield in xrange(YieldTypes.NUM_YIELD_TYPES):
                pFile.write("Player %d %s Total Yield: %d\n" %
                            (iPlayer,
                             CvUtil.convertToStr(
                                 GC.getYieldInfo(iYield).getDescription()),
                             pPlayer.calculateTotalYield(iYield)))

            pFile.write("\n\nCommerce:\n---------\n")

            for iCommerce in xrange(CommerceTypes.NUM_COMMERCE_TYPES):
                pFile.write(
                    "Player %d %s Total Commerce: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         GC.getCommerceInfo(iCommerce).getDescription()),
                     pPlayer.getCommerceRate(CommerceTypes(iCommerce))))

            pFile.write("\n\nCity event history:\n-----------\n")

            if pPlayer.getNumCities():
                pCity, i = pPlayer.firstCity(False)
                while pCity:
                    bFirst = True
                    for iEvent in xrange(GC.getNumEventInfos()):
                        if pCity.isEventOccured(iEvent):
                            if bFirst:
                                pFile.write(
                                    "City: %s\n" %
                                    CvUtil.convertToStr(pCity.getName()))
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getEventInfo(iEvent).getDescription()) +
                                        "\n")
                    pCity, i = pPlayer.nextCity(i, False)

            pFile.write("\n\nCity Info:\n----------\n")

            if pPlayer.getNumCities():
                pCity, i = pPlayer.firstCity(False)
                while pCity:
                    pFile.write("City: %s\n" %
                                CvUtil.convertToStr(pCity.getName()))
                    pFile.write("X: %d, Y: %d\n" %
                                (pCity.getX(), pCity.getY()))
                    pFile.write("Population: %d\n" % (pCity.getPopulation()))
                    pFile.write("Buildings: %d\n" %
                                (pCity.getNumRealBuildings()))
                    pFile.write("Improved Plots: %d\n" %
                                (pCity.countNumImprovedPlots()))
                    pFile.write("Tiles Worked: %d, Specialists: %d\n" %
                                (pCity.getWorkingPopulation(),
                                 pCity.getSpecialistPopulation()))
                    pFile.write("Great People: %d\n" %
                                pCity.getNumGreatPeople())
                    pFile.write("Good Health: %d, Bad Health: %d\n" %
                                (pCity.goodHealth(), pCity.badHealth(False)))
                    pFile.write("Happy Level: %d, Unhappy Level: %d\n" %
                                (pCity.happyLevel(), pCity.unhappyLevel(0)))
                    pFile.write("Food: %d\n" % pCity.getFood())
                    pCity, i = pPlayer.nextCity(i, False)
            else:
                pFile.write("No Cities")

            pFile.write("\n\nBonus Info:\n-----------\n")

            for iBonus in xrange(GC.getNumBonusInfos()):
                szTemp = CvUtil.convertToStr(
                    GC.getBonusInfo(iBonus).getDescription())
                pFile.write(
                    "Player %d, %s, Number Available: %d\n" %
                    (iPlayer, szTemp, pPlayer.getNumAvailableBonuses(iBonus)))
                pFile.write("Player %d, %s, Import: %d\n" %
                            (iPlayer, szTemp, pPlayer.getBonusImport(iBonus)))
                pFile.write("Player %d, %s, Export: %d\n\n" %
                            (iPlayer, szTemp, pPlayer.getBonusExport(iBonus)))

            pFile.write("\n\nImprovement Info:\n-----------------\n")

            for iImprovement in xrange(GC.getNumImprovementInfos()):
                pFile.write(
                    "Player %d, %s, Improvement count: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         GC.getImprovementInfo(iImprovement).getDescription()),
                     pPlayer.getImprovementCount(iImprovement)))

            pFile.write("\n\nBuilding Info:\n--------------------\n")

            for iBuilding in xrange(GC.getNumBuildingInfos()):
                pFile.write(
                    "Player %d, %s, Building class count plus making: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         GC.getBuildingInfo(iBuilding).getDescription()),
                     pPlayer.getBuildingCountPlusMaking(iBuilding)))

            pFile.write("\n\nUnit Class Info:\n--------------------\n")

            for iUnit in xrange(GC.getNumUnitInfos()):
                pFile.write(
                    "Player %d, %s, Unit class count plus training: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         GC.getUnitInfo(iUnit).getDescription()),
                     pPlayer.getUnitCountPlusMaking(iUnit)))

            pFile.write("\n\nUnitAI Types Info:\n------------------\n")

            for iUnitAIType in xrange(int(UnitAITypes.NUM_UNITAI_TYPES)):
                pFile.write(
                    "Player %d, %s, Unit AI Type count: %d\n" %
                    (iPlayer, GC.getUnitAIInfo(iUnitAIType).getType(),
                     pPlayer.AI_totalUnitAIs(UnitAITypes(iUnitAIType))))

            pFile.write("\n\nCity Religions:\n-----------\n")

            if pPlayer.getNumCities():
                pCity, i = pPlayer.firstCity(False)
                while pCity:
                    bFirst = True
                    for iReligion in xrange(GC.getNumReligionInfos()):
                        if pCity.isHasReligion(iReligion):
                            if bFirst:
                                pFile.write(
                                    "City: %s\n" %
                                    CvUtil.convertToStr(pCity.getName()))
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getReligionInfo(iReligion).getDescription())
                                        + "\n")
                    pCity, i = pPlayer.nextCity(i, False)

            pFile.write("\n\nCity Corporations:\n-----------\n")

            if pPlayer.getNumCities():
                pCity, i = pPlayer.firstCity(False)
                while pCity:
                    bFirst = True
                    for iCorporation in xrange(GC.getNumCorporationInfos()):
                        if pCity.isHasCorporation(iCorporation):
                            if bFirst:
                                pFile.write(
                                    "City: %s\n" %
                                    CvUtil.convertToStr(pCity.getName()))
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getCorporationInfo(
                                    iCorporation).getDescription()) + "\n")
                    pCity, i = pPlayer.nextCity(i, False)

            pFile.write("\n\nUnit Info:\n----------\n")

            if pPlayer.getNumUnits():
                for pUnit in pPlayer.units():
                    pFile.write("Player %d, Unit ID: %d, %s\n" %
                                (iPlayer, pUnit.getID(),
                                 CvUtil.convertToStr(pUnit.getName())))
                    pFile.write(
                        "X: %d, Y: %d\nDamage: %d\n" %
                        (pUnit.getX(), pUnit.getY(), pUnit.getDamage()))
                    pFile.write("Experience: %d\nLevel: %d\n" %
                                (pUnit.getExperience(), pUnit.getLevel()))
                    bFirst = True
                    for j in xrange(GC.getNumPromotionInfos()):
                        if pUnit.isHasPromotion(j):
                            if bFirst:
                                pFile.write("Promotions:\n")
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getPromotionInfo(j).getDescription()) +
                                        "\n")
                    bFirst = True
                    for j in xrange(GC.getNumUnitCombatInfos()):
                        if pUnit.isHasUnitCombat(j):
                            if bFirst:
                                pFile.write("UnitCombats:\n")
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getUnitCombatInfo(j).getDescription()) +
                                        "\n")
            else:
                pFile.write("No Units")
            # Space at end of player's info
            pFile.write("\n\n")
    # Close file
    pFile.close()

    # Restore current language
    GAME.setCurrentLanguage(iLanguage)
    def drawFinance(self):
        screen = self.getScreen()
        # Header...
        screen.setLabel(
            self.WIDGET_HEADER, "Background", u"<font=4b>" +
            localText.getText("TXT_KEY_ECONOMICS_ADVISOR_FINANCE_TAB",
                              ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY, self.X_SCREEN, self.Y_TITLE,
            self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL,
            -1, -1)

        player = gc.getPlayer(self.iActiveLeader)

        # numCities = player.getNumCities()

        # K-Mod - I've changed these costs to include inflation.
        inflationFactor = 100 + player.getInflationRate()
        totalUnitCost = (player.calculateUnitCost() * inflationFactor +
                         50) / 100
        totalUnitSupply = (player.calculateUnitSupply() * inflationFactor +
                           50) / 100
        totalMaintenance = (player.getTotalMaintenance() * inflationFactor +
                            50) / 100
        totalCivicUpkeep = (
            player.getCivicUpkeep([], False) * inflationFactor + 50) / 100

        # 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_LEFT_PANEL,
            self.Y_TOP_PANEL,
            self.X_RIGHT_PANEL + self.PANE_WIDTH - self.X_LEFT_PANEL,
            self.H_TOP_PANEL, 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_LEFT_PANEL + self.PANE_WIDTH + self.X_RIGHT_PANEL) / 2,
            self.Y_TOP_PANEL + self.H_TOP_PANEL / 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_LEFT_PANEL, 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_LEFT_PANEL + 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_MIDDLE_PANEL, 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_MIDDLE_PANEL + 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_RIGHT_PANEL, 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_RIGHT_PANEL + 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 xrange(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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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 xrange(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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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 xrange(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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + 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_LEFT_PANEL + self.PANE_WIDTH - self.TEXT_MARGIN,
                    yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ,
                    FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        # K-Mod. Show gold rate if it hasn't been shown already
        if (not player.isCommerceFlexible(CommerceTypes.COMMERCE_GOLD)):
            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_LEFT_PANEL + 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_LEFT_PANEL + 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 xrange(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 xrange(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

        # K-Mod, karadoc
        # The 'total minus taxes' was wrong. We don't need to use that anyway
        # I've changed the 'taxes' output to use fTaxes instead of goldcommerce - totalminustaxes
        ##
        #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_MIDDLE_PANEL + 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(fTaxes)) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_MIDDLE_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + 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_RIGHT_PANEL + self.PANE_WIDTH - 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(totalInflatedCosts) + "</font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            self.X_RIGHT_PANEL + 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)

        return 0