Mercurial > parpg-source
comparison gamescenecontroller.py @ 101:824f3068ef2a
Fixed Saving and Loading.
author | KarstenBock@gmx.net |
---|---|
date | Thu, 29 Sep 2011 18:09:56 +0200 |
parents | 485d866a847f |
children | c9afad46091b |
comparison
equal
deleted
inserted
replaced
100:485d866a847f | 101:824f3068ef2a |
---|---|
334 player_char = self.model.game_state.\ | 334 player_char = self.model.game_state.\ |
335 getObjectById("PlayerCharacter").fifeagent | 335 getObjectById("PlayerCharacter").fifeagent |
336 pc_agent = self.model.agents\ | 336 pc_agent = self.model.agents\ |
337 [self.model.ALL_AGENTS_KEY]["PlayerCharacter"] | 337 [self.model.ALL_AGENTS_KEY]["PlayerCharacter"] |
338 pc_agent["Map"] = self.model.target_map_name | 338 pc_agent["Map"] = self.model.target_map_name |
339 pc_agent["Position"] = self.model.target_position | 339 pc_agent["Position"] = (self.model.target_position or |
340 pc_agent["Position"]) | |
340 player_agent = self.model.active_map.\ | 341 player_agent = self.model.active_map.\ |
341 agent_layer.getInstance("PlayerCharacter") | 342 agent_layer.getInstance("PlayerCharacter") |
342 self.model.game_state.deleteObject("PlayerCharacter") | 343 self.model.game_state.deleteObject("PlayerCharacter").delete() |
343 self.model.game_state.deleteObjectsFromMap( | 344 deleted = self.model.game_state.deleteObjectsFromMap( |
344 self.model.game_state.current_map_name | 345 self.model.game_state.current_map_name |
345 ) | 346 ) |
346 self.model.game_state.deleteObjectsFromMap(None) | 347 deleted.extend( |
348 self.model.game_state.deleteObjectsFromMap(None) | |
349 ) | |
350 for obj in deleted: | |
351 obj.delete() | |
347 | 352 |
348 self.model.loadMap(self.model.target_map_name) | 353 self.model.loadMap(self.model.target_map_name) |
349 | 354 |
350 self.model.setActiveMap(self.model.target_map_name) | 355 self.model.setActiveMap(self.model.target_map_name) |
351 self.model.readAgentsOfMap(self.model.target_map_name) | 356 self.model.readAgentsOfMap(self.model.target_map_name) |
479 PickUpAction(self, obj)]) | 484 PickUpAction(self, obj)]) |
480 | 485 |
481 return actions | 486 return actions |
482 | 487 |
483 def saveGame(self, *args, **kwargs): | 488 def saveGame(self, *args, **kwargs): |
484 """Saves the game state, delegates call to engine.Engine | 489 """Saves the game state, delegates call to gamemodel.GameModel |
485 @return: None""" | 490 @return: None""" |
486 self.model.pause(False) | 491 self.model.pause(False) |
487 self.pause(False) | 492 self.pause(False) |
488 self.view.hud.enabled = True | 493 self.view.hud.enabled = True |
494 self.model.updateObjectDB(self) | |
489 self.model.save(*args, **kwargs) | 495 self.model.save(*args, **kwargs) |
490 | 496 |
491 def loadGame(self, *args, **kwargs): | 497 def loadGame(self, *args, **kwargs): |
492 """Loads the game state, delegates call to engine.Engine | 498 """Loads the game state, delegates call to gamemodel.GameModel |
493 @return: None""" | 499 @return: None""" |
494 # Remove all currently loaded maps so we can start fresh | 500 # Remove all currently loaded maps so we can start fresh |
495 self.model.pause(False) | 501 self.model.pause(False) |
496 self.pause(False) | 502 self.pause(False) |
497 self.view.hud.enabled = True | 503 self.view.hud.enabled = True |
498 self.model.deleteMaps() | 504 self.model.deleteMaps() |
505 for entity in self.entities.copy(): | |
506 entity.delete() | |
499 self.view.hud.inventory = None | 507 self.view.hud.inventory = None |
500 | 508 |
501 self.model.load(*args, **kwargs) | 509 self.model.load(*args, **kwargs) |
510 # Load the current map | |
511 if self.model.game_state.current_map_name: | |
512 self.model.loadMap(self.model.game_state.current_map_name) | |
513 self.model.placeAgents(self) | |
514 self.model.placePC(self) | |
502 self.view.hud.initializeInventory() | 515 self.view.hud.initializeInventory() |
503 | 516 |
504 def quitGame(self): | 517 def quitGame(self): |
505 """Quits the game | 518 """Quits the game |
506 @return: None""" | 519 @return: None""" |