12 #include "../stdafx.h" 14 #include "../script/squirrel_class.hpp" 19 #include "../safeguards.h" 27 return strcmp(api_version,
"1.2") == 0 || strcmp(api_version,
"1.3") == 0 || strcmp(api_version,
"1.4") == 0 ||
28 strcmp(api_version,
"1.5") == 0 || strcmp(api_version,
"1.6") == 0 || strcmp(api_version,
"1.7") == 0 ||
29 strcmp(api_version,
"1.8") == 0;
35 template <>
const char *GetClassName<GameInfo, ST_GS>() {
return "GSInfo"; }
41 SQGSInfo.PreRegister(engine);
42 SQGSInfo.AddConstructor<void (
GameInfo::*)(), 1>(engine,
"x");
51 SQGSInfo.PostRegister(engine);
58 SQUserPointer instance = NULL;
59 if (SQ_FAILED(sq_getinstanceup(vm, 2, &instance, 0)) || instance == NULL)
return sq_throwerror(vm,
"Pass an instance of a child class of GameInfo to RegisterGame");
63 if (res != 0)
return res;
77 if (!info->
CheckMethod(
"GetAPIVersion"))
return SQ_ERROR;
80 DEBUG(script, 1,
"Loading info.nut from (%s.%d): GetAPIVersion returned invalid version", info->
GetName(), info->
GetVersion());
85 sq_setinstanceup(vm, 2, NULL);
91 GameInfo::GameInfo() :
105 if (version == -1)
return true;
110 GameLibrary::~GameLibrary()
112 free(this->category);
int GetVersion() const
Get the version of the script.
This setting will only be visible when the Script development tools are active.
void AddMethod(const char *method_name, SQFUNCTION proc, uint nparam=0, const char *params=NULL, void *userdata=NULL, int size=0)
Adds a function to the stack.
int version
Version of the script.
HSQOBJECT * SQ_instance
The Squirrel instance created for this info.
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
bool CheckMethod(const char *name) const
Check if a given method exists.
bool is_developer_only
Is the script selectable by non-developers?
const char * GetName() const
Get the Name of the script.
All static information from an Game like name, version, etc.
All static information from an Game library like name, version, etc.
The template to define classes in Squirrel.
void RegisterScript(class ScriptInfo *info)
Register a ScriptInfo to the scanner.
SQInteger AddLabels(HSQUIRRELVM vm)
Add labels for a setting.
static SQInteger Constructor(HSQUIRRELVM vm)
Create an Game, using this GameInfo as start-template.
int min_loadable_version
The Game can load savegame data if the version is equal or greater than this.
static SQInteger Constructor(HSQUIRRELVM vm)
Create an GSLibrary, using this GSInfo as start-template.
bool CanLoadFromVersion(int version) const
Check if we can start this Game.
const char * category
The category this library is in.
When randomizing the Script, pick any value between min_value and max_value when on custom difficulty...
This value is a boolean (either 0 (false) or 1 (true) ).
static void RegisterAPI(Squirrel *engine)
Register the functions of this class.
virtual class ScriptScanner * GetScanner()
Get the scanner which has found this ScriptInfo.
#define DEBUG(name, level,...)
Output a line of debugging information.
GameInfo keeps track of all information of an Game, like Author, Description, ... ...
SQInteger AddSetting(HSQUIRRELVM vm)
Set a setting.
declarations of the class for Game scanner
const char * api_version
API version used by this Game.
static const int MAX_GET_OPS
Number of operations to get the author and similar information.
bool MethodExists(HSQOBJECT instance, const char *method_name)
Check if a method exists in an instance.
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!)...
static bool CheckAPIVersion(const char *api_version)
Check if the API version provided by the Game is supported.
void AddClassBegin(const char *class_name)
Adds a class to the global scope.
This setting can be changed while the Script is running.
class Squirrel * engine
Engine used to register for Squirrel.
static SQInteger Constructor(HSQUIRRELVM vm, ScriptInfo *info)
Process the creation of a FileInfo object.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
void AddClassEnd()
Finishes adding a class to the global scope.