WML: Support [filter_side] in [item]. (#3533)
* WML: Support [filter_side] in [item].
If [filter_side] is present then "team_name" is ignored.
Fixes #1477.
* WML: Compare [item]team_name to [side]team_name using intersection.
Fixes problems with substrings and when one or the other is a
comma-separated list. See #3533
* WML: Rename [item][filter_side] to [item][filter_team]
* Add changelog entry
(cherry-picked from commit 3a3b752881
)
This commit is contained in:
parent
d5238ac5cb
commit
e766cdc7cc
4 changed files with 21 additions and 3 deletions
|
@ -44,6 +44,7 @@
|
|||
* Support male_voice and female_voice in [message]
|
||||
* Support [break], [continue], and [return] in [random_placement]
|
||||
* [remove_sound_source] now accepts a comma-separated ID list
|
||||
* Support [filter_team] in [side] in addition to team_name=
|
||||
### Miscellaneous and bug fixes
|
||||
|
||||
## Version 1.14.4+dev
|
||||
|
|
|
@ -16,6 +16,7 @@ local function add_overlay(x, y, cfg)
|
|||
image = cfg.image,
|
||||
halo = cfg.halo,
|
||||
team_name = cfg.team_name,
|
||||
filter_team = cfg.filter_team,
|
||||
visible_in_fog = cfg.visible_in_fog,
|
||||
redraw = cfg.redraw,
|
||||
name = cfg.name
|
||||
|
|
|
@ -2598,8 +2598,12 @@ void display::draw_hex(const map_location& loc) {
|
|||
image::light_string lt = image::get_light_string(-1, tod_col.r, tod_col.g, tod_col.b);
|
||||
|
||||
for( ; overlays.first != overlays.second; ++overlays.first) {
|
||||
const std::string& current_team_name = get_teams()[viewing_team()].team_name();
|
||||
const std::vector<std::string>& current_team_names = utils::split(current_team_name);
|
||||
const std::vector<std::string>& team_names = utils::split(overlays.first->second.team_name);
|
||||
if ((overlays.first->second.team_name.empty() ||
|
||||
overlays.first->second.team_name.find(dc_->teams()[viewing_team()].team_name()) != std::string::npos)
|
||||
std::find_first_of(team_names.begin(), team_names.end(),
|
||||
current_team_names.begin(), current_team_names.end()) != team_names.end())
|
||||
&& !(fogged(loc) && !overlays.first->second.visible_in_fog))
|
||||
{
|
||||
|
||||
|
|
|
@ -3345,11 +3345,23 @@ static int intf_add_known_unit(lua_State *L)
|
|||
int game_lua_kernel::intf_add_tile_overlay(lua_State *L)
|
||||
{
|
||||
map_location loc = luaW_checklocation(L, 1);
|
||||
config cfg = luaW_checkconfig(L, 2);
|
||||
vconfig cfg = luaW_checkvconfig(L, 2);
|
||||
const vconfig &ssf = cfg.child("filter_team");
|
||||
|
||||
std::string team_name;
|
||||
if (!ssf.null()) {
|
||||
const std::vector<int>& teams = side_filter(ssf, &game_state_).get_teams();
|
||||
std::vector<std::string> team_names;
|
||||
std::transform(teams.begin(), teams.end(), std::back_inserter(team_names),
|
||||
[&](int team) { return game_state_.get_disp_context().get_team(team).team_name(); });
|
||||
team_name = utils::join(team_names);
|
||||
} else {
|
||||
team_name = cfg["team_name"].str();
|
||||
}
|
||||
|
||||
if (game_display_) {
|
||||
game_display_->add_overlay(loc, cfg["image"], cfg["halo"],
|
||||
cfg["team_name"], cfg["name"], cfg["visible_in_fog"].to_bool(true));
|
||||
team_name, cfg["name"], cfg["visible_in_fog"].to_bool(true));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue