Attack Predictions: interface improvements

This commit is contained in:
Charles Dang 2017-03-22 05:18:26 +11:00
parent ba8a1188ac
commit 27f2826703
2 changed files with 237 additions and 205 deletions

View file

@ -19,95 +19,172 @@
[/row]
#enddef
#define _GUI_DATA_PANEL _HEADER _ID_PREFIX
#define _GUI_DATA_PANEL _ID_PREFIX
[grid]
[row]
[column]
border = "all"
border_size = 5
grow_factor = 1
horizontal_alignment = "left"
vertical_grow = true
[grid]
[row]
[column]
border = "left,right,top"
border_size = 5
horizontal_alignment = "left"
[label]
label = _ "Base damage"
definition = "default_small"
linked_group = "header"
[/label]
[/column]
[/row]
[row]
[column]
border = "left,right,top"
border_size = 5
horizontal_alignment = "left"
[label]
#label = _ "Opponent resistance against"
label = _ "Modifiers"
definition = "default_small"
linked_group = "header"
[/label]
[/column]
[/row]
{_GUI_SPACER_ROW}
[row]
[column]
border = "left,right,top"
border_size = 5
horizontal_alignment = "left"
[label]
label = _ "Total damage"
definition = "default_small"
linked_group = "header"
[/label]
[/column]
[/row]
[row]
[column]
border = "left,right,top"
border_size = 5
horizontal_alignment = "left"
[label]
label = _ "Chance of being unscathed"
definition = "default_small"
linked_group = "header"
[/label]
[/column]
[/row]
[/grid]
[label]
label = {_HEADER}
definition = "default_bold"
linked_group = "header"
[/label]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
grow_factor = 0
horizontal_grow = true
vertical_grow = true
[label]
id = {_ID_PREFIX} + "_attack"
definition = "default"
linked_group = "header"
[grid]
use_markup = "true"
[/label]
[/column]
[row]
[/row]
[column]
border = "left,right,top"
border_size = 5
horizontal_alignment = "left"
[row]
[label]
id = {_ID_PREFIX} + "_attack"
definition = "default_small"
linked_group = "header"
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
use_markup = "true"
[/label]
[/column]
[label]
id = {_ID_PREFIX} + "_resis"
definition = "default"
linked_group = "header"
[/row]
use_markup = "true"
[/label]
[/column]
[row]
[/row]
[column]
border = "left,right,top"
border_size = 5
horizontal_alignment = "left"
{_GUI_SPACER_ROW}
[label]
id = {_ID_PREFIX} + "_resis"
definition = "default_small"
linked_group = "header"
[row]
use_markup = "true"
[/label]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[/row]
[label]
id = {_ID_PREFIX} + "_damage"
definition = "default"
linked_group = "header"
{_GUI_SPACER_ROW}
use_markup = "true"
[/label]
[/column]
[row]
[/row]
[column]
border = "left,right,top"
border_size = 5
horizontal_alignment = "left"
[row]
[label]
id = {_ID_PREFIX} + "_damage"
definition = "default_small"
linked_group = "header"
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
use_markup = "true"
[/label]
[/column]
[label]
id = {_ID_PREFIX} + "_no_damage_chance"
definition = "default"
linked_group = "header"
[/row]
[row]
[column]
border = "left,right,top"
border_size = 5
horizontal_alignment = "left"
[label]
id = {_ID_PREFIX} + "_no_damage_chance"
definition = "default_small"
linked_group = "header"
use_markup = "true"
[/label]
[/column]
[/row]
[/grid]
use_markup = "true"
[/label]
[/column]
[/row]
@ -120,8 +197,8 @@
id = {_ID_PREFIX} + "_hp_graph"
definition = "default"
width = 300
height = 200
width = 270
height = 170
[draw]
@ -130,9 +207,9 @@
y = 0
w = "(width)"
h = "(height)"
fill_color = "25, 25, 25, 255"
fill_color = {GUI__BACKGROUND_COLOR_DISABLED}
border_thickness = 2
border_color = "183, 193, 183, 255"
border_color = {GUI__FONT_COLOR_DISABLED__DEFAULT}
[/rectangle]
[rectangle]
@ -140,7 +217,7 @@
y = 0
w = 2
h = "(height - 2)"
fill_color = "183, 193, 183, 255"
fill_color = {GUI__FONT_COLOR_DISABLED__DEFAULT}
[/rectangle]
[rectangle]
@ -148,7 +225,7 @@
y = 0
w = 2
h = "(height - 2)"
fill_color = "183, 193, 183, 255"
fill_color = {GUI__FONT_COLOR_DISABLED__DEFAULT}
[/rectangle]
[/draw]
@ -156,6 +233,70 @@
[/drawing]
#enddef
#define _GUI_DATA_COLUMN _HEADER _ID_PREFIX
[grid]
linked_group = "main_column"
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "center"
[label]
label = {_HEADER}
definition = "default_large"
linked_group = "header"
[/label]
[/column]
[/row]
[row]
[column]
horizontal_grow = true
{_GUI_DATA_PANEL ({_ID_PREFIX})}
[/column]
[/row]
{_GUI_SPACER_ROW}
[row]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "center"
[label]
definition = "default_small"
label = _ "Expected Battle Result (HP)"
[/label]
[/column]
[/row]
[row]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "center"
{_GUI_HP_GRAPH ({_ID_PREFIX})}
[/column]
[/row]
[/grid]
#enddef
[window]
id = "attack_predictions"
description = "Statistics dialog."
@ -169,6 +310,11 @@
#maximum_height = 400
[linked_group]
id = "main_column"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "header"
fixed_height = "true"
@ -241,107 +387,21 @@
[row]
[column]
grow_factor = 0
horizontal_alignment = "left"
[grid]
[row]
[column]
border = "all"
border_size = 5
[spacer]
linked_group = "header"
[/spacer]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
label = _ "Base damage"
definition = "default"
linked_group = "header"
[/label]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
#label = _ "Opponent resistance against"
label = _ "Modifiers"
definition = "default"
linked_group = "header"
[/label]
[/column]
[/row]
{_GUI_SPACER_ROW}
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
label = _ "Total damage"
definition = "default"
linked_group = "header"
[/label]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
label = _ "Chance of being unscathed"
definition = "default"
linked_group = "header"
[/label]
[/column]
[/row]
[/grid]
grow_factor = 1
horizontal_grow = true
vertical_grow = true
{_GUI_DATA_COLUMN ( _ "Attacker") ("attacker")}
[/column]
{GUI_VERTICAL_SPACER_LINE}
[column]
grow_factor = 1
horizontal_grow = "true"
horizontal_grow = true
vertical_grow = true
{_GUI_DATA_PANEL ( _ "Attacker") ("attacker")}
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
{_GUI_DATA_PANEL ( _ "Defender") ("defender")}
{_GUI_DATA_COLUMN ( _ "Defender") ("defender")}
[/column]
[/row]
@ -352,43 +412,6 @@
[/row]
[row]
grow_factor = 1
[column]
horizontal_grow = true
[grid]
[row]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_grow = true
vertical_grow = true
{_GUI_HP_GRAPH ("attacker")}
[/column]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_grow = true
vertical_grow = true
{_GUI_HP_GRAPH ("defender")}
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
grow_factor = 0
@ -413,6 +436,7 @@
[/window]
#undef _GUI_DATA_COLUMN
#undef _GUI_HP_GRAPH
#undef _GUI_DATA_PANEL
#undef _GUI_SPACER_ROW

