Register Static Library types.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-01-23 15:10:08 +01:00
parent 47db8464a2
commit af9fa61245
8 changed files with 216 additions and 12 deletions

View File

@@ -5,6 +5,7 @@
#include "TypeRegistry/Library/RegisterItemTypes.hpp"
#include "TypeRegistry/Library/RegisterMoveTypes.hpp"
#include "TypeRegistry/Library/RegisterSpeciesTypes.hpp"
#include "TypeRegistry/Library/RegisterStaticLibraryTypes.hpp"
#include "TypeRegistry/Library/RegisterTypeLibrary.hpp"
CreatureLib::Battling::ScriptResolver* PkmnLib::Battling::BattleLibrary::CreateScriptResolver() {
@@ -36,6 +37,7 @@ void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* librar
RegisterMoveTypes::Register(_engine);
RegisterGrowthRateTypes::Register(_engine);
RegisterTypeLibrary::Register(_engine);
RegisterStaticLibraryTypes::Register(_engine);
_mainModule = _engine->GetModule("pkmn", asGM_ALWAYS_CREATE);

View File

@@ -0,0 +1,43 @@
#include "RegisterStaticLibraryTypes.hpp"
#include <cassert>
#include "../../../Library/PokemonLibrary.hpp"
void RegisterStaticLibraryTypes::Register(asIScriptEngine* engine) {
RegisterLibrarySettingsType(engine);
RegisterLibraryType(engine);
}
void RegisterStaticLibraryTypes::RegisterLibrarySettingsType(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("LibrarySettings", 0, asOBJ_REF | asOBJ_NOCOUNT);
r = engine->RegisterObjectMethod("LibrarySettings", "uint8 get_MaximalLevel() const property",
asMETHOD(CreatureLib::Library::LibrarySettings, GetMaximalLevel), asCALL_THISCALL);
assert(r >= 0);
r = engine->RegisterObjectMethod("LibrarySettings", "uint8 get_MaximalMoves() const property",
asMETHOD(CreatureLib::Library::LibrarySettings, GetMaximalMoves), asCALL_THISCALL);
assert(r >= 0);
}
void RegisterStaticLibraryTypes::RegisterLibraryType(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("StaticLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("StaticLibrary", "const LibrarySettings& get_Settings() const property",
asMETHOD(PkmnLib::Library::PokemonLibrary, GetSettings), asCALL_THISCALL);
assert(r >= 0);
r = engine->RegisterObjectMethod("StaticLibrary", "const SpeciesLibrary@ get_SpeciesLibrary() const property",
asMETHOD(PkmnLib::Library::PokemonLibrary, GetSpeciesLibrary), asCALL_THISCALL);
assert(r >= 0);
r = engine->RegisterObjectMethod("StaticLibrary", "const MoveLibrary@ get_MoveLibrary() const property",
asMETHOD(PkmnLib::Library::PokemonLibrary, GetMoveLibrary), asCALL_THISCALL);
assert(r >= 0);
r = engine->RegisterObjectMethod("StaticLibrary", "const ItemLibrary@ get_ItemLibrary() const property",
asMETHOD(PkmnLib::Library::PokemonLibrary, GetItemLibrary), asCALL_THISCALL);
assert(r >= 0);
r = engine->RegisterObjectMethod("StaticLibrary", "const GrowthRateLibrary@ get_GrowthRateLibrary() const property",
asMETHOD(PkmnLib::Library::PokemonLibrary, GetGrowthRates), asCALL_THISCALL);
assert(r >= 0);
r = engine->RegisterObjectMethod("StaticLibrary", "const TypeLibrary@ get_TypeLibrary() const property",
asMETHOD(PkmnLib::Library::PokemonLibrary, GetTypeLibrary), asCALL_THISCALL);
assert(r >= 0);
}

View File

@@ -0,0 +1,12 @@
#ifndef PKMNLIB_REGISTERSTATICLIBRARYTYPES_HPP
#define PKMNLIB_REGISTERSTATICLIBRARYTYPES_HPP
#include <angelscript.h>
class RegisterStaticLibraryTypes {
static void RegisterLibrarySettingsType(asIScriptEngine* engine);
static void RegisterLibraryType(asIScriptEngine* engine);
public:
static void Register(asIScriptEngine* engine);
};
#endif // PKMNLIB_REGISTERSTATICLIBRARYTYPES_HPP