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 */ 7 8 /** @file script_execmode.hpp Switch the script to Execute Mode. */ 9 10 #ifndef SCRIPT_EXECMODE_HPP 11 #define SCRIPT_EXECMODE_HPP 12 13 #include "script_object.hpp" 14 15 /** 16 * Class to switch current mode to Execute Mode. 17 * If you create an instance of this class, the mode will be switched to 18 * Execute. The original mode is stored and recovered from when ever the 19 * instance is destroyed. 20 * In Execute mode all commands you do are executed for real. 21 * @api ai game 22 */ 23 class ScriptExecMode : public ScriptObject { 24 private: 25 ScriptModeProc *last_mode; ///< The previous mode we were in. 26 ScriptObject *last_instance; ///< The previous instance of the mode. 27 28 protected: 29 /** 30 * The callback proc for Execute mode. 31 */ 32 static bool ModeProc(); 33 34 public: 35 /** 36 * Creating instance of this class switches the build mode to Execute. 37 * @note When the instance is destroyed, it restores the mode that was 38 * current when the instance was created! 39 */ 40 ScriptExecMode(); 41 42 /** 43 * Destroying this instance reset the building mode to the mode it was 44 * in when the instance was created. 45 */ 46 ~ScriptExecMode(); 47 48 /** 49 * @api -all 50 */ 51 virtual void FinalRelease(); 52 }; 53 54 #endif /* SCRIPT_EXECMODE_HPP */ 55