def global_inits(self, m, handlerAv=False):
     GlobalServices.getEventManager().post(ObjectHighlightedEvent(None))
     # Check if the current global overlays are already equivalent to the map's ones
     if m.overlays != get_global_overlays():
         # Remove overlays
         m.clearOverlays()
         # Add global overlays
         for o in get_global_overlays():
             m.addOverlay(o)
         m.flushOverlayQueue()
     # If no other handler init method is attached to this init,
     # this method does the enabling of map rendering (so that you can see stuff)
     if not handlerAv:
         m.rendering_enabled = True
Exemplo n.º 2
0
 def save(self, disp=False):                
     # Get the savegame data
     temp = get_savegame()
     # Open the "real" shelf (the one the player can load up again)!
     save = shelve.open(CURRENT_SHELF_FILENAME[0])
     
     # Save persistent data that needs to be stored in order to retrieve the game state.
     # All data that is used to do that is actually the player's current position,
     # the current map where this position applies, and the currently playing background
     # music.
     # Pre-defined keys for the dict
     save['player_position'] = self.player.position
     save['current_map'] = self.currentmap.properties['key_name']
     save['player_inventory'] = self.player.inventory
     save['current_sounds'] = GlobalServices.getAudioDevice().getPlayingSounds()
     
     temp['global_overlays'] = get_global_overlays()
     
     # Update the persistent map properties for the current map
     update_persistent_map_properties(self.currentmap, temp)
     # Copy the rest of the shelf data to the "correct" save file
     copy_to_shelve(temp, save)
     
     # Close the shelves again; that's it!
     save.close()
     
     if disp:
         # Display the optional success message using the TextRenderer module
         tr = GlobalServices.getTextRenderer()
         tr.write("Game saved.", 3)