Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PlanScreen.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
6  FILE: PlanScreen.cpp
7  AUTHOR: John DiCamillo
8 
9 */
10 
11 #include "MemDebug.h"
12 #include "PlanScreen.h"
13 #include "FormDef.h"
14 #include "MsnObjDlg.h"
15 #include "MsnPkgDlg.h"
16 #include "MsnWepDlg.h"
17 #include "MsnNavDlg.h"
18 #include "DebriefDlg.h"
19 #include "AwardDlg.h"
20 #include "Campaign.h"
21 #include "Mission.h"
22 #include "Sim.h"
23 #include "Starshatter.h"
24 #include "StarSystem.h"
25 
26 #include "Game.h"
27 #include "Video.h"
28 #include "Screen.h"
29 #include "ActiveWindow.h"
30 #include "Mouse.h"
31 #include "Keyboard.h"
32 #include "FadeView.h"
33 #include "Color.h"
34 #include "Bitmap.h"
35 #include "Font.h"
36 #include "FontMgr.h"
37 #include "EventDispatch.h"
38 #include "DataLoader.h"
39 #include "Resource.h"
40 
41 // +--------------------------------------------------------------------+
42 
44 : screen(0), navdlg(0), award_dlg(0), debrief_dlg(0),
45 objdlg(0), pkgdlg(0), wepdlg(0), isShown(false)
46 {
47  loader = DataLoader::GetLoader();
48 }
49 
51 {
52  TearDown();
53 }
54 
55 // +--------------------------------------------------------------------+
56 
57 void
59 {
60  if (!s)
61  return;
62 
63  screen = s;
64 
65  // create windows
66  loader->UseFileSystem(true);
67 
68  FormDef msn_obj_def("MsnObjDlg", 0);
69  msn_obj_def.Load("MsnObjDlg");
70  objdlg = new(__FILE__,__LINE__) MsnObjDlg(screen, msn_obj_def, this);
71 
72  FormDef msn_pkg_def("MsnPkgDlg", 0);
73  msn_pkg_def.Load("MsnPkgDlg");
74  pkgdlg = new(__FILE__,__LINE__) MsnPkgDlg(screen, msn_pkg_def, this);
75 
76  FormDef msn_nav_def("MsnNavDlg", 0);
77  msn_nav_def.Load("MsnNavDlg");
78  navdlg = new(__FILE__,__LINE__) MsnNavDlg(screen, msn_nav_def, this);
79 
80  FormDef msn_wep_def("MsnWepDlg", 0);
81  msn_wep_def.Load("MsnWepDlg");
82  wepdlg = new(__FILE__,__LINE__) MsnWepDlg(screen, msn_wep_def, this);
83 
84  FormDef award_def("AwardDlg", 0);
85  award_def.Load("AwardDlg");
86  award_dlg = new(__FILE__,__LINE__) AwardDlg(screen, award_def, this);
87 
88  FormDef debrief_def("DebriefDlg", 0);
89  debrief_def.Load("DebriefDlg");
90  debrief_dlg = new(__FILE__,__LINE__) DebriefDlg(screen, debrief_def, this);
91 
93  ShowMsnDlg();
94 }
95 
96 // +--------------------------------------------------------------------+
97 
98 void
100 {
101  if (screen) {
102  screen->DelWindow(objdlg);
103  screen->DelWindow(pkgdlg);
104  screen->DelWindow(wepdlg);
105  screen->DelWindow(navdlg);
106  screen->DelWindow(debrief_dlg);
107  screen->DelWindow(award_dlg);
108  }
109 
110  delete objdlg;
111  delete pkgdlg;
112  delete wepdlg;
113  delete navdlg;
114  delete debrief_dlg;
115  delete award_dlg;
116 
117  objdlg = 0;
118  pkgdlg = 0;
119  wepdlg = 0;
120  navdlg = 0;
121  debrief_dlg = 0;
122  award_dlg = 0;
123  screen = 0;
124 }
125 
126 // +--------------------------------------------------------------------+
127 
128 void
130 {
132 
133  Mission* mission = 0;
134  Campaign* campaign = Campaign::GetCampaign();
135 
136  if (campaign)
137  mission = campaign->GetMission();
138 
139  if (navdlg) {
140  navdlg->SetMission(mission);
141 
142  if (navdlg->IsShown())
143  navdlg->ExecFrame();
144  }
145 
146  if (objdlg && objdlg->IsShown()) {
147  objdlg->ExecFrame();
148  }
149 
150  if (pkgdlg && pkgdlg->IsShown()) {
151  pkgdlg->ExecFrame();
152  }
153 
154  if (wepdlg && wepdlg->IsShown()) {
155  wepdlg->ExecFrame();
156  }
157 
158  if (award_dlg && award_dlg->IsShown()) {
159  award_dlg->ExecFrame();
160  }
161 
162  if (debrief_dlg && debrief_dlg->IsShown()) {
163  debrief_dlg->ExecFrame();
164  }
165 }
166 
167 // +--------------------------------------------------------------------+
168 
169 bool
171 {
172  if (debrief_dlg->IsShown()) {
173  debrief_dlg->OnClose(0);
174  }
175 
176  if (award_dlg->IsShown()) {
177  return true;
178  }
179 
180  return false;
181 }
182 
183 void
185 {
186  if (!isShown) {
187  ShowMsnDlg();
188  isShown = true;
189  }
190 }
191 
192 void
194 {
195  HideAll();
196  isShown = false;
197 }
198 
199 // +--------------------------------------------------------------------+
200 
201 void
203 {
204  HideAll();
205  Mouse::Show(true);
206  objdlg->Show();
207 }
208 
209 // +--------------------------------------------------------------------+
210 
211 void
213 {
214  HideAll();
215  Mouse::Show(true);
216  objdlg->Show();
217 }
218 
219 bool
221 {
222  return IsMsnObjShown() || IsMsnPkgShown() || IsMsnWepShown();
223 }
224 
225 // +--------------------------------------------------------------------+
226 
227 void
229 {
230  HideAll();
231  Mouse::Show(true);
232  objdlg->Show();
233 }
234 
235 // +--------------------------------------------------------------------+
236 
237 void
239 {
240  HideAll();
241  Mouse::Show(true);
242 }
243 
244 // +--------------------------------------------------------------------+
245 
246 bool
248 {
249  return objdlg && objdlg->IsShown();
250 }
251 
252 // +--------------------------------------------------------------------+
253 
254 void
256 {
257  HideAll();
258  Mouse::Show(true);
259  pkgdlg->Show();
260 }
261 
262 // +--------------------------------------------------------------------+
263 
264 void
266 {
267  HideAll();
268  Mouse::Show(true);
269 }
270 
271 // +--------------------------------------------------------------------+
272 
273 bool
275 {
276  return pkgdlg && pkgdlg->IsShown();
277 }
278 
279 // +--------------------------------------------------------------------+
280 
281 void
283 {
284  HideAll();
285  Mouse::Show(true);
286  wepdlg->Show();
287 }
288 
289 // +--------------------------------------------------------------------+
290 
291 void
293 {
294  HideAll();
295  Mouse::Show(true);
296 }
297 
298 // +--------------------------------------------------------------------+
299 
300 bool
302 {
303  return wepdlg && wepdlg->IsShown();
304 }
305 
306 // +--------------------------------------------------------------------+
307 
308 void
310 {
311  if (navdlg && !navdlg->IsShown()) {
312  HideAll();
313  Mouse::Show(true);
314  navdlg->Show();
315  }
316 }
317 
318 // +--------------------------------------------------------------------+
319 
320 void
322 {
323  if (navdlg && navdlg->IsShown()) {
324  HideAll();
325  Mouse::Show(true);
326  }
327 }
328 
329 // +--------------------------------------------------------------------+
330 
331 bool
333 {
334  return navdlg && navdlg->IsShown();
335 }
336 
337 // +--------------------------------------------------------------------+
338 
339 void
341 {
342  HideAll();
343  Mouse::Show(true);
344  debrief_dlg->Show();
345 }
346 
347 void
349 {
350  HideAll();
351  Mouse::Show(true);
352 }
353 
354 bool
356 {
357  return debrief_dlg && debrief_dlg->IsShown();
358 }
359 
360 // +--------------------------------------------------------------------+
361 
362 void
364 {
365  HideAll();
366  Mouse::Show(true);
367  award_dlg->Show();
368 }
369 
370 void
372 {
373  HideAll();
374  Mouse::Show(true);
375 }
376 
377 bool
379 {
380  return award_dlg && award_dlg->IsShown();
381 }
382 
383 
384 // +--------------------------------------------------------------------+
385 
386 void
388 {
389  if (objdlg) objdlg->Hide();
390  if (pkgdlg) pkgdlg->Hide();
391  if (wepdlg) wepdlg->Hide();
392  if (navdlg) navdlg->Hide();
393  if (award_dlg) award_dlg->Hide();
394  if (debrief_dlg) debrief_dlg->Hide();
395 }