From 8d33ce1c2a60bd6a2476a4a713f7f82e63125452 Mon Sep 17 00:00:00 2001 From: warp-core Date: Sun, 11 Feb 2024 20:05:16 +0000 Subject: [PATCH] fix(ui): Render animated sprites in the hail panel correctly (#9767) --- source/HailPanel.cpp | 12 ++++++++---- source/HailPanel.h | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/HailPanel.cpp b/source/HailPanel.cpp index 2e9987c82622..1adf001db18b 100644 --- a/source/HailPanel.cpp +++ b/source/HailPanel.cpp @@ -45,8 +45,7 @@ using namespace std; HailPanel::HailPanel(PlayerInfo &player, const shared_ptr &ship, function bribeCallback) - : player(player), ship(ship), bribeCallback(std::move(bribeCallback)), - sprite(ship->GetSprite()), facing(ship->Facing()) + : player(player), ship(ship), bribeCallback(std::move(bribeCallback)), facing(ship->Facing()) { SetInterruptible(false); @@ -125,7 +124,7 @@ HailPanel::HailPanel(PlayerInfo &player, const shared_ptr &ship, function< HailPanel::HailPanel(PlayerInfo &player, const StellarObject *object) - : player(player), planet(object->GetPlanet()), sprite(object->GetSprite()), facing(object->Facing()) + : player(player), object(object), planet(object->GetPlanet()), facing(object->Facing()) { SetInterruptible(false); @@ -209,11 +208,14 @@ void HailPanel::Draw() const Interface *hailUi = GameData::Interfaces().Get("hail panel"); hailUi->Draw(info, this); + const Sprite *sprite = ship ? ship->GetSprite() : object->GetSprite(); + // Draw the sprite, rotated, scaled, and swizzled as necessary. float zoom = min(2.f, 400.f / max(sprite->Width(), sprite->Height())); Point center(-170., -10.); DrawList draw; + draw.Clear(step); // If this is a ship, copy its swizzle, animation settings, etc. // Also draw its fighters and weapon hardpoints. if(ship) @@ -263,7 +265,7 @@ void HailPanel::Draw() addFighter(bay); } else - draw.Add(Body(sprite, center, Point(), facing, zoom)); + draw.Add(Body(*object, center, Point(), facing, zoom)); draw.Draw(); @@ -274,6 +276,8 @@ void HailPanel::Draw() wrap.SetFont(FontSet::Get(14)); wrap.Wrap(message); wrap.Draw(Point(-50., -50.), *GameData::Colors().Get("medium")); + + ++step; } diff --git a/source/HailPanel.h b/source/HailPanel.h index ddb429fdd0e9..3ea6f14b0dd4 100644 --- a/source/HailPanel.h +++ b/source/HailPanel.h @@ -58,9 +58,10 @@ class HailPanel : public Panel { PlayerInfo &player; std::shared_ptr ship = nullptr; std::function bribeCallback = nullptr; + const StellarObject *object = nullptr; const Planet *planet = nullptr; - const Sprite *sprite = nullptr; Angle facing; + int step = 0; std::string header; std::string message;