The Battle for Wesnoth  1.19.0-dev
Classes | Macros | Typedefs | Functions | Variables
reports.cpp File Reference
#include "actions/attack.hpp"
#include "attack_prediction.hpp"
#include "desktop/battery_info.hpp"
#include "font/pango/escape.hpp"
#include "font/text_formatting.hpp"
#include "formatter.hpp"
#include "formula/string_utils.hpp"
#include "preferences/game.hpp"
#include "gettext.hpp"
#include "language.hpp"
#include "map/map.hpp"
#include "mouse_events.hpp"
#include "pathfind/pathfind.hpp"
#include "picture.hpp"
#include "reports.hpp"
#include "color.hpp"
#include "team.hpp"
#include "terrain/movement.hpp"
#include "tod_manager.hpp"
#include "units/unit.hpp"
#include "units/helper.hpp"
#include "units/types.hpp"
#include "units/unit_alignments.hpp"
#include "whiteboard/manager.hpp"
#include <ctime>
#include <iomanip>
#include <boost/format.hpp>
Include dependency graph for reports.cpp:

Go to the source code of this file.

Classes

struct  report_generator_helper
 

Macros

#define REPORT_GENERATOR(n, cn)
 

Typedefs

typedef std::map< std::string, reports::generator_functionstatic_report_generators
 

Functions

static void add_text (config &report, const std::string &text, const std::string &tooltip, const std::string &help="")
 
static void add_image (config &report, const std::string &image, const std::string &tooltip, const std::string &help="")
 
static config text_report (const std::string &text, const std::string &tooltip="", const std::string &help="")
 
static config image_report (const std::string &image, const std::string &tooltip="", const std::string &help="")
 
static void add_status (config &r, const std::string &path, char const *desc1, char const *desc2)
 
static std::string flush (std::ostringstream &s)
 
static const time_of_day get_visible_time_of_day_at (const reports::context &rc, const map_location &hex)
 
static const unitget_visible_unit (const reports::context &rc)
 
static const unitget_selected_unit (const reports::context &rc)
 
static unit_const_ptr get_selected_unit_ptr (const reports::context &rc)
 
static config gray_inactive (const reports::context &rc, const std::string &str, const std::string &tooltip="")
 
static config unit_name (const unit *u)
 
 REPORT_GENERATOR (unit_name, rc)
 
 REPORT_GENERATOR (selected_unit_name, rc)
 
static config unit_type (const unit *u)
 
 REPORT_GENERATOR (unit_type, rc)
 
 REPORT_GENERATOR (selected_unit_type, rc)
 
static config unit_race (const unit *u)
 
 REPORT_GENERATOR (unit_race, rc)
 
 REPORT_GENERATOR (selected_unit_race, rc)
 
static std::string side_tooltip (const team &team)
 
static config unit_side (const reports::context &rc, const unit *u)
 
 REPORT_GENERATOR (unit_side, rc)
 
 REPORT_GENERATOR (selected_unit_side, rc)
 
static config unit_level (const unit *u)
 
 REPORT_GENERATOR (unit_level, rc)
 
 REPORT_GENERATOR (selected_unit_level, rc)
 
 REPORT_GENERATOR (unit_amla, rc)
 
static config unit_traits (const unit *u)
 
 REPORT_GENERATOR (unit_traits, rc)
 
 REPORT_GENERATOR (selected_unit_traits, rc)
 
static config unit_status (const reports::context &rc, const unit *u)
 
 REPORT_GENERATOR (unit_status, rc)
 
 REPORT_GENERATOR (selected_unit_status, rc)
 
static config unit_alignment (const reports::context &rc, const unit *u, const map_location &hex)
 
 REPORT_GENERATOR (unit_alignment, rc)
 
 REPORT_GENERATOR (selected_unit_alignment, rc)
 
static config unit_abilities (const unit *u, const map_location &loc)
 
 REPORT_GENERATOR (unit_abilities, rc)
 
 REPORT_GENERATOR (selected_unit_abilities, rc)
 
static config unit_hp (const reports::context &rc, const unit *u)
 
 REPORT_GENERATOR (unit_hp, rc)
 
 REPORT_GENERATOR (selected_unit_hp, rc)
 
