summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2DlgItemAnimation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2DlgItemAnimation.cpp')
-rw-r--r--src/T2DLL/T2DlgItemAnimation.cpp78
1 files changed, 72 insertions, 6 deletions
diff --git a/src/T2DLL/T2DlgItemAnimation.cpp b/src/T2DLL/T2DlgItemAnimation.cpp
index ae5ff6b..b2f8589 100644
--- a/src/T2DLL/T2DlgItemAnimation.cpp
+++ b/src/T2DLL/T2DlgItemAnimation.cpp
@@ -1,25 +1,91 @@
+#include "GlobalFunc.h"
+#include "T2BitImage.h"
#include "T2DlgItemAnimation.h"
+#include "T2ImageObj.h"
-T2DlgItemAnimation::T2DlgItemAnimation(T2TowerDoc*, T2ImageObj*, CPalette*) {
+T2DlgItemAnimation::T2DlgItemAnimation(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
+ : T2DlgItem(inDoc, inImageObj, inPalette)
+{
+ mBitImage = NULL;
+ mImageObj = NULL;
+ mStartFrame = 0;
+ mDelay = 500;
+ mTimerCreated = false;
}
/*virtual*/ T2DlgItemAnimation::~T2DlgItemAnimation() {
+ if (mBitImage)
+ delete mBitImage;
+ if (mImageObj)
+ delete mImageObj;
}
-/*virtual*/ int T2DlgItemAnimation::OnT2DlgItemEraseBkgnd(CDC*) {
+/*virtual*/ BOOL T2DlgItemAnimation::OnT2DlgItemEraseBkgnd(CDC* pDC) {
+ CRect rect;
+ GetClientRect(rect);
+
+ int save = pDC->SaveDC();
+ pDC->SelectPalette(mPalette, false);
+ pDC->RealizePalette();
+
+ if (mImageObj) {
+ int objID;
+ retry:
+ objID = mImageObj->FindObject("ANIM", mCurrentFrame);
+ if (objID == -1) {
+ mCurrentFrame = mStartFrame;
+ goto retry;
+ }
+
+ mImageObj->DrawObject(pDC, objID, rect);
+ }
+
+ pDC->RestoreDC(save);
+
+ return true;
}
-void T2DlgItemAnimation::SetAnimation(HINSTANCE, int, int) {
+void T2DlgItemAnimation::SetAnimation(HINSTANCE inModule, int inResID, int unk) {
+ if (mBitImage)
+ delete mBitImage;
+ if (mImageObj)
+ delete mImageObj;
+
+#line 60
+ mBitImage = DEBUG_NEW T2BitImage(GetWorldModuleHandle(), inResID, true);
+ mImageObj = DEBUG_NEW T2ImageObj;
+ mImageObj->AddObject(GetWorldModuleHandle(), inResID, mBitImage);
+
+ mStartFrame = 0;
+ mCurrentFrame = 0;
}
-void T2DlgItemAnimation::SetAnimationParam(int, int) {
+void T2DlgItemAnimation::SetAnimationParam(int inDelay, int inStartFrame) {
+ mDelay = inDelay;
+ mStartFrame = inStartFrame;
+
+ if (mTimerCreated) {
+ KillTimer(100);
+ SetTimer(100, mDelay, NULL);
+ }
}
-/*virtual*/ int T2DlgItemAnimation::OnT2DlgItemCreate(CREATESTRUCTA*) {
+/*virtual*/ int T2DlgItemAnimation::OnT2DlgItemCreate(CREATESTRUCT*) {
+ SetTimer(100, mDelay, NULL);
+ mTimerCreated = true;
+ return 0;
}
/*virtual*/ void T2DlgItemAnimation::OnT2Close() {
+ KillTimer(100);
+ mTimerCreated = false;
}
-/*virtual*/ void T2DlgItemAnimation::OnT2Timer(unsigned int) {
+/*virtual*/ void T2DlgItemAnimation::OnT2Timer(UINT id) {
+ if (id == 100) {
+ mCurrentFrame++;
+ InvalidateRect(NULL);
+ } else {
+ T2DlgItem::OnT2Timer(id);
+ }
}