Allow to use scripting on arm64
This commit is contained in:
parent
6d306e64a7
commit
fc3b428360
1017
src/scriptengine/aswrappedcall.hpp
Normal file
1017
src/scriptengine/aswrappedcall.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -18,9 +18,11 @@
|
||||
|
||||
#include "script_audio.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
|
||||
#include <angelscript.h>
|
||||
#include <assert.h>
|
||||
#include <cstring>
|
||||
|
||||
/** \cond DOXYGEN_IGNORE */
|
||||
namespace Scripting
|
||||
@ -50,7 +52,15 @@ namespace Scripting
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
engine->SetDefaultNamespace("Audio");
|
||||
r = engine->RegisterGlobalFunction("void playSound(const string &in)", asFUNCTION(playSound), asCALL_CDECL); assert(r >= 0);
|
||||
|
||||
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||
{
|
||||
r = engine->RegisterGlobalFunction("void playSound(const string &in)", WRAP_FN(playSound), asCALL_GENERIC); assert(r >= 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = engine->RegisterGlobalFunction("void playSound(const string &in)", asFUNCTION(playSound), asCALL_CDECL); assert(r >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_object.hpp"
|
||||
#include "tracks/track_object_manager.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
|
||||
#include <angelscript.h>
|
||||
#include <assert.h>
|
||||
@ -107,11 +108,34 @@ namespace Scripting
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
void registerScriptFunctions_Generic(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
|
||||
engine->SetDefaultNamespace("Challenges");
|
||||
r = engine->RegisterGlobalFunction("int getCompletedChallengesCount()",
|
||||
WRAP_FN(getCompletedChallengesCount),
|
||||
asCALL_GENERIC);
|
||||
assert( r >= 0 );
|
||||
|
||||
r = engine->RegisterGlobalFunction("int getChallengeCount()",
|
||||
WRAP_FN(getChallengeCount),
|
||||
asCALL_GENERIC);
|
||||
assert( r >= 0 );
|
||||
|
||||
r = engine->RegisterGlobalFunction("bool isChallengeUnlocked(string &in)",
|
||||
WRAP_FN(isChallengeUnlocked),
|
||||
asCALL_GENERIC);
|
||||
assert( r >= 0 );
|
||||
|
||||
r = engine->RegisterGlobalFunction("int getChallengeRequiredPoints(string &in)",
|
||||
WRAP_FN(getChallengeRequiredPoints),
|
||||
asCALL_GENERIC);
|
||||
assert( r >= 0 );
|
||||
}
|
||||
|
||||
void registerScriptFunctions_Native(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
|
||||
r = engine->RegisterGlobalFunction("int getCompletedChallengesCount()",
|
||||
asFUNCTION(getCompletedChallengesCount),
|
||||
@ -129,7 +153,21 @@ namespace Scripting
|
||||
asFUNCTION(getChallengeRequiredPoints),
|
||||
asCALL_CDECL);
|
||||
assert(r >= 0);
|
||||
} // registerScriptFunctions
|
||||
}
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
{
|
||||
engine->SetDefaultNamespace("Challenges");
|
||||
|
||||
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||
{
|
||||
registerScriptFunctions_Generic(engine);
|
||||
}
|
||||
else
|
||||
{
|
||||
registerScriptFunctions_Native(engine);
|
||||
}
|
||||
} // registerScriptFunctions
|
||||
|
||||
} // namespace Challenges
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "io/file_manager.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
#include "scriptengine/script_audio.hpp"
|
||||
#include "scriptengine/script_challenges.hpp"
|
||||
#include "scriptengine/script_kart.hpp"
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "input/input_device.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_object.hpp"
|
||||
@ -166,10 +167,24 @@ namespace Scripting
|
||||
}
|
||||
/** \endcond */
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
void registerScriptFunctions_Generic(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
engine->SetDefaultNamespace("GUI");
|
||||
|
||||
r = engine->RegisterGlobalFunction("void displayModalMessage(const string &in)", WRAP_FN(displayModalMessage), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void displayOverlayMessage(const string &in)", WRAP_FN(displayOverlayMessage), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void clearOverlayMessages()", WRAP_FN(clearOverlayMessages), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string getKeyBinding(int input)", WRAP_FN(getKeyBinding), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string translate(const string &in)", WRAP_FN(proxy_translate), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string translate(const string &in, const string &in)", WRAP_FN(proxy_translateAndInsertValues1), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string translate(const string &in, const string &in, const string &in)", WRAP_FN(proxy_translateAndInsertValues2), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string translate(const string &in, const string &in, const string &in, const string &in)", WRAP_FN(proxy_translateAndInsertValues3), asCALL_GENERIC); assert(r >= 0);
|
||||
}
|
||||
|
||||
void registerScriptFunctions_Native(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
|
||||
r = engine->RegisterGlobalFunction("void displayModalMessage(const string &in)", asFUNCTION(displayModalMessage), asCALL_CDECL); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void displayOverlayMessage(const string &in)", asFUNCTION(displayOverlayMessage), asCALL_CDECL); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void clearOverlayMessages()", asFUNCTION(clearOverlayMessages), asCALL_CDECL); assert(r >= 0);
|
||||
@ -180,6 +195,20 @@ namespace Scripting
|
||||
r = engine->RegisterGlobalFunction("string translate(const string &in, const string &in, const string &in, const string &in)", asFUNCTION(proxy_translateAndInsertValues3), asCALL_CDECL); assert(r >= 0);
|
||||
}
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
{
|
||||
engine->SetDefaultNamespace("GUI");
|
||||
|
||||
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||
{
|
||||
registerScriptFunctions_Generic(engine);
|
||||
}
|
||||
else
|
||||
{
|
||||
registerScriptFunctions_Native(engine);
|
||||
}
|
||||
}
|
||||
|
||||
void registerScriptEnums(asIScriptEngine *engine)
|
||||
{
|
||||
// TODO: document enum in doxygen-generated scripting docs
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "scriptvec3.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <angelscript.h>
|
||||
@ -129,10 +130,23 @@ namespace Scripting
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
void registerScriptFunctions_Generic(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
engine->SetDefaultNamespace("Kart");
|
||||
|
||||
r = engine->RegisterGlobalFunction("void squash(int id, float time)", WRAP_FN(squash), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void teleport(int id, const Vec3 &in)", WRAP_FN(teleport), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void setVelocity(int id, const Vec3 &in)", WRAP_FN(setVelocity), asCALL_GENERIC); assert(r >= 0);
|
||||
//r = engine->RegisterGlobalFunction("void jumpTo(int id, float x, float y)", WRAP_FN(jumpTo), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("Vec3 getLocation(int id)", WRAP_FN(getLocation), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("Vec3 getVelocity(int id)", WRAP_FN(getVelocity), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("float getMaxSpeed(int id)", WRAP_FN(getMaxSpeed), asCALL_GENERIC); assert(r >= 0);
|
||||
}
|
||||
|
||||
void registerScriptFunctions_Native(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
|
||||
r = engine->RegisterGlobalFunction("void squash(int id, float time)", asFUNCTION(squash), asCALL_CDECL); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void teleport(int id, const Vec3 &in)", asFUNCTION(teleport), asCALL_CDECL); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void setVelocity(int id, const Vec3 &in)", asFUNCTION(setVelocity), asCALL_CDECL); assert(r >= 0);
|
||||
@ -142,6 +156,20 @@ namespace Scripting
|
||||
r = engine->RegisterGlobalFunction("float getMaxSpeed(int id)", asFUNCTION(getMaxSpeed), asCALL_CDECL); assert(r >= 0);
|
||||
}
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
{
|
||||
engine->SetDefaultNamespace("Kart");
|
||||
|
||||
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||
{
|
||||
registerScriptFunctions_Generic(engine);
|
||||
}
|
||||
else
|
||||
{
|
||||
registerScriptFunctions_Native(engine);
|
||||
}
|
||||
}
|
||||
|
||||
void registerScriptEnums(asIScriptEngine *engine)
|
||||
{
|
||||
// TODO: document enum in doxygen-generated scripting docs
|
||||
|
@ -19,9 +19,10 @@
|
||||
#include <assert.h>
|
||||
#include <angelscript.h>
|
||||
#include "script_physics.hpp"
|
||||
#include "graphics/explosion.hpp"
|
||||
#include "graphics/hit_effect.hpp"
|
||||
#include "items/projectile_manager.hpp"
|
||||
#include "graphics/explosion.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
|
||||
namespace Scripting
|
||||
{
|
||||
@ -41,7 +42,15 @@ namespace Scripting
|
||||
{
|
||||
int r;
|
||||
engine->SetDefaultNamespace("Physics");
|
||||
r = engine->RegisterGlobalFunction("string createExplosion(Vec3 &in)", asFUNCTION(createExplosion), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||
{
|
||||
r = engine->RegisterGlobalFunction("string createExplosion(Vec3 &in)", WRAP_FN(createExplosion), asCALL_GENERIC); assert(r >= 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = engine->RegisterGlobalFunction("string createExplosion(Vec3 &in)", asFUNCTION(createExplosion), asCALL_GENERIC); assert(r >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "input/input_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "scriptengine/property_animator.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
|
||||
#include "states_screens/dialogs/race_paused_dialog.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -448,19 +449,88 @@ namespace Scripting
|
||||
/** @}*/
|
||||
/** @}*/
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
void registerScriptFunctions_Generic(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
|
||||
engine->SetDefaultNamespace("Track");
|
||||
//r = engine->RegisterGlobalFunction("void disableTrackObject(const string &in)", WRAP_FN(disableTrackObject), asCALL_GENERIC); assert(r >= 0);
|
||||
//r = engine->RegisterGlobalFunction("void enableTrackObject(const string &in)", WRAP_FN(enableTrackObject), asCALL_GENERIC); assert(r >= 0);
|
||||
//r = engine->RegisterGlobalFunction("void enableTrigger(const string &in)", WRAP_FN(enableTrigger), asCALL_GENERIC); assert(r >= 0);
|
||||
//r = engine->RegisterGlobalFunction("void disableTrigger(const string &in)", WRAP_FN(disableTrigger), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void createTrigger(const string &in, const Vec3 &in, float distance)",
|
||||
WRAP_FN(createTrigger), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void createTextBillboard(const string &in, const Vec3 &in)",
|
||||
WRAP_FN(createTextBillboard), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void setTriggerReenableTimeout(const string &in, const string &in, float reenable_time)",
|
||||
WRAP_FN(setTriggerReenableTimeout), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("TrackObject@ getTrackObject(const string &in, const string &in)", WRAP_FN(getTrackObject), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void exitRace()", WRAP_FN(exitRace), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void pauseRace()", WRAP_FN(pauseRace), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void setFog(float maxDensity, float start, float end, int r, int g, int b, float duration)", WRAP_FN(setFog), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("int getNumberOfKarts()", WRAP_FN(getNumberOfKarts), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("int getNumLocalPlayers()", WRAP_FN(getNumLocalPlayers), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("bool isReverse()", WRAP_FN(isTrackReverse), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("int getMajorRaceMode()", WRAP_FN(getMajorRaceMode), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("int getMinorRaceMode()", WRAP_FN(getMinorRaceMode), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("bool isDuringDay()", WRAP_FN(isDuringDay), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
r = engine->RegisterObjectType("TrackObject", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("PhysicalObject", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("Mesh", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); // TrackObjectPresentationMesh
|
||||
r = engine->RegisterObjectType("ParticleEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("SoundEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("Animator", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("Light", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
// TrackObject
|
||||
r = engine->RegisterObjectMethod("TrackObject", "void setEnabled(bool status)", WRAP_MFN(::TrackObject, setEnabled), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "SoundEmitter@ getSoundEmitter()", WRAP_MFN(::TrackObject, getSoundEmitter), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Light@ getLight()", WRAP_MFN(::TrackObject, getLight), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "PhysicalObject@ getPhysics()", WRAP_MFN(::TrackObject, getPhysics), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Mesh@ getMesh()", WRAP_MFN(::TrackObject, getMesh), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "ParticleEmitter@ getParticleEmitter()", WRAP_MFN(::TrackObject, getParticleEmitter), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Animator@ getIPOAnimator()", WRAP_MFN(::TrackObject, getIPOAnimator), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "void moveTo(const Vec3 &in, bool)", WRAP_MFN(::TrackObject, moveTo), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Vec3 getCenterPosition()", WRAP_OBJ_LAST(TrackObject::getCenterPosition), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Vec3 getOrigin()", WRAP_OBJ_LAST(TrackObject::getOrigin), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "TrackObject@ getParentLibrary()", WRAP_MFN(::TrackObject, getParentLibrary), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "string getName()", WRAP_MFN(::TrackObject, getName), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
// PhysicalObject
|
||||
r = engine->RegisterObjectMethod("PhysicalObject", "bool isFlattenKartObject()", WRAP_MFN(PhysicalObject, isFlattenKartObject), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("PhysicalObject", "void disable()", WRAP_MFN(PhysicalObject, disable), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("PhysicalObject", "void enable()", WRAP_MFN(PhysicalObject, enable), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
// Animated Mesh
|
||||
r = engine->RegisterObjectMethod("Mesh", "void setFrameLoop(int start, int end)", WRAP_OBJ_LAST(Mesh::setFrameLoop), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void setFrameLoopOnce(int start, int end)", WRAP_OBJ_LAST(Mesh::setFrameLoopOnce), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "int getFrameNr()", WRAP_OBJ_LAST(Mesh::getFrameNr), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "int getAnimationSet()", WRAP_OBJ_LAST(Mesh::getAnimationSet), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void useAnimationSet(int set_num)", WRAP_OBJ_LAST(Mesh::useAnimationSet), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void addAnimationSet(int start, int end)", WRAP_OBJ_LAST(Mesh::addAnimationSet), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void removeAllAnimationSet()", WRAP_OBJ_LAST(Mesh::removeAllAnimationSet), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Mesh", "void setCurrentFrame(int frame)", WRAP_OBJ_LAST(Mesh::setCurrentFrame), asCALL_GENERIC); assert(r >= 0);
|
||||
//r = engine->RegisterObjectMethod("Mesh", "void move(Vec3 &in)", WRAP_OBJ_LAST(movePresentation), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
// Particle Emitter
|
||||
r = engine->RegisterObjectMethod("ParticleEmitter", "void stop()", WRAP_OBJ_LAST(ParticleEmitter::stop), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ParticleEmitter", "void stopIn(float)", WRAP_OBJ_LAST(ParticleEmitter::stopIn), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("ParticleEmitter", "void setEmissionRate(float)", WRAP_OBJ_LAST(ParticleEmitter::setEmissionRate), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
// Sound Effect
|
||||
//r = engine->RegisterObjectMethod("SoundEmitter", "void move(Vec3 &in)", WRAP_OBJ_LAST(movePresentation), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("SoundEmitter", "void stop()", WRAP_OBJ_LAST(SoundEmitter::stop), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("SoundEmitter", "void playOnce()", WRAP_OBJ_LAST(SoundEmitter::playOnce), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("SoundEmitter", "void playLoop()", WRAP_OBJ_LAST(SoundEmitter::playLoop), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
// Light
|
||||
r = engine->RegisterObjectMethod("Light", "void setEnergy(float)", WRAP_OBJ_LAST(Light::setEnergy), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Light", "void animateEnergy(float, float)", WRAP_OBJ_LAST(Light::animateEnergy), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
// Curve based Animation
|
||||
//fails due to insufficient visibility to scripts TODO : Decide whether to fix visibility or introduce wrappers
|
||||
//r = engine->RegisterObjectMethod("Animator", "void setPaused(bool mode)", WRAP_MFN(ThreeDAnimation, setPaused), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Animator", "void setPaused(bool mode)", WRAP_OBJ_LAST(Animator::setPaused), asCALL_GENERIC); assert(r >= 0);
|
||||
// TODO: add method to set current frame
|
||||
// TODO: add method to launch playback from frame X to frame Y
|
||||
// TODO: add method to register onAnimationComplete notifications ?
|
||||
}
|
||||
|
||||
void registerScriptFunctions_Native(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
|
||||
//r = engine->RegisterGlobalFunction("void disableTrackObject(const string &in)", asFUNCTION(disableTrackObject), asCALL_CDECL); assert(r >= 0);
|
||||
//r = engine->RegisterGlobalFunction("void enableTrackObject(const string &in)", asFUNCTION(enableTrackObject), asCALL_CDECL); assert(r >= 0);
|
||||
@ -537,6 +607,30 @@ namespace Scripting
|
||||
// TODO: add method to register onAnimationComplete notifications ?
|
||||
}
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
|
||||
engine->SetDefaultNamespace("Track");
|
||||
|
||||
r = engine->RegisterObjectType("TrackObject", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("PhysicalObject", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("Mesh", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); // TrackObjectPresentationMesh
|
||||
r = engine->RegisterObjectType("ParticleEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("SoundEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("Animator", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("Light", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
|
||||
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||
{
|
||||
registerScriptFunctions_Generic(engine);
|
||||
}
|
||||
else
|
||||
{
|
||||
registerScriptFunctions_Native(engine);
|
||||
}
|
||||
}
|
||||
|
||||
/** \cond DOXYGEN_IGNORE */
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_device.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
#include "scriptengine/script_engine.hpp"
|
||||
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -136,6 +137,15 @@ namespace Scripting
|
||||
ScriptEngine::getInstance()->addPendingTimeout(delay, obj);
|
||||
}
|
||||
|
||||
void setTimeoutDelegate_Generic(asIScriptGeneric *gen)
|
||||
{
|
||||
asIScriptFunction *obj = (asIScriptFunction*)gen->GetArgAddress(0);
|
||||
float delay = gen->GetArgFloat(1);
|
||||
obj->AddRef();
|
||||
ScriptEngine::getInstance()->addPendingTimeout(delay, obj);
|
||||
}
|
||||
|
||||
|
||||
/** Log to the console */
|
||||
void logInfo(std::string* log)
|
||||
{
|
||||
@ -180,10 +190,33 @@ namespace Scripting
|
||||
}
|
||||
/** \endcond */
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
void registerScriptFunctions_Generic(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
|
||||
r = engine->RegisterGlobalFunction("string insertValues(const string &in, const string &in)", WRAP_FN(proxy_insertValues1), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string insertValues(const string &in, const string &in, const string &in)", WRAP_FN(proxy_insertValues2), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string insertValues(const string &in, const string &in, const string &in, const string &in)", WRAP_FN(proxy_insertValues3), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string insertValues(const string &in, const string &in, const string &in, const string &in, const string &in)", WRAP_FN(proxy_insertValues4), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
r = engine->RegisterGlobalFunction("void runScript(string &in)", WRAP_FN(runScript), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
r = engine->RegisterGlobalFunction("int randomInt(int, int)", WRAP_FN(randomInt), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("float randomFloat(int, int)", WRAP_FN(randomFloat), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void setTimeout(const string &in, float)", WRAP_FN(setTimeout), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
r = engine->RegisterFuncdef("void TimeoutCallback()"); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void setTimeoutDelegate(TimeoutCallback@, float)", asFUNCTION(setTimeoutDelegate_Generic), asCALL_GENERIC); assert(r >= 0);
|
||||
//~ r = engine->RegisterGlobalFunction("void setTimeoutDelegate(TimeoutCallback@, float)", WRAP_FN(setTimeoutDelegate), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
r = engine->RegisterGlobalFunction("void logInfo(const string &in)", WRAP_FN(logInfo), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void logWarning(const string &in)", WRAP_FN(logWarning), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void logError(const string &in)", WRAP_FN(logError), asCALL_GENERIC); assert(r >= 0);
|
||||
}
|
||||
|
||||
void registerScriptFunctions_Native(asIScriptEngine *engine)
|
||||
{
|
||||
int r; // of type asERetCodes
|
||||
engine->SetDefaultNamespace("Utils");
|
||||
|
||||
r = engine->RegisterGlobalFunction("string insertValues(const string &in, const string &in)", asFUNCTION(proxy_insertValues1), asCALL_CDECL); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string insertValues(const string &in, const string &in, const string &in)", asFUNCTION(proxy_insertValues2), asCALL_CDECL); assert(r >= 0);
|
||||
@ -203,6 +236,20 @@ namespace Scripting
|
||||
r = engine->RegisterGlobalFunction("void logWarning(const string &in)", asFUNCTION(logWarning), asCALL_CDECL); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void logError(const string &in)", asFUNCTION(logError), asCALL_CDECL); assert(r >= 0);
|
||||
}
|
||||
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
{
|
||||
engine->SetDefaultNamespace("Utils");
|
||||
|
||||
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||
{
|
||||
registerScriptFunctions_Generic(engine);
|
||||
}
|
||||
else
|
||||
{
|
||||
registerScriptFunctions_Native(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** \cond DOXYGEN_IGNORE */
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "karts/kart.hpp"
|
||||
#include "script_kart.hpp"
|
||||
#include "scriptvec3.hpp"
|
||||
#include "scriptengine/aswrappedcall.hpp"
|
||||
|
||||
//debug
|
||||
#include <iostream>
|
||||
@ -59,10 +60,24 @@ namespace Scripting
|
||||
float getZ(SimpleVec3* v) { return v->getZ(); }
|
||||
float getLength(SimpleVec3* v) { return v->getLength(); }
|
||||
|
||||
void RegisterVec3(asIScriptEngine *engine)
|
||||
void RegisterVec3_Generic(asIScriptEngine *engine)
|
||||
{
|
||||
int r;
|
||||
// Register the behaviours
|
||||
r = engine->RegisterObjectBehaviour("Vec3", asBEHAVE_CONSTRUCT, "void f()", WRAP_OBJ_LAST(Constructor), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectBehaviour("Vec3", asBEHAVE_DESTRUCT, "void f()", WRAP_OBJ_LAST(Destructor), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Vec3", "Vec3 &opAssign(const Vec3 &in)", WRAP_MFN_PR(SimpleVec3, operator =, (const SimpleVec3&), SimpleVec3&), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectBehaviour("Vec3", asBEHAVE_CONSTRUCT, "void f(float, float, float)", WRAP_OBJ_LAST(ConstructVector3FromFloats), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void printVec3(Vec3 a)", WRAP_FN(printVec3), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Vec3", "float getX()", WRAP_OBJ_LAST(getX), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Vec3", "float getY()", WRAP_OBJ_LAST(getY), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Vec3", "float getZ()", WRAP_OBJ_LAST(getZ), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Vec3", "float getLength()", WRAP_OBJ_LAST(getLength), asCALL_GENERIC); assert(r >= 0);
|
||||
}
|
||||
|
||||
void RegisterVec3_Native(asIScriptEngine *engine)
|
||||
{
|
||||
int r;
|
||||
r = engine->RegisterObjectType("Vec3", sizeof(SimpleVec3), asOBJ_VALUE | asOBJ_APP_CLASS_ALLFLOATS | asOBJ_APP_CLASS_CDA); assert(r >= 0);
|
||||
// Register the behaviours
|
||||
r = engine->RegisterObjectBehaviour("Vec3", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(Constructor), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectBehaviour("Vec3", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(Destructor), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
@ -74,4 +89,19 @@ namespace Scripting
|
||||
r = engine->RegisterObjectMethod("Vec3", "float getZ()", asFUNCTION(getZ), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Vec3", "float getLength()", asFUNCTION(getLength), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
}
|
||||
|
||||
void RegisterVec3(asIScriptEngine *engine)
|
||||
{
|
||||
int r;
|
||||
r = engine->RegisterObjectType("Vec3", sizeof(SimpleVec3), asOBJ_VALUE | asOBJ_APP_CLASS_ALLFLOATS | asOBJ_APP_CLASS_CDA); assert(r >= 0);
|
||||
|
||||
if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY"))
|
||||
{
|
||||
RegisterVec3_Generic(engine);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegisterVec3_Native(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user