10 #include "../stdafx.h"
12 #include "../script/squirrel_class.hpp"
17 #include "../safeguards.h"
25 static const std::set<std::string> versions = {
"1.2",
"1.3",
"1.4",
"1.5",
"1.6",
"1.7",
"1.8",
"1.9",
"1.10",
"1.11",
"12",
"13",
"14",
"15" };
26 return versions.find(api_version) != versions.end();
32 template <>
const char *GetClassName<GameInfo, ScriptType::GS>() {
return "GSInfo"; }
38 SQGSInfo.PreRegister(
engine);
48 SQGSInfo.PostRegister(
engine);
55 SQUserPointer instance =
nullptr;
56 if (SQ_FAILED(sq_getinstanceup(vm, 2, &instance,
nullptr)) || instance ==
nullptr)
return sq_throwerror(vm,
"Pass an instance of a child class of GameInfo to RegisterGame");
60 if (res != 0)
return res;
74 if (!info->
CheckMethod(
"GetAPIVersion"))
return SQ_ERROR;
77 Debug(script, 1,
"Loading info.nut from ({}.{}): GetAPIVersion returned invalid version", info->
GetName(), info->
GetVersion());
82 sq_setinstanceup(vm, 2,
nullptr);
88 GameInfo::GameInfo() :
89 min_loadable_version(0),
90 is_developer_only(false)
The template to define classes in Squirrel.
void DefSQAdvancedMethod(Squirrel *engine, Func function_proc, const char *function_name)
This defines a method inside a class for Squirrel, which has access to the 'engine' (experts only!...
All static information from an Game like name, version, etc.
std::string api_version
API version used by this Game.
static SQInteger Constructor(HSQUIRRELVM vm)
Create an Game, using this GameInfo as start-template.
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
bool CanLoadFromVersion(int version) const
Check if we can start this Game.
bool is_developer_only
Is the script selectable by non-developers?
int min_loadable_version
The Game can load savegame data if the version is equal or greater than this.
All static information from an Game library like name, version, etc.
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
std::string category
The category this library is in.
static SQInteger Constructor(HSQUIRRELVM vm)
Create an GSLibrary, using this GSInfo as start-template.
int version
Version of the script.
static SQInteger Constructor(HSQUIRRELVM vm, ScriptInfo *info)
Process the creation of a FileInfo object.
virtual class ScriptScanner * GetScanner()
Get the scanner which has found this ScriptInfo.
bool CheckMethod(const char *name) const
Check if a given method exists.
class Squirrel * engine
Engine used to register for Squirrel.
SQInteger AddSetting(HSQUIRRELVM vm)
Set a setting.
SQInteger AddLabels(HSQUIRRELVM vm)
Add labels for a setting.
int GetVersion() const
Get the version of the script.
const std::string & GetName() const
Get the Name of the script.
HSQOBJECT SQ_instance
The Squirrel instance created for this info.
void RegisterScript(class ScriptInfo *info)
Register a ScriptInfo to the scanner.
void AddClassEnd()
Finishes adding a class to the global scope.
void AddMethod(const char *method_name, SQFUNCTION proc, uint nparam=0, const char *params=nullptr, void *userdata=nullptr, int size=0)
Adds a function to the stack.
void AddClassBegin(const char *class_name)
Adds a class to the global scope.
bool MethodExists(HSQOBJECT instance, const char *method_name)
Check if a method exists in an instance.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
static bool CheckAPIVersion(const std::string &api_version)
Check if the API version provided by the Game is supported.
GameInfo keeps track of all information of an Game, like Author, Description, ...
declarations of the class for Game scanner
@ SCRIPTCONFIG_INGAME
This setting can be changed while the Script is running.
@ SCRIPTCONFIG_BOOLEAN
This value is a boolean (either 0 (false) or 1 (true) ).
@ SCRIPTCONFIG_NONE
No flags set.
@ SCRIPTCONFIG_DEVELOPER
This setting will only be visible when the Script development tools are active.
static const int MAX_GET_OPS
Number of operations to get the author and similar information.