diff options
Diffstat (limited to 'src/T2CtrlPalette.cpp')
-rw-r--r-- | src/T2CtrlPalette.cpp | 233 |
1 files changed, 233 insertions, 0 deletions
diff --git a/src/T2CtrlPalette.cpp b/src/T2CtrlPalette.cpp new file mode 100644 index 0000000..ee01d9a --- /dev/null +++ b/src/T2CtrlPalette.cpp @@ -0,0 +1,233 @@ +#include "T2CtrlPalette.h" +#include "T2ImageObj.h" +#include "T2MWControl.h" +#include "T2TowerDoc.h" +#include "T2WorldDef.h" + +// T2.exe 44795C +/*static*/ int T2CtrlPalette::sUnknown = 0; + +T2CtrlPalette::T2CtrlPalette() { +#line 19 + mPauseControl = DEBUG_NEW T2MWControl; + mInViewControl = DEBUG_NEW T2MWControl; + mOutViewControl = DEBUG_NEW T2MWControl; + mMaintControl = DEBUG_NEW T2MWControl; + mEvalControl = DEBUG_NEW T2MWControl; + mTransControl = DEBUG_NEW T2MWControl; + mPriceControl = DEBUG_NEW T2MWControl; + mSliderControl = DEBUG_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::Setup(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 which) { + mInViewControl->SetData(0); + mOutViewControl->SetData(0); + mMaintControl->SetData(0); + mEvalControl->SetData(0); + mTransControl->SetData(0); + mPriceControl->SetData(0); + + int walkRate = mDocument->towerDoc_vf148(); + if (walkRate == -1) + walkRate = 0; + else + walkRate = 7 - walkRate; + mSliderControl->SetData(walkRate); + + switch (which) { + case 0: + mInViewControl->SetData(100); + break; + case 1: + mOutViewControl->SetData(100); + break; + case 4: + mMaintControl->SetData(100); + break; + case 2: + mEvalControl->SetData(100); + break; + case 5: + mTransControl->SetData(100); + break; + case 3: + mPriceControl->SetData(100); + break; + } + + InvalidateRect(NULL); +} + +/*virtual*/ void T2CtrlPalette::vf104(int which) { + RECT windowRect; + RECT clientRect; + int flag = 0; + int y; + + switch (which) { + case 0: + case 6: + y = 0; + break; + case 1: + y = 0; + flag = 1; + break; + case 4: + y = 21; + mE0 = "Maint"; + break; + case 2: + y = 21; + mE0 = "Eval"; + break; + case 5: + y = 21; + mE0 = "Trans"; + break; + case 3: + 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(kTowerDocWindowType0); +} + +/*virtual*/ void T2CtrlPalette::vf108() { +} |