diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index 0910ed7b..21d08c69 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -194,41 +194,119 @@ static void HwidExHashGetter(v8::Local name, const v8::PropertyCallb static void SetClothes(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT(); - V8_CHECK_ARGS_LEN2(3, 4); + V8_CHECK_ARGS_LEN_MIN_MAX(3, 5); V8_GET_THIS_BASE_OBJECT(player, IPlayer); V8_ARG_TO_INTEGER(1, component); V8_ARG_TO_INTEGER(2, drawable); V8_ARG_TO_INTEGER(3, texture); - if(info.Length() == 4) + if(info.Length() == 3) + { + player->SetClothes(component, drawable, texture, 2); + } + else if(info.Length() == 4) { V8_ARG_TO_INTEGER(4, palette); player->SetClothes(component, drawable, texture, palette); } - else + else if(info.Length() == 5) { - player->SetClothes(component, drawable, texture, 2); + V8_ARG_TO_INTEGER(4, palette); + V8_ARG_TO_INTEGER(5, dlc); + player->SetDlcClothes(component, drawable, texture, palette, dlc); } } static void GetClothes(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT(); - V8_CHECK_ARGS_LEN(1); + V8_CHECK_ARGS_LEN2(1, 2); V8_GET_THIS_BASE_OBJECT(player, IPlayer); V8_ARG_TO_INTEGER(1, component); - auto cloth = player->GetClothes(component); + bool dlcCloth = false; + if(info.Length() == 2) + { + V8_ARG_TO_BOOLEAN(2, dlc); + dlcCloth = dlc; + } + V8_NEW_OBJECT(clothes); - V8_OBJECT_SET_INTEGER(clothes, "drawable", cloth.drawableId); - V8_OBJECT_SET_INTEGER(clothes, "texture", cloth.textureId); - V8_OBJECT_SET_INTEGER(clothes, "palette", cloth.paletteId); + if(!dlcCloth) + { + auto cloth = player->GetClothes(component); + V8_OBJECT_SET_INTEGER(clothes, "drawable", cloth.drawableId); + V8_OBJECT_SET_INTEGER(clothes, "texture", cloth.textureId); + V8_OBJECT_SET_INTEGER(clothes, "palette", cloth.paletteId); + } + else + { + auto cloth = player->GetDlcClothes(component); + V8_OBJECT_SET_INTEGER(clothes, "drawable", cloth.drawableId); + V8_OBJECT_SET_INTEGER(clothes, "texture", cloth.textureId); + V8_OBJECT_SET_INTEGER(clothes, "palette", cloth.paletteId); + V8_OBJECT_SET_INTEGER(clothes, "dlc", cloth.dlc); + } V8_RETURN(clothes); } +static void SetProps(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN_MIN_MAX(3, 4); + V8_GET_THIS_BASE_OBJECT(player, IPlayer); + + V8_ARG_TO_INTEGER(1, component); + V8_ARG_TO_INTEGER(2, drawable); + V8_ARG_TO_INTEGER(3, texture); + + if(info.Length() == 3) + { + player->SetProps(component, drawable, texture); + } + else if(info.Length() == 4) + { + V8_ARG_TO_INTEGER(4, dlc); + player->SetDlcProps(component, drawable, texture, dlc); + } +} + +static void GetProps(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN2(1, 2); + V8_GET_THIS_BASE_OBJECT(player, IPlayer); + + V8_ARG_TO_INTEGER(1, component); + + bool dlcProp = false; + if(info.Length() == 2) + { + V8_ARG_TO_BOOLEAN(2, dlc); + dlcProp = dlc; + } + + V8_NEW_OBJECT(prop); + if(!dlcProp) + { + auto props = player->GetProps(component); + V8_OBJECT_SET_INTEGER(prop, "drawable", props.drawableId); + V8_OBJECT_SET_INTEGER(prop, "texture", props.textureId); + } + else + { + auto props = player->GetDlcProps(component); + V8_OBJECT_SET_INTEGER(prop, "drawable", props.drawableId); + V8_OBJECT_SET_INTEGER(prop, "texture", props.textureId); + V8_OBJECT_SET_INTEGER(prop, "dlc", props.dlc); + } + + V8_RETURN(prop); +} + static void IsEntityInStreamRange(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT(); @@ -323,4 +401,7 @@ extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::Local