The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
handlers.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * Define the handlers for the game's events mechanism.
18  *
19  * Events might be units moving or fighting, or when victory or defeat occurs.
20  * A scenario's configuration file will define actions to take when certain events occur.
21  * This module is responsible for tracking these definitions.
22  */
23 
24 #pragma once
25 
26 #include "config.hpp"
27 
28 #include <string>
29 
30 class game_data;
31 class game_lua_kernel;
32 
33 namespace game_events
34 {
35 struct queued_event;
36 
38 {
39 public:
40  event_handler(config&& cfg, bool is_menu_item, const std::vector<std::string>& types);
41 
42  const std::vector<std::string>& names() const
43  {
44  return types_;
45  }
46 
47  bool disabled() const
48  {
49  return disabled_;
50  }
51 
52  bool is_menu_item() const
53  {
54  return is_menu_item_;
55  }
56 
57  /** Flag this handler as disabled. */
58  void disable();
59 
60  /**
61  * Handles the queued event, according to our WML instructions.
62  *
63  * @param[in] event_info Information about the event that needs handling.
64  */
65  void handle_event(const queued_event& event_info, game_lua_kernel&);
66 
67  const config& get_config() const
68  {
69  return cfg_;
70  }
71 
72 private:
75  bool disabled_;
77  std::vector<std::string> types_;
78 };
79 
80 }
void handle_event(const queued_event &event_info, game_lua_kernel &)
Handles the queued event, according to our WML instructions.
Definition: handlers.cpp:61
bool disabled() const
Definition: handlers.hpp:47
bool is_menu_item() const
Definition: handlers.hpp:52
event_handler(config &&cfg, bool is_menu_item, const std::vector< std::string > &types)
Definition: handlers.cpp:46
Definitions for the interface to Wesnoth Markup Language (WML).
const config & get_config() const
Definition: handlers.hpp:67
Domain specific events.
Definition: action_wml.cpp:88
void disable()
Flag this handler as disabled.
Definition: handlers.cpp:55
const std::vector< std::string > & names() const
Definition: handlers.hpp:42
std::vector< std::string > types_
Definition: handlers.hpp:77
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93