2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2012-03-04 16:54:12 +00:00
|
|
|
/** @file script_execmode.hpp Switch the script to Execute Mode. */
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#ifndef SCRIPT_EXECMODE_HPP
|
|
|
|
#define SCRIPT_EXECMODE_HPP
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#include "script_object.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class to switch current mode to Execute Mode.
|
|
|
|
* If you create an instance of this class, the mode will be switched to
|
|
|
|
* Execute. The original mode is stored and recovered from when ever the
|
|
|
|
* instance is destroyed.
|
|
|
|
* In Execute mode all commands you do are executed for real.
|
2011-12-19 20:50:54 +00:00
|
|
|
* @api ai game
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
class ScriptExecMode : public ScriptObject {
|
2009-01-12 17:11:45 +00:00
|
|
|
private:
|
2011-11-29 23:21:04 +00:00
|
|
|
ScriptModeProc *last_mode; ///< The previous mode we were in.
|
2013-01-08 22:46:42 +00:00
|
|
|
ScriptObject *last_instance; ///< The previous instance of the mode.
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* The callback proc for Execute mode.
|
|
|
|
*/
|
2010-01-10 23:20:11 +00:00
|
|
|
static bool ModeProc();
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creating instance of this class switches the build mode to Execute.
|
2021-05-08 10:02:30 +00:00
|
|
|
* @note When the instance is destroyed, it restores the mode that was
|
2009-01-12 17:11:45 +00:00
|
|
|
* current when the instance was created!
|
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
ScriptExecMode();
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroying this instance reset the building mode to the mode it was
|
|
|
|
* in when the instance was created.
|
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
~ScriptExecMode();
|
2015-08-10 20:04:31 +00:00
|
|
|
|
2016-04-17 17:10:07 +00:00
|
|
|
/**
|
|
|
|
* @api -all
|
|
|
|
*/
|
2023-04-13 06:23:18 +00:00
|
|
|
void FinalRelease() override;
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#endif /* SCRIPT_EXECMODE_HPP */
|