Skip to content

Commit

Permalink
client: add player audiofilter
Browse files Browse the repository at this point in the history
  • Loading branch information
C0kkie committed Jul 27, 2023
1 parent ad21416 commit d3bb52c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions client/src/bindings/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,34 @@ static void StaticGetByRemoteId(const v8::FunctionCallbackInfo<v8::Value>& info)
}
}

static void GetFilter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer);

V8_RETURN_BASE_OBJECT(player->GetFilter());
}

static void SetFilter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer);

if(val->IsNull())
{
player->RemoveFilter();
}
else if(val->IsObject())
{
V8_TO_BASEOBJECT(val, filter);
player->AddFilter(filter->SharedAs<alt::IAudioFilter>().get());
}
else
{
V8Helpers::Throw(isolate, "AudioOutput.filter setter expects null or AudioFilter object");
}
}

extern V8Class v8Entity;
extern V8Class v8Player("Player",
v8Entity,
Expand Down Expand Up @@ -186,4 +214,6 @@ extern V8Class v8Player("Player",
// V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsSuperJumpEnabled>(isolate, tpl, "isSuperJumpEnabled");
// V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsCrouching>(isolate, tpl, "isCrouching");
// V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsStealthy>(isolate, tpl, "isStealthy");

V8Helpers::SetAccessor(isolate, tpl, "filter", &GetFilter, &SetFilter);
});
2 changes: 1 addition & 1 deletion shared/deps/cpp-sdk
Submodule cpp-sdk updated 1 files
+6 −0 objects/IPlayer.h

0 comments on commit d3bb52c

Please sign in to comment.