unit_preview_pane: Add attack icons

This commit is contained in:
josteph 2018-11-22 07:19:41 +00:00
parent 6dd39915a5
commit c720e6686e
2 changed files with 66 additions and 4 deletions

View file

@ -183,6 +183,55 @@
[/node_definition]
[/node]
[node]
id = "item_image"
unfolded = true
[node_definition]
[row]
[column]
grow_factor = 0
horizontal_grow = false
vertical_grow = false
horizontal_alignment = "left"
vertical_alignment = "top"
border = "top,right"
border_size = 3
[image]
definition = "default"
id = "image_range"
[/image]
[/column]
[column]
grow_factor = 0
horizontal_grow = false
vertical_grow = false
horizontal_alignment = "left"
vertical_alignment = "top"
border = "top,right"
border_size = 3
[image]
definition = "default"
id = "image_type"
[/image]
[/column]
[column]
grow_factor = 1
horizontal_grow = false
vertical_grow = false
horizontal_alignment = "left"
vertical_alignment = "top"
border = "top,bottom"
border_size = 1
[label]
wrap = true
definition = "default_small"
id = "name"
[/label]
[/column]
[/row]
[/node_definition]
[/node]
[node]
id = "hp_xp_mp"
unfolded = true

View file

@ -217,6 +217,10 @@ void unit_preview_pane::print_attack_details(T attacks, tree_view_node& parent_n
);
for(const auto& a : attacks) {
const std::string range_png = std::string("icons/profiles/") + a.range() + "_attack.png~SCALE_INTO_SHARP(16,16)";
const std::string type_png = std::string("icons/profiles/") + a.type() + ".png~SCALE_INTO_SHARP(16,16)";
const bool range_png_exists = ::image::locator(range_png).file_exists();
const bool type_png_exists = ::image::locator(type_png).file_exists();
auto& subsection = add_name_tree_node(
header_node,
@ -224,12 +228,21 @@ void unit_preview_pane::print_attack_details(T attacks, tree_view_node& parent_n
(formatter() << font::span_color(font::unit_type_color) << a.damage() << font::weapon_numbers_sep << a.num_attacks() << " " << a.name() << "</span>").str()
);
add_name_tree_node(
subsection,
"item",
(formatter() << font::span_color(font::weapon_details_color) << string_table["range_" + a.range()] << font::weapon_details_sep << string_table["type_" + a.type()] << "</span>").str()
subsection.add_child("item_image",
{
{ "image_range", { { "label", range_png }, { "use_markup", "true" } } },
{ "image_type", { { "label", type_png }, { "use_markup", "true" } } },
}
);
if(!range_png_exists || !type_png_exists) {
add_name_tree_node(
subsection,
"item",
(formatter() << font::span_color(font::weapon_details_color) << string_table["range_" + a.range()] << font::weapon_details_sep << string_table["type_" + a.type()] << "</span>").str()
);
}
for(const auto& pair : a.special_tooltips()) {
add_name_tree_node(
subsection,