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

  1. ## Sid Meier's Civilization 4
  2. ## Copyright Firaxis Games 2005
  3. from CvPythonExtensions import *
  4. import PyHelpers
  5. import CvUtil
  6. import ScreenInput
  7. import CvScreenEnums
  8. import string
  9.  
  10. PyPlayer = PyHelpers.PyPlayer
  11. PyInfo = PyHelpers.PyInfo
  12.  
  13. # globals
  14. gc = CyGlobalContext()
  15. ArtFileMgr = CyArtFileMgr()
  16. localText = CyTranslator()
  17.  
  18. MOVIE_SCREEN_WONDER = 0
  19. MOVIE_SCREEN_RELIGION = 1
  20. MOVIE_SCREEN_PROJECT = 2
  21.  
  22. class CvWonderMovieScreen:
  23.     "Wonder Movie Screen"
  24.  
  25.     def __init__(self):
  26.         self.fDelay = -1.0
  27.         self.fTime = 0.0
  28.  
  29.     def interfaceScreen (self, iMovieItem, iCityId, iMovieType):
  30.         # iMovieItem is either the WonderID, the ReligionID, or the ProjectID, depending on iMovieType
  31.         
  32.         self.Z_CONTROLS = -2.2
  33.  
  34.         self.X_SCREEN = 250
  35.         self.Y_SCREEN = 40
  36.         self.W_SCREEN = 760
  37.         self.H_SCREEN = 590
  38.         self.Y_TITLE = self.Y_SCREEN + 20
  39.         self.iWonderId = iMovieItem
  40.         
  41.         self.X_EXIT = self.X_SCREEN + self.W_SCREEN/2 - 50
  42.         self.Y_EXIT = self.Y_SCREEN + self.H_SCREEN - 50
  43.         self.W_EXIT = 120
  44.         self.H_EXIT = 30
  45.         
  46.         self.X_MOVIE = 20
  47.         self.Y_MOVIE = 50
  48.         self.W_MOVIE = 720
  49.         self.H_MOVIE = 480
  50.         
  51.         self.iMovieType = iMovieType
  52.         self.fTime = 0.0
  53.         self.fDelay = 1.
  54.         
  55.         # not all projects have movies
  56.         if self.iMovieType == MOVIE_SCREEN_PROJECT:
  57.             szArtDef = gc.getProjectInfo(iMovieItem).getMovieArtDef()
  58.             if len(szArtDef) == 0:
  59.                 return
  60.         
  61.         player = PyPlayer(CyGame().getActivePlayer())
  62.         
  63.         # move the camera and mark the interface camera as dirty so that it gets reset - JW
  64.         if self.iMovieType == MOVIE_SCREEN_WONDER:
  65.             CyInterface().lookAtCityBuilding(iCityId, iMovieItem)
  66.         else:
  67.             CyInterface().lookAtCityBuilding(iCityId, -1)
  68.         CyInterface().setDirty(InterfaceDirtyBits.SelectionCamera_DIRTY_BIT, True)
  69.         
  70.         screen = CyGInterfaceScreen( "WonderMovieScreen" + str(iMovieItem), CvScreenEnums.WONDER_MOVIE_SCREEN )
  71.         screen.addPanel("WonderMoviePanel", "", "", true, true,
  72.             self.X_SCREEN, self.Y_SCREEN, self.W_SCREEN, self.H_SCREEN, PanelStyles.PANEL_STYLE_MAIN)
  73.         
  74.         screen.showWindowBackground( True )
  75.         screen.setRenderInterfaceOnly(False)
  76.         screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)
  77.         screen.enableWorldSounds( false )
  78.                         
  79.         # Header...
  80.         szHeaderId = "WonderTitleHeader" + str(iMovieItem)
  81.         if self.iMovieType == MOVIE_SCREEN_RELIGION:
  82.             szHeader = localText.getText("TXT_KEY_MISC_REL_FOUNDED_MOVIE", (gc.getReligionInfo(iMovieItem).getTextKey(), ))
  83.         elif self.iMovieType == MOVIE_SCREEN_WONDER:
  84.             szHeader = gc.getBuildingInfo(iMovieItem).getDescription()
  85.         elif self.iMovieType == MOVIE_SCREEN_PROJECT:
  86.             szHeader = gc.getProjectInfo(iMovieItem).getDescription()
  87.  
  88.         screen.setText(szHeaderId, "Background", szHeader, CvUtil.FONT_CENTER_JUSTIFY,
  89.                 self.X_SCREEN + self.W_SCREEN / 2, self.Y_TITLE, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  90.                 
  91.         screen.hide("Background")
  92.  
  93.         screen.playMovie("", 0, 0, 0, 0, 0) # dummy call to hide screen if no movies are supposed to be shown
  94.  
  95.     def playMovie(self):
  96.             
  97.         screen = CyGInterfaceScreen( "WonderMovieScreen" + str(self.iWonderId), CvScreenEnums.WONDER_MOVIE_SCREEN )
  98.         screen.setRenderInterfaceOnly(True)
  99.         screen.show("Background")
  100.  
  101.         # Play the movie
  102.         if self.iMovieType == MOVIE_SCREEN_RELIGION:
  103.             screen.addReligionMovieWidgetGFC( "ReligionMovie", gc.getReligionInfo(self.iWonderId).getMovieFile(), self.X_SCREEN + self.X_MOVIE, self.Y_SCREEN + self.Y_MOVIE, self.W_MOVIE, self.H_MOVIE, WidgetTypes.WIDGET_GENERAL, -1, -1)
  104.             CyInterface().playGeneralSound(gc.getReligionInfo(self.iWonderId).getMovieSound())        
  105.         elif self.iMovieType == MOVIE_SCREEN_WONDER:        
  106.             screen.playMovie(gc.getBuildingInfo(self.iWonderId).getMovie(), self.X_SCREEN + self.X_MOVIE, self.Y_SCREEN + self.Y_MOVIE, self.W_MOVIE, self.H_MOVIE, -2.3 )
  107.         elif self.iMovieType == MOVIE_SCREEN_PROJECT:
  108.             szArtDef = gc.getProjectInfo(self.iWonderId).getMovieArtDef()
  109.             screen.playMovie(CyArtFileMgr().getMovieArtInfo(szArtDef).getPath(), self.X_SCREEN + self.X_MOVIE, self.Y_SCREEN + self.Y_MOVIE, self.W_MOVIE, self.H_MOVIE, -2.3 )
  110.             
  111.         screen.setButtonGFC("WonderExit" + str(self.iWonderId), localText.getText("TXT_KEY_MAIN_MENU_OK", ()), "", self.X_EXIT, self.Y_EXIT, self.W_EXIT, self.H_EXIT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
  112.  
  113.     # Will handle the input for this screen...
  114.     def handleInput (self, inputClass):
  115.         if (inputClass.getNotifyCode() == NotifyCode.NOTIFY_MOVIE_DONE):
  116.             screen = CyGInterfaceScreen( "WonderMovieScreen" + str(self.iWonderId), CvScreenEnums.WONDER_MOVIE_SCREEN )
  117.             if self.iMovieType == MOVIE_SCREEN_WONDER:
  118.                 szHelp = CyGameTextMgr().getBuildingHelp(self.iWonderId, False, False, False, None)
  119.             elif self.iMovieType == MOVIE_SCREEN_WONDER:
  120.                 szHelp = CyGameTextMgr().getProjectHelp(self.iWonderId, False, None)
  121.             else:
  122.                 szHelp = ""
  123.             
  124.             i = 0
  125.             if len(szHelp) > 0:
  126.                 splitText = string.split( szHelp, "\n" )
  127.                 y = self.Y_SCREEN + 100
  128.                 for szLine in splitText:
  129.                     if len( szLine ) != 0:
  130.                         szName = "MonkeyText" + str(i)
  131.                         screen.setText(szName, "", szLine, CvUtil.FONT_CENTER_JUSTIFY,
  132.                                 self.X_SCREEN + self.W_SCREEN / 2, y, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
  133.                         y += 20
  134.                         i += 1
  135.  
  136.         return 0
  137.  
  138.     def update(self, fDelta):
  139.     
  140.         if self.fDelay > 0:
  141.             self.fTime += fDelta
  142.             if self.fTime > self.fDelay:
  143.                 self.playMovie()
  144.                 self.fDelay = -1
  145.         return
  146.  
  147.