unit_preview_pane: Make the unit description button open the help on the right variation
Fixes #4142
This commit is contained in:
parent
f6cc138c20
commit
4c0a012b5b
2 changed files with 6 additions and 8 deletions
|
@ -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_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "gui/widgets/container_base.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <string>
|
||||
|
||||
class unit;
|
||||
|
@ -73,7 +74,7 @@ protected:
|
|||
void finalize_setup();
|
||||
|
||||
private:
|
||||
std::string current_type_;
|
||||
boost::optional<const unit_type&> current_type_;
|
||||
|
||||
image* icon_type_;
|
||||
image* icon_race_;
|
||||
|
|
Loading…
Add table
Reference in a new issue