This commit is contained in:
@@ -77,7 +77,7 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"Battle", "const constString& GetWeatherName() const",
|
||||
asMETHODPR(PkmnLib::Battling::Battle, GetWeatherName, (), const Arbutils::CaseInsensitiveConstString&),
|
||||
asMETHODPR(PkmnLib::Battling::Battle, GetWeatherName, (), const ArbUt::CaseInsensitiveConstString&),
|
||||
asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../../../../../extern/angelscript_addons/scriptarray/scriptarray.h"
|
||||
#include "../../../../Battling/PkmnDamageSource.hpp"
|
||||
#include "../../../../Battling/Pokemon/Pokemon.hpp"
|
||||
#include "../HelperFile.hpp"
|
||||
|
||||
// Hack to handle AngelScript not recognizing different sized enums on fields, and returning invalid values due to it.
|
||||
#define ENUM__SIZE_WRAPPER(name, type, func) \
|
||||
@@ -92,14 +93,18 @@ static bool HasHeldItem(const PkmnLib::Battling::Pokemon* obj, const ConstString
|
||||
return obj->HasHeldItem(str.GetHash());
|
||||
}
|
||||
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies);
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const PkmnLib::Library::PokemonForme, GetForme);
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::Item, GetHeldItem);
|
||||
|
||||
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "const Species@ get_Species() const property",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, GetSpecies), asCALL_THISCALL);
|
||||
asFUNCTION(GetSpeciesWrapper), asCALL_CDECL_OBJLAST);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "const Forme@ get_Forme() const property",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, GetForme), asCALL_THISCALL);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "const Forme@ get_Forme() const property", asFUNCTION(GetFormeWrapper),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "uint8 get_Level() const property",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, GetLevel), asCALL_THISCALL);
|
||||
@@ -117,20 +122,20 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, IsShiny), asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "const Item@ get_HeldItem() const property",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, GetHeldItem), asCALL_THISCALL);
|
||||
asFUNCTION(GetHeldItemWrapper), asCALL_CDECL_OBJLAST);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "bool HasHeldItem(const constString &in name) const",
|
||||
asFUNCTION(HasHeldItem), asCALL_CDECL_OBJFIRST);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"Pokemon", "void SetHeldItem(const string &in name)",
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, SetHeldItem, (const Arbutils::CaseInsensitiveConstString&), void),
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, SetHeldItem, (const ArbUt::CaseInsensitiveConstString&), void),
|
||||
asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"Pokemon", "void SetHeldItem(const Item@ item)",
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, SetHeldItem, (const CreatureLib::Library::Item*), void),
|
||||
asCALL_THISCALL);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const Item@ item)",
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, SetHeldItem,
|
||||
(const ArbUt::BorrowedPtr<const CreatureLib::Library::Item>&), void),
|
||||
asCALL_THISCALL);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Pokemon", "uint32 get_CurrentHealth() const property",
|
||||
asMETHOD(PkmnLib::Battling::Pokemon, GetCurrentHealth), asCALL_THISCALL);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "ConstString.hpp"
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
using ConstString = ArbUt::CaseInsensitiveConstString;
|
||||
|
||||
static void ConstructConstString(void* self) { new (self) ConstString(); }
|
||||
static void CopyConstructConstString(const ConstString& other, void* self) { new (self) ConstString(other); }
|
||||
@@ -11,7 +11,7 @@ static std::string ImplConstStringStdStringConv(const ConstString& s) { return s
|
||||
static uint32_t ImplConstStringHashConv(const ConstString& s) { return s.GetHash(); }
|
||||
|
||||
void ConstStringRegister::Register(asIScriptEngine* engine) {
|
||||
auto r = engine->RegisterObjectType("constString", sizeof(Arbutils::CaseInsensitiveConstString),
|
||||
auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::CaseInsensitiveConstString),
|
||||
asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
|
||||
Assert(r >= 0);
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#define SMART_PTR_GETTER_FUNC(o, returns, funcName) \
|
||||
static returns* funcName##Wrapper(o* obj) { return obj->funcName().operator->(); }
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
static CreatureLib::Library::EffectParameter* Ref_Factory() { return new CreatureLib::Library::EffectParameter(); }
|
||||
|
||||
static const Arbutils::CaseInsensitiveConstString& AsString(const CreatureLib::Library::EffectParameter* p) {
|
||||
static const ArbUt::CaseInsensitiveConstString& AsString(const CreatureLib::Library::EffectParameter* p) {
|
||||
return p->AsString();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ void RegisterEffectParameter::Register(asIScriptEngine* engine) {
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("EffectParameter", "const constString& AsString() const",
|
||||
asFUNCTIONPR(AsString, (const CreatureLib::Library::EffectParameter*),
|
||||
const Arbutils::CaseInsensitiveConstString&),
|
||||
const ArbUt::CaseInsensitiveConstString&),
|
||||
asCALL_CDECL_OBJFIRST);
|
||||
Assert(r >= 0);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ void RegisterItemTypes::RegisterBattleItemCategoryEnum(asIScriptEngine* engine)
|
||||
ENUM__SIZE_WRAPPER(Move_CategoryWrapper, PkmnLib::Library::Item, GetCategory)
|
||||
ENUM__SIZE_WRAPPER(Move_BattleCategoryWrapper, PkmnLib::Library::Item, GetBattleCategory)
|
||||
|
||||
static bool HasFlag(const PkmnLib::Library::Item* obj, const Arbutils::CaseInsensitiveConstString& str) {
|
||||
static bool HasFlag(const PkmnLib::Library::Item* obj, const ArbUt::CaseInsensitiveConstString& str) {
|
||||
return obj->HasFlag(str);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void RegisterMoveTypes::RegisterMoveTarget(asIScriptEngine* engine) {
|
||||
ENUM__SIZE_WRAPPER(Move_CategoryWrapper, PkmnLib::Library::MoveData, GetCategory)
|
||||
ENUM__SIZE_WRAPPER(Move_TargetWrapper, PkmnLib::Library::MoveData, GetTarget)
|
||||
|
||||
static bool HasFlag(const PkmnLib::Library::MoveData* obj, const Arbutils::CaseInsensitiveConstString& str) {
|
||||
static bool HasFlag(const PkmnLib::Library::MoveData* obj, const ArbUt::CaseInsensitiveConstString& str) {
|
||||
return obj->HasFlag(str);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../../../../Library/Species/PokemonSpecies.hpp"
|
||||
#include "../../../../Library/Species/SpeciesLibrary.hpp"
|
||||
#include "../../../../Library/Statistic.hpp"
|
||||
#include "../HelperFile.hpp"
|
||||
|
||||
void RegisterSpeciesTypes::Register(asIScriptEngine* engine) {
|
||||
RegisterGenderEnum(engine);
|
||||
@@ -42,8 +43,11 @@ void RegisterSpeciesTypes::RegisterStatisticEnum(asIScriptEngine* engine) {
|
||||
|
||||
static const PkmnLib::Library::PokemonForme* GetFormeWrapper(const std::string& s,
|
||||
const PkmnLib::Library::PokemonSpecies* species) {
|
||||
return species->GetForme(Arbutils::CaseInsensitiveConstString(s.c_str(), s.length()));
|
||||
return species->GetForme(ArbUt::CaseInsensitiveConstString(s.c_str(), s.length()))
|
||||
.As<const PkmnLib::Library::PokemonForme>()
|
||||
.GetRaw();
|
||||
}
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonSpecies, const PkmnLib::Library::PokemonForme, GetDefaultForme);
|
||||
|
||||
void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
@@ -66,12 +70,12 @@ void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) {
|
||||
r = engine->RegisterObjectMethod("Species", "const Forme@ GetForme(string key) const", asFUNCTION(GetFormeWrapper),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Species", "const Forme@ GetDefaultForme() const",
|
||||
asMETHOD(PkmnLib::Library::PokemonSpecies, GetDefaultForme), asCALL_THISCALL);
|
||||
r = engine->RegisterObjectMethod("Species", "const Forme@ get_DefaultForme() const property",
|
||||
asFUNCTION(GetDefaultFormeWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
const ConstString& GetAbility(PkmnLib::Library::PokemonForme* p, bool hidden, uint8_t index) {
|
||||
const ArbUt::CaseInsensitiveConstString& GetAbility(PkmnLib::Library::PokemonForme* p, bool hidden, uint8_t index) {
|
||||
return p->GetAbility(CreatureLib::Library::TalentIndex(hidden, index));
|
||||
}
|
||||
|
||||
@@ -99,10 +103,11 @@ void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) {
|
||||
r = engine->RegisterObjectMethod("Forme", "uint GetStatistic(Statistic stat) const",
|
||||
asMETHOD(PkmnLib::Library::PokemonForme, GetStatistic), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"Forme", "const constString& GetAbility(bool hidden, uint8 index) const",
|
||||
asFUNCTIONPR(GetAbility, (PkmnLib::Library::PokemonForme * p, bool hidden, uint8_t index), const ConstString&),
|
||||
asCALL_CDECL_OBJFIRST);
|
||||
r = engine->RegisterObjectMethod("Forme", "const constString& GetAbility(bool hidden, uint8 index) const",
|
||||
asFUNCTIONPR(GetAbility,
|
||||
(PkmnLib::Library::PokemonForme * p, bool hidden, uint8_t index),
|
||||
const ArbUt::CaseInsensitiveConstString&),
|
||||
asCALL_CDECL_OBJFIRST);
|
||||
assert(r >= 0);
|
||||
}
|
||||
void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "RegisterStaticLibraryTypes.hpp"
|
||||
#include <cassert>
|
||||
#include "../../../../Library/PokemonLibrary.hpp"
|
||||
#include "../HelperFile.hpp"
|
||||
|
||||
void RegisterStaticLibraryTypes::Register(asIScriptEngine* engine) {
|
||||
RegisterLibrarySettingsType(engine);
|
||||
@@ -20,25 +21,32 @@ void RegisterStaticLibraryTypes::RegisterLibrarySettingsType(asIScriptEngine* en
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::LibrarySettings, GetSettings);
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::SpeciesLibrary, GetSpeciesLibrary);
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::MoveLibrary, GetMoveLibrary);
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::ItemLibrary, GetItemLibrary);
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const CreatureLib::Library::GrowthRateLibrary, GetGrowthRates);
|
||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const CreatureLib::Library::TypeLibrary, GetTypeLibrary);
|
||||
|
||||
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);
|
||||
asFUNCTION(GetSettingsWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("StaticLibrary", "const SpeciesLibrary@ get_SpeciesLibrary() const property",
|
||||
asMETHOD(PkmnLib::Library::PokemonLibrary, GetSpeciesLibrary), asCALL_THISCALL);
|
||||
asFUNCTION(GetSpeciesLibraryWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("StaticLibrary", "const MoveLibrary@ get_MoveLibrary() const property",
|
||||
asMETHOD(PkmnLib::Library::PokemonLibrary, GetMoveLibrary), asCALL_THISCALL);
|
||||
asFUNCTION(GetMoveLibraryWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("StaticLibrary", "const ItemLibrary@ get_ItemLibrary() const property",
|
||||
asMETHOD(PkmnLib::Library::PokemonLibrary, GetItemLibrary), asCALL_THISCALL);
|
||||
asFUNCTION(GetItemLibraryWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("StaticLibrary", "const GrowthRateLibrary@ get_GrowthRateLibrary() const property",
|
||||
asMETHOD(PkmnLib::Library::PokemonLibrary, GetGrowthRates), asCALL_THISCALL);
|
||||
asFUNCTION(GetGrowthRatesWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("StaticLibrary", "const TypeLibrary@ get_TypeLibrary() const property",
|
||||
asMETHOD(PkmnLib::Library::PokemonLibrary, GetTypeLibrary), asCALL_THISCALL);
|
||||
asFUNCTION(GetTypeLibraryWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
void RegisterTypeLibrary::Register(asIScriptEngine* engine) { RegisterTypeLibraryType(engine); }
|
||||
|
||||
static bool GetTypeId(const CreatureLib::Library::TypeLibrary* obj, const Arbutils::CaseInsensitiveConstString& str) {
|
||||
static bool GetTypeId(const CreatureLib::Library::TypeLibrary* obj, const ArbUt::CaseInsensitiveConstString& str) {
|
||||
return obj->GetTypeId(str);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user