(svn r28004) -Update from Eints:
[openttd.git] / src / script / api / script_event.hpp
blobb2dddebd67f927c3d6f5373504df7bf1b43605f1
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file script_event.hpp Everything to handle events from the game. */
12 #ifndef SCRIPT_EVENT_HPP
13 #define SCRIPT_EVENT_HPP
15 #include "script_object.hpp"
17 /**
18 * Class that handles all event related functions.
19 * You can lookup the type, and than convert it to the real event-class.
20 * That way you can request more detailed information about the event.
21 * @api ai game
23 class ScriptEvent : public ScriptObject {
24 public:
25 /**
26 * The type of event. Needed to lookup the detailed class.
28 enum ScriptEventType {
29 ET_INVALID = 0,
30 ET_TEST,
31 ET_SUBSIDY_OFFER,
32 ET_SUBSIDY_OFFER_EXPIRED,
33 ET_SUBSIDY_AWARDED,
34 ET_SUBSIDY_EXPIRED,
35 ET_ENGINE_PREVIEW,
36 ET_COMPANY_NEW,
37 ET_COMPANY_IN_TROUBLE,
38 ET_COMPANY_ASK_MERGER,
39 ET_COMPANY_MERGER,
40 ET_COMPANY_BANKRUPT,
41 ET_VEHICLE_CRASHED,
42 ET_VEHICLE_LOST,
43 ET_VEHICLE_WAITING_IN_DEPOT,
44 ET_VEHICLE_UNPROFITABLE,
45 ET_INDUSTRY_OPEN,
46 ET_INDUSTRY_CLOSE,
47 ET_ENGINE_AVAILABLE,
48 ET_STATION_FIRST_VEHICLE,
49 ET_DISASTER_ZEPPELINER_CRASHED,
50 ET_DISASTER_ZEPPELINER_CLEARED,
51 ET_TOWN_FOUNDED,
52 ET_AIRCRAFT_DEST_TOO_FAR,
53 ET_ADMIN_PORT,
54 ET_WINDOW_WIDGET_CLICK,
55 ET_GOAL_QUESTION_ANSWER,
56 ET_EXCLUSIVE_TRANSPORT_RIGHTS,
57 ET_ROAD_RECONSTRUCTION,
60 /**
61 * Constructor of ScriptEvent, to get the type of event.
63 ScriptEvent(ScriptEvent::ScriptEventType type) :
64 type(type)
67 /**
68 * Get the event-type.
69 * @return The @c ScriptEventType.
71 ScriptEventType GetEventType() { return this->type; }
73 protected:
74 /**
75 * The type of this event.
77 ScriptEventType type;
80 /**
81 * Class that handles all event related functions.
82 * @api ai game
83 * @note it is not needed to create an instance of ScriptEvent to access it, as
84 * all members are static, and all data is stored script instance-wide.
86 class ScriptEventController : public ScriptObject {
87 public:
88 /**
89 * Check if there is an event waiting.
90 * @return true if there is an event on the stack.
92 static bool IsEventWaiting();
94 /**
95 * Get the next event.
96 * @return a class of the event-child issues.
98 static ScriptEvent *GetNextEvent();
101 * Insert an event to the queue for the company.
102 * @param event The event to insert.
103 * @api -all
105 static void InsertEvent(ScriptEvent *event);
108 * Free the event pointer.
109 * @api -all
111 static void FreeEventPointer();
113 private:
115 * Create the event pointer.
117 static void CreateEventPointer();
120 #endif /* SCRIPT_EVENT_HPP */