Enabled difficulty reselection with the gui1 dialog.

This commit is contained in:
Fabian Müller 2012-02-07 13:35:22 +00:00
parent 1e8139041f
commit bbe14565f6
4 changed files with 41 additions and 32 deletions

View file

@ -57,7 +57,6 @@ Version 1.11.0-svn:
* Display the savegame version when warning the user about unsupported or
mismatched versions (bug #7243)
* Implemented feature request for difficulty changing during campaigns.
The feature is still gui2 only and thus still hidden per default.
(see bug #10978)
* The saved games cache file is now save_index instead of save_index.gz, and
it is compressed when the Compressed Saves option is enabled in Advanced

View file

@ -586,7 +586,7 @@ std::string format_time_summary(time_t t)
} // end anon namespace
std::string load_game_dialog(display& disp, const config& game_config, bool* show_replay, bool* cancel_orders)
std::string load_game_dialog(display& disp, const config& game_config, bool* select_difficulty, bool* show_replay, bool* cancel_orders)
{
std::vector<savegame::save_info> games;
{
@ -658,6 +658,11 @@ std::string load_game_dialog(display& disp, const config& game_config, bool* sho
//game_config::small_gui ? gui::dialog::BUTTON_STANDARD : gui::dialog::BUTTON_EXTRA);
gui::dialog::BUTTON_STANDARD);
}
if(select_difficulty != NULL) {
lmenu.add_option(_("Reselect difficulty"), false,
gui::dialog::BUTTON_CHECKBOX);
}
lmenu.add_button(new gui::standard_dialog_button(disp.video(),_("OK"),0,false), gui::dialog::BUTTON_STANDARD);
lmenu.add_button(new gui::standard_dialog_button(disp.video(),_("Cancel"),1,true), gui::dialog::BUTTON_STANDARD);
@ -689,6 +694,9 @@ std::string load_game_dialog(display& disp, const config& game_config, bool* sho
if (cancel_orders != NULL) {
*cancel_orders = lmenu.option_checked(option_index++);
}
if (select_difficulty != NULL) {
*select_difficulty = lmenu.option_checked(option_index++);
}
return games[res].name;
}

View file

@ -67,7 +67,7 @@ void show_objectives(const config &level, const std::string &objectives);
* the game in show_replay. If show_replay is NULL, then the user will not be
* asked if they want to show a replay.
*/
std::string load_game_dialog(display& disp, const config& terrain_config, bool* show_replay, bool* cancel_orders);
std::string load_game_dialog(display& disp, const config& terrain_config, bool* select_difficulty, bool* show_replay, bool* cancel_orders);
/** Show unit-stats in a side-pane to unit-list, recall-list, etc. */
class unit_preview_pane : public gui::preview_pane

View file

@ -434,49 +434,51 @@ void loadgame::show_dialog(bool show_replay, bool cancel_orders)
{
//FIXME: Integrate the load_game dialog into this class
//something to watch for the curious, but not yet ready to go
bool select_difficulty = false;
if (gui2::new_widgets){
gui2::tgame_load load_dialog(game_config_);
load_dialog.show(gui_.video());
if (load_dialog.get_retval() == gui2::twindow::OK){
if (load_dialog.reselect_difficulty()) {
if (load_dialog.get_retval() == gui2::twindow::OK) {
select_difficulty = load_dialog.reselect_difficulty();
config cfg_summary;
std::string dummy;
try {
manager::load_summary(load_dialog.filename(), cfg_summary, &dummy);
} catch(game::load_game_failed&) {
cfg_summary["corrupt"] = "yes";
}
const std::string difficulty_descriptions = cfg_summary["campaign_difficulty_descriptions"];
const std::string difficulties = cfg_summary["campaign_difficulties"];
std::vector<std::string> difficulty_options = utils::split(difficulty_descriptions, ';');
std::vector<std::string> difficulty_list = utils::split(difficulties, ',');
gui2::tcampaign_difficulty difficulty_dlg(difficulty_options);
difficulty_dlg.show(gui_.video());
if (difficulty_dlg.get_retval() != gui2::twindow::OK)
return;
difficulty_ = difficulty_list[difficulty_dlg.selected_index()];
}
filename_ = load_dialog.filename();
show_replay_ = load_dialog.show_replay();
cancel_orders_ = load_dialog.cancel_orders();
}
}
else
{
} else {
bool show_replay_dialog = show_replay;
bool cancel_orders_dialog = cancel_orders;
filename_ = dialogs::load_game_dialog(gui_, game_config_, &show_replay_dialog, &cancel_orders_dialog);
filename_ = dialogs::load_game_dialog(gui_, game_config_, &select_difficulty, &show_replay_dialog, &cancel_orders_dialog);
show_replay_ = show_replay_dialog;
cancel_orders_ = cancel_orders_dialog;
}
if (select_difficulty) {
config cfg_summary;
std::string dummy;
try {
manager::load_summary(filename_, cfg_summary, &dummy);
} catch(game::load_game_failed&) {
cfg_summary["corrupt"] = "yes";
}
const std::string difficulty_descriptions = cfg_summary["campaign_difficulty_descriptions"];
const std::string difficulties = cfg_summary["campaign_difficulties"];
std::vector<std::string> difficulty_options = utils::split(difficulty_descriptions, ';');
std::vector<std::string> difficulty_list = utils::split(difficulties, ',');
gui2::tcampaign_difficulty difficulty_dlg(difficulty_options);
difficulty_dlg.show(gui_.video());
if (difficulty_dlg.get_retval() != gui2::twindow::OK)
return;
difficulty_ = difficulty_list[difficulty_dlg.selected_index()];
}
}
void loadgame::load_game()