tunit_preview_pane: general cleanup and functionality improvements

This includes:
* Allowing the details area to scroll should the parent dialog not be long enough.
* Scaling all displayed sprites to 144x144 while maintaining aspect ratio.
* Forcing extra width so all mainline unit names have enough space to appear.
* Removing the unused 'minimal' definition. Might be added back later.
* Fixing the borders. The internal widgets shouldn't have outside borders, since borders
  should be set for the widget instance in a containing dialog.
This commit is contained in:
Charles Dang 2016-08-04 01:11:02 +11:00
parent e7068e35d5
commit c2b09cbe5b
3 changed files with 51 additions and 165 deletions

View file

@ -7,9 +7,24 @@
grow_factor = 0
[column]
border = "all"
grow_factor = 1
horizontal_grow = "true"
[spacer]
width = 225
[/spacer]
[/column]
[/row]
[row]
grow_factor = 0
[column]
border = "bottom"
border_size = 5
horizontal_alignment = "left"
horizontal_grow = "true"
vertical_alignment = "center"
[image]
@ -23,8 +38,9 @@
[row]
grow_factor = 0
[column]
border = "all"
border = "top,bottom"
border_size = 5
vertical_grow = "true"
horizontal_grow = "true"
@ -52,7 +68,7 @@
[column]
grow_factor = 0
border = "left,right"
border = "right"
border_size = 5
horizontal_alignment = "left"
@ -88,7 +104,7 @@
[column]
grow_factor = 1
border = "left,right"
border = "left"
border_size = 5
horizontal_alignment = "right"
@ -113,141 +129,17 @@
grow_factor = 1
[column]
vertical_grow = "true"
horizontal_alignment = "left"
border = "all"
border_size = 5
[label]
id = "type_details"
definition = "default_small"
wrap = "true"
[/label]
[/column]
[/row]
[/grid]
#enddef
#define _GUI_UNIT_PREVIEW_PANE_MINIMAL
[grid]
[row]
grow_factor = 0
[column]
border = "bottom"
border_size = 5
horizontal_alignment = "center"
vertical_alignment = "center"
[image]
id = "type_image"
definition = "default"
[/image]
[/column]
[/row]
[row]
grow_factor = 0
[column]
border = "bottom"
border_size = 5
horizontal_alignment = "center"
[button]
id = "type_profile"
definition = "default"
label = _ "Profile"
[/button]
[/column]
[/row]
[row]
grow_factor = 0
[column]
border = "bottom"
border_size = 5
vertical_grow = "true"
horizontal_grow = "true"
[label]
id = "type_name"
wrap = "true"
[/label]
[/column]
[/row]
[row]
grow_factor = 0
[column]
border = "right,bottom"
border = "top"
border_size = 5
horizontal_alignment = "left"
[label]
id = "type_level"
[/label]
[/column]
[/row]
[row]
grow_factor = 0
[column]
border = "right,bottom"
border_size = 5
horizontal_alignment = "left"
[label]
id = "type_race"
[/label]
[/column]
[/row]
[row]
grow_factor = 0
[column]
border = "right,bottom"
border_size = 5
horizontal_alignment = "left"
[label]
id = "type_alignment"
[/label]
[/column]
[/row]
[row]
grow_factor = 1
[column]
vertical_grow = "true"
horizontal_alignment = "left"
[label]
[scroll_label]
id = "type_details"
definition = "default_small"
vertical_scrollbar_mode = "auto"
wrap = "true"
[/label]
[/scroll_label]
[/column]
@ -440,13 +332,6 @@
{_GUI_RESOLUTION ({_GUI_UNIT_PREVIEW_PANE_FULL})}
[/unit_preview_pane_definition]
[unit_preview_pane_definition]
id = "minimal"
description = "A unit preview pane without the image or title."
{_GUI_RESOLUTION ({_GUI_UNIT_PREVIEW_PANE_MINIMAL})}
[/unit_preview_pane_definition]
[unit_preview_pane_definition]
id = "unit_minimal_left"
description = "A more text-based unit preview pane, used in the attack dialog with the sprite to the left."

View file

