summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-05 22:31:49 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-05 22:31:49 +0300
commit73432d5972f8a3d2a339260246f3a44842dac58e (patch)
tree9352472b7fb0714b2d898a19f343f8b0456afa38 /src/gui
parent12273c046fff6b2f778ef4c3cc0d8014d86233e5 (diff)
downloadmanaplus-73432d5972f8a3d2a339260246f3a44842dac58e.tar.gz
manaplus-73432d5972f8a3d2a339260246f3a44842dac58e.tar.bz2
manaplus-73432d5972f8a3d2a339260246f3a44842dac58e.tar.xz
manaplus-73432d5972f8a3d2a339260246f3a44842dac58e.zip
Add support for play animation in cutins.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/cutinwindow.cpp42
-rw-r--r--src/gui/windows/cutinwindow.h8
2 files changed, 28 insertions, 22 deletions
diff --git a/src/gui/windows/cutinwindow.cpp b/src/gui/windows/cutinwindow.cpp
index 910c6d562..d1c63e8f5 100644
--- a/src/gui/windows/cutinwindow.cpp
+++ b/src/gui/windows/cutinwindow.cpp
@@ -24,8 +24,12 @@
#include "configuration.h"
-#include "resources/image.h"
-#include "resources/resourcemanager.h"
+#include "const/utils/timer.h"
+
+#include "resources/sprite/animatedsprite.h"
+
+#include "utils/delete2.h"
+#include "utils/timer.h"
#include "debug.h"
@@ -48,16 +52,7 @@ CutInWindow::CutInWindow() :
CutInWindow::~CutInWindow()
{
- deleteImage();
-}
-
-void CutInWindow::deleteImage()
-{
- if (mImage)
- {
- mImage->decRef();
- mImage = nullptr;
- }
+ delete2(mImage);
}
void CutInWindow::draw(Graphics *graphics)
@@ -75,35 +70,37 @@ void CutInWindow::safeDraw(Graphics *graphics)
void CutInWindow::draw2(Graphics *const graphics)
{
if (mImage)
- graphics->drawImage(mImage, mPadding, mTitleBarHeight);
+ mImage->drawRaw(graphics, mPadding, mTitleBarHeight);
}
void CutInWindow::show(const std::string &name,
const CutIn cutin)
{
- deleteImage();
+ delete2(mImage);
if (name.empty())
{
setVisible(Visible_false);
}
else
{
- mImage = resourceManager->getImage(
+ mImage = AnimatedSprite::load(
std::string(paths.getStringValue("cutInsDir")).append(
"/").append(
name).append(
- ".png"));
+ ".xml"));
if (mImage)
{
+ mImage->update(1);
const bool showTitle = (cutin == CutIn::MovableClose);
if (showTitle)
mTitleBarHeight = mOldTitleBarHeight;
else
mTitleBarHeight = mPadding;
- const int width = mImage->mBounds.w + 2 * mPadding;
- const int height = mImage->mBounds.h + mTitleBarHeight
+ const int width = mImage->getWidth() + 2 * mPadding;
+ const int height = mImage->getHeight() + mTitleBarHeight
+ mPadding;
+ logger->log("detected sizes: %d, %d", mImage->getWidth(), mImage->getHeight());
const int screenWidth = mainGraphics->mWidth;
const int screenHeight = mainGraphics->mHeight;
@@ -141,3 +138,12 @@ void CutInWindow::show(const std::string &name,
}
}
}
+
+void CutInWindow::logic()
+{
+ if (mImage)
+ {
+ const int time = tick_time * MILLISECONDS_IN_A_TICK;
+ mImage->update(time);
+ }
+}
diff --git a/src/gui/windows/cutinwindow.h b/src/gui/windows/cutinwindow.h
index 2892f8548..f708242bd 100644
--- a/src/gui/windows/cutinwindow.h
+++ b/src/gui/windows/cutinwindow.h
@@ -27,7 +27,7 @@
#include "enums/cutin.h"
-class Image;
+class AnimatedSprite;
class CutInWindow final : public Window
{
@@ -47,10 +47,10 @@ class CutInWindow final : public Window
void show(const std::string &name,
const CutIn cutin);
- private:
- void deleteImage();
+ void logic() override final;
- Image *mImage;
+ private:
+ AnimatedSprite *mImage;
int mOldTitleBarHeight;
};