The Battle for Wesnoth  1.19.7+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 <boost/format.hpp>
#include <ctime>
#include <iomanip>
#include <utility>
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, const 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 127 of file reports.cpp.

Typedef Documentation

◆ static_report_generators

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

Definition at line 116 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 87 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 766 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 1047 of file reports.cpp.

Referenced by unit_weapons().

◆ format_prob()

static std::string format_prob ( double  prob)
static

Definition at line 1035 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 77 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 1514 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 1500 of file reports.cpp.

References _(), and gray_inactive().

◆ REPORT_GENERATOR() [7/59]

REPORT_GENERATOR ( observers  ,
rc   
)

Definition at line 1735 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 564 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 519 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 287 of file reports.cpp.

References get_selected_unit(), and unit_level().

◆ REPORT_GENERATOR() [20/59]

REPORT_GENERATOR ( selected_unit_moves  ,
rc   
)

Definition at line 753 of file reports.cpp.

References get_selected_unit(), and unit_moves().

◆ REPORT_GENERATOR() [21/59]

REPORT_GENERATOR ( selected_unit_name  ,
rc   
)

Definition at line 183 of file reports.cpp.

References get_selected_unit(), and unit_name().

◆ REPORT_GENERATOR() [22/59]

REPORT_GENERATOR ( selected_unit_profile  ,
rc   
)

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

References get_selected_unit(), and unit_race().

◆ REPORT_GENERATOR() [24/59]

REPORT_GENERATOR ( selected_unit_side  ,
rc   
)

Definition at line 271 of file reports.cpp.

References get_selected_unit(), and unit_side().

◆ REPORT_GENERATOR() [25/59]

REPORT_GENERATOR ( selected_unit_status  ,
rc   
)

Definition at line 371 of file reports.cpp.

References get_selected_unit(), and unit_status().

◆ REPORT_GENERATOR() [26/59]

REPORT_GENERATOR ( selected_unit_traits  ,
rc   
)

Definition at line 329 of file reports.cpp.

References get_selected_unit(), and unit_traits().

◆ REPORT_GENERATOR() [27/59]

REPORT_GENERATOR ( selected_unit_type  ,
rc   
)

Definition at line 210 of file reports.cpp.

References get_selected_unit(), and unit_type().

◆ REPORT_GENERATOR() [28/59]

REPORT_GENERATOR ( selected_unit_vision  ,
rc   
)

Definition at line 658 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 544 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 1349 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 1297 of file reports.cpp.

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

◆ REPORT_GENERATOR() [36/59]

REPORT_GENERATOR ( turn  ,
rc   
)

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

References get_visible_unit(), and unit_advancement_options().

◆ REPORT_GENERATOR() [39/59]

REPORT_GENERATOR ( unit_alignment  ,
rc   
)

Definition at line 397 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 293 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 1440 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 514 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 282 of file reports.cpp.

References get_visible_unit(), and unit_level().

◆ REPORT_GENERATOR() [46/59]

REPORT_GENERATOR ( unit_moves  ,
rc   
)

Definition at line 748 of file reports.cpp.

References get_visible_unit(), and unit_moves().

◆ REPORT_GENERATOR() [47/59]

REPORT_GENERATOR ( unit_name  ,
rc   
)

Definition at line 178 of file reports.cpp.

References get_visible_unit(), and unit_name().

◆ REPORT_GENERATOR() [48/59]

REPORT_GENERATOR ( unit_profile  ,
rc   
)

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

References get_visible_unit(), and unit_race().

◆ REPORT_GENERATOR() [50/59]

REPORT_GENERATOR ( unit_side  ,
rc   
)

Definition at line 266 of file reports.cpp.

References get_visible_unit(), and unit_side().

◆ REPORT_GENERATOR() [51/59]

REPORT_GENERATOR ( unit_status  ,
rc   
)

Definition at line 366 of file reports.cpp.

References get_visible_unit(), and unit_status().

◆ REPORT_GENERATOR() [52/59]

REPORT_GENERATOR ( unit_traits  ,
rc   
)

Definition at line 324 of file reports.cpp.

References get_visible_unit(), and unit_traits().

◆ REPORT_GENERATOR() [53/59]

REPORT_GENERATOR ( unit_type  ,
rc   
)

Definition at line 205 of file reports.cpp.

References get_visible_unit(), and unit_type().

◆ REPORT_GENERATOR() [54/59]

REPORT_GENERATOR ( unit_vision  ,
rc   
)

Definition at line 653 of file reports.cpp.

References get_visible_unit(), and unit_vision().

◆ REPORT_GENERATOR() [55/59]

REPORT_GENERATOR ( unit_weapons  ,
rc   
)

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

References get_visible_unit(), and unit_xp().

◆ REPORT_GENERATOR() [57/59]

REPORT_GENERATOR ( upkeep  ,
rc   
)

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

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

◆ REPORT_GENERATOR() [59/59]

REPORT_GENERATOR ( zoom_level  ,
rc   
)

Definition at line 1667 of file reports.cpp.

References text_report(), and tooltip.

◆ side_tooltip()

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

Definition at line 235 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 550 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 277 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 636 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,
const 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