Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
MenuDlg.cpp
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: MenuDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Main Menu Dialog Active Window class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
MenuDlg.h
"
17
#include "
MenuScreen.h
"
18
#include "
Starshatter.h
"
19
#include "
Campaign.h
"
20
21
#include "
Game.h
"
22
#include "
DataLoader.h
"
23
#include "
Button.h
"
24
#include "
ListBox.h
"
25
#include "
Slider.h
"
26
#include "
Video.h
"
27
#include "
Keyboard.h
"
28
#include "
Mouse.h
"
29
#include "
ParseUtil.h
"
30
31
// +--------------------------------------------------------------------+
32
// DECLARE MAPPING FUNCTIONS:
33
34
DEF_MAP_CLIENT
(
MenuDlg
, OnStart);
35
DEF_MAP_CLIENT
(
MenuDlg
, OnCampaign);
36
DEF_MAP_CLIENT
(
MenuDlg
, OnMission);
37
DEF_MAP_CLIENT
(
MenuDlg
, OnPlayer);
38
DEF_MAP_CLIENT
(
MenuDlg
, OnMultiplayer);
39
DEF_MAP_CLIENT
(
MenuDlg
, OnMod);
40
DEF_MAP_CLIENT
(
MenuDlg
, OnTacReference);
41
DEF_MAP_CLIENT
(
MenuDlg
, OnVideo);
42
DEF_MAP_CLIENT
(
MenuDlg
, OnOptions);
43
DEF_MAP_CLIENT
(
MenuDlg
, OnControls);
44
DEF_MAP_CLIENT
(
MenuDlg
, OnQuit);
45
DEF_MAP_CLIENT
(
MenuDlg
, OnButtonEnter);
46
DEF_MAP_CLIENT
(
MenuDlg
, OnButtonExit);
47
48
extern
const
char
*
versionInfo
;
49
50
// +--------------------------------------------------------------------+
51
52
MenuDlg::MenuDlg
(
Screen
* s,
FormDef
& def,
MenuScreen
* mgr)
53
:
FormWindow
(s, 0, 0, s->Width(), s->Height()),
54
manager(mgr), btn_start(0),
55
btn_campaign(0), btn_mission(0), btn_player(0), btn_multi(0),
56
btn_mod(0), btn_tac(0),
57
btn_options(0), btn_controls(0), btn_quit(0),
58
version(0), description(0), stars(0), campaign(0)
59
{
60
stars
=
Starshatter::GetInstance
();
61
campaign
=
Campaign::GetCampaign
();
62
63
Init
(def);
64
}
65
66
MenuDlg::~MenuDlg
()
67
{
68
}
69
70
// +--------------------------------------------------------------------+
71
72
void
73
MenuDlg::RegisterControls
()
74
{
75
if
(
btn_start
)
76
return
;
77
78
btn_start
= (
Button
*)
FindControl
(120);
79
btn_campaign
= (
Button
*)
FindControl
(101);
80
btn_mission
= (
Button
*)
FindControl
(102);
81
btn_player
= (
Button
*)
FindControl
(103);
82
btn_multi
= (
Button
*)
FindControl
(104);
83
btn_video
= (
Button
*)
FindControl
(111);
84
btn_options
= (
Button
*)
FindControl
(112);
85
btn_controls
= (
Button
*)
FindControl
(113);
86
btn_quit
= (
Button
*)
FindControl
(114);
87
btn_mod
= (
Button
*)
FindControl
(115);
88
btn_tac
= (
Button
*)
FindControl
(116);
89
90
if
(
btn_start
) {
91
REGISTER_CLIENT
(
EID_CLICK
,
btn_start
,
MenuDlg
,
OnStart
);
92
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_start
,
MenuDlg
,
OnButtonEnter
);
93
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_start
,
MenuDlg
,
OnButtonExit
);
94
}
95
96
if
(
btn_campaign
) {
97
REGISTER_CLIENT
(
EID_CLICK
,
btn_campaign
,
MenuDlg
,
OnCampaign
);
98
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_campaign
,
MenuDlg
,
OnButtonEnter
);
99
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_campaign
,
MenuDlg
,
OnButtonExit
);
100
}
101
102
if
(
btn_mission
) {
103
REGISTER_CLIENT
(
EID_CLICK
,
btn_mission
,
MenuDlg
,
OnMission
);
104
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_mission
,
MenuDlg
,
OnButtonEnter
);
105
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_mission
,
MenuDlg
,
OnButtonExit
);
106
}
107
108
if
(
btn_player
) {
109
REGISTER_CLIENT
(
EID_CLICK
,
btn_player
,
MenuDlg
,
OnPlayer
);
110
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_player
,
MenuDlg
,
OnButtonEnter
);
111
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_player
,
MenuDlg
,
OnButtonExit
);
112
}
113
114
if
(
btn_multi
) {
115
REGISTER_CLIENT
(
EID_CLICK
,
btn_multi
,
MenuDlg
,
OnMultiplayer
);
116
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_multi
,
MenuDlg
,
OnButtonEnter
);
117
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_multi
,
MenuDlg
,
OnButtonExit
);
118
}
119
120
if
(
btn_video
) {
121
REGISTER_CLIENT
(
EID_CLICK
,
btn_video
,
MenuDlg
,
OnVideo
);
122
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_video
,
MenuDlg
,
OnButtonEnter
);
123
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_video
,
MenuDlg
,
OnButtonExit
);
124
}
125
126
if
(
btn_options
) {
127
REGISTER_CLIENT
(
EID_CLICK
,
btn_options
,
MenuDlg
,
OnOptions
);
128
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_options
,
MenuDlg
,
OnButtonEnter
);
129
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_options
,
MenuDlg
,
OnButtonExit
);
130
}
131
132
if
(
btn_controls
) {
133
REGISTER_CLIENT
(
EID_CLICK
,
btn_controls
,
MenuDlg
,
OnControls
);
134
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_controls
,
MenuDlg
,
OnButtonEnter
);
135
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_controls
,
MenuDlg
,
OnButtonExit
);
136
}
137
138
if
(
btn_mod
) {
139
REGISTER_CLIENT
(
EID_CLICK
,
btn_mod
,
MenuDlg
,
OnMod
);
140
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_mod
,
MenuDlg
,
OnButtonEnter
);
141
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_mod
,
MenuDlg
,
OnButtonExit
);
142
}
143
144
if
(
btn_tac
) {
145
REGISTER_CLIENT
(
EID_CLICK
,
btn_tac
,
MenuDlg
,
OnTacReference
);
146
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_tac
,
MenuDlg
,
OnButtonEnter
);
147
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_tac
,
MenuDlg
,
OnButtonExit
);
148
}
149
150
if
(
btn_quit
) {
151
REGISTER_CLIENT
(
EID_CLICK
,
btn_quit
,
MenuDlg
,
OnQuit
);
152
REGISTER_CLIENT
(
EID_MOUSE_ENTER
,
btn_quit
,
MenuDlg
,
OnButtonEnter
);
153
REGISTER_CLIENT
(
EID_MOUSE_EXIT
,
btn_quit
,
MenuDlg
,
OnButtonExit
);
154
}
155
156
version
=
FindControl
(100);
157
158
if
(
version
) {
159
version
->
SetText
(
versionInfo
);
160
}
161
162
description
=
FindControl
(202);
163
}
164
165
// +--------------------------------------------------------------------+
166
167
void
168
MenuDlg::Show
()
169
{
170
FormWindow::Show
();
171
172
if
(
btn_multi
&&
Starshatter::UseFileSystem
())
173
btn_multi
->
SetEnabled
(
false
);
174
}
175
176
void
177
MenuDlg::ExecFrame
()
178
{
179
}
180
181
// +--------------------------------------------------------------------+
182
183
void
184
MenuDlg::OnStart
(
AWEvent
* event)
185
{
186
if
(
description
)
description
->
SetText
(
""
);
187
stars
->
StartOrResumeGame
();
188
}
189
190
void
191
MenuDlg::OnCampaign
(
AWEvent
* event)
192
{
193
if
(
description
)
description
->
SetText
(
""
);
194
manager
->
ShowCmpSelectDlg
();
195
}
196
197
void
198
MenuDlg::OnMission
(
AWEvent
* event)
199
{
200
if
(
description
)
description
->
SetText
(
""
);
201
manager
->
ShowMsnSelectDlg
();
202
}
203
204
void
205
MenuDlg::OnPlayer
(
AWEvent
* event)
206
{
207
if
(
description
)
description
->
SetText
(
""
);
208
manager
->
ShowPlayerDlg
();
209
}
210
211
void
212
MenuDlg::OnMultiplayer
(
AWEvent
* event)
213
{
214
if
(
description
)
description
->
SetText
(
""
);
215
manager
->
ShowNetClientDlg
();
216
}
217
218
void
219
MenuDlg::OnVideo
(
AWEvent
* event)
220
{
221
if
(
description
)
description
->
SetText
(
""
);
222
manager
->
ShowVidDlg
();
223
}
224
225
void
226
MenuDlg::OnOptions
(
AWEvent
* event)
227
{
228
if
(
description
)
description
->
SetText
(
""
);
229
manager
->
ShowOptDlg
();
230
}
231
232
void
233
MenuDlg::OnControls
(
AWEvent
* event)
234
{
235
if
(
description
)
description
->
SetText
(
""
);
236
manager
->
ShowCtlDlg
();
237
}
238
239
void
240
MenuDlg::OnMod
(
AWEvent
* event)
241
{
242
if
(
description
)
description
->
SetText
(
""
);
243
manager
->
ShowModDlg
();
244
}
245
246
void
247
MenuDlg::OnTacReference
(
AWEvent
* event)
248
{
249
if
(
description
)
description
->
SetText
(
""
);
250
stars
->
OpenTacticalReference
();
251
}
252
253
void
254
MenuDlg::OnQuit
(
AWEvent
* event)
255
{
256
if
(
description
)
description
->
SetText
(
""
);
257
manager
->
ShowExitDlg
();
258
}
259
260
// +--------------------------------------------------------------------+
261
262
void
263
MenuDlg::OnButtonEnter
(
AWEvent
* event)
264
{
265
ActiveWindow
* src =
event
->window;
266
267
if
(src &&
description
)
268
description
->
SetText
(src->
GetAltText
());
269
}
270
271
void
272
MenuDlg::OnButtonExit
(
AWEvent
* event)
273
{
274
if
(
description
)
275
description
->
SetText
(
""
);
276
}
Stars45
MenuDlg.cpp
Generated on Thu May 31 2012 16:31:09 for Starshatter_Open by
1.8.1