To store label data Class implements logic for rendering. More...
#include <label.hpp>
Public Member Functions | |
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 More... | |
terrain_label (const map_labels &, const config &) | |
Load label from config. 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 SDL_Color & | color () const |
void | set_text (const t_string &) |
void | update_info (const t_string &, const int creator, const t_string &, const std::string &, const SDL_Color) |
void | update_info (const t_string &text, const int creator, const t_string &tooltip, const std::string &team_name, const SDL_Color 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 | |
terrain_label (const terrain_label &) | |
const terrain_label & | operator= (const terrain_label &) |
void | clear () |
void | draw () |
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_context &dc) const |
This is a test used to see if we should bother with the overhead of actually creating a label. More... | |
std::string | cfg_color () const |
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_ |
SDL_Color | color_ |
const map_labels * | parent_ |
map_location | loc_ |
terrain_label::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 = "" |
||
) |
terrain_label::terrain_label | ( | const map_labels & | parent, |
const config & | cfg | ||
) |
|
private |
void terrain_label::calculate_shroud | ( | ) |
Definition at line 521 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 draw().
const std::string & terrain_label::category | ( | ) | const |
Definition at line 434 of file label.cpp.
References category_.
Referenced by editor::mouse_action_map_label::drag_left(), hidden(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), and update_info().
|
private |
|
private |
Definition at line 644 of file label.cpp.
References handle_, font::remove_floating_label(), tooltips::remove_tooltip(), and tooltip_handle_.
Referenced by draw(), and ~terrain_label().
const SDL_Color & terrain_label::color | ( | ) | const |
Definition at line 464 of file label.cpp.
References color_.
Referenced by do_replay_handle(), editor::mouse_action_map_label::drag_left(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), read(), editor::mouse_action_map_label::up_left(), and update_info().
int terrain_label::creator | ( | ) | const |
Definition at line 429 of file label.cpp.
References creator_.
Referenced by do_replay_handle(), hidden(), and update_info().
|
private |
Definition at line 554 of file label.cpp.
References font::add_floating_label(), font::ANCHOR_LABEL_MAP, calculate_shroud(), clear(), color_, map_labels::disp(), t_string::empty(), display::get_disp_context(), display::get_location_x(), display::get_location_y(), handle_, font::LABEL_COLOR, loc_, display::map_outside_area(), parent_, font::floating_label::set_color(), font::SIZE_NORMAL, t_string::str(), text_, tooltip_, viewable(), map_location::x, and map_location::y.
Referenced by recalculate(), terrain_label(), and update_info().
|
private |
Definition at line 541 of file label.cpp.
References map_labels::disp(), display::get_location_x(), display::get_location_y(), display::hex_size(), loc_, and parent_.
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 594 of file label.cpp.
References category(), category_, creator(), creator_, map_labels::disp(), gui2::event::find(), display::get_disp_context(), display_context::hidden_label_categories(), is_fogged(), is_shrouded(), loc_, parent_, team_name(), visible_in_fog_, and visible_in_shroud_.
Referenced by calculate_shroud().
bool terrain_label::immutable | ( | ) | const |
Definition at line 454 of file label.cpp.
References immutable_.
Referenced by playsingle_controller::hotkey_handler::can_execute_command(), editor::mouse_action_map_label::drag_left(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), and update_info().
const map_location & terrain_label::location | ( | ) | const |
|
private |
Definition at line 368 of file label.cpp.
References category_, color(), color_, creator_, config::attribute_value::empty(), resources::gamedata, variable_set::get_variable_const(), immutable_, utils::interpolate_variables_into_string(), utils::interpolate_variables_into_tstring(), font::LABEL_COLOR, loc_, help::string_to_color(), team_name_, text_, config::attribute_value::to_int(), tooltip_, visible_in_fog_, and visible_in_shroud_.
Referenced by terrain_label().
void terrain_label::recalculate | ( | ) |
const std::string & terrain_label::team_name | ( | ) | const |
Definition at line 439 of file label.cpp.
References team_name_.
Referenced by map_labels::add_label(), do_replay_handle(), editor::mouse_action_map_label::drag_left(), hidden(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), update_info(), and write().
const t_string & terrain_label::text | ( | ) | const |
Definition at line 419 of file label.cpp.
References text_.
Referenced by do_replay_handle(), events::menu_handler::do_search(), editor::mouse_action_map_label::drag_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().
const t_string & terrain_label::tooltip | ( | ) | const |
Definition at line 424 of file label.cpp.
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 SDL_Color | color | ||
) |
Definition at line 485 of file label.cpp.
References color(), color_, creator(), creator_, draw(), 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 SDL_Color | color, | ||
const bool | visible_in_fog, | ||
const bool | visible_in_shroud, | ||
const bool | immutable, | ||
const std::string & | category | ||
) |
Definition at line 499 of file label.cpp.
References category(), category_, immutable(), immutable_, 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 624 of file label.cpp.
References map_labels::enabled(), display_context::is_observer(), loc_, parent_, map_labels::team_name(), team_name_, display_context::teams(), and map_labels::visible_global_label().
Referenced by draw().
bool terrain_label::visible_in_fog | ( | ) | const |
Definition at line 444 of file label.cpp.
References visible_in_fog_.
Referenced by editor::mouse_action_map_label::drag_left(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), and update_info().
bool terrain_label::visible_in_shroud | ( | ) | const |
Definition at line 449 of file label.cpp.
References visible_in_shroud_.
Referenced by editor::mouse_action_map_label::drag_left(), editor::editor_action_label::perform(), editor::editor_action_label_delete::perform(), editor::mouse_action_map_label::up_left(), and update_info().
Definition at line 405 of file label.cpp.
References category_, cfg_color(), creator_, immutable_, loc_, team_name(), text(), tooltip(), visible_in_fog_, visible_in_shroud_, and map_location::write().
Referenced by replay::add_label().
|
private |
Definition at line 171 of file label.hpp.
Referenced by category(), hidden(), read(), update_info(), and write().
|
private |
Definition at line 178 of file label.hpp.
Referenced by cfg_color(), color(), draw(), read(), and update_info().
|
private |
|
private |
Definition at line 166 of file label.hpp.
Referenced by calculate_shroud(), clear(), and draw().
|
private |
Definition at line 175 of file label.hpp.
Referenced by immutable(), read(), update_info(), and write().
|
private |
Definition at line 181 of file label.hpp.
Referenced by draw(), get_rect(), hidden(), location(), read(), viewable(), and write().
|
private |
Definition at line 180 of file label.hpp.
Referenced by draw(), get_rect(), hidden(), and viewable().
|
private |
Definition at line 172 of file label.hpp.
Referenced by read(), team_name(), update_info(), and viewable().
|
private |
Definition at line 169 of file label.hpp.
Referenced by draw(), read(), set_text(), text(), and update_info().
|
private |
Definition at line 170 of file label.hpp.
Referenced by calculate_shroud(), draw(), read(), tooltip(), and update_info().
|
private |
Definition at line 167 of file label.hpp.
Referenced by calculate_shroud(), and clear().
|
private |
Definition at line 173 of file label.hpp.
Referenced by hidden(), read(), update_info(), visible_in_fog(), and write().
|
private |
Definition at line 174 of file label.hpp.
Referenced by hidden(), read(), update_info(), visible_in_shroud(), and write().