#include "SpeedDlg.h" #include "T2.h" #include "T2DlgItem.h" #include "T2MainWindow.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 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->GetDrawSpeed(); 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 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->SetDrawSpeed(mCurrentSpeed); } /*virtual*/ void SpeedDlg::OnT2Create() { mCurrentIndex = -1; T2DlgItem *theRadio; T2DlgItem *theTopSpeedText; for (int index = 0; index < 5; index++) { if (mCurrentSpeed == speedValues[index]) { mCurrentIndex = index; theRadio = GetT2DlgItem(105 + mCurrentIndex); theRadio->SetValue(1); break; } } if (mCurrentIndex != 4) { theTopSpeedText = GetT2DlgItem(104); theRadio = GetT2DlgItem(109); theTopSpeedText->ShowWindow(SW_HIDE); theRadio->ShowWindow(SW_HIDE); } } /*virtual*/ BOOL SpeedDlg::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) { BOOL theRes = true; WORD id = LOWORD(inWParam); T2DlgItem *theRadio; T2DlgItem *theTopSpeedText; switch (id) { case 105: case 106: case 107: case 108: case 109: mCurrentSpeed = speedValues[id - 105]; if (mCurrentIndex != -1) { theRadio = GetT2DlgItem(105 + mCurrentIndex); theRadio->SetValue(0); } mCurrentIndex = id - 105; theRadio = GetT2DlgItem(105 + mCurrentIndex); theRadio->SetValue(1); break; case 110: theTopSpeedText = GetT2DlgItem(104); theRadio = GetT2DlgItem(109); theTopSpeedText->ShowWindow(SW_SHOW); theRadio->ShowWindow(SW_SHOW); break; default: theRes = T2Dialog::OnT2DialogCommand(inWParam, inLParam); } return theRes; }