Exemple #1
0
    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))
Exemple #3
0
    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)
Exemple #4
0
 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)
Exemple #5
0
 def return_text(self, event=None):
     if event and event.type == pygame.KEYUP:
         return
     raise constants.ExitDialog(self.text_field.text)
Exemple #6
0
 def return_nothing(self, event=None):
     if event and event.type == pygame.KEYUP:
         return
     raise constants.ExitDialog("")
Exemple #7
0
 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)