diff --git a/Server/Components/TextDraws/textdraw.hpp b/Server/Components/TextDraws/textdraw.hpp index 2f952a6c8..fcd3492ca 100644 --- a/Server/Components/TextDraws/textdraw.hpp +++ b/Server/Components/TextDraws/textdraw.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -34,8 +35,21 @@ class TextDrawBase : public T, public PoolIDProvider, public NoCopy int previewModel; Vector3 previewRotation = Vector3(0.f); Pair previewVehicleColours = std::make_pair(-1, -1); + Pair 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) @@ -44,6 +58,7 @@ class TextDrawBase : public T, public PoolIDProvider, public NoCopy , previewModel(previewModel) { trimText(); + updatePreviewColours(); } int getID() const override @@ -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; } @@ -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; }