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 | |
manager & | operator= (const manager &)=delete |
manager () | |
void | read_scenario (const config &scenario_cfg, game_lua_kernel &lk) |
~manager () | |
void | add_event_handler_from_wml (const config &handler, game_lua_kernel &lk, bool is_menu_item=false) |
Create an event handler from an [event] tag. More... | |
pending_event_handler | add_event_handler_from_lua (const std::string &name, const std::string &id, bool repeat=false, double priority=0., bool is_menu_item=false) |
Create an empty 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, game_lua_kernel &lk, const std::string &type=std::string()) |
void | write_events (config &cfg, bool include_nonserializable=false) const |
void | execute_on_events (const std::string &event_id, event_func_t func) |
bool | is_event_running () const |
game_events::wml_event_pump & | pump () |
game_events::wmi_manager & | wml_menu_items () |
Private Attributes | |
const std::unique_ptr< event_handlers > | event_handlers_ |
std::set< std::string > | unit_wml_ids_ |
const std::unique_ptr< game_events::wml_event_pump > | pump_ |
game_events::wmi_manager | wml_menu_items_ |
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 44 of file manager.hpp.
using game_events::manager::event_func_t = std::function<void(game_events::manager&, handler_ptr&)> |
Definition at line 79 of file manager.hpp.
|
delete |
|
explicit |
Definition at line 125 of file manager.cpp.
game_events::manager::~manager | ( | ) |
Definition at line 149 of file manager.cpp.
pending_event_handler game_events::manager::add_event_handler_from_lua | ( | const std::string & | name, |
const std::string & | id, | ||
bool | repeat = false , |
||
double | priority = 0. , |
||
bool | is_menu_item = false |
||
) |
Create an empty event handler.
Expects the caller to finish setting up the event.
Definition at line 106 of file manager.cpp.
References event_handlers_.
Referenced by game_lua_kernel::intf_add_event(), and game_lua_kernel::intf_add_event_simple().
void game_events::manager::add_event_handler_from_wml | ( | const config & | handler, |
game_lua_kernel & | lk, | ||
bool | is_menu_item = false |
||
) |
Create an event handler from an [event] tag.
Create an event handler.
Definition at line 66 of file manager.cpp.
References config::add_child(), config::all_children_view(), config::attribute_range(), DBG_EH, config::debug(), event_handlers_, and LOG_EH.
Referenced by add_events(), game_events::wml_menu_item::init_handler(), game_lua_kernel::intf_add_event_wml(), read_scenario(), and game_events::wml_menu_item::update_command().
void game_events::manager::add_events | ( | const config::const_child_itors & | cfgs, |
game_lua_kernel & | lk, | ||
const std::string & | type = std::string() |
||
) |
Definition at line 153 of file manager.cpp.
References add_event_handler_from_wml(), unit_wml_ids_, and WRN_NG.
Referenced by unit::advance_to(), unit::apply_builtin_effect(), and unit::init().
void game_events::manager::execute_on_events | ( | const std::string & | event_id, |
manager::event_func_t | func | ||
) |
Definition at line 205 of file manager.cpp.
References event_handlers_, resources::gamedata, i, and game_events::event_handlers::standardize_name().
Referenced by game_events::wml_menu_item::update_command().
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 118 of file manager.cpp.
References event_handlers_.
bool game_events::manager::is_event_running | ( | ) | const |
Definition at line 247 of file manager.cpp.
Referenced by write_events().
game_events::wml_event_pump & game_events::manager::pump | ( | ) |
Definition at line 253 of file manager.cpp.
References pump_.
Referenced by actions::actor_sighted(), advance_unit(), game_events::wml_menu_item::fire_event(), actions::shroud_clearer::fire_events(), team::get_village(), ai::manager::play_turn(), unit_creator::post_create(), storyscreen::story_parser::resolve_wml(), and SYNCED_COMMAND_HANDLER_FUNCTION().
void game_events::manager::read_scenario | ( | const config & | scenario_cfg, |
game_lua_kernel & | lk | ||
) |
Definition at line 133 of file manager.cpp.
References add_event_handler_from_wml(), config::child_range(), game_events::wmi_manager::init_handlers(), game_events::wmi_manager::set_menu_items(), utils::split(), unit_wml_ids_, and wml_menu_items_.
void game_events::manager::remove_event_handler | ( | const std::string & | id | ) |
Removes an event handler.
Definition at line 112 of file manager.cpp.
References event_handlers_.
Referenced by game_events::wml_menu_item::finish_handler().
|
inline |
Definition at line 86 of file manager.hpp.
References wml_menu_items_.
void game_events::manager::write_events | ( | config & | cfg, |
bool | include_nonserializable = false |
||
) | const |
Definition at line 173 of file manager.cpp.
References config::add_child(), config::empty(), event_handlers_, is_event_running(), utils::join(), game_events::wmi_manager::to_config(), unit_wml_ids_, and wml_menu_items_.
Referenced by gui2::dialogs::event_mode_controller::event_mode_controller().
|
private |
Definition at line 47 of file manager.hpp.
Referenced by add_event_handler_from_lua(), add_event_handler_from_wml(), execute_on_events(), get_event_handler_by_id(), remove_event_handler(), and write_events().
|
private |
Definition at line 50 of file manager.hpp.
Referenced by pump().
|
private |
Definition at line 48 of file manager.hpp.
Referenced by add_events(), read_scenario(), and write_events().
|
private |
Definition at line 51 of file manager.hpp.
Referenced by read_scenario(), wml_menu_items(), and write_events().