Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CmdIntelDlg.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: CmdIntelDlg.cpp
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Operational Command Dialog (Intel/Newsfeed Tab)
13 */
14 
15 #include "MemDebug.h"
16 #include "CmdIntelDlg.h"
17 #include "CmpnScreen.h"
18 #include "Starshatter.h"
19 #include "Campaign.h"
20 #include "Combatant.h"
21 #include "CombatEvent.h"
22 #include "CombatGroup.h"
23 #include "CombatUnit.h"
24 #include "ShipDesign.h"
25 #include "Starshatter.h"
26 #include "Sim.h"
27 #include "CameraDirector.h"
28 
29 #include "Game.h"
30 #include "DataLoader.h"
31 #include "Button.h"
32 #include "ComboBox.h"
33 #include "ListBox.h"
34 #include "Slider.h"
35 #include "Video.h"
36 #include "Keyboard.h"
37 #include "Mouse.h"
38 #include "ParseUtil.h"
39 #include "FormatUtil.h"
40 
41 // +--------------------------------------------------------------------+
42 // DECLARE MAPPING FUNCTIONS:
43 
49 
50 // +--------------------------------------------------------------------+
51 
53 : FormWindow(s, 0, 0, s->Width(), s->Height()), CmdDlg(mgr), manager(mgr),
54 stars(0), campaign(0), update_time(0), start_scene(0),
55 cam_view(0), dsp_view(0)
56 {
59 
60  if (campaign)
62 
63  Init(def);
64 }
65 
67 {
68 }
69 
70 // +--------------------------------------------------------------------+
71 
72 void
74 {
75  lst_news = (ListBox*) FindControl(401);
77  img_news = (ImageBox*) FindControl(403);
78  mov_news = FindControl(404);
79  btn_play = (Button*) FindControl(405);
80 
81  RegisterCmdControls(this);
82 
83  if (btn_save)
85 
86  if (btn_exit)
88 
89  if (btn_play)
91 
92  for (int i = 0; i < 5; i++) {
93  if (btn_mode[i])
95  }
96 
97  if (lst_news) {
99  }
100 
101  if (img_news) {
103  }
104 
105  if (mov_news) {
107  cam_view = new(__FILE__,__LINE__) CameraView(mov_news, cam_dir->GetCamera(), 0);
108  if (cam_view)
110 
112  if (dsp_view) {
115  }
116 
117  mov_news->Hide();
118  }
119 }
120 
121 // +--------------------------------------------------------------------+
122 
123 void
125 {
126  mode = MODE_INTEL;
127 
129  ShowCmdDlg();
130 
131  if (btn_play)
132  btn_play->Hide();
133 
134  if (mov_news)
135  mov_news->Hide();
136 }
137 
138 // +--------------------------------------------------------------------+
139 
140 void
142 {
144 
148 
149  lst_news->ClearItems();
150  txt_news->SetText("");
151 
152  if (img_news)
154  }
155 
156  if (campaign) {
157  List<CombatEvent>& events = campaign->GetEvents();
158  bool auto_scroll = false;
159 
160  if (events.size() > lst_news->NumItems()) {
161  while (events.size() > lst_news->NumItems()) {
162  CombatEvent* info = events[lst_news->NumItems()];
163 
164  const char* unread = info->Visited() ? " " : "*";
165  int i = lst_news->AddItemWithData(unread, (DWORD) info) - 1;
166 
167  char dateline[32];
168  FormatDayTime(dateline, info->Time());
169  lst_news->SetItemText(i, 1, dateline);
170  lst_news->SetItemText(i, 2, info->Title());
171  lst_news->SetItemText(i, 3, info->Region());
172  lst_news->SetItemText(i, 4, Game::GetText(info->SourceName()));
173 
174  if (!info->Visited())
175  auto_scroll = true;
176  }
177 
178  if (lst_news->GetSortColumn() > 0)
179  lst_news->SortItems();
180  }
181 
182  else if (events.size() < lst_news->NumItems()) {
183  lst_news->ClearItems();
184 
185  for (int i = 0; i < events.size(); i++) {
186  CombatEvent* info = events[i];
187 
188  const char* unread = info->Visited() ? " " : "*";
189  int j = lst_news->AddItemWithData(unread, (DWORD) info) - 1;
190 
191  char dateline[32];
192  FormatDayTime(dateline, info->Time());
193  lst_news->SetItemText(j, 1, dateline);
194  lst_news->SetItemText(j, 2, info->Title());
195  lst_news->SetItemText(j, 3, info->Region());
196  lst_news->SetItemText(j, 4, Game::GetText(info->SourceName()));
197 
198  if (!info->Visited())
199  auto_scroll = true;
200  }
201 
202  if (lst_news->GetSortColumn() > 0)
203  lst_news->SortItems();
204 
205  txt_news->SetText("");
206 
207  if (img_news)
209  }
210 
211  if (auto_scroll) {
212  int first_unread = -1;
213 
214  for (int i = 0; i < lst_news->NumItems(); i++) {
215  if (lst_news->GetItemText(i, 0) == "*") {
216  first_unread = i;
217  break;
218  }
219  }
220 
221  if (first_unread >= 0)
222  lst_news->ScrollTo(first_unread);
223  }
224  }
225 
227 
228  if (start_scene > 0) {
229  ShowMovie();
230 
231  start_scene--;
232 
233  if (start_scene == 0) {
234  if (stars && campaign) {
236 
237  if (stars->InCutscene()) {
238  Sim* sim = Sim::GetSim();
239 
240  if (sim) {
242  cam_view->UseScene(sim->GetScene());
243  }
244  }
245  }
246 
247  event_scene = "";
248  }
249  }
250  else {
251  if (dsp_view)
252  dsp_view->ExecFrame();
253 
254  if (stars->InCutscene())
255  ShowMovie();
256  else
257  HideMovie();
258  }
259 }
260 
261 // +--------------------------------------------------------------------+
262 
263 void
265 {
266  CmdDlg::OnSave(event);
267 }
268 
269 void
271 {
272  CmdDlg::OnExit(event);
273 }
274 
275 void
277 {
278  CmdDlg::OnMode(event);
279 }
280 
281 
282 // +--------------------------------------------------------------------+
283 
284 void
286 {
287  CombatEvent* event = 0;
288  int index = lst_news->GetSelection();
289 
290  if (index >= 0) {
291  event = (CombatEvent*) lst_news->GetItemData(index, 0);
292  }
293 
294  if (event) {
295  Text info("<font Limerick12><color ffff80>");
296  info += event->Title();
297  info += "<font Verdana><color ffffff>\n\n";
298  info += event->Information();
299 
300  txt_news->SetText(info);
302 
303  lst_news->SetItemText(index, 0, " ");
304 
305  if (img_news) {
306  if (event->Image().Width() >= 64)
307  img_news->SetPicture(event->Image());
308  else
310  }
311 
312  if (btn_play) {
313  if (event->SceneFile() && *event->SceneFile())
314  btn_play->Show();
315  else
316  btn_play->Hide();
317  }
318 
319  if (!event->Visited() && btn_play->IsEnabled())
320  OnPlay(0);
321 
322  event->SetVisited(true);
323  }
324  else {
325  txt_news->SetText("");
326 
327  if (img_news)
329 
330  if (btn_play)
331  btn_play->Hide();
332  }
333 }
334 
335 // +--------------------------------------------------------------------+
336 
337 void
339 {
340  CombatEvent* event = 0;
341  int index = lst_news->GetSelection();
342 
343  if (index >= 0) {
344  event = (CombatEvent*) lst_news->GetItemData(index, 0);
345  }
346 
347  if (mov_news && cam_view && event && event->SceneFile() && *event->SceneFile()) {
348  event_scene = event->SceneFile();
349  start_scene = 2;
350  ShowMovie();
351  }
352 }
353 
354 void
356 {
357  if (mov_news) {
358  mov_news->Show();
360 
361  if (img_news) img_news->Hide();
362  if (txt_news) txt_news->Hide();
363  if (btn_play) btn_play->Hide();
364  }
365 }
366 
367 void
369 {
370  CombatEvent* event = 0;
371  int index = lst_news->GetSelection();
372  bool play = false;
373 
374  if (index >= 0) {
375  event = (CombatEvent*) lst_news->GetItemData(index, 0);
376 
377  if (event && event->SceneFile() && *event->SceneFile())
378  play = true;
379  }
380 
381  if (mov_news) {
382  mov_news->Hide();
383 
384  if (img_news) img_news->Show();
385  if (txt_news) txt_news->Show();
386  if (btn_play) {
387  if (play)
388  btn_play->Show();
389  else
390  btn_play->Hide();
391  }
392  }
393 }