#include "SpeedDlg.h" #include "CT2App.h" #include "T2DlgItem.h" #include "T2MainWindow.h" #include "T2MWControl.h" #include "T2TowerDoc.h" #include "T2WorldDef.h" SpeedDlg::SpeedDlg() { mDeleteOnClose = true; } /*virtual*/ SpeedDlg::~SpeedDlg() { } void SpeedDlg::Setup(T2TowerDoc *inDoc, HINSTANCE inInstance, CWnd *inParentWnd, const POINT &inPt, T2ImageObj *inImageObj) { mDocument = inDoc; mCurrentSpeed = mDocument->towerDoc_vf2A4(); T2DLGTEMPLATE tmpl; tmpl.resID = 7010; tmpl.pt = inPt; tmpl.moduleHandle = inInstance; Realize(inParentWnd, &tmpl, inDoc, inImageObj, inDoc->mWorldDef->GetPalette(), false, inParentWnd, 200, true); ShowWindow(SW_HIDE); } static const int speedValues[] = {125, 25, 20, 5, 1}; void SpeedDlg::Revert() { T2DlgItem *theRadio; if (mCurrentIndex != -1) { theRadio = GetT2DlgItem(105 + mCurrentIndex); theRadio->SetValue(0); } mCurrentIndex = 1; mCurrentSpeed = speedValues[mCurrentIndex]; theRadio = GetT2DlgItem(105 + mCurrentIndex); theRadio->SetValue(1); } void SpeedDlg::Save() { mDocument->towerDoc_vf2A8(mCurrentSpeed); } /*virtual*/ void SpeedDlg::OnT2Create() { mCurrentIndex = -1; T2DlgItem *theRadio; T2DlgItem *theText; for (int i = 0; i < 5; i++) { if (mCurrentSpeed == speedValues[i]) { mCurrentIndex = i; theRadio = GetT2DlgItem(105 + mCurrentIndex); theRadio->SetValue(1); break; } } if (mCurrentIndex != 4) { theText = GetT2DlgItem(104); theRadio = GetT2DlgItem(109); theText->ShowWindow(SW_HIDE); theRadio->ShowWindow(SW_HIDE); } } /*virtual*/ int SpeedDlg::OnT2DialogCommand(UINT cmd, long data) { int result = 1; WORD w = LOWORD(cmd); T2DlgItem *theRadio; T2DlgItem *theText; switch (w) { case 105: case 106: case 107: case 108: case 109: mCurrentSpeed = speedValues[w - 105]; if (mCurrentIndex != -1) { theRadio = GetT2DlgItem(105 + mCurrentIndex); theRadio->SetValue(0); } mCurrentIndex = w - 105; theRadio = GetT2DlgItem(105 + mCurrentIndex); theRadio->SetValue(1); break; case 110: theText = GetT2DlgItem(104); theRadio = GetT2DlgItem(109); theText->ShowWindow(SW_SHOW); theRadio->ShowWindow(SW_SHOW); break; default: result = T2Dialog::OnT2DialogCommand(cmd, data); } return result; }