44 disp_(disp), team_(team), labels_(), enabled_(true), categories_dirty(true)
49 disp_(other.
disp_), team_(other.team_), labels_(), enabled_(true)
72 for (team_label_map::const_iterator labs =
labels_.begin(); labs !=
labels_.end(); ++labs)
74 for(label_map::const_iterator
i = labs->second.begin();
i != labs->second.end(); ++
i) {
76 i->second->write(item);
100 if (label_map !=
labels_.end()) {
101 map_labels::label_map::const_iterator
itor = label_map->second.find(loc);;
102 if (itor != label_map->second.end())
113 if (res ==
nullptr &&
team_name() !=
"") {
149 const SDL_Color
color,
150 const bool visible_in_fog,
151 const bool visible_in_shroud,
152 const bool immutable,
164 if ( current_label_map !=
labels_.end()
165 && (current_label = current_label_map->second.find(loc)) != current_label_map->second.end() )
168 if(text.
str().empty())
171 delete current_label->second;
172 current_label_map->second.erase(current_label);
176 global_label->recalculate();
180 current_label->second->update_info(text, creator, tooltip, team_name, color, visible_in_fog, visible_in_shroud, immutable, category);
181 res = current_label->second;
184 else if(!text.
str().empty())
204 if ( global_label !=
nullptr )
238 if (!i->second->immutable() || force) {
248 for (team_label_map::value_type &
m :
labels_)
257 for (team_label_map::value_type &
m :
labels_)
259 for (label_map::value_type &
l :
m.second)
261 l.second->recalculate();
281 return glabels ==
labels_.end()
282 || glabels->second.find(loc) == glabels->second.end();
287 for (team_label_map::value_type &
m :
labels_)
289 for (label_map::value_type &
l :
m.second)
291 l.second->calculate_shroud();
304 std::set<std::string> unique_cats;
305 for (
const team_label_map::value_type&
m :
labels_) {
306 for (
const label_map::value_type&
l :
m.second) {
307 if(l.second->category().empty())
continue;
308 unique_cats.insert(
"cat:" + l.second->category());
311 std::copy(unique_cats.begin(), unique_cats.end(), std::back_inserter(
categories));
323 const SDL_Color
color,
324 const bool visible_in_fog,
325 const bool visible_in_shroud,
326 const bool immutable,
333 team_name_(team_name),
334 visible_in_fog_(visible_in_fog),
335 visible_in_shroud_(visible_in_shroud),
336 immutable_(immutable),
351 visible_in_fog_(true),
352 visible_in_shroud_(false),
384 int side = cfg[
"side"].to_int(-1);
387 }
else if(cfg[
"side"].str() ==
"current") {
389 if(!current_side.
empty()) {
398 if(!tmp_color.empty()) {
408 cfg[
"text"] =
text();
471 std::stringstream
buf;
472 const unsigned int red =
static_cast<unsigned int>(
color_.r);
473 const unsigned int green =
static_cast<unsigned int>(
color_.g);
474 const unsigned int blue =
static_cast<unsigned int>(
color_.b);
475 const unsigned int alpha =
static_cast<unsigned int>(
color_.a);
476 buf << red <<
"," << green <<
"," << blue <<
"," <<
alpha;
489 const SDL_Color
color)
503 const SDL_Color
color,
504 const bool visible_in_fog,
505 const bool visible_in_shroud,
506 const bool immutable,
513 update_info(text, creator, tooltip, team_name, color);
576 flabel.set_position(xloc, yloc);
581 flabel.use_markup(use_markup);
601 if(
std::find(hidden_categories.begin(), hidden_categories.end(),
category) != hidden_categories.end())
603 if(
creator_ >= 0 &&
std::find(hidden_categories.begin(), hidden_categories.end(),
creator) != hidden_categories.end())
605 if(!
team_name().empty() &&
std::find(hidden_categories.begin(), hidden_categories.end(),
"team") != hidden_categories.end())
630 if ( dc.
teams().empty() )
634 const bool can_see_team_labels = !dc.
is_observer();
const map_labels * parent_
child_itors child_range(const std::string &key)
void recalculate_shroud()
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
std::map< map_location, terrain_label * > label_map
std::string cfg_color() const
std::string interpolate_variables_into_string(const std::string &str, const string_map *const symbols)
Function which will interpolate variables, starting with '$' in the string 'str' with the equivalent ...
map_labels & operator=(const map_labels &)
GLsizei GLenum * categories
const std::vector< std::string > & all_categories() const
void write(config &res) const
void show_floating_label(int handle, bool value)
hides or shows a floating label
const map_location & location() const
void remove_floating_label(int handle)
removes the floating label given by 'handle' from the screen
bool hidden() const
This is a lightweight test used to see if labels are revealed as a result of unit actions (i...
int get_location_x(const map_location &loc) const
Functions to get the on-screen positions of hexes.
bool empty() const
Tests for an attribute that either was never set or was set to "".
tformula< t_string > text_
The text to draw.
Variant for storing WML attributes.
void update_info(const t_string &, const int creator, const t_string &, const std::string &, const SDL_Color)
int get_location_y(const map_location &loc) const
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const SDL_Color color=font::NORMAL_COLOR, const bool visible_in_fog=true, const bool visible_in_shroud=false, const bool immutable=false, const std::string &category="", const t_string &tooltip="")
const std::string & team_name() const
bool is_fogged(const display &disp, const map_location &loc)
Rather simple test for a hex being fogged.
const SDL_Color & color() const
This class stores all the data for a single 'side' (in game nomenclature).
const t_string & text() const
std::vector< std::string > categories
const std::string & category() const
std::vector< team > * teams
bool viewable(const display_context &dc) const
This is a test used to see if we should bother with the overhead of actually creating a label...
void clear(const std::string &, bool force)
map_labels(const map_labels &)
bool is_shrouded(const display &disp, const map_location &loc)
terrain_label(const t_string &text, const int creator, const std::string &team_name, const map_location &loc, const map_labels &parent, const SDL_Color color=font::NORMAL_COLOR, const bool visible_in_fog=true, const bool visible_in_shroud=false, const bool immutable=false, const std::string &category="", const t_string &tooltip="")
creating new label
void set_color(const SDL_Color &color)
const std::string & team_name() const
config & add_child(const std::string &key)
GLclampf GLclampf GLclampf alpha
GLenum GLuint GLsizei const char * buf
void enable(bool is_enabled)
terrain_label * get_label_private(const map_location &loc, const std::string &team_name)
For our private use, a wrapper for get_label() that can return a pointer to a non-const terrain_label...
const std::string & team_name() const
map_display and display: classes which take care of displaying the map and game-data on the screen...
const display & disp() const
const terrain_label * get_label(const map_location &loc, const std::string &team_name) const
void write(config &cfg) const
Encapsulates the map of the game.
void set_team(const team *)
void add_label(const map_location &, terrain_label *)
void recalculate_labels()
virtual const std::vector< team > & teams() const =0
std::map< std::string, tfilter >::iterator itor
void read(const config &cfg)
bool visible_in_shroud() const
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
const SDL_Color LABEL_COLOR
void clear_map(label_map &, bool)
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
bool visible_in_fog() const
void write(config &res) const
void read(const config &cfg)
To store label data Class implements logic for rendering.
virtual config::attribute_value get_variable_const(const std::string &id) const =0
bool find(E event, F functor)
Tests whether an event handler is available.
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
const t_string & tooltip() const
bool is_observer() const
Check if we are an observer in this game.
int to_int(int def=0) const
const display_context & get_disp_context() const
SDL_Color string_to_color(const std::string &cmp_str)
Return the color the string represents.
const std::string & str() const
void set_text(const t_string &)
virtual const std::vector< std::string > & hidden_label_categories() const =0
bool visible_global_label(const map_location &) const
Returns whether or not a global (non-team) label can be shown at a specified location.
A config object defines a single node in a WML file, with access to child nodes.
int hex_size() const
Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right ...
t_string interpolate_variables_into_tstring(const t_string &tstr, const variable_set &variables)
Function that does the same as the above, for t_stringS.
SDL_Rect get_rect() const
GLsizei const GLcharARB ** string