Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OptDlg.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: OptDlg.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 "OptDlg.h"
17 #include "MenuScreen.h"
18 #include "Starshatter.h"
19 #include "Ship.h"
20 #include "HUDView.h"
21 #include "Player.h"
22 
23 #include "DataLoader.h"
24 #include "Button.h"
25 #include "ListBox.h"
26 #include "Slider.h"
27 #include "Video.h"
28 #include "Keyboard.h"
29 #include "MachineInfo.h"
30 
31 // +--------------------------------------------------------------------+
32 // DECLARE MAPPING FUNCTIONS:
33 
34 DEF_MAP_CLIENT(OptDlg, OnApply);
35 DEF_MAP_CLIENT(OptDlg, OnCancel);
36 DEF_MAP_CLIENT(OptDlg, OnEnter);
37 DEF_MAP_CLIENT(OptDlg, OnExit);
38 DEF_MAP_CLIENT(OptDlg, OnAudio);
39 DEF_MAP_CLIENT(OptDlg, OnVideo);
40 DEF_MAP_CLIENT(OptDlg, OnOptions);
41 DEF_MAP_CLIENT(OptDlg, OnControls);
42 DEF_MAP_CLIENT(OptDlg, OnMod);
43 
44 // +--------------------------------------------------------------------+
45 
47 : FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr),
48 apply(0), cancel(0), vid_btn(0), aud_btn(0), ctl_btn(0), opt_btn(0), mod_btn(0),
49 closed(true)
50 {
51  Init(def);
52 }
53 
55 {
56 }
57 
58 // +--------------------------------------------------------------------+
59 
60 void
62 {
63  if (apply)
64  return;
65 
68  landings = (ComboBox*) FindControl(202);
70  hud_mode = (ComboBox*) FindControl(204);
71  hud_color = (ComboBox*) FindControl(205);
72  ff_mode = (ComboBox*) FindControl(206);
73  grid_mode = (ComboBox*) FindControl(207);
74  gunsight = (ComboBox*) FindControl(208);
75  description = FindControl(500);
76  apply = (Button*) FindControl(1);
77  cancel = (Button*) FindControl(2);
78  vid_btn = (Button*) FindControl(901);
79  aud_btn = (Button*) FindControl(902);
80  ctl_btn = (Button*) FindControl(903);
81  opt_btn = (Button*) FindControl(904);
82  mod_btn = (Button*) FindControl(905);
83 
84  if (flight_model) {
87  }
88 
89  if (flying_start) {
92  }
93 
94  if (landings) {
97  }
98 
99  if (ai_difficulty) {
102  }
103 
104  if (hud_mode) {
107  }
108 
109  if (hud_color) {
112  }
113 
114  if (ff_mode) {
117  }
118 
119  if (grid_mode) {
122  }
123 
124  if (gunsight) {
127  }
128 
129  if (apply)
131 
132  if (cancel)
134 
135  if (vid_btn)
137 
138  if (aud_btn)
140 
141  if (ctl_btn)
143 
144  if (opt_btn)
146 
147  if (mod_btn)
149 }
150 
151 // +--------------------------------------------------------------------+
152 
153 void
155 {
157 
158  if (closed) {
160 
161  if (stars) {
162  if (flight_model)
164 
165  if (landings)
167 
168  if (hud_mode)
170 
171  if (hud_color)
173 
174  if (ff_mode)
176  }
177 
178  Player* player = Player::GetCurrentPlayer();
179  if (player) {
180  if (flying_start)
182 
183  if (ai_difficulty)
185 
186  if (grid_mode)
187  grid_mode->SetSelection(player->GridMode());
188 
189  if (gunsight)
190  gunsight->SetSelection(player->Gunsight());
191  }
192  }
193 
194  if (vid_btn) vid_btn->SetButtonState(0);
195  if (aud_btn) aud_btn->SetButtonState(0);
196  if (ctl_btn) ctl_btn->SetButtonState(0);
197  if (opt_btn) opt_btn->SetButtonState(1);
198  if (mod_btn) mod_btn->SetButtonState(0);
199 
200  closed = false;
201 }
202 
203 // +--------------------------------------------------------------------+
204 
205 void
207 {
208  if (Keyboard::KeyDown(VK_RETURN)) {
209  OnApply(0);
210  }
211 }
212 
213 // +--------------------------------------------------------------------+
214 
220 
221 // +--------------------------------------------------------------------+
222 
223 void
225 {
227 }
228 
229 void
231 {
233 }
234 
235 // +--------------------------------------------------------------------+
236 
237 void
239 {
240  ActiveWindow* src = event->window;
241 
242  if (src && description)
243  description->SetText(src->GetAltText());
244 }
245 
246 void
248 {
249  ComboBox* cmb = (ComboBox*) event->window;
250 
251  if (!cmb || cmb->IsListShowing())
252  return;
253 
254  if (description)
255  description->SetText("");
256 }
257 
258 // +--------------------------------------------------------------------+
259 
260 void
262 {
263  if (closed) return;
264 
265  Player* player = Player::GetCurrentPlayer();
266  if (player) {
267  if (flight_model)
269 
270  if (flying_start)
272 
273  if (landings)
275 
276  if (ai_difficulty)
278 
279  if (hud_mode)
281 
282  if (hud_color)
284 
285  if (ff_mode)
287 
288  if (grid_mode)
290 
291  if (gunsight)
293 
294  Player::Save();
295  }
296 
297  if (flight_model)
299 
300  if (landings)
302 
303  if (hud_mode)
305 
306  if (hud_color)
308 
309  if (ff_mode)
311 
312  HUDView* hud = HUDView::GetInstance();
313  if (hud) hud->SetHUDColorSet(hud_color->GetSelectedIndex());
314 
315  closed = true;
316 }
317 
318 void
320 {
321  closed = true;
322 }