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/>.
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"
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.
23 class ScriptEvent
: public ScriptObject
{
26 * The type of event. Needed to lookup the detailed class.
28 enum ScriptEventType
{
32 ET_SUBSIDY_OFFER_EXPIRED
,
37 ET_COMPANY_IN_TROUBLE
,
38 ET_COMPANY_ASK_MERGER
,
43 ET_VEHICLE_WAITING_IN_DEPOT
,
44 ET_VEHICLE_UNPROFITABLE
,
48 ET_STATION_FIRST_VEHICLE
,
49 ET_DISASTER_ZEPPELINER_CRASHED
,
50 ET_DISASTER_ZEPPELINER_CLEARED
,
52 ET_AIRCRAFT_DEST_TOO_FAR
,
54 ET_WINDOW_WIDGET_CLICK
,
55 ET_GOAL_QUESTION_ANSWER
,
56 ET_EXCLUSIVE_TRANSPORT_RIGHTS
,
57 ET_ROAD_RECONSTRUCTION
,
61 * Constructor of ScriptEvent, to get the type of event.
63 ScriptEvent(ScriptEvent::ScriptEventType type
) :
69 * @return The @c ScriptEventType.
71 ScriptEventType
GetEventType() { return this->type
; }
75 * The type of this event.
81 * Class that handles all event related functions.
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
{
89 * Check if there is an event waiting.
90 * @return true if there is an event on the stack.
92 static bool IsEventWaiting();
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.
105 static void InsertEvent(ScriptEvent
*event
);
108 * Free the event pointer.
111 static void FreeEventPointer();
115 * Create the event pointer.
117 static void CreateEventPointer();
120 #endif /* SCRIPT_EVENT_HPP */