The Battle for Wesnoth  1.15.6+dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
game_events::wml_event_pump Class Reference

#include <pump.hpp>

Public Member Functions

 wml_event_pump (manager &)
 
 ~wml_event_pump ()
 
bool undo_disabled ()
 Context: The general environment within which events are processed. More...
 
void set_undo_disabled (bool mutated)
 [allow_undo] implementation More...
 
bool action_canceled ()
 Returns whether or not wml wants to abort the currently executed user action. More...
 
void set_action_canceled ()
 Sets whether or not wml wants to abort the currently executed user action. More...
 
bool context_skip_messages ()
 Returns whether or not we are skipping messages. More...
 
void context_skip_messages (bool skip)
 Sets whether or not we are skipping messages. More...
 
void put_wml_message (const std::string &logger, const std::string &message, bool in_chat)
 Helper function which determines whether a wml_message text can really be pushed into the wml_messages_stream, and does it. More...
 
pump_result_t fire (const std::string &event, const entity_location &loc1=entity_location::null_entity, const entity_location &loc2=entity_location::null_entity, const config &data=config())
 Function to fire an event. More...
 
pump_result_t fire (const std::string &event, const std::string &id, const entity_location &loc1=entity_location::null_entity, const entity_location &loc2=entity_location::null_entity, const config &data=config())
 
void raise (const std::string &event, const std::string &id, const entity_location &loc1=entity_location::null_entity, const entity_location &loc2=entity_location::null_entity, const config &data=config())
 
void raise (const std::string &event, const entity_location &loc1=entity_location::null_entity, const entity_location &loc2=entity_location::null_entity, const config &data=config())
 
pump_result_t operator() ()
 
void flush_messages ()
 Flushes WML messages and errors. More...
 

Private Member Functions

bool filter_event (const event_handler &handler, const queued_event &ev)
 Returns true iff the given event passes all its filters. More...
 
void process_event (handler_ptr &handler_p, const queued_event &ev)
 Processes an event through a single event handler. More...
 
void fill_wml_messages_map (std::map< std::string, int > &msg_map, std::stringstream &source)
 Helper function for show_wml_messages(), which gathers the messages from a stringstream. More...
 
void show_wml_messages (std::stringstream &source, const std::string &caption, bool to_cerr)
 Shows a summary of messages/errors generated so far by WML. More...
 
void show_wml_errors ()
 Shows a summary of the errors encountered in WML so far, to avoid a lot of the same messages to be shown. More...
 
void show_wml_messages ()
 Shows a summary of the messages generated so far by WML. More...
 
void put_wml_message (lg::logger &logger, const std::string &prefix, const std::string &message, bool in_chat)
 

Private Attributes

const std::unique_ptr< pump_implimpl_
 

Detailed Description

Definition at line 72 of file pump.hpp.

Constructor & Destructor Documentation

◆ wml_event_pump()

game_events::wml_event_pump::wml_event_pump ( manager man)

Definition at line 616 of file pump.cpp.

◆ ~wml_event_pump()

game_events::wml_event_pump::~wml_event_pump ( )

Definition at line 621 of file pump.cpp.

Member Function Documentation

◆ action_canceled()

bool game_events::wml_event_pump::action_canceled ( )

Returns whether or not wml wants to abort the currently executed user action.

Definition at line 444 of file pump.cpp.

References impl_.

◆ context_skip_messages() [1/2]

bool game_events::wml_event_pump::context_skip_messages ( )

Returns whether or not we are skipping messages.

Definition at line 457 of file pump.cpp.

References impl_.

◆ context_skip_messages() [2/2]

void game_events::wml_event_pump::context_skip_messages ( bool  skip)

Sets whether or not we are skipping messages.

Definition at line 463 of file pump.cpp.

References b, and impl_.

◆ fill_wml_messages_map()

void game_events::wml_event_pump::fill_wml_messages_map ( std::map< std::string, int > &  msg_map,
std::stringstream &  source 
)
private

Helper function for show_wml_messages(), which gathers the messages from a stringstream.

Definition at line 315 of file pump.cpp.

References wfl::msg(), and mariadb::value::string.

◆ filter_event()

bool game_events::wml_event_pump::filter_event ( const event_handler handler,
const queued_event ev 
)
private

◆ fire() [1/2]

pump_result_t game_events::wml_event_pump::fire ( const std::string &  event,
const entity_location loc1 = entity_location::null_entity,
const entity_location loc2 = entity_location::null_entity,
const config data = config() 
)

◆ fire() [2/2]

pump_result_t game_events::wml_event_pump::fire ( const std::string &  event,
const std::string &  id,
const entity_location loc1 = entity_location::null_entity,
const entity_location loc2 = entity_location::null_entity,
const config data = config() 
)

Definition at line 493 of file pump.cpp.

References mariadb::value::data.

