def _save_hook(self, textbox: vpython.winput): try: common.write_savefile(self._state, common.savefile(textbox.text)) textbox.text = 'File saved!' except OSError: log.exception('Caught exception during file saving') textbox.text = 'Error writing file!'
def _save_hook(self, textbox: vpython.winput): full_path = common.savefile(textbox.text) try: full_path = common.write_savefile(self._last_state, full_path) textbox.text = f'Saved to {full_path}!' except OSError: log.exception('Caught exception during file saving') textbox.text = f'Error writing file to {full_path}'
def _load_hook(self, textbox: vpython.winput): full_path = common.savefile(textbox.text) if full_path.is_file(): self._commands.append( network.Request(ident=network.Request.LOAD_SAVEFILE, loadfile=textbox.text)) textbox.text = f'Loaded {full_path}!' else: log.warning(f'Ignored non-existent loadfile: {full_path}') textbox.text = f'{full_path} not found!'
def _load_hook(self, textbox: vpython.winput): full_path = common.savefile(textbox.text) if full_path.is_file(): self._commands.append( Request(ident=Request.LOAD_SAVEFILE, loadfile=textbox.text)) textbox.text = 'File loaded!' # The file we loaded will have a non-zero time acc, unpause. self.pause(False) # Re-centre on the habitat. self._sidebar.centre_menu._menu.selected = HABITAT self._recentre_dropdown_hook(self._sidebar.centre_menu._menu) else: log.warning(f'Ignored non-existent loadfile: {full_path}') textbox.text = 'File not found!'