Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render animated sprites in the hail panel correctly #9767

Merged
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions source/HailPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ using namespace std;


HailPanel::HailPanel(PlayerInfo &player, const shared_ptr<Ship> &ship, function<void(const Government *)> 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);

Expand Down Expand Up @@ -125,7 +124,7 @@ HailPanel::HailPanel(PlayerInfo &player, const shared_ptr<Ship> &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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();

Expand All @@ -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;
}


Expand Down
3 changes: 2 additions & 1 deletion source/HailPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ class HailPanel : public Panel {
PlayerInfo &player;
std::shared_ptr<Ship> ship = nullptr;
std::function<void(const Government *)> 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;
Expand Down
Loading