From c74680473e702bacc009897a258387445d6f3eb5 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Wed, 6 Mar 2024 21:12:22 +0100 Subject: Use the native TMX tile animation format Rewrote the tile animation loading code based on XML tags, replacing the code that loaded tile animations from tile properties. Also made a number of code simplifications and optimizations: * Replaced a number of pointer members with value members. * Pass around Animation and TileAnimation by value, using std::move to avoid allocating copies. * push -> emplace * push_front -> emplace_front * push_back -> emplace_back * Use range-based for loops * Use std::vector instead of std::list for storing affected tiles (less fragmentation) * Avoid string copies and allocations while parsing CSV layer data. * Replaced xmlNodeGetContent with directly accessing 'content'. --- src/gui/widgets/progressindicator.cpp | 11 ++++------- src/gui/widgets/progressindicator.h | 4 +++- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 40523e9a..37aaab62 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -35,19 +35,16 @@ ProgressIndicator::ProgressIndicator() ImageSet *images = Theme::getImageSetFromTheme("progress-indicator.png", 32, 32); - auto *anim = new Animation; + Animation anim; for (size_t i = 0; i < images->size(); ++i) - anim->addFrame(images->get(i), 100, 0, 0); + anim.addFrame(images->get(i), 100, 0, 0); - mIndicator = new SimpleAnimation(anim); + mIndicator = std::make_unique(std::move(anim)); setSize(32, 32); } -ProgressIndicator::~ProgressIndicator() -{ - delete mIndicator; -} +ProgressIndicator::~ProgressIndicator() = default; void ProgressIndicator::logic() { diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index 13cab227..428bbd02 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -23,6 +23,8 @@ #include +#include + class SimpleAnimation; /** @@ -39,7 +41,7 @@ public: void draw(gcn::Graphics *graphics) override; private: - SimpleAnimation *mIndicator; + std::unique_ptr mIndicator; }; #endif // PROGRESSINDICATOR_H -- cgit v1.2.3-70-g09d2