static config unit_xp (const unit *u)
 
 REPORT_GENERATOR (unit_xp, rc)
 
 REPORT_GENERATOR (selected_unit_xp, rc)
 
static config unit_advancement_options (const unit *u)
 
 REPORT_GENERATOR (unit_advancement_options, rc)
 
 REPORT_GENERATOR (selected_unit_advancement_options, rc)
 
static config unit_defense (const reports::context &rc, const unit *u, const map_location &displayed_unit_hex)
 
 REPORT_GENERATOR (unit_defense, rc)
 
 REPORT_GENERATOR (selected_unit_defense, rc)
 
static config unit_vision (const unit *u)
 
 REPORT_GENERATOR (unit_vision, rc)
 
 REPORT_GENERATOR (selected_unit_vision, rc)
 
static config unit_moves (const reports::context &rc, const unit *u, bool is_visible_unit)
 
 REPORT_GENERATOR (unit_moves, rc)
 
 REPORT_GENERATOR (selected_unit_moves, rc)
 
static const color_t attack_info_percent_color (int resistance)
 Maps resistance <= -60 (resistance value <= -60%) to intense red. More...
 
static int attack_info (const reports::context &rc, const attack_type &at, config &res, const unit &u, const map_location &hex, const unit *sec_u=nullptr, const_attack_ptr sec_u_weapon=nullptr)
 
static std::string format_prob (double prob)
 
static std::string format_hp (unsigned hp)
 
static config unit_weapons (const reports::context &rc, unit_const_ptr attacker, const map_location &attacker_pos, const unit *defender, bool show_attacker)
 
static config unit_weapons (const reports::context &rc, const unit *u, const map_location &hex)
 
 REPORT_GENERATOR (unit_weapons, rc)
 
 REPORT_GENERATOR (highlighted_unit_weapons, rc)
 
 REPORT_GENERATOR (selected_unit_weapons, rc)
 
 REPORT_GENERATOR (unit_image, rc)
 
 REPORT_GENERATOR (selected_unit_image, rc)
 
 REPORT_GENERATOR (selected_unit_profile, rc)
 
 REPORT_GENERATOR (unit_profile, rc)
 
static config tod_stats_at (const reports::context &rc, const map_location &hex)
 
 REPORT_GENERATOR (tod_stats, rc)
 
 REPORT_GENERATOR (selected_tod_stats, rc)
 
static config time_of_day_at (const reports::context &rc, const map_location &mouseover_hex)
 
 REPORT_GENERATOR (time_of_day, rc)
 
 REPORT_GENERATOR (selected_time_of_day, rc)
 
static config unit_box_at (const reports::context &rc, const map_location &mouseover_hex)
 
 REPORT_GENERATOR (unit_box, rc)
 
 REPORT_GENERATOR (turn, rc)
 
 REPORT_GENERATOR (gold, rc)
 
 REPORT_GENERATOR (villages, rc)
 
 REPORT_GENERATOR (num_units, rc)
 
 REPORT_GENERATOR (upkeep, rc)
 
 REPORT_GENERATOR (expenses, rc)
 
 REPORT_GENERATOR (income, rc)
 
 REPORT_GENERATOR (terrain_info, rc)
 
 REPORT_GENERATOR (terrain, rc)
 
 REPORT_GENERATOR (zoom_level, rc)
 
 REPORT_GENERATOR (position, rc)
 
 REPORT_GENERATOR (side_playing, rc)
 
 REPORT_GENERATOR (observers, rc)
 
 REPORT_GENERATOR (report_clock,)
 
 REPORT_GENERATOR (battery,)
 
 REPORT_GENERATOR (report_countdown, rc)
 

Variables

static static_report_generators static_generators
 
static char const * naps = "</span>"
 

Macro Definition Documentation

◆ REPORT_GENERATOR

#define REPORT_GENERATOR (   n,
  cn 
)
Value:
static config report_##n(const reports::context& cn); \
static report_generator_helper reg_gen_##n(#n, &report_##n); \
static config report_##n(const reports::context& cn)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
static map_location::DIRECTION n

Definition at line 121 of file reports.cpp.

Typedef Documentation

◆ static_report_generators

typedef std::map<std::string, reports::generator_function> static_report_generators

