The Battle for Wesnoth  1.19.27+dev
Public Member Functions | Private Attributes | List of all members
color_range Class Reference

Representing the "team color" information, this C++ class contains a subset of WML's [color_range] tag. More...

#include <color_range.hpp>

Public Member Functions

 color_range (color_t mid, color_t max, color_t min, color_t rep, color_t font)
 Constructor, which expects four reference RGB colors. More...
 
 color_range (const std::vector< color_t > &v, const std::optional< color_t > &font)
 Constructor, matching the WML tag's split of the rgb attribute in one argument, and the color for UI text in a different argument. More...
 
 color_range ()
 Default constructor. More...
 
color_t mid () const
 Average color shade. More...
 
color_t max () const
 Maximum color shade. More...
 
color_t min () const
 Minimum color shade. More...
 
color_t rep () const
 High-contrast against typical terrain colors, intended for the minimap markers. More...
 
color_t font_color () const
 High-contrast to dark backgrounds, intended for the text in the chat log, etc. More...
 
bool operator== (const color_range &b) const
 
std::string debug () const
 Return a string describing the color range for debug output. More...
 

Private Attributes

color_t mid_
 
color_t max_
 
color_t min_
 
color_t rep_
 
color_t font_color_
 

Detailed Description

Representing the "team color" information, this C++ class contains a subset of WML's [color_range] tag.

The other content of the [color_range] tags is parsed by the game_config class, and the data is held by several globals declared in game_config.hpp.

The main definition is made of three reference RGB colors, used for calculating conversions from a source/key palette with the external generate_color_mapping() method.

1) The average shade of a unit's team-color portions (default: gray #808080) 2) The maximum highlight shade of a unit's team-color portions (default: white) 3) The minimum shadow shade of a unit's team-color portions (default: black)

Some further colors are included because this mixes the responsibilities of being the "team color" class.

4) A color with high contrast to terrain colors, so that it can be used for the markers on the mini-map. (default: same as the provided average shade, or gray #808080) 5) A color with high contrast to dark backgrounds, used for text.

Definition at line 52 of file color_range.hpp.

Constructor & Destructor Documentation

◆ color_range() [1/3]

color_range::color_range ( color_t  mid,
color_t  max,
color_t  min,
color_t  rep,
color_t  font 
)
inline

Constructor, which expects four reference RGB colors.

Parameters
midAverage color shade.
maxMaximum (highlight) color shade
minMinimum color shade
repHigh-contrast to terrain
fontHigh-contrast to a dark background

Definition at line 63 of file color_range.hpp.

◆ color_range() [2/3]

color_range::color_range ( const std::vector< color_t > &  v,
const std::optional< color_t > &  font 
)
inline

Constructor, matching the WML tag's split of the rgb attribute in one argument, and the color for UI text in a different argument.

Definition at line 75 of file color_range.hpp.

◆ color_range() [3/3]

color_range::color_range ( )
inline

Default constructor.

Definition at line 84 of file color_range.hpp.

Member Function Documentation

◆ debug()

std::string color_range::debug ( ) const

Return a string describing the color range for debug output.

Definition at line 109 of file color_range.cpp.

References font_color_, max_, mid_, min_, rep_, and color_t::to_hex_string().

◆ font_color()

color_t color_range::font_color ( ) const
inline

High-contrast to dark backgrounds, intended for the text in the chat log, etc.

Definition at line 105 of file color_range.hpp.

References font_color_.

Referenced by team::get_font_color().

◆ max()

color_t color_range::max ( ) const
inline

Maximum color shade.

Definition at line 96 of file color_range.hpp.

References max_.

◆ mid()

color_t color_range::mid ( ) const
inline

Average color shade.

Definition at line 93 of file color_range.hpp.

References mid_.

Referenced by team::get_side_color().

◆ min()

color_t color_range::min ( ) const
inline

Minimum color shade.

Definition at line 99 of file color_range.hpp.

References min_.

◆ operator==()

bool color_range::operator== ( const color_range b) const
inline

Definition at line 107 of file color_range.hpp.

References b, font_color_, max_, mid_, min_, and rep_.

◆ rep()

color_t color_range::rep ( ) const
inline

High-contrast against typical terrain colors, intended for the minimap markers.

Definition at line 102 of file color_range.hpp.

References rep_.

Referenced by team::get_minimap_color(), and image::prep_minimap_for_rendering().

Member Data Documentation

◆ font_color_

color_t color_range::font_color_
private

Definition at line 117 of file color_range.hpp.

Referenced by debug(), font_color(), and operator==().

◆ max_

color_t color_range::max_
private

Definition at line 117 of file color_range.hpp.

Referenced by debug(), max(), and operator==().

◆ mid_

color_t color_range::mid_
private

Definition at line 117 of file color_range.hpp.

Referenced by debug(), mid(), and operator==().

◆ min_

color_t color_range::min_
private

Definition at line 117 of file color_range.hpp.

Referenced by debug(), min(), and operator==().

◆ rep_

color_t color_range::rep_
private

Definition at line 117 of file color_range.hpp.

Referenced by debug(), operator==(), and rep().


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