From 8898ad9b25fca6afe2374d293a981db02a83d7e9 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 31 May 2012 14:46:27 +0000 Subject: Committing the documentation to svn to have it accessible online --- Doc/doxygen/html/_flt_dlg_8cpp_source.html | 1202 ++++++++++++++++++++++++++++ 1 file changed, 1202 insertions(+) create mode 100644 Doc/doxygen/html/_flt_dlg_8cpp_source.html (limited to 'Doc/doxygen/html/_flt_dlg_8cpp_source.html') diff --git a/Doc/doxygen/html/_flt_dlg_8cpp_source.html b/Doc/doxygen/html/_flt_dlg_8cpp_source.html new file mode 100644 index 0000000..60c6714 --- /dev/null +++ b/Doc/doxygen/html/_flt_dlg_8cpp_source.html @@ -0,0 +1,1202 @@ + + + + + +Starshatter_Open: D:/SRC/StarshatterSVN/Stars45/FltDlg.cpp Source File + + + + + + + + + + + + + +
+
+ + + + + + +
+
Starshatter_Open +
+
Open source Starshatter engine
+
+
+ + + + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+
+
FltDlg.cpp
+
+
+Go to the documentation of this file.
1 /* Project Starshatter 4.5
+
2  Destroyer Studios LLC
+
3  Copyright (C) 1997-2004. All Rights Reserved.
+
4 
+
5  SUBSYSTEM: Stars.exe
+
6  FILE: FltDlg.cpp
+
7  AUTHOR: John DiCamillo
+
8 
+
9 
+
10  OVERVIEW
+
11  ========
+
12 */
+
13 
+
14 #include "MemDebug.h"
+
15 #include "FltDlg.h"
+
16 #include "GameScreen.h"
+
17 #include "Sim.h"
+
18 #include "Ship.h"
+
19 #include "ShipDesign.h"
+
20 #include "Hangar.h"
+
21 #include "FlightDeck.h"
+
22 #include "Element.h"
+
23 #include "CombatGroup.h"
+
24 #include "Mission.h"
+
25 #include "RadioMessage.h"
+
26 #include "RadioTraffic.h"
+
27 #include "Instruction.h"
+
28 #include "FlightPlanner.h"
+
29 #include "NetUtil.h"
+
30 
+
31 #include "Game.h"
+
32 #include "Button.h"
+
33 #include "ListBox.h"
+
34 #include "ComboBox.h"
+
35 #include "FormatUtil.h"
+
36 
+
37 // +--------------------------------------------------------------------+
+
38 // DECLARE MAPPING FUNCTIONS:
+
39 DEF_MAP_CLIENT(FltDlg, OnFilter);
+
40 DEF_MAP_CLIENT(FltDlg, OnPackage);
+
41 DEF_MAP_CLIENT(FltDlg, OnAlert);
+
42 DEF_MAP_CLIENT(FltDlg, OnLaunch);
+
43 DEF_MAP_CLIENT(FltDlg, OnStandDown);
+
44 DEF_MAP_CLIENT(FltDlg, OnRecall);
+
45 DEF_MAP_CLIENT(FltDlg, OnClose);
+
46 DEF_MAP_CLIENT(FltDlg, OnMissionType);
+
47 
+
48 // +--------------------------------------------------------------------+
+
49 
+
50 static const ShipDesign* design = 0;
+
51 
+
52 // +--------------------------------------------------------------------+
+
53 
+ +
55 : FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr),
+
56 ship(0), filter_list(0), hangar_list(0),
+
57 package_btn(0), alert_btn(0), launch_btn(0), stand_btn(0), recall_btn(0),
+
58 mission_type(-1), flight_planner(0), patrol_pattern(0)
+
59 {
+
60  Init(def);
+
61 }
+
62 
+ +
64 {
+
65  delete flight_planner;
+
66 }
+
67 
+
68 // +--------------------------------------------------------------------+
+
69 
+
70 void
+ +
72 {
+ + +
75  package_btn = (Button*) FindControl(110);
+
76  alert_btn = (Button*) FindControl(111);
+
77  launch_btn = (Button*) FindControl(112);
+
78  stand_btn = (Button*) FindControl(113);
+
79  recall_btn = (Button*) FindControl(114);
+ +
81 
+
82  if (filter_list)
+ +
84 
+
85  if (package_btn)
+ +
87 
+
88  if (alert_btn)
+ +
90 
+
91  if (launch_btn)
+ +
93 
+
94  if (stand_btn)
+ +
96 
+
97  if (recall_btn)
+ +
99 
+
100  if (close_btn)
+ +
102 
+
103  for (int i = 0; i < 6; i++) {
+
104  mission_btn[i] = (Button*) FindControl(210 + i);
+
105  if (mission_btn[i])
+ +
107  }
+
108 
+ +
110  loadout_list = (ListBox*) FindControl(222);
+
111 }
+
112 
+
113 // +--------------------------------------------------------------------+
+
114 
+
115 void
+ +
117 {
+
118  if (ship != s) {
+
119  ship = s;
+
120 
+
121  delete flight_planner;
+
122  flight_planner = 0;
+
123 
+
124  if (filter_list) {
+ +
126 
+
127  if (ship) {
+
128  int nsquadrons = 0;
+
129  int nslots = 0;
+
130  Hangar* hangar = ship->GetHangar();
+
131 
+
132  if (hangar) {
+
133  nsquadrons = hangar->NumSquadrons();
+
134 
+
135  for (int i = 0; i < nsquadrons; i++) {
+
136  char filter[64];
+
137  sprintf_s(filter, "%s %s",
+
138  hangar->SquadronDesign(i)->abrv,
+
139  hangar->SquadronName(i).data());
+
140 
+
141  filter_list->AddItem(filter);
+
142  }
+
143 
+
144  filter_list->AddItem(Game::GetText("FltDlg.PENDING"));
+
145  filter_list->AddItem(Game::GetText("FltDlg.ACTIVE"));
+
146  }
+
147 
+
148  flight_planner = new(__FILE__,__LINE__) FlightPlanner(ship);
+
149  }
+
150 
+
151  OnFilter(0);
+
152  }
+
153  }
+
154 }
+
155 
+
156 // +--------------------------------------------------------------------+
+
157 
+
158 void
+ +
160 {
+
161  if (!ship || !ship->GetHangar()) {
+
162  manager->HideFltDlg();
+
163  }
+
164  else {
+
165  UpdateSelection();
+
166  UpdateObjective();
+
167  }
+
168 }
+
169 
+
170 // +--------------------------------------------------------------------+
+
171 
+
172 void
+ +
174 {
+
175  if (!filter_list || !hangar_list || !ship) return;
+
176 
+
177  design = 0;
+
178 
+
179  bool package = false;
+
180  bool alert = false;
+
181  bool launch = false;
+
182  bool stand = false;
+
183  bool recall = false;
+
184 
+
185  Hangar* hangar = ship->GetHangar();
+
186  int seln = filter_list->GetSelectedIndex();
+
187  char txt[32];
+
188  int item;
+
189 
+
190  // selected squadron:
+
191  if (seln < hangar->NumSquadrons()) {
+
192  int nslots = hangar->SquadronSize(seln);
+
193 
+
194  for (item = 0; item < hangar_list->NumItems(); item++) {
+
195  int i = hangar_list->GetItemData(item);
+
196  const HangarSlot* s = hangar->GetSlot(seln, i);
+
197 
+
198  if (hangar->GetState(s) == Hangar::UNAVAIL)
+ +
200  else if (hangar->GetState(s) == Hangar::MAINT)
+ +
202  else
+ +
204 
+
205  if (hangar->GetState(s) > Hangar::STORAGE) {
+
206  if (hangar->GetShip(s))
+
207  hangar_list->SetItemText(item, 1, hangar->GetShip(s)->Name());
+
208  else if (hangar->GetPackageElement(s))
+
209  hangar_list->SetItemText(item, 1, hangar->GetPackageElement(s)->Name());
+
210  else
+
211  hangar_list->SetItemText(item, 1, hangar->SquadronName(seln));
+
212 
+
213  if (hangar->GetPackageElement(s))
+
214  hangar_list->SetItemText(item, 3, Mission::RoleName(hangar->GetPackageElement(s)->Type()));
+
215  else
+
216  hangar_list->SetItemText(item, 3, "--");
+
217 
+
218  }
+
219  else {
+
220  hangar_list->SetItemText(item, 1, "--");
+
221  hangar_list->SetItemText(item, 3, "--");
+
222  }
+
223 
+
224  hangar_list->SetItemText(item, 2, hangar->StatusName(s));
+
225 
+
226  if (hangar->GetState(s) >= Hangar::ACTIVE) {
+
227  FormatTime(txt, hangar->GetShip(s)->MissionClock() / 1000);
+
228  hangar_list->SetItemText(item, 4, txt);
+
229  }
+
230 
+
231  else if (hangar->GetState(s) == Hangar::MAINT ||
+
232  hangar->GetState(s) > Hangar::STORAGE) {
+
233  FormatTime(txt, hangar->TimeRemaining(s));
+
234  hangar_list->SetItemText(item, 4, txt);
+
235  }
+
236 
+
237  else {
+
238  hangar_list->SetItemText(item, 4, "");
+
239  }
+
240 
+
241  if (hangar_list->IsSelected(item)) {
+
242  if (!design) design = hangar->GetDesign(s);
+
243 
+
244  switch (hangar->GetState(s)) {
+
245  case Hangar::STORAGE: alert = true; break;
+
246  case Hangar::ALERT: launch = true;
+
247  stand = true; break;
+
248  case Hangar::QUEUED: stand = true; break;
+
249  case Hangar::ACTIVE: recall = true; break;
+
250  }
+
251  }
+
252  }
+
253  }
+
254 
+
255  // selected pending filter:
+
256  else if (seln == hangar->NumSquadrons()) {
+
257  for (item = 0; item < hangar_list->NumItems(); item++) {
+
258  int f = hangar_list->GetItemData(item, 1);
+
259  int i = hangar_list->GetItemData(item, 2);
+
260 
+
261  int squadron = -1;
+
262  int slot = -1;
+
263  const HangarSlot* s = 0;
+
264 
+
265  FlightDeck* deck = ship->GetFlightDeck(f);
+
266 
+
267  if (deck->IsLaunchDeck()) {
+
268  int state = deck->State(i);
+
269  int seq = deck->Sequence(i);
+
270  double time = deck->TimeRemaining(i);
+
271  Ship* deckship = deck->GetShip(i);
+
272 
+
273  if (deckship) {
+
274  hangar_list->SetItemText(item, 1, deckship->Name());
+
275 
+
276  for (int a = 0; !s && a < hangar->NumSquadrons(); a++) {
+
277  for (int b = 0; !s && b < hangar->SquadronSize(a); b++) {
+
278  const HangarSlot* test = hangar->GetSlot(a,b);
+
279  if (hangar->GetShip(test) == deckship) {
+
280  s = test;
+
281  squadron = a;
+
282  slot = b;
+
283  }
+
284  }
+
285  }
+
286 
+
287  if (s) {
+
288  hangar_list->SetItemText(item, 2, hangar->StatusName(s));
+
289  if (hangar->GetPackageElement(s))
+
290  hangar_list->SetItemText(item, 3, Mission::RoleName(hangar->GetPackageElement(s)->Type()));
+
291  }
+
292  }
+
293  else {
+
294  hangar_list->SetItemText(item, 1, "--");
+
295  hangar_list->SetItemText(item, 2, Game::GetText("FltDlg.Open"));
+
296  }
+
297 
+
298  FormatTime(txt, time);
+
299  hangar_list->SetItemText(item, 4, txt);
+
300  hangar_list->SetItemData(item, 3, squadron);
+
301  hangar_list->SetItemData(item, 4, slot);
+
302 
+
303  if (hangar_list->IsSelected(item) && s) {
+
304  if (!design) design = hangar->GetDesign(s);
+
305 
+
306  switch (hangar->GetState(s)) {
+
307  case Hangar::ALERT: launch = true;
+
308  stand = true; break;
+
309  case Hangar::QUEUED: stand = true; break;
+
310  }
+
311  }
+
312  }
+
313  }
+
314  }
+
315 
+
316  // selected active filter:
+
317  else if (seln == hangar->NumSquadrons()+1) {
+
318  int last_index = -1;
+
319 
+
320  for (item = 0; item < hangar_list->NumItems(); item++) {
+
321  int squadron = hangar_list->GetItemData(item, 1);
+
322  int slot = hangar_list->GetItemData(item, 2);
+
323 
+
324  int nslots = hangar->SquadronSize(squadron);
+
325 
+
326  if (slot >= 0 && slot < nslots) {
+
327  const HangarSlot* s = hangar->GetSlot(squadron, slot);
+
328 
+
329  if (hangar->GetState(s) > Hangar::STORAGE) {
+
330  if (hangar->GetShip(s))
+
331  hangar_list->SetItemText(item, 1, hangar->GetShip(s)->Name());
+
332  else if (hangar->GetPackageElement(s))
+
333  hangar_list->SetItemText(item, 1, hangar->GetPackageElement(s)->Name());
+
334  else
+
335  hangar_list->SetItemText(item, 1, hangar->SquadronName(squadron));
+
336 
+
337  if (hangar->GetPackageElement(s))
+
338  hangar_list->SetItemText(item, 3, Mission::RoleName(hangar->GetPackageElement(s)->Type()));
+
339  else
+
340  hangar_list->SetItemText(item, 3, "--");
+
341 
+
342  hangar_list->SetItemText(item, 2, hangar->StatusName(s));
+
343 
+
344  FormatTime(txt, hangar->GetShip(s)->MissionClock() / 1000);
+
345  hangar_list->SetItemText(item, 4, txt);
+
346 
+
347  if (last_index < (int) hangar_list->GetItemData(item))
+
348  last_index = (int) hangar_list->GetItemData(item);
+
349  }
+
350  else {
+
351  hangar_list->RemoveItem(item);
+
352  item--;
+
353  }
+
354  }
+
355  else {
+
356  hangar_list->RemoveItem(item);
+
357  item--;
+
358  }
+
359  }
+
360 
+
361  for (int i = 0; i < hangar->NumSquadrons(); i++) {
+
362  int nslots = hangar->SquadronSize(i);
+
363 
+
364  for (int j = 0; j < nslots; j++) {
+
365  const HangarSlot* s = hangar->GetSlot(i, j);
+
366 
+
367  if (hangar->GetState(s) >= Hangar::ACTIVE) {
+
368  bool found = false;
+
369 
+
370  for (int n = 0; !found && n < hangar_list->NumItems(); n++) {
+
371  if (hangar_list->GetItemData(n, 1) == (DWORD) i &&
+
372  hangar_list->GetItemData(n, 2) == (DWORD) j)
+
373  found = true;
+
374  }
+
375 
+
376  if (!found) {
+
377  last_index++;
+
378 
+
379  char txt[32];
+
380  sprintf_s(txt, "%2d ", last_index+1);
+
381  hangar_list->AddItemWithData(txt, last_index); // use data for sort
+
382 
+
383  if (hangar->GetShip(s))
+
384  hangar_list->SetItemText(item, 1, hangar->GetShip(s)->Name());
+
385 
+
386  hangar_list->SetItemText(item, 2, hangar->StatusName(s));
+
387 
+
388  if (hangar->GetPackageElement(s))
+
389  hangar_list->SetItemText(item, 3, Mission::RoleName(hangar->GetPackageElement(s)->Type()));
+
390 
+
391  FormatTime(txt, hangar->GetShip(s)->MissionClock() / 1000);
+
392  hangar_list->SetItemText(item, 4, txt);
+
393 
+
394  hangar_list->SetItemData(item, 1, i);
+
395  hangar_list->SetItemData(item, 2, j);
+
396 
+
397  item++;
+
398  }
+
399  }
+
400  }
+
401  }
+
402 
+
403  if (hangar_list->GetSelCount() > 0)
+
404  recall = true;
+
405  }
+
406 
+
407  if (package_btn) {
+
408  bool pkg_ok = alert && mission_type > -1;
+
409 
+
410  if (pkg_ok && mission_type > 0) {
+
411  pkg_ok = objective_list &&
+ +
413 
+
414  if (pkg_ok) {
+
415  int obj_index = objective_list->GetSelection();
+
416  DWORD obj_data = objective_list->GetItemData(obj_index, 2);
+
417 
+
418  if (obj_data > 1e9)
+
419  pkg_ok = false;
+
420  }
+
421  }
+
422 
+
423  package_btn->SetEnabled(pkg_ok);
+
424  }
+
425 
+
426  if (alert_btn) {
+
427  alert_btn->SetEnabled(alert);
+
428 
+
429  for (int i = 0; i < 6; i++)
+
430  if (mission_btn[i])
+
431  mission_btn[i]->SetEnabled(alert);
+
432  }
+
433 
+
434  if (launch_btn)
+
435  launch_btn->SetEnabled(launch);
+
436 
+
437  if (stand_btn)
+
438  stand_btn->SetEnabled(stand);
+
439 
+
440  if (recall_btn)
+
441  recall_btn->SetEnabled(recall);
+
442 }
+
443 
+
444 // +--------------------------------------------------------------------+
+
445 
+
446 void
+ +
448 {
+
449  if (!objective_list || mission_type < 0 || !ship) return;
+
450 
+
451  Sim* sim = Sim::GetSim();
+
452  char txt[32];
+
453 
+
454  for (int item = 0; item < objective_list->NumItems(); item++) {
+
455  const char* obj_name = objective_list->GetItemText(item);
+
456 
+
457  Element* elem = sim->FindElement(obj_name);
+
458 
+
459  // if element has expired, remove it from the objective list
+
460  if (!elem || !elem->IsActive() || elem->IsFinished()) {
+
461  objective_list->RemoveItem(item);
+
462  item--;
+
463  }
+
464 
+
465  // otherwise, the element is still active, so update range/region
+
466  else {
+
467  Ship* s = elem->GetShip(1);
+
468  double r = 0;
+
469  bool con = false;
+
470 
+
471  if (s) {
+
472  Point s_loc = s->Location() + s->GetRegion()->Location();
+
473  Point h_loc = ship->Location() + ship->GetRegion()->Location();
+
474 
+
475  r = (s_loc - h_loc).length();
+
476 
+
477  con = ship->FindContact(s) != 0;
+
478 
+
479  if (con) {
+
480  FormatNumber(txt, r);
+
481  }
+
482  else {
+
483  strcpy_s(txt, Game::GetText("FltDlg.Unknown").data());
+
484  r = 2e9;
+
485  }
+
486  }
+
487 
+
488  objective_list->SetItemText(item, 1, s->GetRegion()->Name());
+
489 
+
490  objective_list->SetItemText(item, 2, txt);
+
491  objective_list->SetItemData(item, 2, (DWORD) r);
+
492  }
+
493  }
+
494 }
+
495 
+
496 // +--------------------------------------------------------------------+
+
497 
+
498 void
+ +
500 {
+
501  if (shown) return;
+
502 
+ +
504  UpdateSelection();
+
505  UpdateObjective();
+
506 }
+
507 
+
508 // +--------------------------------------------------------------------+
+
509 
+
510 void
+ +
512 {
+ +
514 }
+
515 
+
516 // +--------------------------------------------------------------------+
+
517 
+
518 void
+ +
520 {
+
521  if (!filter_list || !hangar_list) return;
+
522 
+
523  int seln = filter_list->GetSelectedIndex();
+
524 
+ +
526 
+
527  if (!ship) return;
+
528 
+
529  Hangar* hangar = ship->GetHangar();
+
530 
+
531  // selected squadron:
+
532  if (seln < hangar->NumSquadrons()) {
+
533  int nslots = hangar->SquadronSize(seln);
+
534 
+
535  for (int i = 0; i < nslots; i++) {
+
536  char txt[32];
+
537  sprintf_s(txt, " %2d ", i+1);
+
538 
+
539  const HangarSlot* s = hangar->GetSlot(seln, i);
+
540  hangar_list->AddItemWithData(txt, i);
+
541 
+
542  hangar_list->SetItemText(i, 1, "--");
+
543  hangar_list->SetItemText(i, 2, hangar->StatusName(s));
+
544 
+
545  FormatTime(txt, hangar->TimeRemaining(s));
+
546  hangar_list->SetItemText(i, 4, txt);
+
547  }
+
548  }
+
549 
+
550  // selected pending filter:
+
551  else if (seln == hangar->NumSquadrons()) {
+
552  int item = 0;
+
553 
+
554  for (int f = 0; f < ship->NumFlightDecks(); f++) {
+
555  FlightDeck* deck = ship->GetFlightDeck(f);
+
556 
+
557  if (deck->IsLaunchDeck()) {
+
558  for (int i = 0; i < deck->NumSlots(); i++) {
+
559  int state = deck->State(i);
+
560  int seq = deck->Sequence(i);
+
561  double time = deck->TimeRemaining(i);
+
562  Ship* deckship = deck->GetShip(i);
+
563 
+
564  int squadron = -1;
+
565  int slot = -1;
+
566 
+
567  char txt[32];
+
568  sprintf_s(txt, "%d-%d ", f+1, i+1);
+
569 
+
570  hangar_list->AddItemWithData(txt, item); // use data for sort
+
571 
+
572  if (deckship) {
+
573  hangar_list->SetItemText(item, 1, deckship->Name());
+
574 
+
575  const HangarSlot* s = 0;
+
576 
+
577  for (int a = 0; !s && a < hangar->NumSquadrons(); a++) {
+
578  for (int b = 0; !s && b < hangar->SquadronSize(a); b++) {
+
579  const HangarSlot* test = hangar->GetSlot(a, b);
+
580  if (hangar->GetShip(test) == deckship) {
+
581  s = test;
+
582  squadron = a;
+
583  slot = b;
+
584  }
+
585  }
+
586  }
+
587 
+
588  if (s) {
+
589  hangar_list->SetItemText(item, 2, hangar->StatusName(s));
+
590  if (hangar->GetPackageElement(s))
+ +
592  }
+
593  }
+
594  else {
+
595  hangar_list->SetItemText(item, 1, "--");
+
596  hangar_list->SetItemText(item, 2, Game::GetText("FltDlg.Open"));
+
597  }
+
598 
+
599 
+
600  FormatTime(txt, time);
+
601  hangar_list->SetItemText(item, 4, txt);
+
602 
+
603  hangar_list->SetItemData(item, 1, f);
+
604  hangar_list->SetItemData(item, 2, i);
+
605  hangar_list->SetItemData(item, 3, squadron);
+
606  hangar_list->SetItemData(item, 4, slot);
+
607 
+
608  item++;
+
609  }
+
610  }
+
611  }
+
612  }
+
613 
+
614  // selected active filter:
+
615  else if (seln == hangar->NumSquadrons()+1) {
+
616  int item = 0;
+
617 
+
618  for (int i = 0; i < hangar->NumSquadrons(); i++) {
+
619  int nslots = hangar->SquadronSize(i);
+
620 
+
621  for (int j = 0; j < nslots; j++) {
+
622  const HangarSlot* s = hangar->GetSlot(i,j);
+
623 
+
624  if (hangar->GetState(s) >= Hangar::ACTIVE) {
+
625  char txt[32];
+
626  sprintf_s(txt, " %2d ", item+1);
+
627 
+
628  hangar_list->AddItemWithData(txt, item); // use data for sort
+
629 
+
630  if (hangar->GetShip(s))
+
631  hangar_list->SetItemText(item, 1, hangar->GetShip(s)->Name());
+
632 
+
633  hangar_list->SetItemText(item, 2, hangar->StatusName(s));
+
634 
+
635  if (hangar->GetPackageElement(s))
+ +
637 
+
638  FormatTime(txt, hangar->TimeRemaining(s));
+
639  hangar_list->SetItemText(item, 4, txt);
+
640 
+
641  hangar_list->SetItemData(item, 1, i);
+
642  hangar_list->SetItemData(item, 2, j);
+
643 
+
644  item++;
+
645  }
+
646  }
+
647  }
+
648  }
+
649 }
+
650 
+
651 // +--------------------------------------------------------------------+
+
652 
+
653 void
+ +
655 {
+
656  if (!filter_list || !hangar_list || !ship) return;
+
657 
+
658  int code = Mission::PATROL;
+
659 
+
660  switch (mission_type) {
+
661  case 0: code = Mission::PATROL; break;
+
662  case 1: code = Mission::INTERCEPT; break;
+
663  case 2: code = Mission::ASSAULT; break;
+
664  case 3: code = Mission::STRIKE; break;
+
665  case 4: code = Mission::ESCORT; break;
+
666  case 5: code = Mission::INTEL; break;
+
667  }
+
668 
+
669  int squad = filter_list->GetSelectedIndex();
+
670  Hangar* hangar = ship->GetHangar();
+
671  Sim* sim = Sim::GetSim();
+
672  const char* call = sim->FindAvailCallsign(ship->GetIFF());
+
673  Element* elem = sim->CreateElement(call, ship->GetIFF(), code);
+
674  Element* tgt = 0;
+
675  FlightDeck* deck = 0;
+
676  int queue = 1000;
+
677  int* load = 0;
+
678 
+
679  elem->SetSquadron(hangar->SquadronName(squad));
+
680  elem->SetCarrier(ship);
+
681 
+
682  if (objective_list) {
+
683  int index = objective_list->GetListIndex();
+
684  Text target = objective_list->GetItemText(index);
+
685 
+
686  Instruction* objective = new(__FILE__,__LINE__) Instruction(code, target.data());
+
687  elem->AddObjective(objective);
+
688 
+
689  tgt = sim->FindElement(target.data());
+
690  }
+
691 
+
692  if (loadout_list && design) {
+
693  int index = loadout_list->GetListIndex();
+
694  Text loadname = loadout_list->GetItemText(index);
+
695 
+ +
697  while (++sl && !load) {
+
698  if (sl->name == loadname) {
+
699  load = sl->load;
+
700  elem->SetLoadout(load);
+
701  }
+
702  }
+
703  }
+
704 
+
705  for (int i = 0; i < ship->NumFlightDecks(); i++) {
+
706  FlightDeck* d = ship->GetFlightDeck(i);
+
707 
+
708  if (d && d->IsLaunchDeck()) {
+
709  int dq = hangar->PreflightQueue(d);
+
710 
+
711  if (dq < queue) {
+
712  queue = dq;
+
713  deck = d;
+
714  }
+
715  }
+
716  }
+
717 
+
718  int npackage = 0;
+
719  int slots[4];
+
720 
+
721  for (int i = 0; i < 4; i++)
+
722  slots[i] = -1;
+
723 
+
724  for (int i = 0; i < hangar_list->NumItems(); i++) {
+
725  if (hangar_list->IsSelected(i)) {
+
726  int nslot = hangar_list->GetItemData(i);
+
727  hangar->GotoAlert(squad, nslot, deck, elem, load, true);
+
728  slots[npackage] = nslot;
+
729  hangar_list->SetSelected(i, false);
+
730  npackage++;
+
731 
+
732  if (npackage >= 4)
+
733  break;
+
734  }
+
735  }
+
736 
+
737  NetUtil::SendElemCreate(elem, squad, slots, false);
+
738 
+
739  if (flight_planner) {
+
740  switch (mission_type) {
+
741  case 0:
+
742  default:
+ +
744  break;
+
745 
+
746  case 1:
+
747  case 2:
+
748  case 3:
+
749  if (tgt)
+
750  flight_planner->CreateStrikeRoute(elem, tgt);
+
751  else
+ +
753  break;
+
754 
+
755  case 4:
+
756  if (tgt)
+
757  flight_planner->CreateEscortRoute(elem, tgt);
+
758  else
+ +
760  break;
+
761  }
+
762 
+
763  if (patrol_pattern < 0 || patrol_pattern > 3)
+
764  patrol_pattern = 0;
+
765  }
+
766 }
+
767 
+
768 // +--------------------------------------------------------------------+
+
769 
+
770 void
+ +
772 {
+
773  if (!filter_list || !hangar_list || !ship) return;
+
774 
+
775  int squad = filter_list->GetSelectedIndex();
+
776  Hangar* hangar = ship->GetHangar();
+
777  Sim* sim = Sim::GetSim();
+
778  const char* call = sim->FindAvailCallsign(ship->GetIFF());
+
779  Element* elem = sim->CreateElement(call, ship->GetIFF());
+
780  FlightDeck* deck = 0;
+
781  int queue = 1000;
+
782  const int* load = 0;
+
783 
+
784  elem->SetSquadron(hangar->SquadronName(squad));
+
785  elem->SetCarrier(ship);
+
786 
+
787  for (int i = 0; i < ship->NumFlightDecks(); i++) {
+
788  FlightDeck* d = ship->GetFlightDeck(i);
+
789 
+
790  if (d && d->IsLaunchDeck()) {
+
791  int dq = hangar->PreflightQueue(d);
+
792 
+
793  if (dq < queue) {
+
794  queue = dq;
+
795  deck = d;
+
796  }
+
797  }
+
798  }
+
799 
+
800  int nalert = 0;
+
801  int slots[4];
+
802 
+
803  for (int i = 0; i < 4; i++)
+
804  slots[i] = -1;
+
805 
+
806  for (int i = 0; i < hangar_list->NumItems(); i++) {
+
807  if (hangar_list->IsSelected(i)) {
+
808  int nslot = hangar_list->GetItemData(i);
+
809  slots[nalert] = nslot;
+
810 
+
811  if (!load) {
+
812  const HangarSlot* hangar_slot = hangar->GetSlot(squad, nslot);
+
813  if (hangar_slot) {
+
814  load = hangar->GetLoadout(hangar_slot);
+
815  elem->SetLoadout((int*) load);
+
816  }
+
817  }
+
818 
+
819  hangar->GotoAlert(squad, nslot, deck, elem);
+
820  hangar_list->SetSelected(i, false);
+
821  nalert++;
+
822 
+
823  if (nalert >= 4)
+
824  break;
+
825  }
+
826  }
+
827 
+
828  NetUtil::SendElemCreate(elem, squad, slots, true);
+
829 }
+
830 
+
831 // +--------------------------------------------------------------------+
+
832 
+
833 void
+ +
835 {
+
836  if (!filter_list || !hangar_list || !ship) return;
+
837 
+
838  int squad = filter_list->GetSelectedIndex();
+
839 
+
840  Hangar* hangar = ship->GetHangar();
+
841 
+
842  // selected squadron:
+
843  if (squad < hangar->NumSquadrons()) {
+
844  for (int i = 0; i < hangar_list->NumItems(); i++) {
+
845  if (hangar_list->IsSelected(i)) {
+
846  int nslot = hangar_list->GetItemData(i);
+
847  hangar->Launch(squad, nslot);
+
848  NetUtil::SendShipLaunch(ship, squad, nslot);
+
849  }
+
850  }
+
851  }
+
852 
+
853  // selected pending filter:
+
854  else if (squad == hangar->NumSquadrons()) {
+
855  for (int item = 0; item < hangar_list->NumItems(); item++) {
+
856  if (hangar_list->IsSelected(item)) {
+
857  int squadron = hangar_list->GetItemData(item, 3);
+
858  int slot = hangar_list->GetItemData(item, 4);
+
859 
+
860  if (squadron >= 0 && slot >= 0) {
+
861  hangar->Launch(squadron, slot);
+
862  NetUtil::SendShipLaunch(ship, squadron, slot);
+
863  }
+
864  }
+
865  }
+
866  }
+
867 }
+
868 
+
869 // +--------------------------------------------------------------------+
+
870 
+
871 void
+ +
873 {
+
874  if (!filter_list || !hangar_list || !ship) return;
+
875 
+
876  int seln = filter_list->GetSelectedIndex();
+
877 
+
878  Hangar* hangar = ship->GetHangar();
+
879 
+
880  // selected squadron:
+
881  if (seln < hangar->NumSquadrons()) {
+
882  for (int i = 0; i < hangar_list->NumItems(); i++) {
+
883  if (hangar_list->IsSelected(i)) {
+
884  int nslot = hangar_list->GetItemData(i);
+
885  hangar->StandDown(seln, nslot);
+
886  }
+
887  }
+
888  }
+
889 
+
890  // selected pending filter:
+
891  else if (seln == hangar->NumSquadrons()) {
+
892  for (int item = 0; item < hangar_list->NumItems(); item++) {
+
893  if (hangar_list->IsSelected(item)) {
+
894  int squadron = hangar_list->GetItemData(item, 3);
+
895  int slot = hangar_list->GetItemData(item, 4);
+
896 
+
897  if (squadron >= 0 && slot >= 0)
+
898  hangar->StandDown(squadron, slot);
+
899  }
+
900  }
+
901  }
+
902 }
+
903 
+
904 // +--------------------------------------------------------------------+
+
905 
+
906 void
+ +
908 {
+
909  if (!filter_list || !hangar_list || !ship) return;
+
910 
+
911  int seln = filter_list->GetSelectedIndex();
+
912 
+
913  Hangar* hangar = ship->GetHangar();
+
914 
+
915  // selected squadron: or selected active filter:
+
916  if (seln < hangar->NumSquadrons() || seln == hangar->NumSquadrons()+1) {
+
917  for (int i = 0; i < hangar_list->NumItems(); i++) {
+
918  if (hangar_list->IsSelected(i)) {
+
919  int nsquad = seln;
+
920  int nslot = hangar_list->GetItemData(i);
+
921 
+
922  if (seln > hangar->NumSquadrons()) {
+
923  nsquad = hangar_list->GetItemData(i, 1);
+
924  nslot = hangar_list->GetItemData(i, 2);
+
925  }
+
926 
+
927  const HangarSlot* slot = hangar->GetSlot(nsquad, nslot);
+
928  Ship* recall = hangar->GetShip(slot);
+
929 
+
930  if (recall) {
+
931  RadioMessage* msg = new(__FILE__,__LINE__) RadioMessage(recall, ship, RadioMessage::RTB);
+ +
933  }
+
934  }
+
935  }
+
936  }
+
937 }
+
938 
+
939 // +--------------------------------------------------------------------+
+
940 
+
941 void
+ +
943 {
+
944  mission_type = -1;
+
945 
+
946  for (int i = 0; i < 6; i++) {
+
947  if (mission_btn[i]) {
+
948  if (mission_btn[i] == event->window) {
+ +
950  mission_type = i;
+
951  }
+
952  else {
+ +
954  }
+
955  }
+
956  }
+
957 
+
958  if (objective_list && mission_type > -1) {
+ +
960 
+
961  char txt[32];
+
962  Sim* sim = Sim::GetSim();
+
963  ListIter<Element> iter = sim->GetElements();
+
964 
+
965  while (++iter) {
+
966  Element* elem = iter.value();
+
967 
+
968  if (!elem->IsActive() || elem->IsFinished() || elem->IsSquadron())
+
969  continue;
+
970 
+
971  CombatGroup* group = elem->GetCombatGroup();
+
972  int iff = elem->GetIFF();
+
973  Ship* s = elem->GetShip(1);
+
974  double r = 0;
+
975  bool con = false;
+
976 
+
977  if (iff != ship->GetIFF()) {
+
978  if (elem->IntelLevel() < Intel::LOCATED)
+
979  continue;
+
980 
+
981  if (group && group->IntelLevel() < Intel::LOCATED)
+
982  continue;
+
983  }
+
984 
+
985  if (s) {
+
986  Point s_loc = s->Location() + s->GetRegion()->Location();
+
987  Point h_loc = ship->Location() + ship->GetRegion()->Location();
+
988 
+
989  r = (s_loc - h_loc).length();
+
990 
+
991  con = ship->FindContact(s) != 0;
+
992 
+
993  if (con) {
+
994  FormatNumber(txt, r);
+
995  }
+
996  else {
+
997  strcpy_s(txt, Game::GetText("FltDlg.Unknown").data());
+
998  r = 2e9;
+
999  }
+
1000  }
+
1001 
+
1002  switch (mission_type) {
+
1003  case 1: // INTERCEPT
+
1004  if (iff && iff != ship->GetIFF() && s && s->IsDropship()) {
+
1005  int item = objective_list->AddItem(elem->Name()) - 1;
+
1006  objective_list->SetItemText(item, 1, s->GetRegion()->Name());
+
1007 
+
1008  objective_list->SetItemText(item, 2, txt);
+
1009  objective_list->SetItemData(item, 2, (DWORD) r);
+
1010  }
+
1011  break;
+
1012 
+
1013  case 2: // ASSAULT
+
1014  if (iff && iff != ship->GetIFF() && s && (s->IsStarship() || s->IsStatic())) {
+
1015  int item = objective_list->AddItem(elem->Name()) - 1;
+
1016  objective_list->SetItemText(item, 1, s->GetRegion()->Name());
+
1017 
+
1018  objective_list->SetItemText(item, 2, txt);
+
1019  objective_list->SetItemData(item, 2, (DWORD) r);
+
1020  }
+
1021  break;
+
1022 
+
1023  case 3: // STRIKE
+
1024  if (iff && iff != ship->GetIFF() && s && s->IsGroundUnit()) {
+
1025  int item = objective_list->AddItem(elem->Name()) - 1;
+
1026  objective_list->SetItemText(item, 1, s->GetRegion()->Name());
+
1027 
+
1028  objective_list->SetItemText(item, 2, txt);
+
1029  objective_list->SetItemData(item, 2, (DWORD) r);
+
1030  }
+
1031  break;
+
1032 
+
1033  case 4: // ESCORT
+
1034  if ((iff == 0 || iff == ship->GetIFF()) && (!s || !s->IsStatic())) {
+
1035  int item = objective_list->AddItem(elem->Name()) - 1;
+
1036 
+
1037  if (s) {
+
1038  objective_list->SetItemText(item, 1, s->GetRegion()->Name());
+
1039  objective_list->SetItemText(item, 2, txt);
+
1040  objective_list->SetItemData(item, 2, (DWORD) r);
+
1041  }
+
1042 
+
1043  else {
+
1044  objective_list->SetItemText(item, 1, "0");
+
1045  objective_list->SetItemData(item, 1, 0);
+
1046  }
+
1047  }
+
1048  break;
+
1049 
+
1050  case 5: // SCOUT?
+
1051  break;
+
1052 
+
1053  default: break;
+
1054  }
+
1055  }
+
1056  }
+
1057 
+
1058  if (loadout_list && mission_type > -1) {
+ +
1060 
+
1061  if (design) {
+
1062  ListIter<ShipLoad> sl = (List<ShipLoad>&) design->loadouts;
+
1063  while (++sl) {
+
1064  int item = loadout_list->AddItem(sl->name) - 1;
+
1065 
+
1066  char weight[32];
+
1067  sprintf_s(weight, "%d kg", (int) ((design->mass + sl->mass) * 1000));
+
1068  loadout_list->SetItemText(item, 1, weight);
+
1069  loadout_list->SetItemData(item, 1, (DWORD) (sl->mass * 1000));
+
1070  }
+
1071  }
+
1072  }
+
1073 }
+
1074 
+
1075 // +--------------------------------------------------------------------+
+
1076 
+
1077 void
+ +
1079 {
+
1080  if (manager)
+
1081  manager->CloseTopmost();
+
1082 }
+
1083 
+
1084 
+
1085 
+
+
+ + + + -- cgit v1.1