Update: Translations from eints
[openttd-github.git] / src / script / api / script_event.hpp
blob2ff813aa8161df7c5477e5b7991ee0b2af3922bc
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file script_event.hpp Everything to handle events from the game. */
10 #ifndef SCRIPT_EVENT_HPP
11 #define SCRIPT_EVENT_HPP
13 #include "script_object.hpp"
15 /**
16 * Class that handles all event related functions.
17 * You can lookup the type, and than convert it to the real event-class.
18 * That way you can request more detailed information about the event.
19 * @api ai game
21 class ScriptEvent : public ScriptObject {
22 public:
23 /**
24 * The type of event. Needed to lookup the detailed class.
26 enum ScriptEventType {
27 ET_INVALID = 0,
28 ET_TEST,
29 ET_SUBSIDY_OFFER,
30 ET_SUBSIDY_OFFER_EXPIRED,
31 ET_SUBSIDY_AWARDED,
32 ET_SUBSIDY_EXPIRED,
33 ET_ENGINE_PREVIEW,
34 ET_COMPANY_NEW,
35 ET_COMPANY_IN_TROUBLE,
36 ET_COMPANY_ASK_MERGER,
37 ET_COMPANY_MERGER,
38 ET_COMPANY_BANKRUPT,
39 ET_VEHICLE_CRASHED,
40 ET_VEHICLE_LOST,
41 ET_VEHICLE_WAITING_IN_DEPOT,
42 ET_VEHICLE_UNPROFITABLE,
43 ET_INDUSTRY_OPEN,
44 ET_INDUSTRY_CLOSE,
45 ET_ENGINE_AVAILABLE,
46 ET_STATION_FIRST_VEHICLE,
47 ET_DISASTER_ZEPPELINER_CRASHED,
48 ET_DISASTER_ZEPPELINER_CLEARED,
49 ET_TOWN_FOUNDED,
50 ET_AIRCRAFT_DEST_TOO_FAR,
51 ET_ADMIN_PORT,
52 ET_WINDOW_WIDGET_CLICK,
53 ET_GOAL_QUESTION_ANSWER,
54 ET_EXCLUSIVE_TRANSPORT_RIGHTS,
55 ET_ROAD_RECONSTRUCTION,
56 ET_VEHICLE_AUTOREPLACED,
57 ET_STORYPAGE_BUTTON_CLICK,
58 ET_STORYPAGE_TILE_SELECT,
59 ET_STORYPAGE_VEHICLE_SELECT,
62 /**
63 * Constructor of ScriptEvent, to get the type of event.
64 * @param type The type of event to construct.
66 ScriptEvent(ScriptEvent::ScriptEventType type) :
67 type(type)
70 /**
71 * Get the event-type.
72 * @return The @c ScriptEventType.
74 ScriptEventType GetEventType() { return this->type; }
76 protected:
77 /**
78 * The type of this event.
80 ScriptEventType type;
83 /**
84 * Class that handles all event related functions.
85 * @api ai game
86 * @note it is not needed to create an instance of ScriptEvent to access it, as
87 * all members are static, and all data is stored script instance-wide.
89 class ScriptEventController : public ScriptObject {
90 public:
91 /**
92 * Check if there is an event waiting.
93 * @return true if there is an event on the stack.
95 static bool IsEventWaiting();
97 /**
98 * Get the next event.
99 * @return a class of the event-child issues.
101 static ScriptEvent *GetNextEvent();
104 * Insert an event to the queue for the company.
105 * @param event The event to insert.
106 * @api -all
108 static void InsertEvent(ScriptEvent *event);
111 * Free the event pointer.
112 * @api -all
114 static void FreeEventPointer();
116 private:
118 * Create the event pointer.
120 static void CreateEventPointer();
123 #endif /* SCRIPT_EVENT_HPP */