From cd3e1aab4fce32611e8f3bedda2b34914a96c74f Mon Sep 17 00:00:00 2001 From: tovjemam Date: Fri, 22 May 2026 22:36:13 +0200 Subject: [PATCH] Fix vehicle name color in usetargets --- src/game/drivable_vehicle.cpp | 24 ++++++++++++++++++++---- src/game/drivable_vehicle.hpp | 3 +++ src/game/vehicle.hpp | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/game/drivable_vehicle.cpp b/src/game/drivable_vehicle.cpp index a8917b0..237f510 100644 --- a/src/game/drivable_vehicle.cpp +++ b/src/game/drivable_vehicle.cpp @@ -8,6 +8,12 @@ game::DrivableVehicle::DrivableVehicle(World& world, const VehicleTuning& tuning OnPhysicsChanged(); } +void game::DrivableVehicle::SetTuning(const VehicleTuning& tuning) +{ + Super::SetTuning(tuning); + UpdateUseTargetNames(); // to update vehicle color in usetarget names +} + void game::DrivableVehicle::OnPhysicsChanged() { // make body usable @@ -94,9 +100,6 @@ static std::string GetColorTextPrefix(uint32_t color) void game::DrivableVehicle::InitSeats() { - uint32_t color = GetTuningResult().colors[0]; - std::string prefix = "vlízt do " + GetColorTextPrefix(color) + GetModelName() + "^r"; - const auto& veh = *GetModel(); for (char c = '0'; c <= '9'; ++c) { @@ -110,6 +113,19 @@ void game::DrivableVehicle::InitSeats() seats_.emplace_back(seat); uint32_t id = seats_.size() - 1; - use_targets_.emplace_back(this, id, seat.position, prefix + " (místo " + std::to_string(id + 1) + ")"); + use_targets_.emplace_back(this, id, seat.position, std::string()); + } + + UpdateUseTargetNames(); +} + +void game::DrivableVehicle::UpdateUseTargetNames() +{ + uint32_t color = GetTuningResult().colors[0]; + std::string prefix = "vlízt do " + GetColorTextPrefix(color) + GetModelName() + "^r"; + + for (auto& target : use_targets_) + { + target.desc = prefix + " (místo " + std::to_string(target.id + 1) + ")"; } } diff --git a/src/game/drivable_vehicle.hpp b/src/game/drivable_vehicle.hpp index 3d66569..b5cdc0f 100644 --- a/src/game/drivable_vehicle.hpp +++ b/src/game/drivable_vehicle.hpp @@ -20,6 +20,8 @@ public: DrivableVehicle(World& world, const VehicleTuning& tuning); + virtual void SetTuning(const VehicleTuning& tuning) override; + virtual void OnPhysicsChanged() override; virtual bool QueryUseTarget(PlayerCharacter& character, uint32_t target_id, UseTargetQueryResult& res) override; @@ -34,6 +36,7 @@ public: private: void InitSeats(); + void UpdateUseTargetNames(); private: std::vector seats_; diff --git a/src/game/vehicle.hpp b/src/game/vehicle.hpp index 22b1028..55f4974 100644 --- a/src/game/vehicle.hpp +++ b/src/game/vehicle.hpp @@ -74,7 +74,7 @@ public: void SetSteering(bool analog, float value = 0.0f); - void SetTuning(const VehicleTuning& tuning); + virtual void SetTuning(const VehicleTuning& tuning); const std::string& GetModelName() const { return tuning_.model; } const std::shared_ptr& GetModel() const { return model_; }