Definition at line 110 of file reports.cpp.

Function Documentation

◆ add_image()

static void add_image ( config report,
const std::string &  image,
const std::string &  tooltip,
const std::string &  help = "" 
)
static

◆ add_status()

static void add_status ( config r,
const std::string &  path,
char const *  desc1,
char const *  desc2 
)
static

Definition at line 81 of file reports.cpp.

References add_image(), translation::gettext(), game_config::path, and s.

Referenced by unit_status().

◆ add_text()

static void add_text ( config report,
const std::string &  text,
const std::string &  tooltip,
const std::string &  help = "" 
)
static

◆ attack_info()

static int attack_info ( const reports::context rc,
const attack_type at,
config res,
const unit u,
const map_location hex,
const unit sec_u = nullptr,
const_attack_ptr  sec_u_weapon = nullptr 
)
static

◆ attack_info_percent_color()

static const color_t attack_info_percent_color ( int  resistance)
inlinestatic

Maps resistance <= -60 (resistance value <= -60%) to intense red.

Maps resistance >= 60 (resistance value >= 60%) to intense green. Intermediate values are affinely mapped to the red-to-green scale, with 0 (0%) being mapped to yellow. Compare unit_helper::resistance_color().

Definition at line 767 of file reports.cpp.

References game_config::red_to_green().

Referenced by attack_info().

◆ flush()

static std::string flush ( std::ostringstream &  s)
static

◆ format_hp()

static std::string format_hp ( unsigned  hp)
static

Definition at line 1024 of file reports.cpp.

Referenced by unit_weapons().

◆ format_prob()

static std::string format_prob ( double  prob)
static

Definition at line 1012 of file reports.cpp.

Referenced by unit_weapons().

◆ get_selected_unit()

static const unit* get_selected_unit ( const reports::context rc)
static

◆ get_selected_unit_ptr()

static unit_const_ptr get_selected_unit_ptr ( const reports::context rc)
static

◆ get_visible_time_of_day_at()

static const time_of_day get_visible_time_of_day_at ( const reports::context rc,
const map_location hex 
)
static

◆ get_visible_unit()

static const unit* get_visible_unit ( const reports::context rc)
static

◆ gray_inactive()

static config gray_inactive ( const reports::context rc,
const std::string &  str,
const std::string &  tooltip = "" 
)
static

◆ image_report()

static config image_report ( const std::string &  image,
const std::string &  tooltip = "",
const std::string &  help = "" 
)
static

Definition at line 71 of file reports.cpp.

References add_image(), and tooltip.

Referenced by REPORT_GENERATOR(), time_of_day_at(), and unit_box_at().

◆ REPORT_GENERATOR() [1/59]

REPORT_GENERATOR ( battery  )

◆ REPORT_GENERATOR() [2/59]

REPORT_GENERATOR ( expenses  ,
rc   
)

Definition at line 1495 of file reports.cpp.

References team_data::expenses, and gray_inactive().

◆ REPORT_GENERATOR() [3/59]

REPORT_GENERATOR ( gold  ,
rc   
)

◆ REPORT_GENERATOR() [4/59]

REPORT_GENERATOR ( highlighted_unit_weapons  ,
rc   
)

◆ REPORT_GENERATOR() [5/59]

REPORT_GENERATOR ( income  ,
rc   
)

◆ REPORT_GENERATOR() [6/59]

REPORT_GENERATOR ( num_units  ,
rc   
)

Definition at line 1480 of file reports.cpp.

References _(), and gray_inactive().

◆ REPORT_GENERATOR() [7/59]

REPORT_GENERATOR ( observers  ,
rc   
)

Definition at line 1722 of file reports.cpp.

References _(), image_report(), and game_config::images::observer.

◆ REPORT_GENERATOR() [8/59]

REPORT_GENERATOR ( position  ,
rc   
)

◆ REPORT_GENERATOR() [9/59]

REPORT_GENERATOR ( report_clock  )

◆ REPORT_GENERATOR() [10/59]

REPORT_GENERATOR ( report_countdown  ,
rc   
)

◆ REPORT_GENERATOR() [11/59]

REPORT_GENERATOR ( selected_time_of_day  ,
rc   
)

◆ REPORT_GENERATOR() [12/59]

