From 4c0a012b5b54fff6474c9232ccdc75eab2de65df Mon Sep 17 00:00:00 2001 From: josteph Date: Tue, 17 Sep 2019 12:46:11 +0000 Subject: [PATCH] unit_preview_pane: Make the unit description button open the help on the right variation Fixes #4142 --- src/gui/widgets/unit_preview_pane.cpp | 11 ++++------- src/gui/widgets/unit_preview_pane.hpp | 3 ++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gui/widgets/unit_preview_pane.cpp b/src/gui/widgets/unit_preview_pane.cpp index 1148c860b456..84087ac8a45b 100644 --- a/src/gui/widgets/unit_preview_pane.cpp +++ b/src/gui/widgets/unit_preview_pane.cpp @@ -268,7 +268,7 @@ void unit_preview_pane::print_attack_details(T attacks, tree_view_node& parent_n void unit_preview_pane::set_displayed_type(const unit_type& type) { // Sets the current type id for the profile button callback to use - current_type_ = type.id(); + current_type_ = type; if(icon_type_) { std::string mods; @@ -410,7 +410,7 @@ void unit_preview_pane::set_displayed_type(const unit_type& type) void unit_preview_pane::set_displayed_unit(const unit& u) { // Sets the current type id for the profile button callback to use - current_type_ = u.type_id(); + current_type_ = u.type(); if(icon_type_) { std::string mods = u.image_mods(); @@ -555,11 +555,8 @@ void unit_preview_pane::set_displayed_unit(const unit& u) void unit_preview_pane::profile_button_callback() { - if(get_window()) { - const unit_type* ut = unit_types.find(current_type_); - if(ut != nullptr) { - help::show_unit_description(*ut); - } + if(get_window() && current_type_) { + help::show_unit_description(*current_type_); } } diff --git a/src/gui/widgets/unit_preview_pane.hpp b/src/gui/widgets/unit_preview_pane.hpp index 16f727b4fe19..0a7b10ebfa8c 100644 --- a/src/gui/widgets/unit_preview_pane.hpp +++ b/src/gui/widgets/unit_preview_pane.hpp @@ -15,6 +15,7 @@ #include "gui/widgets/container_base.hpp" +#include #include class unit; @@ -73,7 +74,7 @@ class unit_preview_pane : public container_base void finalize_setup(); private: - std::string current_type_; + boost::optional current_type_; image* icon_type_; image* icon_race_;