def created(self):
     loader = self.loader.subApplication
     self.startFrame = loader.startFrame
     self.width = loader.width
     self.height = loader.height
     self.options = loader.options
     self.dockedPosition = loader.getDockedPosition()
     if self.options['Internal'] and self.startFrame != self.player.frameIndex:
         self.gamePlayer = GamePlayer(self.player.gameData, self)
     else:
         self.load_file(loader.name)
     self.player.clock.schedule(self.update)
 def load_file(self, name):
     try:
         reader = ByteReader(open(name, 'rb'))
     except IOError:
         return
     
     extension = name.split('.')[-1]
             
     if extension == 'ccn':
         gameData = GameData(reader, loadImages = True,
             delayedLoad = False)
     elif extension == 'ccj':
         gameData = GameData(reader, loadImages = True,
             delayedLoad = False, java = True)
     else:
         return
         
     self.gamePlayer = GamePlayer(gameData, self)
class SubApplication(ObjectPlayer):
    paused = False
    gamePlayer = None
    def created(self):
        loader = self.loader.subApplication
        self.startFrame = loader.startFrame
        self.width = loader.width
        self.height = loader.height
        self.options = loader.options
        self.dockedPosition = loader.getDockedPosition()
        if self.options['Internal'] and self.startFrame != self.player.frameIndex:
            self.gamePlayer = GamePlayer(self.player.gameData, self)
        else:
            self.load_file(loader.name)
        self.player.clock.schedule(self.update)
    
    def load_file(self, name):
        try:
            reader = ByteReader(open(name, 'rb'))
        except IOError:
            return
        
        extension = name.split('.')[-1]
                
        if extension == 'ccn':
            gameData = GameData(reader, loadImages = True,
                delayedLoad = False)
        elif extension == 'ccj':
            gameData = GameData(reader, loadImages = True,
                delayedLoad = False, java = True)
        else:
            return
            
        self.gamePlayer = GamePlayer(gameData, self)
    
    def get_global_string(self, index):
        if self.gamePlayer is None:
            return ''
        return self.gamePlayer.globals.get_string(index - 1)
    
    def get_global_value(self, index):
        if self.gamePlayer is None:
            return 0
        return self.gamePlayer.globals.get_value(index - 1)
        
    def get_frame(self):
        if self.gamePlayer is None:
            return 0
        return self.gamePlayer.frameIndex + 1
    
    def update(self, sinceLast):
        if self.paused or self.gamePlayer is None:
            return
        self.gamePlayer.update(sinceLast)
    
    def restart(self):
        if self.gamePlayer is None:
            return
        self.gamePlayer.set_frame(self.startFrame)
    
    def draw(self):
        if self.gamePlayer is None or self.gamePlayer.finished:
            return
        player = self.player
        glPushMatrix()
        glTranslatef(self.x, self.y - self.height, 0)
        self.gamePlayer.draw()
        glPopMatrix()
Esempio n. 4
0
                        delayedLoad = DELAYED_LOAD, java = True)
                        
                elif extension == 'ccf':
                    gameData = GameData(reader, loadImages = LOAD_IMAGES,
                        delayedLoad = DELAYED_LOAD, java = True, flash = True)

            elif frozen:
                application_path = 'Application.ccp'
                reader = ByteReader(open(application_path, 'rb'))
                gameData = GameData(reader, loadImages = LOAD_IMAGES,
                    delayedLoad = DELAYED_LOAD)
            else:
                print 'Exiting.'
                raise SystemExit()
    
            newPlayer = GamePlayer(gameData)
            
            if not frozen:
                path = sys.argv[1]
                if extension != 'exe' and os.path.isfile(gameData.editorFilename):
                    path = gameData.editorFilename
                if path is not None:
                    newDirectory = os.path.dirname(path)
                    if newDirectory:
                        sys.path.append(newDirectory)
                        try:
                            os.chdir(newDirectory)
                        except OSError:
                            pass
            
            if PROFILE: