Savegame refactoring: Removes some more references to dialogs.hpp.
This commit is contained in:
parent
61e25db590
commit
9678bd35f1
4 changed files with 16 additions and 20 deletions
|
@ -240,15 +240,6 @@ void show_objectives(game_display& disp, const config& level, const std::string&
|
|||
).show();
|
||||
}
|
||||
|
||||
bool is_illegal_file_char(char c)
|
||||
{
|
||||
return c == '/' || c == '\\' || c == ':'
|
||||
#ifdef _WIN32
|
||||
|| c == '?' || c == '|' || c == '<' || c == '>' || c == '*' || c == '"'
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
/** Class to handle deleting a saved game. */
|
||||
|
|
|
@ -51,9 +51,6 @@ bool animate_unit_advancement(unit_map& units, map_location loc, game_display& g
|
|||
|
||||
void show_objectives(game_display& disp, const config& level, const std::string& objectives);
|
||||
|
||||
/** check if a character is valid for a filename. */
|
||||
bool is_illegal_file_char(char c);
|
||||
|
||||
/**
|
||||
* Allow user to select the game they want to load. Returns the name of the
|
||||
* save they want to load. Stores whether the user wants to show a replay of
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "savegame.hpp"
|
||||
|
||||
#include "dialogs.hpp"
|
||||
#include "dialogs.hpp" //FIXME: get rid of this as soon as the two remaining dialogs are moved to gui2
|
||||
#include "foreach.hpp"
|
||||
#include "game_end_exceptions.hpp"
|
||||
#include "game_events.hpp"
|
||||
|
@ -391,9 +391,7 @@ void loadgame::check_version_compatibility()
|
|||
// do not load if too old, if either the savegame or the current game
|
||||
// has the version 'test' allow loading
|
||||
if(!game_config::is_compatible_savegame_version(gamestate_.version)) {
|
||||
/* GCC-3.3 needs a temp var otherwise compilation fails */
|
||||
gui::message_dialog dlg(gui_, "", _("This save is from a version too old to be loaded."));
|
||||
dlg.show();
|
||||
gui2::show_message(gui_.video(), "", _("This save is from a version too old to be loaded."));
|
||||
throw load_game_cancelled_exception();
|
||||
}
|
||||
|
||||
|
@ -446,9 +444,7 @@ void loadgame::load_multiplayer_game()
|
|||
}
|
||||
|
||||
if(gamestate_.campaign_type != "multiplayer") {
|
||||
/* GCC-3.3 needs a temp var otherwise compilation fails */
|
||||
gui::message_dialog dlg(gui_, "", _("This is not a multiplayer save"));
|
||||
dlg.show();
|
||||
gui2::show_message(gui_.video(), "", _("This is not a multiplayer save"));
|
||||
throw load_game_cancelled_exception();
|
||||
}
|
||||
|
||||
|
@ -576,10 +572,19 @@ void savegame::check_filename(const std::string& filename, CVideo& video)
|
|||
}
|
||||
}
|
||||
|
||||
bool savegame::is_illegal_file_char(char c)
|
||||
{
|
||||
return c == '/' || c == '\\' || c == ':'
|
||||
#ifdef _WIN32
|
||||
|| c == '?' || c == '|' || c == '<' || c == '>' || c == '*' || c == '"'
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
void savegame::set_filename(std::string filename)
|
||||
{
|
||||
filename.erase(std::remove_if(filename.begin(), filename.end(),
|
||||
dialogs::is_illegal_file_char), filename.end());
|
||||
is_illegal_file_char), filename.end());
|
||||
filename_ = filename;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,9 @@ protected:
|
|||
virtual void before_save();
|
||||
|
||||
private:
|
||||
/** Checks if a certain character is allowed in a savefile name. */
|
||||
static bool is_illegal_file_char(char c);
|
||||
|
||||
/** Build the filename according to the specific savegame's needs. Subclasses will have to
|
||||
override this to take effect. */
|
||||
virtual void create_filename() {}
|
||||
|
|
Loading…
Add table
Reference in a new issue