def convert_save(self):
        save = self.listbox.current_item()
        if save is None:
            return
        if not self._load_savegame(save):
            return
        # For ".sav" files, we end up creating a parallel ".s2" file and need
        # to clean up the ".sav" file manually.
        overwrites_in_place = False
        if sv.savegame_exists(save.name):
            if save.savegame_format.internal_version < 99.8:
                # We seem to be updating a ".sav" file but there is an ".s2"
                # file?  This should only happen to beta testers
                yn = dialog.YesNoDialog(
                    self,
                    pos=(-.5, -.5),
                    size=(-.5, -.5),
                    anchor=constants.MID_CENTER,
                    text=_(
                        "A savegame with the same name but for a newer version exists.\n"
                        "Are you sure to overwrite the saved game ?"))
                overwrite = dialog.call_dialog(yn, self)
                if not overwrite:
                    return
            else:
                # Saving will override in place;
                overwrites_in_place = True

        sv.create_savegame(save.name)
        if not overwrites_in_place:
            sv.delete_savegame(save)
        self.reload_savegames()
Esempio n. 2
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)
Esempio n. 3
0
    def save_game(self):
        # If no savename was set yet, use current difficulty
        if not sv.last_savegame_name:
            sv.last_savegame_name = g.strip_hotkey(g.pl.difficulty.name)
        self.savename_dialog.default_text = sv.last_savegame_name
        self.savename_dialog.add_handler(constants.KEYUP, self.check_filename)
        self.savename_dialog.text_field.has_focus = True

        name = dialog.call_dialog(self.savename_dialog, self).strip()
        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:
                    self.save_game()

            sv.create_savegame(name)
            raise constants.ExitDialog(False)