mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 23:48:58 +00:00
Apply patch #1067 by xonev: Add image key to removeitem tag
This commit is contained in:
parent
6d53f6899f
commit
0eefb20a7a
@ -50,6 +50,8 @@ Version 1.5.0+svn:
|
||||
pass parameters (ex: "alias hp=unit hitpoints", then use "hp 100")
|
||||
* WML engine:
|
||||
* titlescreen is now randomly loaded
|
||||
* removeitem now can take an image key so that overlays can be removed one at
|
||||
a time. (patch #1067)
|
||||
* fix [teleport] capturing villages with the wrong side (bug #11683)
|
||||
* SideWML recruit= no longer locks the faction except if explicitely wanted
|
||||
with the new key faction_from_recruit=yes
|
||||
|
@ -136,6 +136,9 @@
|
||||
email = "lao.geek_AT_gmail.com"
|
||||
wikiuser = "lao"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Steven Oxley (xonev)"
|
||||
[/entry]
|
||||
[/about]
|
||||
|
||||
[about]
|
||||
|
@ -97,7 +97,6 @@ game_display::game_display(unit_map& units, CVideo& video, const gamemap& map,
|
||||
for(size_t i = 0; i != teams_.size(); ++i) {
|
||||
std::string side_color = team::get_side_colour_index(i+1);
|
||||
side_colors.push_back(side_color);
|
||||
|
||||
std::string flag = teams_[i].flag();
|
||||
std::string old_rgb = game_config::flag_rgb;
|
||||
std::string new_rgb = side_color;
|
||||
@ -1133,6 +1132,26 @@ void game_display::remove_overlay(const gamemap::location& loc)
|
||||
overlays_.erase(loc);
|
||||
}
|
||||
|
||||
void game_display::remove_single_overlay(const gamemap::location& loc, const std::string& toDelete)
|
||||
{
|
||||
//Iterate through the values with key of loc
|
||||
typedef overlay_map::iterator Itor;
|
||||
overlay_map::iterator iteratorCopy;
|
||||
std::pair<Itor,Itor> itors = overlays_.equal_range(loc);
|
||||
while(itors.first != itors.second) {
|
||||
//If image or halo of overlay struct matches toDelete, remove the overlay
|
||||
if(itors.first->second.image == toDelete || itors.first->second.halo == toDelete) {
|
||||
iteratorCopy = itors.first;
|
||||
++itors.first;
|
||||
halo::remove(iteratorCopy->second.halo_handle);
|
||||
overlays_.erase(iteratorCopy);
|
||||
}
|
||||
else {
|
||||
++itors.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void game_display::write_overlays(config& cfg) const
|
||||
{
|
||||
for(overlay_map::const_iterator i = overlays_.begin(); i != overlays_.end(); ++i) {
|
||||
|
@ -143,6 +143,8 @@ public:
|
||||
void add_overlay(const gamemap::location& loc, const std::string& image, const std::string& halo="");
|
||||
//! remove_overlay will remove all overlays on a tile.
|
||||
void remove_overlay(const gamemap::location& loc);
|
||||
//! remove_single_overlay will remove a single overlay from a tile
|
||||
void remove_single_overlay(const gamemap::location& loc, const std::string& toDelete);
|
||||
|
||||
//! Function to serialize overlay data.
|
||||
void write_overlays(config& cfg) const;
|
||||
|
@ -1544,12 +1544,20 @@ void event_handler::handle_event_command(const queued_event& event_info,
|
||||
}
|
||||
|
||||
else if(cmd == "removeitem") {
|
||||
std::string img = cfg["image"];
|
||||
assert(state_of_game != NULL);
|
||||
gamemap::location loc = cfg_to_loc(cfg);
|
||||
|
||||
if(!loc.valid()) {
|
||||
loc = event_info.loc1;
|
||||
loc = event_info.loc1;
|
||||
}
|
||||
|
||||
screen->remove_overlay(loc);
|
||||
if(!img.empty()) { //If image key is set remove that one item
|
||||
screen->remove_single_overlay(loc, img);
|
||||
}
|
||||
else { //Else remove the overlay completely
|
||||
screen->remove_overlay(loc);
|
||||
}
|
||||
}
|
||||
|
||||
else if(cmd == "unit_overlay") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user