From 5b9d9f92ea76320e405a1ffef8f1ed295cbd9999 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Tue, 5 Jun 2012 18:53:11 +0000 Subject: Documentation update --- Doc/doxygen/html/_starshatter_8cpp_source.html | 5280 ++++++++++++------------ 1 file changed, 2639 insertions(+), 2641 deletions(-) (limited to 'Doc/doxygen/html/_starshatter_8cpp_source.html') diff --git a/Doc/doxygen/html/_starshatter_8cpp_source.html b/Doc/doxygen/html/_starshatter_8cpp_source.html index cfd3e49..4726a42 100644 --- a/Doc/doxygen/html/_starshatter_8cpp_source.html +++ b/Doc/doxygen/html/_starshatter_8cpp_source.html @@ -291,2721 +291,2719 @@ $(document).ready(function(){initNavTree('_starshatter_8cpp.html','');});
187  if (loader->FindFile("vox.dat"))
188  loader->EnableDatafile("vox.dat");
189 
-
190 #ifndef STARSHATTER_DEMO_RELEASE
-
191  if (loader->FindFile("start.dat"))
-
192  loader->EnableDatafile("start.dat");
-
193 #endif
-
194 
-
195  loadstat = loader->EnableDatafile("content.dat");
-
196 
-
197  if (loadstat != DataLoader::DATAFILE_OK) {
-
198  const char* err_msg = loadstat == DataLoader::DATAFILE_INVALID ?
-
199  "The file 'content.dat' appears to have been damaged. Please re-install the latest Starshatter update." :
-
200  "Starshatter cannot open the file 'content.dat'. Please re-install the latest Starshatter update.";
-
201 
-
202  ::MessageBox(hwnd, err_msg, "Starshatter - Error", MB_OK);
-
203  ::Print(err_msg);
-
204  ::Print("\n\nFATAL ERROR: EXIT.");
-
205  exit(-1);
-
206  }
+
190  if (loader->FindFile("start.dat"))
+
191  loader->EnableDatafile("start.dat");
+
192 
+
193  loadstat = loader->EnableDatafile("content.dat");
+
194 
+
195  if (loadstat != DataLoader::DATAFILE_OK) {
+
196  const char* err_msg = loadstat == DataLoader::DATAFILE_INVALID ?
+
197  "The file 'content.dat' appears to have been damaged. Please re-install the latest Starshatter update." :
+
198  "Starshatter cannot open the file 'content.dat'. Please re-install the latest Starshatter update.";
+
199 
+
200  ::MessageBox(hwnd, err_msg, "Starshatter - Error", MB_OK);
+
201  ::Print(err_msg);
+
202  ::Print("\n\nFATAL ERROR: EXIT.");
+
203  exit(-1);
+
204  }
+
205 
+
206  LoadVideoConfig("video.cfg");
207 
-
208  LoadVideoConfig("video.cfg");
-
209 
-
210  // create the fonts
-
211  loader->SetDataPath("Fonts/");
-
212 
-
213  HUDfont = new(__FILE__,__LINE__) Font("HUDfont");
-
214  FontMgr::Register("HUD", HUDfont);
-
215 
-
216  GUIfont = new(__FILE__,__LINE__) Font("GUIfont");
-
217  FontMgr::Register("GUI", GUIfont);
-
218 
-
219  GUI_small_font = new(__FILE__,__LINE__) Font("GUIsmall");
-
220  FontMgr::Register("GUIsmall", GUI_small_font);
-
221 
-
222  limerick12 = new(__FILE__,__LINE__) Font("Limerick12");
-
223  limerick18 = new(__FILE__,__LINE__) Font("Limerick18");
-
224  terminal = new(__FILE__,__LINE__) Font("Terminal");
-
225  verdana = new(__FILE__,__LINE__) Font("Verdana");
-
226  ocrb = new(__FILE__,__LINE__) Font("OCRB");
-
227 
-
228  FontMgr::Register("Limerick12", limerick12);
-
229  FontMgr::Register("Limerick18", limerick18);
-
230  FontMgr::Register("Terminal", terminal);
-
231  FontMgr::Register("Verdana", verdana);
-
232  FontMgr::Register("OCRB", ocrb);
+
208  // create the fonts
+
209  loader->SetDataPath("Fonts/");
+
210 
+
211  HUDfont = new(__FILE__,__LINE__) Font("HUDfont");
+
212  FontMgr::Register("HUD", HUDfont);
+
213 
+
214  GUIfont = new(__FILE__,__LINE__) Font("GUIfont");
+
215  FontMgr::Register("GUI", GUIfont);
+
216 
+
217  GUI_small_font = new(__FILE__,__LINE__) Font("GUIsmall");
+
218  FontMgr::Register("GUIsmall", GUI_small_font);
+
219 
+
220  limerick12 = new(__FILE__,__LINE__) Font("Limerick12");
+
221  limerick18 = new(__FILE__,__LINE__) Font("Limerick18");
+
222  terminal = new(__FILE__,__LINE__) Font("Terminal");
+
223  verdana = new(__FILE__,__LINE__) Font("Verdana");
+
224  ocrb = new(__FILE__,__LINE__) Font("OCRB");
+
225 
+
226  FontMgr::Register("Limerick12", limerick12);
+
227  FontMgr::Register("Limerick18", limerick18);
+
228  FontMgr::Register("Terminal", terminal);
+
229  FontMgr::Register("Verdana", verdana);
+
230  FontMgr::Register("OCRB", ocrb);
+
231 
+
232  loader->SetDataPath(0);
233 
-
234  loader->SetDataPath(0);
-
235 
-
236  ZeroMemory(keymap, sizeof(keymap));
-
237  ZeroMemory(keyalt, sizeof(keyalt));
-
238 }
-
239 
-
240 Starshatter::~Starshatter()
-
241 {
-
242  if (video_changed) {
-
243  SaveVideoConfig("video.cfg");
-
244  }
-
245 
-
246  DeleteFile("video2.cfg");
-
247  StopLobby();
-
248 
-
249  if (Status() <= EXIT)
-
250  Player::Save();
-
251 
-
252  delete menuscreen;
-
253  delete loadscreen;
-
254  delete planscreen;
-
255  delete gamescreen;
-
256  delete cmpnscreen;
-
257 
-
258  menuscreen = 0;
-
259  loadscreen = 0;
-
260  planscreen = 0;
-
261  gamescreen = 0;
-
262  cmpnscreen = 0;
+
234  ZeroMemory(keymap, sizeof(keymap));
+
235  ZeroMemory(keyalt, sizeof(keyalt));
+
236 }
+
237 
+
238 Starshatter::~Starshatter()
+
239 {
+
240  if (video_changed) {
+
241  SaveVideoConfig("video.cfg");
+
242  }
+
243 
+
244  DeleteFile("video2.cfg");
+
245  StopLobby();
+
246 
+
247  if (Status() <= EXIT)
+
248  Player::Save();
+
249 
+
250  delete menuscreen;
+
251  delete loadscreen;
+
252  delete planscreen;
+
253  delete gamescreen;
+
254  delete cmpnscreen;
+
255 
+
256  menuscreen = 0;
+
257  loadscreen = 0;
+
258  planscreen = 0;
+
259  gamescreen = 0;
+
260  cmpnscreen = 0;
+
261 
+
262  music_dir = 0;
263 
-
264  music_dir = 0;
-
265 
-
266  // delete all the ships and stuff
-
267  // BEFORE getting rid of the system
-
268  // and weapons catalogs!
-
269  delete world;
-
270  world = 0; // don't let base class double delete the world
+
264  // delete all the ships and stuff
+
265  // BEFORE getting rid of the system
+
266  // and weapons catalogs!
+
267  delete world;
+
268  world = 0; // don't let base class double delete the world
+
269 
+
270  delete quick_mission;
271 
-
272  delete quick_mission;
-
273 
-
274  AudioConfig::Close();
-
275  HUDSounds::Close();
-
276  MusicDirector::Close();
-
277 
-
278  Player::Close();
-
279  Drive::Close();
-
280  LandingGear::Close();
-
281  MFD::Close();
-
282  Explosion::Close();
-
283  FlightDeck::Close();
-
284  Campaign::Close();
-
285  CombatRoster::Close();
-
286  Galaxy::Close();
-
287  RadioTraffic::Close();
-
288  RadioVox::Close();
-
289  Ship::Close();
-
290  WeaponDesign::Close();
-
291  SystemDesign::Close();
-
292  ModConfig::Close();
-
293  NetClientConfig::Close();
-
294  TacticalView::Close();
-
295  QuantumView::Close();
-
296  QuitView::Close();
-
297  RadioView::Close();
-
298  NetServerConfig::Close();
-
299 
-
300  Mouse::Close();
-
301  EventDispatch::Close();
-
302  FontMgr::Close();
-
303  Button::Close();
-
304  DataLoader::Close();
-
305 
-
306  delete ocrb;
-
307  delete limerick12;
-
308  delete limerick18;
-
309  delete verdana;
-
310  delete terminal;
-
311  delete HUDfont;
-
312  delete GUIfont;
-
313  delete GUI_small_font;
-
314  delete input;
-
315  delete head_tracker;
-
316 
-
317  instance = 0;
-
318 }
-
319 
-
320 void
-
321 Starshatter::Exit()
-
322 {
-
323  MusicDirector::SetMode(MusicDirector::NONE);
-
324  SetGameMode(EXIT_MODE);
-
325 }
+
272  AudioConfig::Close();
+
273  HUDSounds::Close();
+
274  MusicDirector::Close();
+
275 
+
276  Player::Close();
+
277  Drive::Close();
+
278  LandingGear::Close();
+
279  MFD::Close();
+
280  Explosion::Close();
+
281  FlightDeck::Close();
+
282  Campaign::Close();
+
283  CombatRoster::Close();
+
284  Galaxy::Close();
+
285  RadioTraffic::Close();
+
286  RadioVox::Close();
+
287  Ship::Close();
+
288  WeaponDesign::Close();
+
289  SystemDesign::Close();
+
290  ModConfig::Close();
+
291  NetClientConfig::Close();
+
292  TacticalView::Close();
+
293  QuantumView::Close();
+
294  QuitView::Close();
+
295  RadioView::Close();
+
296  NetServerConfig::Close();
+
297 
+
298  Mouse::Close();
+
299  EventDispatch::Close();
+
300  FontMgr::Close();
+
301  Button::Close();
+
302  DataLoader::Close();
+
303 
+
304  delete ocrb;
+
305  delete limerick12;
+
306  delete limerick18;
+
307  delete verdana;
+
308  delete terminal;
+
309  delete HUDfont;
+
310  delete GUIfont;
+
311  delete GUI_small_font;
+
312  delete input;
+
313  delete head_tracker;
+
314 
+
315  instance = 0;
+
316 }
+
317 
+
318 void
+
319 Starshatter::Exit()
+
320 {
+
321  MusicDirector::SetMode(MusicDirector::NONE);
+
322  SetGameMode(EXIT_MODE);
+
323 }
+
324 
+
325 // +--------------------------------------------------------------------+
326 
-
327 // +--------------------------------------------------------------------+
-
328 
-
329 bool
-
330 Starshatter::OnHelp()
-
331 {
-
332  WebBrowser browser;
-
333  browser.OpenURL("http://matrixgames.com/support");
-
334  return true;
-
335 }
+
327 bool
+
328 Starshatter::OnHelp()
+
329 {
+
330  WebBrowser browser;
+
331  browser.OpenURL("http://matrixgames.com/support");
+
332  return true;
+
333 }
+
334 
+
335 // +--------------------------------------------------------------------+
336 
-
337 // +--------------------------------------------------------------------+
-
338 
-
339 void
-
340 Starshatter::MapKeys()
-
341 {
-
342  int nkeys = keycfg.GetNumKeys();
-
343 
-
344  if (nkeys > 0) {
-
345  Starshatter::MapKeys(&keycfg, nkeys);
-
346  input->MapKeys(keycfg.GetMapping(), nkeys);
-
347  }
-
348 }
-
349 
-
350 void
-
351 Starshatter::MapKeys(KeyMap* mapping, int nkeys)
-
352 {
-
353  for (int i = 0; i < nkeys; i++) {
-
354  KeyMapEntry* k = mapping->GetKeyMap(i);
-
355 
-
356  if (k->act >= KEY_MAP_FIRST && k->act <= KEY_MAP_LAST)
-
357  MapKey(k->act, k->key, k->alt);
-
358  }
-
359 }
-
360 
-
361 void
-
362 Starshatter::MapKey(int act, int key, int alt)
-
363 {
-
364  keymap[act] = key;
-
365  keyalt[act] = alt;
-
366 
-
367  GetAsyncKeyState(key);
-
368  GetAsyncKeyState(alt);
-
369 }
+
337 void
+
338 Starshatter::MapKeys()
+
339 {
+
340  int nkeys = keycfg.GetNumKeys();
+
341 
+
342  if (nkeys > 0) {
+
343  Starshatter::MapKeys(&keycfg, nkeys);
+
344  input->MapKeys(keycfg.GetMapping(), nkeys);
+
345  }
+
346 }
+
347 
+
348 void
+
349 Starshatter::MapKeys(KeyMap* mapping, int nkeys)
+
350 {
+
351  for (int i = 0; i < nkeys; i++) {
+
352  KeyMapEntry* k = mapping->GetKeyMap(i);
+
353 
+
354  if (k->act >= KEY_MAP_FIRST && k->act <= KEY_MAP_LAST)
+
355  MapKey(k->act, k->key, k->alt);
+
356  }
+
357 }
+
358 
+
359 void
+
360 Starshatter::MapKey(int act, int key, int alt)
+
361 {
+
362  keymap[act] = key;
+
363  keyalt[act] = alt;
+
364 
+
365  GetAsyncKeyState(key);
+
366  GetAsyncKeyState(alt);
+
367 }
+
368 
+
369 // +--------------------------------------------------------------------+
370 
-
371 // +--------------------------------------------------------------------+
-
372 
-
373 bool
-
374 Starshatter::Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow)
-
375 {
-
376  if (strstr(cmdline, "-win") || strstr(cmdline, "-dbg")) {
-
377  if (video_settings) {
-
378  video_settings->is_windowed = true;
-
379 
-
380  Print(" STARSHATTER RUNNING IN WINDOW MODE\n");
-
381  }
-
382  }
-
383 
-
384  if (strstr(cmdline, "-filesys")) {
-
385  use_file_system = true;
-
386  Print(" FILE SYSTEM ENABLED\n");
-
387  }
-
388 
-
389  if (strstr(cmdline, "-nosplash")) {
-
390  no_splash = true;
-
391  }
-
392 
-
393  if (loader)
-
394  loader->UseFileSystem(use_file_system);
-
395 
-
396  return Game::Init(hi, hpi, cmdline, nCmdShow);
-
397 }
+
371 bool
+
372 Starshatter::Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow)
+
373 {
+
374  if (strstr(cmdline, "-win") || strstr(cmdline, "-dbg")) {
+
375  if (video_settings) {
+
376  video_settings->is_windowed = true;
+
377 
+
378  Print(" STARSHATTER RUNNING IN WINDOW MODE\n");
+
379  }
+
380  }
+
381 
+
382  if (strstr(cmdline, "-filesys")) {
+
383  use_file_system = true;
+
384  Print(" FILE SYSTEM ENABLED\n");
+
385  }
+
386 
+
387  if (strstr(cmdline, "-nosplash")) {
+
388  no_splash = true;
+
389  }
+
390 
+
391  if (loader)
+
392  loader->UseFileSystem(use_file_system);
+
393 
+
394  return Game::Init(hi, hpi, cmdline, nCmdShow);
+
395 }
+
396 
+
397 // +--------------------------------------------------------------------+
398 
-
399 // +--------------------------------------------------------------------+
-
400 
-
401 bool
-
402 Starshatter::InitGame()
-
403 {
-
404  if (!Game::InitGame())
-
405  return false;
+
399 bool
+
400 Starshatter::InitGame()
+
401 {
+
402  if (!Game::InitGame())
+
403  return false;
+
404 
+
405  RandomInit();
406 
-
407  RandomInit();
-
408 
-
409  AudioConfig::Initialize();
-
410  ModConfig::Initialize();
+
407  AudioConfig::Initialize();
+
408  ModConfig::Initialize();
+
409 
+
410  InitMouse();
411 
-
412  InitMouse();
-
413 
-
414  Button::Initialize();
-
415  EventDispatch::Create();
-
416  NetClientConfig::Initialize();
-
417  Player::Initialize();
-
418  HUDSounds::Initialize();
+
412  Button::Initialize();
+
413  EventDispatch::Create();
+
414  NetClientConfig::Initialize();
+
415  Player::Initialize();
+
416  HUDSounds::Initialize();
+
417 
+
418  int nkeys = keycfg.LoadKeyMap("key.cfg", 256);
419 
-
420  int nkeys = keycfg.LoadKeyMap("key.cfg", 256);
-
421 
-
422  if (nkeys)
-
423  Print(" Loaded key.cfg\n\n");
-
424 
-
425  // create the appropriate motion controller and player_ship
-
426  input = new(__FILE__,__LINE__) MultiController;
-
427  Keyboard* k = new(__FILE__,__LINE__) Keyboard;
-
428  input->AddController(k);
-
429 
-
430  mouse_input = new(__FILE__,__LINE__) MouseController;
-
431  input->AddController(mouse_input);
-
432 
-
433  ::Print("\nStarshatter::InitGame() create joystick\n");
-
434  Joystick* j = new(__FILE__,__LINE__) Joystick;
-
435  j->SetSensitivity(15, 5000);
-
436  input->AddController(j);
-
437 
-
438  Joystick::EnumerateDevices();
-
439  ::Print("\n");
-
440 
-
441  head_tracker = new(__FILE__,__LINE__) TrackIR();
-
442  MapKeys();
-
443 
-
444  SystemDesign::Initialize("sys.def");
-
445  WeaponDesign::Initialize("wep.def");
-
446  MusicDirector::Initialize();
-
447 
-
448  // if no splashes, we need to initialize the campaign engine now
-
449  if (no_splash) {
-
450  Ship::Initialize();
-
451  Galaxy::Initialize();
-
452  CombatRoster::Initialize();
-
453  Campaign::Initialize();
-
454  }
-
455 
-
456  // otherwise, the campaign engine will get initialized during the splashes
-
457  else {
-
458  SetupSplash();
-
459  }
-
460 
-
461  time_mark = Game::GameTime();
-
462  minutes = 0;
-
463 
-
464  return true;
-
465 }
-
466 
-
467 void
-
468 Starshatter::InitMouse()
-
469 {
-
470  if (loader) {
-
471  loader->SetDataPath(0);
-
472 
-
473  Mouse::Create(screen);
-
474  Mouse::Show(false);
-
475  Mouse::LoadCursor(Mouse::ARROW, "MouseArrow.pcx", Mouse::HOTSPOT_NW);
-
476  Mouse::LoadCursor(Mouse::CROSS, "MouseCross.pcx", Mouse::HOTSPOT_CTR);
-
477  Mouse::LoadCursor(Mouse::DRAG, "MouseDrag.pcx", Mouse::HOTSPOT_NW);
-
478  Mouse::SetCursor(Mouse::ARROW);
-
479  }
-
480 }
+
420  if (nkeys)
+
421  Print(" Loaded key.cfg\n\n");
+
422 
+
423  // create the appropriate motion controller and player_ship
+
424  input = new(__FILE__,__LINE__) MultiController;
+
425  Keyboard* k = new(__FILE__,__LINE__) Keyboard;
+
426  input->AddController(k);
+
427 
+
428  mouse_input = new(__FILE__,__LINE__) MouseController;
+
429  input->AddController(mouse_input);
+
430 
+
431  ::Print("\nStarshatter::InitGame() create joystick\n");
+
432  Joystick* j = new(__FILE__,__LINE__) Joystick;
+
433  j->SetSensitivity(15, 5000);
+
434  input->AddController(j);
+
435 
+
436  Joystick::EnumerateDevices();
+
437  ::Print("\n");
+
438 
+
439  head_tracker = new(__FILE__,__LINE__) TrackIR();
+
440  MapKeys();
+
441 
+
442  SystemDesign::Initialize("sys.def");
+
443  WeaponDesign::Initialize("wep.def");
+
444  MusicDirector::Initialize();
+
445 
+
446  // if no splashes, we need to initialize the campaign engine now
+
447  if (no_splash) {
+
448  Ship::Initialize();
+
449  Galaxy::Initialize();
+
450  CombatRoster::Initialize();
+
451  Campaign::Initialize();
+
452  }
+
453 
+
454  // otherwise, the campaign engine will get initialized during the splashes
+
455  else {
+
456  SetupSplash();
+
457  }
+
458 
+
459  time_mark = Game::GameTime();
+
460  minutes = 0;
+
461 
+
462  return true;
+
463 }
+
464 
+
465 void
+
466 Starshatter::InitMouse()
+
467 {
+
468  if (loader) {
+
469  loader->SetDataPath(0);
+
470 
+
471  Mouse::Create(screen);
+
472  Mouse::Show(false);
+
473  Mouse::LoadCursor(Mouse::ARROW, "MouseArrow.pcx", Mouse::HOTSPOT_NW);
+
474  Mouse::LoadCursor(Mouse::CROSS, "MouseCross.pcx", Mouse::HOTSPOT_CTR);
+
475  Mouse::LoadCursor(Mouse::DRAG, "MouseDrag.pcx", Mouse::HOTSPOT_NW);
+
476  Mouse::SetCursor(Mouse::ARROW);
+
477  }
+
478 }
+
479 
+
480 // +--------------------------------------------------------------------+
481 
-
482 // +--------------------------------------------------------------------+
-
483 
-
484 void
-
485 Starshatter::RequestChangeVideo()
-
486 {
-
487  req_change_video = true;
-
488 }
-
489 
-
490 int
-
491 Starshatter::GetScreenWidth()
-
492 {
-
493  if (video_settings)
-
494  return video_settings->GetWidth();
-
495 
-
496  return 0;
-
497 }
+
482 void
+
483 Starshatter::RequestChangeVideo()
+
484 {
+
485  req_change_video = true;
+
486 }
+
487 
+
488 int
+
489 Starshatter::GetScreenWidth()
+
490 {
+
491  if (video_settings)
+
492  return video_settings->GetWidth();
+
493 
+
494  return 0;
+
495 }
+
496 
+
497 // +--------------------------------------------------------------------+
498 
-
499 // +--------------------------------------------------------------------+
-
500 
-
501 int
-
502 Starshatter::GetScreenHeight()
-
503 {
-
504  if (video_settings)
-
505  return video_settings->GetHeight();
-
506 
-
507  return 0;
-
508 }
+
499 int
+
500 Starshatter::GetScreenHeight()
+
501 {
+
502  if (video_settings)
+
503  return video_settings->GetHeight();
+
504 
+
505  return 0;
+
506 }
+
507 
+
508 // +--------------------------------------------------------------------+
509 
-
510 // +--------------------------------------------------------------------+
-
511 
-
512 void
-
513 Starshatter::StartOrResumeGame()
-
514 {
-
515  if (game_mode != MENU_MODE && game_mode != CMPN_MODE)
-
516  return;
-
517 
-
518  Player* p = Player::GetCurrentPlayer();
-
519  if (!p)
-
520  return;
-
521 
-
522  List<Campaign>& list = Campaign::GetAllCampaigns();
-
523  Campaign* c = 0;
-
524  Text saved = CampaignSaveGame::GetResumeFile();
-
525 
-
526 
-
527  // resume saved game?
-
528  if (saved.length()) {
-
529  CampaignSaveGame savegame;
-
530  savegame.Load(saved);
-
531  c = savegame.GetCampaign();
-
532  }
-
533 
-
534  // start training campaign?
-
535  else if (p->Trained() < 255) {
-
536  c = list[0];
-
537  c->Load();
-
538  }
-
539 
-
540  // start new dynamic campaign sequence?
-
541  else {
-
542  c = list[1];
-
543  c->Load();
-
544  }
-
545 
-
546  if (c)
-
547  Campaign::SelectCampaign(c->Name());
-
548 
-
549  Mouse::Show(false);
-
550  SetGameMode(CLOD_MODE);
-
551 }
+
510 void
+
511 Starshatter::StartOrResumeGame()
+
512 {
+
513  if (game_mode != MENU_MODE && game_mode != CMPN_MODE)
+
514  return;
+
515 
+
516  Player* p = Player::GetCurrentPlayer();
+
517  if (!p)
+
518  return;
+
519 
+
520  List<Campaign>& list = Campaign::GetAllCampaigns();
+
521  Campaign* c = 0;
+
522  Text saved = CampaignSaveGame::GetResumeFile();
+
523 
+
524 
+
525  // resume saved game?
+
526  if (saved.length()) {
+
527  CampaignSaveGame savegame;
+
528  savegame.Load(saved);
+
529  c = savegame.GetCampaign();
+
530  }
+
531 
+
532  // start training campaign?
+
533  else if (p->Trained() < 255) {
+
534  c = list[0];
+
535  c->Load();
+
536  }
+
537 
+
538  // start new dynamic campaign sequence?
+
539  else {
+
540  c = list[1];
+
541  c->Load();
+
542  }
+
543 
+
544  if (c)
+
545  Campaign::SelectCampaign(c->Name());
+
546 
+
547  Mouse::Show(false);
+
548  SetGameMode(CLOD_MODE);
+
549 }
+
550 
+
551 // +--------------------------------------------------------------------+
552 
-
553 // +--------------------------------------------------------------------+
-
554 
-
555 bool
-
556 Starshatter::UseFileSystem()
-
557 {
-
558  return use_file_system;
-
559 }
+
553 bool
+
554 Starshatter::UseFileSystem()
+
555 {
+
556  return use_file_system;
+
557 }
+
558 
+
559 // +--------------------------------------------------------------------+
560 
-
561 // +--------------------------------------------------------------------+
-
562 
-
563 void
-
564 Starshatter::OpenTacticalReference()
-
565 {
-
566  if (menuscreen && game_mode == MENU_MODE) {
-
567  menuscreen->ShowLoadDlg();
+
561 void
+
562 Starshatter::OpenTacticalReference()
+
563 {
+
564  if (menuscreen && game_mode == MENU_MODE) {
+
565  menuscreen->ShowLoadDlg();
+
566 
+
567  LoadDlg* load_dlg = menuscreen->GetLoadDlg();
568 
-
569  LoadDlg* load_dlg = menuscreen->GetLoadDlg();
-
570 
-
571  if (load_dlg && load_dlg->IsShown()) {
-
572  load_activity = Game::GetText("Starshatter.load.tac-ref");
-
573  load_progress = 1;
-
574  catalog_index = 0;
-
575  }
-
576  else {
-
577  menuscreen->ShowTacRefDlg();
-
578  }
-
579  }
-
580 }
+
569  if (load_dlg && load_dlg->IsShown()) {
+
570  load_activity = Game::GetText("Starshatter.load.tac-ref");
+
571  load_progress = 1;
+
572  catalog_index = 0;
+
573  }
+
574  else {
+
575  menuscreen->ShowTacRefDlg();
+
576  }
+
577  }
+
578 }
+
579 
+
580 // +--------------------------------------------------------------------+
581 
-
582 // +--------------------------------------------------------------------+
-
583 
-
584 void
-
585 Starshatter::SetGameMode(int m)
-
586 {
-
587  if (game_mode == m)
-
588  return;
-
589 
-
590  const char* mode_name[] = {
-
591  "MENU_MODE", // main menu
-
592  "CLOD_MODE", // loading campaign
-
593  "CMPN_MODE", // operational command for dynamic campaign
-
594  "PREP_MODE", // loading mission info for planning
-
595  "PLAN_MODE", // mission briefing
-
596  "LOAD_MODE", // loading mission into simulator
-
597  "PLAY_MODE", // active simulation
-
598  "EXIT_MODE" // shutting down
-
599  };
-
600 
-
601  if (m >= MENU_MODE && m <= EXIT_MODE)
-
602  Print(">>> Starshatter::SetGameMode(%d) (%s)\n", m, mode_name[m]);
-
603  else
-
604  Print(">>> Starshatter::SetGameMode(%d) (UNKNOWN MODE)\n", m);
-
605 
-
606  MouseController* mouse_con = MouseController::GetInstance();
-
607  if (mouse_con)
-
608  mouse_con->SetActive(false);
-
609 
-
610  if (m == CLOD_MODE || m == PREP_MODE || m == LOAD_MODE) {
-
611  load_step = 0;
-
612  load_progress = 0;
-
613  load_activity = Game::GetText("Starshatter.load.general");
-
614  paused = true;
-
615  }
-
616 
-
617  else if (m == CMPN_MODE) {
-
618  load_step = 0;
-
619  load_progress = 100;
-
620  load_activity = Game::GetText("Starshatter.load.complete");
-
621  paused = false;
-
622  }
-
623 
-
624  else if (m == PLAY_MODE) {
-
625  Print(" Starting Game...\n");
-
626 
-
627  player_ship = 0;
-
628  load_progress = 100;
-
629  load_activity = Game::GetText("Starshatter.load.complete");
-
630 
-
631  if (!world) {
-
632  CreateWorld();
-
633  InstantiateMission();
-
634  }
-
635 
-
636  if (gamescreen)
-
637  gamescreen->SetFieldOfView(field_of_view);
-
638 
-
639  HUDView::ClearMessages();
-
640  RadioView::ClearMessages();
-
641 
-
642  SetTimeCompression(1);
-
643  Pause(false);
-
644 
-
645  Print(" Stardate: %.1f\n", StarSystem::GetBaseTime());
-
646  }
-
647 
-
648  else if (m == PLAN_MODE) {
-
649  if (game_mode == PLAY_MODE) {
-
650  Print(" Returning to Plan Mode...\n");
-
651  if (soundcard)
-
652  soundcard->StopSoundEffects();
-
653 
-
654  StopNetGame();
-
655  Pause(true);
-
656  Print(" Stardate: %.1f\n", StarSystem::GetBaseTime());
-
657  }
-
658  }
-
659 
-
660  else if (m == MENU_MODE) {
-
661  Print(" Returning to Main Menu...\n");
-
662 
-
663  if (game_mode == PLAN_MODE || game_mode == PLAY_MODE) {
-
664  if (soundcard)
-
665  soundcard->StopSoundEffects();
-
666 
-
667  StopNetGame();
-
668  }
-
669 
-
670  paused = true;
-
671  }
-
672 
-
673  if (m == EXIT_MODE) {
-
674  Print(" Shutting Down (Returning to Windows)...\n");
-
675 
-
676  if (game_mode == PLAN_MODE || game_mode == PLAY_MODE) {
-
677  if (soundcard)
-
678  soundcard->StopSoundEffects();
-
679 
-
680  StopNetGame();
-
681  }
-
682 
-
683  Print(" Stardate: %.1f\n", StarSystem::GetBaseTime());
-
684  Print(" Bitmap Cache Footprint: %d KB\n", Bitmap::CacheMemoryFootprint() / 1024);
-
685 
-
686  paused = true;
-
687  }
-
688 
-
689  FlushKeys();
-
690  game_mode = m;
-
691 }
+
582 void
+
583 Starshatter::SetGameMode(int m)
+
584 {
+
585  if (game_mode == m)
+
586  return;
+
587 
+
588  const char* mode_name[] = {
+
589  "MENU_MODE", // main menu
+
590  "CLOD_MODE", // loading campaign
+
591  "CMPN_MODE", // operational command for dynamic campaign
+
592  "PREP_MODE", // loading mission info for planning
+
593  "PLAN_MODE", // mission briefing
+
594  "LOAD_MODE", // loading mission into simulator
+
595  "PLAY_MODE", // active simulation
+
596  "EXIT_MODE" // shutting down
+
597  };
+
598 
+
599  if (m >= MENU_MODE && m <= EXIT_MODE)
+
600  Print(">>> Starshatter::SetGameMode(%d) (%s)\n", m, mode_name[m]);
+
601  else
+
602  Print(">>> Starshatter::SetGameMode(%d) (UNKNOWN MODE)\n", m);
+
603 
+
604  MouseController* mouse_con = MouseController::GetInstance();
+
605  if (mouse_con)
+
606  mouse_con->SetActive(false);
+
607 
+
608  if (m == CLOD_MODE || m == PREP_MODE || m == LOAD_MODE) {
+
609  load_step = 0;
+
610  load_progress = 0;
+
611  load_activity = Game::GetText("Starshatter.load.general");
+
612  paused = true;
+
613  }
+
614 
+
615  else if (m == CMPN_MODE) {
+
616  load_step = 0;
+
617  load_progress = 100;
+
618  load_activity = Game::GetText("Starshatter.load.complete");
+
619  paused = false;
+
620  }
+
621 
+
622  else if (m == PLAY_MODE) {
+
623  Print(" Starting Game...\n");
+
624 
+
625  player_ship = 0;
+
626  load_progress = 100;
+
627  load_activity = Game::GetText("Starshatter.load.complete");
+
628 
+
629  if (!world) {
+
630  CreateWorld();
+
631  InstantiateMission();
+
632  }
+
633 
+
634  if (gamescreen)
+
635  gamescreen->SetFieldOfView(field_of_view);
+
636 
+
637  HUDView::ClearMessages();
+
638  RadioView::ClearMessages();
+
639 
+
640  SetTimeCompression(1);
+
641  Pause(false);
+
642 
+
643  Print(" Stardate: %.1f\n", StarSystem::GetBaseTime());
+
644  }
+
645 
+
646  else if (m == PLAN_MODE) {
+
647  if (game_mode == PLAY_MODE) {
+
648  Print(" Returning to Plan Mode...\n");
+
649  if (soundcard)
+
650  soundcard->StopSoundEffects();
+
651 
+
652  StopNetGame();
+
653  Pause(true);
+
654  Print(" Stardate: %.1f\n", StarSystem::GetBaseTime());
+
655  }
+
656  }
+
657 
+
658  else if (m == MENU_MODE) {
+
659  Print(" Returning to Main Menu...\n");
+
660 
+
661  if (game_mode == PLAN_MODE || game_mode == PLAY_MODE) {
+
662  if (soundcard)
+
663  soundcard->StopSoundEffects();
+
664 
+
665  StopNetGame();
+
666  }
+
667 
+
668  paused = true;
+
669  }
+
670 
+
671  if (m == EXIT_MODE) {
+
672  Print(" Shutting Down (Returning to Windows)...\n");
+
673 
+
674  if (game_mode == PLAN_MODE || game_mode == PLAY_MODE) {
+
675  if (soundcard)
+
676  soundcard->StopSoundEffects();
+
677 
+
678  StopNetGame();
+
679  }
+
680 
+
681  Print(" Stardate: %.1f\n", StarSystem::GetBaseTime());
+
682  Print(" Bitmap Cache Footprint: %d KB\n", Bitmap::CacheMemoryFootprint() / 1024);
+
683 
+
684  paused = true;
+
685  }
+
686 
+
687  FlushKeys();
+
688  game_mode = m;
+
689 }
+
690 
+
691 // +--------------------------------------------------------------------+
692 
-
693 // +--------------------------------------------------------------------+
-
694 
-
695 bool
-
696 Starshatter::ChangeVideo()
-
697 {
-
698  bool result = false;
-
699 
-
700  if (menuscreen) {
-
701  delete menuscreen;
-
702  menuscreen = 0;
-
703  }
-
704 
-
705  if (loadscreen) {
-
706  delete loadscreen;
-
707  loadscreen = 0;
-
708  }
-
709 
-
710  if (planscreen) {
-
711  delete planscreen;
-
712  planscreen = 0;
-
713  }
-
714 
-
715  if (gamescreen) {
-
716  delete gamescreen;
-
717  gamescreen = 0;
-
718  }
-
719 
-
720  if (cmpnscreen) {
-
721  delete cmpnscreen;
-
722  cmpnscreen = 0;
-
723  }
+
693 bool
+
694 Starshatter::ChangeVideo()
+
695 {
+
696  bool result = false;
+
697 
+
698  if (menuscreen) {
+
699  delete menuscreen;
+
700  menuscreen = 0;
+
701  }
+
702 
+
703  if (loadscreen) {
+
704  delete loadscreen;
+
705  loadscreen = 0;
+
706  }
+
707 
+
708  if (planscreen) {
+
709  delete planscreen;
+
710  planscreen = 0;
+
711  }
+
712 
+
713  if (gamescreen) {
+
714  delete gamescreen;
+
715  gamescreen = 0;
+
716  }
+
717 
+
718  if (cmpnscreen) {
+
719  delete cmpnscreen;
+
720  cmpnscreen = 0;
+
721  }
+
722 
+
723  loader->SetDataPath(0);
724 
-
725  loader->SetDataPath(0);
+
725  LoadVideoConfig("video2.cfg");
726 
-
727  LoadVideoConfig("video2.cfg");
+
727  result = ResetVideo();
728 
-
729  result = ResetVideo();
+
729  InitMouse();
730 
-
731  InitMouse();
-
732 
-
733  req_change_video = false;
-
734  video_changed = true;
-
735 
-
736  return result;
-
737 }
-
738 
-
739 bool
-
740 Starshatter::ResizeVideo()
-
741 {
-
742  if (Game::ResizeVideo()) {
-
743  InitMouse();
-
744  Mouse::Show(true);
-
745 
-
746  return true;
-
747  }
-
748 
-
749  return false;
-
750 }
+
731  req_change_video = false;
+
732  video_changed = true;
+
733 
+
734  return result;
+
735 }
+
736 
+
737 bool
+
738 Starshatter::ResizeVideo()
+
739 {
+
740  if (Game::ResizeVideo()) {
+
741  InitMouse();
+
742  Mouse::Show(true);
+
743 
+
744  return true;
+
745  }
+
746 
+
747  return false;
+
748 }
+
749 
+
750 // +--------------------------------------------------------------------+
751 
-
752 // +--------------------------------------------------------------------+
-
753 
-
754 void
-
755 Starshatter::CreateWorld()
-
756 {
-
757  RadioTraffic::Initialize();
-
758  RadioView::Initialize();
-
759  RadioVox::Initialize();
-
760  QuantumView::Initialize();
-
761  QuitView::Initialize();
-
762  TacticalView::Initialize();
-
763 
-
764  // create world
-
765  if (!world) {
-
766  Sim* sim = new(__FILE__,__LINE__) Sim(input);
-
767  world = sim;
-
768  Print(" World Created.\n");
-
769  }
-
770 
-
771  cam_dir = CameraDirector::GetInstance();
-
772 }
-
773 
-
774 void
-
775 Starshatter::InstantiateMission()
-
776 {
-
777  Memory::Check();
+
752 void
+
753 Starshatter::CreateWorld()
+
754 {
+
755  RadioTraffic::Initialize();
+
756  RadioView::Initialize();
+
757  RadioVox::Initialize();
+
758  QuantumView::Initialize();
+
759  QuitView::Initialize();
+
760  TacticalView::Initialize();
+
761 
+
762  // create world
+
763  if (!world) {
+
764  Sim* sim = new(__FILE__,__LINE__) Sim(input);
+
765  world = sim;
+
766  Print(" World Created.\n");
+
767  }
+
768 
+
769  cam_dir = CameraDirector::GetInstance();
+
770 }
+
771 
+
772 void
+
773 Starshatter::InstantiateMission()
+
774 {
+
775  Memory::Check();
+
776 
+
777  current_mission = 0;
778 
-
779  current_mission = 0;
-
780 
-
781  if (Campaign::GetCampaign()) {
-
782  current_mission = Campaign::GetCampaign()->GetMission();
-
783  }
+
779  if (Campaign::GetCampaign()) {
+
780  current_mission = Campaign::GetCampaign()->GetMission();
+
781  }
+
782 
+
783  Sim* sim = (Sim*) world;
784 
-
785  Sim* sim = (Sim*) world;
-
786 
-
787  if (sim) {
-
788  bool dynamic = false;
-
789  Campaign* campaign = Campaign::GetCampaign();
-
790 
-
791  if (campaign && campaign->IsDynamic())
-
792  dynamic = true;
-
793 
-
794  sim->UnloadMission();
-
795  sim->LoadMission(current_mission);
-
796  sim->ExecMission();
-
797  sim->SetTestMode(test_mode && !dynamic ? true : false);
-
798 
-
799  Print(" Mission Instantiated.\n");
-
800  }
-
801 
-
802  Memory::Check();
-
803 }
+
785  if (sim) {
+
786  bool dynamic = false;
+
787  Campaign* campaign = Campaign::GetCampaign();
+
788 
+
789  if (campaign && campaign->IsDynamic())
+
790  dynamic = true;
+
791 
+
792  sim->UnloadMission();
+
793  sim->LoadMission(current_mission);
+
794  sim->ExecMission();
+
795  sim->SetTestMode(test_mode && !dynamic ? true : false);
+
796 
+
797  Print(" Mission Instantiated.\n");
+
798  }
+
799 
+
800  Memory::Check();
+
801 }
+
802 
+
803 // +--------------------------------------------------------------------+
804 
-
805 // +--------------------------------------------------------------------+
-
806 
-
807 int
-
808 Starshatter::KeyDown(int action) const
-
809 {
-
810  int k = Joystick::KeyDownMap(action) ||
-
811  Keyboard::KeyDownMap(action);
-
812 
-
813  return k;
-
814 }
+
805 int
+
806 Starshatter::KeyDown(int action) const
+
807 {
+
808  int k = Joystick::KeyDownMap(action) ||
+
809  Keyboard::KeyDownMap(action);
+
810 
+
811  return k;
+
812 }
+
813 
+
814 // +--------------------------------------------------------------------+
815 
-
816 // +--------------------------------------------------------------------+
-
817 
-
818 bool
-
819 Starshatter::GameLoop()
-
820 {
-
821  cam_dir = CameraDirector::GetInstance();
-
822 
-
823  if (active && paused) {
-
824  // Route Events to EventTargets
-
825  EventDispatch* ed = EventDispatch::GetInstance();
-
826  if (ed)
-
827  ed->Dispatch();
-
828 
-
829  UpdateWorld();
-
830  GameState();
-
831  UpdateScreen();
-
832  CollectStats();
-
833 
-
834  /***
-
835  static DWORD vmf_time = 0;
-
836 
-
837  if (real_time() - vmf_time > 5000) {
-
838  vmf_time = real_time();
-
839  DWORD vmf = video->VidMemFree() / (1024 * 1024);
-
840  ::Print("\n###### %02d:%02d - Video Memory Free: %d MB\n\n",
-
841  vmf_time / 60000,
-
842  vmf_time / 1000,
-
843  vmf);
-
844  }
-
845  ***/
-
846  }
-
847 
-
848  Game::GameLoop();
-
849  return false; // must return false to keep processing
-
850  // true tells the outer loop to sleep until a
-
851  // windows event is available
-
852 }
+
816 bool
+
817 Starshatter::GameLoop()
+
818 {
+
819  cam_dir = CameraDirector::GetInstance();
+
820 
+
821  if (active && paused) {
+
822  // Route Events to EventTargets
+
823  EventDispatch* ed = EventDispatch::GetInstance();
+
824  if (ed)
+
825  ed->Dispatch();
+
826 
+
827  UpdateWorld();
+
828  GameState();
+
829  UpdateScreen();
+
830  CollectStats();
+
831 
+
832  /***
+
833  static DWORD vmf_time = 0;
+
834 
+
835  if (real_time() - vmf_time > 5000) {
+
836  vmf_time = real_time();
+
837  DWORD vmf = video->VidMemFree() / (1024 * 1024);
+
838  ::Print("\n###### %02d:%02d - Video Memory Free: %d MB\n\n",
+
839  vmf_time / 60000,
+
840  vmf_time / 1000,
+
841  vmf);
+
842  }
+
843  ***/
+
844  }
+
845 
+
846  Game::GameLoop();
+
847  return false; // must return false to keep processing
+
848  // true tells the outer loop to sleep until a
+
849  // windows event is available
+
850 }
+
851 
+
852 // +--------------------------------------------------------------------+
853 
-
854 // +--------------------------------------------------------------------+
-
855 
-
856 void
-
857 Starshatter::UpdateWorld()
-
858 {
-
859  long new_time = real_time;
-
860  double delta = new_time - frame_time; // in milliseconds
-
861  seconds = max_frame_length; // in seconds
-
862  gui_seconds = delta * 0.001;
-
863 
-
864  if (frame_time == 0)
-
865  gui_seconds = 0;
-
866 
-
867  if (delta < time_comp * max_frame_length * 1000) {
-
868  seconds = time_comp * delta * 0.001;
-
869  }
-
870  else {
-
871  seconds = time_comp * max_frame_length;
-
872  }
+
854 void
+
855 Starshatter::UpdateWorld()
+
856 {
+
857  long new_time = real_time;
+
858  double delta = new_time - frame_time; // in milliseconds
+
859  seconds = max_frame_length; // in seconds
+
860  gui_seconds = delta * 0.001;
+
861 
+
862  if (frame_time == 0)
+
863  gui_seconds = 0;
+
864 
+
865  if (delta < time_comp * max_frame_length * 1000) {
+
866  seconds = time_comp * delta * 0.001;
+
867  }
+
868  else {
+
869  seconds = time_comp * max_frame_length;
+
870  }
+
871 
+
872  frame_time = new_time;
873 
-
874  frame_time = new_time;
-
875 
-
876  Galaxy* galaxy = Galaxy::GetInstance();
-
877  if (galaxy) galaxy->ExecFrame();
-
878 
-
879  // Cutscene missions have a tendency to mess with the stardate
-
880  // to manage time-of-day and camera effects. It's a bad idea to
-
881  // evaluate campaign actions and events while the cutscene is
-
882  // changing the time base.
-
883  if (!cutscene_mission) {
-
884  Campaign* campaign = Campaign::GetCampaign();
-
885  if (campaign) campaign->ExecFrame();
-
886  }
-
887 
-
888  if (paused) {
-
889  if (world)
-
890  world->ExecFrame(0);
-
891  }
-
892 
-
893  else {
-
894  game_time += (DWORD) (seconds * 1000);
+
874  Galaxy* galaxy = Galaxy::GetInstance();
+
875  if (galaxy) galaxy->ExecFrame();
+
876 
+
877  // Cutscene missions have a tendency to mess with the stardate
+
878  // to manage time-of-day and camera effects. It's a bad idea to
+
879  // evaluate campaign actions and events while the cutscene is
+
880  // changing the time base.
+
881  if (!cutscene_mission) {
+
882  Campaign* campaign = Campaign::GetCampaign();
+
883  if (campaign) campaign->ExecFrame();
+
884  }
+
885 
+
886  if (paused) {
+
887  if (world)
+
888  world->ExecFrame(0);
+
889  }
+
890 
+
891  else {
+
892  game_time += (DWORD) (seconds * 1000);
+
893 
+
894  Drive::StartFrame();
895 
-
896  Drive::StartFrame();
-
897 
-
898  if (world)
-
899  world->ExecFrame(seconds);
-
900  }
-
901 
-
902  if (game_mode == PLAY_MODE || InCutscene()) {
-
903  if (cam_dir) {
-
904  if (head_tracker && head_tracker->IsRunning() && !InCutscene()) {
-
905  head_tracker->ExecFrame();
-
906  cam_dir->VirtualHead(head_tracker->GetAzimuth(), head_tracker->GetElevation());
-
907  cam_dir->VirtualHeadOffset(head_tracker->GetX(), head_tracker->GetY(), head_tracker->GetZ());
-
908  }
-
909 
-
910  cam_dir->ExecFrame(gui_seconds);
-
911  }
-
912 
-
913  Sim* sim = Sim::GetSim();
-
914  SimRegion* rgn = sim ? sim->GetActiveRegion() : 0;
-
915 
-
916  if (rgn) {
-
917  ListIter<Ship> iter = rgn->Ships();
-
918  while (++iter) {
-
919  Ship* s = iter.value();
-
920  s->SelectDetail(seconds);
-
921  }
-
922  }
-
923  }
-
924 }
+
896  if (world)
+
897  world->ExecFrame(seconds);
+
898  }
+
899 
+
900  if (game_mode == PLAY_MODE || InCutscene()) {
+
901  if (cam_dir) {
+
902  if (head_tracker && head_tracker->IsRunning() && !InCutscene()) {
+
903  head_tracker->ExecFrame();
+
904  cam_dir->VirtualHead(head_tracker->GetAzimuth(), head_tracker->GetElevation());
+
905  cam_dir->VirtualHeadOffset(head_tracker->GetX(), head_tracker->GetY(), head_tracker->GetZ());
+
906  }
+
907 
+
908  cam_dir->ExecFrame(gui_seconds);
+
909  }
+
910 
+
911  Sim* sim = Sim::GetSim();
+
912  SimRegion* rgn = sim ? sim->GetActiveRegion() : 0;
+
913 
+
914  if (rgn) {
+
915  ListIter<Ship> iter = rgn->Ships();
+
916  while (++iter) {
+
917  Ship* s = iter.value();
+
918  s->SelectDetail(seconds);
+
919  }
+
920  }
+
921  }
+
922 }
+
923 
+
924 // +--------------------------------------------------------------------+
925 
-
926 // +--------------------------------------------------------------------+
-
927 
-
928 void
-
929 Starshatter::GameState()
-
930 {
-
931  if (splash) {
-
932  static bool quick_splash = false;
-
933 
-
934  if (GetKey() != 0)
-
935  quick_splash = true;
-
936 
-
937  if (quick_splash) {
-
938  splash->FadeIn(0);
-
939  splash->StopHold();
-
940  splash->FadeOut(0);
-
941  }
-
942 
-
943  if (splash->Done()) {
-
944  splash = 0; // this will get deleted along with gamewin
-
945  splash_index++;
-
946 
-
947  if (gamewin) {
-
948  screen->DelWindow(gamewin);
-
949  delete gamewin;
-
950  gamewin = 0;
-
951  }
-
952 
-
953  if (splash_index < 2) {
-
954  Ship::Initialize();
-
955  Galaxy::Initialize();
-
956  SetupSplash();
-
957  }
-
958  else {
-
959  CombatRoster::Initialize();
-
960  Campaign::Initialize();
-
961  SetupMenuScreen();
-
962  }
-
963 
-
964  FlushKeys();
-
965  }
-
966  }
-
967 
-
968  else if (game_mode == MENU_MODE) {
-
969  bool campaign_select = false;
-
970 
-
971  if (cmpnscreen) {
-
972  campaign_select = cmpnscreen->IsShown();
-
973  cmpnscreen->Hide();
-
974  }
-
975 
-
976  if (gamescreen)
-
977  gamescreen->Hide();
-
978 
-
979  if (planscreen)
-
980  planscreen->Hide();
-
981 
-
982  if (loadscreen)
-
983  loadscreen->Hide();
-
984 
-
985  if (!menuscreen) {
-
986  SetupMenuScreen();
-
987  }
-
988  else {
-
989  menuscreen->Show();
-
990 
-
991  if (campaign_select)
-
992  menuscreen->ShowCmpSelectDlg();
-
993  }
-
994 
-
995  if (MusicDirector::GetInstance() &&
-
996  MusicDirector::GetInstance()->GetMode() != MusicDirector::CREDITS)
-
997  MusicDirector::SetMode(MusicDirector::MENU);
-
998 
-
999  DoMenuScreenFrame();
-
1000  }
-
1001 
-
1002  else if (game_mode == CLOD_MODE ||
-
1003  game_mode == PREP_MODE ||
-
1004  game_mode == LOAD_MODE) {
-
1005  if (menuscreen)
-
1006  menuscreen->Hide();
-
1007 
-
1008  if (planscreen)
-
1009  planscreen->Hide();
-
1010 
-
1011  if (cmpnscreen)
-
1012  cmpnscreen->Hide();
-
1013 
-
1014  if (!loadscreen)
-
1015  SetupLoadScreen();
-
1016  else
-
1017  loadscreen->Show();
-
1018 
-
1019  if (game_mode == CLOD_MODE)
-
1020  MusicDirector::SetMode(MusicDirector::MENU);
-
1021  else
-
1022  MusicDirector::SetMode(MusicDirector::BRIEFING);
-
1023 
-
1024  DoLoadScreenFrame();
-
1025  }
-
1026 
-
1027  else if (game_mode == PLAN_MODE) {
-
1028  if (menuscreen)
-
1029  menuscreen->Hide();
-
1030 
-
1031  if (cmpnscreen)
-
1032  menuscreen->Hide();
-
1033 
-
1034  if (loadscreen)
-
1035  loadscreen->Hide();
-
1036 
-
1037  if (gamescreen)
-
1038  gamescreen->Hide();
-
1039 
-
1040  if (!planscreen)
-
1041  SetupPlanScreen();
-
1042  else
-
1043  planscreen->Show();
-
1044 
-
1045  Player* p = Player::GetCurrentPlayer();
-
1046  if (p && p->ShowAward()) {
-
1047  if (!planscreen->IsAwardShown())
-
1048  planscreen->ShowAwardDlg();
-
1049  }
-
1050 
-
1051  else if (ShipStats::NumStats()) {
-
1052  if (!planscreen->IsDebriefShown()) {
-
1053  planscreen->ShowDebriefDlg();
-
1054  show_missions = true;
-
1055  }
-
1056  }
-
1057 
-
1058  else {
-
1059  if (!planscreen->IsMsnShown() && !planscreen->IsNavShown())
-
1060  planscreen->ShowMsnDlg();
-
1061  }
+
926 void
+
927 Starshatter::GameState()
+
928 {
+
929  if (splash) {
+
930  static bool quick_splash = false;
+
931 
+
932  if (GetKey() != 0)
+
933  quick_splash = true;
+
934 
+
935  if (quick_splash) {
+
936  splash->FadeIn(0);
+
937  splash->StopHold();
+
938  splash->FadeOut(0);
+
939  }
+
940 
+
941  if (splash->Done()) {
+
942  splash = 0; // this will get deleted along with gamewin
+
943  splash_index++;
+
944 
+
945  if (gamewin) {
+
946  screen->DelWindow(gamewin);
+
947  delete gamewin;
+
948  gamewin = 0;
+
949  }
+
950 
+
951  if (splash_index < 2) {
+
952  Ship::Initialize();
+
953  Galaxy::Initialize();
+
954  SetupSplash();
+
955  }
+
956  else {
+
957  CombatRoster::Initialize();
+
958  Campaign::Initialize();
+
959  SetupMenuScreen();
+
960  }
+
961 
+
962  FlushKeys();
+
963  }
+
964  }
+
965 
+
966  else if (game_mode == MENU_MODE) {
+
967  bool campaign_select = false;
+
968 
+
969  if (cmpnscreen) {
+
970  campaign_select = cmpnscreen->IsShown();
+
971  cmpnscreen->Hide();
+
972  }
+
973 
+
974  if (gamescreen)
+
975  gamescreen->Hide();
+
976 
+
977  if (planscreen)
+
978  planscreen->Hide();
+
979 
+
980  if (loadscreen)
+
981  loadscreen->Hide();
+
982 
+
983  if (!menuscreen) {
+
984  SetupMenuScreen();
+
985  }
+
986  else {
+
987  menuscreen->Show();
+
988 
+
989  if (campaign_select)
+
990  menuscreen->ShowCmpSelectDlg();
+
991  }
+
992 
+
993  if (MusicDirector::GetInstance() &&
+
994  MusicDirector::GetInstance()->GetMode() != MusicDirector::CREDITS)
+
995  MusicDirector::SetMode(MusicDirector::MENU);
+
996 
+
997  DoMenuScreenFrame();
+
998  }
+
999 
+
1000  else if (game_mode == CLOD_MODE ||
+
1001  game_mode == PREP_MODE ||
+
1002  game_mode == LOAD_MODE) {
+
1003  if (menuscreen)
+
1004  menuscreen->Hide();
+
1005 
+
1006  if (planscreen)
+
1007  planscreen->Hide();
+
1008 
+
1009  if (cmpnscreen)
+
1010  cmpnscreen->Hide();
+
1011 
+
1012  if (!loadscreen)
+
1013  SetupLoadScreen();
+
1014  else
+
1015  loadscreen->Show();
+
1016 
+
1017  if (game_mode == CLOD_MODE)
+
1018  MusicDirector::SetMode(MusicDirector::MENU);
+
1019  else
+
1020  MusicDirector::SetMode(MusicDirector::BRIEFING);
+
1021 
+
1022  DoLoadScreenFrame();
+
1023  }
+
1024 
+
1025  else if (game_mode == PLAN_MODE) {
+
1026  if (menuscreen)
+
1027  menuscreen->Hide();
+
1028 
+
1029  if (cmpnscreen)
+
1030  menuscreen->Hide();
+
1031 
+
1032  if (loadscreen)
+
1033  loadscreen->Hide();
+
1034 
+
1035  if (gamescreen)
+
1036  gamescreen->Hide();
+
1037 
+
1038  if (!planscreen)
+
1039  SetupPlanScreen();
+
1040  else
+
1041  planscreen->Show();
+
1042 
+
1043  Player* p = Player::GetCurrentPlayer();
+
1044  if (p && p->ShowAward()) {
+
1045  if (!planscreen->IsAwardShown())
+
1046  planscreen->ShowAwardDlg();
+
1047  }
+
1048 
+
1049  else if (ShipStats::NumStats()) {
+
1050  if (!planscreen->IsDebriefShown()) {
+
1051  planscreen->ShowDebriefDlg();
+
1052  show_missions = true;
+
1053  }
+
1054  }
+
1055 
+
1056  else {
+
1057  if (!planscreen->IsMsnShown() && !planscreen->IsNavShown())
+
1058  planscreen->ShowMsnDlg();
+
1059  }
+
1060 
+
1061  MusicDirector::SetMode(MusicDirector::BRIEFING);
1062 
-
1063  MusicDirector::SetMode(MusicDirector::BRIEFING);
-
1064 
-
1065  DoPlanScreenFrame();
-
1066  }
-
1067 
-
1068 
-
1069  else if (game_mode == CMPN_MODE) {
-
1070  if (menuscreen)
-
1071  menuscreen->Hide();
-
1072 
-
1073  if (planscreen)
-
1074  planscreen->Hide();
-
1075 
-
1076  if (loadscreen)
-
1077  loadscreen->Hide();
-
1078 
-
1079  if (gamescreen)
-
1080  gamescreen->Hide();
-
1081 
-
1082  if (!cmpnscreen)
-
1083  SetupCmpnScreen();
-
1084  else
-
1085  cmpnscreen->Show();
-
1086 
-
1087  DoCmpnScreenFrame();
-
1088  }
-
1089 
-
1090  else if (game_mode == PLAY_MODE) {
-
1091  if (menuscreen)
-
1092  menuscreen->Hide();
-
1093 
-
1094  if (cmpnscreen)
-
1095  cmpnscreen->Hide();
-
1096 
-
1097  if (planscreen)
-
1098  planscreen->Hide();
-
1099 
-
1100  if (loadscreen)
-
1101  loadscreen->Hide();
-
1102 
-
1103  if (!gamescreen)
-
1104  SetupGameScreen();
-
1105  else
-
1106  gamescreen->Show();
-
1107 
-
1108  DoGameScreenFrame();
-
1109  }
-
1110 
-
1111  if (game_mode == EXIT_MODE) {
-
1112  exit_time -= Game::GUITime();
-
1113 
-
1114  if (exit_time <= 0)
-
1115  Game::Exit();
-
1116  }
-
1117 
-
1118  if (net_lobby)
-
1119  net_lobby->ExecFrame();
-
1120 
-
1121  if (music_dir)
-
1122  music_dir->ExecFrame();
-
1123 
-
1124  Memory::Check();
-
1125 }
+
1063  DoPlanScreenFrame();
+
1064  }
+
1065 
+
1066 
+
1067  else if (game_mode == CMPN_MODE) {
+
1068  if (menuscreen)
+
1069  menuscreen->Hide();
+
1070 
+
1071  if (planscreen)
+
1072  planscreen->Hide();
+
1073 
+
1074  if (loadscreen)
+
1075  loadscreen->Hide();
+
1076 
+
1077  if (gamescreen)
+
1078  gamescreen->Hide();
+
1079 
+
1080  if (!cmpnscreen)
+
1081  SetupCmpnScreen();
+
1082  else
+
1083  cmpnscreen->Show();
+
1084 
+
1085  DoCmpnScreenFrame();
+
1086  }
+
1087 
+
1088  else if (game_mode == PLAY_MODE) {
+
1089  if (menuscreen)
+
1090  menuscreen->Hide();
+
1091 
+
1092  if (cmpnscreen)
+
1093  cmpnscreen->Hide();
+
1094 
+
1095  if (planscreen)
+
1096  planscreen->Hide();
+
1097 
+
1098  if (loadscreen)
+
1099  loadscreen->Hide();
+
1100 
+
1101  if (!gamescreen)
+
1102  SetupGameScreen();
+
1103  else
+
1104  gamescreen->Show();
+
1105 
+
1106  DoGameScreenFrame();
+
1107  }
+
1108 
+
1109  if (game_mode == EXIT_MODE) {
+
1110  exit_time -= Game::GUITime();
+
1111 
+
1112  if (exit_time <= 0)
+
1113  Game::Exit();
+
1114  }
+
1115 
+
1116  if (net_lobby)
+
1117  net_lobby->ExecFrame();
+
1118 
+
1119  if (music_dir)
+
1120  music_dir->ExecFrame();
+
1121 
+
1122  Memory::Check();
+
1123 }
+
1124 
+
1125 // +--------------------------------------------------------------------+
1126 
-
1127 // +--------------------------------------------------------------------+
-
1128 
-
1129 void
-
1130 Starshatter::DoMenuScreenFrame()
-
1131 {
-
1132  if (!Mouse::RButton()) {
-
1133  Mouse::SetCursor(Mouse::ARROW);
-
1134  Mouse::Show(true);
-
1135  }
-
1136 
-
1137  if (time_til_change > 0)
-
1138  time_til_change -= Game::GUITime();
-
1139 
-
1140  if (!menuscreen)
-
1141  return;
-
1142 
-
1143  if (KeyDown(KEY_EXIT)) {
-
1144  if (time_til_change <= 0) {
-
1145  time_til_change = 0.5;
-
1146 
-
1147  if (!exit_latch && !menuscreen->CloseTopmost()) {
-
1148  menuscreen->ShowExitDlg();
-
1149  }
-
1150  }
-
1151 
-
1152  exit_latch = true;
-
1153  }
-
1154  else {
-
1155  exit_latch = false;
-
1156  }
+
1127 void
+
1128 Starshatter::DoMenuScreenFrame()
+
1129 {
+
1130  if (!Mouse::RButton()) {
+
1131  Mouse::SetCursor(Mouse::ARROW);
+
1132  Mouse::Show(true);
+
1133  }
+
1134 
+
1135  if (time_til_change > 0)
+
1136  time_til_change -= Game::GUITime();
+
1137 
+
1138  if (!menuscreen)
+
1139  return;
+
1140 
+
1141  if (KeyDown(KEY_EXIT)) {
+
1142  if (time_til_change <= 0) {
+
1143  time_til_change = 0.5;
+
1144 
+
1145  if (!exit_latch && !menuscreen->CloseTopmost()) {
+
1146  menuscreen->ShowExitDlg();
+
1147  }
+
1148  }
+
1149 
+
1150  exit_latch = true;
+
1151  }
+
1152  else {
+
1153  exit_latch = false;
+
1154  }
+
1155 
+
1156  LoadDlg* load_dlg = menuscreen->GetLoadDlg();
1157 
-
1158  LoadDlg* load_dlg = menuscreen->GetLoadDlg();
-
1159 
-
1160  if (load_dlg && load_dlg->IsShown()) {
-
1161  // load all ship designs in the standard catalog
-
1162  if (catalog_index < ShipDesign::StandardCatalogSize()) {
-
1163  ShipDesign::PreloadCatalog(catalog_index++);
-
1164  load_activity = Game::GetText("Starshatter.load.tac-ref");
-
1165 
-
1166  if (load_progress < 95)
-
1167  load_progress++;
-
1168  }
-
1169 
-
1170  else {
-
1171  menuscreen->ShowTacRefDlg();
-
1172  }
-
1173  }
-
1174 
-
1175  if (show_missions) {
-
1176  if (net_lobby)
-
1177  menuscreen->ShowNetLobbyDlg();
-
1178  else
-
1179  menuscreen->ShowMsnSelectDlg();
-
1180 
-
1181  show_missions = false;
-
1182  }
+
1158  if (load_dlg && load_dlg->IsShown()) {
+
1159  // load all ship designs in the standard catalog
+
1160  if (catalog_index < ShipDesign::StandardCatalogSize()) {
+
1161  ShipDesign::PreloadCatalog(catalog_index++);
+
1162  load_activity = Game::GetText("Starshatter.load.tac-ref");
+
1163 
+
1164  if (load_progress < 95)
+
1165  load_progress++;
+
1166  }
+
1167 
+
1168  else {
+
1169  menuscreen->ShowTacRefDlg();
+
1170  }
+
1171  }
+
1172 
+
1173  if (show_missions) {
+
1174  if (net_lobby)
+
1175  menuscreen->ShowNetLobbyDlg();
+
1176  else
+
1177  menuscreen->ShowMsnSelectDlg();
+
1178 
+
1179  show_missions = false;
+
1180  }
+
1181 
+
1182  menuscreen->ExecFrame();
1183 
-
1184  menuscreen->ExecFrame();
-
1185 
-
1186  if (req_change_video) {
-
1187  ChangeVideo();
-
1188  SetupMenuScreen();
-
1189  }
-
1190 }
+
1184  if (req_change_video) {
+
1185  ChangeVideo();
+
1186  SetupMenuScreen();
+
1187  }
+
1188 }
+
1189 
+
1190 // +--------------------------------------------------------------------+
1191 
-
1192 // +--------------------------------------------------------------------+
-
1193 
-
1194 void
-
1195 Starshatter::DoPlanScreenFrame()
-
1196 {
-
1197  Mouse::SetCursor(Mouse::ARROW);
-
1198 
-
1199  if (time_til_change > 0)
-
1200  time_til_change -= Game::GUITime();
-
1201 
-
1202  if (KeyDown(KEY_EXIT)) {
-
1203  if (time_til_change <= 0) {
-
1204  time_til_change = 1;
-
1205 
-
1206  if (!exit_latch && !planscreen->CloseTopmost()) {
-
1207  Campaign* campaign = Campaign::GetCampaign();
-
1208  if (campaign && (campaign->IsDynamic() || campaign->IsTraining()))
-
1209  SetGameMode(CMPN_MODE);
-
1210  else
-
1211  SetGameMode(MENU_MODE);
-
1212  }
-
1213  }
-
1214 
-
1215  exit_latch = true;
-
1216  }
-
1217  else {
-
1218  exit_latch = false;
-
1219  }
-
1220 
-
1221  planscreen->ExecFrame();
-
1222  show_missions = true;
-
1223 }
+
1192 void
+
1193 Starshatter::DoPlanScreenFrame()
+
1194 {
+
1195  Mouse::SetCursor(Mouse::ARROW);
+
1196 
+
1197  if (time_til_change > 0)
+
1198  time_til_change -= Game::GUITime();
+
1199 
+
1200  if (KeyDown(KEY_EXIT)) {
+
1201  if (time_til_change <= 0) {
+
1202  time_til_change = 1;
+
1203 
+
1204  if (!exit_latch && !planscreen->CloseTopmost()) {
+
1205  Campaign* campaign = Campaign::GetCampaign();
+
1206  if (campaign && (campaign->IsDynamic() || campaign->IsTraining()))
+
1207  SetGameMode(CMPN_MODE);
+
1208  else
+
1209  SetGameMode(MENU_MODE);
+
1210  }
+
1211  }
+
1212 
+
1213  exit_latch = true;
+
1214  }
+
1215  else {
+
1216  exit_latch = false;
+
1217  }
+
1218 
+
1219  planscreen->ExecFrame();
+
1220  show_missions = true;
+
1221 }
+
1222 
+
1223 // +--------------------------------------------------------------------+
1224 
-
1225 // +--------------------------------------------------------------------+
-
1226 
-
1227 void
-
1228 Starshatter::DoCmpnScreenFrame()
-
1229 {
-
1230  Mouse::SetCursor(Mouse::ARROW);
-
1231 
-
1232  if (time_til_change > 0)
-
1233  time_til_change -= Game::GUITime();
+
1225 void
+
1226 Starshatter::DoCmpnScreenFrame()
+
1227 {
+
1228  Mouse::SetCursor(Mouse::ARROW);
+
1229 
+
1230  if (time_til_change > 0)
+
1231  time_til_change -= Game::GUITime();
+
1232 
+
1233  exit_latch = KeyDown(KEY_EXIT) ? true : false;
1234 
-
1235  exit_latch = KeyDown(KEY_EXIT) ? true : false;
-
1236 
-
1237  if (InCutscene() && player_ship) {
-
1238  // warp effect:
-
1239  if (player_ship->WarpFactor() > 1) {
-
1240  if (player_ship->WarpFactor() > field_of_view)
-
1241  cmpnscreen->SetFieldOfView(player_ship->WarpFactor());
-
1242  else
-
1243  cmpnscreen->SetFieldOfView(field_of_view);
-
1244  }
-
1245 
-
1246  else {
-
1247  if (cmpnscreen->GetFieldOfView() != field_of_view)
-
1248  cmpnscreen->SetFieldOfView(field_of_view);
-
1249  }
-
1250  }
-
1251 
-
1252  if (InCutscene() && exit_latch) {
-
1253  time_til_change = 1;
-
1254  EndCutscene();
-
1255  EndMission();
-
1256  cmpnscreen->SetFieldOfView(field_of_view);
-
1257  }
-
1258 
-
1259  else if (time_til_change <= 0 && exit_latch) {
-
1260  time_til_change = 1;
-
1261 
-
1262  if (!cmpnscreen || !cmpnscreen->CloseTopmost()) {
-
1263  SetGameMode(MENU_MODE);
-
1264  }
-
1265  }
-
1266 
-
1267  // time control for campaign mode:
-
1268  else if (game_mode == CMPN_MODE) {
-
1269  if (time_til_change <= 0) {
-
1270  if (KeyDown(KEY_PAUSE)) {
-
1271  time_til_change = 1;
-
1272  Pause(!paused);
-
1273  }
-
1274 
-
1275  else if (KeyDown(KEY_TIME_COMPRESS)) {
-
1276  time_til_change = 1;
-
1277 
-
1278  switch (TimeCompression()) {
-
1279  case 1: SetTimeCompression(2); break;
-
1280  case 2: SetTimeCompression(4); break;
-
1281  case 4: SetTimeCompression(8); break;
-
1282  }
-
1283  }
-
1284 
-
1285  else if (KeyDown(KEY_TIME_EXPAND)) {
-
1286  time_til_change = 1;
-
1287 
-
1288  switch (TimeCompression()) {
-
1289  case 8: SetTimeCompression( 4); break;
-
1290  case 4: SetTimeCompression( 2); break;
-
1291  default: SetTimeCompression( 1); break;
-
1292  }
-
1293  }
-
1294  }
-
1295  }
-
1296 
-
1297  if (show_missions && !InCutscene()) {
-
1298  cmpnscreen->ShowCmdMissionsDlg();
-
1299  show_missions = false;
-
1300  }
-
1301 
-
1302  cmpnscreen->ExecFrame();
-
1303 }
+
1235  if (InCutscene() && player_ship) {
+
1236  // warp effect:
+
1237  if (player_ship->WarpFactor() > 1) {
+
1238  if (player_ship->WarpFactor() > field_of_view)
+
1239  cmpnscreen->SetFieldOfView(player_ship->WarpFactor());
+
1240  else
+
1241  cmpnscreen->SetFieldOfView(field_of_view);
+
1242  }
+
1243 
+
1244  else {
+
1245  if (cmpnscreen->GetFieldOfView() != field_of_view)
+
1246  cmpnscreen->SetFieldOfView(field_of_view);
+
1247  }
+
1248  }
+
1249 
+
1250  if (InCutscene() && exit_latch) {
+
1251  time_til_change = 1;
+
1252  EndCutscene();
+
1253  EndMission();
+
1254  cmpnscreen->SetFieldOfView(field_of_view);
+
1255  }
+
1256 
+
1257  else if (time_til_change <= 0 && exit_latch) {
+
1258  time_til_change = 1;
+
1259 
+
1260  if (!cmpnscreen || !cmpnscreen->CloseTopmost()) {
+
1261  SetGameMode(MENU_MODE);
+
1262  }
+
1263  }
+
1264 
+
1265  // time control for campaign mode:
+
1266  else if (game_mode == CMPN_MODE) {
+
1267  if (time_til_change <= 0) {
+
1268  if (KeyDown(KEY_PAUSE)) {
+
1269  time_til_change = 1;
+
1270  Pause(!paused);
+
1271  }
+
1272 
+
1273  else if (KeyDown(KEY_TIME_COMPRESS)) {
+
1274  time_til_change = 1;
+
1275 
+
1276  switch (TimeCompression()) {
+
1277  case 1: SetTimeCompression(2); break;
+
1278  case 2: SetTimeCompression(4); break;
+
1279  case 4: SetTimeCompression(8); break;
+
1280  }
+
1281  }
+
1282 
+
1283  else if (KeyDown(KEY_TIME_EXPAND)) {
+
1284  time_til_change = 1;
+
1285 
+
1286  switch (TimeCompression()) {
+
1287  case 8: SetTimeCompression( 4); break;
+
1288  case 4: SetTimeCompression( 2); break;
+
1289  default: SetTimeCompression( 1); break;
+
1290  }
+
1291  }
+
1292  }
+
1293  }
+
1294 
+
1295  if (show_missions && !InCutscene()) {
+
1296  cmpnscreen->ShowCmdMissionsDlg();
+
1297  show_missions = false;
+
1298  }
+
1299 
+
1300  cmpnscreen->ExecFrame();
+
1301 }
+
1302 
+
1303 // +--------------------------------------------------------------------+
1304 
-
1305 // +--------------------------------------------------------------------+
-
1306 
-
1307 void
-
1308 Starshatter::DoLoadScreenFrame()
-
1309 {
-
1310  Mouse::Show(false);
-
1311  Mouse::SetCursor(Mouse::ARROW);
-
1312 
-
1313  if (game_mode == CLOD_MODE) {
-
1314  CmpLoadDlg* dlg = loadscreen->GetCmpLoadDlg();
-
1315 
-
1316  switch (load_step) {
-
1317  case 0:
-
1318  load_activity = Game::GetText("Starshatter.load.campaign");
-
1319  load_progress = 1;
-
1320  catalog_index = 0;
-
1321  break;
-
1322 
-
1323  case 1:
-
1324  // load all ship designs in the standard catalog
-
1325  if (catalog_index < ShipDesign::StandardCatalogSize()) {
-
1326  ShipDesign::PreloadCatalog(catalog_index++);
-
1327  load_activity = Game::GetText("Starshatter.load.campaign");
-
1328 
-
1329  if (load_progress < 80)
-
1330  load_progress++;
-
1331 
-
1332  load_step = 0; // force return to current step on next frame
-
1333  }
-
1334  else {
-
1335  load_activity = Game::GetText("Starshatter.load.start");
-
1336  load_progress = 80;
-
1337  }
-
1338  break;
-
1339 
-
1340  case 2:
-
1341  if (Campaign::GetCampaign())
-
1342  Campaign::GetCampaign()->Start();
-
1343  break;
-
1344 
-
1345  default:
-
1346  if (dlg && load_progress < 100) {
-
1347  load_progress++;
-
1348  }
-
1349  else {
-
1350  load_activity = Game::GetText("Starshatter.load.ready");
-
1351  load_progress = 100;
-
1352  SetGameMode(CMPN_MODE);
-
1353  }
-
1354  break;
-
1355  }
-
1356  }
-
1357  else {
-
1358  switch (load_step) {
-
1359  case 0:
-
1360  load_activity = Game::GetText("Starshatter.load.drives");
-
1361  load_progress = 0;
-
1362  break;
-
1363 
-
1364  case 1:
-
1365  Drive::Initialize();
-
1366  LandingGear::Initialize();
-
1367  load_activity = Game::GetText("Starshatter.load.explosions");
-
1368  load_progress = 5;
-
1369  break;
-
1370 
-
1371  case 2:
-
1372  Explosion::Initialize();
-
1373  load_activity = Game::GetText("Starshatter.load.systems");
-
1374  load_progress = 10;
-
1375  break;
-
1376 
-
1377  case 3:
-
1378  FlightDeck::Initialize();
-
1379  NavLight::Initialize();
-
1380  load_activity = Game::GetText("Starshatter.load.ships");
-
1381  load_progress = 15;
-
1382  break;
-
1383 
-
1384  case 4:
-
1385  Ship::Initialize();
-
1386  Shot::Initialize();
-
1387  load_activity = Game::GetText("Starshatter.load.hud");
-
1388  load_progress = 20;
-
1389  break;
-
1390 
-
1391  case 5:
-
1392  MFD::Initialize();
-
1393  load_activity = Game::GetText("Starshatter.load.menus");
-
1394  load_progress = 25;
-
1395  break;
-
1396 
-
1397  case 6:
-
1398  RadioTraffic::Initialize();
-
1399  RadioView::Initialize();
-
1400  TacticalView::Initialize();
-
1401 
-
1402  if (!gamescreen && game_mode != PREP_MODE)
-
1403  SetupGameScreen();
-
1404 
-
1405  load_activity = Game::GetText("Starshatter.load.mission");
-
1406  load_progress = 65;
-
1407  break;
-
1408 
-
1409  case 7:
-
1410  if (game_mode == PREP_MODE) {
-
1411  if (Campaign::GetCampaign())
-
1412  Campaign::GetCampaign()->GetMission();
-
1413  SetGameMode(PLAN_MODE);
-
1414  load_activity = Game::GetText("Starshatter.load.loaded");
-
1415  load_progress = 100;
-
1416  Button::PlaySound(4);
-
1417  }
-
1418  else {
-
1419  CreateWorld();
-
1420  load_activity = Game::GetText("Starshatter.load.simulation");
-
1421  load_progress = 75;
-
1422  }
-
1423  break;
-
1424 
-
1425  case 8:
-
1426  InstantiateMission();
-
1427  load_activity = Game::GetText("Starshatter.load.viewscreen");
-
1428  load_progress = 90;
-
1429  break;
-
1430 
-
1431  default:
-
1432  SetGameMode(PLAY_MODE);
-
1433  load_activity = Game::GetText("Starshatter.load.ready");
-
1434  load_progress = 100;
-
1435  break;
-
1436  }
-
1437  }
-
1438 
-
1439  load_step++;
-
1440  loadscreen->ExecFrame();
-
1441 }
+
1305 void
+
1306 Starshatter::DoLoadScreenFrame()
+
1307 {
+
1308  Mouse::Show(false);
+
1309  Mouse::SetCursor(Mouse::ARROW);
+
1310 
+
1311  if (game_mode == CLOD_MODE) {
+
1312  CmpLoadDlg* dlg = loadscreen->GetCmpLoadDlg();
+
1313 
+
1314  switch (load_step) {
+
1315  case 0:
+
1316  load_activity = Game::GetText("Starshatter.load.campaign");
+
1317  load_progress = 1;
+
1318  catalog_index = 0;
+
1319  break;
+
1320 
+
1321  case 1:
+
1322  // load all ship designs in the standard catalog
+
1323  if (catalog_index < ShipDesign::StandardCatalogSize()) {
+
1324  ShipDesign::PreloadCatalog(catalog_index++);
+
1325  load_activity = Game::GetText("Starshatter.load.campaign");
+
1326 
+
1327  if (load_progress < 80)
+
1328  load_progress++;
+
1329 
+
1330  load_step = 0; // force return to current step on next frame
+
1331  }
+
1332  else {
+
1333  load_activity = Game::GetText("Starshatter.load.start");
+
1334  load_progress = 80;
+
1335  }
+
1336  break;
+
1337 
+
1338  case 2:
+
1339  if (Campaign::GetCampaign())
+
1340  Campaign::GetCampaign()->Start();
+
1341  break;
+
1342 
+
1343  default:
+
1344  if (dlg && load_progress < 100) {
+
1345  load_progress++;
+
1346  }
+
1347  else {
+
1348  load_activity = Game::GetText("Starshatter.load.ready");
+
1349  load_progress = 100;
+
1350  SetGameMode(CMPN_MODE);
+
1351  }
+
1352  break;
+
1353  }
+
1354  }
+
1355  else {
+
1356  switch (load_step) {
+
1357  case 0:
+
1358  load_activity = Game::GetText("Starshatter.load.drives");
+
1359  load_progress = 0;
+
1360  break;
+
1361 
+
1362  case 1:
+
1363  Drive::Initialize();
+
1364  LandingGear::Initialize();
+
1365  load_activity = Game::GetText("Starshatter.load.explosions");
+
1366  load_progress = 5;
+
1367  break;
+
1368 
+
1369  case 2:
+
1370  Explosion::Initialize();
+
1371  load_activity = Game::GetText("Starshatter.load.systems");
+
1372  load_progress = 10;
+
1373  break;
+
1374 
+
1375  case 3:
+
1376  FlightDeck::Initialize();
+
1377  NavLight::Initialize();
+
1378  load_activity = Game::GetText("Starshatter.load.ships");
+
1379  load_progress = 15;
+
1380  break;
+
1381 
+
1382  case 4:
+
1383  Ship::Initialize();
+
1384  Shot::Initialize();
+
1385  load_activity = Game::GetText("Starshatter.load.hud");
+
1386  load_progress = 20;
+
1387  break;
+
1388 
+
1389  case 5:
+
1390  MFD::Initialize();
+
1391  load_activity = Game::GetText("Starshatter.load.menus");
+
1392  load_progress = 25;
+
1393  break;
+
1394 
+
1395  case 6:
+
1396  RadioTraffic::Initialize();
+
1397  RadioView::Initialize();
+
1398  TacticalView::Initialize();
+
1399 
+
1400  if (!gamescreen && game_mode != PREP_MODE)
+
1401  SetupGameScreen();
+
1402 
+
1403  load_activity = Game::GetText("Starshatter.load.mission");
+
1404  load_progress = 65;
+
1405  break;
+
1406 
+
1407  case 7:
+
1408  if (game_mode == PREP_MODE) {
+
1409  if (Campaign::GetCampaign())
+
1410  Campaign::GetCampaign()->GetMission();
+
1411  SetGameMode(PLAN_MODE);
+
1412  load_activity = Game::GetText("Starshatter.load.loaded");
+
1413  load_progress = 100;
+
1414  Button::PlaySound(4);
+
1415  }
+
1416  else {
+
1417  CreateWorld();
+
1418  load_activity = Game::GetText("Starshatter.load.simulation");
+
1419  load_progress = 75;
+
1420  }
+
1421  break;
+
1422 
+
1423  case 8:
+
1424  InstantiateMission();
+
1425  load_activity = Game::GetText("Starshatter.load.viewscreen");
+
1426  load_progress = 90;
+
1427  break;
+
1428 
+
1429  default:
+
1430  SetGameMode(PLAY_MODE);
+
1431  load_activity = Game::GetText("Starshatter.load.ready");
+
1432  load_progress = 100;
+
1433  break;
+
1434  }
+
1435  }
+
1436 
+
1437  load_step++;
+
1438  loadscreen->ExecFrame();
+
1439 }
+
1440 
+
1441 // +--------------------------------------------------------------------+
1442 
-
1443 // +--------------------------------------------------------------------+
-
1444 
-
1445 void
-
1446 Starshatter::PlayerCam(int mode)
-
1447 {
-
1448  if (player_ship && !player_ship->InTransition() && player_ship->GetFlightPhase() >= Ship::LOCKED) {
-
1449  gamescreen->CloseTopmost();
-
1450  if (mode == CameraDirector::MODE_DROP) {
-
1451  player_ship->DropCam(15, 0);
-
1452  cam_dir->SetShip(player_ship);
-
1453  cam_dir->SetMode(CameraDirector::MODE_DROP, 0);
-
1454  }
-
1455 
-
1456  else {
-
1457  cam_dir->SetMode(mode);
-
1458 
-
1459  if (mode == CameraDirector::MODE_ORBIT) {
-
1460  MouseController* mouse_con = MouseController::GetInstance();
-
1461  if (mouse_con)
-
1462  mouse_con->SetActive(false);
-
1463  }
-
1464  }
-
1465  }
-
1466 }
-
1467 
-
1468 void
-
1469 Starshatter::ViewSelection()
-
1470 {
-
1471  Sim* sim = (Sim*) world;
-
1472  List<Ship>& seln = sim->GetSelection().container();
-
1473 
-
1474  if (cam_dir) {
-
1475  if (seln.isEmpty())
-
1476  cam_dir->SetViewObject(player_ship);
-
1477 
-
1478  else if (seln.size() == 1)
-
1479  cam_dir->SetViewObject(seln[0]);
-
1480 
-
1481  else
-
1482  cam_dir->SetViewObjectGroup(seln);
-
1483  }
-
1484 }
+
1443 void
+
1444 Starshatter::PlayerCam(int mode)
+
1445 {
+
1446  if (player_ship && !player_ship->InTransition() && player_ship->GetFlightPhase() >= Ship::LOCKED) {
+
1447  gamescreen->CloseTopmost();
+
1448  if (mode == CameraDirector::MODE_DROP) {
+
1449  player_ship->DropCam(15, 0);
+
1450  cam_dir->SetShip(player_ship);
+
1451  cam_dir->SetMode(CameraDirector::MODE_DROP, 0);
+
1452  }
+
1453 
+
1454  else {
+
1455  cam_dir->SetMode(mode);
+
1456 
+
1457  if (mode == CameraDirector::MODE_ORBIT) {
+
1458  MouseController* mouse_con = MouseController::GetInstance();
+
1459  if (mouse_con)
+
1460  mouse_con->SetActive(false);
+
1461  }
+
1462  }
+
1463  }
+
1464 }
+
1465 
+
1466 void
+
1467 Starshatter::ViewSelection()
+
1468 {
+
1469  Sim* sim = (Sim*) world;
+
1470  List<Ship>& seln = sim->GetSelection().container();
+
1471 
+
1472  if (cam_dir) {
+
1473  if (seln.isEmpty())
+
1474  cam_dir->SetViewObject(player_ship);
+
1475 
+
1476  else if (seln.size() == 1)
+
1477  cam_dir->SetViewObject(seln[0]);
+
1478 
+
1479  else
+
1480  cam_dir->SetViewObjectGroup(seln);
+
1481  }
+
1482 }
+
1483 
+
1484 // +--------------------------------------------------------------------+
1485 
-
1486 // +--------------------------------------------------------------------+
-
1487 
-
1488 void
-
1489 Starshatter::DoGameScreenFrame()
-
1490 {
-
1491  Sim* sim = (Sim*) world;
-
1492 
-
1493  if (!gamescreen || !sim)
-
1494  return;
-
1495 
-
1496  if (InCutscene()) {
-
1497  if (player_ship) {
-
1498  // warp effect:
-
1499  if (player_ship->WarpFactor() > 1) {
-
1500  if (player_ship->WarpFactor() > field_of_view)
-
1501  gamescreen->SetFieldOfView(player_ship->WarpFactor());
-
1502  else
-
1503  gamescreen->SetFieldOfView(field_of_view);
-
1504  }
-
1505 
-
1506  else {
-
1507  if (gamescreen->GetFieldOfView() != field_of_view)
-
1508  gamescreen->SetFieldOfView(field_of_view);
-
1509  }
-
1510  }
-
1511 
-
1512  gamescreen->FrameRate(frame_rate);
-
1513  gamescreen->ExecFrame();
-
1514 
-
1515  if (KeyDown(KEY_EXIT)) {
-
1516  gamescreen->SetFieldOfView(field_of_view);
-
1517  exit_latch = true;
-
1518  time_til_change = 1;
-
1519 
-
1520  sim->SkipCutscene();
-
1521  }
-
1522 
-
1523  return;
-
1524  }
-
1525 
-
1526  if (time_til_change > 0)
-
1527  time_til_change -= Game::GUITime();
-
1528 
-
1529  if (exit_latch && !KeyDown(KEY_EXIT))
-
1530  exit_latch = false;
+
1486 void
+
1487 Starshatter::DoGameScreenFrame()
+
1488 {
+
1489  Sim* sim = (Sim*) world;
+
1490 
+
1491  if (!gamescreen || !sim)
+
1492  return;
+
1493 
+
1494  if (InCutscene()) {
+
1495  if (player_ship) {
+
1496  // warp effect:
+
1497  if (player_ship->WarpFactor() > 1) {
+
1498  if (player_ship->WarpFactor() > field_of_view)
+
1499  gamescreen->SetFieldOfView(player_ship->WarpFactor());
+
1500  else
+
1501  gamescreen->SetFieldOfView(field_of_view);
+
1502  }
+
1503 
+
1504  else {
+
1505  if (gamescreen->GetFieldOfView() != field_of_view)
+
1506  gamescreen->SetFieldOfView(field_of_view);
+
1507  }
+
1508  }
+
1509 
+
1510  gamescreen->FrameRate(frame_rate);
+
1511  gamescreen->ExecFrame();
+
1512 
+
1513  if (KeyDown(KEY_EXIT)) {
+
1514  gamescreen->SetFieldOfView(field_of_view);
+
1515  exit_latch = true;
+
1516  time_til_change = 1;
+
1517 
+
1518  sim->SkipCutscene();
+
1519  }
+
1520 
+
1521  return;
+
1522  }
+
1523 
+
1524  if (time_til_change > 0)
+
1525  time_til_change -= Game::GUITime();
+
1526 
+
1527  if (exit_latch && !KeyDown(KEY_EXIT))
+
1528  exit_latch = false;
+
1529 
+
1530  DoMouseFrame();
1531 
-
1532  DoMouseFrame();
+
1532  HUDView* hud_view = HUDView::GetInstance();
1533 
-
1534  HUDView* hud_view = HUDView::GetInstance();
-
1535 
-
1536  // changing to a new ship?
-
1537  if (player_ship != sim->GetPlayerShip()) {
-
1538  gamescreen->HideNavDlg();
-
1539  gamescreen->HideFltDlg();
-
1540  gamescreen->HideEngDlg();
+
1534  // changing to a new ship?
+
1535  if (player_ship != sim->GetPlayerShip()) {
+
1536  gamescreen->HideNavDlg();
+
1537  gamescreen->HideFltDlg();
+
1538  gamescreen->HideEngDlg();
+
1539 
+
1540  Ship* new_player = sim->GetPlayerShip();
1541 
-
1542  Ship* new_player = sim->GetPlayerShip();
-
1543 
-
1544  if (new_player) {
-
1545  if (new_player->IsDropship() && Ship::GetFlightModel() < 2 && Ship::GetControlModel() < 1)
-
1546  input->SwapYawRoll(true);
-
1547  else
-
1548  input->SwapYawRoll(false);
-
1549 
-
1550  if (hud_view) {
-
1551  hud_view->SetHUDMode(HUDView::HUD_MODE_TAC);
-
1552  hud_view->HideHUDWarn();
-
1553  }
-
1554  }
-
1555  }
-
1556 
-
1557  player_ship = sim->GetPlayerShip();
-
1558 
-
1559  if (player_ship) {
-
1560  // warp effect:
-
1561  if (player_ship->WarpFactor() > 1) {
-
1562  if (player_ship->WarpFactor() > field_of_view)
-
1563  gamescreen->SetFieldOfView(player_ship->WarpFactor());
-
1564  else
-
1565  gamescreen->SetFieldOfView(field_of_view);
-
1566  }
-
1567 
-
1568  else {
-
1569  if (gamescreen->GetFieldOfView() != field_of_view)
-
1570  gamescreen->SetFieldOfView(field_of_view);
-
1571  }
-
1572 
-
1573  gamescreen->ShowExternal();
-
1574 
-
1575  if (CameraDirector::GetCameraMode() >= CameraDirector::MODE_ORBIT && !player_ship->InTransition())
-
1576  tactical = true;
-
1577  else
-
1578  tactical = false;
-
1579 
-
1580  if (player_ship->InTransition())
-
1581  gamescreen->CloseTopmost();
-
1582  }
-
1583 
-
1584  if (chat_mode) {
-
1585  DoChatMode();
-
1586  }
-
1587 
-
1588  else {
-
1589  DoGameKeys();
-
1590  }
-
1591 
-
1592  gamescreen->FrameRate(frame_rate);
-
1593  gamescreen->ExecFrame();
-
1594 
-
1595  if (Game::GameTime() - time_mark > 60000) {
-
1596  time_mark = Game::GameTime();
-
1597  minutes++;
-
1598  if (minutes > 60)
-
1599  Print(" TIME %2d:%02d:00\n", minutes/60, minutes%60);
-
1600  else
-
1601  Print(" TIME %2d:00\n", minutes);
-
1602  }
-
1603 }
-
1604 
-
1605 void
-
1606 Starshatter::DoGameKeys()
-
1607 {
-
1608  Sim* sim = (Sim*) world;
-
1609  HUDView* hud_view = HUDView::GetInstance();
-
1610 
-
1611  if (time_til_change <= 0) {
-
1612  if (KeyDown(KEY_CAM_BRIDGE)) {
-
1613  PlayerCam(CameraDirector::MODE_COCKPIT);
-
1614  time_til_change = 0.5;
-
1615  }
-
1616 
-
1617  else if (KeyDown(KEY_CAM_VIRT)) {
-
1618  PlayerCam(CameraDirector::MODE_VIRTUAL);
-
1619  time_til_change = 0.5;
-
1620  }
-
1621 
-
1622  else if (KeyDown(KEY_CAM_CHASE)) {
-
1623  PlayerCam(CameraDirector::MODE_CHASE);
-
1624  time_til_change = 0.5;
-
1625  }
-
1626 
-
1627  else if (KeyDown(KEY_CAM_DROP)) {
-
1628  PlayerCam(CameraDirector::MODE_DROP);
-
1629  time_til_change = 0.5;
-
1630  }
-
1631 
-
1632  else if (KeyDown(KEY_CAM_EXTERN)) {
-
1633  PlayerCam(CameraDirector::MODE_ORBIT);
-
1634  time_til_change = 0.5;
-
1635  }
-
1636 
-
1637  else if (KeyDown(KEY_TARGET_PADLOCK)) {
-
1638  PlayerCam(CameraDirector::MODE_TARGET);
-
1639  time_til_change = 0.5;
-
1640  }
-
1641 
-
1642  else if (KeyDown(KEY_SWAP_ROLL_YAW)) {
-
1643  input->SwapYawRoll(!input->GetSwapYawRoll());
-
1644  time_til_change = 0.5;
-
1645  }
-
1646 
-
1647  else if (KeyDown(KEY_ZOOM_WIDE)) {
-
1648  time_til_change = 0.5;
-
1649  if (gamescreen->GetFieldOfView() <= 2)
-
1650  field_of_view = 3; // wide
-
1651  else
-
1652  field_of_view = 2; // normal
-
1653 
-
1654  // don't mess with fov during warp:
-
1655  if (player_ship && player_ship->WarpFactor() <= 1)
-
1656  gamescreen->SetFieldOfView(field_of_view);
-
1657  }
-
1658 
-
1659  else if (!exit_latch && KeyDown(KEY_EXIT)) {
-
1660  exit_latch = true;
-
1661  time_til_change = 0.5;
-
1662 
-
1663  if (!gamescreen->CloseTopmost()) {
-
1664  QuitView* quit = QuitView::GetInstance();
-
1665  if (quit)
-
1666  quit->ShowMenu();
-
1667  else
-
1668  SetGameMode(Starshatter::PLAN_MODE);
-
1669  }
-
1670  }
-
1671 
-
1672  else if (KeyDown(KEY_PAUSE)) {
-
1673  Pause(!paused);
-
1674  time_til_change = 0.5;
-
1675  }
-
1676 
-
1677 
-
1678  else if (KeyDown(KEY_TIME_COMPRESS)) {
-
1679  time_til_change = 0.5;
-
1680  if (NetGame::IsNetGame())
-
1681  SetTimeCompression(1);
-
1682  else
-
1683  switch (TimeCompression()) {
-
1684  case 1: SetTimeCompression(2); break;
-
1685  default: SetTimeCompression(4); break;
-
1686  }
-
1687  }
-
1688 
-
1689  else if (KeyDown(KEY_TIME_EXPAND)) {
-
1690  time_til_change = 0.5;
-
1691 
-
1692  if (NetGame::IsNetGame())
-
1693  SetTimeCompression(1);
-
1694  else
-
1695  switch (TimeCompression()) {
-
1696  case 4: SetTimeCompression( 2); break;
-
1697  default: SetTimeCompression( 1); break;
-
1698  }
-
1699  }
-
1700 
-
1701  else if (KeyDown(KEY_TIME_SKIP)) {
-
1702  time_til_change = 0.5;
-
1703 
-
1704  if (player_ship && !NetGame::IsNetGame()) {
-
1705  player_ship->TimeSkip();
-
1706  }
-
1707  }
-
1708 
-
1709  else if (KeyDown(KEY_COMMAND_MODE)) {
-
1710  if (player_ship) {
-
1711  time_til_change = 0.5;
-
1712  player_ship->CommandMode();
-
1713  }
-
1714  }
-
1715 
-
1716  /*** For Debug Convenience Only: ***/
-
1717  else if (KeyDown(KEY_INC_STARDATE)) {
-
1718  StarSystem::SetBaseTime(StarSystem::GetBaseTime() + 600, true);
-
1719  }
-
1720 
-
1721  else if (KeyDown(KEY_DEC_STARDATE)) {
-
1722  StarSystem::SetBaseTime(StarSystem::GetBaseTime() - 600, true);
-
1723  }
-
1724  /***/
-
1725  }
-
1726 
-
1727  if (gamescreen && time_til_change <= 0) {
-
1728  if (KeyDown(KEY_MFD1)) {
-
1729  gamescreen->CycleMFDMode(0);
-
1730  time_til_change = 0.5;
-
1731  }
-
1732 
-
1733  else if (KeyDown(KEY_MFD2)) {
-
1734  gamescreen->CycleMFDMode(1);
-
1735  time_til_change = 0.5;
-
1736  }
-
1737 
-
1738  else if (KeyDown(KEY_MFD3)) {
-
1739  gamescreen->CycleMFDMode(2);
-
1740  time_til_change = 0.5;
-
1741  }
-
1742 
-
1743  else if (KeyDown(KEY_MFD4)) {
-
1744  gamescreen->CycleMFDMode(3);
-
1745  time_til_change = 0.5;
-
1746  }
-
1747 
-
1748  else if (KeyDown(KEY_RADIO_MENU)) {
-
1749  RadioView* radio_view = RadioView::GetInstance();
-
1750  if (radio_view) {
-
1751  if (radio_view->IsMenuShown())
-
1752  radio_view->CloseMenu();
-
1753  else
-
1754  radio_view->ShowMenu();
-
1755  }
-
1756  time_til_change = 0.5;
-
1757  }
-
1758 
-
1759  else if (KeyDown(KEY_QUANTUM_MENU)) {
-
1760  QuantumView* quantum_view = QuantumView::GetInstance();
-
1761  if (quantum_view) {
-
1762  if (quantum_view->IsMenuShown())
-
1763  quantum_view->CloseMenu();
-
1764  else
-
1765  quantum_view->ShowMenu();
-
1766  }
-
1767  time_til_change = 0.5;
-
1768  }
-
1769 
-
1770  else if (KeyDown(KEY_CAM_VIEW_SELECTION)) {
-
1771  time_til_change = 0.5;
-
1772  ViewSelection();
-
1773  }
-
1774 
-
1775  else if (KeyDown(KEY_HUD_MODE)) {
-
1776  time_til_change = 0.5;
-
1777  if (hud_view)
-
1778  hud_view->CycleHUDMode();
-
1779  }
-
1780 
-
1781  else if (KeyDown(KEY_HUD_COLOR)) {
-
1782  time_til_change = 0.5;
-
1783  if (hud_view)
-
1784  hud_view->CycleHUDColor();
-
1785  }
-
1786 
-
1787  else if (KeyDown(KEY_HUD_WARN)) {
-
1788  time_til_change = 0.5;
-
1789  if (hud_view)
-
1790  hud_view->CycleHUDWarn();
-
1791  }
-
1792 
-
1793  else if (KeyDown(KEY_HUD_INST)) {
-
1794  time_til_change = 0.5;
-
1795  if (hud_view)
-
1796  hud_view->CycleHUDInst();
-
1797  }
-
1798 
-
1799  else if (KeyDown(KEY_SELF_DESTRUCT)) {
-
1800  time_til_change = 0.5;
-
1801 
-
1802  if (player_ship && !player_ship->InTransition()) {
-
1803  double damage = player_ship->Design()->scuttle;
-
1804 
-
1805  if (NetGame::IsNetGameClient()) {
-
1806  NetUtil::SendSelfDestruct(player_ship, damage);
-
1807  }
-
1808  else {
-
1809  Point scuttle_loc = player_ship->Location() + RandomDirection() * player_ship->Radius();
-
1810  player_ship->InflictDamage(damage, 0, 1, scuttle_loc);
-
1811  }
-
1812 
-
1813  if (player_ship->Integrity() < 1) {
-
1814  ::Print(" %s 0-0-0-Destruct-0\n\n", player_ship->Name());
-
1815 
-
1816  ShipStats* s = ShipStats::Find(player_ship->Name());
-
1817  if (s)
-
1818  s->AddEvent(SimEvent::DESTROYED, player_ship->Name());
-
1819 
-
1820  player_ship->DeathSpiral();
-
1821  }
-
1822  }
-
1823  }
-
1824  }
-
1825 
-
1826  if (gamescreen && player_ship && time_til_change <= 0 && !::GetAsyncKeyState(VK_SHIFT) && !::GetAsyncKeyState(VK_MENU)) {
-
1827  if (KeyDown(KEY_NAV_DLG)) {
-
1828  gamescreen->ShowNavDlg();
-
1829  time_til_change = 0.5;
-
1830  }
-
1831 
-
1832  else if (KeyDown(KEY_WEP_DLG)) {
-
1833  if (player_ship && player_ship->Design()->wep_screen)
-
1834  gamescreen->ShowWeaponsOverlay();
-
1835  time_til_change = 0.5;
-
1836  }
-
1837 
-
1838  else if (KeyDown(KEY_FLT_DLG)) {
-
1839  if (player_ship && player_ship->NumFlightDecks() > 0)
-
1840  gamescreen->ShowFltDlg();
-
1841  time_til_change = 0.5;
-
1842  }
-
1843 
-
1844  else if (KeyDown(KEY_ENG_DLG)) {
-
1845  if (player_ship && player_ship->Design()->repair_screen)
-
1846  gamescreen->ShowEngDlg();
-
1847  time_til_change = 0.5;
-
1848  }
-
1849  }
-
1850 
-
1851  if (cam_dir) {
-
1852  double spin = (PI/2) * Game::FrameTime(); // Game::GUITime();
-
1853 
-
1854  if (avi_file)
-
1855  spin /= 6;
-
1856 
-
1857  if (KeyDown(KEY_CAM_EXT_PLUS_AZ))
-
1858  cam_dir->ExternalAzimuth(spin);
-
1859 
-
1860  else if (KeyDown(KEY_CAM_EXT_MINUS_AZ))
-
1861  cam_dir->ExternalAzimuth(-spin);
-
1862 
-
1863  if (KeyDown(KEY_CAM_EXT_PLUS_EL))
-
1864  cam_dir->ExternalElevation(spin);
-
1865 
-
1866  else if (KeyDown(KEY_CAM_EXT_MINUS_EL))
-
1867  cam_dir->ExternalElevation(-spin);
-
1868 
-
1869  if (KeyDown(KEY_CAM_VIRT_PLUS_AZ))
-
1870  cam_dir->VirtualAzimuth(-spin);
-
1871 
-
1872  else if (KeyDown(KEY_CAM_VIRT_MINUS_AZ))
-
1873  cam_dir->VirtualAzimuth(spin);
-
1874 
-
1875  if (KeyDown(KEY_CAM_VIRT_PLUS_EL))
-
1876  cam_dir->VirtualElevation(spin);
-
1877 
-
1878  else if (KeyDown(KEY_CAM_VIRT_MINUS_EL))
-
1879  cam_dir->VirtualElevation(-spin);
-
1880 
-
1881  if (KeyDown(KEY_CAM_EXT_PLUS_RANGE)){
-
1882  if (!gamescreen->IsNavShown()) {
-
1883  cam_dir->ExternalRange((float) (1 + 1.5 * Game::FrameTime())); // 1.1f);
-
1884  }
-
1885  }
-
1886 
-
1887  else if (KeyDown(KEY_CAM_EXT_MINUS_RANGE)) {
-
1888  if (!gamescreen->IsNavShown()) {
-
1889  cam_dir->ExternalRange((float) (1 - 1.5 * Game::FrameTime())); // 0.9f);
-
1890  }
-
1891  }
-
1892 
-
1893  if (tactical && !gamescreen->IsFormShown()) {
-
1894  if (Mouse::Wheel()) {
-
1895  int w = Mouse::Wheel();
-
1896 
-
1897  if (w < 0) {
-
1898  while (w < 0) {
-
1899  cam_dir->ExternalRange(1.25f);
-
1900  w += 120;
-
1901  }
-
1902  }
-
1903  else {
-
1904  while (w > 0) {
-
1905  cam_dir->ExternalRange(0.75f);
-
1906  w -= 120;
-
1907  }
-
1908  }
-
1909  }
-
1910 
-
1911  else if (Mouse::LButton() && Mouse::RButton()) {
-
1912  if (mouse_dy < 0)
-
1913  cam_dir->ExternalRange(0.85f);
-
1914  else if (mouse_dy > 0)
-
1915  cam_dir->ExternalRange(1.15f);
-
1916  }
-
1917 
-
1918  else if (Mouse::MButton() && time_til_change <= 0) {
-
1919  time_til_change = 0.5;
-
1920  ViewSelection();
-
1921  }
-
1922 
-
1923  else {
-
1924  if (mouse_dx || mouse_dy) {
-
1925  if (CameraDirector::GetCameraMode() == CameraDirector::MODE_VIRTUAL) {
-
1926  cam_dir->VirtualAzimuth( mouse_dx * 0.2 * DEGREES);
-
1927  cam_dir->VirtualElevation(mouse_dy * 0.2 * DEGREES);
-
1928  }
-
1929  else {
-
1930  cam_dir->ExternalAzimuth( mouse_dx * 0.2 * DEGREES);
-
1931  cam_dir->ExternalElevation(mouse_dy * 0.2 * DEGREES);
-
1932  }
-
1933  }
-
1934  }
-
1935  }
-
1936  }
-
1937 
-
1938  // radio message hot keys:
-
1939  static bool comm_key = false;
-
1940 
-
1941  if (KeyDown(KEY_COMM_ATTACK_TGT)) {
-
1942  if (!comm_key)
-
1943  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::ATTACK);
-
1944  comm_key = true;
-
1945  }
-
1946 
-
1947  else if (KeyDown(KEY_COMM_ESCORT_TGT)) {
-
1948  if (!comm_key)
-
1949  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::ESCORT);
-
1950  comm_key = true;
-
1951  }
-
1952 
-
1953  else if (KeyDown(KEY_COMM_WEP_FREE)) {
-
1954  if (!comm_key)
-
1955  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::WEP_FREE);
-
1956  comm_key = true;
-
1957  }
-
1958 
-
1959  else if (KeyDown(KEY_COMM_WEP_HOLD)) {
-
1960  if (!comm_key)
-
1961  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::FORM_UP);
-
1962  comm_key = true;
-
1963  }
-
1964 
-
1965  else if (KeyDown(KEY_COMM_COVER_ME)) {
-
1966  if (!comm_key)
-
1967  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::COVER_ME);
-
1968  comm_key = true;
-
1969  }
-
1970 
-
1971  else if (KeyDown(KEY_COMM_SKIP_NAV)) {
-
1972  if (!comm_key)
-
1973  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::SKIP_NAVPOINT);
-
1974  comm_key = true;
-
1975  }
-
1976 
-
1977  else if (KeyDown(KEY_COMM_RETURN_TO_BASE)) {
-
1978  if (!comm_key)
-
1979  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::RTB);
-
1980  comm_key = true;
-
1981  }
-
1982 
-
1983  else if (KeyDown(KEY_COMM_CALL_INBOUND)) {
-
1984  if (!comm_key)
-
1985  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::CALL_INBOUND);
-
1986  comm_key = true;
-
1987  }
-
1988 
-
1989  else if (KeyDown(KEY_COMM_REQUEST_PICTURE)) {
-
1990  if (!comm_key)
-
1991  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::REQUEST_PICTURE);
-
1992  comm_key = true;
-
1993  }
-
1994 
-
1995  else if (KeyDown(KEY_COMM_REQUEST_SUPPORT)) {
-
1996  if (!comm_key)
-
1997  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::REQUEST_SUPPORT);
-
1998  comm_key = true;
-
1999  }
-
2000 
-
2001  else if (KeyDown(KEY_CHAT_BROADCAST)) {
-
2002  if (!comm_key)
-
2003  SetChatMode(CHAT_BROADCAST);
-
2004  comm_key = true;
-
2005  }
-
2006 
-
2007  else if (KeyDown(KEY_CHAT_TEAM)) {
-
2008  if (!comm_key)
-
2009  SetChatMode(CHAT_TEAM);
-
2010  comm_key = true;
-
2011  }
-
2012 
-
2013  else if (KeyDown(KEY_CHAT_WING)) {
-
2014  if (!comm_key)
-
2015  SetChatMode(CHAT_WING);
-
2016  comm_key = true;
-
2017  }
-
2018 
-
2019  else if (KeyDown(KEY_CHAT_UNIT) && sim->GetSelection().container().size()) {
-
2020  if (!comm_key)
-
2021  SetChatMode(CHAT_UNIT);
-
2022  comm_key = true;
-
2023  }
-
2024 
-
2025  else {
-
2026  comm_key = false;
-
2027  }
-
2028 }
-
2029 
-
2030 void
-
2031 Starshatter::DoChatMode()
-
2032 {
-
2033  Player* p = Player::GetCurrentPlayer();
-
2034  bool send_chat = false;
-
2035  Text name = "Player";
-
2036 
-
2037  if (player_ship)
-
2038  name = player_ship->Name();
-
2039 
-
2040  if (p)
-
2041  name = p->Name();
-
2042 
-
2043  if (chat_text.length()) {
-
2044  if (chat_text[0] >= '0' && chat_text[0] <= '9') {
-
2045  if (p) {
-
2046  chat_text = p->ChatMacro(chat_text[0] - '0');
-
2047  send_chat = true;
-
2048  }
-
2049  }
-
2050  }
-
2051 
-
2052  if (KeyDown(KEY_EXIT)) {
-
2053  SetChatMode(0);
-
2054  time_til_change = 0.5;
-
2055  }
-
2056 
-
2057  else if (send_chat || Keyboard::KeyDown(VK_RETURN)) {
-
2058  switch (chat_mode) {
-
2059  default:
-
2060  case CHAT_BROADCAST:
-
2061  {
-
2062  NetUtil::SendChat(0, name, chat_text);
-
2063  }
-
2064  break;
-
2065 
-
2066  case CHAT_TEAM:
-
2067  if (player_ship) {
-
2068  NetUtil::SendChat(player_ship->GetIFF()+1, name, chat_text);
-
2069  }
-
2070  break;
-
2071 
-
2072  case CHAT_WING:
-
2073  if (player_ship) {
-
2074  Element* elem = player_ship->GetElement();
-
2075  if (elem) {
-
2076  for (int i = 1; i <= elem->NumShips(); i++) {
-
2077  Ship* s = elem->GetShip(i);
-
2078  if (s && s != player_ship)
-
2079  NetUtil::SendChat(s->GetObjID(), name, chat_text);
-
2080  }
-
2081  }
-
2082  }
-
2083  break;
-
2084 
-
2085  case CHAT_UNIT:
-
2086  {
-
2087  Sim* sim = Sim::GetSim();
-
2088  ListIter<Ship> seln = sim->GetSelection();
-
2089 
-
2090  while (++seln) {
-
2091  Ship* s = seln.value();
-
2092  if (s != player_ship)
-
2093  NetUtil::SendChat(s->GetObjID(), name, chat_text);
-
2094  }
-
2095  }
-
2096  break;
-
2097  }
+
1542  if (new_player) {
+
1543  if (new_player->IsDropship() && Ship::GetFlightModel() < 2 && Ship::GetControlModel() < 1)
+
1544  input->SwapYawRoll(true);
+
1545  else
+
1546  input->SwapYawRoll(false);
+
1547 
+
1548  if (hud_view) {
+
1549  hud_view->SetHUDMode(HUDView::HUD_MODE_TAC);
+
1550  hud_view->HideHUDWarn();
+
1551  }
+
1552  }
+
1553  }
+
1554 
+
1555  player_ship = sim->GetPlayerShip();
+
1556 
+
1557  if (player_ship) {
+
1558  // warp effect:
+
1559  if (player_ship->WarpFactor() > 1) {
+
1560  if (player_ship->WarpFactor() > field_of_view)
+
1561  gamescreen->SetFieldOfView(player_ship->WarpFactor());
+
1562  else
+
1563  gamescreen->SetFieldOfView(field_of_view);
+
1564  }
+
1565 
+
1566  else {
+
1567  if (gamescreen->GetFieldOfView() != field_of_view)
+
1568  gamescreen->SetFieldOfView(field_of_view);
+
1569  }
+
1570 
+
1571  gamescreen->ShowExternal();
+
1572 
+
1573  if (CameraDirector::GetCameraMode() >= CameraDirector::MODE_ORBIT && !player_ship->InTransition())
+
1574  tactical = true;
+
1575  else
+
1576  tactical = false;
+
1577 
+
1578  if (player_ship->InTransition())
+
1579  gamescreen->CloseTopmost();
+
1580  }
+
1581 
+
1582  if (chat_mode) {
+
1583  DoChatMode();
+
1584  }
+
1585 
+
1586  else {
+
1587  DoGameKeys();
+
1588  }
+
1589 
+
1590  gamescreen->FrameRate(frame_rate);
+
1591  gamescreen->ExecFrame();
+
1592 
+
1593  if (Game::GameTime() - time_mark > 60000) {
+
1594  time_mark = Game::GameTime();
+
1595  minutes++;
+
1596  if (minutes > 60)
+
1597  Print(" TIME %2d:%02d:00\n", minutes/60, minutes%60);
+
1598  else
+
1599  Print(" TIME %2d:00\n", minutes);
+
1600  }
+
1601 }
+
1602 
+
1603 void
+
1604 Starshatter::DoGameKeys()
+
1605 {
+
1606  Sim* sim = (Sim*) world;
+
1607  HUDView* hud_view = HUDView::GetInstance();
+
1608 
+
1609  if (time_til_change <= 0) {
+
1610  if (KeyDown(KEY_CAM_BRIDGE)) {
+
1611  PlayerCam(CameraDirector::MODE_COCKPIT);
+
1612  time_til_change = 0.5;
+
1613  }
+
1614 
+
1615  else if (KeyDown(KEY_CAM_VIRT)) {
+
1616  PlayerCam(CameraDirector::MODE_VIRTUAL);
+
1617  time_til_change = 0.5;
+
1618  }
+
1619 
+
1620  else if (KeyDown(KEY_CAM_CHASE)) {
+
1621  PlayerCam(CameraDirector::MODE_CHASE);
+
1622  time_til_change = 0.5;
+
1623  }
+
1624 
+
1625  else if (KeyDown(KEY_CAM_DROP)) {
+
1626  PlayerCam(CameraDirector::MODE_DROP);
+
1627  time_til_change = 0.5;
+
1628  }
+
1629 
+
1630  else if (KeyDown(KEY_CAM_EXTERN)) {
+
1631  PlayerCam(CameraDirector::MODE_ORBIT);
+
1632  time_til_change = 0.5;
+
1633  }
+
1634 
+
1635  else if (KeyDown(KEY_TARGET_PADLOCK)) {
+
1636  PlayerCam(CameraDirector::MODE_TARGET);
+
1637  time_til_change = 0.5;
+
1638  }
+
1639 
+
1640  else if (KeyDown(KEY_SWAP_ROLL_YAW)) {
+
1641  input->SwapYawRoll(!input->GetSwapYawRoll());
+
1642  time_til_change = 0.5;
+
1643  }
+
1644 
+
1645  else if (KeyDown(KEY_ZOOM_WIDE)) {
+
1646  time_til_change = 0.5;
+
1647  if (gamescreen->GetFieldOfView() <= 2)
+
1648  field_of_view = 3; // wide
+
1649  else
+
1650  field_of_view = 2; // normal
+
1651 
+
1652  // don't mess with fov during warp:
+
1653  if (player_ship && player_ship->WarpFactor() <= 1)
+
1654  gamescreen->SetFieldOfView(field_of_view);
+
1655  }
+
1656 
+
1657  else if (!exit_latch && KeyDown(KEY_EXIT)) {
+
1658  exit_latch = true;
+
1659  time_til_change = 0.5;
+
1660 
+
1661  if (!gamescreen->CloseTopmost()) {
+
1662  QuitView* quit = QuitView::GetInstance();
+
1663  if (quit)
+
1664  quit->ShowMenu();
+
1665  else
+
1666  SetGameMode(Starshatter::PLAN_MODE);
+
1667  }
+
1668  }
+
1669 
+
1670  else if (KeyDown(KEY_PAUSE)) {
+
1671  Pause(!paused);
+
1672  time_til_change = 0.5;
+
1673  }
+
1674 
+
1675 
+
1676  else if (KeyDown(KEY_TIME_COMPRESS)) {
+
1677  time_til_change = 0.5;
+
1678  if (NetGame::IsNetGame())
+
1679  SetTimeCompression(1);
+
1680  else
+
1681  switch (TimeCompression()) {
+
1682  case 1: SetTimeCompression(2); break;
+
1683  default: SetTimeCompression(4); break;
+
1684  }
+
1685  }
+
1686 
+
1687  else if (KeyDown(KEY_TIME_EXPAND)) {
+
1688  time_til_change = 0.5;
+
1689 
+
1690  if (NetGame::IsNetGame())
+
1691  SetTimeCompression(1);
+
1692  else
+
1693  switch (TimeCompression()) {
+
1694  case 4: SetTimeCompression( 2); break;
+
1695  default: SetTimeCompression( 1); break;
+
1696  }
+
1697  }
+
1698 
+
1699  else if (KeyDown(KEY_TIME_SKIP)) {
+
1700  time_til_change = 0.5;
+
1701 
+
1702  if (player_ship && !NetGame::IsNetGame()) {
+
1703  player_ship->TimeSkip();
+
1704  }
+
1705  }
+
1706 
+
1707  else if (KeyDown(KEY_COMMAND_MODE)) {
+
1708  if (player_ship) {
+
1709  time_til_change = 0.5;
+
1710  player_ship->CommandMode();
+
1711  }
+
1712  }
+
1713 
+
1714  /*** For Debug Convenience Only: ***/
+
1715  else if (KeyDown(KEY_INC_STARDATE)) {
+
1716  StarSystem::SetBaseTime(StarSystem::GetBaseTime() + 600, true);
+
1717  }
+
1718 
+
1719  else if (KeyDown(KEY_DEC_STARDATE)) {
+
1720  StarSystem::SetBaseTime(StarSystem::GetBaseTime() - 600, true);
+
1721  }
+
1722  /***/
+
1723  }
+
1724 
+
1725  if (gamescreen && time_til_change <= 0) {
+
1726  if (KeyDown(KEY_MFD1)) {
+
1727  gamescreen->CycleMFDMode(0);
+
1728  time_til_change = 0.5;
+
1729  }
+
1730 
+
1731  else if (KeyDown(KEY_MFD2)) {
+
1732  gamescreen->CycleMFDMode(1);
+
1733  time_til_change = 0.5;
+
1734  }
+
1735 
+
1736  else if (KeyDown(KEY_MFD3)) {
+
1737  gamescreen->CycleMFDMode(2);
+
1738  time_til_change = 0.5;
+
1739  }
+
1740 
+
1741  else if (KeyDown(KEY_MFD4)) {
+
1742  gamescreen->CycleMFDMode(3);
+
1743  time_til_change = 0.5;
+
1744  }
+
1745 
+
1746  else if (KeyDown(KEY_RADIO_MENU)) {
+
1747  RadioView* radio_view = RadioView::GetInstance();
+
1748  if (radio_view) {
+
1749  if (radio_view->IsMenuShown())
+
1750  radio_view->CloseMenu();
+
1751  else
+
1752  radio_view->ShowMenu();
+
1753  }
+
1754  time_til_change = 0.5;
+
1755  }
+
1756 
+
1757  else if (KeyDown(KEY_QUANTUM_MENU)) {
+
1758  QuantumView* quantum_view = QuantumView::GetInstance();
+
1759  if (quantum_view) {
+
1760  if (quantum_view->IsMenuShown())
+
1761  quantum_view->CloseMenu();
+
1762  else
+
1763  quantum_view->ShowMenu();
+
1764  }
+
1765  time_til_change = 0.5;
+
1766  }
+
1767 
+
1768  else if (KeyDown(KEY_CAM_VIEW_SELECTION)) {
+
1769  time_til_change = 0.5;
+
1770  ViewSelection();
+
1771  }
+
1772 
+
1773  else if (KeyDown(KEY_HUD_MODE)) {
+
1774  time_til_change = 0.5;
+
1775  if (hud_view)
+
1776  hud_view->CycleHUDMode();
+
1777  }
+
1778 
+
1779  else if (KeyDown(KEY_HUD_COLOR)) {
+
1780  time_til_change = 0.5;
+
1781  if (hud_view)
+
1782  hud_view->CycleHUDColor();
+
1783  }
+
1784 
+
1785  else if (KeyDown(KEY_HUD_WARN)) {
+
1786  time_til_change = 0.5;
+
1787  if (hud_view)
+
1788  hud_view->CycleHUDWarn();
+
1789  }
+
1790 
+
1791  else if (KeyDown(KEY_HUD_INST)) {
+
1792  time_til_change = 0.5;
+
1793  if (hud_view)
+
1794  hud_view->CycleHUDInst();
+
1795  }
+
1796 
+
1797  else if (KeyDown(KEY_SELF_DESTRUCT)) {
+
1798  time_til_change = 0.5;
+
1799 
+
1800  if (player_ship && !player_ship->InTransition()) {
+
1801  double damage = player_ship->Design()->scuttle;
+
1802 
+
1803  if (NetGame::IsNetGameClient()) {
+
1804  NetUtil::SendSelfDestruct(player_ship, damage);
+
1805  }
+
1806  else {
+
1807  Point scuttle_loc = player_ship->Location() + RandomDirection() * player_ship->Radius();
+
1808  player_ship->InflictDamage(damage, 0, 1, scuttle_loc);
+
1809  }
+
1810 
+
1811  if (player_ship->Integrity() < 1) {
+
1812  ::Print(" %s 0-0-0-Destruct-0\n\n", player_ship->Name());
+
1813 
+
1814  ShipStats* s = ShipStats::Find(player_ship->Name());
+
1815  if (s)
+
1816  s->AddEvent(SimEvent::DESTROYED, player_ship->Name());
+
1817 
+
1818  player_ship->DeathSpiral();
+
1819  }
+
1820  }
+
1821  }
+
1822  }
+
1823 
+
1824  if (gamescreen && player_ship && time_til_change <= 0 && !::GetAsyncKeyState(VK_SHIFT) && !::GetAsyncKeyState(VK_MENU)) {
+
1825  if (KeyDown(KEY_NAV_DLG)) {
+
1826  gamescreen->ShowNavDlg();
+
1827  time_til_change = 0.5;
+
1828  }
+
1829 
+
1830  else if (KeyDown(KEY_WEP_DLG)) {
+
1831  if (player_ship && player_ship->Design()->wep_screen)
+
1832  gamescreen->ShowWeaponsOverlay();
+
1833  time_til_change = 0.5;
+
1834  }
+
1835 
+
1836  else if (KeyDown(KEY_FLT_DLG)) {
+
1837  if (player_ship && player_ship->NumFlightDecks() > 0)
+
1838  gamescreen->ShowFltDlg();
+
1839  time_til_change = 0.5;
+
1840  }
+
1841 
+
1842  else if (KeyDown(KEY_ENG_DLG)) {
+
1843  if (player_ship && player_ship->Design()->repair_screen)
+
1844  gamescreen->ShowEngDlg();
+
1845  time_til_change = 0.5;
+
1846  }
+
1847  }
+
1848 
+
1849  if (cam_dir) {
+
1850  double spin = (PI/2) * Game::FrameTime(); // Game::GUITime();
+
1851 
+
1852  if (avi_file)
+
1853  spin /= 6;
+
1854 
+
1855  if (KeyDown(KEY_CAM_EXT_PLUS_AZ))
+
1856  cam_dir->ExternalAzimuth(spin);
+
1857 
+
1858  else if (KeyDown(KEY_CAM_EXT_MINUS_AZ))
+
1859  cam_dir->ExternalAzimuth(-spin);
+
1860 
+
1861  if (KeyDown(KEY_CAM_EXT_PLUS_EL))
+
1862  cam_dir->ExternalElevation(spin);
+
1863 
+
1864  else if (KeyDown(KEY_CAM_EXT_MINUS_EL))
+
1865  cam_dir->ExternalElevation(-spin);
+
1866 
+
1867  if (KeyDown(KEY_CAM_VIRT_PLUS_AZ))
+
1868  cam_dir->VirtualAzimuth(-spin);
+
1869 
+
1870  else if (KeyDown(KEY_CAM_VIRT_MINUS_AZ))
+
1871  cam_dir->VirtualAzimuth(spin);
+
1872 
+
1873  if (KeyDown(KEY_CAM_VIRT_PLUS_EL))
+
1874  cam_dir->VirtualElevation(spin);
+
1875 
+
1876  else if (KeyDown(KEY_CAM_VIRT_MINUS_EL))
+
1877  cam_dir->VirtualElevation(-spin);
+
1878 
+
1879  if (KeyDown(KEY_CAM_EXT_PLUS_RANGE)){
+
1880  if (!gamescreen->IsNavShown()) {
+
1881  cam_dir->ExternalRange((float) (1 + 1.5 * Game::FrameTime())); // 1.1f);
+
1882  }
+
1883  }
+
1884 
+
1885  else if (KeyDown(KEY_CAM_EXT_MINUS_RANGE)) {
+
1886  if (!gamescreen->IsNavShown()) {
+
1887  cam_dir->ExternalRange((float) (1 - 1.5 * Game::FrameTime())); // 0.9f);
+
1888  }
+
1889  }
+
1890 
+
1891  if (tactical && !gamescreen->IsFormShown()) {
+
1892  if (Mouse::Wheel()) {
+
1893  int w = Mouse::Wheel();
+
1894 
+
1895  if (w < 0) {
+
1896  while (w < 0) {
+
1897  cam_dir->ExternalRange(1.25f);
+
1898  w += 120;
+
1899  }
+
1900  }
+
1901  else {
+
1902  while (w > 0) {
+
1903  cam_dir->ExternalRange(0.75f);
+
1904  w -= 120;
+
1905  }
+
1906  }
+
1907  }
+
1908 
+
1909  else if (Mouse::LButton() && Mouse::RButton()) {
+
1910  if (mouse_dy < 0)
+
1911  cam_dir->ExternalRange(0.85f);
+
1912  else if (mouse_dy > 0)
+
1913  cam_dir->ExternalRange(1.15f);
+
1914  }
+
1915 
+
1916  else if (Mouse::MButton() && time_til_change <= 0) {
+
1917  time_til_change = 0.5;
+
1918  ViewSelection();
+
1919  }
+
1920 
+
1921  else {
+
1922  if (mouse_dx || mouse_dy) {
+
1923  if (CameraDirector::GetCameraMode() == CameraDirector::MODE_VIRTUAL) {
+
1924  cam_dir->VirtualAzimuth( mouse_dx * 0.2 * DEGREES);
+
1925  cam_dir->VirtualElevation(mouse_dy * 0.2 * DEGREES);
+
1926  }
+
1927  else {
+
1928  cam_dir->ExternalAzimuth( mouse_dx * 0.2 * DEGREES);
+
1929  cam_dir->ExternalElevation(mouse_dy * 0.2 * DEGREES);
+
1930  }
+
1931  }
+
1932  }
+
1933  }
+
1934  }
+
1935 
+
1936  // radio message hot keys:
+
1937  static bool comm_key = false;
+
1938 
+
1939  if (KeyDown(KEY_COMM_ATTACK_TGT)) {
+
1940  if (!comm_key)
+
1941  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::ATTACK);
+
1942  comm_key = true;
+
1943  }
+
1944 
+
1945  else if (KeyDown(KEY_COMM_ESCORT_TGT)) {
+
1946  if (!comm_key)
+
1947  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::ESCORT);
+
1948  comm_key = true;
+
1949  }
+
1950 
+
1951  else if (KeyDown(KEY_COMM_WEP_FREE)) {
+
1952  if (!comm_key)
+
1953  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::WEP_FREE);
+
1954  comm_key = true;
+
1955  }
+
1956 
+
1957  else if (KeyDown(KEY_COMM_WEP_HOLD)) {
+
1958  if (!comm_key)
+
1959  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::FORM_UP);
+
1960  comm_key = true;
+
1961  }
+
1962 
+
1963  else if (KeyDown(KEY_COMM_COVER_ME)) {
+
1964  if (!comm_key)
+
1965  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::COVER_ME);
+
1966  comm_key = true;
+
1967  }
+
1968 
+
1969  else if (KeyDown(KEY_COMM_SKIP_NAV)) {
+
1970  if (!comm_key)
+
1971  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::SKIP_NAVPOINT);
+
1972  comm_key = true;
+
1973  }
+
1974 
+
1975  else if (KeyDown(KEY_COMM_RETURN_TO_BASE)) {
+
1976  if (!comm_key)
+
1977  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::RTB);
+
1978  comm_key = true;
+
1979  }
+
1980 
+
1981  else if (KeyDown(KEY_COMM_CALL_INBOUND)) {
+
1982  if (!comm_key)
+
1983  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::CALL_INBOUND);
+
1984  comm_key = true;
+
1985  }
+
1986 
+
1987  else if (KeyDown(KEY_COMM_REQUEST_PICTURE)) {
+
1988  if (!comm_key)
+
1989  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::REQUEST_PICTURE);
+
1990  comm_key = true;
+
1991  }
+
1992 
+
1993  else if (KeyDown(KEY_COMM_REQUEST_SUPPORT)) {
+
1994  if (!comm_key)
+
1995  RadioTraffic::SendQuickMessage(player_ship, RadioMessage::REQUEST_SUPPORT);
+
1996  comm_key = true;
+
1997  }
+
1998 
+
1999  else if (KeyDown(KEY_CHAT_BROADCAST)) {
+
2000  if (!comm_key)
+
2001  SetChatMode(CHAT_BROADCAST);
+
2002  comm_key = true;
+
2003  }
+
2004 
+
2005  else if (KeyDown(KEY_CHAT_TEAM)) {
+
2006  if (!comm_key)
+
2007  SetChatMode(CHAT_TEAM);
+
2008  comm_key = true;
+
2009  }
+
2010 
+
2011  else if (KeyDown(KEY_CHAT_WING)) {
+
2012  if (!comm_key)
+
2013  SetChatMode(CHAT_WING);
+
2014  comm_key = true;
+
2015  }
+
2016 
+
2017  else if (KeyDown(KEY_CHAT_UNIT) && sim->GetSelection().container().size()) {
+
2018  if (!comm_key)
+
2019  SetChatMode(CHAT_UNIT);
+
2020  comm_key = true;
+
2021  }
+
2022 
+
2023  else {
+
2024  comm_key = false;
+
2025  }
+
2026 }
+
2027 
+
2028 void
+
2029 Starshatter::DoChatMode()
+
2030 {
+
2031  Player* p = Player::GetCurrentPlayer();
+
2032  bool send_chat = false;
+
2033  Text name = "Player";
+
2034 
+
2035  if (player_ship)
+
2036  name = player_ship->Name();
+
2037 
+
2038  if (p)
+
2039  name = p->Name();
+
2040 
+
2041  if (chat_text.length()) {
+
2042  if (chat_text[0] >= '0' && chat_text[0] <= '9') {
+
2043  if (p) {
+
2044  chat_text = p->ChatMacro(chat_text[0] - '0');
+
2045  send_chat = true;
+
2046  }
+
2047  }
+
2048  }
+
2049 
+
2050  if (KeyDown(KEY_EXIT)) {
+
2051  SetChatMode(0);
+
2052  time_til_change = 0.5;
+
2053  }
+
2054 
+
2055  else if (send_chat || Keyboard::KeyDown(VK_RETURN)) {
+
2056  switch (chat_mode) {
+
2057  default:
+
2058  case CHAT_BROADCAST:
+
2059  {
+
2060  NetUtil::SendChat(0, name, chat_text);
+
2061  }
+
2062  break;
+
2063 
+
2064  case CHAT_TEAM:
+
2065  if (player_ship) {
+
2066  NetUtil::SendChat(player_ship->GetIFF()+1, name, chat_text);
+
2067  }
+
2068  break;
+
2069 
+
2070  case CHAT_WING:
+
2071  if (player_ship) {
+
2072  Element* elem = player_ship->GetElement();
+
2073  if (elem) {
+
2074  for (int i = 1; i <= elem->NumShips(); i++) {
+
2075  Ship* s = elem->GetShip(i);
+
2076  if (s && s != player_ship)
+
2077  NetUtil::SendChat(s->GetObjID(), name, chat_text);
+
2078  }
+
2079  }
+
2080  }
+
2081  break;
+
2082 
+
2083  case CHAT_UNIT:
+
2084  {
+
2085  Sim* sim = Sim::GetSim();
+
2086  ListIter<Ship> seln = sim->GetSelection();
+
2087 
+
2088  while (++seln) {
+
2089  Ship* s = seln.value();
+
2090  if (s != player_ship)
+
2091  NetUtil::SendChat(s->GetObjID(), name, chat_text);
+
2092  }
+
2093  }
+
2094  break;
+
2095  }
+
2096 
+
2097  HUDView::Message("%s> %s", name.data(), chat_text.data());
2098 
-
2099  HUDView::Message("%s> %s", name.data(), chat_text.data());
-
2100 
-
2101  SetChatMode(0);
-
2102  time_til_change = 0.5;
-
2103  }
-
2104 
-
2105  else {
-
2106  int key = 0;
-
2107  int shift = 0;
-
2108 
-
2109  while (GetKeyPlus(key, shift)) {
-
2110  if (key >= 'A' && key <= 'Z') {
-
2111  if (shift & 1)
-
2112  chat_text += (char) key;
-
2113  else
-
2114  chat_text += (char) tolower(key);
-
2115  }
-
2116  else {
-
2117  switch (key) {
-
2118  case VK_BACK:
-
2119  chat_text = chat_text.substring(0, chat_text.length()-1);
-
2120  break;
-
2121 
-
2122  case VK_SPACE: chat_text += ' '; break;
-
2123  case '0': if (shift & 1) chat_text += ')'; else chat_text += '0'; break;
-
2124  case '1': if (shift & 1) chat_text += '!'; else chat_text += '1'; break;
-
2125  case '2': if (shift & 1) chat_text += '@'; else chat_text += '2'; break;
-
2126  case '3': if (shift & 1) chat_text += '#'; else chat_text += '3'; break;
-
2127  case '4': if (shift & 1) chat_text += '$'; else chat_text += '4'; break;
-
2128  case '5': if (shift & 1) chat_text += '%'; else chat_text += '5'; break;
-
2129  case '6': if (shift & 1) chat_text += '^'; else chat_text += '6'; break;
-
2130  case '7': if (shift & 1) chat_text += '&'; else chat_text += '7'; break;
-
2131  case '8': if (shift & 1) chat_text += '*'; else chat_text += '8'; break;
-
2132  case '9': if (shift & 1) chat_text += '('; else chat_text += '9'; break;
-
2133  case 186: if (shift & 1) chat_text += ':'; else chat_text += ';'; break;
-
2134  case 187: if (shift & 1) chat_text += '+'; else chat_text += '='; break;
-
2135  case 188: if (shift & 1) chat_text += '<'; else chat_text += ','; break;
-
2136  case 189: if (shift & 1) chat_text += '_'; else chat_text += '-'; break;
-
2137  case 190: if (shift & 1) chat_text += '>'; else chat_text += '.'; break;
-
2138  case 191: if (shift & 1) chat_text += '?'; else chat_text += '/'; break;
-
2139  case 192: if (shift & 1) chat_text += '~'; else chat_text += '`'; break;
-
2140  case 219: if (shift & 1) chat_text += '{'; else chat_text += '['; break;
-
2141  case 221: if (shift & 1) chat_text += '}'; else chat_text += ']'; break;
-
2142  case 220: if (shift & 1) chat_text += '|'; else chat_text += '\\'; break;
-
2143  case 222: if (shift & 1) chat_text += '"'; else chat_text += '\''; break;
-
2144  }
-
2145  }
-
2146  }
-
2147  }
-
2148 }
-
2149 
-
2150 void
-
2151 Starshatter::SetChatMode(int mode)
-
2152 {
-
2153  if (mode >= 0 && mode <= 4 && mode != chat_mode) {
-
2154  chat_text = "";
-
2155 
-
2156  if (!NetGame::IsNetGame()) {
-
2157  chat_mode = 0;
-
2158  }
-
2159  else {
-
2160  chat_mode = mode;
-
2161 
-
2162  // flush input before reading chat message:
-
2163  if (chat_mode) {
-
2164  FlushKeys();
-
2165  }
-
2166 
-
2167  // flush input before sampling flight controls:
-
2168  else {
-
2169  for (int i = 1; i < 255; i++) {
-
2170  Keyboard::KeyDown(i);
-
2171  }
-
2172  }
-
2173  }
-
2174  }
-
2175 }
+
2099  SetChatMode(0);
+
2100  time_til_change = 0.5;
+
2101  }
+
2102 
+
2103  else {
+
2104  int key = 0;
+
2105  int shift = 0;
+
2106 
+
2107  while (GetKeyPlus(key, shift)) {
+
2108  if (key >= 'A' && key <= 'Z') {
+
2109  if (shift & 1)
+
2110  chat_text += (char) key;
+
2111  else
+
2112  chat_text += (char) tolower(key);
+
2113  }
+
2114  else {
+
2115  switch (key) {
+
2116  case VK_BACK:
+
2117  chat_text = chat_text.substring(0, chat_text.length()-1);
+
2118  break;
+
2119 
+
2120  case VK_SPACE: chat_text += ' '; break;
+
2121  case '0': if (shift & 1) chat_text += ')'; else chat_text += '0'; break;
+
2122  case '1': if (shift & 1) chat_text += '!'; else chat_text += '1'; break;
+
2123  case '2': if (shift & 1) chat_text += '@'; else chat_text += '2'; break;
+
2124  case '3': if (shift & 1) chat_text += '#'; else chat_text += '3'; break;
+
2125  case '4': if (shift & 1) chat_text += '$'; else chat_text += '4'; break;
+
2126  case '5': if (shift & 1) chat_text += '%'; else chat_text += '5'; break;
+
2127  case '6': if (shift & 1) chat_text += '^'; else chat_text += '6'; break;
+
2128  case '7': if (shift & 1) chat_text += '&'; else chat_text += '7'; break;
+
2129  case '8': if (shift & 1) chat_text += '*'; else chat_text += '8'; break;
+
2130  case '9': if (shift & 1) chat_text += '('; else chat_text += '9'; break;
+
2131  case 186: if (shift & 1) chat_text += ':'; else chat_text += ';'; break;
+
2132  case 187: if (shift & 1) chat_text += '+'; else chat_text += '='; break;
+
2133  case 188: if (shift & 1) chat_text += '<'; else chat_text += ','; break;
+
2134  case 189: if (shift & 1) chat_text += '_'; else chat_text += '-'; break;
+
2135  case 190: if (shift & 1) chat_text += '>'; else chat_text += '.'; break;
+
2136  case 191: if (shift & 1) chat_text += '?'; else chat_text += '/'; break;
+
2137  case 192: if (shift & 1) chat_text += '~'; else chat_text += '`'; break;
+
2138  case 219: if (shift & 1) chat_text += '{'; else chat_text += '['; break;
+
2139  case 221: if (shift & 1) chat_text += '}'; else chat_text += ']'; break;
+
2140  case 220: if (shift & 1) chat_text += '|'; else chat_text += '\\'; break;
+
2141  case 222: if (shift & 1) chat_text += '"'; else chat_text += '\''; break;
+
2142  }
+
2143  }
+
2144  }
+
2145  }
+
2146 }
+
2147 
+
2148 void
+
2149 Starshatter::SetChatMode(int mode)
+
2150 {
+
2151  if (mode >= 0 && mode <= 4 && mode != chat_mode) {
+
2152  chat_text = "";
+
2153 
+
2154  if (!NetGame::IsNetGame()) {
+
2155  chat_mode = 0;
+
2156  }
+
2157  else {
+
2158  chat_mode = mode;
+
2159 
+
2160  // flush input before reading chat message:
+
2161  if (chat_mode) {
+
2162  FlushKeys();
+
2163  }
+
2164 
+
2165  // flush input before sampling flight controls:
+
2166  else {
+
2167  for (int i = 1; i < 255; i++) {
+
2168  Keyboard::KeyDown(i);
+
2169  }
+
2170  }
+
2171  }
+
2172  }
+
2173 }
+
2174 
+
2175 // +--------------------------------------------------------------------+
2176 
-
2177 // +--------------------------------------------------------------------+
-
2178 
-
2179 void
-
2180 Starshatter::DoMouseFrame()
-
2181 {
-
2182  EventDispatch* event_dispatch = EventDispatch::GetInstance();
-
2183  if (event_dispatch && event_dispatch->GetCapture())
-
2184  return;
-
2185 
-
2186  mouse_dx = 0;
-
2187  mouse_dy = 0;
-
2188 
-
2189  static int old_mouse_x = 0;
-
2190  static int old_mouse_y = 0;
-
2191 
-
2192  if (!spinning && Mouse::RButton()) {
-
2193  spinning = true;
-
2194  old_mouse_x = Mouse::X();
-
2195  old_mouse_y = Mouse::Y();
-
2196  mouse_x = Mouse::X();
-
2197  mouse_y = Mouse::Y();
-
2198  Mouse::Show(false);
-
2199  }
-
2200 
-
2201  else if (spinning) {
-
2202  if (!Mouse::RButton()) {
-
2203  spinning = false;
-
2204 
-
2205  if (tactical) {
-
2206  Mouse::Show(true);
-
2207  Mouse::SetCursor(Mouse::ARROW);
-
2208  }
-
2209 
-
2210  Mouse::SetCursorPos(old_mouse_x, old_mouse_y);
-
2211  }
-
2212 
-
2213  else {
-
2214  mouse_dx = Mouse::X() - mouse_x;
-
2215  mouse_dy = Mouse::Y() - mouse_y;
-
2216 
-
2217  Mouse::SetCursorPos(mouse_x, mouse_y);
-
2218  }
-
2219  }
-
2220 
-
2221  else if (cutscene || !player_ship) {
-
2222  Mouse::Show(false);
-
2223  return;
-
2224  }
-
2225 
-
2226  // hide mouse cursor when mouse controller is actively steering:
-
2227  else if (mouse_input && mouse_input->Active()) {
-
2228  if (mouse_input->Selector() == 1) {
-
2229  Mouse::Show(false);
-
2230  }
-
2231 
-
2232  else if (mouse_input->Selector() == 2) {
-
2233  Mouse::Show(true);
-
2234  Mouse::SetCursor(Mouse::CROSS);
-
2235  }
-
2236  }
-
2237 
-
2238  else {
-
2239  HUDView* hud_view = HUDView::GetInstance();
-
2240 
-
2241  if (hud_view && hud_view->GetHUDMode() != HUDView::HUD_MODE_OFF) {
-
2242  Mouse::Show(true);
-
2243  Mouse::SetCursor(Mouse::ARROW);
-
2244  }
-
2245  }
-
2246 
-
2247  if (gamescreen && gamescreen->IsFormShown())
-
2248  return;
+
2177 void
+
2178 Starshatter::DoMouseFrame()
+
2179 {
+
2180  EventDispatch* event_dispatch = EventDispatch::GetInstance();
+
2181  if (event_dispatch && event_dispatch->GetCapture())
+
2182  return;
+
2183 
+
2184  mouse_dx = 0;
+
2185  mouse_dy = 0;
+
2186 
+
2187  static int old_mouse_x = 0;
+
2188  static int old_mouse_y = 0;
+
2189 
+
2190  if (!spinning && Mouse::RButton()) {
+
2191  spinning = true;
+
2192  old_mouse_x = Mouse::X();
+
2193  old_mouse_y = Mouse::Y();
+
2194  mouse_x = Mouse::X();
+
2195  mouse_y = Mouse::Y();
+
2196  Mouse::Show(false);
+
2197  }
+
2198 
+
2199  else if (spinning) {
+
2200  if (!Mouse::RButton()) {
+
2201  spinning = false;
+
2202 
+
2203  if (tactical) {
+
2204  Mouse::Show(true);
+
2205  Mouse::SetCursor(Mouse::ARROW);
+
2206  }
+
2207 
+
2208  Mouse::SetCursorPos(old_mouse_x, old_mouse_y);
+
2209  }
+
2210 
+
2211  else {
+
2212  mouse_dx = Mouse::X() - mouse_x;
+
2213  mouse_dy = Mouse::Y() - mouse_y;
+
2214 
+
2215  Mouse::SetCursorPos(mouse_x, mouse_y);
+
2216  }
+
2217  }
+
2218 
+
2219  else if (cutscene || !player_ship) {
+
2220  Mouse::Show(false);
+
2221  return;
+
2222  }
+
2223 
+
2224  // hide mouse cursor when mouse controller is actively steering:
+
2225  else if (mouse_input && mouse_input->Active()) {
+
2226  if (mouse_input->Selector() == 1) {
+
2227  Mouse::Show(false);
+
2228  }
+
2229 
+
2230  else if (mouse_input->Selector() == 2) {
+
2231  Mouse::Show(true);
+
2232  Mouse::SetCursor(Mouse::CROSS);
+
2233  }
+
2234  }
+
2235 
+
2236  else {
+
2237  HUDView* hud_view = HUDView::GetInstance();
+
2238 
+
2239  if (hud_view && hud_view->GetHUDMode() != HUDView::HUD_MODE_OFF) {
+
2240  Mouse::Show(true);
+
2241  Mouse::SetCursor(Mouse::ARROW);
+
2242  }
+
2243  }
+
2244 
+
2245  if (gamescreen && gamescreen->IsFormShown())
+
2246  return;
+
2247 
+
2248  TacticalView* tac_view = TacticalView::GetInstance();
2249 
-
2250  TacticalView* tac_view = TacticalView::GetInstance();
-
2251 
-
2252  if (tac_view)
-
2253  tac_view->DoMouseFrame();
-
2254 }
+
2250  if (tac_view)
+
2251  tac_view->DoMouseFrame();
+
2252 }
+
2253 
+
2254 // +--------------------------------------------------------------------+
2255 
-
2256 // +--------------------------------------------------------------------+
-
2257 
-
2258 void
-
2259 Starshatter::SetupSplash()
-
2260 {
-
2261  Color::SetFade(0);
-
2262 
-
2263  if (gamewin) {
-
2264  screen->DelWindow(gamewin);
-
2265  delete gamewin;
-
2266  gamewin = 0;
-
2267  }
-
2268 
-
2269  switch (splash_index) {
-
2270  case 0:
-
2271  splash_image.ClearImage();
-
2272  loader->SetDataPath(0);
-
2273  loader->LoadBitmap("matrix.pcx", splash_image);
-
2274  break;
-
2275 
-
2276  case 1:
-
2277  default:
-
2278  splash_image.ClearImage();
-
2279  loader->SetDataPath(0);
-
2280  loader->LoadBitmap("studio.pcx", splash_image);
-
2281  break;
-
2282  }
-
2283 
-
2284  int screen_width = GetScreenWidth();
-
2285  int screen_height = GetScreenHeight();
-
2286 
-
2287  gamewin = new(__FILE__,__LINE__) Window(screen, 0, 0, screen_width, screen_height);
-
2288  splash = new(__FILE__,__LINE__) FadeView(gamewin, 2, 2, 2);
-
2289 
-
2290  gamewin->AddView(splash);
-
2291  gamewin->AddView(new(__FILE__,__LINE__) ImgView(gamewin, &splash_image));
-
2292  screen->AddWindow(gamewin);
-
2293 }
+
2256 void
+
2257 Starshatter::SetupSplash()
+
2258 {
+
2259  Color::SetFade(0);
+
2260 
+
2261  if (gamewin) {
+
2262  screen->DelWindow(gamewin);
+
2263  delete gamewin;
+
2264  gamewin = 0;
+
2265  }
+
2266 
+
2267  switch (splash_index) {
+
2268  case 0:
+
2269  splash_image.ClearImage();
+
2270  loader->SetDataPath(0);
+
2271  loader->LoadBitmap("matrix.pcx", splash_image);
+
2272  break;
+
2273 
+
2274  case 1:
+
2275  default:
+
2276  splash_image.ClearImage();
+
2277  loader->SetDataPath(0);
+
2278  loader->LoadBitmap("studio.pcx", splash_image);
+
2279  break;
+
2280  }
+
2281 
+
2282  int screen_width = GetScreenWidth();
+
2283  int screen_height = GetScreenHeight();
+
2284 
+
2285  gamewin = new(__FILE__,__LINE__) Window(screen, 0, 0, screen_width, screen_height);
+
2286  splash = new(__FILE__,__LINE__) FadeView(gamewin, 2, 2, 2);
+
2287 
+
2288  gamewin->AddView(splash);
+
2289  gamewin->AddView(new(__FILE__,__LINE__) ImgView(gamewin, &splash_image));
+
2290  screen->AddWindow(gamewin);
+
2291 }
+
2292 
+
2293 // +--------------------------------------------------------------------+
2294 
-
2295 // +--------------------------------------------------------------------+
-
2296 
-
2297 void
-
2298 Starshatter::SetupMenuScreen()
-
2299 {
-
2300  if (menuscreen) {
-
2301  delete menuscreen;
-
2302  menuscreen = 0;
-
2303  }
-
2304 
-
2305  menuscreen = new(__FILE__,__LINE__) MenuScreen();
-
2306  menuscreen->Setup(screen);
-
2307 }
+
2295 void
+
2296 Starshatter::SetupMenuScreen()
+
2297 {
+
2298  if (menuscreen) {
+
2299  delete menuscreen;
+
2300  menuscreen = 0;
+
2301  }
+
2302 
+
2303  menuscreen = new(__FILE__,__LINE__) MenuScreen();
+
2304  menuscreen->Setup(screen);
+
2305 }
+
2306 
+
2307 // +--------------------------------------------------------------------+
2308 
-
2309 // +--------------------------------------------------------------------+
-
2310 
-
2311 void
-
2312 Starshatter::SetupCmpnScreen()
-
2313 {
-
2314  if (cmpnscreen) {
-
2315  delete cmpnscreen;
-
2316  cmpnscreen = 0;
-
2317  }
-
2318 
-
2319  cmpnscreen = new(__FILE__,__LINE__) CmpnScreen();
-
2320  cmpnscreen->Setup(screen);
-
2321 }
+
2309 void
+
2310 Starshatter::SetupCmpnScreen()
+
2311 {
+
2312  if (cmpnscreen) {
+
2313  delete cmpnscreen;
+
2314  cmpnscreen = 0;
+
2315  }
+
2316 
+
2317  cmpnscreen = new(__FILE__,__LINE__) CmpnScreen();
+
2318  cmpnscreen->Setup(screen);
+
2319 }
+
2320 
+
2321 // +--------------------------------------------------------------------+
2322 
-
2323 // +--------------------------------------------------------------------+
-
2324 
-
2325 void
-
2326 Starshatter::SetupPlanScreen()
-
2327 {
-
2328  if (planscreen) {
-
2329  delete planscreen;
-
2330  planscreen = 0;
-
2331  }
-
2332 
-
2333  planscreen = new(__FILE__,__LINE__) PlanScreen();
-
2334  planscreen->Setup(screen);
-
2335 }
+
2323 void
+
2324 Starshatter::SetupPlanScreen()
+
2325 {
+
2326  if (planscreen) {
+
2327  delete planscreen;
+
2328  planscreen = 0;
+
2329  }
+
2330 
+
2331  planscreen = new(__FILE__,__LINE__) PlanScreen();
+
2332  planscreen->Setup(screen);
+
2333 }
+
2334 
+
2335 // +--------------------------------------------------------------------+
2336 
-
2337 // +--------------------------------------------------------------------+
-
2338 
-
2339 void
-
2340 Starshatter::SetupLoadScreen()
-
2341 {
-
2342  if (loadscreen) {
-
2343  delete loadscreen;
-
2344  loadscreen = 0;
-
2345  }
-
2346 
-
2347  loadscreen = new(__FILE__,__LINE__) LoadScreen();
-
2348  loadscreen->Setup(screen);
-
2349 }
+
2337 void
+
2338 Starshatter::SetupLoadScreen()
+
2339 {
+
2340  if (loadscreen) {
+
2341  delete loadscreen;
+
2342  loadscreen = 0;
+
2343  }
+
2344 
+
2345  loadscreen = new(__FILE__,__LINE__) LoadScreen();
+
2346  loadscreen->Setup(screen);
+
2347 }
+
2348 
+
2349 // +--------------------------------------------------------------------+
2350 
-
2351 // +--------------------------------------------------------------------+
-
2352 
-
2353 void
-
2354 Starshatter::SetupGameScreen()
-
2355 {
-
2356  if (gamescreen) {
-
2357  delete gamescreen;
-
2358  gamescreen = 0;
-
2359  }
-
2360 
-
2361  gamescreen = new(__FILE__,__LINE__) GameScreen();
-
2362  gamescreen->Setup(screen);
-
2363  gamescreen->SetFieldOfView(field_of_view);
-
2364 
-
2365  // initialize player_ship's MFD choices:
-
2366  Player::SelectPlayer(Player::GetCurrentPlayer());
-
2367 }
+
2351 void
+
2352 Starshatter::SetupGameScreen()
+
2353 {
+
2354  if (gamescreen) {
+
2355  delete gamescreen;
+
2356  gamescreen = 0;
+
2357  }
+
2358 
+
2359  gamescreen = new(__FILE__,__LINE__) GameScreen();
+
2360  gamescreen->Setup(screen);
+
2361  gamescreen->SetFieldOfView(field_of_view);
+
2362 
+
2363  // initialize player_ship's MFD choices:
+
2364  Player::SelectPlayer(Player::GetCurrentPlayer());
+
2365 }
+
2366 
+
2367 // +--------------------------------------------------------------------+
2368 
-
2369 // +--------------------------------------------------------------------+
-
2370 
-
2371 void
-
2372 Starshatter::LoadVideoConfig(const char* filename)
-
2373 {
-
2374  // set up defaults:
-
2375  int screen_width = 1024;
-
2376  int screen_height = 768;
-
2377  int screen_depth = 32;
-
2378  int terrain_detail_level = 3;
-
2379  bool shadows_enabled = true;
-
2380  bool spec_maps_enabled = true;
-
2381  bool bump_maps_enabled = true;
-
2382  bool vertex_shader = true;
-
2383  bool pixel_shader = true;
-
2384  float depth_bias = video_settings->depth_bias;
+
2369 void
+
2370 Starshatter::LoadVideoConfig(const char* filename)
+
2371 {
+
2372  // set up defaults:
+
2373  int screen_width = 1024;
+
2374  int screen_height = 768;
+
2375  int screen_depth = 32;
+
2376  int terrain_detail_level = 3;
+
2377  bool shadows_enabled = true;
+
2378  bool spec_maps_enabled = true;
+
2379  bool bump_maps_enabled = true;
+
2380  bool vertex_shader = true;
+
2381  bool pixel_shader = true;
+
2382  float depth_bias = video_settings->depth_bias;
+
2383 
+
2384  max_tex_size = 2048;
2385 
-
2386  max_tex_size = 2048;
-
2387 
-
2388  if (MachineInfo::GetCpuSpeed() >= 1000 && MachineInfo::GetTotalRam() > 128)
-
2389  terrain_detail_level = 4;
+
2386  if (MachineInfo::GetCpuSpeed() >= 1000 && MachineInfo::GetTotalRam() > 128)
+
2387  terrain_detail_level = 4;
+
2388 
+
2389  Terrain::SetDetailLevel(terrain_detail_level);
2390 
-
2391  Terrain::SetDetailLevel(terrain_detail_level);
-
2392 
-
2393  // read the config file:
-
2394  BYTE* block = 0;
-
2395  int blocklen = 0;
+
2391  // read the config file:
+
2392  BYTE* block = 0;
+
2393  int blocklen = 0;
+
2394 
+
2395  FILE* f = ::fopen(filename, "rb");
2396 
-
2397  FILE* f = ::fopen(filename, "rb");
-
2398 
-
2399  if (f) {
-
2400  ::fseek(f, 0, SEEK_END);
-
2401  blocklen = ftell(f);
-
2402  ::fseek(f, 0, SEEK_SET);
-
2403 
-
2404  block = new(__FILE__,__LINE__) BYTE[blocklen+1];
-
2405  block[blocklen] = 0;
-
2406 
-
2407  ::fread(block, blocklen, 1, f);
-
2408  ::fclose(f);
-
2409  }
-
2410 
-
2411  if (blocklen == 0)
-
2412  return;
-
2413 
-
2414  Parser parser(new(__FILE__,__LINE__) BlockReader((const char*) block, blocklen));
-
2415  Term* term = parser.ParseTerm();
-
2416 
-
2417  if (!term) {
-
2418  Print("ERROR: could not parse '%s'.\n", filename);
-
2419  exit(-3);
-
2420  }
-
2421  else {
-
2422  TermText* file_type = term->isText();
-
2423  if (!file_type || file_type->value() != "VIDEO") {
-
2424  Print("WARNING: invalid %s file. Using defaults\n", filename);
-
2425  return;
-
2426  }
-
2427  }
-
2428 
-
2429  do {
-
2430  delete term;
-
2431 
-
2432  term = parser.ParseTerm();
-
2433 
-
2434  if (term) {
-
2435  TermDef* def = term->isDef();
-
2436  if (def) {
-
2437  if (def->name()->value() == "width") {
-
2438  int w;
-
2439  GetDefNumber(w, def, filename);
-
2440 
-
2441  switch (w) {
-
2442  case 800:
-
2443  screen_width = 800;
-
2444  screen_height = 600;
-
2445  break;
-
2446 
-
2447  case 1024:
-
2448  screen_width = 1024;
-
2449  screen_height = 768;
-
2450  break;
-
2451 
-
2452  case 1152:
-
2453  screen_width = 1152;
-
2454  screen_height = 864;
-
2455  break;
-
2456 
-
2457  case 1280:
-
2458  screen_width = 1280;
-
2459  screen_height = 960;
-
2460  break;
-
2461 
-
2462  case 1440:
-
2463  screen_width = 1440;
-
2464  screen_height = 900;
-
2465  break;
-
2466 
-
2467  default:
-
2468  screen_width = w;
-
2469  screen_height = (w*3)/4;
-
2470  break;
-
2471  }
-
2472  }
-
2473 
-
2474  else if (def->name()->value() == "height") {
-
2475  int h;
-
2476  GetDefNumber(h, def, filename);
-
2477 
-
2478  if (screen_width == 1280 && (h == 800 || h == 1024))
+
2397  if (f) {
+
2398  ::fseek(f, 0, SEEK_END);
+
2399  blocklen = ftell(f);
+
2400  ::fseek(f, 0, SEEK_SET);
+
2401 
+
2402  block = new(__FILE__,__LINE__) BYTE[blocklen+1];
+
2403  block[blocklen] = 0;
+
2404 
+
2405  ::fread(block, blocklen, 1, f);
+
2406  ::fclose(f);
+
2407  }
+
2408 
+
2409  if (blocklen == 0)
+
2410  return;
+
2411 
+
2412  Parser parser(new(__FILE__,__LINE__) BlockReader((const char*) block, blocklen));
+
2413  Term* term = parser.ParseTerm();
+
2414 
+
2415  if (!term) {
+
2416  Print("ERROR: could not parse '%s'.\n", filename);
+
2417  exit(-3);
+
2418  }
+
2419  else {
+
2420  TermText* file_type = term->isText();
+
2421  if (!file_type || file_type->value() != "VIDEO") {
+
2422  Print("WARNING: invalid %s file. Using defaults\n", filename);
+
2423  return;
+
2424  }
+
2425  }
+
2426 
+
2427  do {
+
2428  delete term;
+
2429 
+
2430  term = parser.ParseTerm();
+
2431 
+
2432  if (term) {
+
2433  TermDef* def = term->isDef();
+
2434  if (def) {
+
2435  if (def->name()->value() == "width") {
+
2436  int w;
+
2437  GetDefNumber(w, def, filename);
+
2438 
+
2439  switch (w) {
+
2440  case 800:
+
2441  screen_width = 800;
+
2442  screen_height = 600;
+
2443  break;
+
2444 
+
2445  case 1024:
+
2446  screen_width = 1024;
+
2447  screen_height = 768;
+
2448  break;
+
2449 
+
2450  case 1152:
+
2451  screen_width = 1152;
+
2452  screen_height = 864;
+
2453  break;
+
2454 
+
2455  case 1280:
+
2456  screen_width = 1280;
+
2457  screen_height = 960;
+
2458  break;
+
2459 
+
2460  case 1440:
+
2461  screen_width = 1440;
+
2462  screen_height = 900;
+
2463  break;
+
2464 
+
2465  default:
+
2466  screen_width = w;
+
2467  screen_height = (w*3)/4;
+
2468  break;
+
2469  }
+
2470  }
+
2471 
+
2472  else if (def->name()->value() == "height") {
+
2473  int h;
+
2474  GetDefNumber(h, def, filename);
+
2475 
+
2476  if (screen_width == 1280 && (h == 800 || h == 1024))
+
2477  screen_height = h;
+
2478  else if (screen_width == 1600 && (h == 900 || h == 1200))
2479  screen_height = h;
-
2480  else if (screen_width == 1600 && (h == 900 || h == 1200))
-
2481  screen_height = h;
-
2482  }
-
2483 
-
2484  else if (def->name()->value() == "depth" ||
-
2485  def->name()->value() == "bpp") {
-
2486 
-
2487  int bpp;
-
2488  GetDefNumber(bpp, def, filename);
-
2489 
-
2490  switch (bpp) {
-
2491  case 8:
-
2492  case 16:
-
2493  case 24:
-
2494  case 32:
-
2495  screen_depth = bpp;
-
2496  break;
-
2497 
-
2498  default:
-
2499  Print("WARNING: Invalid screen bpp (%d) in '%s'\n", bpp, filename);
-
2500  screen_depth = 8;
-
2501  break;
-
2502  }
-
2503  }
-
2504 
-
2505  else if (def->name()->value() == "max_tex") {
-
2506  int n;
-
2507  GetDefNumber(n, def, filename);
-
2508  if (n >= 64 && n <= 4096)
-
2509  max_tex_size = n;
-
2510  }
-
2511 
-
2512  else if (def->name()->value() == "gamma") {
-
2513  int level;
-
2514  GetDefNumber(level, def, filename);
-
2515  if (level >= 0 && level <= 255)
-
2516  gamma = level;
-
2517  }
-
2518 
-
2519  else if (def->name()->value() == "terrain_detail_level") {
-
2520  GetDefNumber(terrain_detail_level, def, filename);
-
2521  Terrain::SetDetailLevel(terrain_detail_level);
-
2522  }
-
2523 
-
2524  else if (def->name()->value() == "terrain_texture_enable") {
-
2525  bool enable;
-
2526  GetDefBool(enable, def, filename);
-
2527 
-
2528  // no longer supported!
-
2529  }
-
2530 
-
2531  else if (def->name()->value() == "shadows") {
-
2532  GetDefBool(shadows_enabled, def, filename);
-
2533  }
-
2534 
-
2535  else if (def->name()->value() == "spec_maps") {
-
2536  GetDefBool(spec_maps_enabled, def, filename);
-
2537  }
-
2538 
-
2539  else if (def->name()->value() == "bump_maps") {
-
2540  GetDefBool(bump_maps_enabled, def, filename);
-
2541  }
-
2542 
-
2543  else if (def->name()->value() == "vertex_shader") {
-
2544  GetDefBool(vertex_shader, def, filename);
-
2545  }
-
2546 
-
2547  else if (def->name()->value() == "pixel_shader") {
-
2548  GetDefBool(pixel_shader, def, filename);
-
2549  }
-
2550 
-
2551  else if (def->name()->value().contains("bias")) {
-
2552  GetDefNumber(depth_bias, def, filename);
-
2553  }
-
2554 
-
2555  else if (def->name()->value() == "flare") {
-
2556  bool b;
-
2557  GetDefBool(b, def, filename);
-
2558  lens_flare = b;
-
2559  }
-
2560 
-
2561  else if (def->name()->value() == "corona") {
-
2562  bool b;
-
2563  GetDefBool(b, def, filename);
-
2564  corona = b;
-
2565  }
-
2566 
-
2567  else if (def->name()->value() == "nebula") {
-
2568  bool b;
-
2569  GetDefBool(b, def, filename);
-
2570  nebula = b;
-
2571  }
-
2572 
-
2573  else if (def->name()->value() == "dust") {
-
2574  GetDefNumber(dust, def, filename);
-
2575  }
-
2576 
-
2577  else if (def->name()->value().indexOf("cam_range") == 0) {
-
2578  double range_max = 0;
-
2579  GetDefNumber(range_max, def, filename);
-
2580  CameraDirector::SetRangeLimit(range_max);
-
2581  }
-
2582  }
-
2583  else {
-
2584  Print("WARNING: term ignored in '%s'\n", filename);
-
2585  term->print();
-
2586  }
-
2587  }
-
2588  }
-
2589  while (term);
+
2480  }
+
2481 
+
2482  else if (def->name()->value() == "depth" ||
+
2483  def->name()->value() == "bpp") {
+
2484 
+
2485  int bpp;
+
2486  GetDefNumber(bpp, def, filename);
+
2487 
+
2488  switch (bpp) {
+
2489  case 8:
+
2490  case 16:
+
2491  case 24:
+
2492  case 32:
+
2493  screen_depth = bpp;
+
2494  break;
+
2495 
+
2496  default:
+
2497  Print("WARNING: Invalid screen bpp (%d) in '%s'\n", bpp, filename);
+
2498  screen_depth = 8;
+
2499  break;
+
2500  }
+
2501  }
+
2502 
+
2503  else if (def->name()->value() == "max_tex") {
+
2504  int n;
+
2505  GetDefNumber(n, def, filename);
+
2506  if (n >= 64 && n <= 4096)
+
2507  max_tex_size = n;
+
2508  }
+
2509 
+
2510  else if (def->name()->value() == "gamma") {
+
2511  int level;
+
2512  GetDefNumber(level, def, filename);
+
2513  if (level >= 0 && level <= 255)
+
2514  gamma = level;
+
2515  }
+
2516 
+
2517  else if (def->name()->value() == "terrain_detail_level") {
+
2518  GetDefNumber(terrain_detail_level, def, filename);
+
2519  Terrain::SetDetailLevel(terrain_detail_level);
+
2520  }
+
2521 
+
2522  else if (def->name()->value() == "terrain_texture_enable") {
+
2523  bool enable;
+
2524  GetDefBool(enable, def, filename);
+
2525 
+
2526  // no longer supported!
+
2527  }
+
2528 
+
2529  else if (def->name()->value() == "shadows") {
+
2530  GetDefBool(shadows_enabled, def, filename);
+
2531  }
+
2532 
+
2533  else if (def->name()->value() == "spec_maps") {
+
2534  GetDefBool(spec_maps_enabled, def, filename);
+
2535  }
+
2536 
+
2537  else if (def->name()->value() == "bump_maps") {
+
2538  GetDefBool(bump_maps_enabled, def, filename);
+
2539  }
+
2540 
+
2541  else if (def->name()->value() == "vertex_shader") {
+
2542  GetDefBool(vertex_shader, def, filename);
+
2543  }
+
2544 
+
2545  else if (def->name()->value() == "pixel_shader") {
+
2546  GetDefBool(pixel_shader, def, filename);
+
2547  }
+
2548 
+
2549  else if (def->name()->value().contains("bias")) {
+
2550  GetDefNumber(depth_bias, def, filename);
+
2551  }
+
2552 
+
2553  else if (def->name()->value() == "flare") {
+
2554  bool b;
+
2555  GetDefBool(b, def, filename);
+
2556  lens_flare = b;
+
2557  }
+
2558 
+
2559  else if (def->name()->value() == "corona") {
+
2560  bool b;
+
2561  GetDefBool(b, def, filename);
+
2562  corona = b;
+
2563  }
+
2564 
+
2565  else if (def->name()->value() == "nebula") {
+
2566  bool b;
+
2567  GetDefBool(b, def, filename);
+
2568  nebula = b;
+
2569  }
+
2570 
+
2571  else if (def->name()->value() == "dust") {
+
2572  GetDefNumber(dust, def, filename);
+
2573  }
+
2574 
+
2575  else if (def->name()->value().indexOf("cam_range") == 0) {
+
2576  double range_max = 0;
+
2577  GetDefNumber(range_max, def, filename);
+
2578  CameraDirector::SetRangeLimit(range_max);
+
2579  }
+
2580  }
+
2581  else {
+
2582  Print("WARNING: term ignored in '%s'\n", filename);
+
2583  term->print();
+
2584  }
+
2585  }
+
2586  }
+
2587  while (term);
+
2588 
+
2589  loader->ReleaseBuffer(block);
2590 
-
2591  loader->ReleaseBuffer(block);
-
2592 
-
2593  if (video_settings) {
-
2594  video_settings->fullscreen_mode.width = screen_width;
-
2595  video_settings->fullscreen_mode.height = screen_height;
-
2596 
-
2597  if (screen_depth == 16)
-
2598  video_settings->fullscreen_mode.format = VideoMode::FMT_R5G6B5;
-
2599  else
-
2600  video_settings->fullscreen_mode.format = VideoMode::FMT_X8R8G8B8;
-
2601 
-
2602  video_settings->shadows = shadows_enabled;
-
2603  video_settings->specmaps = spec_maps_enabled;
-
2604  video_settings->bumpmaps = bump_maps_enabled;
-
2605  video_settings->enable_vs = vertex_shader;
-
2606  video_settings->enable_ps = pixel_shader;
-
2607  video_settings->depth_bias = depth_bias;
-
2608  }
-
2609 
-
2610  if (video) {
-
2611  video->SetShadowEnabled(shadows_enabled);
-
2612  video->SetSpecMapEnabled(spec_maps_enabled);
-
2613  video->SetBumpMapEnabled(bump_maps_enabled);
-
2614  }
-
2615 }
+
2591  if (video_settings) {
+
2592  video_settings->fullscreen_mode.width = screen_width;
+
2593  video_settings->fullscreen_mode.height = screen_height;
+
2594 
+
2595  if (screen_depth == 16)
+
2596  video_settings->fullscreen_mode.format = VideoMode::FMT_R5G6B5;
+
2597  else
+
2598  video_settings->fullscreen_mode.format = VideoMode::FMT_X8R8G8B8;
+
2599 
+
2600  video_settings->shadows = shadows_enabled;
+
2601  video_settings->specmaps = spec_maps_enabled;
+
2602  video_settings->bumpmaps = bump_maps_enabled;
+
2603  video_settings->enable_vs = vertex_shader;
+
2604  video_settings->enable_ps = pixel_shader;
+
2605  video_settings->depth_bias = depth_bias;
+
2606  }
+
2607 
+
2608  if (video) {
+
2609  video->SetShadowEnabled(shadows_enabled);
+
2610  video->SetSpecMapEnabled(spec_maps_enabled);
+
2611  video->SetBumpMapEnabled(bump_maps_enabled);
+
2612  }
+
2613 }
+
2614 
+
2615 // +--------------------------------------------------------------------+
2616 
-
2617 // +--------------------------------------------------------------------+
-
2618 
-
2619 void
-
2620 Starshatter::SaveVideoConfig(const char* filename)
-
2621 {
-
2622  if (!video_settings)
-
2623  return;
-
2624 
-
2625  FILE* f = fopen(filename, "w");
-
2626  if (f) {
-
2627  fprintf(f, "VIDEO\n\n");
-
2628  fprintf(f, "width: %4d\n", video_settings->fullscreen_mode.width);
-
2629  fprintf(f, "height: %4d\n", video_settings->fullscreen_mode.height);
-
2630  fprintf(f, "depth: %4d\n", video_settings->fullscreen_mode.format == VideoMode::FMT_R5G6B5 ? 16 : 32);
-
2631  fprintf(f, "\n");
-
2632  fprintf(f, "max_tex: %4d\n", max_tex_size);
-
2633  fprintf(f, "primary3D: %s\n", "true");
-
2634  fprintf(f, "gamma: %4d\n", gamma);
-
2635  fprintf(f, "\n");
-
2636  fprintf(f, "terrain_detail_level: %d\n", Terrain::DetailLevel());
-
2637  fprintf(f, "terrain_texture_enable: %true\n");
-
2638  fprintf(f, "\n");
-
2639 
-
2640  fprintf(f, "shadows: %s\n", video_settings->shadows ? "true" : "false");
-
2641  fprintf(f, "spec_maps: %s\n", video_settings->specmaps ? "true" : "false");
-
2642  fprintf(f, "bump_maps: %s\n", video_settings->bumpmaps ? "true" : "false");
-
2643  fprintf(f, "bias: %f\n", video_settings->depth_bias);
-
2644  fprintf(f, "\n");
-
2645 
-
2646  fprintf(f, "flare: %s\n", lens_flare ? "true" : "false");
-
2647  fprintf(f, "corona: %s\n", corona ? "true" : "false");
-
2648  fprintf(f, "nebula: %s\n", nebula ? "true" : "false");
-
2649  fprintf(f, "dust: %d\n", dust);
-
2650 
-
2651  if (CameraDirector::GetRangeLimit() != 300e3)
-
2652  fprintf(f, " cam_range_max: %f,\n", CameraDirector::GetRangeLimit());
-
2653 
-
2654  fclose(f);
-
2655  }
-
2656 
-
2657  video_changed = false;
-
2658 }
+
2617 void
+
2618 Starshatter::SaveVideoConfig(const char* filename)
+
2619 {
+
2620  if (!video_settings)
+
2621  return;
+
2622 
+
2623  FILE* f = fopen(filename, "w");
+
2624  if (f) {
+
2625  fprintf(f, "VIDEO\n\n");
+
2626  fprintf(f, "width: %4d\n", video_settings->fullscreen_mode.width);
+
2627  fprintf(f, "height: %4d\n", video_settings->fullscreen_mode.height);
+
2628  fprintf(f, "depth: %4d\n", video_settings->fullscreen_mode.format == VideoMode::FMT_R5G6B5 ? 16 : 32);
+
2629  fprintf(f, "\n");
+
2630  fprintf(f, "max_tex: %4d\n", max_tex_size);
+
2631  fprintf(f, "primary3D: %s\n", "true");
+
2632  fprintf(f, "gamma: %4d\n", gamma);
+
2633  fprintf(f, "\n");
+
2634  fprintf(f, "terrain_detail_level: %d\n", Terrain::DetailLevel());
+
2635  fprintf(f, "terrain_texture_enable: %true\n");
+
2636  fprintf(f, "\n");
+
2637 
+
2638  fprintf(f, "shadows: %s\n", video_settings->shadows ? "true" : "false");
+
2639  fprintf(f, "spec_maps: %s\n", video_settings->specmaps ? "true" : "false");
+
2640  fprintf(f, "bump_maps: %s\n", video_settings->bumpmaps ? "true" : "false");
+
2641  fprintf(f, "bias: %f\n", video_settings->depth_bias);
+
2642  fprintf(f, "\n");
+
2643 
+
2644  fprintf(f, "flare: %s\n", lens_flare ? "true" : "false");
+
2645  fprintf(f, "corona: %s\n", corona ? "true" : "false");
+
2646  fprintf(f, "nebula: %s\n", nebula ? "true" : "false");
+
2647  fprintf(f, "dust: %d\n", dust);
+
2648 
+
2649  if (CameraDirector::GetRangeLimit() != 300e3)
+
2650  fprintf(f, " cam_range_max: %f,\n", CameraDirector::GetRangeLimit());
+
2651 
+
2652  fclose(f);
+
2653  }
+
2654 
+
2655  video_changed = false;
+
2656 }
+
2657 
+
2658 // +--------------------------------------------------------------------+
2659 
-
2660 // +--------------------------------------------------------------------+
-
2661 
-
2662 void
-
2663 Starshatter::InvalidateTextureCache()
-
2664 {
-
2665  if (video)
-
2666  video->InvalidateCache();
-
2667 }
+
2660 void
+
2661 Starshatter::InvalidateTextureCache()
+
2662 {
+
2663  if (video)
+
2664  video->InvalidateCache();
+
2665 }
+
2666 
+
2667 // +--------------------------------------------------------------------+
2668 
-
2669 // +--------------------------------------------------------------------+
-
2670 
-
2671 void
-
2672 Starshatter::ExecCutscene(const char* msn_file, const char* path)
-
2673 {
-
2674  if (InCutscene() || !msn_file || !*msn_file) return;
-
2675 
-
2676  if (!world)
-
2677  CreateWorld();
-
2678 
-
2679  cutscene_mission = new(__FILE__,__LINE__) Mission(0);
-
2680  cutscene_basetime = StarSystem::GetBaseTime();
-
2681 
-
2682  if (cutscene_mission->Load(msn_file, path)) {
-
2683  Sim* sim = (Sim*) world;
-
2684 
-
2685  if (sim) {
-
2686  bool dynamic = false;
-
2687  Campaign* campaign = Campaign::GetCampaign();
-
2688 
-
2689  if (campaign && campaign->IsDynamic())
-
2690  dynamic = true;
-
2691 
-
2692  sim->UnloadMission();
-
2693  sim->LoadMission(cutscene_mission, true); // attempt to preload the tex cache
-
2694  sim->ExecMission();
-
2695  sim->ShowGrid(false);
-
2696  player_ship = sim->GetPlayerShip();
+
2669 void
+
2670 Starshatter::ExecCutscene(const char* msn_file, const char* path)
+
2671 {
+
2672  if (InCutscene() || !msn_file || !*msn_file) return;
+
2673 
+
2674  if (!world)
+
2675  CreateWorld();
+
2676 
+
2677  cutscene_mission = new(__FILE__,__LINE__) Mission(0);
+
2678  cutscene_basetime = StarSystem::GetBaseTime();
+
2679 
+
2680  if (cutscene_mission->Load(msn_file, path)) {
+
2681  Sim* sim = (Sim*) world;
+
2682 
+
2683  if (sim) {
+
2684  bool dynamic = false;
+
2685  Campaign* campaign = Campaign::GetCampaign();
+
2686 
+
2687  if (campaign && campaign->IsDynamic())
+
2688  dynamic = true;
+
2689 
+
2690  sim->UnloadMission();
+
2691  sim->LoadMission(cutscene_mission, true); // attempt to preload the tex cache
+
2692  sim->ExecMission();
+
2693  sim->ShowGrid(false);
+
2694  player_ship = sim->GetPlayerShip();
+
2695 
+
2696  Print(" Cutscene Instantiated.\n");
2697 
-
2698  Print(" Cutscene Instantiated.\n");
-
2699 
-
2700  UpdateWorld();
-
2701  }
-
2702  }
-
2703  else {
-
2704  delete cutscene_mission;
-
2705  cutscene_mission = 0;
-
2706  cutscene_basetime = 0;
-
2707  }
-
2708 }
-
2709 
-
2710 void
-
2711 Starshatter::BeginCutscene()
-
2712 {
-
2713  Sim* sim = Sim::GetSim();
-
2714 
-
2715  if (cutscene == 0 && !sim->IsNetGame()) {
-
2716  HUDView* hud_view = HUDView::GetInstance();
-
2717  if (hud_view)
-
2718  hud_view->SetHUDMode(HUDView::HUD_MODE_OFF);
-
2719 
-
2720  if (sim->GetPlayerShip())
-
2721  sim->GetPlayerShip()->SetControls(0);
+
2698  UpdateWorld();
+
2699  }
+
2700  }
+
2701  else {
+
2702  delete cutscene_mission;
+
2703  cutscene_mission = 0;
+
2704  cutscene_basetime = 0;
+
2705  }
+
2706 }
+
2707 
+
2708 void
+
2709 Starshatter::BeginCutscene()
+
2710 {
+
2711  Sim* sim = Sim::GetSim();
+
2712 
+
2713  if (cutscene == 0 && !sim->IsNetGame()) {
+
2714  HUDView* hud_view = HUDView::GetInstance();
+
2715  if (hud_view)
+
2716  hud_view->SetHUDMode(HUDView::HUD_MODE_OFF);
+
2717 
+
2718  if (sim->GetPlayerShip())
+
2719  sim->GetPlayerShip()->SetControls(0);
+
2720 
+
2721  AudioConfig* audio_cfg = AudioConfig::GetInstance();
2722 
-
2723  AudioConfig* audio_cfg = AudioConfig::GetInstance();
-
2724 
-
2725  if (audio_cfg) {
-
2726  cut_efx_volume = audio_cfg->GetEfxVolume();
-
2727  cut_wrn_volume = audio_cfg->GetWrnVolume();
-
2728  }
-
2729 
-
2730  Ship::SetFlightModel(Ship::FM_ARCADE);
-
2731  }
-
2732 
-
2733  cutscene++;
-
2734 }
-
2735 
-
2736 void
-
2737 Starshatter::EndCutscene()
-
2738 {
-
2739  cutscene--;
-
2740 
-
2741  if (cutscene == 0) {
-
2742  DisplayView* disp_view = DisplayView::GetInstance();
-
2743  if (disp_view)
-
2744  disp_view->ClearDisplay();
-
2745 
-
2746  HUDView* hud_view = HUDView::GetInstance();
-
2747  if (hud_view)
-
2748  hud_view->SetHUDMode(HUDView::HUD_MODE_TAC);
-
2749 
-
2750  Sim* sim = Sim::GetSim();
-
2751  if (sim->GetPlayerShip())
-
2752  sim->GetPlayerShip()->SetControls(sim->GetControls());
-
2753 
-
2754  if (cam_dir) {
-
2755  cam_dir->SetViewOrbital(0);
-
2756  CameraDirector::SetRangeLimits(10, CameraDirector::GetRangeLimit());
-
2757  cam_dir->SetOrbitPoint(PI/4,PI/4,1);
-
2758  cam_dir->SetOrbitRates(0,0,0);
-
2759  }
+
2723  if (audio_cfg) {
+
2724  cut_efx_volume = audio_cfg->GetEfxVolume();
+
2725  cut_wrn_volume = audio_cfg->GetWrnVolume();
+
2726  }
+
2727 
+
2728  Ship::SetFlightModel(Ship::FM_ARCADE);
+
2729  }
+
2730 
+
2731  cutscene++;
+
2732 }
+
2733 
+
2734 void
+
2735 Starshatter::EndCutscene()
+
2736 {
+
2737  cutscene--;
+
2738 
+
2739  if (cutscene == 0) {
+
2740  DisplayView* disp_view = DisplayView::GetInstance();
+
2741  if (disp_view)
+
2742  disp_view->ClearDisplay();
+
2743 
+
2744  HUDView* hud_view = HUDView::GetInstance();
+
2745  if (hud_view)
+
2746  hud_view->SetHUDMode(HUDView::HUD_MODE_TAC);
+
2747 
+
2748  Sim* sim = Sim::GetSim();
+
2749  if (sim->GetPlayerShip())
+
2750  sim->GetPlayerShip()->SetControls(sim->GetControls());
+
2751 
+
2752  if (cam_dir) {
+
2753  cam_dir->SetViewOrbital(0);
+
2754  CameraDirector::SetRangeLimits(10, CameraDirector::GetRangeLimit());
+
2755  cam_dir->SetOrbitPoint(PI/4,PI/4,1);
+
2756  cam_dir->SetOrbitRates(0,0,0);
+
2757  }
+
2758 
+
2759  AudioConfig* audio_cfg = AudioConfig::GetInstance();
2760 
-
2761  AudioConfig* audio_cfg = AudioConfig::GetInstance();
-
2762 
-
2763  if (audio_cfg) {
-
2764  audio_cfg->SetEfxVolume(cut_efx_volume);
-
2765  audio_cfg->SetWrnVolume(cut_wrn_volume);
-
2766  }
-
2767 
-
2768  Player* p = Player::GetCurrentPlayer();
-
2769  if (p)
-
2770  Ship::SetFlightModel(p->FlightModel());
-
2771  }
-
2772 }
-
2773 
-
2774 void
-
2775 Starshatter::EndMission()
-
2776 {
-
2777  if (cutscene_mission) {
-
2778  Sim* sim = Sim::GetSim();
-
2779 
-
2780  if (sim && sim->GetMission() == cutscene_mission) {
-
2781  ShipStats::Initialize();
-
2782  sim->UnloadMission();
-
2783 
-
2784  // restore world clock (true => absolute time reference)
-
2785  if (cutscene_basetime != 0)
-
2786  StarSystem::SetBaseTime(cutscene_basetime, true);
-
2787 
-
2788  delete cutscene_mission;
-
2789  cutscene_mission = 0;
-
2790  cutscene_basetime = 0;
-
2791 
-
2792  return;
-
2793  }
-
2794  }
-
2795 
-
2796  SetGameMode(Starshatter::PLAN_MODE);
-
2797 }
-
2798 
-
2799 Mission*
-
2800 Starshatter::GetCutsceneMission() const
-
2801 {
-
2802  return cutscene_mission;
-
2803 }
-
2804 
-
2805 const char*
-
2806 Starshatter::GetSubtitles() const
-
2807 {
-
2808  if (cutscene_mission)
-
2809  return cutscene_mission->Subtitles();
-
2810 
-
2811  return "";
-
2812 }
+
2761  if (audio_cfg) {
+
2762  audio_cfg->SetEfxVolume(cut_efx_volume);
+
2763  audio_cfg->SetWrnVolume(cut_wrn_volume);
+
2764  }
+
2765 
+
2766  Player* p = Player::GetCurrentPlayer();
+
2767  if (p)
+
2768  Ship::SetFlightModel(p->FlightModel());
+
2769  }
+
2770 }
+
2771 
+
2772 void
+
2773 Starshatter::EndMission()
+
2774 {
+
2775  if (cutscene_mission) {
+
2776  Sim* sim = Sim::GetSim();
+
2777 
+
2778  if (sim && sim->GetMission() == cutscene_mission) {
+
2779  ShipStats::Initialize();
+
2780  sim->UnloadMission();
+
2781 
+
2782  // restore world clock (true => absolute time reference)
+
2783  if (cutscene_basetime != 0)
+
2784  StarSystem::SetBaseTime(cutscene_basetime, true);
+
2785 
+
2786  delete cutscene_mission;
+
2787  cutscene_mission = 0;
+
2788  cutscene_basetime = 0;
+
2789 
+
2790  return;
+
2791  }
+
2792  }
+
2793 
+
2794  SetGameMode(Starshatter::PLAN_MODE);
+
2795 }
+
2796 
+
2797 Mission*
+
2798 Starshatter::GetCutsceneMission() const
+
2799 {
+
2800  return cutscene_mission;
+
2801 }
+
2802 
+
2803 const char*
+
2804 Starshatter::GetSubtitles() const
+
2805 {
+
2806  if (cutscene_mission)
+
2807  return cutscene_mission->Subtitles();
+
2808 
+
2809  return "";
+
2810 }
+
2811 
+
2812 // +--------------------------------------------------------------------+
2813 
-
2814 // +--------------------------------------------------------------------+
-
2815 
-
2816 int
-
2817 Starshatter::GetLobbyMode()
-
2818 {
-
2819  return lobby_mode;
-
2820 }
-
2821 
-
2822 void
-
2823 Starshatter::SetLobbyMode(int mode)
-
2824 {
-
2825  lobby_mode = mode;
-
2826 }
-
2827 
-
2828 void
-
2829 Starshatter::StartLobby()
-
2830 {
-
2831  if (!net_lobby) {
-
2832  if (lobby_mode == NET_LOBBY_SERVER) {
-
2833  NetServerConfig::Initialize();
-
2834  NetServerConfig* server_config = NetServerConfig::GetInstance();
-
2835 
-
2836  if (server_config)
-
2837  net_lobby = new(__FILE__,__LINE__) NetLobbyServer;
-
2838  }
-
2839 
-
2840  else {
-
2841  NetClientConfig* client_config = NetClientConfig::GetInstance();
-
2842  if (client_config)
-
2843  client_config->Login();
-
2844 
-
2845  net_lobby = NetLobby::GetInstance();
-
2846  }
-
2847  }
-
2848 
-
2849  lobby_mode = NET_LOBBY_CLIENT;
-
2850 }
-
2851 
-
2852 void
-
2853 Starshatter::StopLobby()
-
2854 {
-
2855  if (net_lobby) {
-
2856  if (net_lobby->IsServer()) {
-
2857  delete net_lobby;
-
2858  NetServerConfig::Close();
-
2859  }
-
2860 
-
2861  else {
-
2862  NetClientConfig* client_config = NetClientConfig::GetInstance();
-
2863  if (client_config)
-
2864  client_config->Logout();
-
2865  }
-
2866 
-
2867  net_lobby = 0;
-
2868  }
-
2869 
-
2870  lobby_mode = NET_LOBBY_CLIENT;
-
2871 }
-
2872 
-
2873 void
-
2874 Starshatter::StopNetGame()
-
2875 {
-
2876  // local server:
-
2877  NetLobby* lobby = NetLobby::GetInstance();
-
2878 
-
2879  if (lobby && lobby->IsServer()) {
-
2880  lobby->GameStop();
-
2881  }
-
2882 
-
2883  // client connected to remote server:
-
2884  else {
-
2885  NetClientConfig* config = NetClientConfig::GetInstance();
-
2886  if (config && config->GetHostRequest()) {
-
2887  config->Login();
+
2814 int
+
2815 Starshatter::GetLobbyMode()
+
2816 {
+
2817  return lobby_mode;
+
2818 }
+
2819 
+
2820 void
+
2821 Starshatter::SetLobbyMode(int mode)
+
2822 {
+
2823  lobby_mode = mode;
+
2824 }
+
2825 
+
2826 void
+
2827 Starshatter::StartLobby()
+
2828 {
+
2829  if (!net_lobby) {
+
2830  if (lobby_mode == NET_LOBBY_SERVER) {
+
2831  NetServerConfig::Initialize();
+
2832  NetServerConfig* server_config = NetServerConfig::GetInstance();
+
2833 
+
2834  if (server_config)
+
2835  net_lobby = new(__FILE__,__LINE__) NetLobbyServer;
+
2836  }
+
2837 
+
2838  else {
+
2839  NetClientConfig* client_config = NetClientConfig::GetInstance();
+
2840  if (client_config)
+
2841  client_config->Login();
+
2842 
+
2843  net_lobby = NetLobby::GetInstance();
+
2844  }
+
2845  }
+
2846 
+
2847  lobby_mode = NET_LOBBY_CLIENT;
+
2848 }
+
2849 
+
2850 void
+
2851 Starshatter::StopLobby()
+
2852 {
+
2853  if (net_lobby) {
+
2854  if (net_lobby->IsServer()) {
+
2855  delete net_lobby;
+
2856  NetServerConfig::Close();
+
2857  }
+
2858 
+
2859  else {
+
2860  NetClientConfig* client_config = NetClientConfig::GetInstance();
+
2861  if (client_config)
+
2862  client_config->Logout();
+
2863  }
+
2864 
+
2865  net_lobby = 0;
+
2866  }
+
2867 
+
2868  lobby_mode = NET_LOBBY_CLIENT;
+
2869 }
+
2870 
+
2871 void
+
2872 Starshatter::StopNetGame()
+
2873 {
+
2874  // local server:
+
2875  NetLobby* lobby = NetLobby::GetInstance();
+
2876 
+
2877  if (lobby && lobby->IsServer()) {
+
2878  lobby->GameStop();
+
2879  }
+
2880 
+
2881  // client connected to remote server:
+
2882  else {
+
2883  NetClientConfig* config = NetClientConfig::GetInstance();
+
2884  if (config && config->GetHostRequest()) {
+
2885  config->Login();
+
2886 
+
2887  NetLobbyClient* conn = config->GetConnection();
2888 
-
2889  NetLobbyClient* conn = config->GetConnection();
-
2890 
-
2891  if (conn) {
-
2892  conn->GameStop();
-
2893  conn->SelectMission(0);
-
2894  }
-
2895  }
-
2896  }
-
2897 }
+
2889  if (conn) {
+
2890  conn->GameStop();
+
2891  conn->SelectMission(0);
+
2892  }
+
2893  }
+
2894  }
+
2895 }