home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 January / Gamestar_80_2006-01_dvd.iso / Dema / Civilization4 / data1.cab / Civ4DemoComponent / Assets / Python / Screens / CvInfoScreen.py < prev    next >
Encoding:
Python Source  |  2005-11-09  |  88.4 KB  |  2,097 lines

  1. ## Sid Meier's Civilization 4
  2. ## Copyright Firaxis Games 2005
  3. from CvPythonExtensions import *
  4. import CvScreenEnums
  5. import CvUtil
  6. import ScreenInput
  7.  
  8. import string
  9. import time
  10.  
  11. from PyHelpers import PyPlayer
  12.  
  13. # globals
  14. gc = CyGlobalContext()
  15. ArtFileMgr = CyArtFileMgr()
  16. localText = CyTranslator()
  17.  
  18. class CvInfoScreen:
  19.     "Info Screen! Contains the Demographics, Wonders / Top Cities and Statistics Screens"
  20.     
  21.     def __init__(self, screenId):
  22.         return
  23.         
  24.         self.screenId = screenId
  25.         self.DEMO_SCREEN_NAME = "DemographicsScreen"
  26.         self.TOP_CITIES_SCREEN_NAME = "TopCitiesScreen"
  27.         
  28.         self.INTERFACE_ART_INFO = "TECH_BG"
  29.  
  30.         self.WIDGET_ID = "DemoScreenWidget"
  31.  
  32.         self.Z_BACKGROUND = -6.1
  33.         self.Z_CONTROLS = self.Z_BACKGROUND - 0.2
  34.         self.DZ = -0.2
  35.         self.Z_HELP_AREA = self.Z_CONTROLS - 1
  36.  
  37.         self.X_SCREEN = 0
  38.         self.Y_SCREEN = 0
  39.         self.W_SCREEN = 1024
  40.         self.H_SCREEN = 768
  41.         self.X_TITLE = 512
  42.         self.Y_TITLE = 8
  43.         self.BORDER_WIDTH = 4
  44.         self.W_HELP_AREA = 200
  45.         
  46.         self.X_EXIT = 994
  47.         self.Y_EXIT = 730
  48.         
  49.         self.X_DEMOGRAPHICS_TAB = 30
  50.         self.X_TOP_CITIES_TAB = 250
  51.         self.X_STATS_TAB = 550
  52.         self.Y_TABS = 730
  53.         self.W_BUTTON = 200
  54.         self.H_BUTTON = 30
  55.         
  56.         self.nWidgetCount = 0
  57.         # This is used to allow the wonders screen to refresh without redrawing everything
  58.         self.iNumWondersPermanentWidgets = 0
  59.         
  60.         self.iDemographicsID    =    0
  61.         self.iTopCitiesID    =    1
  62.         self.iStatsID        =    2
  63.                 
  64.         self.iActiveTab = self.iDemographicsID
  65.         
  66. ############################################### DEMOGRAPHICS ###############################################
  67.         
  68.         self.X_CHART = 460
  69.         self.Y_CHART = 80
  70.         self.W_CHART = 530
  71.         self.H_CHART = 600
  72.         
  73.         self.X_GRAPH = 45
  74.         self.Y_GRAPH = 110#80
  75.         self.W_GRAPH = 400
  76.         self.H_GRAPH = 570
  77.         
  78.         self.X_DEMO_DROPDOWN = 45
  79.         self.Y_DEMO_DROPDOWN = 78#650
  80.         self.W_DEMO_DROPDOWN = 197
  81.         
  82.         self.X_ALL_PLAYERS_CHECKBOX = self.X_DEMO_DROPDOWN + self.W_DEMO_DROPDOWN + 10
  83.         self.Y_ALL_PLAYERS_CHECKBOX = self.Y_DEMO_DROPDOWN + 7
  84.         self.BUTTON_SIZE = 20
  85.         
  86.         self.W_TEXT = 140
  87.         self.H_TEXT = 15
  88.         self.X_TEXT_BUFFER = 0
  89.         self.Y_TEXT_BUFFER = 43
  90.         
  91.         self.X_COL_1 = 535
  92.         self.X_COL_2 = self.X_COL_1 + self.W_TEXT + self.X_TEXT_BUFFER
  93.         self.X_COL_3 = self.X_COL_2 + self.W_TEXT + self.X_TEXT_BUFFER
  94.         self.X_COL_4 = self.X_COL_3 + self.W_TEXT + self.X_TEXT_BUFFER
  95.         
  96.         self.Y_ROW_1 = 100
  97.         self.Y_ROW_2 = self.Y_ROW_1 + self.H_TEXT + self.Y_TEXT_BUFFER
  98.         self.Y_ROW_3 = self.Y_ROW_2 + self.H_TEXT + self.Y_TEXT_BUFFER
  99.         self.Y_ROW_4 = self.Y_ROW_3 + self.H_TEXT + self.Y_TEXT_BUFFER
  100.         self.Y_ROW_5 = self.Y_ROW_4 + self.H_TEXT + self.Y_TEXT_BUFFER
  101.         self.Y_ROW_6 = self.Y_ROW_5 + self.H_TEXT + self.Y_TEXT_BUFFER
  102.         self.Y_ROW_7 = self.Y_ROW_6 + self.H_TEXT + self.Y_TEXT_BUFFER
  103.         self.Y_ROW_8 = self.Y_ROW_7 + self.H_TEXT + self.Y_TEXT_BUFFER
  104.         self.Y_ROW_9 = self.Y_ROW_8 + self.H_TEXT + self.Y_TEXT_BUFFER
  105.         self.Y_ROW_10 = self.Y_ROW_9 + self.H_TEXT + self.Y_TEXT_BUFFER
  106.         
  107.         self.bAbleToShowAllPlayers = false
  108.         self.iShowingPlayer = -1
  109.         self.aiDropdownPlayerIDs = []
  110.         
  111.         self.iScoreTabID    = 0
  112.         self.iEconomyTabID    = 1
  113.         self.iIndustryTabID    = 2
  114.         self.iAgricultureTabID    = 3
  115.         self.iPowerTabID    = 4
  116.         self.iCultureTabID    = 5
  117.         
  118. ############################################### TOP CITIES ###############################################
  119.         
  120.         self.X_LEFT_PANE = 45
  121.         self.Y_LEFT_PANE = 70
  122.         self.W_LEFT_PANE = 470
  123.         self.H_LEFT_PANE = 620
  124.         
  125.         # Text
  126.         
  127.         self.W_TC_TEXT = 280
  128.         self.H_TC_TEXT = 15
  129.         self.X_TC_TEXT_BUFFER = 0
  130.         self.Y_TC_TEXT_BUFFER = 43
  131.         
  132.         # Animated City thingies
  133.                 
  134.         self.X_CITY_ANIMATION = self.X_LEFT_PANE + 20
  135.         self.Z_CITY_ANIMATION = self.Z_BACKGROUND - 0.5
  136.         self.W_CITY_ANIMATION = 150
  137.         self.H_CITY_ANIMATION = 110
  138.         self.Y_CITY_ANIMATION_BUFFER = self.H_CITY_ANIMATION / 2
  139.         
  140.         self.X_ROTATION_CITY_ANIMATION = -20
  141.         self.Z_ROTATION_CITY_ANIMATION = 30
  142.         self.SCALE_ANIMATION = 0.5
  143.         
  144.         # Placement of Cities
  145.         
  146.         self.X_COL_1_CITIES = self.X_LEFT_PANE + 20
  147.         self.Y_CITIES_BUFFER = 118
  148.                 
  149.         self.Y_ROWS_CITIES = []
  150.         self.Y_ROWS_CITIES.append(self.Y_LEFT_PANE + 20)
  151.         for i in range(1,5):
  152.             self.Y_ROWS_CITIES.append(self.Y_ROWS_CITIES[i-1] + self.Y_CITIES_BUFFER)
  153.         
  154.         self.X_COL_1_CITIES_DESC = self.X_LEFT_PANE + self.W_CITY_ANIMATION + 30
  155.         self.Y_CITIES_DESC_BUFFER = -4
  156.         self.W_CITIES_DESC = 275
  157.         self.H_CITIES_DESC = 60
  158.         
  159.         self.Y_CITIES_WONDER_BUFFER = 57
  160.         self.W_CITIES_WONDER = 275
  161.         self.H_CITIES_WONDER = 51
  162.         
  163. ############################################### WONDERS ###############################################
  164.         
  165.         self.X_RIGHT_PANE = 520
  166.         self.Y_RIGHT_PANE = 70
  167.         self.W_RIGHT_PANE = 460
  168.         self.H_RIGHT_PANE = 620
  169.         
  170.         # Info about this wonder, e.g. name, cost so on
  171.         
  172.         self.X_STATS_PANE = self.X_RIGHT_PANE + 20
  173.         self.Y_STATS_PANE = self.Y_RIGHT_PANE + 20
  174.         self.W_STATS_PANE = 210
  175.         self.H_STATS_PANE = 220
  176.         
  177.         # Wonder mode dropdown Box
  178.         
  179.         self.X_DROPDOWN = self.X_RIGHT_PANE + 240 + 3 # the 3 is the 'fudge factor' due to the widgets not lining up perfectly
  180.         self.Y_DROPDOWN = self.Y_RIGHT_PANE + 20
  181.         self.W_DROPDOWN = 200
  182.         
  183.         # List Box that displays all wonders built
  184.         
  185.         self.X_WONDER_LIST = self.X_RIGHT_PANE + 240 + 6 # the 6 is the 'fudge factor' due to the widgets not lining up perfectly
  186.         self.Y_WONDER_LIST = self.Y_RIGHT_PANE + 60
  187.         self.W_WONDER_LIST = 200 - 6 # the 6 is the 'fudge factor' due to the widgets not lining up perfectly
  188.         self.H_WONDER_LIST = 180
  189.         
  190.         # Animated Wonder thingies
  191.         
  192.         self.X_WONDER_GRAPHIC = 540
  193.         self.Y_WONDER_GRAPHIC = self.Y_RIGHT_PANE + 20 + 200 + 35
  194.         self.W_WONDER_GRAPHIC = 420
  195.         self.H_WONDER_GRAPHIC = 190
  196.         
  197.         self.X_ROTATION_WONDER_ANIMATION = -20
  198.         self.Z_ROTATION_WONDER_ANIMATION = 30
  199.         
  200.         # Icons used for Projects instead because no on-map art exists
  201.         self.X_PROJECT_ICON = self.X_WONDER_GRAPHIC + self.W_WONDER_GRAPHIC / 2
  202.         self.Y_PROJECT_ICON = self.Y_WONDER_GRAPHIC + self.H_WONDER_GRAPHIC / 2
  203.         self.W_PROJECT_ICON = 128
  204.         
  205.         # Special Stats about this wonder
  206.         
  207.         self.X_SPECIAL_TITLE = 540
  208.         self.Y_SPECIAL_TITLE = 310 + 200 + 7
  209.         
  210.         self.X_SPECIAL_PANE = 540
  211.         self.Y_SPECIAL_PANE = 310 + 200 + 20 + 15
  212.         self.W_SPECIAL_PANE = 420
  213.         self.H_SPECIAL_PANE = 140 - 15
  214.         
  215.         self.szWonderDisplayMode = "World Wonders"
  216.         
  217.         self.iWonderID = -1            # BuildingType ID of the active wonder, e.g. Palace is 0, Globe Theater is 66
  218.         self.iActiveWonderCounter = 0        # Screen ID for this wonder (0, 1, 2, etc.) - different from the above variable
  219.         
  220. ############################################### STATISTICS ###############################################
  221.         
  222.         # STATISTICS TAB
  223.         
  224.         # Top Panel
  225.         
  226.         self.X_STATS_TOP_PANEL = 45
  227.         self.Y_STATS_TOP_PANEL = 75
  228.         self.W_STATS_TOP_PANEL = 935
  229.         self.H_STATS_TOP_PANEL = 180
  230.         
  231.         # Leader
  232.         
  233.         self.X_LEADER_ICON = 250
  234.         self.Y_LEADER_ICON = 95
  235.         self.H_LEADER_ICON = 140
  236.         self.W_LEADER_ICON = 110
  237.         
  238.         # Top Chart
  239.         
  240.         self.X_STATS_TOP_CHART = 400
  241.         self.Y_STATS_TOP_CHART = 130
  242.         self.W_STATS_TOP_CHART = 380
  243.         self.H_STATS_TOP_CHART = 102
  244.         
  245.         self.STATS_TOP_CHART_W_COL_0 = 304
  246.         self.STATS_TOP_CHART_W_COL_1 = 76
  247.         
  248.         self.iNumTopChartCols = 2
  249.         self.iNumTopChartRows = 4
  250.         
  251.         self.X_LEADER_NAME = self.X_STATS_TOP_CHART
  252.         self.Y_LEADER_NAME = self.Y_STATS_TOP_CHART - 40
  253.         
  254.         # Bottom Chart
  255.         
  256.         self.X_STATS_BOTTOM_CHART = 45
  257.         self.Y_STATS_BOTTOM_CHART = 280
  258.         self.W_STATS_BOTTOM_CHART = 935
  259.         self.H_STATS_BOTTOM_CHART = 410
  260.         
  261.         self.reset()
  262.         
  263.     def initText(self):
  264.         
  265.         ###### TEXT ######
  266.         self.SCREEN_TITLE = u"<font=4b>" + localText.getText("TXT_KEY_INFO_SCREEN", ()).upper() + u"</font>"
  267.         self.SCREEN_DEMOGRAPHICS_TITLE = u"<font=4b>" + localText.getText("TXT_KEY_DEMO_SCREEN_TITLE", ()).upper() + u"</font>"
  268.         self.SCREEN_TOP_CITIES_TITLE = u"<font=4b>" + localText.getText("TXT_KEY_CONCEPT_WONDERS", ()).upper() + " / " + localText.getText("TXT_KEY_WONDERS_SCREEN_TOP_CITIES_TEXT", ()).upper() + u"</font>"
  269.         self.SCREEN_STATS_TITLE = u"<font=4b>" + localText.getText("TXT_KEY_INFO_SCREEN_STATISTICS_TITLE", ()).upper() + u"</font>"
  270.         
  271.         self.EXIT_TEXT = u"<font=4>" + localText.getText("TXT_KEY_PEDIA_SCREEN_EXIT", ()).upper() + u"</font>"
  272.         
  273.         self.TEXT_DEMOGRAPHICS = u"<font=4>" + localText.getText("TXT_KEY_DEMO_SCREEN_TITLE", ()).upper() + u"</font>"
  274.         self.TEXT_DEMOGRAPHICS_SMALL = localText.getText("TXT_KEY_DEMO_SCREEN_TITLE", ())
  275.         self.TEXT_TOP_CITIES = u"<font=4>" + localText.getText("TXT_KEY_CONCEPT_WONDERS", ()).upper() + " / " + localText.getText("TXT_KEY_WONDERS_SCREEN_TOP_CITIES_TEXT", ()).upper() + u"</font>"
  276.         self.TEXT_STATS = u"<font=4>" + localText.getText("TXT_KEY_INFO_SCREEN_STATISTICS_TITLE", ()).upper() + u"</font>"
  277.         self.TEXT_DEMOGRAPHICS_YELLOW = u"<font=4>" + localText.getColorText("TXT_KEY_DEMO_SCREEN_TITLE", (), gc.getInfoTypeForString("COLOR_YELLOW")).upper() + u"</font>"
  278.         self.TEXT_TOP_CITIES_YELLOW = u"<font=4>" + localText.getColorText("TXT_KEY_CONCEPT_WONDERS", (), gc.getInfoTypeForString("COLOR_YELLOW")).upper() + " / " + localText.getColorText("TXT_KEY_WONDERS_SCREEN_TOP_CITIES_TEXT", (), gc.getInfoTypeForString("COLOR_YELLOW")).upper() + u"</font>"
  279.         self.TEXT_STATS_YELLOW = u"<font=4>" + localText.getColorText("TXT_KEY_INFO_SCREEN_STATISTICS_TITLE", (), gc.getInfoTypeForString("COLOR_YELLOW")).upper() + u"</font>"
  280.         
  281.         self.TEXT_SHOW_ALL_PLAYERS = "Show All Players"
  282.         self.TEXT_SHOW_ALL_PLAYERS_GRAY = localText.getColorText("TXT_KEY_DEMO_SCREEN_TITLE", (), gc.getInfoTypeForString("COLOR_PLAYER_GRAY")).upper()
  283.         
  284.         self.TEXT_SCORE = localText.getText("TXT_KEY_GAME_SCORE", ())
  285.         self.TEXT_POWER = localText.getText("TXT_KEY_POWER", ())
  286.         self.TEXT_CULTURE = localText.getText("TXT_KEY_COMMERCE_CULTURE", ())
  287.         
  288.         self.TEXT_VALUE = localText.getText("TXT_KEY_DEMO_SCREEN_VALUE_TEXT", ())
  289.         self.TEXT_RANK = localText.getText("TXT_KEY_DEMO_SCREEN_RANK_TEXT", ())
  290.         self.TEXT_AVERAGE = localText.getText("TXT_KEY_DEMOGRAPHICS_SCREEN_RIVAL_AVERAGE", ())
  291.         
  292.         self.TEXT_ECONOMY = localText.getText("TXT_KEY_DEMO_SCREEN_ECONOMY_TEXT", ())
  293.         self.TEXT_INDUSTRY = localText.getText("TXT_KEY_DEMO_SCREEN_INDUSTRY_TEXT", ())
  294.         self.TEXT_AGRICULTURE = localText.getText("TXT_KEY_DEMO_SCREEN_AGRICULTURE_TEXT", ())
  295.         self.TEXT_MILITARY = localText.getText("TXT_KEY_DEMO_SCREEN_MILITARY_TEXT", ())
  296.         self.TEXT_LAND_AREA = localText.getText("TXT_KEY_DEMO_SCREEN_LAND_AREA_TEXT", ())
  297.         self.TEXT_POPULATION = localText.getText("TXT_KEY_DEMO_SCREEN_POPULATION_TEXT", ())
  298.         self.TEXT_HAPPINESS = localText.getText("TXT_KEY_DEMO_SCREEN_HAPPINESS_TEXT", ())
  299.         self.TEXT_HEALTH = localText.getText("TXT_KEY_DEMO_SCREEN_HEALTH_TEXT", ())
  300.         self.TEXT_IMP_EXP = localText.getText("TXT_KEY_DEMO_SCREEN_IMPORTS_TEXT", ()) + "/" + localText.getText("TXT_KEY_DEMO_SCREEN_EXPORTS_TEXT", ())
  301.         
  302.         self.TEXT_ECONOMY_MEASURE = (u"  %c" % CyGame().getSymbolID(FontSymbols.BULLET_CHAR)) + localText.getText("TXT_KEY_DEMO_SCREEN_ECONOMY_MEASURE", ())
  303.         self.TEXT_INDUSTRY_MEASURE = (u"  %c" % CyGame().getSymbolID(FontSymbols.BULLET_CHAR)) + localText.getText("TXT_KEY_DEMO_SCREEN_INDUSTRY_MEASURE", ())
  304.         self.TEXT_AGRICULTURE_MEASURE = (u"  %c" % CyGame().getSymbolID(FontSymbols.BULLET_CHAR)) + localText.getText("TXT_KEY_DEMO_SCREEN_AGRICULTURE_MEASURE", ())
  305.         self.TEXT_MILITARY_MEASURE = ""
  306.         self.TEXT_LAND_AREA_MEASURE = (u"  %c" % CyGame().getSymbolID(FontSymbols.BULLET_CHAR)) + localText.getText("TXT_KEY_DEMO_SCREEN_LAND_AREA_MEASURE", ())
  307.         self.TEXT_POPULATION_MEASURE = ""
  308.         self.TEXT_HAPPINESS_MEASURE = "%"
  309.         self.TEXT_HEALTH_MEASURE = (u"  %c" % CyGame().getSymbolID(FontSymbols.BULLET_CHAR)) + localText.getText("TXT_KEY_DEMO_SCREEN_POPULATION_MEASURE", ())
  310.         self.TEXT_IMP_EXP_MEASURE = (u"  %c" % CyGame().getSymbolID(FontSymbols.BULLET_CHAR)) + localText.getText("TXT_KEY_DEMO_SCREEN_ECONOMY_MEASURE", ())
  311.         
  312.         self.TEXT_TIME_PLAYED = localText.getText("TXT_KEY_INFO_SCREEN_TIME_PLAYED", ())
  313.         self.TEXT_CITIES_BUILT = localText.getText("TXT_KEY_INFO_SCREEN_CITIES_BUILT", ())
  314.         self.TEXT_CITIES_RAZED = localText.getText("TXT_KEY_INFO_SCREEN_CITIES_RAZED", ())
  315.         self.TEXT_NUM_GOLDEN_AGES = localText.getText("TXT_KEY_INFO_SCREEN_NUM_GOLDEN_AGES", ())
  316.         self.TEXT_NUM_RELIGIONS_FOUNDED = localText.getText("TXT_KEY_INFO_SCREEN_RELIGIONS_FOUNDED", ())
  317.         
  318.         self.TEXT_CURRENT = localText.getText("TXT_KEY_CURRENT", ())
  319.         self.TEXT_UNITS = localText.getText("TXT_KEY_CONCEPT_UNITS", ())
  320.         self.TEXT_BUILDINGS = localText.getText("TXT_KEY_CONCEPT_BUILDINGS", ())
  321.         self.TEXT_KILLED = localText.getText("TXT_KEY_INFO_SCREEN_KILLED", ())
  322.         self.TEXT_LOST = localText.getText("TXT_KEY_INFO_SCREEN_LOST", ())
  323.         self.TEXT_BUILT = localText.getText("TXT_KEY_INFO_SCREEN_BUILT", ())
  324.         
  325.     def reset(self):
  326.         
  327.         # City Members
  328.         
  329.         self.szCityNames = [    "",
  330.                     "",
  331.                     "",
  332.                     "",
  333.                     ""    ]
  334.         
  335.         self.iCitySizes = [    -1,
  336.                     -1,
  337.                     -1,
  338.                     -1,
  339.                     -1    ]
  340.         
  341.         self.szCityDescs = [    "",
  342.                     "",
  343.                     "",
  344.                     "",
  345.                     ""    ]
  346.         
  347.         self.aaCitiesXY = [    [-1, -1],
  348.                     [-1, -1],
  349.                     [-1, -1],
  350.                     [-1, -1],
  351.                     [-1, -1]    ]
  352.         
  353.         self.iCityValues =   [  0,
  354.                     0,
  355.                     0,
  356.                     0,
  357.                     0    ]
  358.         
  359.         self.pCityPointers = [  0,
  360.                     0,
  361.                     0,
  362.                     0,
  363.                     0    ]
  364.         
  365. #        self.bShowAllPlayers = false
  366.         self.iShowingPlayer = -1
  367.         
  368.     def resetWonders(self):
  369.         
  370.         self.szWonderDisplayMode = "World Wonders"
  371.         
  372.         self.iWonderID = -1            # BuildingType ID of the active wonder, e.g. Palace is 0, Globe Theater is 66
  373.         self.iActiveWonderCounter = 0        # Screen ID for this wonder (0, 1, 2, etc.) - different from the above variable
  374.         
  375.         self.aiWonderListBoxIDs = []
  376.         self.aiTurnYearBuilt = []
  377.         self.aiWonderBuiltBy = []
  378.         
  379.     def getScreen(self):
  380.         return CyGInterfaceScreen(self.DEMO_SCREEN_NAME, self.screenId)
  381.  
  382.     def hideScreen(self):
  383.         screen = self.getScreen()
  384.         screen.hideScreen()
  385.     
  386.     def getLastTurn(self):
  387.         return (gc.getGame().getReplayMessageTurn(gc.getGame().getNumReplayMessages()-1))
  388.         
  389.     # Screen construction function
  390.     def showScreen(self, iTurn, iTabID):
  391.         
  392.         self.initText();
  393.         
  394.         self.iStartTurn = 0
  395.         for iI in range(gc.getGameSpeedInfo(gc.getGame().getGameSpeedType()).getNumTurnIncrements()):
  396.             self.iStartTurn += gc.getGameSpeedInfo(gc.getGame().getGameSpeedType()).getGameTurnInfo(iI).iNumGameTurnsPerIncrement
  397.         self.iStartTurn *= gc.getEraInfo(gc.getGame().getStartEra()).getStartPercent()
  398.         self.iStartTurn /= 100
  399.     
  400.         self.iTurn = 0
  401.  
  402.         if (iTurn > self.getLastTurn()):
  403.             return
  404.                     
  405.         # Create a new screen
  406.         screen = self.getScreen()
  407.         if screen.isActive():
  408.             return
  409.         screen.setRenderInterfaceOnly(True)
  410.         screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)
  411.         
  412.         self.reset()
  413.         
  414.         self.deleteAllWidgets()
  415.  
  416.         # Set the background widget and exit button
  417.         screen.addDDSGFC("DemographicsScreenBackground", ArtFileMgr.getInterfaceArtInfo("MAINMENU_SLIDESHOW_LOAD").getPath(), 0, 0, self.W_SCREEN, self.H_SCREEN, WidgetTypes.WIDGET_GENERAL, -1, -1 )
  418.         screen.addPanel( "TechTopPanel", u"", u"", True, False, 0, 0, self.W_SCREEN, 55, PanelStyles.PANEL_STYLE_TOPBAR )
  419.         screen.addPanel( "TechBottomPanel", u"", u"", True, False, 0, 713, self.W_SCREEN, 55, PanelStyles.PANEL_STYLE_BOTTOMBAR )
  420.         screen.showWindowBackground( False )
  421.         screen.setDimensions(screen.centerX(self.X_SCREEN), screen.centerY(self.Y_SCREEN), self.W_SCREEN, self.H_SCREEN)
  422.         self.szExitButtonName = self.getNextWidgetName()
  423.         screen.setText(self.szExitButtonName, "Background", self.EXIT_TEXT, CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXIT, self.Y_EXIT, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
  424.     
  425.         # Header...
  426.         self.szHeaderWidget = self.getNextWidgetName()
  427.         screen.setText(self.szHeaderWidget, "Background", self.SCREEN_TITLE, CvUtil.FONT_CENTER_JUSTIFY, self.X_TITLE, self.Y_TITLE, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  428.         screen.setTextHighlightColor(self.szHeaderWidget, gc.getInfoTypeForString("COLOR_BROWN_TEXT"))
  429.  
  430.         # Help area for tooltips
  431.         screen.setHelpTextArea(self.W_HELP_AREA, FontTypes.SMALL_FONT, self.X_SCREEN, self.Y_SCREEN, self.Z_HELP_AREA, 1, ArtFileMgr.getInterfaceArtInfo("POPUPS_BACKGROUND_TRANSPARENT").getPath(), True, True, CvUtil.FONT_LEFT_JUSTIFY, 0 )
  432.         
  433.         self.DEBUG_DROPDOWN_ID = ""
  434.         
  435.         if (CyGame().isDebugMode()):
  436.             self.DEBUG_DROPDOWN_ID = "InfoScreenDropdownWidget"
  437.             self.szDropdownName = self.DEBUG_DROPDOWN_ID
  438.             screen.addDropDownBoxGFC(self.szDropdownName, 22, 12, 300, WidgetTypes.WIDGET_GENERAL, -1, -1, FontTypes.GAME_FONT)
  439.             for j in range(gc.getMAX_PLAYERS()):
  440.                 if (gc.getPlayer(j).isAlive()):
  441.                     screen.addPullDownString(self.szDropdownName, gc.getPlayer(j).getName(), j, j, False )
  442.         
  443.         self.iActivePlayer = CyGame().getActivePlayer()
  444.         self.pActivePlayer = gc.getPlayer(self.iActivePlayer)
  445.         self.iActiveTeam = self.pActivePlayer.getTeam()
  446.         self.pActiveTeam = gc.getTeam(self.iActiveTeam)
  447.         
  448.         # Determine who this active player knows
  449.         self.aiPlayersMet = []
  450.         self.iNumPlayersMet = 0
  451.         for iLoopPlayer in range(gc.getMAX_CIV_PLAYERS()):
  452.             pLoopPlayer = gc.getPlayer(iLoopPlayer)
  453.             iLoopPlayerTeam = pLoopPlayer.getTeam()
  454.             if (gc.getTeam(iLoopPlayerTeam).isEverAlive()):
  455.                 if (self.pActiveTeam.isHasMet(iLoopPlayerTeam) or CyGame().isDebugMode()):
  456.                     self.aiPlayersMet.append(iLoopPlayer)
  457.                     self.iNumPlayersMet += 1
  458.         
  459.         # "Save" current widgets so they won't be deleted later when changing tabs
  460.         self.iNumPermanentWidgets = self.nWidgetCount
  461.         
  462.         self.iActiveTab = iTabID
  463.         if (self.iNumPlayersMet > 1):
  464.             self.iShowingPlayer = 666#self.iActivePlayer
  465.         else:
  466.             self.iShowingPlayer = self.iActivePlayer
  467.         
  468.         self.redrawContents()
  469.         
  470.         return
  471.         
  472.     def redrawContents(self):
  473.         
  474.         screen = self.getScreen()
  475.         self.deleteAllWidgets(self.iNumPermanentWidgets)
  476.         self.iNumWondersPermanentWidgets = 0
  477.         
  478.         self.szDemographicsTabWidget = self.getNextWidgetName()
  479.         self.szTopCitiesTabWidget = self.getNextWidgetName()
  480.         self.szStatsTabWidget = self.getNextWidgetName()
  481.         
  482.         # Draw Tab buttons and tabs
  483.         if (self.iActiveTab == self.iDemographicsID):
  484.             screen.setText(self.szDemographicsTabWidget, "", self.TEXT_DEMOGRAPHICS_YELLOW, CvUtil.FONT_LEFT_JUSTIFY, self.X_DEMOGRAPHICS_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  485.             screen.setText(self.szTopCitiesTabWidget, "", self.TEXT_TOP_CITIES, CvUtil.FONT_LEFT_JUSTIFY, self.X_TOP_CITIES_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  486.             screen.setText(self.szStatsTabWidget, "", self.TEXT_STATS, CvUtil.FONT_LEFT_JUSTIFY, self.X_STATS_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  487.             
  488.             self.drawDemographicsTab()
  489.             
  490.         elif(self.iActiveTab == self.iTopCitiesID):
  491.             screen.setText(self.szDemographicsTabWidget, "", self.TEXT_DEMOGRAPHICS, CvUtil.FONT_LEFT_JUSTIFY, self.X_DEMOGRAPHICS_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  492.             screen.setText(self.szTopCitiesTabWidget, "", self.TEXT_TOP_CITIES_YELLOW, CvUtil.FONT_LEFT_JUSTIFY, self.X_TOP_CITIES_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  493.             screen.setText(self.szStatsTabWidget, "", self.TEXT_STATS, CvUtil.FONT_LEFT_JUSTIFY, self.X_STATS_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  494.             self.drawTopCitiesTab()
  495.             
  496.         elif(self.iActiveTab == self.iStatsID):
  497.             screen.setText(self.szDemographicsTabWidget, "", self.TEXT_DEMOGRAPHICS, CvUtil.FONT_LEFT_JUSTIFY, self.X_DEMOGRAPHICS_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  498.             screen.setText(self.szTopCitiesTabWidget, "", self.TEXT_TOP_CITIES, CvUtil.FONT_LEFT_JUSTIFY, self.X_TOP_CITIES_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  499.             screen.setText(self.szStatsTabWidget, "", self.TEXT_STATS_YELLOW, CvUtil.FONT_LEFT_JUSTIFY, self.X_STATS_TAB, self.Y_TABS, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  500.             self.drawStatsTab()
  501.             
  502. #############################################################################################################
  503. ################################################# DEMOGRAPHICS ##############################################
  504. #############################################################################################################
  505.     
  506.     def drawDemographicsTab(self):
  507.         
  508.         self.iDemoGraphTabID = self.iScoreTabID
  509.         self.fMaxDemoStatValue = 0.0
  510.         
  511.         self.drawTextChart()
  512.         self.drawPermanentGraphWidgets()
  513.         self.drawGraph()
  514.         self.updateGraph()
  515.         
  516.     def drawTextChart(self):
  517.         
  518.         ######## DATA ########
  519.  
  520.         iNumActivePlayers = 0
  521.  
  522.         pPlayer = gc.getPlayer(self.iActivePlayer)
  523.  
  524.         iEconomy = pPlayer.calculateTotalYield(YieldTypes.YIELD_COMMERCE) - pPlayer.calculateInflatedCosts()
  525.         iIndustry = pPlayer.calculateTotalYield(YieldTypes.YIELD_PRODUCTION)
  526.         iAgriculture = pPlayer.calculateTotalYield(YieldTypes.YIELD_FOOD)
  527.         fMilitary = pPlayer.getPower() * 1000
  528.         iLandArea = pPlayer.getTotalLand() * 1000
  529.         iPopulation = pPlayer.getRealPopulation()
  530.         if (pPlayer.calculateTotalCityHappiness() > 0):
  531.             iHappiness = int((1.0 * pPlayer.calculateTotalCityHappiness()) / (pPlayer.calculateTotalCityHappiness() + \
  532.                     pPlayer.calculateTotalCityUnhappiness()) * 100)
  533.         else:
  534.             iHappiness = 50
  535.  
  536.         if (pPlayer.calculateTotalCityHealthiness() > 0):
  537.             iHealth = int((1.0 * pPlayer.calculateTotalCityHealthiness()) / (pPlayer.calculateTotalCityHealthiness() + \
  538.                     pPlayer.calculateTotalCityUnhealthiness()) * 100)
  539.         else:
  540.             iHealth = 30
  541.         iImports = pPlayer.calculateTotalImports(YieldTypes.YIELD_COMMERCE)
  542.         iExports = pPlayer.calculateTotalExports(YieldTypes.YIELD_COMMERCE)
  543.  
  544.         if (iExports > 0):
  545.             if (iImports == 0):
  546.                 fImpExpRatio = 1 / (1.0 * iExports)
  547.             else:
  548.                 fImpExpRatio = iImports / (1.0 * iExports)
  549.         else:
  550.             # Make ratio 1 when both imports and exports are 0
  551.             if (iImports == 0):
  552.                 fImpExpRatio = 1.0
  553.             else:
  554.                 fImpExpRatio = 1.0 * iImports
  555.         
  556.         iEconomyRank = 0
  557.         iIndustryRank = 0
  558.         iAgricultureRank = 0
  559.         iMilitaryRank = 0
  560.         iLandAreaRank = 0
  561.         iPopulationRank = 0
  562.         iHappinessRank = 0
  563.         iHealthRank = 0
  564.         iImpExpRatioRank = 0
  565.         
  566.         fEconomyGameAverage = 0
  567.         fIndustryGameAverage = 0
  568.         fAgricultureGameAverage = 0
  569.         fMilitaryGameAverage = 0
  570.         fLandAreaGameAverage = 0
  571.         fPopulationGameAverage = 0
  572.         fHappinessGameAverage = 0
  573.         fHealthGameAverage = 0
  574.         fImportsGameAverage = 0
  575.         fExportsGameAverage = 0
  576.         fImpExpRatioGameAverage = 0
  577.         
  578.         # Lists of Player values - will be used to determine rank, strength and average per city
  579.         
  580.         aiGroupEconomy = []
  581.         aiGroupIndustry = []
  582.         aiGroupAgriculture = []
  583.         aiGroupMilitary = []
  584.         aiGroupLandArea = []
  585.         aiGroupPopulation = []
  586.         aiGroupHappiness = []
  587.         aiGroupHealth = []
  588.         aiGroupImports = []
  589.         aiGroupExports = []
  590.         afGroupImpExpRatio = []
  591.         
  592.         # Loop through all players to determine Rank and relative Strength
  593.         for iPlayerLoop in range(gc.getMAX_PLAYERS()):
  594.             
  595.             if (gc.getPlayer(iPlayerLoop).isAlive() and not gc.getPlayer(iPlayerLoop).isBarbarian()):
  596.                 
  597.                 iNumActivePlayers += 1
  598.                 
  599.                 pCurrPlayer = gc.getPlayer(iPlayerLoop)
  600.                 aiGroupEconomy.append(pCurrPlayer.calculateTotalYield(YieldTypes.YIELD_COMMERCE) - pCurrPlayer.calculateInflatedCosts())
  601.                 aiGroupIndustry.append(pCurrPlayer.calculateTotalYield(YieldTypes.YIELD_PRODUCTION))
  602.                 aiGroupAgriculture.append(pCurrPlayer.calculateTotalYield(YieldTypes.YIELD_FOOD))
  603.                 aiGroupMilitary.append(pCurrPlayer.getPower() * 1000)
  604.                 aiGroupLandArea.append(pCurrPlayer.getTotalLand() * 1000)
  605.                 aiGroupPopulation.append(pCurrPlayer.getRealPopulation())
  606.                 if (pCurrPlayer.calculateTotalCityHappiness() > 0):
  607.                     aiGroupHappiness.append(int((1.0 * pCurrPlayer.calculateTotalCityHappiness()) / (pCurrPlayer.calculateTotalCityHappiness() \
  608.                         + pCurrPlayer.calculateTotalCityUnhappiness()) * 100))
  609.                 else:
  610.                     aiGroupHappiness.append(50)
  611.                 
  612.                 if (pCurrPlayer.calculateTotalCityHealthiness() > 0):
  613.                     aiGroupHealth.append(int((1.0 * pCurrPlayer.calculateTotalCityHealthiness()) / (pCurrPlayer.calculateTotalCityHealthiness() \
  614.                         + pCurrPlayer.calculateTotalCityUnhealthiness()) * 100))
  615.                 else:
  616.                     aiGroupHealth.append(30)
  617.                 iTempImports = pCurrPlayer.calculateTotalImports(YieldTypes.YIELD_COMMERCE)
  618.                 aiGroupImports.append(iTempImports)
  619.                 iTempExports = pCurrPlayer.calculateTotalExports(YieldTypes.YIELD_COMMERCE)
  620.                 aiGroupExports.append(iTempExports)
  621.                 
  622.                 if (iTempExports > 0):
  623.                     if (iTempImports == 0):
  624.                         fGroupImpExpRatio = 1 / (1.0 * iTempExports)
  625.                         afGroupImpExpRatio.append(fGroupImpExpRatio)
  626.                     else:
  627.                         fGroupImpExpRatio = iTempImports / (1.0 * iTempExports)
  628.                         afGroupImpExpRatio.append(fGroupImpExpRatio)
  629.                 else:
  630.                     # Make ratio 1 when both imports and exports are 0
  631.                     if (iTempImports == 0):
  632.                         fGroupImpExpRatio = 1.0
  633.                         afGroupImpExpRatio.append(fGroupImpExpRatio)
  634.                     else:
  635.                         fGroupImpExpRatio = 1.0 * iTempImports
  636.                         afGroupImpExpRatio.append(fGroupImpExpRatio)
  637.  
  638.         aiGroupEconomy.sort()
  639.         aiGroupIndustry.sort()
  640.         aiGroupAgriculture.sort()
  641.         aiGroupMilitary.sort()
  642.         aiGroupLandArea.sort()
  643.         aiGroupPopulation.sort()
  644.         aiGroupHappiness.sort()
  645.         aiGroupHealth.sort()
  646.         aiGroupImports.sort()
  647.         aiGroupExports.sort()
  648.         afGroupImpExpRatio.sort()
  649.  
  650.         aiGroupEconomy.reverse()
  651.         aiGroupIndustry.reverse()
  652.         aiGroupAgriculture.reverse()
  653.         aiGroupMilitary.reverse()
  654.         aiGroupLandArea.reverse()
  655.         aiGroupPopulation.reverse()
  656.         aiGroupHappiness.reverse()
  657.         aiGroupHealth.reverse()
  658.         aiGroupImports.reverse()
  659.         aiGroupExports.reverse()
  660.         afGroupImpExpRatio.reverse()
  661.  
  662.         # Lists of player values are ordered from highest first to lowest, so determine Rank, Strength and World Average
  663.  
  664.         bEconomyFound = false
  665.         bIndustryFound = false
  666.         bAgricultureFound = false
  667.         bMilitaryFound = false
  668.         bLandAreaFound = false
  669.         bPopulationFound = false
  670.         bHappinessFound = false
  671.         bHealthFound = false
  672.         bImpExpRatioFound = false
  673.  
  674.         for i in range(len(aiGroupEconomy)):
  675.             
  676.             if (iEconomy == aiGroupEconomy[i] and bEconomyFound == false):
  677.                 iEconomyRank = i + 1
  678.                 bEconomyFound = true
  679.             else:
  680.                 fEconomyGameAverage += aiGroupEconomy[i]
  681.                 
  682.             if (iIndustry == aiGroupIndustry[i] and bIndustryFound == false):
  683.                 iIndustryRank = i + 1
  684.                 bIndustryFound = true
  685.             else:
  686.                 fIndustryGameAverage += aiGroupIndustry[i]
  687.                 
  688.             if (iAgriculture == aiGroupAgriculture[i] and bAgricultureFound == false):
  689.                 iAgricultureRank = i + 1
  690.                 bAgricultureFound = true
  691.             else:
  692.                 fAgricultureGameAverage += aiGroupAgriculture[i]
  693.                 
  694.             if (fMilitary == aiGroupMilitary[i] and bMilitaryFound == false):
  695.                 iMilitaryRank = i + 1
  696.                 bMilitaryFound = true
  697.             else:
  698.                 fMilitaryGameAverage += aiGroupMilitary[i]
  699.                 
  700.             if (iLandArea == aiGroupLandArea[i] and bLandAreaFound == false):
  701.                 iLandAreaRank = i + 1
  702.                 bLandAreaFound = true
  703.             else:
  704.                 fLandAreaGameAverage += aiGroupLandArea[i]
  705.                 
  706.             if (iPopulation == aiGroupPopulation[i] and bPopulationFound == false):
  707.                 iPopulationRank = i + 1
  708.                 bPopulationFound = true
  709.             else:
  710.                 fPopulationGameAverage += aiGroupPopulation[i]
  711.                 
  712.             if (iHappiness == aiGroupHappiness[i] and bHappinessFound == false):
  713.                 iHappinessRank = i + 1
  714.                 bHappinessFound = true
  715.             else:
  716.                 fHappinessGameAverage += aiGroupHappiness[i]
  717.                 
  718.             if (iHealth == aiGroupHealth[i] and bHealthFound == false):
  719.                 iHealthRank = i + 1
  720.                 bHealthFound = true
  721.             else:
  722.                 fHealthGameAverage += aiGroupHealth[i]
  723.                 
  724.             if (fImpExpRatio == afGroupImpExpRatio[i] and bImpExpRatioFound == false):
  725.                 iImpExpRatioRank = i + 1
  726.                 bImpExpRatioFound = true
  727.             else:
  728.                 fImportsGameAverage += aiGroupImports[i]
  729.                 fExportsGameAverage += aiGroupImports[i]
  730.             
  731.         if (iNumActivePlayers > 1):
  732.             fEconomyGameAverage = (1.0 * fEconomyGameAverage) / (iNumActivePlayers - 1)
  733.             fIndustryGameAverage = (1.0 * fIndustryGameAverage) / (iNumActivePlayers - 1)
  734.             fAgricultureGameAverage = (1.0 * fAgricultureGameAverage) / (iNumActivePlayers - 1)
  735.             fMilitaryGameAverage = int((1.0 * fMilitaryGameAverage) / (iNumActivePlayers - 1))
  736.             fLandAreaGameAverage = (1.0 * fLandAreaGameAverage) / (iNumActivePlayers - 1)
  737.             fPopulationGameAverage = int((1.0 * fPopulationGameAverage) / (iNumActivePlayers - 1))
  738.             fHappinessGameAverage = (1.0 * fHappinessGameAverage) / (iNumActivePlayers - 1)
  739.             fHealthGameAverage = (1.0 * fHealthGameAverage) / (iNumActivePlayers - 1)
  740.             fImportsGameAverage = (1.0 * fImportsGameAverage) / (iNumActivePlayers - 1)
  741.             fExportsGameAverage = (1.0 * fExportsGameAverage) / (iNumActivePlayers - 1)
  742.  
  743.         ######## TEXT ########
  744.  
  745.         screen = self.getScreen()
  746.  
  747.         # Create Table
  748.         szTable = self.getNextWidgetName()
  749.         screen.addTableControlGFC(szTable, 4, self.X_CHART, self.Y_CHART, self.W_CHART, self.H_CHART, true, true, 32,32, TableStyles.TABLE_STYLE_STANDARD)
  750.         screen.setTableColumnHeader(szTable, 0, self.TEXT_DEMOGRAPHICS_SMALL, 190) # Total graph width is 530
  751.         screen.setTableColumnHeader(szTable, 1, self.TEXT_VALUE, 135)
  752.         screen.setTableColumnHeader(szTable, 2, self.TEXT_AVERAGE, 135)
  753.         screen.setTableColumnHeader(szTable, 3, self.TEXT_RANK, 70)
  754.         
  755.         for i in range(18 + 5): # 18 normal items + 5 lines for spacing
  756.             screen.appendTableRow(szTable)
  757.         iNumRows = screen.getTableNumRows(szTable)
  758.         iRow = iNumRows - 1
  759.         iCol = 0
  760.         screen.setTableText(szTable, iCol, 0, self.TEXT_ECONOMY, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  761.         screen.setTableText(szTable, iCol, 1, self.TEXT_ECONOMY_MEASURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  762.         screen.setTableText(szTable, iCol, 3, self.TEXT_INDUSTRY, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  763.         screen.setTableText(szTable, iCol, 4, self.TEXT_INDUSTRY_MEASURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  764.         screen.setTableText(szTable, iCol, 6, self.TEXT_AGRICULTURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  765.         screen.setTableText(szTable, iCol, 7, self.TEXT_AGRICULTURE_MEASURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  766.         screen.setTableText(szTable, iCol, 9, self.TEXT_MILITARY, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  767.         screen.setTableText(szTable, iCol, 11, self.TEXT_LAND_AREA, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  768.         screen.setTableText(szTable, iCol, 12, self.TEXT_LAND_AREA_MEASURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  769.         screen.setTableText(szTable, iCol, 14, self.TEXT_POPULATION, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  770.         screen.setTableText(szTable, iCol, 16, self.TEXT_HAPPINESS, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  771.         screen.setTableText(szTable, iCol, 18, self.TEXT_HEALTH, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  772.         screen.setTableText(szTable, iCol, 19, self.TEXT_HEALTH_MEASURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  773.         screen.setTableText(szTable, iCol, 21, self.TEXT_IMP_EXP, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  774.         screen.setTableText(szTable, iCol, 22, self.TEXT_IMP_EXP_MEASURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  775.  
  776.         iCol = 1
  777.         screen.setTableText(szTable, iCol, 0, str(iEconomy), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  778.         screen.setTableText(szTable, iCol, 3, str(iIndustry), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  779.         screen.setTableText(szTable, iCol, 6, str(iAgriculture), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  780.         screen.setTableText(szTable, iCol, 9, str(int(fMilitary)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  781.         screen.setTableText(szTable, iCol, 11, str(iLandArea), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  782.         screen.setTableText(szTable, iCol, 14, str(iPopulation), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  783.         screen.setTableText(szTable, iCol, 16, str(iHappiness) + self.TEXT_HAPPINESS_MEASURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  784.         screen.setTableText(szTable, iCol, 18, str(iHealth), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  785.         screen.setTableText(szTable, iCol, 21, str(iImports) + "/" + str(iExports), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  786.         
  787.         iCol = 2
  788.         screen.setTableText(szTable, iCol, 0, str(int(fEconomyGameAverage)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  789.         screen.setTableText(szTable, iCol, 3, str(int(fIndustryGameAverage)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  790.         screen.setTableText(szTable, iCol, 6, str(int(fAgricultureGameAverage)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  791.         screen.setTableText(szTable, iCol, 9, str(int(fMilitaryGameAverage)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  792.         screen.setTableText(szTable, iCol, 11, str(int(fLandAreaGameAverage)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  793.         screen.setTableText(szTable, iCol, 14, str(int(fPopulationGameAverage)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  794.         screen.setTableText(szTable, iCol, 16, str(int(fHappinessGameAverage)) + self.TEXT_HAPPINESS_MEASURE, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  795.         screen.setTableText(szTable, iCol, 18, str(int(fHealthGameAverage)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  796.         screen.setTableText(szTable, iCol, 21, str(int(fImportsGameAverage)) + "/" + str(int(fExportsGameAverage)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  797.         
  798.         iCol = 3
  799.         screen.setTableText(szTable, iCol, 0, str(iEconomyRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  800.         screen.setTableText(szTable, iCol, 3, str(iIndustryRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  801.         screen.setTableText(szTable, iCol, 6, str(iAgricultureRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  802.         screen.setTableText(szTable, iCol, 9, str(iMilitaryRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  803.         screen.setTableText(szTable, iCol, 11, str(iLandAreaRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  804.         screen.setTableText(szTable, iCol, 14, str(iPopulationRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  805.         screen.setTableText(szTable, iCol, 16, str(iHappinessRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  806.         screen.setTableText(szTable, iCol, 18, str(iHealthRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  807.         screen.setTableText(szTable, iCol, 21, str(iImpExpRatioRank), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  808.  
  809.         return
  810.  
  811.     def drawGraph(self):
  812.         
  813.         screen = self.getScreen()
  814.         
  815.         print("Drawing Graph")
  816.         
  817.         szTextPanel = self.getNextWidgetName()
  818.         screen.addPanel( szTextPanel, "", "", true, true,
  819.             self.X_GRAPH, self.Y_GRAPH, self.W_GRAPH, self.H_GRAPH, PanelStyles.PANEL_STYLE_DAWNBOTTOM )
  820.         
  821.         ######## GRAPH ########
  822.         
  823.         self.iNumPreDemoChartWidgets = self.nWidgetCount
  824.         
  825.         # Create Graph itself
  826.         self.szGraphWidget = self.getNextWidgetName()
  827.         screen.addGraphWidget(self.szGraphWidget, "Background", ArtFileMgr.getInterfaceArtInfo("POPUPS_BACKGROUND_TRANSPARENT").getPath(),
  828.                       self.X_GRAPH, self.Y_GRAPH, self.Z_CONTROLS, self.W_GRAPH, self.H_GRAPH, WidgetTypes.WIDGET_GENERAL, -1, -1)
  829.  
  830.         screen.setGraphLabelX(self.szGraphWidget, localText.getText("TXT_KEY_REPLAY_SCREEN_TURNS", ()))
  831.         screen.setGraphLabelY(self.szGraphWidget, self.TEXT_SCORE)
  832.         
  833.         return
  834.         
  835.     def drawPermanentGraphWidgets(self):
  836.         
  837.         screen = self.getScreen()
  838.         
  839.         # Dropdown Box
  840.         self.szGraphDropdownWidget = self.getNextWidgetName()
  841.         screen.addDropDownBoxGFC(self.szGraphDropdownWidget, self.X_DEMO_DROPDOWN, self.Y_DEMO_DROPDOWN, self.W_DEMO_DROPDOWN, WidgetTypes.WIDGET_GENERAL, -1, -1, FontTypes.GAME_FONT)
  842.         screen.addPullDownString(self.szGraphDropdownWidget, self.TEXT_SCORE, 0, 0, False )
  843.         screen.addPullDownString(self.szGraphDropdownWidget, self.TEXT_ECONOMY, 1, 1, False )
  844.         screen.addPullDownString(self.szGraphDropdownWidget, self.TEXT_INDUSTRY, 2, 2, False )
  845.         screen.addPullDownString(self.szGraphDropdownWidget, self.TEXT_AGRICULTURE, 3, 3, False )
  846.         screen.addPullDownString(self.szGraphDropdownWidget, self.TEXT_POWER, 4, 4, False )
  847.         screen.addPullDownString(self.szGraphDropdownWidget, self.TEXT_CULTURE, 5, 5, False )
  848.         
  849.         iCounter = 0
  850.         
  851.         self.aiDropdownPlayerIDs = []
  852.         
  853.         # Show Players Dropdown
  854.         self.szCivsDropdownWidget = self.getNextWidgetName()
  855.         screen.addDropDownBoxGFC(self.szCivsDropdownWidget, self.X_DEMO_DROPDOWN + self.W_DEMO_DROPDOWN + 8, self.Y_DEMO_DROPDOWN, self.W_DEMO_DROPDOWN, WidgetTypes.WIDGET_GENERAL, -1, -1, FontTypes.GAME_FONT)
  856.         if (self.iNumPlayersMet > 1):
  857.             screen.addPullDownString(self.szCivsDropdownWidget, localText.getText("TXT_KEY_SHOW_ALL_PLAYERS", ()), iCounter, iCounter, False )
  858.             self.iShowingPlayer = 666
  859.             self.aiDropdownPlayerIDs.append(666)
  860.             
  861.         else:
  862.             self.iShowingPlayer = self.iActivePlayer
  863.             
  864.         # Add active player
  865.         szCivName = gc.getPlayer(self.iActivePlayer).getCivilizationShortDescription(0)
  866.         screen.addPullDownString(self.szCivsDropdownWidget, szCivName, iCounter, iCounter, False )
  867.         self.aiDropdownPlayerIDs.append(self.iActivePlayer)
  868.         
  869.         for iPlayerIDLoop in self.aiPlayersMet:
  870.             if (iPlayerIDLoop != self.iActivePlayer):
  871.                 self.aiDropdownPlayerIDs.append(iPlayerIDLoop)
  872.                 szCivName = gc.getPlayer(iPlayerIDLoop).getCivilizationShortDescription(0)
  873.                 screen.addPullDownString(self.szCivsDropdownWidget, szCivName, iCounter, iCounter, False )
  874.                 iCounter += 1
  875.                 
  876. #        print("Player Dropdown List:")
  877.         print(self.aiDropdownPlayerIDs)
  878.                 
  879.     def updateGraph(self):
  880.  
  881.         screen = self.getScreen()
  882.         
  883.         print("Updating Graph")
  884.  
  885.         self.iTurn = CyGame().getGameTurn()
  886.         iTurn = CyGame().getGameTurn()
  887.         
  888.         iLoopTurn = CyGame().getStartTurn()
  889. #        print("StartTurn: %d" %(CyGame().getStartTurn()))
  890.         
  891.         # If player has met someone else then allow him the different graph modes
  892.         if (self.iNumPlayersMet > 1):
  893.             # Allow "Show All Buttons" CheckBox to be used
  894.             self.bAbleToShowAllPlayers = true
  895.         
  896. #        print("iDemoGraphTabID: %s" %(str(self.iDemoGraphTabID)))
  897.                 
  898.         # Graph should only show active player's progression if he has yet to meet any other civs
  899.         # Or if player has elected not to show all players
  900.         if (self.iNumPlayersMet == 1 or self.iShowingPlayer != 666):
  901.             # Add layers and set colors
  902.             if (self.iDemoGraphTabID == self.iScoreTabID):
  903.                 screen.setGraphLabelY(self.szGraphWidget, self.TEXT_SCORE)
  904.                 if (self.iNumPlayersMet == 1 or self.iShowingPlayer != 666):
  905.                     screen.addGraphLayer(self.szGraphWidget, 0, gc.getInfoTypeForString("COLOR_WHITE"))
  906.             elif (self.iDemoGraphTabID == self.iEconomyTabID):
  907.                 screen.setGraphLabelY(self.szGraphWidget, self.TEXT_ECONOMY)
  908.                 if (self.iNumPlayersMet == 1 or self.iShowingPlayer != 666):
  909.                     screen.addGraphLayer(self.szGraphWidget, 0, gc.getInfoTypeForString("COLOR_YELLOW"))
  910.             elif (self.iDemoGraphTabID == self.iIndustryTabID):
  911.                 screen.setGraphLabelY(self.szGraphWidget, self.TEXT_INDUSTRY)
  912.                 if (self.iNumPlayersMet == 1 or self.iShowingPlayer != 666):
  913.                     screen.addGraphLayer(self.szGraphWidget, 0, gc.getInfoTypeForString("COLOR_BLUE"))
  914.             elif (self.iDemoGraphTabID == self.iAgricultureTabID):
  915.                 screen.setGraphLabelY(self.szGraphWidget, self.TEXT_AGRICULTURE)
  916.                 if (self.iNumPlayersMet == 1 or self.iShowingPlayer != 666):
  917.                     screen.addGraphLayer(self.szGraphWidget, 0, gc.getInfoTypeForString("COLOR_GREEN"))
  918.             elif (self.iDemoGraphTabID == self.iPowerTabID):
  919.                 screen.setGraphLabelY(self.szGraphWidget, self.TEXT_POWER)
  920.                 if (self.iNumPlayersMet == 1 or self.iShowingPlayer != 666):
  921.                     screen.addGraphLayer(self.szGraphWidget, 0, gc.getInfoTypeForString("COLOR_RED"))
  922.             elif (self.iDemoGraphTabID == self.iCultureTabID):
  923.                 screen.setGraphLabelY(self.szGraphWidget, self.TEXT_CULTURE)
  924.                 if (self.iNumPlayersMet == 1 or self.iShowingPlayer != 666):
  925.                     screen.addGraphLayer(self.szGraphWidget, 0, gc.getInfoTypeForString("COLOR_PLAYER_PURPLE"))
  926. #            print("Drawing graph for player %s" %(str(self.iShowingPlayer)))
  927.             screen.addGraphData(self.szGraphWidget, 0, 0, 0)
  928.             while (iLoopTurn <= self.iTurn - 1):
  929.                 if (self.iDemoGraphTabID == self.iScoreTabID):
  930.                     fValue = (1.0 * gc.getPlayer(self.iShowingPlayer).getScoreHistory(iLoopTurn))
  931.                 elif (self.iDemoGraphTabID == self.iEconomyTabID):
  932.                     fValue = (1.0 * gc.getPlayer(self.iShowingPlayer).getEconomyHistory(iLoopTurn))
  933.                 elif (self.iDemoGraphTabID == self.iIndustryTabID):
  934.                     fValue = (1.0 * gc.getPlayer(self.iShowingPlayer).getIndustryHistory(iLoopTurn))
  935.                 elif (self.iDemoGraphTabID == self.iAgricultureTabID):
  936.                     fValue = (1.0 * gc.getPlayer(self.iShowingPlayer).getAgricultureHistory(iLoopTurn))
  937.                 elif (self.iDemoGraphTabID == self.iPowerTabID):
  938.                     fValue = (1.0 * gc.getPlayer(self.iShowingPlayer).getPowerHistory(iLoopTurn))
  939.                 elif (self.iDemoGraphTabID == self.iCultureTabID):
  940.                     fValue = (1.0 * gc.getPlayer(self.iShowingPlayer).getCultureHistory(iLoopTurn))
  941.                     
  942.                 screen.addGraphData(self.szGraphWidget, iLoopTurn + 1 - CyGame().getStartTurn(), fValue, 0)
  943.                 iLoopTurn += 1
  944.                 
  945.             # Determine max y value for graph
  946.             for iLoopPlayer in self.aiPlayersMet:
  947.                 iLoopTurn = CyGame().getStartTurn()
  948.                 while (iLoopTurn <= self.iTurn - 1):
  949.                     if (self.iDemoGraphTabID == self.iScoreTabID):
  950.                         fValue = (1.0 * gc.getPlayer(iLoopPlayer).getScoreHistory(iLoopTurn))
  951.                     elif (self.iDemoGraphTabID == self.iEconomyTabID):
  952.                         fValue = (1.0 * gc.getPlayer(iLoopPlayer).getEconomyHistory(iLoopTurn))
  953.                     elif (self.iDemoGraphTabID == self.iIndustryTabID):
  954.                         fValue = (1.0 * gc.getPlayer(iLoopPlayer).getIndustryHistory(iLoopTurn))
  955.                     elif (self.iDemoGraphTabID == self.iAgricultureTabID):
  956.                         fValue = (1.0 * gc.getPlayer(iLoopPlayer).getAgricultureHistory(iLoopTurn))
  957.                     elif (self.iDemoGraphTabID == self.iPowerTabID):
  958.                         fValue = (1.0 * gc.getPlayer(iLoopPlayer).getPowerHistory(iLoopTurn))
  959.                     elif (self.iDemoGraphTabID == self.iCultureTabID):
  960.                         fValue = (1.0 * gc.getPlayer(iLoopPlayer).getCultureHistory(iLoopTurn))
  961.                         
  962.                     if (fValue > self.fMaxDemoStatValue):
  963.                         self.fMaxDemoStatValue = fValue
  964.                     iLoopTurn += 1
  965.                 
  966.             screen.setGraphYDataRange(self.szGraphWidget, 0.0, self.fMaxDemoStatValue)
  967.                 
  968.         # We have other players to display
  969.         else:
  970.             iCounter = 0
  971.             # Add graph layers and set them to the player color
  972.             for iPlayerLoop in self.aiPlayersMet:
  973.                 pLoopPlayer = gc.getPlayer(iPlayerLoop)
  974.                 iPlayerColor = gc.getPlayerColorInfo(pLoopPlayer.getPlayerColor()).getColorTypePrimary()
  975.                 screen.addGraphLayer(self.szGraphWidget, iCounter, iPlayerColor)
  976.                 iCounter += 1
  977.             
  978.             screen.setGraphYDataRange(self.szGraphWidget, 0.0, 1.0)
  979.             
  980.             # Add first turn (which isn't stored)
  981.             # Determine fraction for each player
  982.             iTotalValue = 0
  983.             iBaseline = 0
  984.             iCounter = 0
  985.             iBaseline = 0
  986.             # Determine total
  987.             for iLoopPlayer in self.aiPlayersMet:
  988.                 iTotalValue += 1.0
  989.             for iLoopPlayer in self.aiPlayersMet:
  990.                 iValue = 1.0
  991.                 iBaseline += iValue
  992.                 if (iTotalValue > 0):
  993.                     fGraphHeight = (iValue + iTotalValue - iBaseline) / (1.0 * iTotalValue)
  994.                 else:
  995.                     fGraphHeight = 1 / (1.0 * self.iNumPlayersMet)
  996. #                print("Layer %d - X: %d, Y: %f, iValue: %d, iBaseline: %d, iTotal: %d" %(iCounter, iLoopTurn, fGraphHeight, iValue, iBaseline, iTotalValue))
  997.                 screen.addGraphData(self.szGraphWidget, 0, fGraphHeight, iCounter)    # Counter is the (player num) Layer
  998.                 iCounter += 1
  999.             
  1000.             while (iLoopTurn <= self.iTurn - 1):
  1001.                 iTotalValue = 0
  1002.                 iBaseline = 0
  1003.                 iCounter = 0
  1004. #                print("iLoopTurn: %d" %(iLoopTurn))
  1005.                 # Score
  1006.                 if (self.iDemoGraphTabID == self.iScoreTabID):
  1007.                     # Determine total
  1008.                     for iLoopPlayer in self.aiPlayersMet:
  1009.                         iTotalValue += gc.getPlayer(iLoopPlayer).getScoreHistory(iLoopTurn)
  1010.                         
  1011.                     # Determine fraction for each player
  1012.                     iBaseline = 0
  1013.                     for iLoopPlayer in self.aiPlayersMet:
  1014.                         iValue = (1.0 * gc.getPlayer(iLoopPlayer).getScoreHistory(iLoopTurn))
  1015.                         iBaseline += iValue
  1016.                         if (iTotalValue > 0):
  1017.                             fGraphHeight = (iValue + iTotalValue - iBaseline) / (1.0 * iTotalValue)
  1018.                         else:
  1019.                             fGraphHeight = 1 / (1.0 * self.iNumPlayersMet)
  1020. #                        print("Layer %d - X: %d, Y: %f, iValue: %d, iBaseline: %d, iTotal: %d" %(iCounter, iLoopTurn + 1 - CyGame().getStartTurn(), fGraphHeight, iValue, iBaseline, iTotalValue))
  1021.                         screen.addGraphData(self.szGraphWidget, iLoopTurn + 1 - CyGame().getStartTurn(), fGraphHeight, iCounter)    # Counter is the (player num) Layer
  1022.                         iCounter += 1
  1023.                 
  1024.                 # Economy
  1025.                 elif (self.iDemoGraphTabID == self.iEconomyTabID):
  1026.                     # Determine total
  1027.                     for iLoopPlayer in self.aiPlayersMet:
  1028.                         iTotalValue += gc.getPlayer(iLoopPlayer).getEconomyHistory(iLoopTurn)
  1029.                         
  1030.                     # Determine fraction for each player
  1031.                     iBaseline = 0
  1032.                     for iLoopPlayer in self.aiPlayersMet:
  1033.                         iValue = (1.0 * gc.getPlayer(iLoopPlayer).getEconomyHistory(iLoopTurn))
  1034.                         iBaseline += iValue
  1035.                         if (iTotalValue > 0):
  1036.                             fGraphHeight = (iValue + iTotalValue - iBaseline) / (1.0 * iTotalValue)
  1037.                         else:
  1038.                             fGraphHeight = 1 / (1.0 * self.iNumPlayersMet)
  1039.                         screen.addGraphData(self.szGraphWidget, iLoopTurn + 1 - CyGame().getStartTurn(), fGraphHeight, iCounter)    # Counter is the (player num) Layer
  1040.                         iCounter += 1
  1041.                         
  1042.                 # Industry
  1043.                 elif (self.iDemoGraphTabID == self.iIndustryTabID):
  1044.                     # Determine total
  1045.                     for iLoopPlayer in self.aiPlayersMet:
  1046.                         iTotalValue += gc.getPlayer(iLoopPlayer).getIndustryHistory(iLoopTurn)
  1047.                         
  1048.                     # Determine fraction for each player
  1049.                     iBaseline = 0
  1050.                     for iLoopPlayer in self.aiPlayersMet:
  1051.                         iValue = (1.0 * gc.getPlayer(iLoopPlayer).getIndustryHistory(iLoopTurn))
  1052.                         iBaseline += iValue
  1053.                         if (iTotalValue > 0):
  1054.                             fGraphHeight = (iValue + iTotalValue - iBaseline) / (1.0 * iTotalValue)
  1055.                         else:
  1056.                             fGraphHeight = 1 / (1.0 * self.iNumPlayersMet)
  1057.                         screen.addGraphData(self.szGraphWidget, iLoopTurn + 1 - CyGame().getStartTurn(), fGraphHeight, iCounter)    # Counter is the (player num) Layer
  1058.                         iCounter += 1
  1059.                         
  1060.                 # Agriculture
  1061.                 elif (self.iDemoGraphTabID == self.iAgricultureTabID):
  1062.                     # Determine total
  1063.                     for iLoopPlayer in self.aiPlayersMet:
  1064.                         iTotalValue += gc.getPlayer(iLoopPlayer).getAgricultureHistory(iLoopTurn)
  1065.                         
  1066.                     # Determine fraction for each player
  1067.                     iBaseline = 0
  1068.                     for iLoopPlayer in self.aiPlayersMet:
  1069.                         iValue = (1.0 * gc.getPlayer(iLoopPlayer).getAgricultureHistory(iLoopTurn))
  1070.                         iBaseline += iValue
  1071.                         if (iTotalValue > 0):
  1072.                             fGraphHeight = (iValue + iTotalValue - iBaseline) / (1.0 * iTotalValue)
  1073.                         else:
  1074.                             fGraphHeight = 1 / (1.0 * self.iNumPlayersMet)
  1075.                         screen.addGraphData(self.szGraphWidget, iLoopTurn + 1 - CyGame().getStartTurn(), fGraphHeight, iCounter)    # Counter is the (player num) Layer
  1076.                         iCounter += 1
  1077.                         
  1078.                 # Power
  1079.                 elif (self.iDemoGraphTabID == self.iPowerTabID):
  1080.                     # Determine total
  1081.                     for iLoopPlayer in self.aiPlayersMet:
  1082.                         iTotalValue += gc.getPlayer(iLoopPlayer).getPowerHistory(iLoopTurn)
  1083.                         
  1084.                     # Determine fraction for each player
  1085.                     iBaseline = 0
  1086.                     for iLoopPlayer in self.aiPlayersMet:
  1087.                         iValue = (1.0 * gc.getPlayer(iLoopPlayer).getPowerHistory(iLoopTurn))
  1088.                         iBaseline += iValue
  1089.                         if (iTotalValue > 0):
  1090.                             fGraphHeight = (iValue + iTotalValue - iBaseline) / (1.0 * iTotalValue)
  1091.                         else:
  1092.                             fGraphHeight = 1 / (1.0 * self.iNumPlayersMet)
  1093.                         screen.addGraphData(self.szGraphWidget, iLoopTurn + 1 - CyGame().getStartTurn(), fGraphHeight, iCounter)    # Counter is the (player num) Layer
  1094.                         iCounter += 1
  1095.                         
  1096.                 # Culture
  1097.                 elif (self.iDemoGraphTabID == self.iCultureTabID):
  1098.                     # Determine total
  1099.                     for iLoopPlayer in self.aiPlayersMet:
  1100.                         iTotalValue += gc.getPlayer(iLoopPlayer).getCultureHistory(iLoopTurn)
  1101.                         
  1102.                     # Determine fraction for each player
  1103.                     iBaseline = 0
  1104.                     for iLoopPlayer in self.aiPlayersMet:
  1105.                         iValue = (1.0 * gc.getPlayer(iLoopPlayer).getCultureHistory(iLoopTurn))
  1106.                         iBaseline += iValue
  1107.                         if (iTotalValue > 0):
  1108.                             fGraphHeight = (iValue + iTotalValue - iBaseline) / (1.0 * iTotalValue)
  1109.                         else:
  1110.                             fGraphHeight = 1 / (1.0 * self.iNumPlayersMet)
  1111.                         screen.addGraphData(self.szGraphWidget, iLoopTurn + 1 - CyGame().getStartTurn(), fGraphHeight, iCounter)    # Counter is the (player num) Layer
  1112.                         iCounter += 1
  1113.                         
  1114.                 iLoopTurn += 1
  1115.         
  1116. #############################################################################################################
  1117. ################################################## TOP CITIES ###############################################
  1118. #############################################################################################################
  1119.         
  1120.     def drawTopCitiesTab(self):
  1121.         
  1122.         screen = self.getScreen()
  1123.         
  1124.         # Background Panes
  1125.         self.szLeftPaneWidget = self.getNextWidgetName()
  1126.         screen.addPanel( self.szLeftPaneWidget, "", "", true, true,
  1127.             self.X_LEFT_PANE, self.Y_LEFT_PANE, self.W_LEFT_PANE, self.H_LEFT_PANE, PanelStyles.PANEL_STYLE_MAIN )#PanelStyles.PANEL_STYLE_DAWNTOP )
  1128.         
  1129.         self.drawTopCities()
  1130.         self.drawWondersTab()
  1131.     
  1132.     def drawTopCities(self):
  1133.         
  1134.         self.calculateTopCities()
  1135.         self.determineCityData()
  1136.         
  1137.         screen = self.getScreen()
  1138.         
  1139.         self.szCityNameWidgets = []
  1140.         self.szCityDescWidgets = []
  1141.         self.szCityAnimWidgets = []
  1142.         
  1143.         for iWidgetLoop in range(self.iNumCities):
  1144.             
  1145.             szTextPanel = self.getNextWidgetName()
  1146.             screen.addPanel( szTextPanel, "", "", false, true,
  1147.                 self.X_COL_1_CITIES_DESC, self.Y_ROWS_CITIES[iWidgetLoop] + self.Y_CITIES_DESC_BUFFER, self.W_CITIES_DESC, self.H_CITIES_DESC, PanelStyles.PANEL_STYLE_DAWNTOP )
  1148.             self.szCityNameWidgets.append(self.getNextWidgetName())
  1149. #            szProjectDesc = u"<font=3b>" + pProjectInfo.getDescription().upper() + u"</font>"
  1150.             szCityDesc = u"<font=4b>" + str(self.iCitySizes[iWidgetLoop]) + u"</font>" + " - " + u"<font=3b>" + self.szCityNames[iWidgetLoop] + u"</font>" + "\n"
  1151.             szCityDesc += self.szCityDescs[iWidgetLoop]
  1152.             screen.addMultilineText(self.szCityNameWidgets[iWidgetLoop], szCityDesc,
  1153.                 self.X_COL_1_CITIES_DESC + 6, self.Y_ROWS_CITIES[iWidgetLoop] + self.Y_CITIES_DESC_BUFFER + 3, self.W_CITIES_DESC - 6, self.H_CITIES_DESC - 6, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1154. #            screen.attachMultilineText( szTextPanel, self.szCityNameWidgets[iWidgetLoop], str(self.iCitySizes[iWidgetLoop]) + " - " + self.szCityNames[iWidgetLoop] + "\n" + self.szCityDescs[iWidgetLoop], WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1155.             
  1156.             iCityX = self.aaCitiesXY[iWidgetLoop][0]
  1157.             iCityY = self.aaCitiesXY[iWidgetLoop][1]
  1158.             pPlot = CyMap().plot(iCityX, iCityY)
  1159.             pCity = pPlot.getPlotCity()
  1160.             
  1161.             iDistance = 200 + (pCity.getPopulation() * 5)
  1162.             if (iDistance > 350):
  1163.                 iDistance = 350
  1164.             
  1165.             self.szCityAnimWidgets.append(self.getNextWidgetName())
  1166.             screen.addPlotGraphicGFC(self.szCityAnimWidgets[iWidgetLoop], self.X_CITY_ANIMATION, self.Y_ROWS_CITIES[iWidgetLoop] + self.Y_CITY_ANIMATION_BUFFER - self.H_CITY_ANIMATION / 2, self.W_CITY_ANIMATION, self.H_CITY_ANIMATION, pPlot, iDistance, false, WidgetTypes.WIDGET_GENERAL, -1, -1)
  1167.             
  1168.         # Draw Wonder icons
  1169.         self.drawCityWonderIcons();
  1170.         
  1171.         return
  1172.         
  1173.     def drawCityWonderIcons(self):
  1174.         
  1175.         screen = self.getScreen()
  1176.         
  1177.         aaiTopCitiesWonders = []
  1178.         aiTopCitiesNumWonders = []
  1179.         for i in range(self.iNumCities):
  1180.             aaiTopCitiesWonders.append(0)
  1181.             aiTopCitiesNumWonders.append(0)
  1182.         
  1183.         # Loop through top cities and determine if they have any wonders to display
  1184.         for iCityLoop in range(self.iNumCities):
  1185.             
  1186.             if (self.pCityPointers[iCityLoop]):
  1187.                 
  1188.                 pCity = self.pCityPointers[iCityLoop]
  1189.                 
  1190.                 aiTempWondersList = []
  1191.                 
  1192.                 # Loop through buildings
  1193.                 
  1194.                 for iBuildingLoop in range(gc.getNumBuildingInfos()):
  1195.                     
  1196.                     pBuilding = gc.getBuildingInfo(iBuildingLoop)
  1197.                     
  1198.                     # If this building is a wonder...
  1199.                     if (isWorldWonderClass(gc.getBuildingInfo(iBuildingLoop).getBuildingClassType())):
  1200.                         
  1201.                         if (pCity.hasBuilding(iBuildingLoop)):
  1202.                             
  1203.                             aiTempWondersList.append(iBuildingLoop)
  1204.                             aiTopCitiesNumWonders[iCityLoop] += 1
  1205.                             
  1206.                 aaiTopCitiesWonders[iCityLoop] = aiTempWondersList
  1207.             
  1208.         # Create Scrollable areas under each city
  1209.         self.szCityWonderScrollArea = []
  1210.         for iCityLoop in range (self.iNumCities):
  1211.             
  1212.             self.szCityWonderScrollArea.append(self.getNextWidgetName())
  1213.             
  1214.             #iScollAreaY = (self.Y_CITIES_BUFFER * iCityLoop) + 90 + self.Y_CITIES_WONDER_BUFFER
  1215.             
  1216.             szIconPanel = self.szCityWonderScrollArea[iCityLoop]
  1217.             screen.addPanel( szIconPanel, "", "", false, true,
  1218.                 self.X_COL_1_CITIES_DESC, self.Y_ROWS_CITIES[iCityLoop] + self.Y_CITIES_WONDER_BUFFER + self.Y_CITIES_DESC_BUFFER, self.W_CITIES_DESC, self.H_CITIES_DESC, PanelStyles.PANEL_STYLE_DAWNTOP )
  1219.             
  1220.             # Now place the wonder buttons
  1221.             for iWonderLoop in range(aiTopCitiesNumWonders[iCityLoop]):
  1222.                 
  1223.                 iBuildingID = aaiTopCitiesWonders[iCityLoop][iWonderLoop]
  1224.                 screen.attachImageButton( szIconPanel, "", gc.getBuildingInfo(iBuildingID).getButton(),
  1225.                     GenericButtonSizes.BUTTON_SIZE_46, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, iBuildingID, -1, False )
  1226.             
  1227.     def calculateTopCities(self):
  1228.         
  1229.         # Calculate the top 5 cities
  1230.  
  1231.         for iPlayerLoop in range(gc.getMAX_PLAYERS()):
  1232.             
  1233.             apCityList = PyPlayer(iPlayerLoop).getCityList()
  1234.             
  1235.             for pCity in apCityList:
  1236.                 
  1237.                 iTotalCityValue = ((pCity.getCulture() / 5) + (pCity.getFoodRate() + pCity.getProductionRate() \
  1238.                     + pCity.calculateGoldRate())) * pCity.getPopulation()
  1239.                 
  1240.                 for iRankLoop in range(5):
  1241.                     
  1242.                     if (iTotalCityValue > self.iCityValues[iRankLoop] and not pCity.isBarbarian()):
  1243.                         
  1244.                         self.addCityToList(iRankLoop, pCity, iTotalCityValue)
  1245.                         
  1246.                         break
  1247.             
  1248.     # Recursive
  1249.     def addCityToList(self, iRank, pCity, iTotalCityValue):
  1250.         
  1251.         if (iRank > 4):
  1252.             
  1253.             return
  1254.             
  1255.         else:
  1256.             pTempCity = self.pCityPointers[iRank]
  1257.             
  1258.             # Verify a city actually exists at this rank
  1259.             if (pTempCity):
  1260.                 
  1261.                 iTempCityValue = self.iCityValues[iRank]
  1262.                 
  1263.                 self.addCityToList(iRank+1, pTempCity, iTempCityValue)
  1264.                 
  1265.                 self.pCityPointers[iRank] = pCity
  1266.                 self.iCityValues[iRank] = iTotalCityValue
  1267.                 
  1268.             else:
  1269.                 self.pCityPointers[iRank] = pCity
  1270.                 self.iCityValues[iRank] = iTotalCityValue
  1271.                 
  1272.                 return
  1273.             
  1274.     def determineCityData(self):
  1275.         
  1276.         self.iNumCities = 0
  1277.         
  1278.         for iRankLoop in range(5):
  1279.             
  1280.             pCity = self.pCityPointers[iRankLoop]
  1281.             
  1282.             # If this city exists and has data we can use
  1283.             if (pCity):
  1284.                 
  1285.                 pPlayer = gc.getPlayer(pCity.getOwner())
  1286.                 
  1287.                 iTurnYear = CyGame().getTurnYear(pCity.getGameTurnFounded())
  1288.                 
  1289.                 if (iTurnYear < 0):
  1290.                     szTurnFounded = localText.getText("TXT_KEY_TIME_BC", (-iTurnYear,))#"%d %s" %(-iTurnYear, self.TEXT_BC)
  1291.                 else:
  1292.                     szTurnFounded = localText.getText("TXT_KEY_TIME_AD", (iTurnYear,))#"%d %s" %(iTurnYear, self.TEXT_AD)
  1293.                 
  1294.                 self.szCityNames[iRankLoop] = pCity.getName().upper()
  1295.                 self.iCitySizes[iRankLoop] = pCity.getPopulation()
  1296.                 self.szCityDescs[iRankLoop] = ("%s, %s" %(pPlayer.getCivilizationAdjective(0), localText.getText("TXT_KEY_MISC_FOUNDED_IN", (szTurnFounded,))))
  1297.                 self.aaCitiesXY[iRankLoop] = [pCity.getX(), pCity.getY()]
  1298.                 
  1299.                 self.iNumCities += 1
  1300.             else:
  1301.                 
  1302.                 self.szCityNames[iRankLoop] = ""
  1303.                 self.iCitySizes[iRankLoop] = -1
  1304.                 self.szCityDescs[iRankLoop] = ""
  1305.                 self.aaCitiesXY[iRankLoop] = [-1, -1]
  1306.                 
  1307.         return
  1308.         
  1309. #############################################################################################################
  1310. ################################################### WONDERS #################################################
  1311. #############################################################################################################
  1312.         
  1313.     def drawWondersTab(self):
  1314.         
  1315.         screen = self.getScreen()
  1316.         
  1317.         self.szRightPaneWidget = self.getNextWidgetName()
  1318.         screen.addPanel( self.szRightPaneWidget, "", "", true, true,
  1319.             self.X_RIGHT_PANE, self.Y_RIGHT_PANE, self.W_RIGHT_PANE, self.H_RIGHT_PANE, PanelStyles.PANEL_STYLE_MAIN )#PanelStyles.PANEL_STYLE_DAWNTOP )
  1320.         
  1321.         self.drawWondersDropdownBox()
  1322.         self.calculateWondersList()
  1323.         self.drawWondersList()
  1324.         
  1325.     def drawWondersDropdownBox(self):
  1326.         "Draws the Wonders Dropdown Box"
  1327.         
  1328.         screen = self.getScreen()
  1329.         
  1330.         ######################### Dropdown Box Widget #########################################
  1331.         
  1332.         self.szWondersDropdownWidget = self.getNextWidgetName()
  1333.         
  1334.         screen.addDropDownBoxGFC(self.szWondersDropdownWidget,
  1335.             self.X_DROPDOWN, self.Y_DROPDOWN, self.W_DROPDOWN, WidgetTypes.WIDGET_GENERAL, -1, -1, FontTypes.GAME_FONT)
  1336.         
  1337.         if (self.szWonderDisplayMode == "World Wonders"):
  1338.             bDefault = true
  1339.         else:
  1340.             bDefault = false
  1341.         screen.addPullDownString(self.szWondersDropdownWidget, localText.getText("TXT_KEY_TOP_CITIES_SCREEN_WORLD_WONDERS", ()), 0, 0, bDefault )
  1342.  
  1343.         if (self.szWonderDisplayMode == "National Wonders"):
  1344.             bDefault = true
  1345.         else:
  1346.             bDefault = false
  1347.         screen.addPullDownString(self.szWondersDropdownWidget, localText.getText("TXT_KEY_TOP_CITIES_SCREEN_NATIONAL_WONDERS", ()), 1, 1, bDefault )
  1348.  
  1349.         if (self.szWonderDisplayMode == "Projects"):
  1350.             bDefault = true
  1351.         else:
  1352.             bDefault = false
  1353.         screen.addPullDownString(self.szWondersDropdownWidget, localText.getText("TXT_KEY_PEDIA_CATEGORY_PROJECT", ()), 2, 2, bDefault )
  1354.         
  1355.         return
  1356.         
  1357.     def determineListBoxContents(self):
  1358.         
  1359.         screen = self.getScreen()
  1360.         
  1361.         # Fill wonders listbox
  1362.     
  1363.         iNumWondersBeingBuilt = len(self.aaWondersBeingBuilt)
  1364.         
  1365.         szWonderName = ""
  1366.         self.aiWonderListBoxIDs = []
  1367.         self.aiTurnYearBuilt = []
  1368.         self.aiWonderBuiltBy = []
  1369.         
  1370.         if (self.szWonderDisplayMode == "Projects"):
  1371.             
  1372.     ############### Create ListBox for Projects ###############
  1373.             
  1374.             for iWonderLoop in range(iNumWondersBeingBuilt):
  1375.                 
  1376.                 iProjectType = self.aaWondersBeingBuilt[iWonderLoop][0]
  1377.                 pProjectInfo = gc.getProjectInfo(iProjectType)
  1378.                 szProjectName = pProjectInfo.getDescription()
  1379.                 
  1380.                 self.aiWonderListBoxIDs.append(iProjectType)
  1381.                 self.aiTurnYearBuilt.append(-6666)
  1382.                 szWonderBuiltBy = self.aaWondersBeingBuilt[iWonderLoop][1]
  1383.                 self.aiWonderBuiltBy.append(szWonderBuiltBy)
  1384.                 
  1385.                 screen.appendListBoxString( self.szWondersListBox, szProjectName + " (" + szWonderBuiltBy + ")", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY )
  1386.         
  1387.             for iWonderLoop in range(self.iNumWonders):
  1388.                 
  1389.                 iProjectType = self.aaWondersBuilt[iWonderLoop][1]
  1390.                 pProjectInfo = gc.getProjectInfo(iProjectType)
  1391.                 szProjectName = pProjectInfo.getDescription()
  1392.                 
  1393.                 self.aiWonderListBoxIDs.append(iProjectType)
  1394.                 self.aiTurnYearBuilt.append(-9999)
  1395.                 szWonderBuiltBy = self.aaWondersBuilt[iWonderLoop][2]
  1396.                 self.aiWonderBuiltBy.append(szWonderBuiltBy)
  1397.                 
  1398.                 screen.appendListBoxString( self.szWondersListBox, szProjectName + " (" + szWonderBuiltBy + ")", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY )
  1399.         
  1400.         else:
  1401.             
  1402.     ############### Create ListBox for Wonders ###############
  1403.             
  1404.             for iWonderLoop in range(iNumWondersBeingBuilt):
  1405.                 
  1406.                 iWonderType = self.aaWondersBeingBuilt[iWonderLoop][0]
  1407.                 pWonderInfo = gc.getBuildingInfo(iWonderType)
  1408.                 szWonderName = pWonderInfo.getDescription()
  1409.                 
  1410.                 self.aiWonderListBoxIDs.append(iWonderType)
  1411.                 self.aiTurnYearBuilt.append(-9999)
  1412.                 szWonderBuiltBy = self.aaWondersBeingBuilt[iWonderLoop][1]
  1413.                 self.aiWonderBuiltBy.append(szWonderBuiltBy)
  1414.                 
  1415.                 screen.appendListBoxString( self.szWondersListBox, szWonderName + " (" + szWonderBuiltBy + ")", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY )
  1416.         
  1417.             for iWonderLoop in range(self.iNumWonders):
  1418.                 
  1419.                 iWonderType = self.aaWondersBuilt[iWonderLoop][1]
  1420.                 pWonderInfo = gc.getBuildingInfo(iWonderType)
  1421.                 szWonderName = pWonderInfo.getDescription()
  1422.                 
  1423.                 self.aiWonderListBoxIDs.append(iWonderType)
  1424.                 self.aiTurnYearBuilt.append(self.aaWondersBuilt[iWonderLoop][0])
  1425.                 szWonderBuiltBy = self.aaWondersBuilt[iWonderLoop][2]
  1426.                 self.aiWonderBuiltBy.append(szWonderBuiltBy)
  1427.                 
  1428.                 screen.appendListBoxString( self.szWondersListBox, szWonderName + " (" + szWonderBuiltBy + ")", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY )
  1429.         
  1430.     def drawWondersList(self):
  1431.         
  1432.         screen = self.getScreen()
  1433.         
  1434.         if (self.iNumWondersPermanentWidgets == 0):
  1435.             
  1436.             # Wonders List ListBox
  1437.             self.szWondersListBox = self.getNextWidgetName()
  1438.             screen.addListBoxGFC(self.szWondersListBox, "",
  1439.                 self.X_WONDER_LIST, self.Y_WONDER_LIST, self.W_WONDER_LIST, self.H_WONDER_LIST, TableStyles.TABLE_STYLE_STANDARD )
  1440.             
  1441.             self.determineListBoxContents()
  1442.             
  1443.             self.iNumWondersPermanentWidgets = self.nWidgetCount
  1444.             
  1445.         # Stats Panel
  1446.         panelName = self.getNextWidgetName()
  1447.         screen.addPanel( panelName, "", "", true, true,
  1448.                  self.X_STATS_PANE, self.Y_STATS_PANE, self.W_STATS_PANE, self.H_STATS_PANE, PanelStyles.PANEL_STYLE_IN )
  1449.         
  1450. ############################################### DISPLAY SINGLE WONDER ###############################################
  1451.         
  1452.         # Set default wonder if any exist in this list
  1453.         if (len(self.aiWonderListBoxIDs) > 0 and self.iWonderID == -1):
  1454.             self.iWonderID = self.aiWonderListBoxIDs[0]
  1455.         
  1456.         # Only display/do the following if a wonder is actively being displayed
  1457.         if (self.iWonderID > -1):
  1458.             
  1459. ############################################### DISPLAY PROJECT MODE ###############################################
  1460.             
  1461.             if (self.szWonderDisplayMode == "Projects"):
  1462.                 
  1463.                 pProjectInfo = gc.getProjectInfo(self.iWonderID)
  1464.                 
  1465.                 # Stats panel (cont'd) - Name
  1466.                 szProjectDesc = u"<font=3b>" + pProjectInfo.getDescription().upper() + u"</font>"
  1467.                 szStatsText = szProjectDesc + "\n\n"
  1468.                 
  1469.                 # Say whether this project is built yet or not
  1470.                 
  1471.                 iTurnYear = self.aiTurnYearBuilt[self.iActiveWonderCounter]
  1472.                 if (iTurnYear == -6666):    # -6666 used for wonders in progress
  1473.                     szTempText = localText.getText("TXT_KEY_BEING_BUILT", ())
  1474.                     
  1475.                 else:
  1476.                     szTempText = localText.getText("TXT_KEY_INFO_SCREEN_BUILT", ())
  1477.                     
  1478.                 szWonderDesc = "%s, %s" %(self.aiWonderBuiltBy[self.iActiveWonderCounter], szTempText)
  1479.                 szStatsText += szWonderDesc + "\n\n"
  1480.                 
  1481.                 if (pProjectInfo.getProductionCost() > 0):
  1482.                     szCost = localText.getText("TXT_KEY_PEDIA_COST", (gc.getActivePlayer().getProjectProductionNeeded(self.iWonderID),))
  1483.                     szStatsText += szCost.upper() + (u"%c" % gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar()) + "\n"
  1484.                 
  1485.                 if (isWorldProject(self.iWonderID)):
  1486.                     iMaxInstances = gc.getProjectInfo(self.iWonderID).getMaxGlobalInstances()
  1487.                     szProjectType = localText.getText("TXT_KEY_PEDIA_WORLD_PROJECT", ())
  1488.                     if (iMaxInstances > 1):
  1489.                         szProjectType += " " + localText.getText("TXT_KEY_PEDIA_WONDER_INSTANCES", (iMaxInstances,))
  1490.                     szStatsText += szProjectType.upper() + "\n"
  1491.  
  1492.                 if (isTeamProject(self.iWonderID)):
  1493.                     iMaxInstances = gc.getProjectInfo(self.iWonderID).getMaxTeamInstances()
  1494.                     szProjectType = localText.getText("TXT_KEY_PEDIA_TEAM_PROJECT", ())
  1495.                     if (iMaxInstances > 1):
  1496.                         szProjectType += " " + localText.getText("TXT_KEY_PEDIA_WONDER_INSTANCES", (iMaxInstances,))
  1497.                     szStatsText += szProjectType.upper()
  1498.                 
  1499.                 screen.addMultilineText(self.getNextWidgetName(), szStatsText, self.X_STATS_PANE + 5, self.Y_STATS_PANE + 15, self.W_STATS_PANE - 10, self.H_STATS_PANE - 20, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY)
  1500.                 
  1501.                 # Add Graphic
  1502.                 iIconX = self.X_PROJECT_ICON - self.W_PROJECT_ICON / 2
  1503.                 iIconY = self.Y_PROJECT_ICON - self.W_PROJECT_ICON / 2
  1504.                 
  1505.                 screen.addDDSGFC(self.getNextWidgetName(), gc.getProjectInfo(self.iWonderID).getButton(),
  1506.                          iIconX, iIconY, self.W_PROJECT_ICON, self.W_PROJECT_ICON, WidgetTypes.WIDGET_GENERAL, -1, -1 )
  1507.                 
  1508.                 # Special Abilities ListBox
  1509.                 
  1510.                 szSpecialTitle = u"<font=3b>" + localText.getText("TXT_KEY_PEDIA_SPECIAL_ABILITIES", ()) + u"</font>"
  1511.                 self.szSpecialTitleWidget = self.getNextWidgetName()
  1512.                 screen.setText(self.szSpecialTitleWidget, "", szSpecialTitle, CvUtil.FONT_LEFT_JUSTIFY, self.X_SPECIAL_TITLE, self.Y_SPECIAL_TITLE, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  1513.                 
  1514.                 panelName = self.getNextWidgetName()
  1515.                 screen.addPanel( panelName, "", "", true, true,
  1516.                          self.X_SPECIAL_PANE, self.Y_SPECIAL_PANE, self.W_SPECIAL_PANE, self.H_SPECIAL_PANE, PanelStyles.PANEL_STYLE_IN)
  1517.                 
  1518.                 listName = self.getNextWidgetName()
  1519.                 screen.attachListBoxGFC( panelName, listName, "", TableStyles.TABLE_STYLE_EMPTY )
  1520.                 screen.enableSelect(listName, False)
  1521.                 
  1522.                 szSpecialText = CyGameTextMgr().getProjectHelp(self.iWonderID, True, None)
  1523.                 splitText = string.split( szSpecialText, "\n" )
  1524.                 for special in splitText:
  1525.                     if len( special ) != 0:
  1526.                         screen.appendListBoxString( listName, special, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY )
  1527.                         
  1528.             else:
  1529.                     
  1530.     ############################################### DISPLAY WONDER MODE ###############################################
  1531.                 
  1532.                 pWonderInfo = gc.getBuildingInfo(self.iWonderID)
  1533.                 
  1534.                 # Stats panel (cont'd) - Name
  1535.                 szWonderDesc = u"<font=3b>" + gc.getBuildingInfo(self.iWonderID).getDescription().upper() + u"</font>"
  1536.                 szStatsText = szWonderDesc + "\n\n"
  1537.                 
  1538.                 # Wonder built-in year
  1539.                 iTurnYear = self.aiTurnYearBuilt[self.iActiveWonderCounter]#self.aaWondersBuilt[self.iActiveWonderCounter][0]#.append([0,iProjectLoop,""]
  1540.                 
  1541.                 szDateBuilt = ""
  1542.                 
  1543.                 if (iTurnYear != -9999):    # -9999 used for wonders in progress
  1544.                     if (iTurnYear < 0):
  1545.                         szTurnFounded = localText.getText("TXT_KEY_TIME_BC", (-iTurnYear,))
  1546.                     else:
  1547.                         szTurnFounded = localText.getText("TXT_KEY_TIME_AD", (iTurnYear,))
  1548.                 
  1549.                     szDateBuilt = (", %s" %(szTurnFounded))
  1550.                     
  1551.                 else:
  1552.                     szDateBuilt = (", %s" %(localText.getText("TXT_KEY_BEING_BUILT", ())))
  1553.                     
  1554.                 szWonderDesc = "%s%s" %(self.aiWonderBuiltBy[self.iActiveWonderCounter], szDateBuilt)
  1555.                 szStatsText += szWonderDesc + "\n\n"
  1556.                 
  1557.                 # Building attributes
  1558.                 
  1559.                 if (pWonderInfo.getProductionCost() > 0):
  1560.                     szCost = localText.getText("TXT_KEY_PEDIA_COST", (gc.getActivePlayer().getBuildingProductionNeeded(self.iWonderID),))
  1561.                     szStatsText += szCost.upper() + (u"%c" % gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar()) + "\n"
  1562.                 
  1563.                 for k in range(CommerceTypes.NUM_COMMERCE_TYPES):
  1564.                     if (pWonderInfo.getObsoleteSafeCommerceChange(k) != 0):
  1565.                         if (pWonderInfo.getObsoleteSafeCommerceChange(k) > 0):
  1566.                             szSign = "+"
  1567.                         else:
  1568.                             szSign = ""
  1569.                             
  1570.                         szCommerce = gc.getCommerceInfo(k).getDescription() + ": "
  1571.                         
  1572.                         szText1 = szCommerce.upper() + szSign + str(pWonderInfo.getObsoleteSafeCommerceChange(k))
  1573.                         szText2 = szText1 + (u"%c" % (gc.getCommerceInfo(k).getChar()))
  1574.                         szStatsText += szText2 + "\n"
  1575.  
  1576.                 if (pWonderInfo.getHappiness() > 0):
  1577.                     szText = localText.getText("TXT_KEY_PEDIA_HAPPY", (pWonderInfo.getHappiness(),))
  1578.                     szStatsText += szText + (u"%c" % CyGame().getSymbolID(FontSymbols.HAPPY_CHAR)) + "\n"
  1579.                     
  1580.                 elif (pWonderInfo.getHappiness() < 0):
  1581.                     szText = localText.getText("TXT_KEY_PEDIA_UNHAPPY", (-pWonderInfo.getHappiness(),))
  1582.                     szStatsText += szText + (u"%c" % CyGame().getSymbolID(FontSymbols.UNHAPPY_CHAR)) + "\n"
  1583.  
  1584.                 if (pWonderInfo.getHealth() > 0):
  1585.                     szText = localText.getText("TXT_KEY_PEDIA_HEALTHY", (pWonderInfo.getHealth(),))
  1586.                     szStatsText += szText + (u"%c" % CyGame().getSymbolID(FontSymbols.HEALTHY_CHAR)) + "\n"
  1587.                     
  1588.                 elif (pWonderInfo.getHealth() < 0):
  1589.                     szText = localText.getText("TXT_KEY_PEDIA_UNHEALTHY", (-pWonderInfo.getHealth(),))
  1590.                     szStatsText += szText + (u"%c" % CyGame().getSymbolID(FontSymbols.UNHEALTHY_CHAR)) + "\n"
  1591.                 
  1592.                 if (pWonderInfo.getGreatPeopleRateChange() != 0):
  1593.                     szText = localText.getText("TXT_KEY_PEDIA_GREAT_PEOPLE", (pWonderInfo.getGreatPeopleRateChange(),))
  1594.                     szStatsText += szText + (u"%c" % CyGame().getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR)) + "\n"
  1595.                 
  1596.                 screen.addMultilineText(self.getNextWidgetName(), szStatsText, self.X_STATS_PANE + 5, self.Y_STATS_PANE + 15, self.W_STATS_PANE - 10, self.H_STATS_PANE - 20, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY)
  1597.                 
  1598.                 # Add Graphic
  1599.                 screen.addBuildingGraphicGFC(self.getNextWidgetName(), self.iWonderID,
  1600.                     self.X_WONDER_GRAPHIC, self.Y_WONDER_GRAPHIC, self.W_WONDER_GRAPHIC, self.H_WONDER_GRAPHIC,
  1601.                     WidgetTypes.WIDGET_GENERAL, -1, -1, self.X_ROTATION_WONDER_ANIMATION, self.Z_ROTATION_WONDER_ANIMATION, self.SCALE_ANIMATION, True)
  1602.                 
  1603.                 # Special Abilities ListBox
  1604.                 
  1605.                 szSpecialTitle = u"<font=3b>" + localText.getText("TXT_KEY_PEDIA_SPECIAL_ABILITIES", ()) + u"</font>"
  1606.                 self.szSpecialTitleWidget = self.getNextWidgetName()
  1607.                 screen.setText(self.szSpecialTitleWidget, "", szSpecialTitle, CvUtil.FONT_LEFT_JUSTIFY, self.X_SPECIAL_TITLE, self.Y_SPECIAL_TITLE, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  1608.                 
  1609.                 panelName = self.getNextWidgetName()
  1610.                 screen.addPanel( panelName, "", "", true, true,#localText.getText("TXT_KEY_PEDIA_SPECIAL_ABILITIES", ())
  1611.                          self.X_SPECIAL_PANE, self.Y_SPECIAL_PANE, self.W_SPECIAL_PANE, self.H_SPECIAL_PANE, PanelStyles.PANEL_STYLE_IN)
  1612.                 
  1613.                 listName = self.getNextWidgetName()
  1614.                 screen.attachListBoxGFC( panelName, listName, "", TableStyles.TABLE_STYLE_EMPTY )
  1615.                 screen.enableSelect(listName, False)
  1616.                 
  1617.                 szSpecialText = CyGameTextMgr().getBuildingHelp(self.iWonderID, True, False, False, None)
  1618.                 splitText = string.split( szSpecialText, "\n" )
  1619.                 for special in splitText:
  1620.                     if len( special ) != 0:
  1621.                         screen.appendListBoxString( listName, special, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY )
  1622.                         
  1623.     def calculateWondersList(self):
  1624.         
  1625.         self.aaWondersBeingBuilt = []
  1626.         self.aaWondersBuilt = []
  1627.         self.iNumWonders = 0
  1628.         
  1629.         self.pActivePlayer = gc.getPlayer(CyGame().getActivePlayer())
  1630.         
  1631.         # Loop through players to determine Wonders
  1632.         for iPlayerLoop in range(gc.getMAX_PLAYERS()):
  1633.             
  1634.             pPlayer = gc.getPlayer(iPlayerLoop)
  1635.             iPlayerTeam = pPlayer.getTeam()
  1636.             
  1637.             # No barbs and only display national wonders for the active player's team
  1638.              if (pPlayer and not pPlayer.isBarbarian() and ((self.szWonderDisplayMode != "National Wonders") or (iPlayerTeam == gc.getTeam(gc.getPlayer(self.iActivePlayer).getTeam()).getID()))):
  1639.  
  1640.                 # Loop through this player's cities and determine if they have any wonders to display
  1641.                 apCityList = PyPlayer(iPlayerLoop).getCityList()
  1642.                 for pCity in apCityList:
  1643.                     
  1644.                     # Loop through projects to find any under construction
  1645.                     if (self.szWonderDisplayMode == "Projects"):
  1646.                         for iProjectLoop in range(gc.getNumProjectInfos()):
  1647.                             
  1648.                             iProjectProd = pCity.getProductionProject()
  1649.                             pProject = gc.getProjectInfo(iProjectLoop)
  1650.                             
  1651.                             # Project is being constructed
  1652.                             if (iProjectProd == iProjectLoop):
  1653.                                 
  1654.                                 # Project Mode
  1655.                                 if (iPlayerTeam == gc.getTeam(gc.getPlayer(self.iActivePlayer).getTeam()).getID()):
  1656.                                     
  1657.                                     self.aaWondersBeingBuilt.append([iProjectProd, pPlayer.getCivilizationShortDescription(0)])
  1658.                         
  1659.                     # Loop through buildings
  1660.                     else:
  1661.                         
  1662.                         for iBuildingLoop in range(gc.getNumBuildingInfos()):
  1663.                             
  1664.                             iBuildingProd = pCity.getProductionBuilding()
  1665.                             
  1666.                             pBuilding = gc.getBuildingInfo(iBuildingLoop)
  1667.                             
  1668.                             # World Wonder Mode
  1669.                             if (self.szWonderDisplayMode == "World Wonders" and isWorldWonderClass(gc.getBuildingInfo(iBuildingLoop).getBuildingClassType())):
  1670.                                 
  1671.                                 # Is this city building a wonder?
  1672.                                 if (iBuildingProd == iBuildingLoop):
  1673.                                     
  1674.                                     # Only show our wonders under construction
  1675.                                     if (iPlayerTeam == gc.getTeam(gc.getPlayer(self.iActivePlayer).getTeam()).getID()):
  1676.                                         
  1677.                                         self.aaWondersBeingBuilt.append([iBuildingProd, pPlayer.getCivilizationShortDescription(0)])
  1678.                                     
  1679.                                 if (pCity.hasBuilding(iBuildingLoop)):
  1680.                                     
  1681.                                     self.aaWondersBuilt.append([pCity.getBuildingOriginalTime(iBuildingLoop),iBuildingLoop,pPlayer.getCivilizationShortDescription(0)])
  1682.     #                                print("Adding World wonder to list: %s, %d, %s" %(pCity.getBuildingOriginalTime(iBuildingLoop),iBuildingLoop,pPlayer.getCivilizationAdjective(0)))
  1683.                                     self.iNumWonders += 1
  1684.                             
  1685.                             # National/Team Wonder Mode
  1686.                             elif (self.szWonderDisplayMode == "National Wonders" and (isNationalWonderClass(gc.getBuildingInfo(iBuildingLoop).getBuildingClassType()) or isTeamWonderClass(gc.getBuildingInfo(iBuildingLoop).getBuildingClassType()))):
  1687.                                 
  1688.                                 # Is this city building a wonder?
  1689.                                 if (iBuildingProd == iBuildingLoop):
  1690.                                     
  1691.                                     # Only show our wonders under construction
  1692.                                     if (iPlayerTeam == gc.getTeam(gc.getPlayer(self.iActivePlayer).getTeam()).getID()):
  1693.                                         
  1694.                                         self.aaWondersBeingBuilt.append([iBuildingProd, pPlayer.getCivilizationShortDescription(0)])
  1695.                                     
  1696.                                 if (pCity.hasBuilding(iBuildingLoop)):
  1697.                                     
  1698.     #                                print("Adding National wonder to list: %s, %d, %s" %(pCity.getBuildingOriginalTime(iBuildingLoop),iBuildingLoop,pPlayer.getCivilizationAdjective(0)))
  1699.                                     self.aaWondersBuilt.append([pCity.getBuildingOriginalTime(iBuildingLoop),iBuildingLoop,pPlayer.getCivilizationShortDescription(0)])
  1700.                                     self.iNumWonders += 1
  1701.         
  1702.         # This array used to store which players have already used up a team's slot so team projects don't get added to list more than once
  1703.         aiTeamsUsed = []
  1704.         
  1705.         # Project Mode
  1706.         if (self.szWonderDisplayMode == "Projects"):
  1707.             
  1708.             # Loop through players to determine Projects
  1709.             for iPlayerLoop in range(gc.getMAX_PLAYERS()):
  1710.                 
  1711.                 pPlayer = gc.getPlayer(iPlayerLoop)
  1712.                 iTeamLoop = pPlayer.getTeam()
  1713.                 
  1714.                 # Block duplicates
  1715.                 if (iTeamLoop not in aiTeamsUsed):
  1716.                     
  1717.                     aiTeamsUsed.append(iTeamLoop)
  1718.                     pTeam = gc.getTeam(iTeamLoop)
  1719.                     
  1720.                     # No barbs and only display national wonders for the active player's team
  1721.                     if (pTeam.isAlive() and not pTeam.isBarbarian()):
  1722.                         
  1723.                         # Loop through projects
  1724.                         for iProjectLoop in range(gc.getNumProjectInfos()):
  1725.                             
  1726.                             for iI in range(pTeam.getProjectCount(iProjectLoop)):
  1727.                                 
  1728.                                 self.aaWondersBuilt.append([-9999,iProjectLoop,gc.getPlayer(iPlayerLoop).getCivilizationShortDescription(0)])
  1729.                                 self.iNumWonders += 1
  1730.         
  1731.         # Sort wonders in order of date built
  1732.         self.aaWondersBuilt.sort()
  1733.         self.aaWondersBuilt.reverse()
  1734.         
  1735. #        print("List of wonders/projects Built:")
  1736. #        print(self.aaWondersBuilt)
  1737.                                            
  1738. #############################################################################################################
  1739. ################################################## STATISTICS ###############################################
  1740. #############################################################################################################
  1741.         
  1742.     def drawStatsTab(self):
  1743.         
  1744.         screen = self.getScreen()
  1745.         
  1746.         iNumUnits = gc.getNumUnitInfos()
  1747.         iNumBuildings = gc.getNumBuildingInfos()
  1748.         
  1749.         self.iNumStatsChartCols = 7
  1750.         self.iNumStatsChartRows = max(iNumUnits, iNumBuildings)
  1751.         
  1752. ################################################### CALCULATE STATS ###################################################
  1753.         
  1754.         iMinutesPlayed = CyGame().getMinutesPlayed()
  1755.         iHoursPlayed = iMinutesPlayed / 60
  1756.         iMinutesPlayed = iMinutesPlayed - (iHoursPlayed * 60)
  1757.         
  1758.         szMinutesString = str(iMinutesPlayed)
  1759.         if (iMinutesPlayed < 10):
  1760.             szMinutesString = "0" + szMinutesString
  1761.         szHoursString = str(iHoursPlayed)
  1762.         if (iHoursPlayed < 10):
  1763.             szHoursString = "0" + szHoursString
  1764.         
  1765.         szTimeString = szHoursString + ":" + szMinutesString
  1766.         
  1767.         iNumCitiesBuilt = CyStatistics().getPlayerNumCitiesBuilt(self.iActivePlayer)
  1768.         
  1769.         iNumCitiesRazed = CyStatistics().getPlayerNumCitiesRazed(self.iActivePlayer)
  1770.         
  1771.         iNumReligionsFounded = 0
  1772.         for iReligionLoop in range(gc.getNumReligionInfos()):
  1773.             if (CyStatistics().getPlayerReligionFounded(self.iActivePlayer, iReligionLoop)):
  1774.                 iNumReligionsFounded += 1
  1775.         
  1776.         aiUnitsBuilt = []
  1777.         for iUnitLoop in range(iNumUnits):
  1778.             aiUnitsBuilt.append(CyStatistics().getPlayerNumUnitsBuilt(self.iActivePlayer, iUnitLoop))
  1779.         
  1780.         aiUnitsKilled = []
  1781.         for iUnitLoop in range(iNumUnits):
  1782.             aiUnitsKilled.append(CyStatistics().getPlayerNumUnitsKilled(self.iActivePlayer, iUnitLoop))
  1783.         
  1784.         aiUnitsLost = []
  1785.         for iUnitLoop in range(iNumUnits):
  1786.             aiUnitsLost.append(CyStatistics().getPlayerNumUnitsLost(self.iActivePlayer, iUnitLoop))
  1787.         
  1788.         aiBuildingsBuilt = []
  1789.         for iBuildingLoop in range(iNumBuildings):
  1790.             aiBuildingsBuilt.append(CyStatistics().getPlayerNumBuildingsBuilt(self.iActivePlayer, iBuildingLoop))
  1791.         
  1792.         aiUnitsCurrent = []
  1793.         for iUnitLoop in range(iNumUnits):
  1794.             aiUnitsCurrent.append(0)
  1795.         
  1796.         apUnitList = PyPlayer(self.iActivePlayer).getUnitList()
  1797.         for pUnit in apUnitList:
  1798.             iType = pUnit.getUnitType()
  1799.             aiUnitsCurrent[iType] += 1
  1800.             
  1801. ################################################### TOP PANEL ###################################################
  1802.         
  1803.         # Add Panel
  1804.         szTopPanelWidget = self.getNextWidgetName()
  1805.         screen.addPanel( szTopPanelWidget, u"", u"", True, False, self.X_STATS_TOP_PANEL, self.Y_STATS_TOP_PANEL, self.W_STATS_TOP_PANEL, self.H_STATS_TOP_PANEL,
  1806.                  PanelStyles.PANEL_STYLE_DAWNTOP )
  1807.         
  1808.         # Leaderhead graphic
  1809.         player = gc.getPlayer(gc.getGame().getActivePlayer())
  1810.         szLeaderWidget = self.getNextWidgetName()
  1811.         screen.addLeaderheadGFC(szLeaderWidget, player.getLeaderType(), AttitudeTypes.ATTITUDE_PLEASED,
  1812.             self.X_LEADER_ICON, self.Y_LEADER_ICON, self.W_LEADER_ICON, self.H_LEADER_ICON, WidgetTypes.WIDGET_GENERAL, -1, -1)
  1813.         
  1814.         # Leader Name
  1815.         self.szLeaderNameWidget = self.getNextWidgetName()
  1816.         szText = u"<font=4b>" + gc.getPlayer(self.iActivePlayer).getName() + u"</font>"
  1817.         screen.setText(self.szLeaderNameWidget, "", szText, CvUtil.FONT_LEFT_JUSTIFY,
  1818.                    self.X_LEADER_NAME, self.Y_LEADER_NAME, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  1819.         
  1820.         # Create Table
  1821.         szTopChart = self.getNextWidgetName()
  1822.         screen.addTableControlGFC(szTopChart, self.iNumTopChartCols, self.X_STATS_TOP_CHART, self.Y_STATS_TOP_CHART, self.W_STATS_TOP_CHART, self.H_STATS_TOP_CHART,
  1823.                       False, True, 32,32, TableStyles.TABLE_STYLE_STANDARD)
  1824.         
  1825.         # Add Columns
  1826.         screen.setTableColumnHeader(szTopChart, 0, "", self.STATS_TOP_CHART_W_COL_0)
  1827.         screen.setTableColumnHeader(szTopChart, 1, "", self.STATS_TOP_CHART_W_COL_1)
  1828.         
  1829.         # Add Rows
  1830.         for i in range(self.iNumTopChartRows - 1):
  1831.             screen.appendTableRow(szTopChart)
  1832.         iNumRows = screen.getTableNumRows(szTopChart)
  1833.         
  1834.         # Graph itself
  1835.         iRow = 0
  1836.         iCol = 0
  1837.         screen.setTableText(szTopChart, iCol, iRow, self.TEXT_TIME_PLAYED, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1838.         iCol = 1
  1839.         screen.setTableText(szTopChart, iCol, iRow, szTimeString, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1840.         
  1841.         iRow = 1
  1842.         iCol = 0
  1843.         screen.setTableText(szTopChart, iCol, iRow, self.TEXT_CITIES_BUILT, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1844.         iCol = 1
  1845.         screen.setTableText(szTopChart, iCol, iRow, str(iNumCitiesBuilt), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1846.  
  1847.         iRow = 2
  1848.         iCol = 0
  1849.         screen.setTableText(szTopChart, iCol, iRow, self.TEXT_CITIES_RAZED, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1850.         iCol = 1
  1851.         screen.setTableText(szTopChart, iCol, iRow, str(iNumCitiesRazed), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1852.  
  1853.         iRow = 3
  1854.         iCol = 0
  1855.         screen.setTableText(szTopChart, iCol, iRow, self.TEXT_NUM_RELIGIONS_FOUNDED, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1856.         iCol = 1
  1857.         screen.setTableText(szTopChart, iCol, iRow, str(iNumReligionsFounded), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1858.         
  1859. ################################################### BOTTOM PANEL ###################################################
  1860.         
  1861.         # Create Table
  1862.         szTable = self.getNextWidgetName()
  1863.         screen.addTableControlGFC(szTable, self.iNumStatsChartCols, self.X_STATS_BOTTOM_CHART, self.Y_STATS_BOTTOM_CHART, self.W_STATS_BOTTOM_CHART, self.H_STATS_BOTTOM_CHART,
  1864.                       True, True, 32,32, TableStyles.TABLE_STYLE_STANDARD)
  1865.         screen.enableSort(szTable)
  1866.         
  1867.         # Reducing the width a bit to leave room for the vertical scrollbar, preventing a horizontal scrollbar from also being created
  1868.         iChartWidth = self.W_STATS_BOTTOM_CHART - 12
  1869.         
  1870.         # Add Columns
  1871.         iColWidth = int((iChartWidth / 12 * 3))
  1872.         screen.setTableColumnHeader(szTable, 0, self.TEXT_UNITS, iColWidth)
  1873.         iColWidth = int((iChartWidth / 12 * 1))
  1874.         screen.setTableColumnHeader(szTable, 1, self.TEXT_CURRENT, iColWidth)
  1875.         iColWidth = int((iChartWidth / 12 * 1))
  1876.         screen.setTableColumnHeader(szTable, 2, self.TEXT_BUILT, iColWidth)
  1877.         iColWidth = int((iChartWidth / 12 * 1))
  1878.         screen.setTableColumnHeader(szTable, 3, self.TEXT_KILLED, iColWidth)
  1879.         iColWidth = int((iChartWidth / 12 * 1))
  1880.         screen.setTableColumnHeader(szTable, 4, self.TEXT_LOST, iColWidth)
  1881.         iColWidth = int((iChartWidth / 12 * 4))
  1882.         screen.setTableColumnHeader(szTable, 5, self.TEXT_BUILDINGS, iColWidth)
  1883.         iColWidth = int((iChartWidth / 12 * 1))
  1884.         screen.setTableColumnHeader(szTable, 6, self.TEXT_BUILT, iColWidth)
  1885.         
  1886.         # Add Rows
  1887.         for i in range(self.iNumStatsChartRows - 1):
  1888.             screen.appendTableRow(szTable)
  1889.         iNumRows = screen.getTableNumRows(szTable)
  1890.         
  1891.         # Add Units to table
  1892.         for iUnitLoop in range(iNumUnits):
  1893.             iRow = iUnitLoop
  1894.             
  1895.             iCol = 0
  1896.             szUnitName = gc.getUnitInfo(iUnitLoop).getDescription()
  1897.             screen.setTableText(szTable, iCol, iRow, szUnitName, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1898.             
  1899.             iCol = 1
  1900.             iNumUnitsCurrent = aiUnitsCurrent[iUnitLoop]
  1901.             screen.setTableInt(szTable, iCol, iRow, str(iNumUnitsCurrent), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1902.             
  1903.             iCol = 2
  1904.             iNumUnitsBuilt = aiUnitsBuilt[iUnitLoop]
  1905.             screen.setTableInt(szTable, iCol, iRow, str(iNumUnitsBuilt), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1906.             
  1907.             iCol = 3
  1908.             iNumUnitsKilled = aiUnitsKilled[iUnitLoop]
  1909.             screen.setTableInt(szTable, iCol, iRow, str(iNumUnitsKilled), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1910.             
  1911.             iCol = 4
  1912.             iNumUnitsLost = aiUnitsLost[iUnitLoop]
  1913.             screen.setTableInt(szTable, iCol, iRow, str(iNumUnitsLost), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1914.         
  1915.         # Add Buildings to table
  1916.         for iBuildingLoop in range(iNumBuildings):
  1917.             iRow = iBuildingLoop
  1918.             
  1919.             iCol = 5
  1920.             szBuildingName = gc.getBuildingInfo(iBuildingLoop).getDescription()
  1921.             screen.setTableText(szTable, iCol, iRow, szBuildingName, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1922.             iCol = 6
  1923.             iNumBuildingsBuilt = aiBuildingsBuilt[iBuildingLoop]
  1924.             screen.setTableInt(szTable, iCol, iRow, str(iNumBuildingsBuilt), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  1925.         
  1926. #############################################################################################################
  1927. ##################################################### OTHER #################################################
  1928. #############################################################################################################
  1929.  
  1930.     # returns a unique ID for a widget in this screen
  1931.     def getNextWidgetName(self):
  1932.         szName = self.WIDGET_ID + str(self.nWidgetCount)
  1933.         self.nWidgetCount += 1
  1934.         return szName
  1935.         
  1936.     def deleteAllWidgets(self, iNumPermanentWidgets = 0):
  1937.         screen = self.getScreen()
  1938.         i = self.nWidgetCount - 1
  1939.         while (i >= iNumPermanentWidgets):
  1940.             self.nWidgetCount = i
  1941.             screen.deleteWidget(self.getNextWidgetName())
  1942.             i -= 1
  1943.         
  1944.         self.nWidgetCount = iNumPermanentWidgets
  1945.         self.yMessage = 5
  1946.     
  1947.     # handle the input for this screen...
  1948.     def handleInput (self, inputClass):
  1949.         
  1950.         screen = self.getScreen()
  1951.             
  1952.         szWidgetName = inputClass.getFunctionName() + str(inputClass.getID())
  1953.         
  1954.         # Exit
  1955.         if ( szWidgetName == self.szExitButtonName and inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED \
  1956.                 or inputClass.getData() == int(InputTypes.KB_RETURN) ):
  1957.             # Reset Wonders so nothing lingers next time the screen is opened
  1958.             self.resetWonders()
  1959.             screen.hideScreen()
  1960.         
  1961. #        print("szWidgetName: %s" %(szWidgetName))
  1962. #        print("Notify Code: %s" %(inputClass.getNotifyCode()))
  1963.         
  1964.         # Dropdown Box/ ListBox
  1965.         if (inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED):
  1966.             
  1967.             # Debug dropdown
  1968.             if (inputClass.getFunctionName() == self.DEBUG_DROPDOWN_ID):
  1969.                 iIndex = screen.getSelectedPullDownID(self.DEBUG_DROPDOWN_ID)
  1970.                 self.iActivePlayer = screen.getPullDownData(self.DEBUG_DROPDOWN_ID, iIndex)
  1971.                 
  1972.                 self.pActivePlayer = gc.getPlayer(self.iActivePlayer)
  1973.                 self.iActiveTeam = self.pActivePlayer.getTeam()
  1974.                 self.pActiveTeam = gc.getTeam(self.iActiveTeam)
  1975.                 
  1976.                 # Determine who this active player knows
  1977.                 self.aiPlayersMet = []
  1978.                 self.iNumPlayersMet = 0
  1979.                 for iLoopPlayer in range(gc.getMAX_CIV_PLAYERS()):
  1980.                     pLoopPlayer = gc.getPlayer(iLoopPlayer)
  1981.                     iLoopPlayerTeam = pLoopPlayer.getTeam()
  1982.                     if (self.pActiveTeam.isHasMet(iLoopPlayerTeam)):
  1983.                         self.aiPlayersMet.append(iLoopPlayer)
  1984.                         self.iNumPlayersMet += 1
  1985.                 self.redrawContents()
  1986.             
  1987.             iSelected = inputClass.getData()
  1988. #            print("iSelected : %d" %(iSelected))
  1989.             
  1990. ############################### WONDERS / TOP CITIES TAB ###############################
  1991.             
  1992.             if (self.iActiveTab == self.iTopCitiesID):
  1993.                 
  1994.                 # Wonder type dropdown box
  1995.                 if (szWidgetName == self.szWondersDropdownWidget):
  1996.                     
  1997.                     # Reset wonders stuff so that when the type shown changes the old contents don't mess with things
  1998.                     
  1999.                     self.iNumWonders = 0
  2000.                     self.iActiveWonderCounter = 0
  2001.                     self.iWonderID = -1
  2002.                     self.aaWondersBuilt = []
  2003.                     
  2004.                     self.aaWondersBeingBuilt = []
  2005.                     
  2006.                     if (iSelected == 0):
  2007.                         self.szWonderDisplayMode = "World Wonders"
  2008.                     
  2009.                     elif (iSelected == 1):
  2010.                         self.szWonderDisplayMode = "National Wonders"
  2011.                     
  2012.                     elif (iSelected == 2):
  2013.                         self.szWonderDisplayMode = "Projects"
  2014.                         
  2015.                     self.reset()
  2016.                     
  2017.                     self.calculateWondersList()
  2018.                     self.determineListBoxContents()
  2019.                     
  2020.                     # Change selected wonder to the one at the top of the new list
  2021.                     if (self.iNumWonders > 0):
  2022.                         self.iWonderID = self.aiWonderListBoxIDs[0]
  2023.                         
  2024.                     self.redrawContents()
  2025.                     
  2026.                 # Wonders ListBox
  2027.                 elif (szWidgetName == self.szWondersListBox):
  2028.                     
  2029.                     self.reset()
  2030.                     self.iWonderID = self.aiWonderListBoxIDs[iSelected]
  2031.                     self.iActiveWonderCounter = iSelected
  2032.                     self.deleteAllWidgets(self.iNumWondersPermanentWidgets)
  2033.                     self.drawWondersList()
  2034. #                    self.redrawContents()
  2035.                     
  2036. ############################### DEMOGRAPHICS TAB ###############################
  2037.             
  2038.             elif (self.iActiveTab == self.iDemographicsID):
  2039.                 
  2040.                 # Graph dropdown to select what values are being graphed
  2041.                 if (szWidgetName == self.szGraphDropdownWidget):
  2042.                     
  2043.                     if (iSelected == 0):
  2044.                         self.iDemoGraphTabID = self.iScoreTabID
  2045.                     
  2046.                     elif (iSelected == 1):
  2047.                         self.iDemoGraphTabID = self.iEconomyTabID
  2048.                     
  2049.                     elif (iSelected == 2):
  2050.                         self.iDemoGraphTabID = self.iIndustryTabID
  2051.                     
  2052.                     elif (iSelected == 3):
  2053.                         self.iDemoGraphTabID = self.iAgricultureTabID
  2054.                     
  2055.                     elif (iSelected == 4):
  2056.                         self.iDemoGraphTabID = self.iPowerTabID
  2057.                     
  2058.                     elif (iSelected == 5):
  2059.                         self.iDemoGraphTabID = self.iCultureTabID
  2060.                     
  2061.                     self.fMaxDemoStatValue = 0.0
  2062.                     self.updateGraph()
  2063.                         
  2064.                 # Dropdown to select players to show
  2065.                 elif (szWidgetName == self.szCivsDropdownWidget):
  2066.                     
  2067.                     screen.deleteWidget(self.szGraphWidget)
  2068.                     self.drawGraph()
  2069.                     self.iShowingPlayer = self.aiDropdownPlayerIDs[iSelected]
  2070.                     self.updateGraph()
  2071.                     
  2072.         # Something Clicked
  2073.         elif (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
  2074.             
  2075.             ######## Screen 'Tabs' for Navigation ########
  2076.             
  2077.             if (szWidgetName == self.szDemographicsTabWidget):
  2078.                 self.iActiveTab = self.iDemographicsID
  2079.                 self.reset()
  2080.                 self.redrawContents()
  2081.                 
  2082.             elif (szWidgetName == self.szTopCitiesTabWidget):
  2083.                 self.iActiveTab = self.iTopCitiesID
  2084.                 self.reset()
  2085.                 self.redrawContents()
  2086.                 
  2087.             elif (szWidgetName == self.szStatsTabWidget):
  2088.                 self.iActiveTab = self.iStatsID
  2089.                 self.reset()
  2090.                 self.redrawContents()
  2091.                 
  2092.         return 0
  2093.  
  2094.     def update(self, fDelta):
  2095.         
  2096.         return
  2097.