First (non-OO) attempt at abstracting out a popup-transient window.

This commit is contained in:
Eric S. Raymond 2007-06-08 05:53:15 +00:00
parent 9c8ef5a345
commit d851c2d4b0

View File

@ -39,6 +39,12 @@
namespace {
static void popup_transient(display& screen,
const std::string& caption, const std::string& message)
{
gui::show_dialog(screen, NULL, caption, message, gui::MESSAGE);
}
class statistics_dialog : public gui::dialog
{
public:
@ -477,10 +483,10 @@ namespace events{
try {
recorder.save_game(label, snapshot, gamestate_.starting_pos);
if(dialog_type != gui::NULL_DIALOG) {
gui::show_dialog(*gui_,NULL,_("Saved"),_("The game has been saved"));
popup_transient(*gui_,_("Saved"),_("The game has been saved"));
}
} catch(game::save_game_failed&) {
gui::show_dialog(*gui_,NULL,_("Error"),_("The game could not be saved"),gui::MESSAGE);
popup_transient(*gui_,_("Error"),_("The game could not be saved"));
//do not bother retrying, since the user can just try to save the game again
};
} else if(res == 2) {
@ -611,7 +617,7 @@ namespace events{
recorder.save_game(label + "-" + _("Auto-Save") + lexical_cast<std::string>(turn), snapshot, starting_pos);
}
} catch(game::save_game_failed&) {
gui::show_dialog(*gui_,NULL,"",_("Could not auto save the game. Please save the game manually."),gui::MESSAGE);
popup_transient(*gui_,"",_("Could not auto save the game. Please save the game manually."));
//do not bother retrying, since the user can just save the game
}
end = SDL_GetTicks();
@ -720,7 +726,7 @@ namespace events{
}
if(sample_units.empty()) {
gui::show_dialog(*gui_,NULL,"",_("You have no units available to recruit."),gui::MESSAGE);
popup_transient(*gui_,"",_("You have no units available to recruit."));
return;
}
@ -1866,7 +1872,7 @@ namespace events{
gamestate_.set_variable(name,value);
}
} else if(game_config::debug && cmd == "show_var") {
gui::show_dialog(*gui_,NULL,"",gamestate_.get_variable(data),gui::MESSAGE);
popup_transient(*gui_,"",gamestate_.get_variable(data));
} else if(game_config::debug && cmd == "unit") {
const unit_map::iterator i = current_unit(mousehandler);
if(i != units_.end()) {