25 return std::ranges::find(GameInfo::ApiVersions, api_version) != std::end(GameInfo::ApiVersions);
28template <> SQInteger PushClassName<GameInfo, ScriptType::GS>(HSQUIRRELVM vm) { sq_pushstring(vm,
"GSInfo");
return 1; }
34 SQGSInfo.PreRegister(
engine);
35 SQGSInfo.AddConstructor<void (GameInfo::*)()>(
engine,
"x");
38 SQGSInfo.DefSQConst(
engine, ScriptConfigFlags{}.base(),
"CONFIG_NONE");
39 SQGSInfo.DefSQConst(
engine, ScriptConfigFlags{}.base(),
"CONFIG_RANDOM");
44 SQGSInfo.PostRegister(
engine);
51 SQUserPointer instance =
nullptr;
52 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");
53 GameInfo *info = (GameInfo *)instance;
56 if (res != 0)
return res;
71 if (!info->
CheckMethod(
"GetAPIVersion"))
return SQ_ERROR;
74 sq_throwerror(vm, fmt::format(
"Loading info.nut from ({}.{}): GetAPIVersion returned invalid version", info->
GetName(), info->
GetVersion()));
79 sq_setinstanceup(vm, 2,
nullptr);
86 min_loadable_version(0),
87 is_developer_only(false)
101 engine.AddClassBegin(
"GSLibrary");
109 auto library = std::make_unique<GameLibrary>();
117 if (!library->CheckMethod(
"GetCategory") || !library->engine->CallStringMethod(library->SQ_instance,
"GetCategory", &library->category,
MAX_GET_OPS)) {
123 scanner->RegisterScript(std::move(library));
static bool CheckAPIVersion(const std::string &api_version)
Check if the API version provided by the AI is supported.
The template to define classes in Squirrel.
void DefSQAdvancedMethod(Squirrel &engine, Func function_proc, std::string_view function_name, bool suspendable=false)
This defines a method inside a class for Squirrel, which has access to the 'engine' (experts only!...
std::string api_version
API version used by this Game.
static SQInteger Constructor(HSQUIRRELVM vm)
Create an Game, using this GameInfo as start-template.
bool CanLoadFromVersion(int version) const
Check if we can start this Game.
static void RegisterAPI(Squirrel &engine)
Register the functions of this class.
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.
static void RegisterAPI(Squirrel &engine)
Register the functions of this class.
static SQInteger Constructor(HSQUIRRELVM vm)
Create an GSLibrary, using this GSInfo as start-template.
bool CheckMethod(std::string_view name) const
Check if a given method exists.
int version
Version of the script.
class ScriptScanner * scanner
ScriptScanner object that was used to scan this script info.
const std::string & GetName() const
Get the Name of the script.
class Squirrel * engine
Engine used to register for Squirrel.
static SQInteger Constructor(HSQUIRRELVM vm, ScriptInfo &info)
Process the creation of a FileInfo object.
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.
HSQOBJECT SQ_instance
The Squirrel instance created for this info.
virtual class ScriptScanner * GetScanner()
Get the scanner which has found this ScriptInfo.
Scanner to help finding scripts.
void RegisterScript(std::unique_ptr< class ScriptInfo > &&info)
Register a ScriptInfo to the scanner.
bool MethodExists(HSQOBJECT instance, std::string_view method_name)
Check if a method exists in an instance.
Functions related to debugging.
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 GS scanner.
A number of safeguards to prevent using unsafe methods.
@ Boolean
This value is a boolean (either 0 (false) or 1 (true) ).
@ Developer
This setting will only be visible when the Script development tools are active.
@ InGame
This setting can be changed while the Script is running.
static const int MAX_GET_OPS
Number of operations to get the author and similar information.
Defines templates for converting C++ classes to Squirrel classes.
Definition of base types and functions in a cross-platform compatible way.