The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
terrain_label Class Reference

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_stringtext () const
 
const t_stringtooltip () const
 
int creator () const
 
const std::stringteam_name () const
 
const std::stringcategory () const
 
bool visible_in_fog () const
 
bool visible_in_shroud () const
 
bool immutable () const
 
const map_locationlocation () 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_labeloperator= (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_labelsparent_
 
map_location loc_
 

Detailed Description

To store label data Class implements logic for rendering.

Definition at line 103 of file label.hpp.

Constructor & Destructor Documentation

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 = "" 
)

creating new label

Definition at line 318 of file label.cpp.

References draw().

terrain_label::terrain_label ( const map_labels parent,
const config cfg 
)

Load label from config.

Definition at line 346 of file label.cpp.

References read().

terrain_label::~terrain_label ( )

Definition at line 363 of file label.cpp.

References clear().

terrain_label::terrain_label ( const terrain_label )
private

Member Function Documentation

void terrain_label::calculate_shroud ( )
const std::string & terrain_label::category ( ) const
std::string terrain_label::cfg_color ( ) const
private

Definition at line 469 of file label.cpp.

References color_.

Referenced by write().

void terrain_label::clear ( )
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
int terrain_label::creator ( ) const

Definition at line 429 of file label.cpp.

References creator_.

Referenced by do_replay_handle(), hidden(), and update_info().

void terrain_label::draw ( )
private
SDL_Rect terrain_label::get_rect ( ) const
private
bool terrain_label::hidden ( ) const
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
const map_location & terrain_label::location ( ) const

Definition at line 459 of file label.cpp.

References loc_.

Referenced by do_replay_handle().

const terrain_label& terrain_label::operator= ( const terrain_label )
private
void terrain_label::read ( const config cfg)
void terrain_label::recalculate ( )

Definition at line 516 of file label.cpp.

References draw().

Referenced by map_labels::set_label().

void terrain_label::set_text ( const t_string text)

Definition at line 480 of file label.cpp.

References text(), and text_.

const std::string & terrain_label::team_name ( ) const
const t_string & terrain_label::text ( ) const
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 
)
bool terrain_label::viewable ( const display_context dc) const
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
bool terrain_label::visible_in_shroud ( ) const
void terrain_label::write ( config res) const

Member Data Documentation

std::string terrain_label::category_
private

Definition at line 171 of file label.hpp.

Referenced by category(), hidden(), read(), update_info(), and write().

SDL_Color terrain_label::color_
private

Definition at line 178 of file label.hpp.

Referenced by cfg_color(), color(), draw(), read(), and update_info().

int terrain_label::creator_
private

Definition at line 176 of file label.hpp.

Referenced by creator(), hidden(), read(), update_info(), and write().

int terrain_label::handle_
private

Definition at line 166 of file label.hpp.

Referenced by calculate_shroud(), clear(), and draw().

bool terrain_label::immutable_
private

Definition at line 175 of file label.hpp.

Referenced by immutable(), read(), update_info(), and write().

map_location terrain_label::loc_
private

Definition at line 181 of file label.hpp.

Referenced by draw(), get_rect(), hidden(), location(), read(), viewable(), and write().

const map_labels* terrain_label::parent_
private

Definition at line 180 of file label.hpp.

Referenced by draw(), get_rect(), hidden(), and viewable().

std::string terrain_label::team_name_
private

Definition at line 172 of file label.hpp.

Referenced by read(), team_name(), update_info(), and viewable().

t_string terrain_label::text_
private

Definition at line 169 of file label.hpp.

Referenced by draw(), read(), set_text(), text(), and update_info().

t_string terrain_label::tooltip_
private

Definition at line 170 of file label.hpp.

Referenced by calculate_shroud(), draw(), read(), tooltip(), and update_info().

int terrain_label::tooltip_handle_
private

Definition at line 167 of file label.hpp.

Referenced by calculate_shroud(), and clear().

bool terrain_label::visible_in_fog_
private

Definition at line 173 of file label.hpp.

Referenced by hidden(), read(), update_info(), visible_in_fog(), and write().

bool terrain_label::visible_in_shroud_
private

Definition at line 174 of file label.hpp.

Referenced by hidden(), read(), update_info(), visible_in_shroud(), and write().


The documentation for this class was generated from the following files: