Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GAME_EVENTS_H_INCLUDED
00017 #define GAME_EVENTS_H_INCLUDED
00018
00019 #include "map.hpp"
00020 #include "variable.hpp"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class unit;
00036
00037
00038
00039
00040
00041 void change_terrain(const map_location &loc, const t_translation::t_terrain &t,
00042 gamemap::tmerge_mode mode, bool replace_if_failed);
00043
00044 namespace game_events
00045 {
00046
00047
00048
00049
00050
00051
00052
00053 struct manager {
00054
00055
00056 manager(const config& scenario_cfg);
00057 ~manager();
00058
00059 private:
00060 variable::manager variable_manager;
00061 };
00062
00063 struct entity_location : public map_location {
00064 entity_location(const map_location &loc, size_t id = 0);
00065 explicit entity_location(const unit &);
00066 bool requires_unit() const;
00067 bool matches_unit(const unit& u) const;
00068 private:
00069 size_t id_;
00070 };
00071
00072
00073 struct queued_event {
00074 queued_event(const std::string& name, const game_events::entity_location& loc1,
00075 const game_events::entity_location& loc2,
00076 const config& data)
00077 : name(name), loc1(loc1), loc2(loc2),data(data) {}
00078
00079 std::string name;
00080 game_events::entity_location loc1;
00081 game_events::entity_location loc2;
00082 config data;
00083 };
00084
00085 class event_handler
00086 {
00087 public:
00088 event_handler(const config &cfg, bool is_menu_item = false);
00089
00090 bool matches_name(const std::string& name) const;
00091
00092 bool disabled() const { return disabled_; }
00093 bool is_menu_item() const { return is_menu_item_; }
00094
00095 void handle_event(const queued_event& event_info);
00096
00097 const config &get_config() const { return cfg_; }
00098 private:
00099 bool first_time_only_;
00100 bool disabled_;
00101 bool is_menu_item_;
00102 config cfg_;
00103 };
00104
00105
00106
00107
00108 void handle_event_commands(const queued_event &event_info, const vconfig &cfg);
00109
00110
00111
00112
00113 void handle_event_command(const std::string &cmd,
00114 const queued_event &event_info, const vconfig &cfg);
00115
00116 void write_events(config& cfg);
00117 void add_events(
00118 const config::const_child_itors &cfgs,
00119 const std::string& type = std::string());
00120
00121 bool unit_matches_filter(const unit &, const vconfig& filter);
00122
00123
00124 void handle_wml_log_message(const config& cfg);
00125
00126 void handle_deprecated_message(const config& cfg);
00127
00128
00129
00130
00131 std::vector<int> get_sides_vector(const vconfig& cfg);
00132
00133
00134
00135
00136
00137
00138 bool fire(const std::string& event,
00139 const entity_location& loc1=map_location::null_location,
00140 const entity_location& loc2=map_location::null_location,
00141 const config& data=config());
00142
00143 void raise(const std::string& event,
00144 const entity_location& loc1=map_location::null_location,
00145 const entity_location& loc2=map_location::null_location,
00146 const config& data=config());
00147
00148 bool conditional_passed(const vconfig& cond, bool backwards_compat=true);
00149
00150
00151
00152
00153 void commit();
00154
00155 bool pump();
00156
00157 typedef void (*action_handler)(const game_events::queued_event &, const vconfig &);
00158
00159 }
00160
00161 #endif