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

  1. ## Sid Meier's Civilization 4
  2. ## Copyright Firaxis Games 2005
  3.  
  4. import CvUtil
  5. from CvPythonExtensions import *
  6.  
  7. ArtFileMgr = CyArtFileMgr()
  8. localText = CyTranslator()
  9. gc = CyGlobalContext()
  10.  
  11. class CvDawnOfMan:
  12.     "Dawn of man screen"
  13.     def __init__(self, iScreenID):
  14.         self.iScreenID = iScreenID
  15.         
  16.         self.X_SCREEN = 0
  17.         self.Y_SCREEN = 0
  18.         self.W_SCREEN = 1024
  19.         self.H_SCREEN = 768
  20.         
  21.         self.X_MAIN_PANEL = 250
  22.         self.Y_MAIN_PANEL = 70
  23.         self.W_MAIN_PANEL = 550
  24.         self.H_MAIN_PANEL = 500
  25.         
  26.         self.iMarginSpace = 15
  27.         
  28.         self.X_HEADER_PANEL = self.X_MAIN_PANEL + self.iMarginSpace
  29.         self.Y_HEADER_PANEL = self.Y_MAIN_PANEL + self.iMarginSpace
  30.         self.W_HEADER_PANEL = self.W_MAIN_PANEL - (self.iMarginSpace * 2)
  31.         self.H_HEADER_PANEL = int(self.H_MAIN_PANEL * (2.0 / 5.0))
  32.         
  33.         self.X_LEADER_ICON = self.X_HEADER_PANEL + self.iMarginSpace
  34.         self.Y_LEADER_ICON = self.Y_HEADER_PANEL + self.iMarginSpace
  35.         self.H_LEADER_ICON = self.H_HEADER_PANEL - (15 * 2)#140
  36.         self.W_LEADER_ICON = int(self.H_LEADER_ICON / 1.272727)#110
  37.         
  38. #        iWHeaderPanelRemainingAfterLeader = self.W_HEADER_PANEL - self.W_LEADER_ICON + (self.iMarginSpace * 3)
  39. #        iXHeaderPanelRemainingAfterLeader = self.X_LEADER_ICON + self.W_LEADER_ICON + self.iMarginSpace
  40.         self.X_LEADER_TITLE_TEXT = 510#iXHeaderPanelRemainingAfterLeader + (iWHeaderPanelRemainingAfterLeader / 2)
  41.         self.Y_LEADER_TITLE_TEXT = self.Y_HEADER_PANEL + self.iMarginSpace + 6
  42.         self.W_LEADER_TITLE_TEXT = self.W_HEADER_PANEL / 3
  43.         self.H_LEADER_TITLE_TEXT = self.H_HEADER_PANEL / 2
  44.         
  45.         self.X_FANCY_ICON1 = self.X_HEADER_PANEL + 170
  46.         self.X_FANCY_ICON2 = self.X_HEADER_PANEL + 430
  47.         self.Y_FANCY_ICON = self.Y_LEADER_TITLE_TEXT - 6
  48.         self.WH_FANCY_ICON = 64
  49.         
  50.         self.X_STATS_TEXT = self.X_FANCY_ICON1# + self.W_LEADER_ICON + (self.iMarginSpace * 2) + 5
  51.         self.Y_STATS_TEXT = self.Y_LEADER_TITLE_TEXT + 75
  52.         self.W_STATS_TEXT = int(self.W_HEADER_PANEL * (5 / 7.0))
  53.         self.H_STATS_TEXT = int(self.H_HEADER_PANEL * (3 / 5.0))
  54.         
  55.         self.X_TEXT_PANEL = self.X_HEADER_PANEL
  56.         self.Y_TEXT_PANEL = self.Y_HEADER_PANEL + self.H_HEADER_PANEL + self.iMarginSpace - 10 #10 is the fudge factor
  57.         self.W_TEXT_PANEL = self.W_HEADER_PANEL
  58.         self.H_TEXT_PANEL = self.H_MAIN_PANEL - self.H_HEADER_PANEL - (self.iMarginSpace * 3) + 10 #10 is the fudge factor
  59.         self.iTEXT_PANEL_MARGIN = 35
  60.         
  61.         self.X_EXIT = 460
  62.         self.Y_EXIT = self.Y_MAIN_PANEL + 440
  63.         self.W_EXIT = 120
  64.         self.H_EXIT = 30
  65.         
  66.     def interfaceScreen(self):
  67.         'Use a popup to display the opening text'
  68.         if ( CyGame().isPitbossHost() ):
  69.             return
  70.         
  71.         self.player = gc.getPlayer(gc.getGame().getActivePlayer())
  72.         self.EXIT_TEXT = localText.getText("TXT_KEY_SCREEN_CONTINUE", ())
  73.         
  74.         # Create screen
  75.         
  76.         screen = CyGInterfaceScreen( "CvDawnOfMan", self.iScreenID )        
  77.         screen.showScreen(PopupStates.POPUPSTATE_QUEUED, False)
  78.         screen.showWindowBackground( False )
  79.         screen.setDimensions(screen.centerX(self.X_SCREEN), screen.centerY(self.Y_SCREEN), self.W_SCREEN, self.H_SCREEN)
  80.         screen.enableWorldSounds( false )
  81.         screen.setCloseOnEscape( false )
  82.         
  83.         # Create panels
  84.         
  85.         # Main
  86.         szMainPanel = "DawnOfManMainPanel"
  87.         screen.addPanel( szMainPanel, "", "", true, true,
  88.             self.X_MAIN_PANEL, self.Y_MAIN_PANEL, self.W_MAIN_PANEL, self.H_MAIN_PANEL, PanelStyles.PANEL_STYLE_MAIN )
  89.         
  90.         # Top
  91.         szHeaderPanel = "DawnOfManHeaderPanel"
  92.         screen.addPanel( szHeaderPanel, "", "", true, false,
  93.             self.X_HEADER_PANEL, self.Y_HEADER_PANEL, self.W_HEADER_PANEL, self.H_HEADER_PANEL, PanelStyles.PANEL_STYLE_DAWNTOP )
  94.         
  95.         # Bottom
  96.         szTextPanel = "DawnOfManTextPanel"
  97.         screen.addPanel( szTextPanel, "", "", true, true,
  98.             self.X_TEXT_PANEL, self.Y_TEXT_PANEL, self.W_TEXT_PANEL, self.H_TEXT_PANEL, PanelStyles.PANEL_STYLE_DAWNBOTTOM )
  99.         
  100.         # Add contents
  101.         
  102.         # Leaderhead graphic
  103.         szLeaderPanel = "DawnOfManLeaderPanel"
  104.         screen.addPanel( szLeaderPanel, "", "", true, false,
  105.             self.X_LEADER_ICON - 3, self.Y_LEADER_ICON - 5, self.W_LEADER_ICON + 6, self.H_LEADER_ICON + 8, PanelStyles.PANEL_STYLE_DAWNTOP )
  106.         screen.addLeaderheadGFC("LeaderHead", self.player.getLeaderType(), AttitudeTypes.ATTITUDE_PLEASED,
  107.             self.X_LEADER_ICON + 5, self.Y_LEADER_ICON + 5, self.W_LEADER_ICON - 10, self.H_LEADER_ICON - 10, WidgetTypes.WIDGET_GENERAL, -1, -1)
  108.         
  109.         # Info/"Stats" text
  110.         
  111.         szNameText = "<color=255,255,0,255>" + u"<font=3b>" + gc.getLeaderHeadInfo(self.player.getLeaderType()).getDescription().upper() + u"</font>" + "\n- " + self.player.getCivilizationDescription(0) + " -"
  112.         screen.addMultilineText( "NameText", szNameText, self.X_LEADER_TITLE_TEXT, self.Y_LEADER_TITLE_TEXT, self.W_LEADER_TITLE_TEXT, self.H_LEADER_TITLE_TEXT, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY)
  113.         
  114.         self.Text_BoxText = CyGameTextMgr().parseLeaderTraits(self.player.getLeaderType(), self.player.getCivilizationType(), True, False)
  115.         self.Text_BoxText += "\n" + CyGameTextMgr().parseCivInfos(self.player.getCivilizationType(), True)
  116.         
  117.         screen.addMultilineText( "HeaderText", self.Text_BoxText, self.X_STATS_TEXT, self.Y_STATS_TEXT, self.W_STATS_TEXT, self.H_STATS_TEXT, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  118.         
  119.         # Fancy icon things
  120.         screen.addDDSGFC( "IconLeft", gc.getMissionInfo(MissionTypes.MISSION_FORTIFY).getButton(), self.X_FANCY_ICON1 , self.Y_FANCY_ICON , self.WH_FANCY_ICON, self.WH_FANCY_ICON, WidgetTypes.WIDGET_GENERAL, -1, -1 )
  121.         screen.addDDSGFC( "IconRight", gc.getMissionInfo(MissionTypes.MISSION_FORTIFY).getButton(), self.X_FANCY_ICON2 , self.Y_FANCY_ICON , self.WH_FANCY_ICON, self.WH_FANCY_ICON, WidgetTypes.WIDGET_GENERAL, -1, -1 )
  122.         
  123.         # Main Body text
  124.         szDawnTitle = u"<font=3>" + localText.getText("TXT_KEY_DAWN_OF_MAN_SCREEN_TITLE", ()).upper() + u"</font>"
  125.         screen.setLabel("DawnTitle", "Background", szDawnTitle, CvUtil.FONT_CENTER_JUSTIFY,
  126.                 self.X_TEXT_PANEL + (self.W_TEXT_PANEL / 2), self.Y_TEXT_PANEL + 15, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
  127.         bodyString = localText.getText("TXT_KEY_DAWN_OF_MAN_TEXT", (CyGameTextMgr().getTimeStr(gc.getGame().getGameTurn(), false), self.player.getCivilizationAdjectiveKey(), self.player.getNameKey()))
  128.         screen.addMultilineText( "BodyText", bodyString, self.X_TEXT_PANEL + self.iMarginSpace, self.Y_TEXT_PANEL + self.iMarginSpace + self.iTEXT_PANEL_MARGIN, self.W_TEXT_PANEL - (self.iMarginSpace * 2), self.H_TEXT_PANEL - (self.iMarginSpace * 2) - 75, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
  129.         
  130.         screen.setButtonGFC("Exit", self.EXIT_TEXT, "", self.X_EXIT, self.Y_EXIT, self.W_EXIT, self.H_EXIT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
  131.         
  132.         pActivePlayer = gc.getPlayer(CyGame().getActivePlayer())
  133.         pLeaderHeadInfo = gc.getLeaderHeadInfo(pActivePlayer.getLeaderType())
  134.         self.iSoundID = CyAudioGame().Play2DSoundWithId(pLeaderHeadInfo.getDiploPeaceMusicScriptIds(0))
  135. #        CyInterface().playGeneralSoundByID()
  136.         
  137.     def handleInput( self, inputClass ):
  138.         screen = CyInterfaceScreen( "CvDawnOfMan", self.iScreenID )        
  139.         
  140.         if ( inputClass.getFunctionName() == "Exit" and inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED \
  141.                 or inputClass.getData() == int(InputTypes.KB_RETURN) ):
  142.             print("2d sound should be stopping")
  143.             CyAudioGame().Destroy2DSound(self.iSoundID)
  144. #            CyInterface().stop2DSound()
  145.             screen.hideScreen()
  146.             import CvEventInterface
  147.             return 1
  148.         return 0
  149.     
  150.     def update(self, fDelta):
  151.         return