Skip to content

Commit

Permalink
client: more base object list getter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
C0kkie committed Jul 20, 2023
1 parent 92fdcc7 commit 51ef993
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 42 deletions.
4 changes: 2 additions & 2 deletions client/src/bindings/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ static void Seek(const v8::FunctionCallbackInfo<v8::Value>& info)
static void AllAudioGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
auto objects = alt::ICore::Instance().GetAudios();
auto objects = alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO);
v8::Local<v8::Array> 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);
}

static void AudioCountGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_RETURN_UINT(alt::ICore::Instance().GetAudios().size());
V8_RETURN_UINT(alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO).size());
}

extern V8Class v8BaseObject;
Expand Down
70 changes: 34 additions & 36 deletions client/src/bindings/AudioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void ConstructorWorld(const v8::FunctionCallbackInfo<v8::Value>& 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");
}
Expand All @@ -57,15 +57,15 @@ static void ConstructorAttached(const v8::FunctionCallbackInfo<v8::Value>& info)
static void AllAudioOutputGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& 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<v8::Array> 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);
}

static void AudioOutputCountGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& 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<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
Expand Down Expand Up @@ -98,7 +98,7 @@ static void SetFilter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8:
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_GET_THIS_BASE_OBJECT(output, alt::IAudioOutput);

if (val->IsNull())
if(val->IsNull())
{
output->RemoveFilter();
}
Expand All @@ -117,44 +117,42 @@ using namespace alt;

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

V8Helpers::SetStaticAccessor(isolate, tpl, "all", &AllAudioOutputGetter);
V8Helpers::SetStaticAccessor(isolate, tpl, "count", &AudioOutputCountGetter);
v8BaseObject,
&Constructor,
[](v8::Local<v8::FunctionTemplate> tpl)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();

V8Helpers::SetAccessor<IAudioOutput, bool, &IAudioOutput::IsMuted, &IAudioOutput::SetMuted>(isolate, tpl, "muted");
V8Helpers::SetAccessor<IAudioOutput, float, &IAudioOutput::GetVolume, &IAudioOutput::SetVolume>(isolate, tpl, "volume");
V8Helpers::SetAccessor<IAudioOutput, uint32_t, &IAudioOutput::GetCategory>(isolate, tpl, "category");
V8Helpers::SetAccessor(isolate, tpl, "filter", &GetFilter, &SetFilter);
});
V8Helpers::SetStaticAccessor(isolate, tpl, "all", &AllAudioOutputGetter);
V8Helpers::SetStaticAccessor(isolate, tpl, "count", &AudioOutputCountGetter);

V8Helpers::SetAccessor<IAudioOutput, bool, &IAudioOutput::IsMuted, &IAudioOutput::SetMuted>(isolate, tpl, "muted");
V8Helpers::SetAccessor<IAudioOutput, float, &IAudioOutput::GetVolume, &IAudioOutput::SetVolume>(isolate, tpl, "volume");
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)
{
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");
});
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);
});
v8AudioOutput,
&ConstructorAttached,
[](v8::Local<v8::FunctionTemplate> tpl)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
V8Helpers::SetAccessor(isolate, tpl, "entity", &EntityGetter, &EntitySetter);
});
6 changes: 3 additions & 3 deletions client/src/bindings/WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static void Reload(const v8::FunctionCallbackInfo<v8::Value>& 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;
Expand All @@ -236,15 +236,15 @@ static void Reload(const v8::FunctionCallbackInfo<v8::Value>& info)
static void AllWebviewGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
auto objects = alt::ICore::Instance().GetWebViews();
auto objects = alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::WEBVIEW);
v8::Local<v8::Array> 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);
}

static void WebviewCountGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& 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<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
Expand Down
2 changes: 1 addition & 1 deletion shared/deps/cpp-sdk
Submodule cpp-sdk updated 1 files
+0 −3 ICore.h

0 comments on commit 51ef993

Please sign in to comment.