automaticly detect whether to show mp_configure in sp
We now automaticly show mp_configure in sp iff there are actually things to configure. This means if eigher force_lock_settiings was explicitly set to false or if the [campaign] or one of the [modification] provides [options] to configure.
This commit is contained in:
parent
f8aa355486
commit
acf177fbd0
12 changed files with 42 additions and 64 deletions
|
@ -97,12 +97,8 @@
|
|||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[toggle_button]
|
||||
definition = "default"
|
||||
id = "mp_configure"
|
||||
|
||||
label = _ "Level options"
|
||||
[/toggle_button]
|
||||
[spacer]
|
||||
[/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
|
|
|
@ -408,8 +408,7 @@ void connect_engine::start_game(LOAD_USERS load_users)
|
|||
|
||||
// Shuffle sides (check settings and if it is a re-loaded game).
|
||||
// Must be done after resolve_random() or shuffle sides, or they won't work.
|
||||
if (state_.mp_settings().shuffle_sides && !(level_.child("snapshot") &&
|
||||
level_.child("snapshot").child("side"))) {
|
||||
if (state_.mp_settings().shuffle_sides && !force_lock_settings_ && !(level_.child("snapshot") && level_.child("snapshot").child("side"))) {
|
||||
|
||||
// Only playable sides should be shuffled.
|
||||
std::vector<int> playable_sides;
|
||||
|
|
|
@ -415,11 +415,9 @@ create_engine::create_engine(game_display& disp, saved_game& state) :
|
|||
|
||||
// Restore game config for multiplayer.
|
||||
game_classification::CAMPAIGN_TYPE type = state_.classification().campaign_type;
|
||||
bool configure = state_.mp_settings().show_configure;
|
||||
bool connect = state_.mp_settings().show_connect;
|
||||
state_ = saved_game();
|
||||
state_.classification().campaign_type = type;
|
||||
state_.mp_settings().show_configure = configure;
|
||||
state_.mp_settings().show_connect = connect;
|
||||
game_config_manager::get()->load_game_config_for_create(type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
|
||||
//Initilialize dependency_manager_ after refreshing game config.
|
||||
|
|
|
@ -104,6 +104,11 @@ void manager::restore_defaults(const std::string &component)
|
|||
}
|
||||
}
|
||||
|
||||
bool manager::has_options()
|
||||
{
|
||||
return !widgets_.empty();
|
||||
}
|
||||
|
||||
manager::manager(const config &gamecfg, game_display &display, gui::scrollpane *pane, const config &values)
|
||||
: options_info_()
|
||||
, values_(values)
|
||||
|
|
|
@ -222,6 +222,7 @@ public:
|
|||
|
||||
void restore_defaults(const std::string &component);
|
||||
|
||||
bool has_options();
|
||||
private:
|
||||
|
||||
/** Stores needed info about each element and their configuration options */
|
||||
|
|
|
@ -237,6 +237,10 @@ configure::configure(game_display& disp, const config &cfg, chat& c, config& gam
|
|||
plugins_context_->set_callback("launch", boost::bind(&configure::plugin_event_helper, this, process_event_data (true, false)));
|
||||
plugins_context_->set_callback("quit", boost::bind(&configure::plugin_event_helper, this, process_event_data (false, true)));
|
||||
plugins_context_->set_callback("set_name", boost::bind(&gui::textbox::set_text, &name_entry_, boost::bind(get_str, _1, "name"), font::NORMAL_COLOR), true);
|
||||
|
||||
if(!options_manager_.has_options() && engine_.force_lock_settings() && state_.classification().campaign_type != game_classification::CAMPAIGN_TYPE::MULTIPLAYER) {
|
||||
set_result(CREATE);
|
||||
}
|
||||
}
|
||||
|
||||
configure::~configure()
|
||||
|
|
|
@ -38,7 +38,6 @@ public:
|
|||
~configure();
|
||||
|
||||
void get_parameters();
|
||||
|
||||
protected:
|
||||
virtual void layout_children(const SDL_Rect& rect);
|
||||
virtual void process_event();
|
||||
|
|
|
@ -125,45 +125,41 @@ bool enter_create_mode(game_display& disp, const config& game_config,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool enter_configure_mode(game_display& disp, const config& game_config,
|
||||
saved_game& state, jump_to_campaign_info& jump_to_campaign, bool local_players_only) {
|
||||
bool enter_configure_mode(game_display& disp, const config& game_config, saved_game& state, jump_to_campaign_info& jump_to_campaign, bool local_players_only) {
|
||||
bool connect_canceled;
|
||||
do {
|
||||
connect_canceled = false;
|
||||
|
||||
if (state.mp_settings().show_configure) {
|
||||
bool connect_canceled;
|
||||
do{
|
||||
connect_canceled = false;
|
||||
mp::ui::result res;
|
||||
|
||||
mp::ui::result res;
|
||||
{
|
||||
mp::configure ui(disp, game_config, gamechat, gamelist, state, local_players_only);
|
||||
mp::run_lobby_loop(disp, ui);
|
||||
res = ui.get_result();
|
||||
ui.get_parameters();
|
||||
}
|
||||
|
||||
{
|
||||
mp::configure ui(disp, game_config, gamechat, gamelist, state, local_players_only);
|
||||
mp::run_lobby_loop(disp, ui);
|
||||
res = ui.get_result();
|
||||
ui.get_parameters();
|
||||
}
|
||||
|
||||
switch (res) {
|
||||
case mp::ui::CREATE:
|
||||
connect_canceled = !enter_connect_mode(disp, game_config, state, local_players_only);
|
||||
break;
|
||||
case mp::ui::QUIT:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} while (connect_canceled);
|
||||
return true;
|
||||
} else {
|
||||
ng::configure_engine engine(state);
|
||||
engine.set_default_values();
|
||||
// try to set campaign-scenario from commandline
|
||||
if (!jump_to_campaign.scenario_id_.empty() && !engine.set_scenario(jump_to_campaign.scenario_id_)) {
|
||||
std::cerr << "Invalid campaign-scenario specified." << std::endl;
|
||||
jump_to_campaign = jump_to_campaign_info(false, -1, "", "");
|
||||
switch (res) {
|
||||
case mp::ui::CREATE:
|
||||
connect_canceled = !enter_connect_mode(disp, game_config, state, local_players_only);
|
||||
break;
|
||||
case mp::ui::QUIT:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return enter_connect_mode(disp, game_config, state, local_players_only);
|
||||
} while (connect_canceled);
|
||||
#if 0
|
||||
ng::configure_engine engine(state);
|
||||
engine.set_default_values();
|
||||
// try to set campaign-scenario from commandline
|
||||
if (!jump_to_campaign.scenario_id_.empty() && !engine.set_scenario(jump_to_campaign.scenario_id_)) {
|
||||
std::cerr << "Invalid campaign-scenario specified." << std::endl;
|
||||
jump_to_campaign = jump_to_campaign_info(false, -1, "", "");
|
||||
return false;
|
||||
}
|
||||
|
||||
return enter_connect_mode(disp, game_config, state, local_players_only);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool enter_connect_mode(game_display& disp, const config& game_config,
|
||||
|
|
|
@ -797,8 +797,6 @@ bool game_launcher::new_campaign()
|
|||
{
|
||||
state_ = saved_game();
|
||||
state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::SCENARIO;
|
||||
|
||||
state_.mp_settings().show_configure = false;
|
||||
state_.mp_settings().show_connect = false;
|
||||
play_replay_ = false;
|
||||
|
||||
|
|
|
@ -147,9 +147,6 @@ void tcampaign_settings::update_lists(twindow& window)
|
|||
|
||||
void tcampaign_settings::pre_show(CVideo&, twindow& window)
|
||||
{
|
||||
find_widget<ttoggle_button>(&window, "mp_configure", false).set_value(
|
||||
engine_.get_state().mp_settings().show_configure);
|
||||
|
||||
find_widget<ttoggle_button>(&window, "mp_connect", false).set_value(
|
||||
engine_.get_state().mp_settings().show_connect);
|
||||
|
||||
|
@ -158,16 +155,8 @@ void tcampaign_settings::pre_show(CVideo&, twindow& window)
|
|||
tlistbox& era_list = find_widget<tlistbox>(&window, "era_list", false);
|
||||
tlistbox& mod_list = find_widget<tlistbox>(&window, "modification_list", false);
|
||||
|
||||
ttoggle_button& configure_toggle = find_widget<ttoggle_button>(&window, "mp_configure", false);
|
||||
ttoggle_button& connect_toggle = find_widget<ttoggle_button>(&window, "mp_connect", false);
|
||||
|
||||
const config::attribute_value& show_configure = engine_.current_level().data()["show_configure"];
|
||||
if (show_configure.blank() || show_configure.str() == "user") {
|
||||
configure_toggle.set_active(true);
|
||||
} else {
|
||||
configure_toggle.set_value(show_configure.to_bool());
|
||||
configure_toggle.set_active(false);
|
||||
}
|
||||
const config::attribute_value& show_connect = engine_.current_level().data()["show_connect"];
|
||||
if (show_connect.blank() || show_connect.str() == "user") {
|
||||
connect_toggle.set_active(true);
|
||||
|
@ -186,8 +175,6 @@ void tcampaign_settings::post_show(twindow& window)
|
|||
{
|
||||
engine_.get_state().mp_settings().show_connect =
|
||||
find_widget<ttoggle_button>(&window, "mp_connect", false).get_value();
|
||||
engine_.get_state().mp_settings().show_configure =
|
||||
find_widget<ttoggle_button>(&window, "mp_configure", false).get_value();
|
||||
}
|
||||
|
||||
} // end namespace gui2
|
||||
|
|
|
@ -42,8 +42,6 @@ mp_game_settings::mp_game_settings() :
|
|||
difficulty_define(),
|
||||
active_mods(),
|
||||
side_users(),
|
||||
show_configure(true),
|
||||
show_connect(true),
|
||||
num_turns(0),
|
||||
village_gold(0),
|
||||
village_support(1),
|
||||
|
@ -77,7 +75,6 @@ mp_game_settings::mp_game_settings(const config& cfg)
|
|||
, difficulty_define(cfg["difficulty_define"].str())
|
||||
, active_mods(utils::split(cfg["active_mods"], ','))
|
||||
, side_users(utils::map_split(cfg["side_users"]))
|
||||
, show_configure(cfg["show_configure"].to_bool(true))
|
||||
, show_connect(cfg["show_connect"].to_bool(true))
|
||||
, num_turns(cfg["mp_num_turns"])
|
||||
, village_gold(cfg["mp_village_gold"])
|
||||
|
@ -119,7 +116,6 @@ config mp_game_settings::to_config() const
|
|||
cfg["difficulty_define"] = difficulty_define;
|
||||
cfg["active_mods"] = utils::join(active_mods, ",");
|
||||
cfg["side_users"] = utils::join_map(side_users);
|
||||
cfg["show_configure"] = show_configure;
|
||||
cfg["show_connect"] = show_connect;
|
||||
cfg["experience_modifier"] = xp_modifier;
|
||||
cfg["mp_countdown"] = mp_countdown;
|
||||
|
|
|
@ -45,7 +45,6 @@ struct mp_game_settings : public savegame::savegame_config
|
|||
std::vector<std::string> active_mods;
|
||||
std::map<std::string, std::string> side_users;
|
||||
|
||||
bool show_configure;
|
||||
bool show_connect;
|
||||
|
||||
int num_turns;
|
||||
|
|
Loading…
Add table
Reference in a new issue