Codechange: Optimize FlowsDown (#13262)
[openttd-github.git] / src / script / api / script_execmode.hpp
bloba673a195b2d863043bd2d32688ad19d96618dc5a
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_execmode.hpp Switch the script to Execute Mode. */
10 #ifndef SCRIPT_EXECMODE_HPP
11 #define SCRIPT_EXECMODE_HPP
13 #include "script_object.hpp"
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
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.
28 protected:
29 /**
30 * The callback proc for Execute mode.
32 static bool ModeProc();
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!
40 ScriptExecMode();
42 /**
43 * Destroying this instance reset the building mode to the mode it was
44 * in when the instance was created.
46 ~ScriptExecMode();
48 /**
49 * @api -all
51 void FinalRelease() override;
54 #endif /* SCRIPT_EXECMODE_HPP */