Changeset 641


Ignore:
Timestamp:
08/10/10 16:00:10 (9 years ago)
Author:
beliar
Message:

Patch by Beliar

  • The State of the PlayerCharacter? is now saved and stored correctly when changing a map. This fixes that the game "forgot" what npcs the character has already met.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/gamescenecontroller.py

    r640 r641  
    1515#   You should have received a copy of the GNU General Public License 
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
     17"""This file contains the GameSceneController that handles  
     18input when the game is exploring a scene""" 
     19 
    1720 
    1821from datetime import datetime 
     
    224227        self.updateMouse(evt.getX(), evt.getY()) 
    225228     
    226     def updateMouse(self, mouseX, mouseY): 
     229    def updateMouse(self, mouse_x, mouse_y): 
    227230        """Updates the mouse values 
    228231        @param mouseX: X-Position of mouse 
     
    233236            return 
    234237         
    235         self.last_mousecoords = fife.ScreenPoint(mouseX, mouseY)         
     238        self.last_mousecoords = fife.ScreenPoint(mouse_x, mouse_y)         
    236239        self.view.highlightFrontObject(self.last_mousecoords)        
    237240         
     
    239242        pixle_edge = 20 
    240243         
    241         mouse_x = self.last_mousecoords.x 
    242244        screen_width = self.model.engine.getSettings().getScreenWidth() 
    243         mouse_y = self.last_mousecoords.y 
    244245        screen_height = self.model.engine.getSettings().getScreenHeight() 
    245246         
     
    283284        """ 
    284285        if self.model.map_change: 
     286            self.pause(True) 
    285287            if self.model.active_map: 
     288                player_char = self.model.game_state.player_character 
     289                self.model.game_state.player_character = None 
     290                pc_agent = self.model.agents[self.model.ALL_AGENTS_KEY]\ 
     291                                                ["PlayerCharacter"] 
     292                pc_agent.update(player_char.getStateForSaving()) 
     293                pc_agent["Map"] = self.model.target_map_name  
     294                pc_agent["Position"] = self.model.target_position 
     295                pc_agent["Inventory"] = \ 
     296                        player_char.inventory.serializeInventory() 
    286297                player_agent = self.model.active_map.\ 
    287298                                    agent_layer.getInstance("PlayerCharacter") 
    288299                self.model.active_map.agent_layer.deleteInstance(player_agent) 
    289                 player_char = self.model.game_state.player_character 
    290                 self.model.game_state.player_character = None 
    291                 pc_agent = self.model.agents[self.model.ALL_AGENTS_KEY]\ 
    292                                                 ["PlayerCharacter"]  
    293                 pc_agent["Map"] = self.model.target_map_name  
    294                 pc_agent["Position"] = self.model.target_position 
    295                 pc_agent["Inventory"] = player_char.inventory.serializeInventory() 
    296300            self.model.loadMap(self.model.target_map_name) 
    297301            self.model.setActiveMap(self.model.target_map_name)           
     
    306310            self.view.hud.inventory = None 
    307311            self.view.hud.initializeInventory()          
    308                          
     312            self.pause(False) 
     313 
    309314    def nullFunc(self, userdata): 
    310315        """Sample callback for the context menus.""" 
     
    343348            else: 
    344349                actions.append(["Examine", "Examine", 
    345                                 self.model.game_state.player_character.approach,  
     350                                self.model.game_state.\ 
     351                                player_character.approach,  
    346352                                [obj.X, obj.Y], 
    347                                 ExamineAction(self, obj_id, obj.name, obj.text)]) 
     353                                ExamineAction(self,  
     354                                              obj_id, obj.name,  
     355                                              obj.text)]) 
    348356                # is it a Door? 
    349357                if obj.trueAttr("door"): 
     
    407415     
    408416    def pause(self, paused): 
     417        """Pauses the controller""" 
    409418        super(GameSceneController, self).pause(paused) 
    410419        self.paused = paused 
     
    422431            self.view.highlightFrontObject(self.last_mousecoords) 
    423432            self.view.refreshTopLayerTransparencies() 
    424             if self.scroll_direction != [0,0]: 
     433            if self.scroll_direction != [0, 0]: 
    425434                self.scroll_timer.start() 
    426435            else:  
Note: See TracChangeset for help on using the changeset viewer.