Savegame reorganization Step 1: a simpler interface to saving and loading.
Implement the savegame dialog for OoS messages.
This commit is contained in:
parent
44517c9804
commit
b539658983
6 changed files with 56 additions and 12 deletions
|
@ -136,8 +136,8 @@
|
|||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
size_text = _ "OK"
|
||||
label = _ "OK"
|
||||
size_text = _ "Yes"
|
||||
label = _ "Yes"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
@ -151,7 +151,7 @@
|
|||
id = "cancel"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Cancel"
|
||||
label = _ "No"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
|
|
@ -83,5 +83,23 @@ void tgame_save_message::pre_show(CVideo& video, twindow& window)
|
|||
tgame_save::pre_show(video, window);
|
||||
}
|
||||
|
||||
tgame_save_oos::tgame_save_oos(const std::string& title, const std::string& filename, const std::string& message)
|
||||
: tgame_save_message(title, filename, message),
|
||||
btnIgnoreAll_(register_bool("ignore_all", false)),
|
||||
ignore_all_(false)
|
||||
{}
|
||||
|
||||
twindow* tgame_save_oos::build_window(CVideo& video)
|
||||
{
|
||||
return build(video, get_id(GAME_SAVE_OOS));
|
||||
}
|
||||
|
||||
void tgame_save_oos::post_show(twindow& window)
|
||||
{
|
||||
tgame_save::post_show(window);
|
||||
|
||||
ignore_all_ = btnIgnoreAll_->get_widget_value(window);
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
|
|
|
@ -31,13 +31,12 @@ protected:
|
|||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
private:
|
||||
/** Inherited from tdialog. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(twindow& window);
|
||||
|
||||
private:
|
||||
/** Inherited from tdialog. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
tfield_text* txtFilename_;
|
||||
std::string title_;
|
||||
|
@ -50,15 +49,33 @@ public:
|
|||
tgame_save_message(const std::string& title, const std::string& filename="", const std::string& message="");
|
||||
|
||||
private:
|
||||
/** Inherited from tgame_save. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
/** Inherited from tgame_save. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
/** Inherited from tgame_save. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
std::string message_;
|
||||
};
|
||||
|
||||
class tgame_save_oos : public tgame_save_message
|
||||
{
|
||||
public:
|
||||
tgame_save_oos(const std::string& title, const std::string& filename="", const std::string& message="");
|
||||
|
||||
const bool ignore_all() const { return ignore_all_; }
|
||||
|
||||
private:
|
||||
/** Inherited from tgame_save. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(twindow& window);
|
||||
|
||||
tfield_bool* btnIgnoreAll_;
|
||||
bool ignore_all_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -89,6 +89,7 @@ static void fill_window_types()
|
|||
window_type_list[TITLE_SCREEN] = "title_screen";
|
||||
window_type_list[GAME_SAVE] = "game_save";
|
||||
window_type_list[GAME_SAVE_MESSAGE] = "game_save_message";
|
||||
window_type_list[GAME_SAVE_OOS] = "game_save_oos";
|
||||
#ifndef DISABLE_EDITOR2
|
||||
window_type_list[EDITOR_NEW_MAP] = "editor_new_map";
|
||||
window_type_list[EDITOR_GENERATE_MAP] = "editor_generate_map";
|
||||
|
|
|
@ -67,6 +67,7 @@ enum twindow_type {
|
|||
#endif
|
||||
GAME_SAVE, /**< Save game dialog. */
|
||||
GAME_SAVE_MESSAGE, /**< Save game dialog with additional message. */
|
||||
GAME_SAVE_OOS, /**< Save game dialog for processing OOS. */
|
||||
COUNT /**<
|
||||
* The last one to hold the number of items and as
|
||||
* sentinel.
|
||||
|
|
|
@ -479,14 +479,21 @@ bool savegame::save_game_interactive(display& gui, const std::string& message,
|
|||
int res = 0;
|
||||
int overwrite = 0;
|
||||
bool exit = true;
|
||||
static bool ignore_all = false;
|
||||
bool has_exit = true;
|
||||
|
||||
do{
|
||||
try{
|
||||
if (ask_for_filename){
|
||||
std::string filename = filename_;
|
||||
|
||||
if (has_exit_button)
|
||||
res = dialogs::get_save_name_oos(gui, message, _("Name: "), &filename_, dialog_type, title_);
|
||||
if (has_exit){
|
||||
gui2::tgame_save_oos dlg(title_, filename, message);
|
||||
dlg.show(gui.video());
|
||||
filename = dlg.filename();
|
||||
ignore_all = dlg.ignore_all();
|
||||
res = dlg.get_retval();
|
||||
}
|
||||
else{
|
||||
if (dialog_type == gui::OK_CANCEL){
|
||||
gui2::tgame_save dlg(title_, filename);
|
||||
|
|
Loading…
Add table
Reference in a new issue