REPORT_GENERATOR ( selected_tod_stats  ,
rc   
)

◆ REPORT_GENERATOR() [13/59]

REPORT_GENERATOR ( selected_unit_abilities  ,
rc   
)

◆ REPORT_GENERATOR() [14/59]

REPORT_GENERATOR ( selected_unit_advancement_options  ,
rc   
)

Definition at line 567 of file reports.cpp.

References get_selected_unit(), and unit_advancement_options().

◆ REPORT_GENERATOR() [15/59]

REPORT_GENERATOR ( selected_unit_alignment  ,
rc   
)

◆ REPORT_GENERATOR() [16/59]

REPORT_GENERATOR ( selected_unit_defense  ,
rc   
)

◆ REPORT_GENERATOR() [17/59]

REPORT_GENERATOR ( selected_unit_hp  ,
rc   
)

Definition at line 520 of file reports.cpp.

References get_selected_unit(), and unit_hp().

◆ REPORT_GENERATOR() [18/59]

REPORT_GENERATOR ( selected_unit_image  ,
rc   
)

◆ REPORT_GENERATOR() [19/59]

REPORT_GENERATOR ( selected_unit_level  ,
rc   
)

Definition at line 283 of file reports.cpp.

References get_selected_unit(), and unit_level().

◆ REPORT_GENERATOR() [20/59]

REPORT_GENERATOR ( selected_unit_moves  ,
rc   
)

Definition at line 754 of file reports.cpp.

References get_selected_unit(), and unit_moves().

◆ REPORT_GENERATOR() [21/59]

REPORT_GENERATOR ( selected_unit_name  ,
rc   
)

Definition at line 179 of file reports.cpp.

References get_selected_unit(), and unit_name().

◆ REPORT_GENERATOR() [22/59]

REPORT_GENERATOR ( selected_unit_profile  ,
rc   
)

Definition at line 1242 of file reports.cpp.

References get_selected_unit(), image_report(), and unit::small_profile().

◆ REPORT_GENERATOR() [23/59]

REPORT_GENERATOR ( selected_unit_race  ,
rc   
)

Definition at line 225 of file reports.cpp.

References get_selected_unit(), and unit_race().

◆ REPORT_GENERATOR() [24/59]

REPORT_GENERATOR ( selected_unit_side  ,
rc   
)

Definition at line 267 of file reports.cpp.

References get_selected_unit(), and unit_side().

◆ REPORT_GENERATOR() [25/59]

REPORT_GENERATOR ( selected_unit_status  ,
rc   
)

Definition at line 367 of file reports.cpp.

References get_selected_unit(), and unit_status().

◆ REPORT_GENERATOR() [26/59]

REPORT_GENERATOR ( selected_unit_traits  ,
rc   
)

Definition at line 325 of file reports.cpp.

References get_selected_unit(), and unit_traits().

◆ REPORT_GENERATOR() [27/59]

REPORT_GENERATOR ( selected_unit_type  ,
rc   
)

Definition at line 206 of file reports.cpp.

References get_selected_unit(), and unit_type().

◆ REPORT_GENERATOR() [28/59]

REPORT_GENERATOR ( selected_unit_vision  ,
rc   
)

Definition at line 661 of file reports.cpp.

References get_selected_unit(), and unit_vision().

◆ REPORT_GENERATOR() [29/59]

REPORT_GENERATOR ( selected_unit_weapons  ,
rc   
)

◆ REPORT_GENERATOR() [30/59]

REPORT_GENERATOR ( selected_unit_xp  ,
rc   
)

Definition at line 547 of file reports.cpp.

References get_selected_unit(), and unit_xp().

◆ REPORT_GENERATOR() [31/59]

REPORT_GENERATOR ( side_playing  ,
rc   
)

◆ REPORT_GENERATOR() [32/59]

REPORT_GENERATOR ( terrain  ,
rc   
)

◆ REPORT_GENERATOR() [33/59]

REPORT_GENERATOR ( terrain_info  ,
rc   
)

◆ REPORT_GENERATOR() [34/59]

REPORT_GENERATOR ( time_of_day  ,
rc   
)

Definition at line 1330 of file reports.cpp.

References time_of_day_at(), and map_location::valid().

