summaryrefslogtreecommitdiff
path: root/src/gui/windows/cutinwindow.cpp
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/windows/cutinwindow.cpp
parent12273c046fff6b2f778ef4c3cc0d8014d86233e5 (diff)
downloadplus-73432d5972f8a3d2a339260246f3a44842dac58e.tar.gz
plus-73432d5972f8a3d2a339260246f3a44842dac58e.tar.bz2
plus-73432d5972f8a3d2a339260246f3a44842dac58e.tar.xz
plus-73432d5972f8a3d2a339260246f3a44842dac58e.zip
Add support for play animation in cutins.
Diffstat (limited to 'src/gui/windows/cutinwindow.cpp')
-rw-r--r--src/gui/windows/cutinwindow.cpp42
1 files changed, 24 insertions, 18 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);
+ }
+}