def finish(self): if 0 <= self.listbox.list_pos < len(self.key_list): type = self.key_list[self.listbox.list_pos] name = self.text_field.text if not name: name = generate_base_name(self.parent.location, type) raise constants.ExitDialog((name, type))
def get_name(self): if 0 <= self.listbox.list_pos < len(self.key_list): type = self.key_list[self.listbox.list_pos] self.name_dialog.default_text = \ generate_base_name(self.parent.location, type) name = dialog.call_dialog(self.name_dialog, self) if name: raise constants.ExitDialog((name, type))
def save_game(self): self.savename_dialog.default_text = sv.default_savegame_name name = dialog.call_dialog(self.savename_dialog, self) if name: if sv.savegame_exists(name): yn = dialog.YesNoDialog(self, pos=(-.5,-.5), size=(-.5,-.5), anchor=constants.MID_CENTER, text=_("A savegame with the same name exists.\n" "Are you sure to overwrite the saved game ?")) overwrite = dialog.call_dialog(yn, self) if not overwrite: return sv.create_savegame(name) raise constants.ExitDialog(False)
def load_game(self): did_load = dialog.call_dialog(self.load_dialog, self) if did_load: self._map_screen.force_update() raise constants.ExitDialog(False)
def return_text(self, event=None): if event and event.type == pygame.KEYUP: return raise constants.ExitDialog(self.text_field.text)
def return_nothing(self, event=None): if event and event.type == pygame.KEYUP: return raise constants.ExitDialog("")
def exit_dialog(self): """Closes the dialog with the given exit code.""" if self.exit_code_func: raise constants.ExitDialog(self.exit_code_func()) else: raise constants.ExitDialog(self.exit_code)