@ -54,8 +54,8 @@ void tunit_preview_pane::finalize_setup()
// Labels
label_name_ = find_widget<tlabel>(this, "type_name" , false, false);
label_level_ = find_widget<tlabel>(this, "type_level" , false, false);
label_details_ = find_widget<tlabel>(this, "type_details", false, false);
label_details_minimal_ = find_widget<tlabel>(this, "type_details_minimal", false, false);
label_details_ = find_widget<tcontrol>(this, "type_details", false, false);
label_details_minimal_ = find_widget<tcontrol>(this, "type_details_minimal", false, false);
// Profile button
button_profile_ = find_widget<tbutton>(this, "type_profile", false, false);
@ -72,23 +72,23 @@ void tunit_preview_pane::finalize_setup()
*/
void tunit_preview_pane::print_attack_details(const std::vector<attack_type>& attacks, std::stringstream& str)
{
str << "<b>" << _("Attacks") << "</b>" << "\n";
str << "<b>" << _("Attacks") << "</b>";
for(const auto& a : attacks) {
str << "<span color='#f5e6c1'>" << a.damage()
<< font::weapon_numbers_sep << a.num_attacks() << " " << a.name() << "</span>" << "\n";
str << "\n" << "<span color='#f5e6c1'>" << a.damage()
<< font::weapon_numbers_sep << a.num_attacks() << " " << a.name() << "</span>";
str << "<span color='#a69275'>" << " " << a.range()
<< font::weapon_details_sep << a.type() << "</span>" << "\n";
str << "\n" << "<span color='#a69275'>" << " " << a.range()
<< font::weapon_details_sep << a.type() << "</span>";
const std::string special = a.weapon_specials();
if (!special.empty()) {
str << "<span color='#a69275'>" << " " << special << "</span>" << "\n";
str << "\n" << "<span color='#a69275'>" << " " << special << "</span>";
}
const std::string accuracy_parry = a.accuracy_parry_description();
if(!accuracy_parry.empty()) {
str << "<span color='#a69275'>" << " " << accuracy_parry << "</span>" << "\n";
str << "\n" << "<span color='#a69275'>" << " " << accuracy_parry << "</span>";
}
}
}
@ -106,8 +106,8 @@ void tunit_preview_pane::set_displayed_type(const unit_type* type)
team::get_side_color_index(resources::controller->current_side())
+ ")";
}
mods += image_mods_;
mods += "~SCALE_INTO_SHARP(144,144)" + image_mods_;
icon_type_->set_label((type->icon().empty() ? type->image() : type->icon()) + mods);
}
@ -145,17 +145,17 @@ void tunit_preview_pane::set_displayed_type(const unit_type* type)
std::stringstream str;
str << "<small>";
str << "<b>" << _("HP: ") << "</b>"
<< "<span color='#21e100'>" << type->hitpoints() << "</span> ";
str << "<span color='#21e100'>"
<< "<b>" << _("HP: ") << "</b>" << type->hitpoints() << "</span>" << " | ";
str << "<b>" << _("XP: ") << "</b>"
<< "<span color='#00a0e1'>" << type->experience_needed() << "</span> ";
str << "<span color='#00a0e1'>"
<< "<b>" << _("XP: ") << "</b>" << type->experience_needed() << "</span>" << " | ";
str << "<b>" << _("MP: ") << "</b>"
<< type->movement() << "\n";
<< type->movement();
str << "</small>";
str << "\n";
str << "\n\n";
// Print trait details
std::stringstream t_str;
@ -219,7 +219,7 @@ void tunit_preview_pane::set_displayed_unit(const unit* unit)
mods += "~BLIT(" + overlay + ")";
}
mods += image_mods_;
mods += "~SCALE_INTO_SHARP(144,144)" + image_mods_;
icon_type_->set_label(unit->absolute_image() + mods);
}
@ -266,7 +266,7 @@ void tunit_preview_pane::set_displayed_unit(const unit* unit)
const std::string name = "<span size='large'>" + (!unit->name().empty() ? unit->name() : " ") + "</span>";
str << name << "\n";
str << "<span color='#f5e6c1'>" << unit->type_name() << "</span>" << "\n";
str << "<small><span color='#a69275'>" << unit->type_name() << "</span></small>" << "\n";
str << "Lvl " << unit->level() << "\n";
@ -297,11 +297,11 @@ void tunit_preview_pane::set_displayed_unit(const unit* unit)
std::stringstream str;
str << "<small>";
str << "<b>" << _("HP: ") << "</b>"
<<font::span_color(unit->hp_color()) << unit->hitpoints() << "/" << unit->max_hitpoints() << "</span>" << " | ";
str << font::span_color(unit->hp_color())
<< "<b>" << _("HP: ") << "</b>" << unit->hitpoints() << "/" << unit->max_hitpoints() << "</span>" << " | ";
str << "<b>" << _("XP: ") << "</b>"
<< font::span_color(unit->xp_color()) << unit->experience() << "/" << unit->max_experience() << "</span>" << " | ";
str << font::span_color(unit->xp_color())
<< "<b>" << _("XP: ") << "</b>" << unit->experience() << "/" << unit->max_experience() << "</span>" << " | ";
str << "<b>" << _("MP: ") << "</b>"
<< unit->movement_left() << "/" << unit->total_movement();

View file

@ -94,8 +94,9 @@ private:
tlabel* label_name_;
tlabel* label_level_;
tlabel* label_details_;
tlabel* label_details_minimal_;
tcontrol* label_details_;
tcontrol* label_details_minimal_;
tbutton* button_profile_;