Skip to content

Commit

Permalink
feat(client): new textlable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
zziger committed Nov 22, 2023
1 parent 048539d commit 0c09c60
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion client/src/bindings/TextLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_ARG_TO_UINT_OPT(11, streamingDistance, 0);

auto textLabel =
alt::ICore::Instance().CreateTextLabel(text, fontName, fontSize, scale, pos, rot, color, outlineWidth, outlineColor, useStreaming, streamingDistance, resource->GetResource());
alt::ICore::Instance().CreateTextLabel(resource->GetResource(), text, fontName, fontSize, scale, pos, rot, color, outlineWidth, outlineColor, useStreaming, streamingDistance, resource->GetResource());
V8_BIND_BASE_OBJECT(textLabel, "Failed to create textlabel");
}

Expand Down Expand Up @@ -51,6 +51,24 @@ static void StaticGetByID(const v8::FunctionCallbackInfo<v8::Value>& info)
}
}

static void AlignGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE();

V8_GET_THIS_BASE_OBJECT(label, alt::ITextLabel);

V8_RETURN_NUMBER(label->GetAlign());
}

static void AlignSetter(v8::Local<v8::String>, v8::Local<v8::Value> val, const v8::PropertyCallbackInfo<void>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(label, alt::ITextLabel);

V8_TO_NUMBER(val, align);
label->SetAlign((alt::ITextLabel::Alignment) align);
}

extern V8Class v8WorldObject;
extern V8Class v8TextLabel("TextLabel",
v8WorldObject,
Expand All @@ -69,6 +87,12 @@ extern V8Class v8TextLabel("TextLabel",
V8Helpers::SetAccessor<ITextLabel, IPlayer*, &ITextLabel::GetTarget>(isolate, tpl, "target");
V8Helpers::SetAccessor<ITextLabel, bool, &ITextLabel::IsVisible, &ITextLabel::SetVisible>(isolate, tpl, "visible");
V8Helpers::SetAccessor<ITextLabel, RGBA, &ITextLabel::GetColor, &ITextLabel::SetColor>(isolate, tpl, "color");
V8Helpers::SetAccessor<ITextLabel, RGBA, &ITextLabel::GetOutlineColor, &ITextLabel::SetOutlineColor>(isolate, tpl, "outlineColor");
V8Helpers::SetAccessor<ITextLabel, float, &ITextLabel::GetOutlineWidth, &ITextLabel::SetOutlineWidth>(isolate, tpl, "outlineWidth");
V8Helpers::SetAccessor<ITextLabel, float, &ITextLabel::GetFontSize, &ITextLabel::SetFontSize>(isolate, tpl, "fontSize");
V8Helpers::SetAccessor(isolate, tpl, "align", &AlignGetter, &AlignSetter);
V8Helpers::SetAccessor<ITextLabel, std::string, &ITextLabel::GetText, const std::string&, &ITextLabel::SetText>(isolate, tpl, "text");
V8Helpers::SetAccessor<ITextLabel, std::string, &ITextLabel::GetFont, const std::string&, &ITextLabel::SetFont>(isolate, tpl, "font");
V8Helpers::SetAccessor<ITextLabel, float, &ITextLabel::GetScale, &ITextLabel::SetScale>(isolate, tpl, "scale");
V8Helpers::SetAccessor<ITextLabel, Rotation, &ITextLabel::GetRotation, &ITextLabel::SetRotation>(isolate, tpl, "rot");
V8Helpers::SetAccessor<ITextLabel, bool, &ITextLabel::IsFacingCamera, &ITextLabel::SetFaceCamera>(isolate, tpl, "faceCamera");
Expand Down
2 changes: 1 addition & 1 deletion shared/deps/cpp-sdk

0 comments on commit 0c09c60

Please sign in to comment.