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
|
#include "StdAfx.h"
#include "T2BitImage.h"
#include "T2PluginSpecifier.h"
#include "../T2TowerDoc.h"
#include "T2TreasurePane.h"
T2TreasurePane::T2TreasurePane(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
: T2DlgItem(inDoc, inImageObj, inPalette)
{
mImages[1] = NULL;
mImages[0] = NULL;
mCurrentImage = 0;
mLastChangeAt = 0;
}
/*virtual*/ T2TreasurePane::~T2TreasurePane() {
if (mImages[0])
delete mImages[0];
if (mImages[1])
delete mImages[1];
}
void T2TreasurePane::SetAnimPics(T2TowerDoc* inDoc, int inID1, int inID2) {
if (inDoc) {
HINSTANCE theModule = inDoc->mWorldPluginSpecifier->mInstance;
mImages[0] = new T2BitImage(theModule, inID1, true);
mImages[1] = new T2BitImage(theModule, inID2, true);
}
}
/*virtual*/ void T2TreasurePane::DrawSelf(CDC* pDC) {
if (mImages[0]) {
int dcSave = pDC->SaveDC();
pDC->SelectPalette(mPalette, false);
pDC->RealizePalette();
RECT src, dst;
SetRect(&src, 0, 0, mImages[mCurrentImage]->mBitmap.header.biWidth, mImages[mCurrentImage]->mBitmap.header.biHeight);
dst = src;
mImages[mCurrentImage]->CopyImage(pDC, src, dst);
pDC->RestoreDC(dcSave);
}
}
/*virtual*/ void T2TreasurePane::SpendTime() {
DWORD now = GetTickCount();
if (mLastChangeAt == 0) {
mLastChangeAt = now;
} else if ((now - mLastChangeAt) > 30) {
mCurrentImage = !mCurrentImage;
mLastChangeAt = now;
InvalidateRect(NULL);
}
}
/*virtual*/ BOOL T2TreasurePane::OnT2DlgItemEraseBkgnd(CDC* pDC) {
DrawSelf(pDC);
return true;
}
/*virtual*/ int T2TreasurePane::OnCreate(CREATESTRUCT* inCreateStruct) {
return T2DlgItem::OnCreate(inCreateStruct);
}
|