mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 08:38:52 +00:00
add "random faction mode" mp game setting, mp configure option
This just adds the gui and preference. It doesn't implement the feature. Current modes are "normal" i.e. "independent", "no mirror", and "no ally mirror".
This commit is contained in:
parent
abcba455f4
commit
d7cb138796
@ -54,6 +54,7 @@ void configure_engine::set_default_values() {
|
||||
set_random_start_time(random_start_time_default());
|
||||
set_fog_game(fog_game_default());
|
||||
set_shroud_game(shroud_game_default());
|
||||
set_random_faction_mode(random_faction_mode_default());
|
||||
}
|
||||
|
||||
bool configure_engine::force_lock_settings() const {
|
||||
@ -77,6 +78,7 @@ bool configure_engine::fog_game() const { return parameters_.fog_game; }
|
||||
bool configure_engine::shroud_game() const { return parameters_.shroud_game; }
|
||||
bool configure_engine::allow_observers() const { return parameters_.allow_observers; }
|
||||
bool configure_engine::shuffle_sides() const { return parameters_.shuffle_sides; }
|
||||
int configure_engine::random_faction_mode() const { return parameters_.random_faction_mode; }
|
||||
const config& configure_engine::options() const { return parameters_.options; }
|
||||
|
||||
void configure_engine::set_game_name(std::string val) { parameters_.name = val; }
|
||||
@ -96,6 +98,7 @@ void configure_engine::set_shroud_game(bool val) { parameters_.shroud_game = val
|
||||
void configure_engine::set_allow_observers(bool val) { parameters_.allow_observers = val; }
|
||||
void configure_engine::set_oos_debug(bool val) { state_.classification().oos_debug = val; }
|
||||
void configure_engine::set_shuffle_sides(bool val) { parameters_.shuffle_sides = val; }
|
||||
void configure_engine::set_random_faction_mode(int val) { parameters_.random_faction_mode = val;}
|
||||
void configure_engine::set_options(const config& cfg) { parameters_.options = cfg; }
|
||||
|
||||
void configure_engine::set_scenario(size_t scenario_num) {
|
||||
@ -180,6 +183,10 @@ bool configure_engine::allow_observers_default() const {
|
||||
bool configure_engine::shuffle_sides_default() const {
|
||||
return preferences::shuffle_sides();
|
||||
}
|
||||
int configure_engine::random_faction_mode_default() const {
|
||||
return preferences::random_faction_mode();
|
||||
}
|
||||
|
||||
const config& configure_engine::options_default() const {
|
||||
return preferences::options();
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
bool shroud_game() const;
|
||||
bool allow_observers() const;
|
||||
bool shuffle_sides() const;
|
||||
int random_faction_mode() const;
|
||||
const config& options() const;
|
||||
|
||||
// setter methods
|
||||
@ -75,6 +76,7 @@ public:
|
||||
void set_allow_observers(bool val);
|
||||
void set_oos_debug(bool val);
|
||||
void set_shuffle_sides(bool val);
|
||||
void set_random_faction_mode(int val);
|
||||
void set_options(const config& cfg);
|
||||
|
||||
void set_scenario(size_t scenario_num);
|
||||
@ -97,6 +99,7 @@ public:
|
||||
bool shroud_game_default() const;
|
||||
bool allow_observers_default() const;
|
||||
bool shuffle_sides_default() const;
|
||||
int random_faction_mode_default() const;
|
||||
const config& options_default() const;
|
||||
|
||||
// parameters_ accessor
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "wml_separators.hpp"
|
||||
#include "formula_string_utils.hpp"
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
@ -82,6 +83,7 @@ configure::configure(game_display& disp, const config &cfg, chat& c, config& gam
|
||||
observers_game_(disp.video(), _("Observers"), gui::button::TYPE_CHECK),
|
||||
oos_debug_(disp.video(), _("Debug OOS"), gui::button::TYPE_CHECK),
|
||||
shuffle_sides_(disp.video(), _("Shuffle sides"), gui::button::TYPE_CHECK),
|
||||
random_faction_mode_(disp, std::vector<std::string>()),
|
||||
cancel_game_(disp.video(), _("Back")),
|
||||
launch_game_(disp.video(), _("OK")),
|
||||
password_button_(disp.video(), _("Set Password...")),
|
||||
@ -183,6 +185,10 @@ configure::configure(game_display& disp, const config &cfg, chat& c, config& gam
|
||||
shuffle_sides_.set_check(engine_.shuffle_sides_default());
|
||||
shuffle_sides_.set_help_string(_("Assign sides to players at random"));
|
||||
|
||||
random_faction_mode_.set_items(boost::assign::list_of(_("Independent"))(_("No Mirror"))( _("No Ally Mirror")));
|
||||
random_faction_mode_.set_selected(engine_.random_faction_mode());
|
||||
random_faction_mode_.set_help_string(_("Independent: Random factions assigned independently uniformly at random\nNo Mirror: No two players will get the same faction\nNo Ally Mirror: No two allied players will get the same faction"));
|
||||
|
||||
#if 0
|
||||
// The possible vision settings
|
||||
std::vector<std::string> vision_types;
|
||||
@ -229,6 +235,7 @@ configure::~configure()
|
||||
// Save values for next game
|
||||
DBG_MP << "storing parameter values in preferences" << std::endl;
|
||||
preferences::set_shuffle_sides(engine_.shuffle_sides());
|
||||
preferences::set_random_faction_mode(engine_.random_faction_mode());
|
||||
preferences::set_use_map_settings(engine_.use_map_settings());
|
||||
preferences::set_countdown(engine_.mp_countdown());
|
||||
preferences::set_countdown_init_time(engine_.mp_countdown_init_time());
|
||||
@ -292,6 +299,7 @@ const mp_game_settings& configure::get_parameters()
|
||||
engine_.set_allow_observers(observers_game_.checked());
|
||||
engine_.set_oos_debug(oos_debug_.checked());
|
||||
engine_.set_shuffle_sides(shuffle_sides_.checked());
|
||||
engine_.set_random_faction_mode(random_faction_mode_.selected());
|
||||
|
||||
engine_.set_options(options_manager_.get_values());
|
||||
|
||||
@ -483,6 +491,7 @@ void configure::hide_children(bool hide)
|
||||
observers_game_.hide(hide);
|
||||
oos_debug_.hide(hide);
|
||||
shuffle_sides_.hide(hide);
|
||||
random_faction_mode_.hide(hide);
|
||||
cancel_game_.hide(hide);
|
||||
launch_game_.hide(hide);
|
||||
|
||||
@ -538,12 +547,12 @@ void configure::layout_children(const SDL_Rect& rect)
|
||||
int ypos_left = 0;
|
||||
|
||||
ypos_left += 2 * border_size;
|
||||
options_pane_left_.add_widget(&observers_game_, xpos_left, ypos_left);
|
||||
options_pane_left_.add_widget(&shuffle_sides_,
|
||||
options_pane_left_.add_widget(&shuffle_sides_, xpos_left, ypos_left);
|
||||
options_pane_left_.add_widget(&observers_game_,
|
||||
xpos_left + (options_pane_left_.width() - xpos_left) / 2 + border_size, ypos_left);
|
||||
ypos_left += shuffle_sides_.height() + border_size;
|
||||
|
||||
options_pane_left_.add_widget(&countdown_game_, xpos_left, ypos_left);
|
||||
options_pane_left_.add_widget(&random_faction_mode_, xpos_left, ypos_left);
|
||||
|
||||
if(!local_players_only_) {
|
||||
options_pane_left_.add_widget(&password_button_,
|
||||
@ -551,7 +560,9 @@ void configure::layout_children(const SDL_Rect& rect)
|
||||
} else {
|
||||
password_button_.hide(true);
|
||||
}
|
||||
ypos_left += random_faction_mode_.height() + border_size;
|
||||
|
||||
options_pane_left_.add_widget(&countdown_game_, xpos_left, ypos_left);
|
||||
ypos_left += countdown_game_.height() + border_size;
|
||||
|
||||
options_pane_left_.add_widget(&countdown_init_time_label_, xpos_left, ypos_left );
|
||||
|
@ -79,6 +79,8 @@ private:
|
||||
gui::button observers_game_;
|
||||
gui::button oos_debug_;
|
||||
gui::button shuffle_sides_;
|
||||
gui::combo random_faction_mode_;
|
||||
|
||||
gui::button cancel_game_;
|
||||
gui::button launch_game_;
|
||||
gui::button password_button_;
|
||||
|
@ -568,6 +568,14 @@ void set_shuffle_sides(bool value)
|
||||
preferences::set("shuffle_sides", value);
|
||||
}
|
||||
|
||||
int random_faction_mode(){
|
||||
return lexical_cast_default<int>(preferences::get("random_faction_mode"), 0);
|
||||
}
|
||||
|
||||
void set_random_faction_mode(int value) {
|
||||
preferences::set("random_faction_mode", value);
|
||||
}
|
||||
|
||||
bool use_map_settings()
|
||||
{
|
||||
return preferences::get("mp_use_map_settings", true);
|
||||
|
@ -125,6 +125,9 @@ class acquaintance;
|
||||
bool shuffle_sides();
|
||||
void set_shuffle_sides(bool value);
|
||||
|
||||
int random_faction_mode();
|
||||
void set_random_faction_mode(int value);
|
||||
|
||||
bool use_map_settings();
|
||||
void set_use_map_settings(bool value);
|
||||
|
||||
|
@ -50,6 +50,7 @@ mp_game_settings::mp_game_settings() :
|
||||
shroud_game(false),
|
||||
allow_observers(false),
|
||||
shuffle_sides(false),
|
||||
random_faction_mode(0),
|
||||
saved_game(false),
|
||||
options()
|
||||
{}
|
||||
@ -83,6 +84,7 @@ mp_game_settings::mp_game_settings(const config& cfg)
|
||||
, shroud_game(cfg["mp_shroud"].to_bool())
|
||||
, allow_observers(cfg["observer"].to_bool())
|
||||
, shuffle_sides(cfg["shuffle_sides"].to_bool())
|
||||
, random_faction_mode(cfg["random_faction_mode"].to_int(0))
|
||||
, saved_game(cfg["savegame"].to_bool())
|
||||
, options(cfg.child_or_empty("options"))
|
||||
{
|
||||
@ -118,6 +120,7 @@ config mp_game_settings::to_config() const
|
||||
cfg["mp_random_start_time"] = random_start_time;
|
||||
cfg["observer"] = allow_observers;
|
||||
cfg["shuffle_sides"] = shuffle_sides;
|
||||
cfg["random_faction_mode"] = random_faction_mode;
|
||||
cfg["savegame"] = saved_game;
|
||||
cfg.add_child("options", options);
|
||||
|
||||
|
@ -58,6 +58,7 @@ struct mp_game_settings : public savegame::savegame_config
|
||||
bool shroud_game;
|
||||
bool allow_observers;
|
||||
bool shuffle_sides;
|
||||
int random_faction_mode;
|
||||
|
||||
bool saved_game;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user