class EditorSession(Session): def __init__(self, *args, **kwargs): kwargs['ingame_gui_class'] = IngameGui super(EditorSession, self).__init__(*args, **kwargs) self.world_editor = None def create_manager(self): return SPManager(self) def create_rng(self, seed=None): return random.Random() def create_timer(self): return Timer() def load(self, *args, **kwargs): super(EditorSession, self).load(*args, **kwargs) self.world_editor = WorldEditor(self.world) self.ingame_gui.setup() # editor "games" start right away self.start() def autosave(self): # TODO see issue 1935 pass def quicksave(self): # TODO see issue 1935 pass def save(self, name): self.world_editor.save_map(PATHS.USER_MAPS_DIR, name)
class EditorSession(Session): def __init__(self, *args, **kwargs): kwargs['ingame_gui_class'] = IngameGui super().__init__(*args, **kwargs) self.world_editor = None def create_manager(self): return SPManager(self) def create_rng(self, seed=None): return random.Random() def create_timer(self): return Timer() def load(self, *args, **kwargs): super().load(*args, **kwargs) self.world_editor = WorldEditor(self.world) self.ingame_gui.setup() # editor "games" start right away self.start() def autosave(self): """Called automatically in an interval""" self.log.debug("Session: autosaving map") success = self.world_editor.save_map(PATHS.USER_MAPS_DIR, 'autosave') if success: self.ingame_gui.message_widget.add('AUTOSAVE') def quicksave(self): """Called when user presses the quicksave hotkey""" self.log.debug("Session: quicksaving map") success = self.world_editor.save_map(PATHS.USER_MAPS_DIR, 'quicksave') if success: self.ingame_gui.message_widget.add('QUICKSAVE') else: headline = T("Failed to quicksave.") descr = T("An error happened during quicksave.") + "\n" + T( "Your map has not been saved.") advice = T( "If this error happens again, please contact the development team: " "{website}").format( website="http://unknown-horizons.org/support/") self.ingame_gui.open_error_popup(headline, descr, advice) def save(self, savegamename, players_recommended): success = self.world_editor.save_map(PATHS.USER_MAPS_DIR, savegamename, players_recommended) return success
class EditorSession(Session): def __init__(self, *args, **kwargs): kwargs['ingame_gui_class'] = IngameGui super(EditorSession, self).__init__(*args, **kwargs) self.world_editor = None def create_manager(self): return SPManager(self) def create_rng(self, seed=None): return random.Random() def create_timer(self): return Timer() def load(self, *args, **kwargs): super(EditorSession, self).load(*args, **kwargs) self.world_editor = WorldEditor(self.world) self.ingame_gui.setup() # editor "games" start right away self.start() def autosave(self): """Called automatically in an interval""" self.log.debug("Session: autosaving map") success = self.world_editor.save_map(PATHS.USER_MAPS_DIR, 'autosave') if success: self.ingame_gui.message_widget.add('AUTOSAVE') def quicksave(self): """Called when user presses the quicksave hotkey""" self.log.debug("Session: quicksaving map") success = self.world_editor.save_map(PATHS.USER_MAPS_DIR, 'quicksave') if success: self.ingame_gui.message_widget.add('QUICKSAVE') else: headline = _("Failed to quicksave.") descr = _("An error happened during quicksave.") + u"\n" + _("Your map has not been saved.") #xgettext:python-format advice = _("If this error happens again, please contact the development team: " "{website}").format(website="http://unknown-horizons.org/support/") self.gui.show_error_popup(headline, descr, advice) def save(self, savegamename): success = self.world_editor.save_map(PATHS.USER_MAPS_DIR, savegamename) return success
def _edit_map(map_file): """ Start editing the specified map file. @param map_file: path to the map file or a list of random island strings @return: bool, whether loading succeeded """ if not map_file: return False options = StartGameOptions.create_editor_load(map_file) start_singleplayer(options) from horizons.editor.worldeditor import WorldEditor _modules.session.world_editor = WorldEditor(_modules.session.world) return True
def load(self, *args, **kwargs): super(EditorSession, self).load(*args, **kwargs) self.world_editor = WorldEditor(self.world) self.ingame_gui.setup() # editor "games" start right away self.start()