To store label data Class implements logic for rendering. More...
#include <label.hpp>
Public Member Functions | |
terrain_label (const terrain_label &)=delete | |
Delete copy ctor and assignment ops. More... | |
terrain_label & | operator= (const terrain_label &)=delete |
terrain_label (const map_labels &parent, const t_string &text, const int creator, const std::string &team_name, const map_location &loc, 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="") | |
Create a new label. More... | |
terrain_label (const map_labels &, const config &) | |
Load label from config. More... | |
terrain_label (terrain_label &&) | |
Move ctor. More... | |
~terrain_label () | |
void | write (config &res) const |
void | read (const config &cfg) |
const t_string & | text () const |
const t_string & | tooltip () const |
int | creator () const |
const std::string & | team_name () const |
const std::string & | category () const |
bool | visible_in_fog () const |
bool | visible_in_shroud () const |
bool | immutable () const |
const map_location & | location () const |
const color_t & | color () const |
void | set_text (const t_string &text) |
void | update_info (const t_string &, const int creator, const t_string &, const std::string &, const color_t) |
void | update_info (const t_string &text, const int creator, const t_string &tooltip, const std::string &team_name, const color_t color, const bool visible_in_fog, const bool visible_in_shroud, const bool immutable, const std::string &category) |
void | recalculate () |
void | calculate_shroud () |
Private Member Functions | |
void | clear () |
bool | hidden () const |
This is a lightweight test used to see if labels are revealed as a result of unit actions (i.e. More... | |
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. More... | |
SDL_Rect | get_rect () const |
Private Attributes | |
int | handle_ |
int | tooltip_handle_ |
t_string | text_ |
t_string | tooltip_ |
std::string | category_ |
std::string | team_name_ |
bool | visible_in_fog_ |
bool | visible_in_shroud_ |
bool | immutable_ |
int | creator_ |
color_t | color_ |
const map_labels * | parent_ |
map_location | loc_ |
|
delete |
Delete copy ctor and assignment ops.
terrain_label::terrain_label | ( | const map_labels & | parent, |
const t_string & | text, | ||
const int | creator, | ||
const std::string & | team_name, | ||
const map_location & | loc, | ||
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 = "" |
||
) |
terrain_label::terrain_label | ( | const map_labels & | parent, |
const config & | cfg | ||
) |
terrain_label::terrain_label | ( | terrain_label && | l | ) |
void terrain_label::calculate_shroud | ( | ) |
Definition at line 480 of file label.cpp.
References tooltips::add_tooltip(), t_string::empty(), get_rect(), handle_, hidden(), tooltips::remove_tooltip(), font::show_floating_label(), t_string::str(), tooltip_, tooltip_handle_, and tooltips::update_tooltip().
Referenced by recalculate().
|
inline |
Definition at line 159 of file label.hpp.
References category_.
Referenced by editor::mouse_action_map_label::drag_end_left(), hidden(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), and update_info().
|
private |
Definition at line 637 of file label.cpp.
References handle_, font::remove_floating_label(), tooltips::remove_tooltip(), and tooltip_handle_.
Referenced by recalculate(), and ~terrain_label().
|
inline |
Definition at line 184 of file label.hpp.
References color_.
Referenced by editor::mouse_action_map_label::drag_end_left(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), read(), editor::mouse_action_map_label::up_left(), and update_info().
|
inline |
Definition at line 149 of file label.hpp.
References creator_.
Referenced by hidden(), and update_info().
|
private |
Definition at line 501 of file label.cpp.
References sdl::empty_rect, display::get_location_rect(), display::get_singleton(), display::hex_size(), and loc_.
Referenced by calculate_shroud().
|
private |
This is a lightweight test used to see if labels are revealed as a result of unit actions (i.e.
fog/shroud clearing). It should not contain any tests that are invariant during unit movement (disregarding potential WML events); those belong in visible().
Definition at line 568 of file label.cpp.
References category(), category_, display::context(), creator(), creator_, display::get_singleton(), display_context::hidden_label_categories(), is_fogged(), is_shrouded(), loc_, team_name(), visible_in_fog_, and visible_in_shroud_.
Referenced by calculate_shroud().
|
inline |
Definition at line 174 of file label.hpp.
References immutable_.
Referenced by editor::mouse_action_map_label::drag_end_left(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), and update_info().
|
inline |
|
delete |
void terrain_label::read | ( | const config & | cfg | ) |
Definition at line 385 of file label.cpp.
References category_, color(), color_, creator_, config_attribute_value::empty(), color_t::from_rgb_string(), color_t::from_rgba_string(), resources::gamedata, variable_set::get_variable_const(), immutable_, utils::interpolate_variables_into_string(), utils::interpolate_variables_into_tstring(), font::LABEL_COLOR, loc_, team_name_, text_, config_attribute_value::to_int(), tooltip_, visible_in_fog_, and visible_in_shroud_.
Referenced by terrain_label().
void terrain_label::recalculate | ( | ) |
Definition at line 520 of file label.cpp.
References font::add_floating_label(), font::ANCHOR_LABEL_MAP, calculate_shroud(), clear(), color_, t_string::empty(), map_location::get_direction(), display::get_location(), display::get_singleton(), handle_, font::LABEL_COLOR, loc_, display::map_outside_area(), map_location::north_east, scale_to_map_zoom(), font::floating_label::set_clip_rect(), font::floating_label::set_color(), font::floating_label::set_font_size(), font::floating_label::set_height(), font::floating_label::set_position(), font::floating_label::set_scroll_mode(), font::floating_label::set_width(), font::SIZE_NORMAL, map_location::south, t_string::str(), text_, tooltip_, font::floating_label::use_markup(), and viewable().
Referenced by map_labels::set_label(), terrain_label(), and update_info().
|
inline |
|
inline |
Definition at line 154 of file label.hpp.
References team_name_.
Referenced by editor::mouse_action_map_label::drag_end_left(), hidden(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), update_info(), and write().
|
inline |
Definition at line 139 of file label.hpp.
References text_.
Referenced by editor::mouse_action_map_label::drag_end_left(), events::menu_handler::label_terrain(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), set_text(), editor::mouse_action_map_label::up_left(), update_info(), and write().
|
inline |
Definition at line 144 of file label.hpp.
References tooltip_.
Referenced by update_info(), and write().
void terrain_label::update_info | ( | const t_string & | text, |
const int | creator, | ||
const t_string & | tooltip, | ||
const std::string & | team_name, | ||
const color_t | color | ||
) |
Definition at line 447 of file label.cpp.
References color(), color_, creator(), creator_, recalculate(), team_name(), team_name_, text(), text_, tooltip(), and tooltip_.
Referenced by update_info().
void terrain_label::update_info | ( | const t_string & | text, |
const int | creator, | ||
const t_string & | tooltip, | ||
const std::string & | team_name, | ||
const color_t | color, | ||
const bool | visible_in_fog, | ||
const bool | visible_in_shroud, | ||
const bool | immutable, | ||
const std::string & | category | ||
) |
Definition at line 462 of file label.cpp.
References category(), category_, color(), creator(), immutable(), immutable_, team_name(), text(), tooltip(), update_info(), visible_in_fog(), visible_in_fog_, visible_in_shroud(), and visible_in_shroud_.
|
private |
This is a test used to see if we should bother with the overhead of actually creating a label.
Conditions that can change during unit movement (disregarding potential WML events) should not be listed here; they belong in hidden().
Definition at line 614 of file label.cpp.
References display::context(), map_labels::enabled(), display::in_editor(), display_context::is_observer(), loc_, parent_, map_labels::team_name(), team_name_, and map_labels::visible_global_label().
Referenced by recalculate().
|
inline |
Definition at line 164 of file label.hpp.
References visible_in_fog_.
Referenced by editor::mouse_action_map_label::drag_end_left(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), and update_info().
|
inline |
Definition at line 169 of file label.hpp.
References visible_in_shroud_.
Referenced by editor::mouse_action_map_label::drag_end_left(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), and update_info().
void terrain_label::write | ( | config & | res | ) | const |
Definition at line 432 of file label.cpp.
References category_, color_, creator_, immutable_, loc_, team_name(), text(), color_t::to_rgb_string(), tooltip(), visible_in_fog_, visible_in_shroud_, and map_location::write().
|
private |
Definition at line 220 of file label.hpp.
Referenced by category(), hidden(), read(), update_info(), and write().
|
private |
Definition at line 228 of file label.hpp.
Referenced by color(), read(), recalculate(), update_info(), and write().
|
private |
|
private |
Definition at line 214 of file label.hpp.
Referenced by calculate_shroud(), clear(), and recalculate().
|
private |
Definition at line 225 of file label.hpp.
Referenced by immutable(), read(), update_info(), and write().
|
private |
Definition at line 231 of file label.hpp.
Referenced by get_rect(), hidden(), location(), read(), recalculate(), viewable(), and write().
|
private |
Definition at line 230 of file label.hpp.
Referenced by viewable().
|
private |
Definition at line 221 of file label.hpp.
Referenced by read(), team_name(), update_info(), and viewable().
|
private |
Definition at line 217 of file label.hpp.
Referenced by read(), recalculate(), set_text(), text(), and update_info().
|
private |
Definition at line 218 of file label.hpp.
Referenced by calculate_shroud(), read(), recalculate(), tooltip(), and update_info().
|
private |
Definition at line 215 of file label.hpp.
Referenced by calculate_shroud(), and clear().
|
private |
Definition at line 223 of file label.hpp.
Referenced by hidden(), read(), update_info(), visible_in_fog(), and write().
|
private |
Definition at line 224 of file label.hpp.
Referenced by hidden(), read(), update_info(), visible_in_shroud(), and write().