From c0c336500955a23e344651e5412c9d9d441ef4ee Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 28 Jun 2023 22:22:32 +0100 Subject: first pass of T2DLL --- src/T2DLL/T2TreasurePane.cpp | 53 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) (limited to 'src/T2DLL/T2TreasurePane.cpp') 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); } -- cgit v1.2.3