Files
@ r28025:9116d6e411b0
Branch filter:
Location: cpp/openttd-patchpack/source/src/script/script_info.hpp - annotation
r28025:9116d6e411b0
5.0 KiB
text/x-c++hdr
Codechange: replace x.size() == 0 with x.empty()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r11380:8edd3e28a734 r11380:8edd3e28a734 r16851:b5784600e35e r16851:b5784600e35e r11380:8edd3e28a734 r14248:a9050881acd7 r11380:8edd3e28a734 r11380:8edd3e28a734 r18510:9d33e9643f80 r18510:9d33e9643f80 r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18511:f289eabf96bf r18508:f893337ab5c7 r11380:8edd3e28a734 r18508:f893337ab5c7 r23607:36c15679007d r13879:b9c13f7998cb r23607:36c15679007d r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r27365:849bb90cdbff r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r27365:849bb90cdbff r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r27365:849bb90cdbff r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r27365:849bb90cdbff r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r27365:849bb90cdbff r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r27365:849bb90cdbff r11380:8edd3e28a734 r11380:8edd3e28a734 r11702:a9dd3b59c546 r11702:a9dd3b59c546 r27365:849bb90cdbff r11702:a9dd3b59c546 r11702:a9dd3b59c546 r11380:8edd3e28a734 r11380:8edd3e28a734 r27365:849bb90cdbff r11380:8edd3e28a734 r11380:8edd3e28a734 r18074:2c37f49891fa r18074:2c37f49891fa r27365:849bb90cdbff r18074:2c37f49891fa r18074:2c37f49891fa r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r18508:f893337ab5c7 r18508:f893337ab5c7 r18508:f893337ab5c7 r18508:f893337ab5c7 r18508:f893337ab5c7 r18508:f893337ab5c7 r11380:8edd3e28a734 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r27359:9505d4407412 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r18510:9d33e9643f80 r27310:97eaae2636e8 r18510:9d33e9643f80 r18755:ade8fc0cd811 r18755:ade8fc0cd811 r18755:ade8fc0cd811 r18755:ade8fc0cd811 r18510:9d33e9643f80 r11380:8edd3e28a734 r18510:9d33e9643f80 r27369:d93808e810cd r18510:9d33e9643f80 r18508:f893337ab5c7 r11380:8edd3e28a734 r24529:3dec691db49a r24529:3dec691db49a r27365:849bb90cdbff r27365:849bb90cdbff r27365:849bb90cdbff r27365:849bb90cdbff r27365:849bb90cdbff r27365:849bb90cdbff r18508:f893337ab5c7 r27365:849bb90cdbff r18508:f893337ab5c7 r18508:f893337ab5c7 r11380:8edd3e28a734 r11380:8edd3e28a734 r26832:a6bd9039c80b r26832:a6bd9039c80b r26832:a6bd9039c80b r16851:b5784600e35e | /*
* 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/>.
*/
/** @file script_info.hpp ScriptInfo keeps track of all information of a script, like Author, Description, ... */
#ifndef SCRIPT_INFO_HPP
#define SCRIPT_INFO_HPP
#include <squirrel.h>
#include "../misc/countedptr.hpp"
#include "script_config.hpp"
/** The maximum number of operations for saving or loading the data of a script. */
static const int MAX_SL_OPS = 100000;
/** The maximum number of operations for initial start of a script. */
static const int MAX_CONSTRUCTOR_OPS = 100000;
/** Number of operations to create an instance of a script. */
static const int MAX_CREATEINSTANCE_OPS = 100000;
/** Number of operations to get the author and similar information. */
static const int MAX_GET_OPS = 1000;
/** Maximum number of operations allowed for getting a particular setting. */
static const int MAX_GET_SETTING_OPS = 100000;
/** All static information from an Script like name, version, etc. */
class ScriptInfo : public SimpleCountedObject {
public:
ScriptInfo() :
engine(nullptr),
version(0),
scanner(nullptr)
{}
/**
* Get the Author of the script.
*/
const std::string &GetAuthor() const { return this->author; }
/**
* Get the Name of the script.
*/
const std::string &GetName() const { return this->name; }
/**
* Get the 4 character long short name of the script.
*/
const std::string &GetShortName() const { return this->short_name; }
/**
* Get the description of the script.
*/
const std::string &GetDescription() const { return this->description; }
/**
* Get the version of the script.
*/
int GetVersion() const { return this->version; }
/**
* Get the last-modified date of the script.
*/
const std::string &GetDate() const { return this->date; }
/**
* Get the name of the instance of the script to create.
*/
const std::string &GetInstanceName() const { return this->instance_name; }
/**
* Get the website for this script.
*/
const std::string &GetURL() const { return this->url; }
/**
* Get the filename of the main.nut script.
*/
const std::string &GetMainScript() const { return this->main_script; }
/**
* Get the filename of the tar the script is in.
*/
const std::string &GetTarFile() const { return this->tar_file; }
/**
* Check if a given method exists.
*/
bool CheckMethod(const char *name) const;
/**
* Process the creation of a FileInfo object.
*/
static SQInteger Constructor(HSQUIRRELVM vm, ScriptInfo *info);
/**
* Get the scanner which has found this ScriptInfo.
*/
virtual class ScriptScanner *GetScanner() { return this->scanner; }
/**
* Get the settings of the Script.
*/
bool GetSettings();
/**
* Get the config list for this Script.
*/
const ScriptConfigItemList *GetConfigList() const;
/**
* Get the description of a certain Script config option.
*/
const ScriptConfigItem *GetConfigItem(const std::string_view name) const;
/**
* Set a setting.
*/
SQInteger AddSetting(HSQUIRRELVM vm);
/**
* Add labels for a setting.
*/
SQInteger AddLabels(HSQUIRRELVM vm);
/**
* Get the default value for a setting.
*/
int GetSettingDefaultValue(const std::string &name) const;
/**
* Can this script be selected by developers only?
*/
virtual bool IsDeveloperOnly() const { return false; }
protected:
class Squirrel *engine; ///< Engine used to register for Squirrel.
HSQOBJECT SQ_instance; ///< The Squirrel instance created for this info.
ScriptConfigItemList config_list; ///< List of settings from this Script.
private:
std::string main_script; ///< The full path of the script.
std::string tar_file; ///< If, which tar file the script was in.
std::string author; ///< Author of the script.
std::string name; ///< Full name of the script.
std::string short_name; ///< Short name (4 chars) which uniquely identifies the script.
std::string description; ///< Small description of the script.
std::string date; ///< The date the script was written at.
std::string instance_name; ///< Name of the main class in the script.
int version; ///< Version of the script.
std::string url; ///< URL of the script.
class ScriptScanner *scanner; ///< ScriptScanner object that was used to scan this script info.
};
void Script_CreateDummyInfo(HSQUIRRELVM vm, const char *type, const char *dir);
void Script_CreateDummy(HSQUIRRELVM vm, StringID string, const char *type);
#endif /* SCRIPT_INFO_HPP */
|