The Battle for Wesnoth  1.19.5+dev
Classes | Macros | Typedefs | Functions | Variables
reports.cpp File Reference
#include "reports.hpp"
#include "actions/attack.hpp"
#include "attack_prediction.hpp"
#include "color.hpp"
#include "desktop/battery_info.hpp"
#include "font/pango/escape.hpp"
#include "formatter.hpp"
#include "formula/string_utils.hpp"
#include "gettext.hpp"
#include "language.hpp"
#include "map/map.hpp"
#include "mouse_events.hpp"
#include "pathfind/pathfind.hpp"
#include "picture.hpp"
#include "preferences/preferences.hpp"
#include "serialization/markup.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
 

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:172
static map_location::direction n

Definition at line 126 of file reports.cpp.

Typedef Documentation

◆ static_report_generators

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

Definition at line 115 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 86 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 765 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 1046 of file reports.cpp.

Referenced by unit_weapons().

◆ format_prob()

static std::string format_prob ( double  prob)
static

Definition at line 1034 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 76 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 1513 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 1499 of file reports.cpp.

References _(), and gray_inactive().

◆ REPORT_GENERATOR() [7/59]

REPORT_GENERATOR ( observers  ,
rc   
)

Definition at line 1734 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 563 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 518 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 286 of file reports.cpp.

References get_selected_unit(), and unit_level().

◆ REPORT_GENERATOR() [20/59]

REPORT_GENERATOR ( selected_unit_moves  ,
rc   
)

Definition at line 752 of file reports.cpp.

References get_selected_unit(), and unit_moves().

◆ REPORT_GENERATOR() [21/59]

REPORT_GENERATOR ( selected_unit_name  ,
rc   
)

Definition at line 182 of file reports.cpp.

References get_selected_unit(), and unit_name().

◆ REPORT_GENERATOR() [22/59]

REPORT_GENERATOR ( selected_unit_profile  ,
rc   
)

Definition at line 1258 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 228 of file reports.cpp.

References get_selected_unit(), and unit_race().

◆ REPORT_GENERATOR() [24/59]

REPORT_GENERATOR ( selected_unit_side  ,
rc   
)

Definition at line 270 of file reports.cpp.

References get_selected_unit(), and unit_side().

◆ REPORT_GENERATOR() [25/59]

REPORT_GENERATOR ( selected_unit_status  ,
rc   
)

Definition at line 370 of file reports.cpp.

References get_selected_unit(), and unit_status().

◆ REPORT_GENERATOR() [26/59]

REPORT_GENERATOR ( selected_unit_traits  ,
rc   
)

Definition at line 328 of file reports.cpp.

References get_selected_unit(), and unit_traits().

◆ REPORT_GENERATOR() [27/59]

REPORT_GENERATOR ( selected_unit_type  ,
rc   
)

Definition at line 209 of file reports.cpp.

References get_selected_unit(), and unit_type().

◆ REPORT_GENERATOR() [28/59]

REPORT_GENERATOR ( selected_unit_vision  ,
rc   
)

Definition at line 657 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 543 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 1348 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 1296 of file reports.cpp.

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

◆ REPORT_GENERATOR() [36/59]

REPORT_GENERATOR ( turn  ,
rc   
)

Definition at line 1446 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 558 of file reports.cpp.

References get_visible_unit(), and unit_advancement_options().

◆ REPORT_GENERATOR() [39/59]

REPORT_GENERATOR ( unit_alignment  ,
rc   
)

Definition at line 396 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 292 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 1439 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 513 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 281 of file reports.cpp.

References get_visible_unit(), and unit_level().

◆ REPORT_GENERATOR() [46/59]

REPORT_GENERATOR ( unit_moves  ,
rc   
)

Definition at line 747 of file reports.cpp.

References get_visible_unit(), and unit_moves().

◆ REPORT_GENERATOR() [47/59]

REPORT_GENERATOR ( unit_name  ,
rc   
)

Definition at line 177 of file reports.cpp.

References get_visible_unit(), and unit_name().

◆ REPORT_GENERATOR() [48/59]

REPORT_GENERATOR ( unit_profile  ,
rc   
)

Definition at line 1264 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 223 of file reports.cpp.

References get_visible_unit(), and unit_race().

◆ REPORT_GENERATOR() [50/59]

REPORT_GENERATOR ( unit_side  ,
rc   
)

Definition at line 265 of file reports.cpp.

References get_visible_unit(), and unit_side().

◆ REPORT_GENERATOR() [51/59]

REPORT_GENERATOR ( unit_status  ,
rc   
)

Definition at line 365 of file reports.cpp.

References get_visible_unit(), and unit_status().

◆ REPORT_GENERATOR() [52/59]

REPORT_GENERATOR ( unit_traits  ,
rc   
)

Definition at line 323 of file reports.cpp.

References get_visible_unit(), and unit_traits().

◆ REPORT_GENERATOR() [53/59]

REPORT_GENERATOR ( unit_type  ,
rc   
)

Definition at line 204 of file reports.cpp.

References get_visible_unit(), and unit_type().

◆ REPORT_GENERATOR() [54/59]

REPORT_GENERATOR ( unit_vision  ,
rc   
)

Definition at line 652 of file reports.cpp.

References get_visible_unit(), and unit_vision().

◆ REPORT_GENERATOR() [55/59]

REPORT_GENERATOR ( unit_weapons  ,
rc   
)

Definition at line 1197 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 538 of file reports.cpp.

References get_visible_unit(), and unit_xp().

◆ REPORT_GENERATOR() [57/59]

REPORT_GENERATOR ( upkeep  ,
rc   
)

Definition at line 1504 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 1481 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 1666 of file reports.cpp.

References text_report(), and tooltip.

◆ side_tooltip()

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

Definition at line 234 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 549 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 276 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

◆ 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 635 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

◆ static_generators

static_report_generators static_generators
static