コード例 #1
0
 def initMapLoading(self, name):
     # Check if there are MapProperties for this map by looking into the
     # savegame dict object.
     shelf = get_savegame()
     try:
         # Dictionary of saved map properties
         saveds = shelf['saved_maps']
         # Properties of this particular map
         properties = saveds[name]
     except KeyError:
         # No properties found
         properties = None
     # If this map hasn't been loaded yet, do so and place it inside the map dict
     if not MapFactory.mapAlreadyLoaded(name):
         # Map is loading. Change game state and notify other controllers
         # that a loading process is going on right now
         self.state = STATE_GAME_MAP_LOADING
         self.evManager.post(GameStateChangedEvent(self.state))
         
         MapFactory.loadMap(name, properties)
     else:
         # If it has already been loaded, change the map on your own
         # (no need for a 1-frame loading screen, amirite?)
         m = MapFactory.getMap(name)
         if properties is not None:
             m.setInteractives(properties.scripts, properties.objects)
         method = m.init_method
         self.changeMap(m, method)