#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); }