Skip to content

Commit

Permalink
MP Faction Select dialog: Show leader unit details.
Browse files Browse the repository at this point in the history
If the leader hasn't been discovered, the "Unknown Unit" topic will be shown.

Fixes #1491
  • Loading branch information
jostephd authored and jyrkive committed Jun 21, 2018
1 parent 05f2b19 commit 8fe296d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions data/gui/window/mp_faction_select.cfg
Expand Up @@ -132,6 +132,15 @@

[/column]

[column]
[button]
id = "type_profile"
definition = "action_about"

label = _ "Profile"
[/button]
[/column]

[/row]

[/grid]
Expand Down
22 changes: 22 additions & 0 deletions src/gui/dialogs/multiplayer/faction_select.cpp
Expand Up @@ -26,11 +26,14 @@
#include "gui/widgets/settings.hpp"
#include "gui/widgets/image.hpp"
#include "gui/widgets/label.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/menu_button.hpp"
#include "gui/widgets/toggle_button.hpp"
#include "gui/widgets/window.hpp"
#include "formatter.hpp"
#include "game_config_manager.hpp"
#include "gettext.hpp"
#include "help/help.hpp"
#include "units/types.hpp"

#include "utils/functional.hpp"
Expand Down Expand Up @@ -78,6 +81,10 @@ void faction_select::pre_show(window& window)
connect_signal_notify_modified(find_widget<menu_button>(&window, "leader_menu", false),
std::bind(&faction_select::on_leader_select, this, std::ref(window)));

// Leader's profile button
find_widget<button>(&window, "type_profile", false).connect_click_handler(
std::bind(&faction_select::profile_button_callback, this, std::ref(window)));

//
// Set up faction list
//
Expand Down Expand Up @@ -195,6 +202,21 @@ void faction_select::on_leader_select(window& window)
});

update_leader_image(window);

// Disable the profile button if leader_type is dash or "Random"
button& profile_button = find_widget<button>(&window, "type_profile", false);
const std::string& leader_type = find_widget<menu_button>(&window, "leader_menu", false).get_value_string();
profile_button.set_active(unit_types.find(leader_type) != nullptr);
}

void faction_select::profile_button_callback(window& window)
{
const std::string& leader_type = find_widget<menu_button>(&window, "leader_menu", false).get_value_string();
const unit_type* ut = unit_types.find(leader_type);
if(ut != nullptr) {
help::help_manager help_manager(&game_config_manager::get()->game_config());
help::show_unit_description(*ut);
}
}

void faction_select::on_gender_select(window& window)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/dialogs/multiplayer/faction_select.hpp
Expand Up @@ -57,6 +57,8 @@ class faction_select : public modal_dialog

void on_leader_select(window& window);

void profile_button_callback(window& window);

void on_gender_select(window& window);

void update_leader_image(window& window);
Expand Down

0 comments on commit 8fe296d

Please sign in to comment.