The Battle for Wesnoth  1.15.1+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 "resources.hpp"
#include "color.hpp"
#include "team.hpp"
#include "terrain/movement.hpp"
#include "tod_manager.hpp"
#include "units/unit.hpp"
#include "units/helper.hpp"
#include "whiteboard/manager.hpp"
#include <cassert>
#include <ctime>
#include <iomanip>
#include <boost/dynamic_bitset.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.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, char const *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 (reports::context &rc, const map_location &hex)
 
static const unitget_visible_unit (reports::context &rc)
 
static const unitget_selected_unit (reports::context &rc)
 
static config gray_inactive (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 (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 (reports::context &rc, const unit *u)
 
 REPORT_GENERATOR (unit_status, rc)
 
 REPORT_GENERATOR (selected_unit_status, rc)
 
static config unit_alignment (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 (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 (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 (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)
 
static int attack_info (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 (reports::context &rc, const unit *attacker, const map_location &attacker_pos, const unit *defender, bool show_attacker)
 
static config unit_weapons (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 (reports::context &rc, const map_location &hex)
 
 REPORT_GENERATOR (tod_stats, rc)
 
 REPORT_GENERATOR (selected_tod_stats, rc)
 
static config time_of_day_at (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 (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(reports::context & cn); \
static report_generator_helper reg_gen_##n(#n, &report_##n); \
static config report_##n(reports::context & cn)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
static map_location::DIRECTION n

Definition at line 122 of file reports.cpp.

Typedef Documentation

◆ static_report_generators

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

Definition at line 111 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,
char const *  path,
char const *  desc1,
char const *  desc2 
)
static

Definition at line 82 of file reports.cpp.

References add_image(), translation::gettext(), 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 ( 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

Definition at line 747 of file reports.cpp.

References font::BAD_COLOR, font::GOOD_COLOR, and font::YELLOW_COLOR.

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 997 of file reports.cpp.

Referenced by unit_weapons().

◆ format_prob()

static std::string format_prob ( double  prob)
static

Definition at line 985 of file reports.cpp.

Referenced by unit_weapons().

◆ get_selected_unit()

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

◆ get_visible_time_of_day_at()

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

◆ get_visible_unit()

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

◆ gray_inactive()

static config gray_inactive ( 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 72 of file reports.cpp.

References add_image(), and font::span_color().

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

◆ REPORT_GENERATOR() [1/59]

REPORT_GENERATOR ( unit_name  ,
rc   
)

Definition at line 168 of file reports.cpp.

References get_visible_unit(), and unit_name().

◆ REPORT_GENERATOR() [2/59]

REPORT_GENERATOR ( selected_unit_name  ,
rc   
)

Definition at line 173 of file reports.cpp.

References get_selected_unit(), and unit_name().

◆ REPORT_GENERATOR() [3/59]

REPORT_GENERATOR ( unit_type  ,
rc   
)

Definition at line 189 of file reports.cpp.

References get_visible_unit(), and unit_type().

◆ REPORT_GENERATOR() [4/59]

REPORT_GENERATOR ( selected_unit_type  ,
rc   
)

Definition at line 194 of file reports.cpp.

References get_selected_unit(), and unit_type().

◆ REPORT_GENERATOR() [5/59]

REPORT_GENERATOR ( unit_race  ,
rc   
)

Definition at line 208 of file reports.cpp.

References get_visible_unit(), and unit_race().

◆ REPORT_GENERATOR() [6/59]

REPORT_GENERATOR ( selected_unit_race  ,
rc   
)

Definition at line 213 of file reports.cpp.

References get_selected_unit(), and unit_race().

◆ REPORT_GENERATOR() [7/59]

REPORT_GENERATOR ( unit_side  ,
rc   
)

Definition at line 250 of file reports.cpp.

References get_visible_unit(), and unit_side().

◆ REPORT_GENERATOR() [8/59]

REPORT_GENERATOR ( selected_unit_side  ,
rc   
)

Definition at line 255 of file reports.cpp.

References get_selected_unit(), and unit_side().

◆ REPORT_GENERATOR() [9/59]

REPORT_GENERATOR ( unit_level  ,
rc   
)

Definition at line 288 of file reports.cpp.

References get_visible_unit(), and unit_level().

◆ REPORT_GENERATOR() [10/59]

REPORT_GENERATOR ( selected_unit_level  ,
rc   
)

Definition at line 293 of file reports.cpp.

References get_selected_unit(), and unit_level().

◆ REPORT_GENERATOR() [11/59]

REPORT_GENERATOR ( unit_amla  ,
rc   
)

Definition at line 299 of file reports.cpp.

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

◆ REPORT_GENERATOR() [12/59]

REPORT_GENERATOR ( unit_traits  ,
rc   
)

Definition at line 330 of file reports.cpp.

References get_visible_unit(), and unit_traits().

◆ REPORT_GENERATOR() [13/59]

REPORT_GENERATOR ( selected_unit_traits  ,
rc   
)

Definition at line 335 of file reports.cpp.

References get_selected_unit(), and unit_traits().

◆ REPORT_GENERATOR() [14/59]

REPORT_GENERATOR ( unit_status  ,
rc   
)

Definition at line 364 of file reports.cpp.

References get_visible_unit(), and unit_status().

◆ REPORT_GENERATOR() [15/59]

REPORT_GENERATOR ( selected_unit_status  ,
rc   
)

Definition at line 369 of file reports.cpp.

References get_selected_unit(), and unit_status().

◆ REPORT_GENERATOR() [16/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() [17/59]

REPORT_GENERATOR ( selected_unit_alignment  ,
rc   
)

◆ REPORT_GENERATOR() [18/59]

REPORT_GENERATOR ( unit_abilities  ,
rc   
)

Definition at line 447 of file reports.cpp.

References get_visible_unit(), and unit_abilities().

◆ REPORT_GENERATOR() [19/59]

REPORT_GENERATOR ( selected_unit_abilities  ,
rc   
)

◆ REPORT_GENERATOR() [20/59]

REPORT_GENERATOR ( unit_hp  ,
rc   
)

Definition at line 509 of file reports.cpp.

References get_visible_unit(), and unit_hp().

◆ REPORT_GENERATOR() [21/59]

REPORT_GENERATOR ( selected_unit_hp  ,
rc   
)

Definition at line 514 of file reports.cpp.

References get_selected_unit(), and unit_hp().

◆ REPORT_GENERATOR() [22/59]

REPORT_GENERATOR ( unit_xp  ,
rc   
)

Definition at line 536 of file reports.cpp.

References get_visible_unit(), and unit_xp().

◆ REPORT_GENERATOR() [23/59]

REPORT_GENERATOR ( selected_unit_xp  ,
rc   
)

Definition at line 541 of file reports.cpp.

References get_selected_unit(), and unit_xp().

◆ REPORT_GENERATOR() [24/59]

REPORT_GENERATOR ( unit_advancement_options  ,
rc   
)

Definition at line 557 of file reports.cpp.

References get_visible_unit(), and unit_advancement_options().

◆ REPORT_GENERATOR() [25/59]

REPORT_GENERATOR ( selected_unit_advancement_options  ,
rc   
)

Definition at line 562 of file reports.cpp.

References get_selected_unit(), and unit_advancement_options().

◆ REPORT_GENERATOR() [26/59]

REPORT_GENERATOR ( unit_defense  ,
rc   
)

◆ REPORT_GENERATOR() [27/59]

REPORT_GENERATOR ( selected_unit_defense  ,
rc   
)

◆ REPORT_GENERATOR() [28/59]

REPORT_GENERATOR ( unit_vision  ,
rc   
)

Definition at line 650 of file reports.cpp.

References get_visible_unit(), and unit_vision().

◆ REPORT_GENERATOR() [29/59]

REPORT_GENERATOR ( selected_unit_vision  ,
rc   
)

Definition at line 655 of file reports.cpp.

References get_selected_unit(), and unit_vision().

◆ REPORT_GENERATOR() [30/59]

REPORT_GENERATOR ( unit_moves  ,
rc   
)

Definition at line 736 of file reports.cpp.

References get_visible_unit(), and unit_moves().

◆ REPORT_GENERATOR() [31/59]

REPORT_GENERATOR ( selected_unit_moves  ,
rc   
)

Definition at line 741 of file reports.cpp.

References get_selected_unit(), and unit_moves().

◆ REPORT_GENERATOR() [32/59]

REPORT_GENERATOR ( unit_weapons  ,
rc   
)

Definition at line 1154 of file reports.cpp.

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

◆ REPORT_GENERATOR() [33/59]

REPORT_GENERATOR ( highlighted_unit_weapons  ,
rc   
)

◆ REPORT_GENERATOR() [34/59]

REPORT_GENERATOR ( selected_unit_weapons  ,
rc   
)

◆ REPORT_GENERATOR() [35/59]

REPORT_GENERATOR ( unit_image  ,
rc   
)

◆ REPORT_GENERATOR() [36/59]

REPORT_GENERATOR ( selected_unit_image  ,
rc   
)

◆ REPORT_GENERATOR() [37/59]

REPORT_GENERATOR ( selected_unit_profile  ,
rc   
)

Definition at line 1214 of file reports.cpp.

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

◆ REPORT_GENERATOR() [38/59]

REPORT_GENERATOR ( unit_profile  ,
rc   
)

Definition at line 1220 of file reports.cpp.

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

◆ REPORT_GENERATOR() [39/59]

REPORT_GENERATOR ( tod_stats  ,
rc   
)

Definition at line 1250 of file reports.cpp.

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

◆ REPORT_GENERATOR() [40/59]

REPORT_GENERATOR ( selected_tod_stats  ,
rc   
)

◆ REPORT_GENERATOR() [41/59]

REPORT_GENERATOR ( time_of_day  ,
rc   
)

Definition at line 1302 of file reports.cpp.

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

◆ REPORT_GENERATOR() [42/59]

REPORT_GENERATOR ( selected_time_of_day  ,
rc   
)

◆ REPORT_GENERATOR() [43/59]

REPORT_GENERATOR ( unit_box  ,
rc   
)

Definition at line 1389 of file reports.cpp.

References unit_box_at().

◆ REPORT_GENERATOR() [44/59]

REPORT_GENERATOR ( turn  ,
rc   
)

Definition at line 1396 of file reports.cpp.

References _(), and text_report().

◆ REPORT_GENERATOR() [45/59]

REPORT_GENERATOR ( gold  ,
rc   
)

◆ REPORT_GENERATOR() [46/59]

REPORT_GENERATOR ( villages  ,
rc   
)

Definition at line 1433 of file reports.cpp.

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

◆ REPORT_GENERATOR() [47/59]

REPORT_GENERATOR ( num_units  ,
rc   
)

Definition at line 1452 of file reports.cpp.

References _(), and gray_inactive().

◆ REPORT_GENERATOR() [48/59]

REPORT_GENERATOR ( upkeep  ,
rc   
)

Definition at line 1457 of file reports.cpp.

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

◆ REPORT_GENERATOR() [49/59]

REPORT_GENERATOR ( expenses  ,
rc   
)

Definition at line 1467 of file reports.cpp.

References gray_inactive().

◆ REPORT_GENERATOR() [50/59]

REPORT_GENERATOR ( income  ,
rc   
)

◆ REPORT_GENERATOR() [51/59]

REPORT_GENERATOR ( terrain_info  ,
rc   
)

◆ REPORT_GENERATOR() [52/59]

REPORT_GENERATOR ( terrain  ,
rc   
)

◆ REPORT_GENERATOR() [53/59]

REPORT_GENERATOR ( zoom_level  ,
rc   
)

Definition at line 1597 of file reports.cpp.

References text_report().

◆ REPORT_GENERATOR() [54/59]

REPORT_GENERATOR ( position  ,
rc   
)

◆ REPORT_GENERATOR() [55/59]

REPORT_GENERATOR ( side_playing  ,
rc   
)

◆ REPORT_GENERATOR() [56/59]

REPORT_GENERATOR ( observers  ,
rc   
)

Definition at line 1662 of file reports.cpp.

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

◆ REPORT_GENERATOR() [57/59]

REPORT_GENERATOR ( report_clock  )

◆ REPORT_GENERATOR() [58/59]

REPORT_GENERATOR ( battery  )

◆ REPORT_GENERATOR() [59/59]

REPORT_GENERATOR ( report_countdown  ,
rc   
)

◆ side_tooltip()

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

Definition at line 219 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 ( reports::context rc,
const map_location mouseover_hex 
)
static

◆ tod_stats_at()

static config tod_stats_at ( 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 547 of file reports.cpp.

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

Referenced by REPORT_GENERATOR().

◆ unit_alignment()

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

◆ unit_box_at()

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

◆ unit_defense()

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

◆ unit_hp()

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

◆ unit_level()

static config unit_level ( const unit u)
static

◆ unit_moves()

static config unit_moves ( 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 200 of file reports.cpp.

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

Referenced by REPORT_GENERATOR().

◆ unit_side()

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

◆ unit_status()

static config unit_status ( 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 633 of file reports.cpp.

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

Referenced by REPORT_GENERATOR().

◆ unit_weapons() [1/2]

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

◆ unit_weapons() [2/2]

static config unit_weapons ( reports::context rc,
const unit u,
const map_location hex 
)
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