◆ REPORT_GENERATOR() [35/59]

REPORT_GENERATOR ( tod_stats  ,
rc   
)

Definition at line 1278 of file reports.cpp.

References tod_stats_at(), and map_location::valid().

◆ REPORT_GENERATOR() [36/59]

REPORT_GENERATOR ( turn  ,
rc   
)

Definition at line 1424 of file reports.cpp.

References _(), text_report(), and tooltip.

◆ REPORT_GENERATOR() [37/59]

REPORT_GENERATOR ( unit_abilities  ,
rc   
)

◆ REPORT_GENERATOR() [38/59]

REPORT_GENERATOR ( unit_advancement_options  ,
rc   
)

Definition at line 562 of file reports.cpp.

References get_visible_unit(), and unit_advancement_options().

◆ REPORT_GENERATOR() [39/59]

REPORT_GENERATOR ( unit_alignment  ,
rc   
)

Definition at line 394 of file reports.cpp.

References get_visible_unit(), unit_alignment(), and map_location::valid().

◆ REPORT_GENERATOR() [40/59]

REPORT_GENERATOR ( unit_amla  ,
rc   
)

Definition at line 289 of file reports.cpp.

References add_image(), unit::amla_icons(), and get_visible_unit().

◆ REPORT_GENERATOR() [41/59]

REPORT_GENERATOR ( unit_box  ,
rc   
)

Definition at line 1417 of file reports.cpp.

References unit_box_at().

◆ REPORT_GENERATOR() [42/59]

REPORT_GENERATOR ( unit_defense  ,
rc   
)

◆ REPORT_GENERATOR() [43/59]

REPORT_GENERATOR ( unit_hp  ,
rc   
)

Definition at line 515 of file reports.cpp.

References get_visible_unit(), and unit_hp().

◆ REPORT_GENERATOR() [44/59]

REPORT_GENERATOR ( unit_image  ,
rc   
)

◆ REPORT_GENERATOR() [45/59]

REPORT_GENERATOR ( unit_level  ,
rc   
)

Definition at line 278 of file reports.cpp.

References get_visible_unit(), and unit_level().

◆ REPORT_GENERATOR() [46/59]

REPORT_GENERATOR ( unit_moves  ,
rc   
)

Definition at line 749 of file reports.cpp.

References get_visible_unit(), and unit_moves().

◆ REPORT_GENERATOR() [47/59]

REPORT_GENERATOR ( unit_name  ,
rc   
)

Definition at line 174 of file reports.cpp.

References get_visible_unit(), and unit_name().

◆ REPORT_GENERATOR() [48/59]

REPORT_GENERATOR ( unit_profile  ,
rc   
)

Definition at line 1248 of file reports.cpp.

References get_visible_unit(), image_report(), and unit::small_profile().

◆ REPORT_GENERATOR() [49/59]

REPORT_GENERATOR ( unit_race  ,
rc   
)

Definition at line 220 of file reports.cpp.

References get_visible_unit(), and unit_race().

◆ REPORT_GENERATOR() [50/59]

REPORT_GENERATOR ( unit_side  ,
rc   
)

Definition at line 262 of file reports.cpp.

References get_visible_unit(), and unit_side().

◆ REPORT_GENERATOR() [51/59]

REPORT_GENERATOR ( unit_status  ,
rc   
)

Definition at line 362 of file reports.cpp.

References get_visible_unit(), and unit_status().

◆ REPORT_GENERATOR() [52/59]

REPORT_GENERATOR ( unit_traits  ,
rc   
)

Definition at line 320 of file reports.cpp.

References get_visible_unit(), and unit_traits().

◆ REPORT_GENERATOR() [53/59]

REPORT_GENERATOR ( unit_type  ,
rc   
)

Definition at line 201 of file reports.cpp.

References get_visible_unit(), and unit_type().

◆ REPORT_GENERATOR() [54/59]

REPORT_GENERATOR ( unit_vision  ,
rc   
)

Definition at line 656 of file reports.cpp.

References get_visible_unit(), and unit_vision().

◆ REPORT_GENERATOR() [55/59]

REPORT_GENERATOR ( unit_weapons  ,
rc   
)

Definition at line 1181 of file reports.cpp.

