Get game config and schema to use some common types
This also fixes an invalid type issue in the GUI2 schema, and allows types to be a direct alias for other types.
This commit is contained in:
parent
3365aef28a
commit
34604fdff6
5 changed files with 65 additions and 82 deletions
|
@ -55,16 +55,6 @@
|
|||
name="defeat_condition"
|
||||
value="no_leader_left|no_units_left|never|always"
|
||||
[/type]
|
||||
[type]
|
||||
name=point
|
||||
[list]
|
||||
min=1
|
||||
max=2
|
||||
[element]
|
||||
link="int"
|
||||
[/element]
|
||||
[/list]
|
||||
[/type]
|
||||
[type]
|
||||
name=range
|
||||
[list]
|
||||
|
|
|
@ -1,40 +1,10 @@
|
|||
[wml_schema]
|
||||
[type]
|
||||
name=bool
|
||||
value="^true|false|yes|no$"
|
||||
[/type]
|
||||
{./types/basic.cfg}
|
||||
{./types/formula.cfg}
|
||||
[type]
|
||||
name=border
|
||||
value="^(top|bottom|left|right|all)?(,\s*(top|bottom|left|right|all))*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=color
|
||||
value="^(?:2[0-5][0-5]|[01]?\d?\d)[.,]\s*(?:2[0-5][0-5]|[01]?\d?\d)[.,]\s*(?:2[0-5][0-5]|[01]?\d?\d)[.,]\s*(?:2[0-5][0-5]|[01]?\d?\d)$"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_bool
|
||||
value="^.*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_h_align
|
||||
value="^.*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_int
|
||||
value="^.*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_string
|
||||
value="^.*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_tstring
|
||||
value="^_?.*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_unsigned
|
||||
value="^.+$"
|
||||
[/type]
|
||||
[type]
|
||||
name=font_family
|
||||
value="^(sans|monospace|light|script)?$"
|
||||
|
@ -43,10 +13,6 @@
|
|||
name=font_style
|
||||
value="^(normal|bold|italic|underline|light)?$"
|
||||
[/type]
|
||||
[type]
|
||||
name=function
|
||||
value="^_?.*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=grow_direction
|
||||
value="^horizontal|vertical$"
|
||||
|
@ -55,10 +21,7 @@
|
|||
name=h_align
|
||||
value="^left|right|center$"
|
||||
[/type]
|
||||
[type]
|
||||
name=int
|
||||
value="^-?\d+$"
|
||||
[/type]
|
||||
{FORMULA_TYPE h_align}
|
||||
[type]
|
||||
name=resize_mode
|
||||
value="^scale|stretch|tile|tile_center$"
|
||||
|
@ -67,18 +30,6 @@
|
|||
name=scrollbar_mode
|
||||
value="^always|never|auto|initial_auto$"
|
||||
[/type]
|
||||
[type]
|
||||
name=string
|
||||
value="^.*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=t_string
|
||||
value="^_?.*$"
|
||||
[/type]
|
||||
[type]
|
||||
name=unsigned
|
||||
value="^\d+$"
|
||||
[/type]
|
||||
[type]
|
||||
name=v_align
|
||||
value="^top|bottom|center$"
|
||||
|
@ -444,7 +395,7 @@
|
|||
[/key]
|
||||
[key]
|
||||
name="text"
|
||||
type="f_tstring"
|
||||
type="f_t_string"
|
||||
default=""
|
||||
[/key]
|
||||
[key]
|
||||
|
|
|
@ -1,12 +1,29 @@
|
|||
|
||||
#define ALIAS_TYPE TYPE BASE
|
||||
[type]
|
||||
name={TYPE}
|
||||
link={BASE}
|
||||
[/type]
|
||||
#enddef
|
||||
|
||||
[type]
|
||||
name=bool
|
||||
value="true|false|yes|no"
|
||||
[/type]
|
||||
|
||||
[type]
|
||||
name=int
|
||||
value="-?\d+"
|
||||
[/type]
|
||||
[type]
|
||||
name=unsigned
|
||||
value="\d+"
|
||||
[/type]
|
||||
[type]
|
||||
name=real
|
||||
value="-?\d+(\.\d+)?"
|
||||
[/type]
|
||||
|
||||
[type]
|
||||
name=string
|
||||
value=".*"
|
||||
|
@ -15,7 +32,19 @@
|
|||
name=t_string
|
||||
value="_?.*"
|
||||
[/type]
|
||||
|
||||
[type]
|
||||
name=real
|
||||
value="-?\d+(\.\d+)?"
|
||||
name=color
|
||||
value="(?:2[0-5][0-5]|[01]?\d?\d)[.,]\s*(?:2[0-5][0-5]|[01]?\d?\d)[.,]\s*(?:2[0-5][0-5]|[01]?\d?\d)[.,]\s*(?:2[0-5][0-5]|[01]?\d?\d)"
|
||||
[/type]
|
||||
|
||||
[type]
|
||||
name=point
|
||||
[list]
|
||||
min=1
|
||||
max=2
|
||||
[element]
|
||||
link="int"
|
||||
[/element]
|
||||
[/list]
|
||||
[/type]
|
||||
|
|
|
@ -1,19 +1,30 @@
|
|||
|
||||
# The "formula" and "f_string" types are currently the same as "string"
|
||||
# Note that basic.cfg must also be included for these to work!
|
||||
|
||||
#define FORMULA_TYPE BASE
|
||||
[type]
|
||||
name=f_{BASE}
|
||||
[union]
|
||||
[type]
|
||||
link={BASE}
|
||||
[/type]
|
||||
[type]
|
||||
value="\(.*\)\s*"
|
||||
[/type]
|
||||
[/union]
|
||||
[/type]
|
||||
#enddef
|
||||
|
||||
# The "formula", "function", and "f_string" types are currently the same as "string"
|
||||
# They're provided as separate types only for documentation purposes
|
||||
[type]
|
||||
name=formula
|
||||
value=".*"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_string
|
||||
value=".*"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_int
|
||||
value="-?\d+|\(.*\)"
|
||||
[/type]
|
||||
[type]
|
||||
name=f_real
|
||||
value="(-?\d+(\.\d+))|\(.*\)?"
|
||||
[/type]
|
||||
{ALIAS_TYPE formula string}
|
||||
{ALIAS_TYPE function string}
|
||||
{ALIAS_TYPE f_string string}
|
||||
|
||||
{FORMULA_TYPE bool}
|
||||
{FORMULA_TYPE int}
|
||||
{FORMULA_TYPE unsigned}
|
||||
{FORMULA_TYPE real}
|
||||
{FORMULA_TYPE color}
|
||||
{FORMULA_TYPE point}
|
||||
{FORMULA_TYPE t_string}
|
||||
|
|
|
@ -77,6 +77,8 @@ class_type::class_type(const config& cfg)
|
|||
}
|
||||
} else if(cfg.has_attribute("value")) {
|
||||
patterns_.emplace_back(cfg["value"].str());
|
||||
} else if(cfg.has_attribute("link")) {
|
||||
links_.emplace_back(cfg["link"].str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue