Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kodeyeen committed May 1, 2024
1 parent a37bcc8 commit 3f36a21
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ extern "C"

if (data)
{
IPlayerObject* object = data->get(id)
IPlayerObject* object = data->get(id);

if (object)
{
Expand Down
122 changes: 120 additions & 2 deletions api/TextLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ extern "C"
{
#endif

GOMPONENT_EXPORT void* textLabel_create(String text, uint32_t colour, float posX, float posY, float posZ, float drawDist, int vw, unsigned char los)
GOMPONENT_EXPORT void* textLabel_create(String text, uint32_t colour, float posX, float posY, float posZ, float drawDistance, int vw, unsigned char los)
{
ITextLabelsComponent* textlabels = Gomponent::Get()->textlabels;

if (textlabels)
{
ITextLabel* textlabel = textlabels->create(StringView(text.buf, text.length), Colour::FromRGBA(colour), Vector3(posX, posY, posZ), drawDist, vw, los != 0);
ITextLabel* textlabel = textlabels->create(StringView(text.buf, text.length), Colour::FromRGBA(colour), Vector3(posX, posY, posZ), drawDistance, vw, los != 0);

if (textlabel)
{
Expand Down Expand Up @@ -130,6 +130,124 @@ extern "C"
return static_cast<ITextLabel*>(textLabel)->getVirtualWorld();
}

// PlayerTextLabel

GOMPONENT_EXPORT void* playerTextLabel_create(void* player, String text, uint32_t colour, float posX, float posY, float posZ, float drawDistance, unsigned char los)
{
IPlayerTextLabelData* data = queryExtension<IPlayerTextLabelData>(static_cast<IPlayer*>(player));

if (data)
{
IPlayerTextLabel* textlabel = data->create(StringView(text.buf, text.length), Colour::FromRGBA(colour), Vector3(posX, posY, posZ), drawDistance, los != 0);

if (textlabel)
{
return static_cast<void*>(textlabel);
}
}

return NULL;
}

GOMPONENT_EXPORT void playerTextLabel_release(void* textLabel, void* player)
{
IPlayerTextLabelData* data = queryExtension<IPlayerTextLabelData>(static_cast<IPlayer*>(player));

if (data)
{
data->release(static_cast<IPlayerTextLabel*>(textLabel)->getID());
}
}

GOMPONENT_EXPORT void playerTextLabel_setText(void* textLabel, String text)
{
static_cast<IPlayerTextLabel*>(textLabel)->setText(StringView(text.buf, text.length));
}

GOMPONENT_EXPORT String playerTextLabel_getText(void* textLabel)
{
StringView textView = static_cast<IPlayerTextLabel*>(textLabel)->getText();

return { textView.data(), textView.length() };
}

GOMPONENT_EXPORT void playerTextLabel_setColour(void* textLabel, uint32_t colour)
{
static_cast<IPlayerTextLabel*>(textLabel)->setColour(Colour::FromRGBA(colour));
}

GOMPONENT_EXPORT uint32_t playerTextLabel_getColour(void* textLabel)
{
return static_cast<IPlayerTextLabel*>(textLabel)->getColour().RGBA();
}

GOMPONENT_EXPORT void playerTextLabel_setDrawDistance(void* textLabel, float drawDist)
{
static_cast<IPlayerTextLabel*>(textLabel)->setDrawDistance(drawDist);
}

GOMPONENT_EXPORT float playerTextLabel_getDrawDistance(void* textLabel)
{
return static_cast<IPlayerTextLabel*>(textLabel)->getDrawDistance();
}

GOMPONENT_EXPORT void playerTextLabel_attachToPlayer(void* textLabel, void* player, float offsetX, float offsetY, float offsetZ)
{
static_cast<IPlayerTextLabel*>(textLabel)->attachToPlayer(*static_cast<IPlayer*>(player), Vector3(offsetX, offsetY, offsetZ));
}

GOMPONENT_EXPORT void playerTextLabel_attachToVehicle(void* textLabel, void* vehicle, float offsetX, float offsetY, float offsetZ)
{
static_cast<IPlayerTextLabel*>(textLabel)->attachToVehicle(*static_cast<IVehicle*>(vehicle), Vector3(offsetX, offsetY, offsetZ));
}

GOMPONENT_EXPORT TextLabelAttachmentData playerTextLabel_getAttachmentData(void* textLabel)
{
return static_cast<IPlayerTextLabel*>(textLabel)->getAttachmentData();
}

GOMPONENT_EXPORT void playerTextLabel_detachFromPlayer(void* textLabel, float posX, float posY, float posZ)
{
static_cast<IPlayerTextLabel*>(textLabel)->detachFromPlayer(Vector3(posX, posY, posZ));
}

GOMPONENT_EXPORT void playerTextLabel_detachFromVehicle(void* textLabel, float posX, float posY, float posZ)
{
static_cast<IPlayerTextLabel*>(textLabel)->detachFromVehicle(Vector3(posX, posY, posZ));
}

GOMPONENT_EXPORT void playerTextLabel_setTestLOS(void* textLabel, unsigned char status)
{
static_cast<IPlayerTextLabel*>(textLabel)->setTestLOS(status != 0);
}

GOMPONENT_EXPORT unsigned char playerTextLabel_getTestLOS(void* textLabel)
{
return static_cast<IPlayerTextLabel*>(textLabel)->getTestLOS() ? 1 : 0;
}

// entity

GOMPONENT_EXPORT void playerTextLabel_setPosition(void* textLabel, float posX, float posY, float posZ)
{
static_cast<IPlayerTextLabel*>(textLabel)->setPosition(Vector3(posX, posY, posZ));
}

GOMPONENT_EXPORT Vector3 playerTextLabel_getPosition(void* textLabel)
{
return static_cast<IPlayerTextLabel*>(textLabel)->getPosition();
}

GOMPONENT_EXPORT void playerTextLabel_setVirtualWorld(void* textLabel, int vw)
{
static_cast<IPlayerTextLabel*>(textLabel)->setVirtualWorld(vw);
}

GOMPONENT_EXPORT int playerTextLabel_getVirtualWorld(void* textLabel)
{
return static_cast<IPlayerTextLabel*>(textLabel)->getVirtualWorld();
}

#ifdef __cplusplus
}
#endif

0 comments on commit 3f36a21

Please sign in to comment.