1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#include "StdAfx.h"
#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;
}
|