summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2TreasurePane.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
commitc0c336500955a23e344651e5412c9d9d441ef4ee (patch)
tree790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2TreasurePane.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2TreasurePane.cpp53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/T2DLL/T2TreasurePane.cpp b/src/T2DLL/T2TreasurePane.cpp
index a6ed42c..85057c2 100644
--- a/src/T2DLL/T2TreasurePane.cpp
+++ b/src/T2DLL/T2TreasurePane.cpp
@@ -1,22 +1,65 @@
+#include "T2BitImage.h"
+#include "T2PluginSpecifier.h"
+#include "T2TowerDoc.h"
#include "T2TreasurePane.h"
-T2TreasurePane::T2TreasurePane(T2TowerDoc*, T2ImageObj*, CPalette*) {
+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*, int, int) {
+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*) {
+/*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*/ int T2TreasurePane::OnT2DlgItemEraseBkgnd(CDC*) {
+/*virtual*/ BOOL T2TreasurePane::OnT2DlgItemEraseBkgnd(CDC* pDC) {
+ DrawSelf(pDC);
+ return true;
}
-/*virtual*/ int T2TreasurePane::OnCreate(CREATESTRUCTA*) {
+/*virtual*/ int T2TreasurePane::OnCreate(CREATESTRUCT* inCreateStruct) {
+ return T2DlgItem::OnCreate(inCreateStruct);
}