script_event.hpp

Go to the documentation of this file.
00001 /* $Id$ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef SCRIPT_EVENT_HPP
00013 #define SCRIPT_EVENT_HPP
00014 
00015 #include "script_object.hpp"
00016 
00023 class ScriptEvent : public ScriptObject {
00024 public:
00028   enum ScriptEventType {
00029     ET_INVALID = 0,
00030     ET_TEST,
00031     ET_SUBSIDY_OFFER,
00032     ET_SUBSIDY_OFFER_EXPIRED,
00033     ET_SUBSIDY_AWARDED,
00034     ET_SUBSIDY_EXPIRED,
00035     ET_ENGINE_PREVIEW,
00036     ET_COMPANY_NEW,
00037     ET_COMPANY_IN_TROUBLE,
00038     ET_COMPANY_ASK_MERGER,
00039     ET_COMPANY_MERGER,
00040     ET_COMPANY_BANKRUPT,
00041     ET_VEHICLE_CRASHED,
00042     ET_VEHICLE_LOST,
00043     ET_VEHICLE_WAITING_IN_DEPOT,
00044     ET_VEHICLE_UNPROFITABLE,
00045     ET_INDUSTRY_OPEN,
00046     ET_INDUSTRY_CLOSE,
00047     ET_ENGINE_AVAILABLE,
00048     ET_STATION_FIRST_VEHICLE,
00049     ET_DISASTER_ZEPPELINER_CRASHED,
00050     ET_DISASTER_ZEPPELINER_CLEARED,
00051     ET_TOWN_FOUNDED,
00052   };
00053 
00057   ScriptEvent(ScriptEvent::ScriptEventType type) :
00058     type(type)
00059   {}
00060 
00065   ScriptEventType GetEventType() { return this->type; }
00066 
00067 protected:
00071   ScriptEventType type;
00072 };
00073 
00080 class ScriptEventController : public ScriptObject {
00081 public:
00086   static bool IsEventWaiting();
00087 
00092   static ScriptEvent *GetNextEvent();
00093 
00099   static void InsertEvent(ScriptEvent *event);
00100 
00105   static void FreeEventPointer();
00106 
00107 private:
00111   static void CreateEventPointer();
00112 };
00113 
00114 #endif /* SCRIPT_EVENT_HPP */