Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CmdDlg.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: CmdDlg.cpp
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Operational Command Dialog Active Window class
13 */
14 
15 #include "MemDebug.h"
16 #include "CmdDlg.h"
17 #include "CmpFileDlg.h"
18 #include "CmpnScreen.h"
19 #include "Starshatter.h"
20 #include "Campaign.h"
21 #include "Combatant.h"
22 #include "CombatGroup.h"
23 #include "CombatUnit.h"
24 #include "ShipDesign.h"
25 
26 #include "Game.h"
27 #include "DataLoader.h"
28 #include "Button.h"
29 #include "Video.h"
30 #include "Keyboard.h"
31 #include "Mouse.h"
32 #include "ParseUtil.h"
33 #include "FormatUtil.h"
34 
35 // +--------------------------------------------------------------------+
36 
38 : cmpn_screen(mgr),
39 txt_group(0), txt_score(0), txt_name(0), txt_time(0),
40 btn_save(0), btn_exit(0), stars(0), campaign(0), mode(0)
41 {
44 
45  for (int i = 0; i < 5; i++)
46  btn_mode[i] = 0;
47 }
48 
50 {
51 }
52 
53 // +--------------------------------------------------------------------+
54 
55 void
57 {
58  btn_save = (Button*) win->FindControl( 1);
59  btn_exit = (Button*) win->FindControl( 2);
60 
61  for (int i = 0; i < 5; i++) {
62  btn_mode[i] = (Button*) win->FindControl(100 + i);
63  }
64 
65  txt_group = win->FindControl(200);
66  txt_score = win->FindControl(201);
67  txt_name = win->FindControl(300);
68  txt_time = win->FindControl(301);
69 }
70 
71 // +--------------------------------------------------------------------+
72 
73 void
75 {
77 
78  if (txt_name) {
79  if (campaign)
81  else
82  txt_name->SetText("No Campaign Selected");
83  }
84 
85  ShowMode();
86 
87  if (btn_save)
89 
92 }
93 
94 // +--------------------------------------------------------------------+
95 
96 void
98 {
100  if (g && txt_group)
102 
103  if (txt_score) {
104  char score[32];
105  sprintf_s(score, "Team Score: %d", campaign->GetPlayerTeamScore()); txt_score->SetText(score); txt_score->SetTextAlign(DT_RIGHT);
106  }
107 
108  if (txt_time) {
109  double t = campaign->GetTime();
110  char daytime[32];
111  FormatDayTime(daytime, t);
112  txt_time->SetText(daytime);
113  }
114 
115  int unread = campaign->CountNewEvents();
116 
117  if (btn_mode[MODE_INTEL]) {
118  if (unread > 0) {
119  char text[64];
120  sprintf_s(text, "INTEL (%d)", unread);
121  btn_mode[MODE_INTEL]->SetText(text);
122  }
123  else {
124  btn_mode[MODE_INTEL]->SetText("INTEL");
125  }
126  }
127 }
128 
129 // +--------------------------------------------------------------------+
130 
131 void
133 {
134  for (int i = 0; i < 5; i++) {
135  if (btn_mode[i]) btn_mode[i]->SetButtonState(0);
136  }
137 
138  if (mode < 0 || mode > 4)
139  mode = 0;
140 
142 }
143 
144 void
146 {
147  for (int i = MODE_ORDERS; i < NUM_MODES; i++) {
148  Button* btn = btn_mode[i];
149 
150  if (event->window == btn) {
151  mode = i;
152  }
153  }
154 
155  switch (mode) {
156  case MODE_ORDERS: cmpn_screen->ShowCmdOrdersDlg(); break;
158  case MODE_FORCES: cmpn_screen->ShowCmdForceDlg(); break;
159  case MODE_INTEL: cmpn_screen->ShowCmdIntelDlg(); break;
161  default: cmpn_screen->ShowCmdOrdersDlg(); break;
162  }
163 }
164 
165 void
167 {
168  if (campaign && cmpn_screen) {
170 
172  }
173 }
174 
175 void
177 {
178  if (stars) {
179  Mouse::Show(false);
181  }
182 }
183 
184 // +--------------------------------------------------------------------+