mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 20:06:28 +00:00
Added support for has_flag in [variant]
Works like in [tile]: for the [variant] to match, the tile that the rule is being applied to must have all of the specified flags.
This commit is contained in:
parent
a87e7e16ed
commit
2f910913f3
@ -30,6 +30,7 @@ Version 1.13.1+dev:
|
|||||||
option previously found in Preferences -> General.
|
option previously found in Preferences -> General.
|
||||||
* WML engine:
|
* WML engine:
|
||||||
* Added support for mod_x,mod_y= in [terrain_graphics].
|
* Added support for mod_x,mod_y= in [terrain_graphics].
|
||||||
|
* Added support for has_flag= in terrain graphics [variant].
|
||||||
* Miscellaneous and bug fixes:
|
* Miscellaneous and bug fixes:
|
||||||
* Fixed Generate Map dialog bug that caused last choice of map
|
* Fixed Generate Map dialog bug that caused last choice of map
|
||||||
generator to not be actually selected (bug #23711).
|
generator to not be actually selected (bug #23711).
|
||||||
|
@ -125,6 +125,21 @@ void terrain_builder::tile::rebuild_cache(const std::string& tod, logs* log)
|
|||||||
imagelist& img_list = is_background ? images_background : images_foreground;
|
imagelist& img_list = is_background ? images_background : images_foreground;
|
||||||
|
|
||||||
BOOST_FOREACH(const rule_image_variant& variant, ri->variants){
|
BOOST_FOREACH(const rule_image_variant& variant, ri->variants){
|
||||||
|
if(!variant.has_flag.empty()) {
|
||||||
|
bool has_flag_match = true;
|
||||||
|
BOOST_FOREACH(const std::string& s, variant.has_flag) {
|
||||||
|
// If a flag listed in "has_flag" is not present, this variant does not match
|
||||||
|
if(flags.find(s) == flags.end()) {
|
||||||
|
has_flag_match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!has_flag_match) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!variant.tods.empty() && variant.tods.find(tod) == variant.tods.end())
|
if(!variant.tods.empty() && variant.tods.find(tod) == variant.tods.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -622,13 +637,17 @@ void terrain_builder::rotate_rule(building_rule &ret, int angle,
|
|||||||
replace_rotate_tokens(ret, angle, rot);
|
replace_rotate_tokens(ret, angle, rot);
|
||||||
}
|
}
|
||||||
|
|
||||||
terrain_builder::rule_image_variant::rule_image_variant(const std::string &image_string, const std::string& variations, const std::string& tod, bool random_start) :
|
terrain_builder::rule_image_variant::rule_image_variant(const std::string &image_string, const std::string& variations, const std::string& tod, const std::string& has_flag, bool random_start) :
|
||||||
image_string(image_string),
|
image_string(image_string),
|
||||||
variations(variations),
|
variations(variations),
|
||||||
images(),
|
images(),
|
||||||
tods(),
|
tods(),
|
||||||
|
has_flag(),
|
||||||
random_start(random_start)
|
random_start(random_start)
|
||||||
{
|
{
|
||||||
|
if(!has_flag.empty()) {
|
||||||
|
this->has_flag = utils::split(has_flag);
|
||||||
|
}
|
||||||
if(!tod.empty()) {
|
if(!tod.empty()) {
|
||||||
const std::vector<std::string> tod_list = utils::split(tod);
|
const std::vector<std::string> tod_list = utils::split(tod);
|
||||||
tods.insert(tod_list.begin(), tod_list.end());
|
tods.insert(tod_list.begin(), tod_list.end());
|
||||||
@ -667,9 +686,10 @@ void terrain_builder::add_images_from_config(rule_imagelist& images, const confi
|
|||||||
const std::string &name = variant["name"];
|
const std::string &name = variant["name"];
|
||||||
const std::string &variations = img["variations"];
|
const std::string &variations = img["variations"];
|
||||||
const std::string &tod = variant["tod"];
|
const std::string &tod = variant["tod"];
|
||||||
|
const std::string &has_flag = variant["has_flag"];
|
||||||
bool random_start = variant["random_start"].to_bool(true);
|
bool random_start = variant["random_start"].to_bool(true);
|
||||||
|
|
||||||
images.back().variants.push_back(rule_image_variant(name, variations, tod, random_start));
|
images.back().variants.push_back(rule_image_variant(name, variations, tod, has_flag, random_start));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds the main (default) variant of the image at the end,
|
// Adds the main (default) variant of the image at the end,
|
||||||
|
@ -155,11 +155,12 @@ public:
|
|||||||
variations(variations),
|
variations(variations),
|
||||||
images(),
|
images(),
|
||||||
tods(),
|
tods(),
|
||||||
|
has_flag(),
|
||||||
random_start(random_start)
|
random_start(random_start)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/** Constructor for true [variant] cases */
|
/** Constructor for true [variant] cases */
|
||||||
rule_image_variant(const std::string &image_string, const std::string& variations, const std::string& tod, bool random_start = true);
|
rule_image_variant(const std::string &image_string, const std::string& variations, const std::string& tod, const std::string& has_flag, bool random_start = true);
|
||||||
|
|
||||||
/** A string representing either the filename for an image, or
|
/** A string representing either the filename for an image, or
|
||||||
* a list of images, with an optional timing for each image.
|
* a list of images, with an optional timing for each image.
|
||||||
@ -194,6 +195,8 @@ public:
|
|||||||
/** The Time of Day associated to this variant (if any)*/
|
/** The Time of Day associated to this variant (if any)*/
|
||||||
std::set<std::string> tods;
|
std::set<std::string> tods;
|
||||||
|
|
||||||
|
std::vector<std::string> has_flag;
|
||||||
|
|
||||||
/** Indicate if the animation uses a random shift */
|
/** Indicate if the animation uses a random shift */
|
||||||
bool random_start;
|
bool random_start;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user