1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#include "GlobalFunc.h"
#include "T2BitImage.h"
#include "T2DlgItemAnimation.h"
#include "T2ImageObj.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
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*/ 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 inModule, int inResID, int unk) {
if (mBitImage)
delete mBitImage;
if (mImageObj)
delete mImageObj;
#line 60
mBitImage = new T2BitImage(GetWorldModuleHandle(), inResID, true);
mImageObj = new T2ImageObj;
mImageObj->AddObject(GetWorldModuleHandle(), inResID, mBitImage);
mStartFrame = 0;
mCurrentFrame = 0;
}
void T2DlgItemAnimation::SetAnimationParam(int inDelay, int inStartFrame) {
mDelay = inDelay;
mStartFrame = inStartFrame;
if (mTimerCreated) {
KillTimer(100);
SetTimer(100, mDelay, NULL);
}
}
/*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(UINT id) {
if (id == 100) {
mCurrentFrame++;
InvalidateRect(NULL);
} else {
T2DlgItem::OnT2Timer(id);
}
}
|