From 51ef99391898112912479eb716df760e745d7f96 Mon Sep 17 00:00:00 2001 From: Blue Date: Thu, 20 Jul 2023 21:51:01 +0200 Subject: [PATCH] client: more base object list getter changes --- client/src/bindings/Audio.cpp | 4 +- client/src/bindings/AudioOutput.cpp | 70 ++++++++++++++--------------- client/src/bindings/WebView.cpp | 6 +-- shared/deps/cpp-sdk | 2 +- 4 files changed, 40 insertions(+), 42 deletions(-) diff --git a/client/src/bindings/Audio.cpp b/client/src/bindings/Audio.cpp index 7f1599ef..14c636e6 100644 --- a/client/src/bindings/Audio.cpp +++ b/client/src/bindings/Audio.cpp @@ -120,7 +120,7 @@ static void Seek(const v8::FunctionCallbackInfo& info) static void AllAudioGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); - auto objects = alt::ICore::Instance().GetAudios(); + auto objects = alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO); v8::Local jsArr = v8::Array::New(isolate, objects.size()); for(size_t i = 0; i < objects.size(); ++i) jsArr->Set(ctx, i, resource->GetBaseObjectOrNull(objects[i])); V8_RETURN(jsArr); @@ -128,7 +128,7 @@ static void AllAudioGetter(v8::Local name, const v8::PropertyCallbac static void AudioCountGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { - V8_RETURN_UINT(alt::ICore::Instance().GetAudios().size()); + V8_RETURN_UINT(alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO).size()); } extern V8Class v8BaseObject; diff --git a/client/src/bindings/AudioOutput.cpp b/client/src/bindings/AudioOutput.cpp index 1d4d10f4..30b11d49 100644 --- a/client/src/bindings/AudioOutput.cpp +++ b/client/src/bindings/AudioOutput.cpp @@ -36,7 +36,7 @@ static void ConstructorWorld(const v8::FunctionCallbackInfo& info) 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"); } @@ -57,7 +57,7 @@ static void ConstructorAttached(const v8::FunctionCallbackInfo& info) static void AllAudioOutputGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); - auto objects = alt::ICore::Instance().GetAudioOutputs(); + auto objects = alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO_OUTPUT); v8::Local jsArr = v8::Array::New(isolate, objects.size()); for(size_t i = 0; i < objects.size(); ++i) jsArr->Set(ctx, i, resource->GetBaseObjectOrNull(objects[i])); V8_RETURN(jsArr); @@ -65,7 +65,7 @@ static void AllAudioOutputGetter(v8::Local name, const v8::PropertyC static void AudioOutputCountGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { - V8_RETURN_UINT(alt::ICore::Instance().GetAudioOutputs().size()); + V8_RETURN_UINT(alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO_OUTPUT).size()); } static void EntityGetter(v8::Local, const v8::PropertyCallbackInfo& info) @@ -98,7 +98,7 @@ static void SetFilter(v8::Local, v8::Local val, const v8: V8_GET_ISOLATE_CONTEXT_RESOURCE(); V8_GET_THIS_BASE_OBJECT(output, alt::IAudioOutput); - if (val->IsNull()) + if(val->IsNull()) { output->RemoveFilter(); } @@ -117,44 +117,42 @@ using namespace alt; extern V8Class v8BaseObject; extern V8Class v8AudioOutput("AudioOutput", - v8BaseObject, - &Constructor, - [](v8::Local tpl) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - - V8Helpers::SetStaticAccessor(isolate, tpl, "all", &AllAudioOutputGetter); - V8Helpers::SetStaticAccessor(isolate, tpl, "count", &AudioOutputCountGetter); + v8BaseObject, + &Constructor, + [](v8::Local tpl) + { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8Helpers::SetAccessor(isolate, tpl, "muted"); - V8Helpers::SetAccessor(isolate, tpl, "volume"); - V8Helpers::SetAccessor(isolate, tpl, "category"); - V8Helpers::SetAccessor(isolate, tpl, "filter", &GetFilter, &SetFilter); - }); + V8Helpers::SetStaticAccessor(isolate, tpl, "all", &AllAudioOutputGetter); + V8Helpers::SetStaticAccessor(isolate, tpl, "count", &AudioOutputCountGetter); + V8Helpers::SetAccessor(isolate, tpl, "muted"); + V8Helpers::SetAccessor(isolate, tpl, "volume"); + V8Helpers::SetAccessor(isolate, tpl, "category"); + V8Helpers::SetAccessor(isolate, tpl, "filter", &GetFilter, &SetFilter); + }); extern V8Class v8AudioOutputFrontend("AudioOutputFrontend", - v8AudioOutput, - &ConstructorFrontend, - [](v8::Local tpl) - { + v8AudioOutput, + &ConstructorFrontend, + [](v8::Local tpl) { - }); + }); extern V8Class v8AudioOutputWorld("AudioOutputWorld", - v8AudioOutput, - &ConstructorWorld, - [](v8::Local tpl) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8Helpers::SetAccessor(isolate, tpl, "pos"); - }); + v8AudioOutput, + &ConstructorWorld, + [](v8::Local tpl) + { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + V8Helpers::SetAccessor(isolate, tpl, "pos"); + }); extern V8Class v8AudioOutputAttached("AudioOutputAttached", - v8AudioOutput, - &ConstructorAttached, - [](v8::Local tpl) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8Helpers::SetAccessor(isolate, tpl, "entity", &EntityGetter, &EntitySetter); - }); + v8AudioOutput, + &ConstructorAttached, + [](v8::Local tpl) + { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + V8Helpers::SetAccessor(isolate, tpl, "entity", &EntityGetter, &EntitySetter); + }); diff --git a/client/src/bindings/WebView.cpp b/client/src/bindings/WebView.cpp index e3490dd0..33c801f2 100644 --- a/client/src/bindings/WebView.cpp +++ b/client/src/bindings/WebView.cpp @@ -224,7 +224,7 @@ static void Reload(const v8::FunctionCallbackInfo& info) V8_CHECK_ARGS_LEN2(0, 1); bool ignoreCache = false; - if (info.Length() > 0) + if(info.Length() > 0) { V8_ARG_TO_BOOLEAN(1, _ignoreCache); ignoreCache = _ignoreCache; @@ -236,7 +236,7 @@ static void Reload(const v8::FunctionCallbackInfo& info) static void AllWebviewGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); - auto objects = alt::ICore::Instance().GetWebViews(); + auto objects = alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::WEBVIEW); v8::Local jsArr = v8::Array::New(isolate, objects.size()); for(size_t i = 0; i < objects.size(); ++i) jsArr->Set(ctx, i, resource->GetBaseObjectOrNull(objects[i])); V8_RETURN(jsArr); @@ -244,7 +244,7 @@ static void AllWebviewGetter(v8::Local name, const v8::PropertyCallb static void WebviewCountGetter(v8::Local name, const v8::PropertyCallbackInfo& info) { - V8_RETURN_UINT(alt::ICore::Instance().GetWebViews().size()); + V8_RETURN_UINT(alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::WEBVIEW).size()); } static void WebviewGpuAccelerationActive(v8::Local name, const v8::PropertyCallbackInfo& info) diff --git a/shared/deps/cpp-sdk b/shared/deps/cpp-sdk index fcd25f90..666d80a8 160000 --- a/shared/deps/cpp-sdk +++ b/shared/deps/cpp-sdk @@ -1 +1 @@ -Subproject commit fcd25f907522c3c2451ae8d4597d4ee8679da766 +Subproject commit 666d80a8ca71d230ab1d19ef80b113c701df31d2