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

  1. ## Sid Meier's Civilization 4
  2. ## Copyright Firaxis Games 2005
  3. from CvPythonExtensions import *
  4. import CvUtil
  5. import ScreenInput
  6. import CvScreenEnums
  7.  
  8. PIXEL_INCREMENT = 7
  9. BOX_INCREMENT_WIDTH = 27 # Used to be 33 #Should be a multiple of 3...
  10. BOX_INCREMENT_HEIGHT = 9 #Should be a multiple of 3...
  11. BOX_INCREMENT_Y_SPACING = 6 #Should be a multiple of 3...
  12. BOX_INCREMENT_X_SPACING = 9 #Should be a multiple of 3...
  13.  
  14. TEXTURE_SIZE = 24
  15. X_START = 6
  16. X_INCREMENT = 27
  17. Y_ROW = 32
  18.  
  19. CIV_HAS_TECH = 0
  20. CIV_IS_RESEARCHING = 1
  21. CIV_NO_RESEARCH = 2
  22. CIV_TECH_AVAILABLE = 3
  23.  
  24. # globals
  25. gc = CyGlobalContext()
  26. ArtFileMgr = CyArtFileMgr()
  27. g_civSelected = 0
  28. localText = CyTranslator()
  29. g_iCurrentState = []
  30.  
  31. zLevel = -6.1
  32.  
  33. class CvTechChooser:
  34.     "Tech Chooser Screen"
  35.  
  36.     def __init__(self):
  37.         self.nWidgetCount = 0
  38.  
  39.     def hideScreen (self):
  40.     
  41.         # Get the screen
  42.         screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )
  43.  
  44.         # Hide the screen
  45.         screen.hideScreen()
  46.     
  47.     # Screen construction function
  48.     def interfaceScreen(self):
  49.     
  50.         global g_civSelected
  51.  
  52.         if ( not CyGame().isPitbossHost() ):
  53.             g_civSelected = gc.getGame().getActivePlayer()
  54.  
  55.         # Create a new screen, called TechChooser, using the file CvTechChooser.py for input
  56.         screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )
  57.         screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)
  58.     
  59.         if ( CyGame().isDebugMode() ):
  60.             screen.addDropDownBoxGFC( "CivDropDown", 22, 12, 192, WidgetTypes.WIDGET_GENERAL, -1, -1, FontTypes.SMALL_FONT )
  61.             screen.setActivation( "CivDropDown", ActivationTypes.ACTIVATE_MIMICPARENTFOCUS )
  62.             for j in range(gc.getMAX_PLAYERS()):
  63.                 if (gc.getPlayer(j).isAlive()):
  64.                     screen.addPullDownString( "CivDropDown", gc.getPlayer(j).getName(), j, j, False )
  65.         else:
  66.             screen.hide( "CivDropDown" )
  67.     
  68.         if ( screen.isPersistent() ):
  69.             self.updateTechRecords()
  70.             return
  71.         
  72.         screen.setPersistent( True )
  73.         
  74.         # Here we set the background widget and exit button, and we show the screen
  75.         screen.showWindowBackground( False )
  76.         screen.setDimensions(screen.centerX(0), screen.centerY(0), 1024, 768)
  77.         screen.addPanel( "TechTopPanel", u"", u"", True, False, 0, 0, 1024, 55, PanelStyles.PANEL_STYLE_TOPBAR )
  78.         screen.addDDSGFC("TechBG", ArtFileMgr.getInterfaceArtInfo("SCREEN_BG_OPAQUE").getPath(), 0, 48, 1024, 672, WidgetTypes.WIDGET_GENERAL, -1, -1 )
  79.         screen.addPanel( "TechBottomPanel", u"", u"", True, False, 0, 713, 1024, 55, PanelStyles.PANEL_STYLE_BOTTOMBAR )
  80.         screen.setText( "TechChooserExit", "Background", u"<font=4>" + CyTranslator().getText("TXT_KEY_PEDIA_SCREEN_EXIT", ()).upper() + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, 994, 726, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1 )
  81.         screen.setActivation( "TechChooserExit", ActivationTypes.ACTIVATE_MIMICPARENTFOCUS )
  82.  
  83.         # Header...
  84.         szText = u"<font=4>"
  85.         szText = szText + localText.getText("TXT_KEY_TECH_CHOOSER_TITLE", ()).upper()
  86.         szText = szText + u"</font>"
  87.         screen.setLabel( "TechTitleHeader", "Background", szText, CvUtil.FONT_CENTER_JUSTIFY, 502, 8, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
  88.  
  89.         # Make the scrollable area for the city list...
  90.         screen.addScrollPanel( "TechList", u"", 0, 64, 1024, 626, PanelStyles.PANEL_STYLE_EXTERNAL )
  91.         screen.setActivation( "TechList", ActivationTypes.ACTIVATE_NORMAL )
  92.         screen.hide( "TechList" )
  93.         
  94.         # Add the Highlight
  95.         #screen.addDDSGFC( "TechHighlight", ArtFileMgr.getInterfaceArtInfo("TECH_HIGHLIGHT").getPath(), 0, 0, self.getXStart() + 6, 12 + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ), WidgetTypes.WIDGET_GENERAL, -1, -1 )
  96.         #screen.hide( "TechHighlight" )
  97.  
  98.         # Place the tech blocks
  99.         self.placeTechs()
  100.     
  101.         # Draw the arrows
  102.         self.drawArrows()
  103.         
  104.         screen.moveToFront( "CivDropDown" )
  105.     
  106.     def placeTechs (self):
  107.     
  108.         global g_civSelected
  109.         global g_iCurrentState
  110.  
  111.         iMaxX = 0
  112.         iMaxY = 0
  113.  
  114.         # If we are the Pitboss, we don't want to put up an interface at all
  115.         if ( CyGame().isPitbossHost() ):
  116.             return
  117.             
  118.         # Get the screen
  119.         screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )
  120.     
  121.         # Go through all the techs
  122.         for i in range(gc.getNumTechInfos()):
  123.  
  124.             # Create and place a tech in its proper location
  125.             iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
  126.             iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
  127.             szTechRecord = "TechRecord" + str(i)
  128.             
  129.             if ( iMaxX < iX + self.getXStart() ):
  130.                 iMaxX = iX + self.getXStart()
  131.             if ( iMaxY < iY + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ) ):
  132.                 iMaxY = iY + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT )
  133.  
  134.             screen.attachPanelAt( "TechList", szTechRecord, u"", u"", True, False, PanelStyles.PANEL_STYLE_TECH, iX - 6, iY - 6, self.getXStart() + 6, 12 + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ), WidgetTypes.WIDGET_TECH_TREE, i, -1 )
  135.             screen.setActivation( szTechRecord, ActivationTypes.ACTIVATE_MIMICPARENTFOCUS)
  136.             screen.hide( szTechRecord )
  137.             
  138.             if ( gc.getTeam(gc.getPlayer(g_civSelected).getTeam()).isHasTech(i) ):
  139.                 screen.setPanelColor(szTechRecord, 85, 150, 87)
  140.                 g_iCurrentState.append(CIV_HAS_TECH)
  141.             elif ( gc.getPlayer(g_civSelected).getCurrentResearch() == i ):
  142.                 screen.setPanelColor(szTechRecord, 104, 158, 165)
  143.                 g_iCurrentState.append(CIV_IS_RESEARCHING)
  144.             elif ( gc.getPlayer(g_civSelected).isResearchingTech(i) ):
  145.                 screen.setPanelColor(szTechRecord, 104, 158, 165)
  146.                 g_iCurrentState.append(CIV_IS_RESEARCHING)
  147.             elif ( gc.getPlayer(g_civSelected).canEverResearch(i) ):
  148.                 screen.setPanelColor(szTechRecord, 100, 104, 160)
  149.                 g_iCurrentState.append(CIV_NO_RESEARCH)
  150.             else:
  151.                 screen.setPanelColor(szTechRecord, 206, 65, 69)
  152.                 g_iCurrentState.append(CIV_TECH_AVAILABLE)
  153.  
  154.             szTechID = "TechID" + str(i)
  155.             szTechString = "<font=1>"
  156.             if ( gc.getPlayer(g_civSelected).isResearchingTech(i) ):
  157.                 szTechString = szTechString + str(gc.getPlayer(g_civSelected).getQueuePosition(i)) + ". "
  158.             szTechString += gc.getTechInfo(i).getDescription()
  159.             szTechString = szTechString + "</font>"
  160.             screen.setTextAt( szTechID, "TechList", szTechString, CvUtil.FONT_LEFT_JUSTIFY, iX + 6 + X_INCREMENT, iY + 6, -0.1, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_TECH_TREE, i, -1 )
  161.             screen.setActivation( szTechID, ActivationTypes.ACTIVATE_MIMICPARENTFOCUS )
  162.  
  163.             szTechButtonID = "TechButtonID" + str(i)
  164.             screen.addDDSGFCAt( szTechButtonID, "TechList", gc.getTechInfo(i).getButton(), iX + 6, iY + 6, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_TECH_TREE, i, -1, False )
  165.  
  166.             fX = X_START
  167.  
  168.             j = 0
  169.             k = 0
  170.  
  171.             # Unlockable units...
  172.             for j in range( gc.getNumUnitClassInfos() ):
  173.                 eLoopUnit = gc.getCivilizationInfo(gc.getGame().getActiveCivilizationType()).getCivilizationUnits(j)
  174.                 if (eLoopUnit != -1):
  175.                     if (gc.getUnitInfo(eLoopUnit).getPrereqAndTech() == i):
  176.                         szUnitButton = "Unit" + str(j)
  177.                         screen.addDDSGFCAt( szUnitButton, "TechList", gc.getUnitInfo(eLoopUnit).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_UNIT, eLoopUnit, 1, True )
  178.                         fX += X_INCREMENT
  179.  
  180.             j = 0
  181.             k = 0
  182.  
  183.             # Unlockable Buildings...
  184.             for j in range(gc.getNumBuildingClassInfos()):
  185.                 bTechFound = 0
  186.                 eLoopBuilding = gc.getCivilizationInfo(gc.getGame().getActiveCivilizationType()).getCivilizationBuildings(j)
  187.  
  188.                 if (eLoopBuilding != -1):
  189.                     if (gc.getBuildingInfo(eLoopBuilding).getPrereqAndTech() == i):
  190.                         szBuildingButton = "Building" + str(j)
  191.                         screen.addDDSGFCAt( szBuildingButton, "TechList", gc.getBuildingInfo(eLoopBuilding).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, eLoopBuilding, 1, True )
  192.                         fX += X_INCREMENT
  193.  
  194.             j = 0
  195.             k = 0
  196.  
  197.             # Obsolete Buildings...
  198.             for j in range(gc.getNumBuildingClassInfos()):
  199.                 eLoopBuilding = gc.getCivilizationInfo(gc.getPlayer(g_civSelected).getCivilizationType()).getCivilizationBuildings(j)
  200.  
  201.                 if (eLoopBuilding != -1):
  202.                     if (gc.getBuildingInfo(eLoopBuilding).getObsoleteTech() == i):
  203.                         # Add obsolete picture here...
  204.                         szObsoleteButton = "Obsolete" + str(j)
  205.                         szObsoleteX = "ObsoleteX" + str(j)
  206.                         screen.addDDSGFCAt( szObsoleteButton, "TechList", gc.getBuildingInfo(eLoopBuilding).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE, eLoopBuilding, -1, False )
  207.                         screen.addDDSGFCAt( szObsoleteX, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_RED_X").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE, eLoopBuilding, -1, False )
  208.                         fX += X_INCREMENT
  209.                         
  210.             j = 0
  211.             k = 0
  212.  
  213.             # Obsolete Bonuses...
  214.             for j in range(gc.getNumBonusInfos()):
  215.                 if (gc.getBonusInfo(j).getTechObsolete() == i):
  216.                     # Add obsolete picture here...
  217.                     szObsoleteButton = "ObsoleteBonus" + str(j)
  218.                     szObsoleteX = "ObsoleteXBonus" + str(j)
  219.                     screen.addDDSGFCAt( szObsoleteButton, "TechList", gc.getBonusInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE_BONUS, j, -1, False )
  220.                     screen.addDDSGFCAt( szObsoleteX, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_RED_X").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE_BONUS, j, -1, False )
  221.                     fX += X_INCREMENT
  222.                         
  223.             j = 0
  224.             k = 0
  225.  
  226.             # Obsolete Monastaries...
  227.             for j in range (gc.getNumSpecialBuildingInfos()):
  228.                 if (gc.getSpecialBuildingInfo(j).getObsoleteTech() == i):
  229.                         # Add obsolete picture here...
  230.                         szObsoleteSpecialButton = "ObsoleteSpecial" + str(j)
  231.                         szObsoleteSpecialX = "ObsoleteSpecialX" + str(j)
  232.                         screen.addDDSGFCAt( szObsoleteSpecialButton, "TechList", gc.getSpecialBuildingInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE_SPECIAL, j, -1, False )
  233.                         screen.addDDSGFCAt( szObsoleteSpecialX, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_RED_X").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE_SPECIAL, j, -1, False )
  234.                         fX += X_INCREMENT
  235.  
  236.             j = 0
  237.             k = 0
  238.  
  239.             # Route movement change
  240.             for j in range(gc.getNumRouteInfos()):
  241.                 if ( gc.getRouteInfo(j).getTechMovementChange(i) != 0 ):
  242.                     szMoveButton = "Move" + str(j)
  243.                     screen.addDDSGFCAt( szMoveButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_MOVE_BONUS").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_MOVE_BONUS, i, -1, False )
  244.                     fX += X_INCREMENT
  245.  
  246.             j = 0
  247.             k = 0
  248.  
  249.             # Promotion Info
  250.             for j in range( gc.getNumPromotionInfos() ):
  251.                 if ( gc.getPromotionInfo(j).getTechPrereq() == i ):
  252.                     szPromotionButton = "Promotion" + str(i)
  253.                     screen.addDDSGFCAt( szPromotionButton, "TechList", gc.getPromotionInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROMOTION, j, -1, False )
  254.                     fX += X_INCREMENT
  255.  
  256.             j = 0
  257.             k = 0
  258.  
  259.             # Free unit
  260.             if ( gc.getTechInfo(i).getFirstFreeUnitClass() != UnitClassTypes.NO_UNITCLASS ):
  261.                 szFreeUnitButton = "FreeUnit" + str(i)
  262.                 screen.addDDSGFCAt( szFreeUnitButton, "TechList", gc.getUnitInfo(gc.getUnitClassInfo(gc.getTechInfo(i).getFirstFreeUnitClass()).getDefaultUnitIndex()).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_FREE_UNIT, i, -1, False )
  263.                 fX += X_INCREMENT
  264.  
  265.             j = 0
  266.             k = 0
  267.  
  268.             # Worker speed
  269.             if ( gc.getTechInfo(i).getWorkerSpeedModifier() != 0 ):
  270.                 szWorkerModifierButton = "Worker" + str(i)
  271.                 screen.addDDSGFCAt( szWorkerModifierButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_WORKER_SPEED").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_WORKER_RATE, i, -1, False )
  272.                 fX += X_INCREMENT
  273.  
  274.             j = 0
  275.             k = 0
  276.  
  277.             # Trade Routes per City change
  278.             if ( gc.getTechInfo(i).getTradeRoutes() != 0 ):
  279.                 szTradeRouteButton = "TradeRoutes" + str(i)
  280.                 screen.addDDSGFCAt( szTradeRouteButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_TRADE_ROUTES").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TRADE_ROUTES, i, -1, False )
  281.                 fX += X_INCREMENT
  282.  
  283.             j = 0
  284.             k = 0
  285.  
  286.             # Health Rate bonus from this tech...
  287.             if ( gc.getTechInfo(i).getHealth() != 0 ):
  288.                 szHealthRateButton = "HealthRate" + str(i)
  289.                 screen.addDDSGFCAt( szHealthRateButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_HEALTH").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_HEALTH_RATE, i, -1, False )
  290.                 fX += X_INCREMENT
  291.  
  292.             j = 0
  293.             k = 0
  294.  
  295.             # Happiness Rate bonus from this tech...
  296.             if ( gc.getTechInfo(i).getHappiness() != 0 ):
  297.                 szHappinessRateButton = "HappinessRate" + str(i)
  298.                 screen.addDDSGFCAt( szHappinessRateButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_HAPPINESS").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_HAPPINESS_RATE, i, -1, False )
  299.                 fX += X_INCREMENT
  300.  
  301.             j = 0
  302.             k = 0
  303.  
  304.             # Free Techs
  305.             if ( gc.getTechInfo(i).getFirstFreeTechs() > 0 ):
  306.                 szFreeTechButton = "FreeTech" + str(i)
  307.                 screen.addDDSGFCAt( szFreeTechButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_FREETECH").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_FREE_TECH, i, -1, False )
  308.                 fX += X_INCREMENT
  309.  
  310.             j = 0
  311.             k = 0
  312.  
  313.             # Line of Sight bonus...
  314.             if ( gc.getTechInfo(i).isExtraWaterSeeFrom() ):
  315.                 szLOSButton = "LOS" + str(i)
  316.                 screen.addDDSGFCAt( szLOSButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_LOS").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_LOS_BONUS, i, -1, False )
  317.                 fX += X_INCREMENT
  318.  
  319.             j = 0
  320.             k = 0
  321.  
  322.             # Map Center Bonus...
  323.             if ( gc.getTechInfo(i).isMapCentering() ):
  324.                 szMapCenterButton = "MapCenter" + str(i)
  325.                 screen.addDDSGFCAt( szMapCenterButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_MAPCENTER").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_MAP_CENTER, i, -1, False )
  326.                 fX += X_INCREMENT
  327.  
  328.             j = 0
  329.             k = 0
  330.  
  331.             # Map Reveal...
  332.             if ( gc.getTechInfo(i).isMapVisible() ):
  333.                 szMapRevealButton = "MapReveal" + str(i)
  334.                 screen.addDDSGFCAt( szMapRevealButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_MAPREVEAL").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_MAP_REVEAL, i, -1, False )
  335.                 fX += X_INCREMENT
  336.                 
  337.             j = 0
  338.             k = 0
  339.  
  340.             # Map Trading
  341.             if ( gc.getTechInfo(i).isMapTrading() == True ):
  342.                 szMapTradeButton = "MapTrade" + str(i)
  343.                 screen.addDDSGFCAt( szMapTradeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_MAPTRADING").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_MAP_TRADE, i, -1, False )
  344.                 fX += X_INCREMENT
  345.  
  346.             j = 0
  347.             k = 0
  348.  
  349.             # Tech Trading
  350.             if ( gc.getTechInfo(i).isTechTrading() ):
  351.                 szTechTradeButton = "TechTrade" + str(i)
  352.                 screen.addDDSGFCAt( szTechTradeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_TECHTRADING").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TECH_TRADE, i, -1, False )
  353.                 fX += X_INCREMENT
  354.  
  355.             j = 0
  356.             k = 0
  357.  
  358.             # Gold Trading
  359.             if ( gc.getTechInfo(i).isGoldTrading() ):
  360.                 szGoldTradeButton = "GoldTrade" + str(i)
  361.                 screen.addDDSGFCAt( szGoldTradeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_GOLDTRADING").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_GOLD_TRADE, i, -1, False )
  362.                 fX += X_INCREMENT
  363.  
  364.             j = 0
  365.             k = 0
  366.  
  367.             # Open Borders
  368.             if ( gc.getTechInfo(i).isOpenBordersTrading() ):
  369.                 szOpenBordersButton = "OpenBorders" + str(i)
  370.                 screen.addDDSGFCAt( szOpenBordersButton , "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_OPENBORDERS").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OPEN_BORDERS, i, -1, False )
  371.                 fX += X_INCREMENT
  372.  
  373.             j = 0
  374.             k = 0
  375.  
  376.             # Defensive Pact
  377.             if ( gc.getTechInfo(i).isDefensivePactTrading() ):
  378.                 szDefensivePactButton = "DefensivePact" + str(i)
  379.                 screen.addDDSGFCAt( szDefensivePactButton , "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_DEFENSIVEPACT").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_DEFENSIVE_PACT, i, -1, False )
  380.                 fX += X_INCREMENT
  381.  
  382.             j = 0
  383.             k = 0
  384.  
  385.             # Permanent Alliance
  386.             if ( gc.getTechInfo(i).isPermanentAllianceTrading() ):
  387.                 szPermanentAllianceButton = "PermanentAlliance" + str(i)
  388.                 screen.addDDSGFCAt( szPermanentAllianceButton , "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_PERMALLIANCE").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_PERMANENT_ALLIANCE, i, -1, False )
  389.                 fX += X_INCREMENT
  390.  
  391.             j = 0
  392.             k = 0
  393.  
  394.             # Bridge Building
  395.             if ( gc.getTechInfo(i).isBridgeBuilding() ):
  396.                 szBuildBridgeButton = "BuildBridge" + str(i)
  397.                 screen.addDDSGFCAt( szBuildBridgeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_BRIDGEBUILDING").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_BUILD_BRIDGE, i, -1, False )
  398.                 fX += X_INCREMENT
  399.  
  400.             j = 0
  401.             k = 0
  402.  
  403.             # Irrigation unlocked...
  404.             if ( gc.getTechInfo(i).isIrrigation() ):
  405.                 szIrrigationButton = "Irrigation" + str(i)
  406.                 screen.addDDSGFCAt( szIrrigationButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_IRRIGATION").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_IRRIGATION, i, -1, False )
  407.                 fX += X_INCREMENT
  408.  
  409.             j = 0
  410.             k = 0
  411.  
  412.             # Ignore Irrigation unlocked...
  413.             if ( gc.getTechInfo(i).isIgnoreIrrigation() ):
  414.                 szIgnoreIrrigationButton = "IgnoreIrrigation" + str(i)
  415.                 screen.addDDSGFCAt( szIgnoreIrrigationButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_NOIRRIGATION").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_IGNORE_IRRIGATION, i, -1, False )
  416.                 fX += X_INCREMENT
  417.  
  418.             j = 0
  419.             k = 0
  420.  
  421.             # Coastal Work unlocked...
  422.             if ( gc.getTechInfo(i).isWaterWork() ):
  423.                 szWaterWorkButton = "WaterWork" + str(i)
  424.                 screen.addDDSGFCAt( szWaterWorkButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_WATERWORK").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_WATER_WORK, i, -1, False )
  425.                 fX += X_INCREMENT
  426.  
  427.             j = 0
  428.             k = 0
  429.  
  430.             # Improvements
  431.             for j in range(gc.getNumBuildInfos()):
  432.                 bTechFound = 0;
  433.  
  434.                 if (gc.getBuildInfo(j).getTechPrereq() == -1):
  435.                     bTechFound = 0
  436.                     for k in range(gc.getNumFeatureInfos()):
  437.                         if (gc.getBuildInfo(j).getFeatureTech(k) == i):
  438.                             bTechFound = 1
  439.                 else:
  440.                     if (gc.getBuildInfo(j).getTechPrereq() == i):
  441.                         bTechFound = 1
  442.  
  443.                 if (bTechFound == 1):
  444.                     szImprovementButton = "Improvement" + str( ( i * 1000 ) + j )
  445.                     screen.addDDSGFCAt( szImprovementButton, "TechList", gc.getBuildInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_IMPROVEMENT, i, j, False )
  446.                     fX += X_INCREMENT
  447.  
  448.             j = 0
  449.             k = 0
  450.  
  451.             # Domain Extra Moves
  452.             for j in range( DomainTypes.NUM_DOMAIN_TYPES ):
  453.                 if (gc.getTechInfo(i).getDomainExtraMoves(j) != 0):
  454.                     szDomainExtraMovesButton = "DomainExtraMoves" + str( ( i * 1000 ) + j )
  455.                     screen.addDDSGFCAt( szDomainExtraMovesButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_WATERMOVES").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_DOMAIN_EXTRA_MOVES, i, j, False )
  456.                     fX += X_INCREMENT
  457.  
  458.             j = 0
  459.             k = 0
  460.  
  461.             # Adjustments
  462.             for j in range( CommerceTypes.NUM_COMMERCE_TYPES ):
  463.                 if (gc.getTechInfo(i).isCommerceFlexible(j) and not (gc.getTeam(gc.getPlayer(g_civSelected).getTeam()).isCommerceFlexible(j))):
  464.                     szAdjustButton = "AdjustButton" + str( ( i * 1000 ) + j )
  465.                     if ( j == CommerceTypes.COMMERCE_CULTURE ):
  466.                         szFileName = ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_CULTURE").getPath()
  467.                     else:
  468.                         szFileName = ArtFileMgr.getInterfaceArtInfo("INTERFACE_GENERAL_QUESTIONMARK").getPath()
  469.                     screen.addDDSGFCAt( szAdjustButton, "TechList", szFileName, iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_ADJUST, i, j, False )
  470.                     fX += X_INCREMENT
  471.  
  472.             j = 0
  473.             k = 0
  474.  
  475.             # Terrain opens up as a trade route
  476.             for j in range( gc.getNumTerrainInfos() ):
  477.                 if (gc.getTechInfo(i).isTerrainTrade(j) and not (gc.getTeam(gc.getPlayer(g_civSelected).getTeam()).isTerrainTrade(j))):
  478.                     szTerrainTradeButton = "TerrainTradeButton" + str( ( i * 1000 ) + j )
  479.                     screen.addDDSGFCAt( szTerrainTradeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_WATERTRADE").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TERRAIN_TRADE, i, j, False )
  480.                     fX += X_INCREMENT
  481.                 
  482.             j = 0
  483.             k = 0
  484.  
  485.             # Special buildings like monestaries...
  486.             for j in range( gc.getNumSpecialBuildingInfos() ):
  487.                 if (gc.getSpecialBuildingInfo(j).getTechPrereq() == i):
  488.                     szSpecialBuilding = "SpecialBuildingButton" + str( ( i * 1000 ) + j )
  489.                     screen.addDDSGFCAt( szSpecialBuilding, "TechList", gc.getSpecialBuildingInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_SPECIAL_BUILDING, i, j, False )
  490.                     fX += X_INCREMENT
  491.  
  492.             j = 0
  493.             k = 0
  494.  
  495.             # Yield change
  496.             for j in range( gc.getNumImprovementInfos() ):
  497.                 bFound = False
  498.                 for k in range( YieldTypes.NUM_YIELD_TYPES ):
  499.                     if (gc.getImprovementInfo(j).getTechYieldChanges(i, k)):
  500.                         if ( bFound == False ):
  501.                             szYieldChange = "YieldChangeButton" + str( ( i * 1000 ) + j )
  502.                             screen.addDDSGFCAt( szYieldChange, "TechList", gc.getImprovementInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_YIELD_CHANGE, i, j, False )
  503.                             fX += X_INCREMENT
  504.                             bFound = True
  505.  
  506.             j = 0
  507.             k = 0
  508.  
  509.             # Bonuses revealed
  510.             for j in range( gc.getNumBonusInfos() ):
  511.                 if (gc.getBonusInfo(j).getTechReveal() == i):
  512.                     szBonusReveal = "BonusRevealButton" + str( ( i * 1000 ) + j )
  513.                     screen.addDDSGFCAt( szBonusReveal, "TechList", gc.getBonusInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_BONUS_REVEAL, i, j, False )
  514.                     fX += X_INCREMENT
  515.  
  516.             j = 0
  517.             k = 0
  518.  
  519.             # Civic options
  520.             for j in range( gc.getNumCivicInfos() ):
  521.                 if (gc.getCivicInfo(j).getTechPrereq() == i):
  522.                     szCivicReveal = "CivicRevealButton" + str( ( i * 1000 ) + j )
  523.                     screen.addDDSGFCAt( szCivicReveal, "TechList", gc.getCivicInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_CIVIC_REVEAL, j, j, False )
  524.                     fX += X_INCREMENT
  525.  
  526.             j = 0
  527.             k = 0
  528.  
  529.             # Projects possible
  530.             for j in range( gc.getNumProjectInfos() ):
  531.                 if (gc.getProjectInfo(j).getTechPrereq() == i):
  532.                     szProjectInfo = "ProjectInfoButton" + str( ( i * 1000 ) + j )
  533.                     screen.addDDSGFCAt( szProjectInfo, "TechList", gc.getProjectInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROJECT, j, 1, False )
  534.                     fX += X_INCREMENT
  535.  
  536.             j = 0
  537.             k = 0
  538.  
  539.             # Processes possible
  540.             for j in range( gc.getNumProcessInfos() ):
  541.                 if (gc.getProcessInfo(j).getTechPrereq() == i):
  542.                     szProcessInfo = "ProcessInfoButton" + str( ( i * 1000 ) + j )
  543.                     screen.addDDSGFCAt( szProcessInfo, "TechList", gc.getProcessInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_PROCESS_INFO, i, j, False )
  544.                     fX += X_INCREMENT
  545.  
  546.             j = 0
  547.             k = 0
  548.  
  549.             # Religions unlocked
  550.             for j in range( gc.getNumReligionInfos() ):
  551.                 if ( gc.getReligionInfo(j).getTechPrereq() == i ):
  552.                     szFoundReligion = "FoundReligionButton" + str( ( i * 1000 ) + j )
  553.                     screen.addDDSGFCAt( szFoundReligion, "TechList", gc.getReligionInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_FOUND_RELIGION, i, j, False )
  554.                     fX += X_INCREMENT
  555.                     
  556.             screen.show( szTechRecord )
  557.                     
  558.         screen.setViewMin( "TechList", iMaxX + 20, iMaxY + 20 )
  559.         screen.show( "TechList" )
  560.         screen.setFocus( "TechList" )
  561.         
  562.  
  563.     # Will update the tech records based on color, researching, researched, queued, etc.
  564.     def updateTechRecords (self):
  565.  
  566.         global g_civSelected
  567.         global g_iCurrentState
  568.                 
  569.         # If we are the Pitboss, we don't want to put up an interface at all
  570.         if ( CyGame().isPitbossHost() ):
  571.             return
  572.             
  573.         # Get the screen
  574.         screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )
  575.     
  576.         # Go through all the techs
  577.         for i in range(gc.getNumTechInfos()):
  578.         
  579.             bChanged = 0
  580.         
  581.             if ( gc.getTeam(gc.getPlayer(g_civSelected).getTeam()).isHasTech(i) ):
  582.                 if ( g_iCurrentState[i] != CIV_HAS_TECH ):
  583.                     g_iCurrentState[i] = CIV_HAS_TECH
  584.                     bChanged = 1;
  585.             elif ( gc.getPlayer(g_civSelected).getCurrentResearch() == i ):
  586.                 if ( g_iCurrentState[i] != CIV_IS_RESEARCHING ):
  587.                     g_iCurrentState[i] = CIV_IS_RESEARCHING
  588.                     bChanged = 1;
  589.             elif ( gc.getPlayer(g_civSelected).isResearchingTech(i) ):
  590.                 if ( g_iCurrentState[i] != CIV_IS_RESEARCHING ):
  591.                     g_iCurrentState[i] = CIV_IS_RESEARCHING
  592.                     bChanged = 1;
  593.             elif ( gc.getPlayer(g_civSelected).canEverResearch(i) ):
  594.                 if ( g_iCurrentState[i] != CIV_NO_RESEARCH ):
  595.                     g_iCurrentState[i] = CIV_NO_RESEARCH
  596.                     bChanged = 1;
  597.             else:
  598.                 if ( g_iCurrentState[i] != CIV_TECH_AVAILABLE ):
  599.                     g_iCurrentState[i] = CIV_TECH_AVAILABLE
  600.                     bChanged = 1;
  601.  
  602.             if ( bChanged ):
  603.                 # Create and place a tech in its proper location
  604.                 szTechRecord = "TechRecord" + str(i)
  605.                 szTechID = "TechID" + str(i)
  606.                 szTechString = "<font=1>"
  607.                 
  608.                 if ( gc.getPlayer(g_civSelected).isResearchingTech(i) ):
  609.                     szTechString = szTechString + unicode(gc.getPlayer(g_civSelected).getQueuePosition(i)) + ". "
  610.                     
  611.                 iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
  612.                 iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
  613.  
  614.                 szTechString += gc.getTechInfo(i).getDescription()
  615.                 if ( gc.getPlayer(g_civSelected).isResearchingTech(i) ):
  616.                     szTechString += " ("
  617.                     szTechString += str(gc.getPlayer(g_civSelected).getResearchTurnsLeft(i, ( gc.getPlayer(g_civSelected).getCurrentResearch() == i )))
  618.                     szTechString += ")"
  619.                 szTechString = szTechString + "</font>"
  620.                 screen.setTextAt( szTechID, "TechList", szTechString, CvUtil.FONT_LEFT_JUSTIFY, iX + 6 + X_INCREMENT, iY + 6, -0.1, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_TECH_TREE, i, -1 )
  621.                 screen.setActivation( szTechID, ActivationTypes.ACTIVATE_MIMICPARENTFOCUS )
  622.  
  623.                 if ( gc.getTeam(gc.getPlayer(g_civSelected).getTeam()).isHasTech(i) ):
  624.                     screen.setPanelColor(szTechRecord, 85, 150, 87)
  625.                     g_iCurrentState.append(CIV_HAS_TECH)
  626.                 elif ( gc.getPlayer(g_civSelected).getCurrentResearch() == i ):
  627.                     screen.setPanelColor(szTechRecord, 104, 158, 165)
  628.                     g_iCurrentState.append(CIV_IS_RESEARCHING)
  629.                 elif ( gc.getPlayer(g_civSelected).isResearchingTech(i) ):
  630.                     screen.setPanelColor(szTechRecord, 104, 158, 165)
  631.                     g_iCurrentState.append(CIV_IS_RESEARCHING)
  632.                 elif ( gc.getPlayer(g_civSelected).canEverResearch(i) ):
  633.                     screen.setPanelColor(szTechRecord, 100, 104, 160)
  634.                     g_iCurrentState.append(CIV_NO_RESEARCH)
  635.                 else:
  636.                     screen.setPanelColor(szTechRecord, 206, 65, 69)
  637.                     g_iCurrentState.append(CIV_TECH_AVAILABLE)
  638.  
  639.     # Will draw the arrows
  640.     def drawArrows (self):
  641.  
  642.         global g_civSelected
  643.  
  644.         screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )
  645.  
  646.         iLoop = 0
  647.         self.nWidgetCount = 0
  648.         
  649.         ARROW_X = ArtFileMgr.getInterfaceArtInfo("ARROW_X").getPath()
  650.         ARROW_Y = ArtFileMgr.getInterfaceArtInfo("ARROW_Y").getPath()
  651.         ARROW_MXMY = ArtFileMgr.getInterfaceArtInfo("ARROW_MXMY").getPath()
  652.         ARROW_XY = ArtFileMgr.getInterfaceArtInfo("ARROW_XY").getPath()
  653.         ARROW_MXY = ArtFileMgr.getInterfaceArtInfo("ARROW_MXY").getPath()
  654.         ARROW_XMY = ArtFileMgr.getInterfaceArtInfo("ARROW_XMY").getPath()
  655.         ARROW_HEAD = ArtFileMgr.getInterfaceArtInfo("ARROW_HEAD").getPath()
  656.  
  657.         for i in range(gc.getNumTechInfos()):
  658.  
  659.             bFirst = 1
  660.  
  661.             fX = (BOX_INCREMENT_WIDTH * PIXEL_INCREMENT) - 8
  662.  
  663.             for j in range( gc.getDefineINT("NUM_AND_TECH_PREREQS") ):
  664.  
  665.                 eTech = gc.getTechInfo(i).getPrereqAndTechs(j)
  666.  
  667.                 if ( eTech > -1 ):
  668.  
  669.                     fX = fX - X_INCREMENT
  670.  
  671.                     iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
  672.                     iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
  673.  
  674.                     szTechPrereqID = "TechPrereqID" + str((i * 1000) + j)
  675.                     screen.addDDSGFCAt( szTechPrereqID, "TechList", gc.getTechInfo(eTech).getButton(), iX + fX, iY + 6, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TECH_PREPREQ, eTech, -1, False )
  676.  
  677.                     #szTechPrereqBorderID = "TechPrereqBorderID" + str((i * 1000) + j)
  678.                     #screen.addDDSGFCAt( szTechPrereqBorderID, "TechList", ArtFileMgr.getInterfaceArtInfo("TECH_TREE_BUTTON_BORDER").getPath(), iX + fX + 4, iY + 22, 32, 32, WidgetTypes.WIDGET_HELP_TECH_PREPREQ, eTech, -1, False )
  679.  
  680.             j = 0
  681.  
  682.             for j in range( gc.getDefineINT("NUM_OR_TECH_PREREQS") ):
  683.  
  684.                 eTech = gc.getTechInfo(i).getPrereqOrTechs(j)
  685.  
  686.                 if ( eTech > -1 ):
  687.  
  688.                     iX = 24 + ( (gc.getTechInfo(eTech).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
  689.                     iY = ( gc.getTechInfo(eTech).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
  690.                     
  691.                     # j is the pre-req, i is the tech...
  692.                     xDiff = gc.getTechInfo(i).getGridX() - gc.getTechInfo(eTech).getGridX()
  693.                     yDiff = gc.getTechInfo(i).getGridY() - gc.getTechInfo(eTech).getGridY()
  694.  
  695.                     if (yDiff == 0):
  696.                         screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(3), self.getWidth(xDiff), 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  697.                         screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  698.                     elif (yDiff < 0):
  699.                         if ( yDiff == -6 ):
  700.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(1), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  701.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  702.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) + 8 - self.getHeight(yDiff, 0), 8, self.getHeight(yDiff, 0) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  703.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) - self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  704.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) - self.getHeight(yDiff, 0), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  705.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(1) - self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  706.                         elif ( yDiff == -2 and xDiff == 2 ):
  707.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(2), self.getWidth(xDiff) * 5 / 6, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  708.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  709.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) + 8 - self.getHeight(yDiff, 3), 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  710.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  711.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 6 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  712.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  713.                         else:
  714.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(2), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  715.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  716.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) + 8 - self.getHeight(yDiff, 3), 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  717.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  718.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  719.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  720.                     elif (yDiff > 0):
  721.                         if ( yDiff == 2 and xDiff == 2):
  722.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(4), self.getWidth(xDiff) / 6, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  723.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  724.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + 8, 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  725.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  726.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), ( self.getWidth(xDiff) * 5 / 6 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  727.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  728.                         elif ( yDiff == 4 and xDiff == 1):
  729.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(5), self.getWidth(xDiff) / 3, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  730.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  731.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + 8, 8, self.getHeight(yDiff, 0) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  732.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  733.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + self.getHeight(yDiff, 0), ( self.getWidth(xDiff) * 2 / 3 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  734.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(5) + self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  735.                         else:
  736.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(4), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  737.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  738.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + 8, 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  739.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  740.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  741.                             screen.addDDSGFCAt( self.getNextWidgetName(), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
  742.  
  743.         return
  744.  
  745.     def TechRecord (self, inputClass):
  746.         return 0
  747.  
  748.     # Clicked the parent?
  749.     def ParentClick (self, inputClass):
  750.         return 0
  751.             
  752.     def CivDropDown( self, inputClass ):
  753.     
  754.         global g_civSelected
  755.         
  756.         if ( inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED ):
  757.             screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )            
  758.             iIndex = screen.getSelectedPullDownID("CivDropDown")
  759.             g_civSelected = screen.getPullDownData("CivDropDown", iIndex)
  760.             self.updateTechRecords()
  761.         
  762.     # Will handle the input for this screen...
  763.     def handleInput (self, inputClass):
  764.         # Get the screen
  765.         screen = CyGInterfaceScreen( "TechChooser", CvScreenEnums.TECH_CHOOSER )
  766.  
  767.         ' Calls function mapped in TechChooserInputMap'
  768.         # only get from the map if it has the key
  769.         if (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CHARACTER and ( inputClass.getData() == int(InputTypes.KB_F6) or inputClass.getData() == int(InputTypes.KB_ESCAPE) ) ):
  770.             self.hideScreen()
  771.             return 1
  772.         if ( inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED ):
  773.             self.CivDropDown( inputClass )
  774.             return 1
  775.         return 0
  776.  
  777.     def getNextWidgetName(self):
  778.         szName = "TechArrow" + str(self.nWidgetCount)
  779.         self.nWidgetCount += 1
  780.         return szName
  781.         
  782.     def getXStart(self):
  783.         return ( BOX_INCREMENT_WIDTH * PIXEL_INCREMENT )
  784.         
  785.     def getXSpacing(self):
  786.         return ( BOX_INCREMENT_X_SPACING * PIXEL_INCREMENT )
  787.                                         
  788.     def getYStart(self, iY):
  789.         return int((((BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ) / 6.0) * iY) - PIXEL_INCREMENT )
  790.  
  791.     def getWidth(self, xDiff):
  792.         return ( ( xDiff * self.getXSpacing() ) + ( ( xDiff - 1 ) * self.getXStart() ) )
  793.         
  794.     def getHeight(self, yDiff, nFactor):
  795.         return ( ( nFactor + ( ( abs( yDiff ) - 1 ) * 6 ) ) * PIXEL_INCREMENT )
  796.         
  797.     def update(self, fDelta):
  798.         return
  799.  
  800. class TechChooserMaps:
  801.  
  802.     TechChooserInputMap = {
  803.         'TechRecord'            : CvTechChooser().TechRecord,
  804.         'TechID'                : CvTechChooser().ParentClick,
  805.         'TechPane'                : CvTechChooser().ParentClick,
  806.         'TechButtonID'            : CvTechChooser().ParentClick,
  807.         'TechButtonBorder'        : CvTechChooser().ParentClick,
  808.         'Unit'                    : CvTechChooser().ParentClick,
  809.         'Building'                : CvTechChooser().ParentClick,
  810.         'Obsolete'                : CvTechChooser().ParentClick,
  811.         'ObsoleteX'                : CvTechChooser().ParentClick,
  812.         'Move'                    : CvTechChooser().ParentClick,
  813.         'FreeUnit'                : CvTechChooser().ParentClick,
  814.         'Worker'                : CvTechChooser().ParentClick,
  815.         'TradeRoutes'            : CvTechChooser().ParentClick,
  816.         'HealthRate'            : CvTechChooser().ParentClick,
  817.         'HappinessRate'            : CvTechChooser().ParentClick,
  818.         'FreeTech'                : CvTechChooser().ParentClick,
  819.         'LOS'                    : CvTechChooser().ParentClick,
  820.         'MapCenter'                : CvTechChooser().ParentClick,
  821.         'MapReveal'                : CvTechChooser().ParentClick,
  822.         'MapTrade'                : CvTechChooser().ParentClick,
  823.         'TechTrade'                : CvTechChooser().ParentClick,
  824.         'OpenBorders'        : CvTechChooser().ParentClick,
  825.         'BuildBridge'            : CvTechChooser().ParentClick,
  826.         'Irrigation'            : CvTechChooser().ParentClick,
  827.         'Improvement'            : CvTechChooser().ParentClick,
  828.         'DomainExtraMoves'            : CvTechChooser().ParentClick,
  829.         'AdjustButton'            : CvTechChooser().ParentClick,
  830.         'TerrainTradeButton'    : CvTechChooser().ParentClick,
  831.         'SpecialBuildingButton'    : CvTechChooser().ParentClick,
  832.         'YieldChangeButton'        : CvTechChooser().ParentClick,
  833.         'BonusRevealButton'        : CvTechChooser().ParentClick,
  834.         'CivicRevealButton'        : CvTechChooser().ParentClick,
  835.         'ProjectInfoButton'        : CvTechChooser().ParentClick,
  836.         'ProcessInfoButton'        : CvTechChooser().ParentClick,
  837.         'FoundReligionButton'    : CvTechChooser().ParentClick,
  838.         'CivDropDown'            : CvTechChooser().CivDropDown,
  839.         }
  840.  
  841.