View file

@ -42,8 +42,8 @@ namespace dialogs
REGISTER_DIALOG(attack_predictions)
const unsigned int attack_predictions::graph_width = 300;
const unsigned int attack_predictions::graph_height = 200;
const unsigned int attack_predictions::graph_width = 270;
const unsigned int attack_predictions::graph_height = 170;
const unsigned int attack_predictions::graph_max_rows = 10;
attack_predictions::attack_predictions(battle_context& bc, const unit& attacker, const unit& defender)
@ -161,6 +161,13 @@ void attack_predictions::set_data(window& window, const combatant_data& attacker
// Resistance modifier.
const int resistance_modifier = defender.unit_.damage_from(*weapon, !attacker.stats_.is_attacker, defender.unit_.get_location());
if(resistance_modifier != 100) {
// TODO
//if(attacker.stats_.is_attacker) {
// ss << "Defender resistance vs ";
//} else {
// ss << "Attacker vulnerability vs ";
//}
ss << string_table["type_" + weapon->type()] << ": ";
ss << font::unicode_multiplication_sign << (resistance_modifier / 100) << "." << ((resistance_modifier % 100) / 10);
@ -199,7 +206,7 @@ void attack_predictions::set_data(window& window, const combatant_data& attacker
set_label_helper("attack", _("No usable weapon"));
}
const color_t ndc_color = game_config::red_to_green(attacker.combatant_.untouched * 10);
const color_t ndc_color = game_config::red_to_green(attacker.combatant_.untouched * 100);
// Unscathed probability.
set_label_helper("no_damage_chance",
@ -213,13 +220,14 @@ void attack_predictions::set_data(window& window, const combatant_data& attacker
void attack_predictions::draw_hp_graph(drawing& hp_graph, const combatant_data& attacker, const combatant_data& defender)
{
// Font size. If you change this, you must update the separator space.
// TODO: probably should remove this.
const int fs = font::SIZE_SMALL;
// Space before HP separator.
const int hp_sep = 24 + 6;
const int hp_sep = 30;
// Space after percentage separator.
const int percent_sep = 43 + 6;
const int percent_sep = 50;
// Bar space between both separators.
const int bar_space = graph_width - hp_sep - percent_sep - 4;
@ -264,7 +272,7 @@ void attack_predictions::draw_hp_graph(drawing& hp_graph, const combatant_data&
}
shape["text"] = hp;
shape["x"] = 2;
shape["x"] = 4;
shape["y"] = 2 + (fs + 2) * i;
shape["w"] = "(text_width)";
shape["h"] = "(text_height)";