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

The game event manager loads the scenario configuration object, and ensures that events are handled according to the scenario configuration for its lifetime. More...

#include <manager.hpp>

Public Types

using event_func_t = std::function< void(game_events::manager &, handler_ptr &)>
 

Public Member Functions

 manager (const manager &)=delete
 
manageroperator= (const manager &)=delete
 
 manager ()
 
void read_scenario (const config &scenario_cfg)
 
 ~manager ()
 
void add_event_handler (const config &handler, bool is_menu_item=false)
 Create an event handler. More...
 
void remove_event_handler (const std::string &id)
 Removes an event handler. More...
 
const handler_ptr get_event_handler_by_id (const std::string &id)
 Gets an event handler by ID. More...
 
void add_events (const config::const_child_itors &cfgs, const std::string &type=std::string())
 
void write_events (config &cfg) const
 
void execute_on_events (const std::string &event_id, event_func_t func)
 
bool is_event_running () const
 
game_events::wml_event_pumppump ()
 
game_events::wmi_managerwml_menu_items ()
 

Private Attributes

const std::unique_ptr< event_handlersevent_handlers_
 
std::set< std::string > unit_wml_ids_
 
const std::unique_ptr< game_events::wml_event_pumppump_
 
game_events::wmi_manager wml_menu_items_
 

Detailed Description

The game event manager loads the scenario configuration object, and ensures that events are handled according to the scenario configuration for its lifetime.

Thus, a manager object should be created when a scenario is played, and destroyed at the end of the scenario. If a second manager object is created before destroying the previous one, the game will crash with an assertion failure.

Definition at line 43 of file manager.hpp.

Member Typedef Documentation

◆ event_func_t

Definition at line 73 of file manager.hpp.

Constructor & Destructor Documentation

◆ manager() [1/2]

game_events::manager::manager ( const manager )
delete

◆ manager() [2/2]

game_events::manager::manager ( )
explicit

Definition at line 87 of file manager.cpp.

◆ ~manager()

game_events::manager::~manager ( )

Definition at line 111 of file manager.cpp.

Member Function Documentation

◆ add_event_handler()

void game_events::manager::add_event_handler ( const config handler,
bool  is_menu_item = false 
)

◆ add_events()

void game_events::manager::add_events ( const config::const_child_itors cfgs,
const std::string &  type = std::string() 
)

Definition at line 115 of file manager.cpp.

References add_event_handler(), gui2::event::find(), unit_wml_ids_, and WRN_NG.

Referenced by unit::advance_to(), and unit::init().

◆ execute_on_events()

void game_events::manager::execute_on_events ( const std::string &  event_id,
manager::event_func_t  func 
)

◆ get_event_handler_by_id()

const handler_ptr game_events::manager::get_event_handler_by_id ( const std::string &  id)

Gets an event handler by ID.

Gets an event handler by id.

Definition at line 80 of file manager.cpp.

◆ is_event_running()

bool game_events::manager::is_event_running ( ) const

Definition at line 223 of file manager.cpp.

Referenced by write_events().

◆ operator=()

manager& game_events::manager::operator= ( const manager )
delete

◆ pump()

game_events::wml_event_pump & game_events::manager::pump ( )

◆ read_scenario()

void game_events::manager::read_scenario ( const config scenario_cfg)

◆ remove_event_handler()

void game_events::manager::remove_event_handler ( const std::string &  id)

Removes an event handler.

Definition at line 74 of file manager.cpp.

Referenced by game_events::wml_menu_item::finish_handler(), and game_events::wml_menu_item::update_command().

◆ wml_menu_items()

game_events::wmi_manager& game_events::manager::wml_menu_items ( )
inline

Definition at line 80 of file manager.hpp.

References wml_menu_items_.

◆ write_events()

void game_events::manager::write_events ( config cfg) const

Member Data Documentation

◆ event_handlers_

const std::unique_ptr<event_handlers> game_events::manager::event_handlers_
private

Definition at line 46 of file manager.hpp.

Referenced by execute_on_events(), and write_events().

◆ pump_

const std::unique_ptr<game_events::wml_event_pump> game_events::manager::pump_
private

Definition at line 49 of file manager.hpp.

Referenced by pump().

◆ unit_wml_ids_

std::set<std::string> game_events::manager::unit_wml_ids_
private

Definition at line 47 of file manager.hpp.

Referenced by add_events(), read_scenario(), and write_events().

◆ wml_menu_items_

game_events::wmi_manager game_events::manager::wml_menu_items_
private

Definition at line 50 of file manager.hpp.

Referenced by read_scenario(), wml_menu_items(), and write_events().


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