MP Create: implemented a bunch more functionality
This commit is contained in:
parent
803e668a22
commit
e33e9b1d32
5 changed files with 77 additions and 40 deletions
|
@ -11,7 +11,7 @@
|
|||
[/spacer]
|
||||
#enddef
|
||||
|
||||
#define _GUI_MP_CREATE_OPTION_SLIDER _LABEL _SLIDER_ID _SLIDER_MIN _SLIDER_MAX
|
||||
#define _GUI_MP_CREATE_OPTION_SLIDER _LABEL _SLIDER_ID _SLIDER_MIN _SLIDER_MAX _TOOLTIP
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
@ -57,6 +57,7 @@
|
|||
minimum_value = {_SLIDER_MIN}
|
||||
maximum_value = {_SLIDER_MAX}
|
||||
step_size = 1
|
||||
tooltip = {_TOOLTIP}
|
||||
[/slider]
|
||||
|
||||
[/column]
|
||||
|
@ -122,7 +123,12 @@
|
|||
[label]
|
||||
definition = "default"
|
||||
|
||||
label = _ "Random Factions:"
|
||||
label = _ "Random Faction Matchups:"
|
||||
# TODO: assign to individual options?
|
||||
tooltip = _ "Allow for mirror matchups when random factions are chosen.
|
||||
Independent: Random factions assigned independently
|
||||
No Mirror: No two players will get the same faction
|
||||
No Ally Mirror: No two allied players will get the same faction"
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
|
@ -543,6 +549,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Use Map Settings"
|
||||
tooltip = _ "Use scenario specific settings"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
@ -558,13 +565,13 @@
|
|||
|
||||
[grid]
|
||||
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Number of Turns") "turn_count" 1 100}
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Number of Turns") "turn_count" 1 100 ( _ "The maximum number of turns the game can last")}
|
||||
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Village Gold") "village_gold" 1 5}
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Village Gold") "village_gold" 1 5 ( _ "The amount of income each village yields per turn")}
|
||||
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Village Support") "village_support" 0 4}
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Village Support") "village_support" 0 4 ( _ "The number of unit levels each village can support")}
|
||||
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Experience Modifier") "experience_modifier" 30 200}
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Experience Modifier") "experience_modifier" 30 200 ( _ "The amount of experience a unit needs to advance")}
|
||||
|
||||
[/grid]
|
||||
|
||||
|
@ -599,6 +606,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Fog of war"
|
||||
tooltip = _ "Enemy units cannot be seen unless they are in range of your units"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
@ -614,6 +622,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Shroud"
|
||||
tooltip = _ "The map is unknown until your units explore it"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
@ -630,6 +639,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Random start time"
|
||||
tooltip = _ "Randomize the starting time of day"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
@ -666,6 +676,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Time Limit"
|
||||
tooltip = _ "Enable custom time limits"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
@ -681,13 +692,13 @@
|
|||
|
||||
[grid]
|
||||
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Initial Limit") "init_turn_limit" 30 1500}
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Initial Limit") "init_turn_limit" 30 1500 (_ "Longest time allowed for first turn (seconds)")}
|
||||
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Turn Bonus") "turn_bonus" 10 300}
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Turn Bonus") "turn_bonus" 10 300 ( _ "Time for general tasks each turn (seconds)")}
|
||||
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Reservior") "reservior" 30 1500}
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Reservior") "reservior" 30 1500 ( _ "Longest time possible for any turn (seconds)")}
|
||||
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Action Bonus") "action_bonus" 0 30}
|
||||
{_GUI_MP_CREATE_OPTION_SLIDER ( _ "Action Bonus") "action_bonus" 0 30 ( _ "Time for each attack, recruit, and capture")}
|
||||
|
||||
[/grid]
|
||||
|
||||
|
@ -1270,18 +1281,18 @@
|
|||
[grid]
|
||||
|
||||
[row]
|
||||
#[column]
|
||||
# grow_factor = 0
|
||||
# horizontal_alignment = "left"
|
||||
# border = "all"
|
||||
# border_size = 5
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
# [label]
|
||||
# id = "game_icon"
|
||||
# definition = "default"
|
||||
# [/label]
|
||||
[image]
|
||||
id = "game_icon"
|
||||
definition = "default"
|
||||
[/image]
|
||||
|
||||
#[/column]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
@ -1461,6 +1472,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Shuffle Sides"
|
||||
tooltip = _ "Assign sides to players at random"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
@ -1476,6 +1488,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Observers"
|
||||
tooltip = _ "Allow users who are not playing to watch the game"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
@ -1491,6 +1504,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Registered Users Only"
|
||||
tooltip = _ "Allow only registered users to join the game"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
@ -1506,6 +1520,7 @@
|
|||
definition = "default"
|
||||
|
||||
label = _ "Strict Synchronization"
|
||||
tooltip = _ "Stricter checks for out-of-sync errors"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
|
|
@ -76,6 +76,7 @@ mp_game_settings::RANDOM_FACTION_MODE configure_engine::random_faction_mode() co
|
|||
const config& configure_engine::options() const { return parameters_.options; }
|
||||
|
||||
void configure_engine::set_game_name(std::string val) { parameters_.name = val; }
|
||||
void configure_engine::set_game_password(std::string val) { parameters_.password = val; }
|
||||
void configure_engine::set_num_turns(int val) { parameters_.num_turns = val; }
|
||||
void configure_engine::set_village_gold(int val) { parameters_.village_gold = val; }
|
||||
void configure_engine::set_village_support(int val) { parameters_.village_support = val; }
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
|
||||
// setter methods
|
||||
void set_game_name(std::string name);
|
||||
void set_game_password(std::string name);
|
||||
void set_num_turns(int val);
|
||||
void set_village_gold(int val);
|
||||
void set_village_support(int val);
|
||||
|
|
|
@ -56,6 +56,7 @@ tmp_create_game::tmp_create_game(const config& cfg, ng::create_engine& create_en
|
|||
: cfg_(cfg)
|
||||
, create_engine_(create_eng)
|
||||
, config_engine_()
|
||||
, selected_game_index_(-1)
|
||||
, use_map_settings_(register_bool("use_map_settings",
|
||||
true, preferences::use_map_settings, preferences::set_use_map_settings,
|
||||
dialog_callback<tmp_create_game, &tmp_create_game::update_map_settings>))
|
||||
|
@ -84,7 +85,6 @@ tmp_create_game::tmp_create_game(const config& cfg, ng::create_engine& create_en
|
|||
true, preferences::countdown_reservoir_time, preferences::set_countdown_reservoir_time))
|
||||
, action_bonus_(register_integer("action_bonus",
|
||||
true, preferences::countdown_action_bonus, preferences::set_countdown_action_bonus))
|
||||
, selected_game_index_(-1)
|
||||
{
|
||||
level_types_ = {
|
||||
{ng::level::TYPE::SCENARIO, _("Scenarios")},
|
||||
|
@ -113,6 +113,8 @@ void tmp_create_game::pre_show(twindow& window)
|
|||
{
|
||||
find_widget<tminimap>(&window, "minimap", false).set_config(&cfg_);
|
||||
|
||||
find_widget<ttext_box>(&window, "game_name", false).set_value(config_engine_->game_name_default());
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "random_map_regenerate", false),
|
||||
std::bind(&tmp_create_game::regenerate_random_map, this, std::ref(window)));
|
||||
|
@ -133,6 +135,12 @@ void tmp_create_game::pre_show(twindow& window)
|
|||
|
||||
window.keyboard_capture(&list);
|
||||
|
||||
//
|
||||
// Set up filtering
|
||||
//
|
||||
connect_signal_notify_modified(find_widget<tslider>(&window, "num_players", false),
|
||||
std::bind(&tmp_create_game::num_players_filter_callback, this, std::ref(window)));
|
||||
|
||||
//
|
||||
// Set up game types combobox
|
||||
//
|
||||
|
@ -262,6 +270,13 @@ void tmp_create_game::on_tab_select(twindow& window)
|
|||
}
|
||||
}
|
||||
|
||||
void tmp_create_game::num_players_filter_callback(twindow& window)
|
||||
{
|
||||
create_engine_.apply_level_filter(find_widget<tslider>(&window, "num_players", false).get_value());
|
||||
|
||||
// TODO: actually display the filtered options
|
||||
}
|
||||
|
||||
void tmp_create_game::update_games_list(twindow& window)
|
||||
{
|
||||
const int index = find_widget<tcombobox>(&window, "game_types", false).get_value();
|
||||
|
@ -285,15 +300,11 @@ void tmp_create_game::display_games_of_type(twindow& window, ng::level::TYPE typ
|
|||
std::map<std::string, string_map> data;
|
||||
string_map item;
|
||||
|
||||
// FIXME
|
||||
/*if(type == ng::level::TYPE::SP_CAMPAIGN) {
|
||||
if(type == ng::level::TYPE::CAMPAIGN || type == ng::level::TYPE::SP_CAMPAIGN) {
|
||||
item["label"] = game.get()->icon();
|
||||
} else {
|
||||
item["label"] = "";
|
||||
data.emplace("game_icon", item);
|
||||
}
|
||||
|
||||
data.emplace("game_icon", item);*/
|
||||
|
||||
item["label"] = game.get()->name();
|
||||
data.emplace("game_name", item);
|
||||
|
||||
|
@ -451,11 +462,6 @@ void tmp_create_game::display_custom_options(ttree_view& tree, std::string&& typ
|
|||
map[text_entry_option["id"]] = [textbox]() { return cav(textbox->get_value()); };
|
||||
}
|
||||
|
||||
// Only add a spacer if there were an option of this type
|
||||
if(options.has_child("entry")) {
|
||||
option_node.add_child("options_spacer_node", empty);
|
||||
}
|
||||
|
||||
// Add the Defaults button at the end
|
||||
option_node.add_child("options_default_button", empty);
|
||||
}
|
||||
|
@ -470,11 +476,14 @@ void tmp_create_game::update_options_list(twindow& window)
|
|||
visible_options_.clear();
|
||||
options_tree.clear();
|
||||
|
||||
display_custom_options(options_tree, create_engine_.current_level_type() == ng::level::TYPE::CAMPAIGN ? "campaign" : "multiplayer", create_engine_.current_level().data()["id"], create_engine_.current_level().data());
|
||||
display_custom_options(options_tree,
|
||||
create_engine_.current_level_type() == ng::level::TYPE::CAMPAIGN ? "campaign" : "multiplayer",
|
||||
create_engine_.current_level().data()["id"], create_engine_.current_level().data());
|
||||
|
||||
display_custom_options(options_tree, "era", create_engine_.curent_era_cfg()["id"], create_engine_.curent_era_cfg());
|
||||
|
||||
std::set<std::string> activemods(create_engine_.active_mods().begin(), create_engine_.active_mods().end());
|
||||
for (const auto& mod : create_engine_.get_const_extras_by_type(ng::create_engine::MP_EXTRA::MOD)) {
|
||||
for(const auto& mod : create_engine_.get_const_extras_by_type(ng::create_engine::MP_EXTRA::MOD)) {
|
||||
if (activemods.find(mod->id) != activemods.end()) {
|
||||
display_custom_options(options_tree, "modification", mod->id, *mod->cfg);
|
||||
}
|
||||
|
@ -514,9 +523,6 @@ void tmp_create_game::update_details(twindow& window)
|
|||
eras->set_active(create_engine_.current_level().allow_era_choice());
|
||||
}
|
||||
|
||||
// TODO: remove this
|
||||
//scenario_ = &cfg_.child("multiplayer", index);
|
||||
|
||||
// If the current random map doesn't have data, generate it
|
||||
if(create_engine_.current_level_type() == ng::level::TYPE::RANDOM_MAP) {
|
||||
if(create_engine_.generator_assigned() && create_engine_.current_level().data()["map_data"].empty()) {
|
||||
|
@ -554,7 +560,7 @@ void tmp_create_game::update_details(twindow& window)
|
|||
|
||||
create_engine_.get_state().classification().campaign = current_campaign->data()["id"].str();
|
||||
|
||||
const std::string image = formatter() << current_campaign->data()["image"] << "~SCALE(240,240)";
|
||||
const std::string image = formatter() << current_campaign->data()["image"] << "~SCALE_INTO(240,240)";
|
||||
|
||||
find_widget<tstacked_widget>(&window, "minimap_stack", false).select_layer(1);
|
||||
find_widget<timage>(&window, "campaign_image", false).set_label(image);
|
||||
|
@ -671,6 +677,18 @@ void tmp_create_game::post_show(twindow& window)
|
|||
}
|
||||
|
||||
config_engine_->set_options(options);
|
||||
|
||||
// Set game name
|
||||
const std::string name = find_widget<ttext_box>(&window, "game_name", false).get_value();
|
||||
if(!name.empty() && (name != config_engine_->game_name_default())) {
|
||||
config_engine_->set_game_name(name);
|
||||
}
|
||||
|
||||
// Set game password
|
||||
const std::string password = find_widget<ttext_box>(&window, "game_password", false).get_value();
|
||||
if(!password.empty()) {
|
||||
config_engine_->set_game_password(password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ private:
|
|||
ng::create_engine& create_engine_;
|
||||
std::unique_ptr<ng::configure_engine> config_engine_;
|
||||
|
||||
int selected_game_index_;
|
||||
|
||||
std::vector<level_type_info> level_types_;
|
||||
|
||||
void update_games_list(twindow& window);
|
||||
|
@ -69,6 +71,8 @@ private:
|
|||
|
||||
tfield_integer* turns_, *gold_, *support_, *experience_, *init_turn_limit, *turn_bonus_, *reservior_, *action_bonus_;
|
||||
|
||||
void num_players_filter_callback(twindow& window);
|
||||
|
||||
void on_game_select(twindow& window);
|
||||
|
||||
void on_tab_select(twindow& window);
|
||||
|
@ -82,8 +86,6 @@ private:
|
|||
|
||||
void update_options_list(twindow& window);
|
||||
|
||||
int selected_game_index_;
|
||||
|
||||
public:
|
||||
// another map selected
|
||||
void update_details(twindow& window);
|
||||
|
|
Loading…
Add table
Reference in a new issue