mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-20 18:46:19 +00:00
Added support for labels and items that are hiden by fog...
...(patch #1101 by broodkiller)
This commit is contained in:
parent
84bcc60ed5
commit
190db928b9
@ -42,6 +42,7 @@ Version 1.5.3+svn:
|
||||
* Fixed linewrapping with not to wrap markups (bug #11946 and bug #11945)
|
||||
* fix bug where max_experience of stored units was not the true max when
|
||||
playing with under 100% exp. settings
|
||||
* Added support for labels and items that are hiden by fog (patch #1101)
|
||||
* Made it possible to use another color palette as second parameter in
|
||||
RC(A=B) image path function by using '=' instead of '>' as parameter
|
||||
separator; this allows simple color replacement that RC(A>B) did not
|
||||
|
@ -722,6 +722,9 @@
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Jan Zvánovec (jaz)"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Jacek Kominek (BroodKiller)"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Jeff Breidenbach (jab)"
|
||||
|
@ -2134,6 +2134,7 @@ bool clear_shroud(game_display& disp, const gamemap& map,
|
||||
recalculate_fog(map,units,teams,team);
|
||||
}
|
||||
|
||||
disp.labels().recalculate_labels();
|
||||
disp.labels().recalculate_shroud();
|
||||
|
||||
return result;
|
||||
|
@ -325,6 +325,7 @@ void game_display::draw_hex(const gamemap::location& loc)
|
||||
{
|
||||
const bool on_map = map_.on_board(loc);
|
||||
const bool is_shrouded = shrouded(loc);
|
||||
const bool is_fogged = fogged(loc);
|
||||
int xpos = get_location_x(loc);
|
||||
int ypos = get_location_y(loc);
|
||||
int drawing_order = gamemap::get_drawing_order(loc);
|
||||
@ -338,8 +339,9 @@ void game_display::draw_hex(const gamemap::location& loc)
|
||||
typedef overlay_map::const_iterator Itor;
|
||||
std::pair<Itor,Itor> overlays = overlays_.equal_range(loc);
|
||||
for( ; overlays.first != overlays.second; ++overlays.first) {
|
||||
if (overlays.first->second.team_name == "" ||
|
||||
if ((overlays.first->second.team_name == "" ||
|
||||
overlays.first->second.team_name.find(teams_[playing_team()].team_name()) != std::string::npos)
|
||||
&& !(is_fogged && overlays.first->second.fogged))
|
||||
{
|
||||
drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, tblit(xpos, ypos,
|
||||
image::get_image(overlays.first->second.image,image_type)));
|
||||
@ -966,12 +968,12 @@ void game_display::clear_attack_indicator()
|
||||
set_attack_indicator(gamemap::location::null_location, gamemap::location::null_location);
|
||||
}
|
||||
|
||||
void game_display::add_overlay(const gamemap::location& loc, const std::string& img, const std::string& halo,const std::string& team_name)
|
||||
void game_display::add_overlay(const gamemap::location& loc, const std::string& img, const std::string& halo,const std::string& team_name,const std::string& fogged)
|
||||
{
|
||||
const int halo_handle = halo::add(get_location_x(loc) + hex_size() / 2,
|
||||
get_location_y(loc) + hex_size() / 2, halo, loc);
|
||||
|
||||
const overlay item(img, halo, halo_handle, team_name);
|
||||
const overlay item(img, halo, halo_handle, team_name, utils::string_bool(fogged,true));
|
||||
overlays_.insert(overlay_map::value_type(loc,item));
|
||||
}
|
||||
|
||||
@ -1015,6 +1017,7 @@ void game_display::write_overlays(config& cfg) const
|
||||
item["image"] = i->second.image;
|
||||
item["halo"] = i->second.halo;
|
||||
item["team_name"] = i->second.team_name;
|
||||
item["fogged"] = i->second.fogged ? "yes" : "no";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public:
|
||||
//! Functions to add and remove overlays from locations.
|
||||
//! An overlay is an image that is displayed on top of the tile.
|
||||
//! One tile may have multiple overlays.
|
||||
void add_overlay(const gamemap::location& loc, const std::string& image, const std::string& halo="", const std::string& team_name="");
|
||||
void add_overlay(const gamemap::location& loc, const std::string& image, const std::string& halo="", const std::string& team_name="",const std::string& fogged="yes");
|
||||
//! 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
|
||||
@ -281,12 +281,13 @@ private:
|
||||
|
||||
struct overlay {
|
||||
overlay(const std::string& img, const std::string& halo_img,
|
||||
int handle, const std::string& overlay_team_name) : image(img), halo(halo_img),
|
||||
team_name(overlay_team_name), halo_handle(handle) {}
|
||||
int handle, const std::string& overlay_team_name, const bool can_be_fogged) : image(img), halo(halo_img),
|
||||
team_name(overlay_team_name), halo_handle(handle) , fogged(can_be_fogged){}
|
||||
std::string image;
|
||||
std::string halo;
|
||||
std::string team_name;
|
||||
int halo_handle;
|
||||
bool fogged;
|
||||
};
|
||||
|
||||
typedef std::multimap<gamemap::location,overlay> overlay_map;
|
||||
|
@ -1577,9 +1577,10 @@ namespace {
|
||||
std::string img = cfg["image"];
|
||||
std::string halo = cfg["halo"];
|
||||
std::string team_name = cfg["team_name"];
|
||||
std::string fogged = cfg["fogged"];
|
||||
assert(state_of_game != NULL);
|
||||
if(!img.empty() || !halo.empty()) {
|
||||
(screen)->add_overlay(loc, img, halo, team_name);
|
||||
(screen)->add_overlay(loc, img, halo, team_name, fogged);
|
||||
(screen)->invalidate(loc);
|
||||
(screen)->draw();
|
||||
}
|
||||
|
@ -360,6 +360,7 @@ void terrain_label::read(const config& cfg, const variable_set *variables)
|
||||
|
||||
text_ = cfg["text"];
|
||||
team_name_ = cfg["team_name"];
|
||||
fogged_ = utils::string_bool(cfg["fogged"],true);
|
||||
|
||||
if (variables)
|
||||
{
|
||||
@ -391,7 +392,7 @@ void terrain_label::write(config& cfg) const
|
||||
cfg["text"] = text();
|
||||
cfg["team_name"] = (this->team_name());
|
||||
cfg["colour"] = cfg_colour();
|
||||
|
||||
cfg["fogged"] = fogged() ? "yes" : "no";
|
||||
}
|
||||
|
||||
const std::string& terrain_label::text() const
|
||||
@ -404,6 +405,11 @@ const std::string& terrain_label::team_name() const
|
||||
return team_name_;
|
||||
}
|
||||
|
||||
bool terrain_label::fogged() const
|
||||
{
|
||||
return fogged_;
|
||||
}
|
||||
|
||||
const gamemap::location& terrain_label::location() const
|
||||
{
|
||||
return loc_;
|
||||
@ -502,7 +508,7 @@ void terrain_label::draw()
|
||||
bool terrain_label::visible() const
|
||||
{
|
||||
return (parent_->team_name() == team_name_
|
||||
|| (team_name_.empty() && parent_->visible_global_label(loc_)));
|
||||
|| (team_name_.empty() && parent_->visible_global_label(loc_)) && !(parent_->disp().fogged(loc_) && fogged()));
|
||||
}
|
||||
|
||||
void terrain_label::check_text_length()
|
||||
|
@ -109,6 +109,7 @@ public:
|
||||
|
||||
const std::string& text() const;
|
||||
const std::string& team_name() const;
|
||||
bool fogged() const;
|
||||
const gamemap::location& location() const;
|
||||
const SDL_Colour& colour() const;
|
||||
|
||||
@ -136,6 +137,7 @@ private:
|
||||
|
||||
std::string text_;
|
||||
std::string team_name_;
|
||||
bool fogged_;
|
||||
SDL_Color colour_;
|
||||
|
||||
const map_labels* parent_;
|
||||
|
@ -256,7 +256,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const std::vector<config*>& st
|
||||
// Find a list of 'items' (i.e. overlays) on the level, and add them
|
||||
const config::child_list& overlays = level_.get_children("item");
|
||||
for(config::child_list::const_iterator overlay = overlays.begin(); overlay != overlays.end(); ++overlay) {
|
||||
gui_->add_overlay(gamemap::location(**overlay, game_events::get_state_of_game()), (**overlay)["image"], (**overlay)["halo"], (**overlay)["team_name"]);
|
||||
gui_->add_overlay(gamemap::location(**overlay, game_events::get_state_of_game()), (**overlay)["image"], (**overlay)["halo"], (**overlay)["team_name"], (**overlay)["fogged"]);
|
||||
}
|
||||
|
||||
victory_conditions::set_victory_when_enemies_defeated(
|
||||
|
Loading…
x
Reference in New Issue
Block a user