Implement [true] and [false] ConditionalWML tags

[true] and [false] describe a condition that yields true or false,
respectively. They are intended as syntactic sugar in situations where
one absolutely needs to have a conditional statement for whatever
reason.
This commit is contained in:
Ignacio R. Morelle 2014-02-11 05:09:59 -03:00
parent 5293851c8e
commit a2f1c64eb1
2 changed files with 15 additions and 0 deletions

View file

@ -10,6 +10,9 @@ Version 1.11.9+dev:
* Added: A new tooltip window.
* Language and i18n:
* Updated translations:
* WML engine:
* Implemented [true] and [false] ConditionalWML tags, which describe a
condition that always yields true or false, respectively.
* Miscellaneous and bug fixes:
* Fixed: A compilation warning with DEBUG_WINDOW_LAYOUT_GRAPHS.

View file

@ -47,6 +47,18 @@ namespace { // Support functions
bool internal_conditional_passed(const vconfig& cond, bool& backwards_compat)
{
const vconfig::child_list& true_keyword = cond.get_children("true");
backwards_compat = backwards_compat && true_keyword.empty();
if(!true_keyword.empty()) {
return true;
}
const vconfig::child_list& false_keyword = cond.get_children("false");
backwards_compat = backwards_compat && false_keyword.empty();
if(!false_keyword.empty()) {
return false;
}
static std::vector<std::pair<int,int> > default_counts = utils::parse_ranges("1-99999");
// If the if statement requires we have a certain unit,