unit preview pane: use overloaded functions to set data

This commit is contained in:
Subhraman Sarkar 2024-12-12 08:45:06 +05:30 committed by Charles Dang
parent 2dcfe2435c
commit 2debd74605
9 changed files with 14 additions and 14 deletions

View file

@ -101,7 +101,7 @@ void unit_advance::list_item_clicked()
}
find_widget<unit_preview_pane>("advancement_details")
.set_displayed_unit(*previews_[selected_row]);
.set_display_data(*previews_[selected_row]);
}
void unit_advance::show_help()

View file

@ -61,10 +61,10 @@ void unit_attack::pre_show()
std::bind(&unit_attack::damage_calc_callback, this));
find_widget<unit_preview_pane>("attacker_pane")
.set_displayed_unit(*attacker_itor_);
.set_display_data(*attacker_itor_);
find_widget<unit_preview_pane>("defender_pane")
.set_displayed_unit(*defender_itor_);
.set_display_data(*defender_itor_);
selected_weapon_ = -1;

View file

@ -168,7 +168,7 @@ void unit_create::update_displayed_type()
ut = &ut->get_variation(variation_);
}
find_widget<unit_preview_pane>("unit_details").set_displayed_type(*ut);
find_widget<unit_preview_pane>("unit_details").set_display_data(*ut);
}
void unit_create::list_item_clicked()

View file

@ -171,7 +171,7 @@ void unit_list::list_item_clicked()
}
find_widget<unit_preview_pane>("unit_details")
.set_displayed_unit(*unit_list_[selected_row].get());
.set_display_data(*unit_list_[selected_row].get());
}
void unit_list::post_show()

View file

@ -419,7 +419,7 @@ void unit_recall::list_item_clicked()
const unit& selected_unit = *recall_list_[selected_row].get();
find_widget<unit_preview_pane>("unit_details")
.set_displayed_unit(selected_unit);
.set_display_data(selected_unit);
find_widget<button>("rename").set_active(!selected_unit.unrenamable());
}

View file

@ -181,7 +181,7 @@ void unit_recruit::list_item_clicked()
}
find_widget<unit_preview_pane>("recruit_details")
.set_displayed_type(*recruit_list_[selected_row]);
.set_display_data(*recruit_list_[selected_row]);
}
void unit_recruit::show_help()

View file

@ -258,7 +258,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)
void unit_preview_pane::set_display_data(const unit_type& type)
{
// Sets the current type id for the profile button callback to use
current_type_ = type;
@ -389,7 +389,7 @@ void unit_preview_pane::set_displayed_type(const unit_type& type)
}
}
void unit_preview_pane::set_displayed_unit(const unit& u)
void unit_preview_pane::set_display_data(const unit& u)
{
// Sets the current type id for the profile button callback to use
current_type_ = u.type();

View file

@ -47,10 +47,10 @@ public:
explicit unit_preview_pane(const implementation::builder_unit_preview_pane& builder);
/** Displays the stats of a specified unit type */
void set_displayed_type(const unit_type& type);
void set_display_data(const unit_type& type);
/** Displays the stats of a specific unit */
void set_displayed_unit(const unit& u);
void set_display_data(const unit& u);
/** Sets the facing of the unit image */
void set_image_mods(const std::string& mods);
@ -71,7 +71,7 @@ protected:
/**
* Initializes the internal sub-widget pointers.
* Should be called when building the window, so the pointers
* are initialized when set_displayed_type() is called.
* are initialized when set_display_data() is called.
*/
void finalize_setup();

View file

@ -375,9 +375,9 @@ WIDGET_SETTER("value_compat,unfolded", bool, gui2::tree_view_node)
WIDGET_SETTER("value_compat,unit", lua_index_raw, gui2::unit_preview_pane)
{
if(const unit_type* ut = luaW_tounittype(L, value.index)) {
w.set_displayed_type(*ut);
w.set_display_data(*ut);
} else if(unit* u = luaW_tounit(L, value.index)) {
w.set_displayed_unit(*u);
w.set_display_data(*u);
} else {
luaW_type_error(L, value.index, "unit or unit type");
}