51 , categories_dirty(true)
82 for(
const auto& group :
labels_) {
83 for(
const auto&
label : group.second) {
85 label.second.write(item);
109 return &itor->second;
122 if(res ==
nullptr && !
team_name().empty()) {
135 static const std::string empty;
150 const std::string& team_name,
152 const bool visible_in_fog,
153 const bool visible_in_shroud,
154 const bool immutable,
155 const std::string& category,
166 if(current_label_map !=
labels_.end() &&
167 (current_label = current_label_map->second.find(
loc)) != current_label_map->second.end())
170 if(text.
str().empty()) {
172 current_label_map->second.erase(current_label);
176 global_label->recalculate();
179 current_label->second.update_info(
180 text, creator,
tooltip,
team_name, color, visible_in_fog, visible_in_shroud, immutable, category);
182 res = ¤t_label->second;
184 }
else if(!text.
str().empty()) {
190 *
this, text, creator,
team_name,
loc, color, visible_in_fog, visible_in_shroud, immutable, category,
tooltip);
193 if(global_label !=
nullptr) {
202 template<
typename... T>
208 return &(*
labels_[
t.team_name()].emplace(
t.location(), std::move(
t)).first).second;
229 while(
i != m.end()) {
230 if(!
i->second.immutable() || force) {
248 for(
auto& l : m.second) {
249 l.second.recalculate();
269 if(
team_ ==
nullptr) {
275 return glabels ==
labels_.end() || glabels->second.find(
loc) == glabels->second.end();
281 for(
auto& l : m.second) {
282 l.second.calculate_shroud();
295 categories.push_back(
"side:" + std::to_string(
t.side()));
298 std::set<std::string> unique_cats;
300 for(
const auto& l : m.second) {
301 if(l.second.category().empty()) {
305 unique_cats.insert(
"cat:" + l.second.category());
309 std::copy(unique_cats.begin(), unique_cats.end(), std::back_inserter(
categories));
319 const std::string& team_name,
322 const bool visible_in_fog,
323 const bool visible_in_shroud,
324 const bool immutable,
325 const std::string& category,
330 , category_(category)
331 , team_name_(team_name)
332 , visible_in_fog_(visible_in_fog)
333 , visible_in_shroud_(visible_in_shroud)
334 , immutable_(immutable)
350 , visible_in_fog_(true)
351 , visible_in_shroud_(false)
363 , tooltip_handle_(l.tooltip_handle_)
365 , tooltip_(l.tooltip_)
366 , category_(l.category_)
367 , team_name_(l.team_name_)
368 , visible_in_fog_(l.visible_in_fog_)
369 , visible_in_shroud_(l.visible_in_shroud_)
370 , immutable_(l.immutable_)
371 , creator_(l.creator_)
377 l.tooltip_handle_ = 0;
392 std::string tmp_color = cfg[
"color"];
402 int side = cfg[
"side"].to_int(-1);
405 }
else if(cfg[
"side"].str() ==
"current") {
407 if(!current_side.
empty()) {
418 if(!tmp_color.empty()) {
421 }
catch(
const std::invalid_argument&) {
436 cfg[
"text"] =
text();
450 const std::string& team_name,
465 const std::string& team_name,
467 const bool visible_in_fog,
468 const bool visible_in_shroud,
469 const bool immutable,
470 const std::string& category)
580 if(
std::find(hidden_categories.begin(), hidden_categories.end(),
category) != hidden_categories.end()) {
585 std::find(hidden_categories.begin(), hidden_categories.end(),
creator) != hidden_categories.end())
591 std::find(hidden_categories.begin(), hidden_categories.end(),
"team") != hidden_categories.end())
Variant for storing WML attributes.
int to_int(int def=0) const
bool empty() const
Tests for an attribute that either was never set or was set to "".
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
config & add_child(config_key_type key)
bool is_observer() const
Check if we are an observer in this game.
virtual const std::vector< std::string > & hidden_label_categories() const =0
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
point get_location(const map_location &loc) const
Functions to get the on-screen positions of hexes.
static int hex_size()
Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right ...
static double get_zoom_factor()
Returns the current zoom factor.
bool fogged(const map_location &loc) const
Returns true if location (x,y) is covered in fog.
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
virtual bool in_editor() const
const display_context & context() const
rect get_location_rect(const map_location &loc) const
Returns the on-screen rect corresponding to a loc.
static display * get_singleton()
Returns the display object if a display object exists.
bool shrouded(const map_location &loc) const
Returns true if location (x,y) is covered in shroud.
void set_position(double xpos, double ypos)
void set_color(const color_t &color)
void set_clip_rect(const SDL_Rect &r)
void set_scroll_mode(LABEL_SCROLL_MODE scroll)
void set_font_size(int font_size)
void write(config &res) const
void clear_map(label_map &, bool)
const std::vector< std::string > & all_categories() const
const std::string & team_name() const
bool visible_global_label(const map_location &) const
Returns whether or not a global (non-team) label can be shown at a specified location.
terrain_label * add_label(T &&... args)
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const color_t 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 terrain_label * get_label(const map_location &loc, const std::string &team_name) const
void recalculate_shroud()
terrain_label * get_label_private(const map_location &loc, const std::string &team_name)
map_labels & operator=(const map_labels &)
void enable(bool is_enabled)
void set_team(const team *)
void clear(const std::string &, bool force)
std::vector< std::string > categories
map_labels(const map_labels &)
void recalculate_labels()
std::map< map_location, terrain_label > label_map
void read(const config &cfg)
const std::string & str() const
This class stores all the data for a single 'side' (in game nomenclature).
const std::string & team_name() const
To store label data Class implements logic for rendering.
terrain_label(const terrain_label &)=delete
Delete copy ctor and assignment ops.
bool visible_in_shroud() const
void update_info(const t_string &, const int creator, const t_string &, const std::string &, const color_t)
bool visible_in_fog() const
const t_string & tooltip() const
void write(config &res) const
const map_labels * parent_
SDL_Rect get_rect() const
bool hidden() const
This is a lightweight test used to see if labels are revealed as a result of unit actions (i....
const color_t & color() const
bool viewable(const display &disp) const
This is a test used to see if we should bother with the overhead of actually creating a label.
const std::string & category() const
const t_string & text() const
void read(const config &cfg)
const std::string & team_name() const
virtual config::attribute_value get_variable_const(const std::string &id) const =0
map_display and display: classes which take care of displaying the map and game-data on the screen.
std::string label
What to show in the filter's drop-down list.
std::string tooltip
Shown when hovering over an entry in the filter's drop-down list.
bool is_shrouded(const display *disp, const map_location &loc)
Our definition of map labels being obscured is if the tile is obscured, or the tile below is obscured...
static int scale_to_map_zoom(int val)
bool is_fogged(const display *disp, const map_location &loc)
Rather simple test for a hex being fogged.
const color_t LABEL_COLOR
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
void show_floating_label(int handle, bool value)
hides or shows a floating label
void remove_floating_label(int handle, const std::chrono::milliseconds &fadeout)
removes the floating label given by 'handle' from the screen
constexpr const SDL_Rect empty_rect
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 ...
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.
auto * find(Container &container, const Value &value)
Convenience wrapper for using find on a container without needing to comare to end()
std::string::const_iterator iterator
The basic class for representing 8-bit RGB or RGBA colour values.
static color_t from_rgb_string(std::string_view c)
Creates a new opaque color_t object from a string variable in "R,G,B" format.
std::string to_rgb_string() const
Returns the stored color as an "R,G,B" string.
static color_t from_rgba_string(std::string_view c)
Creates a new color_t object from a string variable in "R,G,B,A" format.
Encapsulates the map of the game.
map_location get_direction(direction dir, unsigned int n=1u) const
void write(config &cfg) const