The Battle for Wesnoth  1.19.5+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 ()
 
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 110 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 316 of file label.cpp.

References recalculate().

◆ terrain_label() [3/4]

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

Load label from config.

Definition at line 344 of file label.cpp.

References read().

◆ terrain_label() [4/4]

terrain_label::terrain_label ( terrain_label &&  l)

Move ctor.

Definition at line 361 of file label.cpp.

◆ ~terrain_label()

terrain_label::~terrain_label ( )

Definition at line 380 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

◆ color()

const color_t& terrain_label::color ( ) const
inline

◆ creator()

int terrain_label::creator ( ) const
inline

Definition at line 149 of file label.hpp.

References creator_.

Referenced by hidden(), and update_info().

◆ 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 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().

◆ immutable()

bool terrain_label::immutable ( ) const
inline

◆ location()

const map_location& terrain_label::location ( ) const
inline

Definition at line 179 of file label.hpp.

References loc_.

◆ operator=()

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

◆ read()

void terrain_label::read ( const config cfg)

◆ recalculate()

void terrain_label::recalculate ( )

◆ set_text()

void terrain_label::set_text ( const t_string text)
inline

Definition at line 189 of file label.hpp.

References text(), and text_.

◆ 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 144 of file label.hpp.

References tooltip_.

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

References color(), color_, creator(), creator_, recalculate(), 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 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().

◆ 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 220 of file label.hpp.

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

◆ color_

color_t terrain_label::color_
private

Definition at line 228 of file label.hpp.

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

◆ creator_

int terrain_label::creator_
private

Definition at line 226 of file label.hpp.

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

◆ handle_

int terrain_label::handle_
private

Definition at line 214 of file label.hpp.

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

◆ immutable_

bool terrain_label::immutable_
private

Definition at line 225 of file label.hpp.

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

◆ loc_

map_location terrain_label::loc_
private

Definition at line 231 of file label.hpp.

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

◆ parent_

const map_labels* terrain_label::parent_
private

Definition at line 230 of file label.hpp.

Referenced by viewable().

◆ team_name_

std::string terrain_label::team_name_
private

Definition at line 221 of file label.hpp.

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

◆ text_

t_string terrain_label::text_
private

Definition at line 217 of file label.hpp.

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

◆ tooltip_

t_string terrain_label::tooltip_
private

Definition at line 218 of file label.hpp.

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

◆ tooltip_handle_

int terrain_label::tooltip_handle_
private

Definition at line 215 of file label.hpp.

Referenced by calculate_shroud(), and clear().

◆ visible_in_fog_

bool terrain_label::visible_in_fog_
private

Definition at line 223 of file label.hpp.

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

◆ visible_in_shroud_

bool terrain_label::visible_in_shroud_
private

Definition at line 224 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: