Skip to content

Commit

Permalink
Merge tag 'dev/15.0-dev610' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
emcifuntik committed Sep 10, 2023
2 parents 8ebe3cf + 132b88b commit a6e306e
Show file tree
Hide file tree
Showing 23 changed files with 685 additions and 105 deletions.
23 changes: 23 additions & 0 deletions client/src/bindings/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include "helpers/BindHelpers.h"
#include "V8ResourceImpl.h"
#include "V8Class.h"

#include "../CV8ScriptRuntime.h"

#include "cpp-sdk/script-objects/IAudio.h"
#include "cpp-sdk/script-objects/IAudioOutput.h"

Expand Down Expand Up @@ -133,6 +135,25 @@ static void AudioCountGetter(v8::Local<v8::String> name, const v8::PropertyCallb
V8_RETURN_UINT(alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO).size());
}

static void StaticGetByID(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_ARGS_LEN(1);

V8_ARG_TO_INT(1, id);

alt::IBaseObject* baseObject = alt::ICore::Instance().GetBaseObjectByID(alt::IBaseObject::Type::AUDIO, id);

if(baseObject)
{
V8_RETURN_BASE_OBJECT(baseObject);
}
else
{
V8_RETURN_NULL();
}
}

extern V8Class v8BaseObject;
extern V8Class v8Audio("Audio",
v8BaseObject,
Expand All @@ -142,6 +163,8 @@ extern V8Class v8Audio("Audio",
using namespace alt;
v8::Isolate* isolate = v8::Isolate::GetCurrent();

V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID);

V8Helpers::SetStaticAccessor(isolate, tpl, "all", &AllAudioGetter);
V8Helpers::SetStaticAccessor(isolate, tpl, "count", &AudioCountGetter);

Expand Down
4 changes: 2 additions & 2 deletions client/src/bindings/AudioFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void AddChorusEffect(const v8::FunctionCallbackInfo<v8::Value>& info)

V8_GET_THIS_BASE_OBJECT(filter, alt::IAudioFilter);

V8_CHECK_ARGS_LEN(6);
V8_CHECK_ARGS_LEN(7);
V8_ARG_TO_NUMBER(1, fDryMix);
V8_ARG_TO_NUMBER(2, fWetMix);
V8_ARG_TO_NUMBER(3, fFeedback);
Expand Down Expand Up @@ -244,7 +244,7 @@ static void AddEcho4Effect(const v8::FunctionCallbackInfo<v8::Value>& info)

V8_GET_THIS_BASE_OBJECT(filter, alt::IAudioFilter);

V8_CHECK_ARGS_LEN(4);
V8_CHECK_ARGS_LEN(5);
V8_ARG_TO_NUMBER(1, fDryMix);
V8_ARG_TO_NUMBER(2, fWetMix);
V8_ARG_TO_NUMBER(3, fFeedback);
Expand Down
85 changes: 2 additions & 83 deletions client/src/bindings/AudioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
#include "helpers/BindHelpers.h"
#include "V8ResourceImpl.h"
#include "V8Class.h"

#include "../CV8ScriptRuntime.h"

#include "cpp-sdk/objects/IWorldObject.h"
#include "cpp-sdk/script-objects/IAudioOutput.h"
#include "cpp-sdk/script-objects/IAudioFrontendOutput.h"
#include "cpp-sdk/script-objects/IAudioWorldOutput.h"
#include "cpp-sdk/script-objects/IAudioAttachedOutput.h"

static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
{
Expand All @@ -16,44 +15,6 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_CHECK(false, "You can't use constructor of abstract class");
}

static void ConstructorFrontend(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_CONSTRUCTOR();
V8_CHECK_ARGS_LEN_MIN_MAX(0, 1);

V8_ARG_TO_INT_OPT(1, categoryHash, alt::ICore::Instance().Hash("radio"));

auto output = alt::ICore::Instance().CreateFrontendOutput(categoryHash, resource->GetResource());
V8_BIND_BASE_OBJECT(output, "Failed to create AudioOutputFrontend");
}

static void ConstructorWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_CONSTRUCTOR();
V8_CHECK_ARGS_LEN_MIN_MAX(1, 2);

V8_ARG_TO_VECTOR3(1, pos);
V8_ARG_TO_INT_OPT(2, categoryHash, alt::ICore::Instance().Hash("radio"));

auto output = alt::ICore::Instance().CreateWorldOutput(categoryHash, pos, resource->GetResource());
V8_BIND_BASE_OBJECT(output, "Failed to create AudioOutputWorld");
}

static void ConstructorAttached(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_CONSTRUCTOR();
V8_CHECK_ARGS_LEN_MIN_MAX(1, 2);

V8_ARG_TO_BASE_OBJECT(1, entity, alt::IWorldObject, "IWorldObject");
V8_ARG_TO_INT_OPT(2, categoryHash, alt::ICore::Instance().Hash("radio"));

auto output = alt::ICore::Instance().CreateAttachedOutput(categoryHash, entity, resource->GetResource());
V8_BIND_BASE_OBJECT(output, "Failed to create AudioOutputAttached");
}

static void AllAudioOutputGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
Expand All @@ -66,23 +27,6 @@ static void AudioOutputCountGetter(v8::Local<v8::String> name, const v8::Propert
V8_RETURN_UINT(alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO_OUTPUT).size());
}

static void EntityGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_GET_THIS_BASE_OBJECT(ent, alt::IAudioAttachedOutput);
V8_RETURN_BASE_OBJECT(ent->GetEntity());
}

static void EntitySetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(_this, alt::IAudioAttachedOutput);

V8_TO_WORLDOBJECT(val, entity);

_this->SetEntity(entity);
}

static void GetFilter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
Expand Down Expand Up @@ -129,28 +73,3 @@ extern V8Class v8AudioOutput("AudioOutput",
V8Helpers::SetAccessor<IAudioOutput, uint32_t, &IAudioOutput::GetCategory>(isolate, tpl, "category");
V8Helpers::SetAccessor(isolate, tpl, "filter", &GetFilter, &SetFilter);
});

extern V8Class v8AudioOutputFrontend("AudioOutputFrontend",
v8AudioOutput,
&ConstructorFrontend,
[](v8::Local<v8::FunctionTemplate> tpl) {

});

extern V8Class v8AudioOutputWorld("AudioOutputWorld",
v8AudioOutput,
&ConstructorWorld,
[](v8::Local<v8::FunctionTemplate> tpl)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
V8Helpers::SetAccessor<IAudioWorldOutput, alt::Position, &IAudioWorldOutput::GetPosition, &IAudioWorldOutput::SetPosition>(isolate, tpl, "pos");
});

extern V8Class v8AudioOutputAttached("AudioOutputAttached",
v8AudioOutput,
&ConstructorAttached,
[](v8::Local<v8::FunctionTemplate> tpl)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
V8Helpers::SetAccessor(isolate, tpl, "entity", &EntityGetter, &EntitySetter);
});
74 changes: 74 additions & 0 deletions client/src/bindings/AudioOutputAttached.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include "V8Helpers.h"
#include "helpers/BindHelpers.h"
#include "V8ResourceImpl.h"
#include "V8Class.h"

#include "../CV8ScriptRuntime.h"

#include "cpp-sdk/objects/IWorldObject.h"
#include "cpp-sdk/script-objects/IAudioOutput.h"
#include "cpp-sdk/script-objects/IAudioAttachedOutput.h"

static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_CONSTRUCTOR();
V8_CHECK_ARGS_LEN_MIN_MAX(1, 2);

V8_ARG_TO_BASE_OBJECT(1, entity, alt::IWorldObject, "IWorldObject");
V8_ARG_TO_INT_OPT(2, categoryHash, alt::ICore::Instance().Hash("radio"));

auto output = alt::ICore::Instance().CreateAttachedOutput(categoryHash, entity, resource->GetResource());
V8_BIND_BASE_OBJECT(output, "Failed to create AudioOutputAttached");
}

static void EntityGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_GET_THIS_BASE_OBJECT(ent, alt::IAudioAttachedOutput);
V8_RETURN_BASE_OBJECT(ent->GetEntity());
}

static void EntitySetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(_this, alt::IAudioAttachedOutput);

V8_TO_WORLDOBJECT(val, entity);

_this->SetEntity(entity);
}

