Skip to content

Commit

Permalink
Add ThemeWML and HelpWML to the schema
Browse files Browse the repository at this point in the history
The change in theme.cpp is just to make the "title_literal" key be consistently applied as documented. Since the key isn't used in mainline, it should have no effect on actual uses.
  • Loading branch information
CelticMinstrel committed Oct 24, 2020
1 parent c086ec1 commit fab490c
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 6 deletions.
28 changes: 26 additions & 2 deletions data/schema/core/help.cfg
Expand Up @@ -2,6 +2,30 @@
[tag]
name="help"
min=1
any_tag=yes
# TODO: Document the HelpWML properly
[tag]
name="toplevel"
min=1
{REQUIRED_KEY sections string_list}
{REQUIRED_KEY topics string_list}
[/tag]
[tag]
name="section"
max=infinite
{REQUIRED_KEY id string}
{REQUIRED_KEY title t_string}
{SIMPLE_KEY topics string_list}
{SIMPLE_KEY sections string_list}
{SIMPLE_KEY generator string}
{SIMPLE_KEY sections_generator string}
{SIMPLE_KEY sort_topics topic_sort}
{SIMPLE_KEY sort_sections bool}
[/tag]
[tag]
name="topic"
max=infinite
{REQUIRED_KEY id string}
{REQUIRED_KEY title t_string}
{SIMPLE_KEY text t_string}
{SIMPLE_KEY generator string}
[/tag]
[/tag]
146 changes: 143 additions & 3 deletions data/schema/core/themes.cfg
Expand Up @@ -2,7 +2,147 @@
[tag]
name="theme"
max=infinite
any_tag=yes
{ANY_KEY string}
# TODO: Document the ThemeWML properly
{REQUIRED_KEY id string}
{SIMPLE_KEY name t_string}
{SIMPLE_KEY description t_string}
{DEFAULT_KEY hidden bool no}
[tag]
name="~content~"
[tag]
name="~element~"
{SIMPLE_KEY id string}
{SIMPLE_KEY rect theme_rect}
{SIMPLE_KEY xanchor theme_anchor}
{SIMPLE_KEY yanchor theme_anchor}
{SIMPLE_KEY ref string}
[/tag]
[tag]
name="~control~"
super="theme/~content~/~element~"
{SIMPLE_KEY image string}
{SIMPLE_KEY title t_string}
{SIMPLE_KEY title2 t_string}
{SIMPLE_KEY title_literal string}
{SIMPLE_KEY tooltip t_string}
{SIMPLE_KEY overlay string}
[/tag]
[tag]
name="menu"
max=infinite
{DEFAULT_KEY is_context_menu bool no}
{REQUIRED_KEY items string_list}
[if]
[not]
is_context_menu=yes
[/not]
[then]
super="theme/~content~/~control~"
{DEFAULT_KEY type theme_action image}
{DEFAULT_KEY button bool yes}
{SIMPLE_KEY font_size int}
[/then]
[/if]
[/tag]
[tag]
name="action"
super="theme/~content~/~control~"
max=infinite
{REQUIRED_KEY items string_list}
{DEFAULT_KEY type theme_action image}
{DEFAULT_KEY auto_tooltip bool no}
{DEFAULT_KEY tooltip_name_prepend bool no}
[/tag]
[tag]
name="panel"
super="theme/~content~/~control~"
max=infinite
[/tag]
[tag]
name="slider"
super="theme/~content~/~control~"
max=infinite
{SIMPLE_KEY black_line bool}
[/tag]
[tag]
name="main_map_border"
super="theme/~content~/~element~"
{SIMPLE_KEY border_size real}
{SIMPLE_KEY background_image string}
{SIMPLE_KEY tile_image string}
{DEFAULT_KEY show_border bool yes}
[/tag]
[tag]
name="label"
max=infinite
super="theme/~content~/~element~"
{REQUIRED_KEY text t_string}
{SIMPLE_KEY prefix t_string}
{SIMPLE_KEY postfix t_string}
{SIMPLE_KEY icon string}
{SIMPLE_KEY font_size int}
{SIMPLE_KEY font_rgb color}
[/tag]
[tag]
name="no_battery"
super="theme/~modification~"
[/tag]
[tag]
name="replay"
super="theme/~modification~"
[/tag]
[tag]
name="status"
[tag]
name="*"
super="theme/resolution/label"
{SIMPLE_KEY font_size int}
{SIMPLE_KEY prefix t_string}
{SIMPLE_KEY postfix t_string}
{SIMPLE_KEY prefix_literal string}
{SIMPLE_KEY postfix_literal string}
[/tag]
[/tag]
[tag]
name="*"
super="theme/~content~/~element~"
[/tag]
[/tag]
[tag]
name="~modification~"
[tag]
name="change"
super="theme/~content~/~element~"
max=infinite
{ANY_KEY string}
[/tag]
[tag]
name="remove"
max=infinite
{REQUIRED_KEY id string}
[/tag]
[tag]
name="add"
max=infinite
super="theme/~content~"
#max_children=1
[/tag]
[/tag]
[tag]
name="resolution"
min=1
max=infinite
super="theme/~content~"
{REQUIRED_KEY id resolution}
{REQUIRED_KEY width int}
{REQUIRED_KEY height int}
[/tag]
[tag]
name="partialresolution"
max=infinite
super="theme/~modification~"
{REQUIRED_KEY id resolution}
{REQUIRED_KEY inherits resolution}
{REQUIRED_KEY width int}
{REQUIRED_KEY height int}
[/tag]
[/tag]
46 changes: 46 additions & 0 deletions data/schema/game_config.cfg
Expand Up @@ -390,6 +390,52 @@
name="only"
value="only"
[/type]
[type]
name="topic_sort"
[union]
[type]
link=bool
[/type]
[type]
value="generated"
[/type]
[/union]
[/type]
[type]
name="resolution"
[list]
split="x"
min=2
max=2
[element]
link=int
[/element]
[/list]
[/type]
[type]
name="theme_rect"
[list]
min=4
max=4
[element]
link=int
[/element]
[element]
value="="
[/element]
[element]
value="=?[-+]\d+"
[/element]
[/list]
[/type]
[type]
name="theme_anchor"
value="top|left|bottom|right|fixed|proportional"
[/type]
[type]
name="theme_action"
value="checkbox|radiobox|image|turbo"
[/type]
[tag]
name="root"
min=1
Expand Down
1 change: 1 addition & 0 deletions data/themes/null.cfg
Expand Up @@ -8,6 +8,7 @@
id=null
hidden=yes
[resolution]
id=1x1
width=1
height=1
[/resolution]
Expand Down
2 changes: 1 addition & 1 deletion src/theme.cpp
Expand Up @@ -1014,7 +1014,7 @@ theme::object* theme::refresh_title2(const std::string& id, const std::string& t
if(!cfg[title_tag].empty())
new_title = cfg[title_tag].str();

return refresh_title(id, new_title);
return refresh_title(id, new_title + cfg["title_literal"].str());
}

void theme::modify_label(const std::string& id, const std::string& text)
Expand Down

0 comments on commit fab490c

Please sign in to comment.