Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions Server/Components/TextDraws/textdraw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <Impl/pool_impl.hpp>
#include <Server/Components/TextDraws/textdraws.hpp>
#include <Server/Components/Vehicles/vehicle_colours.hpp>
#include <netcode.hpp>
#include <sdk.hpp>

Expand All @@ -34,8 +35,21 @@ class TextDrawBase : public T, public PoolIDProvider, public NoCopy
int previewModel;
Vector3 previewRotation = Vector3(0.f);
Pair<int, int> previewVehicleColours = std::make_pair(-1, -1);
Pair<int, int> colourSettings = std::make_pair(-1, -1);
float previewZoom = 1.f;

void updatePreviewColours()
{
previewVehicleColours = colourSettings;

// Pick random colours here instead of sending -1, so the getter returns what the client shows
if (previewModel >= 400 && previewModel <= 611 && (previewVehicleColours.first == -1 || previewVehicleColours.second == -1))
{
int ignore;
getRandomVehicleColour(previewModel, previewVehicleColours.first == -1 ? previewVehicleColours.first : ignore, previewVehicleColours.second == -1 ? previewVehicleColours.second : ignore);
}
}

public:
TextDrawBase(Vector2 pos, StringView text, TextDrawStyle style = TextDrawStyle_FontAharoniBold, int previewModel = 0)
: pos(pos)
Expand All @@ -44,6 +58,7 @@ class TextDrawBase : public T, public PoolIDProvider, public NoCopy
, previewModel(previewModel)
{
trimText();
updatePreviewColours();
}

int getID() const override
Expand Down Expand Up @@ -212,7 +227,11 @@ class TextDrawBase : public T, public PoolIDProvider, public NoCopy

T& setPreviewModel(int model) override
{
previewModel = model;
if (previewModel != model)
{
previewModel = model;
updatePreviewColours();
}
return *this;
}

Expand All @@ -234,8 +253,9 @@ class TextDrawBase : public T, public PoolIDProvider, public NoCopy

T& setPreviewVehicleColour(int colour1, int colour2) override
{
previewVehicleColours.first = colour1;
previewVehicleColours.second = colour2;
colourSettings.first = colour1;
colourSettings.second = colour2;
updatePreviewColours();
return *this;
}

Expand Down