References get_visible_unit(), unit_weapons(), and map_location::valid().

◆ REPORT_GENERATOR() [56/59]

REPORT_GENERATOR ( unit_xp  ,
rc   
)

Definition at line 542 of file reports.cpp.

References get_visible_unit(), and unit_xp().

◆ REPORT_GENERATOR() [57/59]

REPORT_GENERATOR ( upkeep  ,
rc   
)

Definition at line 1485 of file reports.cpp.

References _(), team_data::expenses, gray_inactive(), and team_data::upkeep.

◆ REPORT_GENERATOR() [58/59]

REPORT_GENERATOR ( villages  ,
rc   
)

Definition at line 1461 of file reports.cpp.

References _(), gray_inactive(), team::shrouded(), team::uses_shroud(), and team::villages().

◆ REPORT_GENERATOR() [59/59]

REPORT_GENERATOR ( zoom_level  ,
rc   
)

Definition at line 1657 of file reports.cpp.

References text_report(), and tooltip.

◆ side_tooltip()

static std::string side_tooltip ( const team team)
static

Definition at line 231 of file reports.cpp.

References team::get_side_color_name_for_UI(), team::side(), team::side_name(), and VGETTEXT.

Referenced by REPORT_GENERATOR(), and unit_side().

◆ text_report()

static config text_report ( const std::string &  text,
const std::string &  tooltip = "",
const std::string &  help = "" 
)
static

◆ time_of_day_at()

static config time_of_day_at ( const reports::context rc,
const map_location mouseover_hex 
)
static

◆ tod_stats_at()

static config tod_stats_at ( const reports::context rc,
const map_location hex 
)
static

◆ unit_abilities()

static config unit_abilities ( const unit u,
const map_location loc 
)
static

◆ unit_advancement_options()

static config unit_advancement_options ( const unit u)
static

Definition at line 553 of file reports.cpp.

References add_image(), and unit::advancement_icons().

Referenced by REPORT_GENERATOR().

◆ unit_alignment()

static config unit_alignment ( const reports::context rc,
const unit u,
const map_location hex 
)
static

◆ unit_box_at()

static config unit_box_at ( const reports::context rc,
const map_location mouseover_hex 
)
static

◆ unit_defense()

static config unit_defense ( const reports::context rc,
const unit u,
const map_location displayed_unit_hex 
)
static

◆ unit_hp()

static config unit_hp ( const reports::context rc,
const unit u 
)
static

◆ unit_level()

static config unit_level ( const unit u)
static

Definition at line 273 of file reports.cpp.

References unit::level(), text_report(), and unit_helper::unit_level_tooltip().

Referenced by REPORT_GENERATOR().

◆ unit_moves()

static config unit_moves ( const reports::context rc,
const unit u,
bool  is_visible_unit 
)
static

◆ unit_name()

static config unit_name ( const unit u)
static

◆ unit_race()

static config unit_race ( const unit u)
static

Definition at line 212 of file reports.cpp.

References _(), unit::gender(), unit_race::id(), unit_race::name(), unit::race(), text_report(), and tooltip.

Referenced by REPORT_GENERATOR().

◆ unit_side()

static config unit_side ( const reports::context rc,
const unit u 
)
static

◆ unit_status()

static config unit_status ( const reports::context rc,
const unit u 
)
static

◆ unit_traits()

static config unit_traits ( const unit u)
static

◆ unit_type()

static config unit_type ( const unit u)
static

◆ unit_vision()

static config unit_vision ( const unit u)
static

Definition at line 639 of file reports.cpp.

References _(), unit::jamming(), text_report(), tooltip, unit::total_movement(), and unit::vision().

Referenced by REPORT_GENERATOR().

◆ unit_weapons() [1/2]

static config unit_weapons ( const reports::context rc,
const unit u,
const map_location hex 
)
static

◆ unit_weapons() [2/2]

static config unit_weapons ( const reports::context rc,
unit_const_ptr  attacker,
const map_location attacker_pos,
const unit defender,
bool  show_attacker 
)
static

◆ unit_xp()

static config unit_xp ( const unit u)
static

Variable Documentation

◆ naps

char const* naps = "</span>"
static

◆ static_generators

static_report_generators static_generators
static