Second refactoring step for popup transients.
There's now a function to do these in the GUI namespace. At the moment it produces only an ordinary MESSAGE window.
This commit is contained in:
parent
49fc7fe2bb
commit
10002159ba
5 changed files with 21 additions and 18 deletions
|
@ -39,12 +39,6 @@
|
|||
|
||||
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:
|
||||
|
@ -483,10 +477,10 @@ namespace events{
|
|||
try {
|
||||
recorder.save_game(label, snapshot, gamestate_.starting_pos);
|
||||
if(dialog_type != gui::NULL_DIALOG) {
|
||||
popup_transient(*gui_,_("Saved"),_("The game has been saved"));
|
||||
gui::popup_transient(*gui_,_("Saved"),_("The game has been saved"));
|
||||
}
|
||||
} catch(game::save_game_failed&) {
|
||||
popup_transient(*gui_,_("Error"),_("The game could not be saved"));
|
||||
gui::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) {
|
||||
|
@ -617,7 +611,7 @@ namespace events{
|
|||
recorder.save_game(label + "-" + _("Auto-Save") + lexical_cast<std::string>(turn), snapshot, starting_pos);
|
||||
}
|
||||
} catch(game::save_game_failed&) {
|
||||
popup_transient(*gui_,"",_("Could not auto save the game. Please save the game manually."));
|
||||
gui::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();
|
||||
|
@ -726,7 +720,7 @@ namespace events{
|
|||
}
|
||||
|
||||
if(sample_units.empty()) {
|
||||
popup_transient(*gui_,"",_("You have no units available to recruit."));
|
||||
gui::popup_transient(*gui_,"",_("You have no units available to recruit."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1872,7 +1866,7 @@ namespace events{
|
|||
gamestate_.set_variable(name,value);
|
||||
}
|
||||
} else if(game_config::debug && cmd == "show_var") {
|
||||
popup_transient(*gui_,"",gamestate_.get_variable(data));
|
||||
gui::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()) {
|
||||
|
|
|
@ -479,7 +479,7 @@ void playsingle_controller::before_human_turn(bool save)
|
|||
}
|
||||
|
||||
if(preferences::turn_dialog()) {
|
||||
gui::show_dialog(*gui_,NULL,"",_("It is now your turn"),gui::MESSAGE);
|
||||
gui::popup_transient(*gui_,"",_("It is now your turn"));
|
||||
}
|
||||
|
||||
const std::string& turn_cmd = preferences::turn_cmd();
|
||||
|
|
|
@ -77,8 +77,7 @@ void set_fullscreen(bool ison)
|
|||
} else if(video.modePossible(1024,768,16,flags)) {
|
||||
set_resolution(std::pair<int,int>(1024,768));
|
||||
} else {
|
||||
gui::show_dialog(*disp,NULL,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."),
|
||||
gui::MESSAGE);
|
||||
gui::popup_transient(*disp,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ void set_resolution(const std::pair<int,int>& resolution)
|
|||
|
||||
} else {
|
||||
write_resolution = false;
|
||||
gui::show_dialog(*disp,NULL,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."),gui::MESSAGE);
|
||||
gui::popup_transient(*disp,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1384,7 +1383,7 @@ void show_hotkeys_dialog (display & disp, config *save_config)
|
|||
hotkey::hotkey_item& newhk = hotkey::get_visible_hotkey(menu_.selection());
|
||||
|
||||
if(oldhk.get_id() != newhk.get_id() && !oldhk.null()) {
|
||||
gui::show_dialog(disp,NULL,"",_("This Hotkey is already in use."),gui::MESSAGE);
|
||||
gui::popup_transient(disp,"",_("This Hotkey is already in use."));
|
||||
} else {
|
||||
newhk.set_key(character, keycode, (mod & KMOD_SHIFT) != 0,
|
||||
(mod & KMOD_CTRL) != 0, (mod & KMOD_ALT) != 0, (mod & KMOD_LMETA) != 0);
|
||||
|
@ -1423,11 +1422,11 @@ bool show_theme_dialog(display& disp)
|
|||
preferences::set_theme(options[action]);
|
||||
//it would be preferable for the new theme to take effect
|
||||
//immediately, however, this will have to do for now.
|
||||
gui::show_dialog(disp,NULL,"",_("New theme will take effect on next new or loaded game."),gui::MESSAGE);
|
||||
gui::popup_transient(disp,"",_("New theme will take effect on next new or loaded game."));
|
||||
return(1);
|
||||
}
|
||||
}else{
|
||||
gui::show_dialog(disp,NULL,"",_("No known themes. Try changing from within an existing game."),gui::MESSAGE);
|
||||
gui::popup_transient(disp,"",_("No known themes. Try changing from within an existing game."));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
|
|
@ -402,6 +402,13 @@ int show_dialog(display& screen, surface image,
|
|||
return d.result();
|
||||
}
|
||||
|
||||
void popup_transient(display& screen,
|
||||
const std::string& caption, const std::string& message)
|
||||
{
|
||||
// FIXME: placeholder for a semitransparent window with timeout
|
||||
gui::show_dialog(screen, NULL, caption, message, gui::MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace gui {
|
||||
|
|
|
@ -182,6 +182,9 @@ int show_dialog(display &screen, surface image,
|
|||
|
||||
void show_error_message(display &disp, std::string const &message);
|
||||
|
||||
void popup_transient(display& screen,
|
||||
const std::string& caption, const std::string& message);
|
||||
|
||||
network::connection network_send_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
|
||||
network::connection network_receive_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
|
||||
network::connection network_connect_dialog(display& disp, const std::string& msg, const std::string& hostname, int port);
|
||||
|
|
Loading…
Add table
Reference in a new issue