void mp_staging::on_team_select(window& window, ng::side_engine_ptr side, menu_button& team_menu, bool& handled, bool& halt) { side->set_team(team_menu.get_value()); // First, remove the node from the tree find_widget<tree_view>(&window, "side_list", false).remove_node(side_tree_map_[side]); // Then add a new node as a child to the appropriate team's node add_side_node(window, side); set_state_changed(); handled = true; halt = true; }
void mp_staging::on_ai_select(ng::side_engine_ptr side, menu_button& ai_menu, const bool saved_game) { // If this is a saved game, we need to reduce the index by one, to account for // the "Keep saved AI" option having been added to the computer player menu int i = ai_menu.get_value(); if(saved_game) { i--; } if(i < 0) { side->set_ai_algorithm("use_saved"); } else { side->set_ai_algorithm(ai_algorithms_[i]->id); } set_state_changed(); }
void mp_staging::on_team_select(window& window, ng::side_engine_ptr side, menu_button& team_menu) { // Since we're not necessarily displaying every every team in the menu, we can't just // use the selected index to set a side's team. Instead, we grab the index we stored // in add_side_node from the selected config, which should correspond to the // appropriate entry in the connect_engine's team name vector. const unsigned team_index = team_menu.get_value_config()["team_index"].to_unsigned(); if(team_index == side->team()) { return; } side->set_team(team_index); // First, remove the node from the tree auto node = find_widget<tree_view>(&window, "side_list", false).remove_node(side_tree_map_[side]); // Then add a new node as a child to the appropriate team's node team_tree_map_[side->team_name()]->add_child(std::move(node.first), get_side_node_position(side)); set_state_changed(); }
void mp_staging::on_ai_select(ng::side_engine_ptr side, menu_button& ai_menu) { side->set_ai_algorithm(ai_algorithms_[ai_menu.get_value()]->id); set_state_changed(); }