static void StaticGetByID(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_ARGS_LEN(1);

V8_ARG_TO_INT(1, id);

alt::IBaseObject* baseObject = alt::ICore::Instance().GetBaseObjectByID(alt::IBaseObject::Type::AUDIO_OUTPUT_ATTACHED, id);

if(baseObject)
{
V8_RETURN_BASE_OBJECT(baseObject);
}
else
{
V8_RETURN_NULL();
}
}

using namespace alt;

extern V8Class v8AudioOutput;
extern V8Class v8AudioOutputAttached("AudioOutputAttached",
v8AudioOutput,
&Constructor,
[](v8::Local<v8::FunctionTemplate> tpl)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();

V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID);

V8Helpers::SetAccessor(isolate, tpl, "entity", &EntityGetter, &EntitySetter);
});
54 changes: 54 additions & 0 deletions client/src/bindings/AudioOutputFrontend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "V8Helpers.h"
#include "helpers/BindHelpers.h"
#include "V8ResourceImpl.h"
#include "V8Class.h"

#include "../CV8ScriptRuntime.h"

#include "cpp-sdk/objects/IWorldObject.h"
#include "cpp-sdk/script-objects/IAudioOutput.h"
#include "cpp-sdk/script-objects/IAudioFrontendOutput.h"

static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_CONSTRUCTOR();
V8_CHECK_ARGS_LEN_MIN_MAX(0, 1);

V8_ARG_TO_INT_OPT(1, categoryHash, alt::ICore::Instance().Hash("radio"));

auto output = alt::ICore::Instance().CreateFrontendOutput(categoryHash, resource->GetResource());
V8_BIND_BASE_OBJECT(output, "Failed to create AudioOutputFrontend");
}

static void StaticGetByID(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_ARGS_LEN(1);

V8_ARG_TO_INT(1, id);

alt::IBaseObject* baseObject = alt::ICore::Instance().GetBaseObjectByID(alt::IBaseObject::Type::AUDIO_OUTPUT_FRONTEND, id);

if(baseObject)
{
V8_RETURN_BASE_OBJECT(baseObject);
}
else
{
V8_RETURN_NULL();
}
}

using namespace alt;

extern V8Class v8AudioOutput;
extern V8Class v8AudioOutputFrontend("AudioOutputFrontend",
v8AudioOutput,
&Constructor,
[](v8::Local<v8::FunctionTemplate> tpl)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();

V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID);
});
57 changes: 57 additions & 0 deletions client/src/bindings/AudioOutputWorld.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "V8Helpers.h"
#include "helpers/BindHelpers.h"
#include "V8ResourceImpl.h"
#include "V8Class.h"

#include "../CV8ScriptRuntime.h"

#include "cpp-sdk/objects/IWorldObject.h"
#include "cpp-sdk/script-objects/IAudioOutput.h"
#include "cpp-sdk/script-objects/IAudioWorldOutput.h"

static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_CONSTRUCTOR();
V8_CHECK_ARGS_LEN_MIN_MAX(1, 2);

V8_ARG_TO_VECTOR3(1, pos);
V8_ARG_TO_INT_OPT(2, categoryHash, alt::ICore::Instance().Hash("radio"));

auto output = alt::ICore::Instance().CreateWorldOutput(categoryHash, pos, resource->GetResource());
V8_BIND_BASE_OBJECT(output, "Failed to create AudioOutputWorld");
}

static void StaticGetByID(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_CHECK_ARGS_LEN(1);

V8_ARG_TO_INT(1, id);

alt::IBaseObject* baseObject = alt::ICore::Instance().GetBaseObjectByID(alt::IBaseObject::Type::AUDIO_OUTPUT_WORLD, id);

if(baseObject)
{
V8_RETURN_BASE_OBJECT(baseObject);
}
else
{
V8_RETURN_NULL();
}
}

using namespace alt;

extern V8Class v8AudioOutput;
extern V8Class v8AudioOutputWorld("AudioOutputWorld",
v8AudioOutput,
&Constructor,
[](v8::Local<v8::FunctionTemplate> tpl)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();

V8Helpers::SetStaticMethod(isolate, tpl, "getByID", StaticGetByID);

V8Helpers::SetAccessor<IAudioWorldOutput, alt::Position, &IAudioWorldOutput::GetPosition, &IAudioWorldOutput::SetPosition>(isolate, tpl, "pos");
});
Loading

0 comments on commit a6e306e

Please sign in to comment.