def ok(self): path = self.pathname if os.path.exists(path): answer = ask("Replace existing '%s'?" % os.path.basename(path)) if answer <> "OK": return FileDialog.ok(self)
def ask_save_progress(self): """If there is unsaved game progress, ask the user whether to save it, and if the answer is yes, do so. Reports errors to the user. Raises Cancel if cancelled or an error occurred.""" if self.game.game_needs_saving(): resp = ask("Save game progress?", ["Yes", "No", "Cancel"]) if resp == "Cancel": raise Cancel if resp == "Yes": self.save_game(prompt = True)
def ask_save_progress(self): """If there is unsaved game progress, ask the user whether to save it, and if the answer is yes, do so. Reports errors to the user. Raises Cancel if cancelled or an error occurred.""" if self.game.game_needs_saving(): resp = ask("Save game progress?", ["Yes", "No", "Cancel"]) if resp == "Cancel": raise Cancel if resp == "Yes": self.save_game(prompt=True)
def ask_save_level(self): """If there are unsaved changes to a level, ask the user whether to save it, and if the answer is yes, do so. Reports errors to the user. Raises Cancel if cancelled or an error occurred.""" if self.game.level_needs_saving: resp = ask("Save changes to level?", ["Yes", "No", "Cancel"]) if resp == "Cancel": raise Cancel if resp == "Yes": self.save_level_cmd()
def ask_quit(self): """Make sure user really wants quit the game. Raises Cancel if cancelled or an error occurred.""" if not ask("Quit the game?") == "OK": raise Cancel
def look_for_level_set(self, orig_path): name = os.path.basename(orig_path) prompt = "Can't find '%s'. Would you like to look for it?" % name if ask(prompt, ["Yes", "No"]) == "Yes": return look_for_file_or_directory(name)