Skip to content

Commit

Permalink
Simplify storyscreen title definition
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Apr 8, 2017
1 parent e46b10a commit 9b2eac1
Showing 1 changed file with 34 additions and 49 deletions.
83 changes: 34 additions & 49 deletions data/gui/widget/label_story_screen_title.cfg
Expand Up @@ -5,7 +5,7 @@

# We can't get the exact size of the text outside a [text] element, so estimate it instead.
# Using an average character width of 12 seems to give good results.
# Then we centre the text in the estimated width rather than.
# Then we centre the text in the estimated width rather than in the entire width.

#define _GUI_ESTIMATE_TEXT_WIDTH
(length(text) * 12)#enddef
Expand All @@ -14,6 +14,33 @@
(10 + max((box_width - text_width) / 2, 0)
where box_width = {_GUI_ESTIMATE_TEXT_WIDTH})#enddef

#define _GUI_BACKGROUND
[rectangle]
x = 10
y = 10
w = "{_GUI_ESTIMATE_TEXT_WIDTH}"
h = "(height - 20)"
fill_color = "0, 0, 0, 128"
[/rectangle]
#enddef

#define _GUI_TEXT MODE
[text]
x = "{_GUI_CENTER_STORY_TEXT}"
y = {GUI__TEXT_VERTICALLY_CENTRED}
w = "(width)"
h = "(text_height)"
maximum_width = "(width)"
font_size = {GUI_FONT_SIZE_LARGE}
color = {GUI__FONT_COLOR_{MODE}__DEFAULT}
text = "(text)"
text_markup = "(text_markup)"
text_alignment = "(text_alignment)"
text_link_aware = "(text_link_aware)"
text_link_color = "(text_link_color)"
[/text]
#enddef

[label_definition]
id = "story_screen_title"
description = "Large label with translucent background for story screen"
Expand All @@ -37,61 +64,17 @@ where box_width = {_GUI_ESTIMATE_TEXT_WIDTH})#enddef
[state_enabled]

[draw]

[rectangle]
x = 10
y = 10
w = "{_GUI_ESTIMATE_TEXT_WIDTH}"
h = "(height - 20)"
fill_color = "0, 0, 0, 128"
[/rectangle]

[text]
x = "{_GUI_CENTER_STORY_TEXT}"
y = {GUI__TEXT_VERTICALLY_CENTRED}
w = "(width)"
h = "(text_height)"
maximum_width = "(width)"
font_size = {GUI_FONT_SIZE_LARGE}
color = {GUI__FONT_COLOR_ENABLED__DEFAULT}
text = "(text)"
text_markup = "(text_markup)"
text_alignment = "(text_alignment)"
text_link_aware = "(text_link_aware)"
text_link_color = "(text_link_color)"
[/text]

{_GUI_BACKGROUND}
{_GUI_TEXT ENABLED}
[/draw]

[/state_enabled]

[state_disabled]

[draw]

[rectangle]
x = 10
y = 10
w = "{_GUI_ESTIMATE_TEXT_WIDTH}"
h = "(height - 20)"
fill_color = "0, 0, 0, 128"
[/rectangle]

[text]
x = "{_GUI_CENTER_STORY_TEXT}"
y = {GUI__TEXT_VERTICALLY_CENTRED}
w = "(width)"
h = "(text_height)"
maximum_width = "(width)"
font_size = {GUI_FONT_SIZE_LARGE}
color = {GUI__FONT_COLOR_DISABLED__DEFAULT}
text = "(text)"
text_markup = "(text_markup)"
text_alignment = "(text_alignment)"
text_link_aware = "(text_link_aware)"
text_link_color = "(text_link_color)"
[/text]

{_GUI_BACKGROUND}
{_GUI_TEXT DISABLED}
[/draw]

[/state_disabled]
Expand All @@ -102,3 +85,5 @@ where box_width = {_GUI_ESTIMATE_TEXT_WIDTH})#enddef

#undef _GUI_ESTIMATE_TEXT_WIDTH
#undef _GUI_CENTER_STORY_TEXT
#undef _GUI_BACKGROUND
#undef _GUI_TEXT

0 comments on commit 9b2eac1

Please sign in to comment.