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/>.
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"
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.
21 class ScriptEvent
: public ScriptObject
{
24 * The type of event. Needed to lookup the detailed class.
26 enum ScriptEventType
{
30 ET_SUBSIDY_OFFER_EXPIRED
,
35 ET_COMPANY_IN_TROUBLE
,
36 ET_COMPANY_ASK_MERGER
,
41 ET_VEHICLE_WAITING_IN_DEPOT
,
42 ET_VEHICLE_UNPROFITABLE
,
46 ET_STATION_FIRST_VEHICLE
,
47 ET_DISASTER_ZEPPELINER_CRASHED
,
48 ET_DISASTER_ZEPPELINER_CLEARED
,
50 ET_AIRCRAFT_DEST_TOO_FAR
,
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
,
63 * Constructor of ScriptEvent, to get the type of event.
64 * @param type The type of event to construct.
66 ScriptEvent(ScriptEvent::ScriptEventType type
) :
72 * @return The @c ScriptEventType.
74 ScriptEventType
GetEventType() { return this->type
; }
78 * The type of this event.
84 * Class that handles all event related functions.
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
{
92 * Check if there is an event waiting.
93 * @return true if there is an event on the stack.
95 static bool IsEventWaiting();
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.
108 static void InsertEvent(ScriptEvent
*event
);
111 * Free the event pointer.
114 static void FreeEventPointer();
118 * Create the event pointer.
120 static void CreateEventPointer();
123 #endif /* SCRIPT_EVENT_HPP */