#include "T2CtrlPalette.h" #include "T2ImageObj.h" #include "T2MWControl.h" #include "T2TowerDoc.h" #include "T2WorldDef.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // T2.exe 44795C /*static*/ int T2CtrlPalette::sUnknown = 0; T2CtrlPalette::T2CtrlPalette() { #line 19 mPauseControl = new T2MWControl; mInViewControl = new T2MWControl; mOutViewControl = new T2MWControl; mMaintControl = new T2MWControl; mEvalControl = new T2MWControl; mTransControl = new T2MWControl; mPriceControl = new T2MWControl; mSliderControl = new T2MWControl; mDocument = NULL; mWorldDef = NULL; sUnknown = 0; mIsSetUp = false; } /*virtual*/ T2CtrlPalette::~T2CtrlPalette() { delete mPauseControl; delete mInViewControl; delete mOutViewControl; delete mMaintControl; delete mEvalControl; delete mTransControl; delete mPriceControl; delete mSliderControl; } BEGIN_MESSAGE_MAP(T2CtrlPalette, CFrameWnd) ON_WM_CREATE() ON_WM_QUERYNEWPALETTE() ON_WM_ERASEBKGND() ON_WM_CLOSE() END_MESSAGE_MAP() /*virtual*/ void T2CtrlPalette::SetDocument(T2TowerDoc *inDoc) { mDocument = inDoc; mWorldDef = inDoc->mWorldDef; mE4 = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); RECT rect; mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Pause", 0), rect); mPauseControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2000); mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("InView", 0), rect); mInViewControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2001); mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("OutView", 0), rect); mOutViewControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2006); mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Maint", 0), rect); mMaintControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2004); mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Eval", 0), rect); mEvalControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2003); mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Trans", 0), rect); mTransControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2005); mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Price", 0), rect); mPriceControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2002); mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Slider", 0), rect); mSliderControl->Create(mE4, "", WS_CHILD | WS_VISIBLE, rect, this, 2007); mPauseControl->Setup(inDoc); mInViewControl->Setup(inDoc); mOutViewControl->Setup(inDoc); mMaintControl->Setup(inDoc); mEvalControl->Setup(inDoc); mTransControl->Setup(inDoc); mPriceControl->Setup(inDoc); mSliderControl->Setup(inDoc); mIsSetUp = true; InvalidateRect(NULL); } /*virtual*/ void T2CtrlPalette::vf100(int inViewMode) { mInViewControl->SetData(0); mOutViewControl->SetData(0); mMaintControl->SetData(0); mEvalControl->SetData(0); mTransControl->SetData(0); mPriceControl->SetData(0); int walkRate = mDocument->GetWalkRate(); if (walkRate == -1) walkRate = 0; else walkRate = 7 - walkRate; mSliderControl->SetData(walkRate); switch (inViewMode) { case kInView: mInViewControl->SetData(100); break; case kOutView: mOutViewControl->SetData(100); break; case kMaintView: mMaintControl->SetData(100); break; case kEvalView: mEvalControl->SetData(100); break; case kTransView: mTransControl->SetData(100); break; case kPriceView: mPriceControl->SetData(100); break; } InvalidateRect(NULL); } /*virtual*/ void T2CtrlPalette::vf104(int inViewMode) { #pragma var_order(windowRect, y, clientRect, flag) RECT windowRect; RECT clientRect; int flag = 0; int y; switch (inViewMode) { case kInView: case ViewMode_6: y = 0; break; case kOutView: y = 0; flag = 1; break; case kMaintView: y = 21; mE0 = "Maint"; break; case kEvalView: y = 21; mE0 = "Eval"; break; case kTransView: y = 21; mE0 = "Trans"; break; case kPriceView: y = 21; mE0 = "Price"; break; } GetWindowRect(&windowRect); GetClientRect(&clientRect); SetWindowPos( NULL, 0, 0, windowRect.right - windowRect.left - clientRect.right + 123, windowRect.bottom - windowRect.top - clientRect.bottom + 51 + y, SWP_NOMOVE | SWP_NOZORDER ); InvalidateRect(NULL); } afx_msg int T2CtrlPalette::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; RECT windowRect; RECT clientRect; GetWindowRect(&windowRect); GetClientRect(&clientRect); SetWindowPos( NULL, 0, 0, windowRect.right - windowRect.left - clientRect.right + 123, windowRect.bottom - windowRect.top - clientRect.bottom + 51, SWP_NOMOVE | SWP_NOZORDER ); return 0; } afx_msg BOOL T2CtrlPalette::OnQueryNewPalette() { return CFrameWnd::OnQueryNewPalette(); } afx_msg BOOL T2CtrlPalette::OnEraseBkgnd(CDC* pDC) { if (!mDocument) return CFrameWnd::OnEraseBkgnd(pDC); pDC->SaveDC(); pDC->SelectPalette(mWorldDef->GetPalette(), false); RECT rect; int objectID = mWorldDef->mImageObj->FindObject("CtrlPal"); SetRect(&rect, 0, 0, 123, 51); mWorldDef->mImageObj->DrawObject(pDC, objectID, rect); objectID = mWorldDef->mImageObj->FindObject(mE0, 1000); if (objectID >= 0) { SetRect(&rect, 0, 51, 123, 72); mWorldDef->mImageObj->DrawObject(pDC, objectID, rect); } pDC->RealizePalette(); pDC->RestoreDC(-1); return true; } afx_msg void T2CtrlPalette::OnClose() { if (!mDocument) return; mDocument->towerDoc_vf198(kControlWindow); }