The Battle for Wesnoth  1.19.0-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

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)
 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 73 of file pump.hpp.

Constructor & Destructor Documentation

◆ wml_event_pump()

game_events::wml_event_pump::wml_event_pump ( manager man)

Definition at line 530 of file pump.cpp.

◆ ~wml_event_pump()

game_events::wml_event_pump::~wml_event_pump ( )

Definition at line 535 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 357 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 370 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 376 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 234 of file pump.cpp.

References wfl::msg().

Referenced by show_wml_messages().

◆ 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 406 of file pump.cpp.

References data, and id.

◆ flush_messages()

void game_events::wml_event_pump::flush_messages ( )

Flushes WML messages and errors.

Definition at line 521 of file pump.cpp.

References game_display::get_singleton(), and video::headless().

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 195 of file pump.cpp.

References 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, config::optional_child(), 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 386 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 315 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 entity_location loc1 = entity_location::null_entity,
const entity_location loc2 = entity_location::null_entity,
const config data = config() 
)
inline

Definition at line 132 of file pump.hpp.

References data.

◆ raise() [2/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() 
)

◆ 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 363 of file pump.cpp.

References impl_.

Referenced by game_lua_kernel::intf_cancel_action().

◆ set_undo_disabled()

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

[allow_undo] implementation

Definition at line 351 of file pump.cpp.

References b, and impl_.

Referenced by game_lua_kernel::intf_allow_undo().

◆ 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 298 of file pump.cpp.

References lg::log_to_chat(), and show_wml_messages().

◆ show_wml_messages() [1/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 310 of file pump.cpp.

References impl_.

Referenced by show_wml_errors().

◆ show_wml_messages() [2/2]

void game_events::wml_event_pump::show_wml_messages ( std::stringstream &  source,
const std::string &  caption 
)
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.

Parameters
sourceThe source to be parsed before being displayed.
captionThe text to display before each message parsed from source.

Definition at line 269 of file pump.cpp.

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

◆ 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 345 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 75 of file pump.hpp.

Referenced by process_event(), put_wml_message(), and show_wml_messages().


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