The Battle for Wesnoth  1.15.1+dev
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 terrain_label &)=delete
 Delete copy ctor and assignment ops. More...
 
terrain_labeloperator= (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_stringtext () const
 
const t_stringtooltip () 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_locationlocation () const
 
const color_tcolor () 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 ()
 
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 &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_labelsparent_
 
map_location loc_
 

Detailed Description

To store label data Class implements logic for rendering.

Definition at line 107 of file label.hpp.

Constructor & Destructor Documentation

◆ terrain_label() [1/4]

terrain_label::terrain_label ( const terrain_label )
delete

Delete copy ctor and assignment ops.

◆ terrain_label() [2/4]

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

Create a new label.

Definition at line 315 of file label.cpp.

References draw().

◆ terrain_label() [3/4]

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

Load label from config.

Definition at line 343 of file label.cpp.

References read().

◆ terrain_label() [4/4]

terrain_label::terrain_label ( terrain_label &&  l)

Move ctor.

Definition at line 360 of file label.cpp.

◆ ~terrain_label()

terrain_label::~terrain_label ( )

Definition at line 379 of file label.cpp.

References clear().

Member Function Documentation

◆ calculate_shroud()

void terrain_label::calculate_shroud ( )

◆ category()

const std::string& terrain_label::category ( ) const
inline

◆ clear()

void terrain_label::clear ( )
private

Definition at line 640 of file label.cpp.

References handle_, font::remove_floating_label(), tooltips::remove_tooltip(), and tooltip_handle_.

Referenced by draw(), and ~terrain_label().

◆ color()

const color_t& terrain_label::color ( ) const
inline

◆ creator()

int terrain_label::creator ( ) const
inline

Definition at line 146 of file label.hpp.

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

◆ draw()

void terrain_label::draw ( )
private

◆ get_rect()

SDL_Rect terrain_label::get_rect ( ) const
private

◆ hidden()

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 571 of file label.cpp.

References category(), category_, creator(), creator_, gui2::event::find(), display::get_disp_context(), 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().

◆ immutable()

bool terrain_label::immutable ( ) const
inline

◆ location()

const map_location& terrain_label::location ( ) const
inline

Definition at line 176 of file label.hpp.

References loc_.

Referenced by map_labels::add_label(), and do_replay_handle().

◆ operator=()

terrain_label& terrain_label::operator= ( const terrain_label )
delete

◆ read()

void terrain_label::read ( const config cfg)

◆ recalculate()

void terrain_label::recalculate ( )

Definition at line 479 of file label.cpp.

References draw().

Referenced by map_labels::set_label().

◆ set_text()

void terrain_label::set_text ( const t_string text)
inline

Definition at line 186 of file label.hpp.

References map_labels::clear().

◆ team_name()

const std::string& terrain_label::team_name ( ) const
inline

◆ text()

const t_string& terrain_label::text ( ) const
inline

◆ tooltip()

const t_string& terrain_label::tooltip ( ) const
inline

Definition at line 141 of file label.hpp.

Referenced by update_info(), and write().

◆ update_info() [1/2]

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 446 of file label.cpp.

References color(), color_, creator(), creator_, draw(), team_name(), team_name_, text(), text_, tooltip(), and tooltip_.

Referenced by update_info().

◆ update_info() [2/2]

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 
)

◆ viewable()

bool terrain_label::viewable ( const display disp) 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 617 of file label.cpp.

References map_labels::enabled(), display::get_disp_context(), display::in_editor(), display_context::is_observer(), loc_, parent_, map_labels::team_name(), team_name_, and map_labels::visible_global_label().

Referenced by draw().

◆ visible_in_fog()

bool terrain_label::visible_in_fog ( ) const
inline

◆ visible_in_shroud()

bool terrain_label::visible_in_shroud ( ) const
inline

◆ write()

void terrain_label::write ( config res) const

Member Data Documentation

◆ category_

std::string terrain_label::category_
private

Definition at line 218 of file label.hpp.

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

◆ color_

color_t terrain_label::color_
private

Definition at line 226 of file label.hpp.

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

◆ creator_

int terrain_label::creator_
private

Definition at line 224 of file label.hpp.

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

◆ handle_

int terrain_label::handle_
private

Definition at line 212 of file label.hpp.

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

◆ immutable_

bool terrain_label::immutable_
private

Definition at line 223 of file label.hpp.

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

◆ loc_

map_location terrain_label::loc_
private

Definition at line 229 of file label.hpp.

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

◆ parent_

const map_labels* terrain_label::parent_
private

Definition at line 228 of file label.hpp.

Referenced by viewable().

◆ team_name_

std::string terrain_label::team_name_
private

Definition at line 219 of file label.hpp.

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

◆ text_

t_string terrain_label::text_
private

Definition at line 215 of file label.hpp.

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

◆ tooltip_

t_string terrain_label::tooltip_
private

Definition at line 216 of file label.hpp.

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

◆ tooltip_handle_

int terrain_label::tooltip_handle_
private

Definition at line 213 of file label.hpp.

Referenced by calculate_shroud(), and clear().

◆ visible_in_fog_

bool terrain_label::visible_in_fog_
private

Definition at line 221 of file label.hpp.

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

◆ visible_in_shroud_

bool terrain_label::visible_in_shroud_
private

Definition at line 222 of file label.hpp.

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


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