Add ability to bypass strict no-disabled-events assertion when writing events

This is since the Gamestate Inspector can be invoked mid-event (using [inspect])
and it makes use of write_events().
This commit is contained in:
Charles Dang 2018-03-25 04:06:13 +11:00
parent ef172d47fa
commit afaa75842c
3 changed files with 7 additions and 4 deletions

View file

@ -132,11 +132,14 @@ void manager::add_events(const config::const_child_itors& cfgs, const std::strin
}
}
void manager::write_events(config& cfg) const
void manager::write_events(config& cfg, bool strict) const
{
for(const handler_ptr& eh : event_handlers_->get_active()) {
if(eh && !eh->is_menu_item()) {
assert(!eh->disabled());
if(strict) {
assert(!eh->disabled());
}
cfg.add_child("event", eh->get_config());;
}
}

View file

@ -68,7 +68,7 @@ public:
void add_events(const config::const_child_itors& cfgs, const std::string& type = std::string());
void write_events(config& cfg) const;
void write_events(config& cfg, bool strict = true) const;
using event_func_t = std::function<void(game_events::manager&, handler_ptr&)>;
void execute_on_events(const std::string& event_id, event_func_t func);

View file

@ -509,7 +509,7 @@ const display_context& single_mode_controller::dc() const {
event_mode_controller::event_mode_controller(gamestate_inspector::controller& c)
: single_mode_controller(c)
{
single_mode_controller::events().write_events(events);
single_mode_controller::events().write_events(events, false);
}
void variable_mode_controller::show_list(tree_view_node& node)