Skip to content

Commit

Permalink
unit_preview_pane: Make the unit description button open the help on …
Browse files Browse the repository at this point in the history
…the right variation

Fixes #4142
  • Loading branch information
jostephd committed Sep 17, 2019
1 parent f6cc138 commit 4c0a012
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/gui/widgets/unit_preview_pane.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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_);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/widgets/unit_preview_pane.hpp
Expand Up @@ -15,6 +15,7 @@

#include "gui/widgets/container_base.hpp"

#include <boost/optional.hpp>
#include <string>

class unit;
Expand Down Expand Up @@ -73,7 +74,7 @@ class unit_preview_pane : public container_base
void finalize_setup();

private:
std::string current_type_;
boost::optional<const unit_type&> current_type_;

image* icon_type_;
image* icon_race_;
Expand Down

0 comments on commit 4c0a012

Please sign in to comment.