◆ flush_messages()

void game_events::wml_event_pump::flush_messages ( )

Flushes WML messages and errors.

Definition at line 607 of file pump.cpp.

References game_display::get_singleton(), and CVideo::get_singleton().

Referenced by SYNCED_COMMAND_HANDLER_FUNCTION().

◆ operator()()

pump_result_t game_events::wml_event_pump::operator() ( )

◆ process_event()

void game_events::wml_event_pump::process_event ( handler_ptr handler_p,
const queued_event ev 
)
private

Processes an event through a single event handler.

This includes checking event filters, but not checking that the event name matches.

Parameters
[in,out]handler_pThe handler to offer the event to. This may be reset during processing.
[in]evThe event information.

Definition at line 276 of file pump.cpp.

References config::child(), game_events::queued_event::data, DBG_EH, resources::gameboard, resources::gamedata, game_display::get_singleton(), game_events::queued_event::id, impl_, game_data::last_selected, game_events::queued_event::loc1, game_events::queued_event::loc2, resources::lua_kernel, game_display::maybe_rebuild(), game_events::queued_event::name, and game_board::units().

◆ put_wml_message() [1/2]

void game_events::wml_event_pump::put_wml_message ( const std::string &  logger,
const std::string &  message,
bool  in_chat 
)

Helper function which determines whether a wml_message text can really be pushed into the wml_messages_stream, and does it.

Definition at line 473 of file pump.cpp.

References _(), lg::debug(), lg::err(), lg::info(), log_wml, and lg::warn().

Referenced by storyscreen::story_parser::resolve_wml().

◆ put_wml_message() [2/2]

void game_events::wml_event_pump::put_wml_message ( lg::logger logger,
const std::string &  prefix,
const std::string &  message,
bool  in_chat 
)
private

Definition at line 402 of file pump.cpp.

References FORCE_LOG_TO, impl_, and log_wml.

◆ raise() [1/2]

void game_events::wml_event_pump::raise ( const std::string &  event,
const std::string &  id,
const entity_location loc1 = entity_location::null_entity,
const entity_location loc2 = entity_location::null_entity,
const config data = config() 
)

◆ raise() [2/2]

void game_events::wml_event_pump::raise ( const std::string &  event,
const entity_location loc1 = entity_location::null_entity,
const entity_location loc2 = entity_location::null_entity,
const config data = config() 
)
inline

Definition at line 131 of file pump.hpp.

References mariadb::value::data, and mariadb::value::string.

◆ set_action_canceled()

void game_events::wml_event_pump::set_action_canceled ( )

Sets whether or not wml wants to abort the currently executed user action.

Definition at line 450 of file pump.cpp.

References impl_.

◆ set_undo_disabled()

void game_events::wml_event_pump::set_undo_disabled ( bool  mutated)

[allow_undo] implementation

Definition at line 438 of file pump.cpp.

References b, and impl_.

◆ show_wml_errors()

void game_events::wml_event_pump::show_wml_errors ( )
private

Shows a summary of the errors encountered in WML so far, to avoid a lot of the same messages to be shown.

Identical messages are shown once, with (between parentheses) the number of times that message was encountered. The order in which the messages are shown does not need to be the order in which these messages are encountered. Messages are always written to std::cerr.

Definition at line 381 of file pump.cpp.

References mariadb::value::string, and lg::wml_error().

◆ show_wml_messages() [1/2]

void game_events::wml_event_pump::show_wml_messages ( std::stringstream &  source,
const std::string &  caption,
bool  to_cerr 
)
private

Shows a summary of messages/errors generated so far by WML.

Identical messages are shown once, with (between parentheses) the number of times that message was encountered. The order in which the messages are shown does not need to be the order in which these messages are encountered. Messages are also written to std::cerr if to_cerr is true.

Definition at line 348 of file pump.cpp.

References display_chat_manager::add_chat_message(), game_display::get_chat_manager(), game_display::get_singleton(), events::chat_handler::MESSAGE_PUBLIC, wfl::msg(), and mariadb::value::time.

◆ show_wml_messages() [2/2]

void game_events::wml_event_pump::show_wml_messages ( )
private

Shows a summary of the messages generated so far by WML.

Identical messages are shown once, with (between parentheses) the number of times that message was encountered. The order in which the messages are shown does not need to be the order in which these messages are encountered.

Definition at line 395 of file pump.cpp.

References impl_, and mariadb::value::string.

◆ undo_disabled()

bool game_events::wml_event_pump::undo_disabled ( )

Context: The general environment within which events are processed.

Returns whether or not audoing is impossible due to wml.

Definition at line 432 of file pump.cpp.

References impl_.

Member Data Documentation

◆ impl_

const std::unique_ptr<pump_impl> game_events::wml_event_pump::impl_
private

Definition at line 74 of file pump.hpp.


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