Fix vehicle name color in usetargets

This commit is contained in:
tovjemam 2026-05-22 22:36:13 +02:00
parent cf8742c4fe
commit cd3e1aab4f
3 changed files with 24 additions and 5 deletions

View File

@ -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) + ")";
}
}

View File

@ -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<VehicleSeat> seats_;

View File

@ -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<const assets::VehicleModel>& GetModel() const { return model_; }