On scenario victory, the code now tries to clean up *all* old savegames...
...rather than just autosaves. The start-of-scenario save is exempted, and cleanup is done before replay save if that is enabled. The preference to control this deletion behavior is now delete_saves rather than delete_autosaves.
This commit is contained in:
parent
cb373e270c
commit
00732a7789
6 changed files with 37 additions and 29 deletions
|
@ -36,6 +36,11 @@ Version 1.3.9+svn:
|
|||
* new key "contains=" in [variable] conditions to check the presence of a
|
||||
substring in a variable value
|
||||
* maps now have a user definable border
|
||||
* Changed the mute hotkey from ctrl-m to ctrl-alt-m.
|
||||
* On victory, all old saves for the scenario except the start one
|
||||
are now deleted (rather than just autosaves as formerly). This
|
||||
is done before replay saving, if that is enabled. The preference
|
||||
name has changed from delete_autosaves to delete_saves.
|
||||
* miscellaneous and bug fixes:
|
||||
|
||||
Version 1.3.9:
|
||||
|
|
|
@ -30,6 +30,10 @@ Version 1.3.9+svn:
|
|||
|
||||
* User interface
|
||||
* Changed the mute hotkey from ctrl-m to ctrl-alt-m.
|
||||
* On victory, all old saves for the scenario except the start one
|
||||
are now deleted (rather than just autosaves as formerly). This
|
||||
is done before replay saving, if that is enabled. The preference
|
||||
name has changed from delete_autosaves to delete_saves.
|
||||
|
||||
Version 1.3.9:
|
||||
* Campaigns
|
||||
|
|
|
@ -425,14 +425,14 @@ bool save_replays()
|
|||
return utils::string_bool(preferences::get("save_replays"), true);
|
||||
}
|
||||
|
||||
void set_delete_autosaves(bool value)
|
||||
void set_delete_saves(bool value)
|
||||
{
|
||||
preferences::set("delete_autosaves", value ? "yes" : "no");
|
||||
preferences::set("delete_saves", value ? "yes" : "no");
|
||||
}
|
||||
|
||||
bool delete_autosaves()
|
||||
bool delete_saves()
|
||||
{
|
||||
return utils::string_bool(preferences::get("delete_autosaves"), false);
|
||||
return utils::string_bool(preferences::get("delete_saves"), false);
|
||||
}
|
||||
|
||||
void set_ask_delete_saves(bool value)
|
||||
|
|
|
@ -128,8 +128,8 @@ namespace preferences {
|
|||
bool save_replays();
|
||||
void set_save_replays(bool value);
|
||||
|
||||
bool delete_autosaves();
|
||||
void set_delete_autosaves(bool value);
|
||||
bool delete_saves();
|
||||
void set_delete_saves(bool value);
|
||||
|
||||
void set_ask_delete_saves(bool value);
|
||||
bool ask_delete_saves();
|
||||
|
|
|
@ -106,7 +106,7 @@ private:
|
|||
buffer_size_slider_, idle_anim_slider_, savemax_slider_;
|
||||
gui::list_slider<double> turbo_slider_;
|
||||
gui::button fullscreen_button_, turbo_button_, show_ai_moves_button_,
|
||||
show_grid_button_, save_replays_button_, delete_autosaves_button_,
|
||||
show_grid_button_, save_replays_button_, delete_saves_button_,
|
||||
show_lobby_joins_button1_,
|
||||
show_lobby_joins_button2_,
|
||||
show_lobby_joins_button3_,
|
||||
|
@ -160,8 +160,8 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
|
|||
turbo_button_(disp.video(), _("Accelerated Speed"), gui::button::TYPE_CHECK),
|
||||
show_ai_moves_button_(disp.video(), _("Skip AI Moves"), gui::button::TYPE_CHECK),
|
||||
show_grid_button_(disp.video(), _("Show Grid"), gui::button::TYPE_CHECK),
|
||||
save_replays_button_(disp.video(), _("Save Replays"), gui::button::TYPE_CHECK),
|
||||
delete_autosaves_button_(disp.video(), _("Delete Autosaves"), gui::button::TYPE_CHECK),
|
||||
save_replays_button_(disp.video(), _("Save Replay on Victory"), gui::button::TYPE_CHECK),
|
||||
delete_saves_button_(disp.video(), _("Delete Saves on Victory"), gui::button::TYPE_CHECK),
|
||||
show_lobby_joins_button1_(disp.video(), _("Do Not Show Lobby Joins"), gui::button::TYPE_CHECK),
|
||||
show_lobby_joins_button2_(disp.video(), _("Show Lobby Joins Of Friends Only"), gui::button::TYPE_CHECK),
|
||||
show_lobby_joins_button3_(disp.video(), _("Show All Lobby Joins"), gui::button::TYPE_CHECK),
|
||||
|
@ -341,8 +341,8 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
|
|||
save_replays_button_.set_check(save_replays());
|
||||
save_replays_button_.set_help_string(_("Save replays at scenario end."));
|
||||
|
||||
delete_autosaves_button_.set_check(delete_autosaves());
|
||||
delete_autosaves_button_.set_help_string(_("Automatically delete autosaves at the end of a scenario"));
|
||||
delete_saves_button_.set_check(delete_saves());
|
||||
delete_saves_button_.set_help_string(_("Automatically delete saves on victory"));
|
||||
show_grid_button_.set_check(grid());
|
||||
show_grid_button_.set_help_string(_("Overlay a grid onto the map"));
|
||||
|
||||
|
@ -417,7 +417,7 @@ handler_vector preferences_dialog::handler_members()
|
|||
h.push_back(&idle_anim_button_);
|
||||
h.push_back(&show_ai_moves_button_);
|
||||
h.push_back(&save_replays_button_);
|
||||
h.push_back(&delete_autosaves_button_);
|
||||
h.push_back(&delete_saves_button_);
|
||||
h.push_back(&show_grid_button_);
|
||||
h.push_back(&sort_list_by_group_button_);
|
||||
h.push_back(&iconize_list_button_);
|
||||
|
@ -507,7 +507,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
ypos += item_interline; show_team_colours_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline; show_grid_button_.set_location(rect.x, ypos);
|
||||
ypos += item_interline; save_replays_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline; delete_autosaves_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline; delete_saves_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline; savemax_slider_label_.set_location(rect.x, ypos);
|
||||
SDL_Rect savemax_rect = { rect.x, ypos+short_interline,
|
||||
rect.w - right_border, 0};
|
||||
|
@ -665,8 +665,8 @@ void preferences_dialog::process_event()
|
|||
set_grid(show_grid_button_.checked());
|
||||
if (save_replays_button_.pressed())
|
||||
set_save_replays(save_replays_button_.checked());
|
||||
if (delete_autosaves_button_.pressed())
|
||||
set_delete_autosaves(delete_autosaves_button_.checked());
|
||||
if (delete_saves_button_.pressed())
|
||||
set_delete_saves(delete_saves_button_.checked());
|
||||
if (turn_dialog_button_.pressed())
|
||||
set_turn_dialog(turn_dialog_button_.checked());
|
||||
if (show_team_colours_button_.pressed())
|
||||
|
@ -1019,7 +1019,7 @@ void preferences_dialog::set_selection(int index)
|
|||
show_team_colours_button_.hide(hide_general);
|
||||
show_grid_button_.hide(hide_general);
|
||||
save_replays_button_.hide(hide_general);
|
||||
delete_autosaves_button_.hide(hide_general);
|
||||
delete_saves_button_.hide(hide_general);
|
||||
savemax_slider_label_.hide(hide_general);
|
||||
savemax_slider_label_.enable(!hide_general);
|
||||
//savemax_slider_.hide(hide_general);
|
||||
|
|
|
@ -100,13 +100,14 @@ void play_replay(display& disp, game_state& gamestate, const config& game_config
|
|||
}
|
||||
}
|
||||
|
||||
static void clean_autosaves(const std::string &label)
|
||||
static void clean_saves(const std::string &label)
|
||||
{
|
||||
std::vector<save_info> games = get_saves_list();
|
||||
std::string prefix = label + "-" + _("Auto-Save");
|
||||
std::cerr << "Cleaning autosaves with prefix '" << prefix << "'\n";
|
||||
std::cerr << "Cleaning saves with prefix '" << label << "'\n";
|
||||
for (std::vector<save_info>::iterator i = games.begin(); i != games.end(); i++) {
|
||||
if (i->name.compare(0,prefix.length(),prefix) == 0) {
|
||||
if (i->name.compare(0,i->name.length(),label) == 0)
|
||||
continue; // Never delete scenario-start saves
|
||||
if (i->name.compare(0,label.length(),label) == 0) {
|
||||
std::cerr << "Deleting autosave '" << i->name << "'\n";
|
||||
delete_game(i->name);
|
||||
}
|
||||
|
@ -377,18 +378,16 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
|
|||
|
||||
gamestate.snapshot = config();
|
||||
|
||||
// Temporary fix:
|
||||
// Only apply preferences for replays and autosave
|
||||
// deletes on victory.
|
||||
//! @todo We need to rethink what this code should be doing.
|
||||
// Only apply prefs for deleting old savegames and
|
||||
// saving replays on victory.
|
||||
if(res == VICTORY) {
|
||||
const std::string orig_scenario = gamestate.scenario;
|
||||
gamestate.scenario = current_scenario;
|
||||
|
||||
std::string label = gamestate.label + _(" replay");
|
||||
if (preferences::delete_autosaves())
|
||||
clean_autosaves(gamestate.label);
|
||||
if (preferences::delete_saves())
|
||||
clean_saves(gamestate.label);
|
||||
|
||||
std::string label = gamestate.label + _(" replay");
|
||||
if(preferences::save_replays()) {
|
||||
try {
|
||||
config snapshot;
|
||||
|
@ -561,8 +560,8 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
|
|||
}
|
||||
|
||||
if (gamestate.campaign_type == "scenario"){
|
||||
if (preferences::delete_autosaves())
|
||||
clean_autosaves(gamestate.label);
|
||||
if (preferences::delete_saves())
|
||||
clean_saves(gamestate.label);
|
||||
}
|
||||
return VICTORY;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue