GUI2/Story Viewer: refine recent design updates, fix some layout issues

This commit is contained in:
Charles Dang 2024-05-25 00:26:11 -04:00
parent 9f1a92d71a
commit 4cb9df8e6c
3 changed files with 149 additions and 73 deletions

View File

@ -9,8 +9,22 @@
{RESOLUTION}
min_width = 0
min_height = 0
#
# NOTE: there's a very weird bug where if this is not set, during very specific story screens
# (you can currently observe it in HttT), the button will be greately reduced in width. This
# effect will *only* appear on certain screens consistently, and it will go away and reappear
# when nevigating to and from that screen. This is also observed with the default button only
# if *no labe is set*. If a label is set the issue will not appear. For the default button, it
# appears as if it's being reset to min_width, but the bug will stil appear here if this value
# is set to 0. In that case, though, the observed width will not be 0. We can work around this
# by setting min values, but at some point it should be looked into.
#
# See https://github.com/wesnoth/wesnoth/pull/8510#issuecomment-2130657988
# - vultraz, 2024-05-25
#
min_width = 128
min_height = 128
default_width = 128
default_height = 128
@ -82,14 +96,14 @@
### Text helper macro, from button_default.cfg
#define _GUI_BUTTON_TEXT DX DY FONT_SIZE FONT_STYLE FONT_COLOR FONT_FAMILY
#define _GUI_BUTTON_TEXT FONT_STYLE FONT_COLOR FONT_FAMILY
[text]
# relative positioning of text so that it doesn't overlap with the preceding image
x = {DX}
y = {DY}
x = "(max(iw + 5, width / 2 - text_width / 2))"
y = {GUI__TEXT_VERTICALLY_CENTRED}
w = "(text_width)"
h = "(text_height)"
font_size = {FONT_SIZE}
font_size = 20
font_style = {FONT_STYLE}
font_family = {FONT_FAMILY}
color = "{FONT_COLOR},200"
@ -128,11 +142,11 @@
{RESOLUTION}
min_width = 128
min_height = 32
min_width = 250
min_height = 50
default_width = 250
default_height = 32
default_height = 50
max_width = 0
max_height = 0
@ -147,9 +161,11 @@
name = "misc/dots.png"
actions = "( [set_var('iw', image_width), set_var('iy', clip_y)] )"
[/image]
{_GUI_BUTTON_TEXT "(iw+5)" "(iy)" 20 () ("215, 215, 215") ()}
{_GUI_BUTTON_TEXT () ("215, 215, 215") ()}
[image]
x = "(iw + tw + 10)"
x = "(width - image_width)"
y = "(max((height - image_height - 2) / 2, 0))"
name = "misc/dots.png~FL()"
[/image]
@ -168,9 +184,11 @@
name = "misc/dots.png"
actions = "( [set_var('iw', image_width), set_var('iy', clip_y)] )"
[/image]
{_GUI_BUTTON_TEXT "(iw+5)" "(iy)" 20 () ("128, 128, 128") ()}
{_GUI_BUTTON_TEXT () ("128, 128, 128") ()}
[image]
x = "(iw + tw + 10)"
x = "(width - image_width)"
y = "(max((height - image_height - 2) / 2, 0))"
name = "misc/dots.png~FL()"
[/image]
@ -189,9 +207,11 @@
name = "misc/dots.png~BLEND({PRESS_TINT},0.7)"
actions = "( [set_var('iw', image_width), set_var('iy', clip_y)] )"
[/image]
{_GUI_BUTTON_TEXT "(iw+5)" "(iy)" 20 () ({PRESS_TINT}) ()}
{_GUI_BUTTON_TEXT () ({PRESS_TINT}) ()}
[image]
x = "(iw + tw + 10)"
x = "(width - image_width)"
y = "(max((height - image_height - 2) / 2, 0))"
name = "misc/dots.png~FL()~BLEND({PRESS_TINT},0.7)"
[/image]
@ -209,9 +229,11 @@
name = "misc/dots.png~BLEND({ACTIVE_TINT},0.4)"
actions = "( [set_var('iw', image_width), set_var('iy', clip_y)] )"
[/image]
{_GUI_BUTTON_TEXT "(iw+5)" "(iy)" 20 () ({ACTIVE_TINT}) ()}
{_GUI_BUTTON_TEXT () ({ACTIVE_TINT}) ()}
[image]
x = "(iw + tw + 10)"
x = "(width - image_width)"
y = "(max((height - image_height - 2) / 2, 0))"
name = "misc/dots.png~FL()~BLEND({ACTIVE_TINT},0.4)"
[/image]
@ -329,5 +351,5 @@
#undef _GUI_DEFINITION_ORIGINAL_SIZE
#undef _GUI_DEFINITION_HEADER
#undef _GUI_RESOLUTION_ORIGINAL_SIZE
#under _GUI_RESOLUTION_HEADER
#undef _GUI_RESOLUTION_HEADER
#undef _GUI_BUTTON_TEXT

View File

@ -1,6 +1,7 @@
#textdomain wesnoth-lib
#define _GUI_SPACER_WIDTH
"((screen_width - min(screen_width / 1.5, 1000)) / 2)" #enddef
#define _GUI_MAIN_STACK
[stacked_widget]
@ -58,23 +59,58 @@
[layer]
[row]
[column]
border = "all"
border_size = "10"
horizontal_alignment = "left"
vertical_alignment = "bottom"
[button]
id = "prev"
definition = "left_arrow_story"
[/button]
[column]
grow_factor = 0
horizontal_grow = true
[grid]
[row]
[column]
grow_factor = 0
border = "all"
border_size = "10"
horizontal_alignment = "center"
vertical_alignment = "center"
[button]
id = "prev"
definition = "left_arrow_story"
[/button]
[/column]
[/row]
[row]
grow_factor = 0
[column]
[spacer]
width = {_GUI_SPACER_WIDTH}
[/spacer]
[/column]
[/row]
[/grid]
[/column]
[column]
horizontal_alignment = "right"
vertical_alignment = "center"
grow_factor = 1
horizontal_grow = true
vertical_grow = true
[grid]
[row]
grow_factor = 1
[column]
grow_factor = 1
border = "all"
@ -89,51 +125,74 @@
use_markup = true
[/scroll_label]
[/column]
[/row]
[row]
[column]
horizontal_alignment = "center"
vertical_alignment = "bottom"
[grid]
[row]
grow_factor = 0
[column]
border = "top"
border_size = "10"
horizontal_alignment = "center"
[button]
id = "cancel"
label = _ "Skip"
definition = "header_story_skip"
[/button]
[/column]
[/row]
[row]
[column]
[spacer]
height=30
[/spacer]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
grow_factor = 0
[column]
border = "left,right,bottom"
border_size = 20
horizontal_alignment = "center"
[button]
id = "cancel"
label = _ "Skip"
definition = "header_story_skip"
[/button]
[/column]
[/row]
[/grid]
[/column]
[column]
border = "all"
border_size = "10"
horizontal_alignment = "right"
vertical_alignment = "bottom"
[button]
id = "next"
definition = "right_arrow_story"
[/button]
grow_factor = 0
horizontal_grow = true
[grid]
[row]
[column]
grow_factor = 0
border = "all"
border_size = "10"
horizontal_alignment = "center"
vertical_alignment = "center"
[button]
id = "next"
definition = "right_arrow_story"
[/button]
[/column]
[/row]
[row]
grow_factor = 0
[column]
[spacer]
width = {_GUI_SPACER_WIDTH}
[/spacer]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/layer]
@ -243,3 +302,4 @@
[/window]
#undef _GUI_MAIN_STACK
#undef _GUI_SPACER_WIDTH

View File

@ -308,12 +308,6 @@ void story_viewer::display_part()
PangoAlignment story_text_alignment = decode_text_alignment(current_part_->story_text_alignment());
scroll_label& text_label = find_widget<scroll_label>(get_window(), "part_text", false);
// TODO Hardcoded max width, should be made customizable
// preferably as an key to [part]
unsigned win_width = get_window()->get_size().x;
unsigned best_text_width = (win_width < 1500) ? win_width/1.5 : 800;
text_label.set_text_max_width(best_text_width);
text_label.set_text_alignment(story_text_alignment);
text_label.set_text_alpha(0);
text_label.set_label(part_text);