FS2_Open
Open source remastering of the Freespace 2 engine
fred.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #include "stdafx.h"
13 #include "FRED.h"
14 
15 #include "MainFrm.h"
16 #include "FREDDoc.h"
17 #include "FREDView.h"
18 #include "FredRender.h"
19 #include "Management.h"
20 
21 #include "graphics/2d.h"
22 #include "io/key.h"
23 #include "object/object.h"
24 #include "editor.h"
25 #include "CampaignTreeWnd.h"
26 #include "CampaignTreeView.h"
27 #include "CampaignEditorDlg.h"
29 
30 #include "AFXADV.H"
31 
32 #ifdef NDEBUG
33 #ifndef FRED
34 #error macro FRED is not defined when trying to build release Fred. Please define FRED macro in build settings in all Fred projects
35 #endif
36 #endif
37 
38 #ifdef _DEBUG
39 #undef THIS_FILE
40 static char THIS_FILE[] = __FILE__;
41 #endif
42 
43 
44 int Fred_running = 1;
46 int FrameCount = 0;
47 int Fred_active = 1;
48 int Update_window = 1;
50 
51 // Goober5000 - needed to restore compatibility with the changes in fs2_open
52 int Show_cpu = 0;
53 
60 
76 
78 // CFREDApp
79 
80 BEGIN_MESSAGE_MAP(CFREDApp, CWinApp)
81  //{{AFX_MSG_MAP(CFREDApp)
82  ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
83  ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
84  // NOTE - the ClassWizard will add and remove mapping macros here.
85  // DO NOT EDIT what you see in these blocks of generated code!
86  //}}AFX_MSG_MAP
87  // Standard file based document commands
88  ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
89  // Standard print setup command
90  ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
91 END_MESSAGE_MAP()
92 
94 // CFREDApp construction
95 
97 {
98  app_init = 0;
99 
101 
102 #ifndef NDEBUG
103  outwnd_init();
104 #endif
105 }
106 
108 {
110 }
111 
113 // The one and only CFREDApp object
114 
116 
118 // CFREDApp initialization
119 char *c;
120 char *tok = "whee";
122 {
123 
124 
125  // disable the debug memory stuff
126 // _CrtSetDbgFlag(~(_CRTDBG_ALLOC_MEM_DF) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
127 
128  // Standard initialization
129  // If you are not using these features and wish to reduce the size
130  // of your final executable, you should remove from the following
131  // the specific initialization routines you do not need.
132 
133 #ifdef _AFXDLL
134  Enable3dControls(); // Call this when using MFC in a shared DLL
135 #else
136  Enable3dControlsStatic(); // Call this when linking to MFC statically
137 #endif
138 
139  LoadStdProfileSettings(9); // Load standard INI file options (including MRU)
140  User_interface = GetProfileInt("Preferences", "User interface", User_interface);
141  Show_stars = GetProfileInt("Preferences", "Show stars", Show_stars);
142  Show_grid_positions = GetProfileInt("Preferences", "Show grid positions", Show_grid_positions);
143  Show_coordinates = GetProfileInt("Preferences", "Show coordinates", Show_coordinates);
144  Show_compass = GetProfileInt("Preferences", "Show compass", Show_compass);
145  Show_ship_models = GetProfileInt("Preferences", "Show ship models", Show_ship_models);
146  Show_ship_info = GetProfileInt("Preferences", "Show ship info", Show_ship_info);
147  Show_outlines = GetProfileInt("Preferences", "Show outlines", Show_outlines);
148  Show_waypoints = GetProfileInt("Preferences", "Show waypoints", Show_waypoints);
149  Show_sexp_help = GetProfileInt("Preferences", "Show sexp help", Show_sexp_help);
150  physics_speed = GetProfileInt("Preferences", "Physics speed", physics_speed);
151  physics_rot = GetProfileInt("Preferences", "Physics rotation", physics_rot);
152  Hide_ship_cues = GetProfileInt("Preferences", "Hide ship cues", Hide_ship_cues);
153  Hide_wing_cues = GetProfileInt("Preferences", "Hide wing cues", Hide_wing_cues);
154  Autosave_disabled = GetProfileInt("Preferences", "Autosave disabled", Autosave_disabled);
155  double_fine_gridlines = GetProfileInt("Preferences", "Double fine gridlines", double_fine_gridlines);
156  Aa_gridlines = GetProfileInt("Preferences", "Anti aliased gridlines", Aa_gridlines);
157  Show_dock_points = GetProfileInt("Preferences", "Show dock points", Show_dock_points);
158  Show_paths_fred = GetProfileInt("Preferences", "Show paths", Show_paths_fred);
159  Lighting_on = GetProfileInt("Preferences", "Lighting On", Lighting_on);
160 
161  // Goober5000
162  Format_fs2_open = GetProfileInt("Preferences", "FS2 open format", Format_fs2_open);
163  Format_fs2_retail = GetProfileInt("Preferences", "FS2 retail format", Format_fs2_retail);
164  Format_fs1_retail = GetProfileInt("Preferences", "FS1 retail format", Format_fs1_retail);
165 
166  read_window("Main window", &Main_wnd_data);
167  read_window("Ship window", &Ship_wnd_data);
168  read_window("Wing window", &Wing_wnd_data);
169  read_window("Waypoint window", &Waypoint_wnd_data);
170  read_window("Object window", &Object_wnd_data);
171  read_window("Mission goals window", &Mission_goals_wnd_data);
172  read_window("Messages window", &Messages_wnd_data);
173  read_window("Player window", &Player_wnd_data);
174  read_window("Events window", &Events_wnd_data);
175  read_window("Bg window", &Bg_wnd_data);
176  read_window("Briefing window", &Briefing_wnd_data);
177  read_window("Reinforcement window", &Reinforcement_wnd_data);
178  read_window("Starfield window", &Starfield_wnd_data);
179  read_window("Asteroid window", &Asteroid_wnd_data);
180  read_window("Mission notes window", &Mission_notes_wnd_data);
181  write_ini_file(1);
182 
183  // Register the application's document templates. Document templates
184  // serve as the connection between documents, frame windows and views.
185 
186  CSingleDocTemplate* pDocTemplate;
187  pDocTemplate = new CSingleDocTemplate(
189  RUNTIME_CLASS(CFREDDoc),
190  RUNTIME_CLASS(CMainFrame), // main SDI frame window
191  RUNTIME_CLASS(CFREDView));
192  AddDocTemplate(pDocTemplate);
193 
194  /* Goober5000: um, no, because this is extremely annoying
195  // Enable DDE Execute open
196  EnableShellOpen();
197  RegisterShellFileTypes(TRUE); */
198 
199  // setup the fred exe directory so CFILE can init properly
200  /*
201  c = GetCommandLine();
202  Assert(c != NULL);
203  if(c == NULL){
204  return FALSE;
205  }
206  tok = strtok(c, " \n");
207  Assert(tok != NULL);
208  if(tok == NULL){
209  return FALSE;
210  }
211  // Fred_exe_dir = strdup(c);
212  strcpy_s(Fred_exe_dir, tok);
213  */
214 
215  // we need a full path, and if run from a shell that may not happen, so work that case out...
216 
217  Assert( strlen(__argv[0]) > 2 );
218 
219  // see if we have a ':', and if not then assume that we don't have a full path
220  if (__argv[0][1] != ':') {
222  strcat_s(Fred_exe_dir, "\\");
223  strcat_s(Fred_exe_dir, __argv[0]);
224  } else {
225  strcpy_s(Fred_exe_dir, __argv[0]);
226  }
227 
229 
230  char *str_end = Fred_base_dir + strlen(Fred_base_dir) - 1; // last char
231 
232  while (*str_end != '//' && *str_end != '\\')
233  str_end--;
234  *str_end = '\0';
235 
236 
237  // Goober5000 - figure out where the FRED file dialog should go
238  if ((m_pRecentFileList != NULL) && (m_pRecentFileList->GetSize() > 0))
239  {
240  // use the most recently opened file to supply the default folder
241  m_sInitialDir = m_pRecentFileList->operator[](0); // lol syntax
242  }
243  else
244  {
245  // use FRED's own directory to search for missions
246  m_sInitialDir = Fred_base_dir;
247  m_sInitialDir += "\\data\\missions";
248  }
249 
250 
251  // Parse command line for standard shell commands, DDE, file open
252  CCommandLineInfo cmdInfo;
253  ParseCommandLine(cmdInfo);
254 
255  m_nCmdShow = Main_wnd_data.p.showCmd;
256 
257  OnFileNew();
258 
259  if(m_pMainWnd == NULL) return FALSE;
260 
261  // Enable drag/drop open
262  m_pMainWnd->DragAcceptFiles();
263 
264  h_cursor_move = LoadCursor(IDC_CURSOR1);
265  h_cursor_rotate = LoadCursor(IDC_CURSOR2);
266  return TRUE;
267 }
268 
270 // CAboutDlg dialog used for App About
271 
272 class CAboutDlg : public CDialog
273 {
274 public:
275  CAboutDlg();
276 
277 // Dialog Data
278  //{{AFX_DATA(CAboutDlg)
279  enum { IDD = IDD_ABOUTBOX };
280  //}}AFX_DATA
281 
282  // ClassWizard generated virtual function overrides
283  //{{AFX_VIRTUAL(CAboutDlg)
284  protected:
285  virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
286  //}}AFX_VIRTUAL
287 
288 // Implementation
289 protected:
290  //{{AFX_MSG(CAboutDlg)
291  afx_msg void OnBug();
292  afx_msg void OnForums();
293  //}}AFX_MSG
294  DECLARE_MESSAGE_MAP()
295 };
296 
298 {
299  //{{AFX_DATA_INIT(CAboutDlg)
300  //}}AFX_DATA_INIT
301 }
302 
303 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
304 {
305  CDialog::DoDataExchange(pDX);
306  //{{AFX_DATA_MAP(CAboutDlg)
307  //}}AFX_DATA_MAP
308 }
309 
310 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
311  //{{AFX_MSG_MAP(CAboutDlg)
312  ON_BN_CLICKED(IDC_BUG, OnBug)
313  ON_BN_CLICKED(IDC_FORUMS, OnForums)
314  //}}AFX_MSG_MAP
315 END_MESSAGE_MAP()
316 
317 // App command to run the dialog
318 void CFREDApp::OnAppAbout()
319 {
320  CAboutDlg aboutDlg;
321  aboutDlg.DoModal();
322 }
323 
324 // G5K - from http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/Q_20155824.html
326 {
327  // use the initial dir the first time we prompt for a file
328  // name. after a successful open, the file name will be
329  // changed to be the empty string and the default dir
330  // will be supplied by the CFileDialog internal memory
331  if(!DoPromptFileName(m_sInitialDir, AFX_IDS_OPENFILE, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, TRUE, NULL))
332  {
333  // open cancelled
334  return;
335  }
336  AfxGetApp()->OpenDocumentFile(m_sInitialDir);
337  // if returns NULL, the user has already been alerted
338 
339  // now erase the initial dir since we only want to use it once
340  m_sInitialDir.Empty();
341 }
342 
344 // CFREDApp commands
345 
346 char *edit_mode_text[] = {
347  "Ships",
348  "Waypoints",
349 };
350 /* "Grid",
351  "Wing",
352  "Object Relative"
353 };
354 */
355 
356 char *control_mode_text[] = {
357  "Camera",
358  "Object"
359 };
360 
362 {
363  CString str;
364 
365  CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
366  CStatusBar* pStatus = &pFrame->m_wndStatusBar;
367  //CStatusBarCtrl pStatusBarCtrl;
368 
369  if (pStatus) {
370 // pStatus->GetStatusBarCtrl().SetParts(NUM_STATUS_PARTS, parts);
371 
372  if (Marked)
373  str.Format("Marked: %d", Marked);
374  else
375  str = _T("");
376  pStatus->SetPaneText(1, str);
377 
378  if (viewpoint)
379  str.Format("Viewpoint: %s", object_name(view_obj));
380  else
381  str.Format("Viewpoint: Camera");
382 
383  pStatus->SetPaneText(2, str);
384 
385  if (FREDDoc_ptr->IsModified())
386  pStatus->SetPaneText(3, "MODIFIED");
387  else
388  pStatus->SetPaneText(3, "");
389 
390  str.Format("Units = %.1f Meters", The_grid->square_size);
391  pStatus->SetPaneText(4, str);
392 
393 // pStatus->SetPaneText(4, "abcdefg");
394 // pStatus->SetPaneText(4, "1234567890!");
395  }
396 
397 }
398 
399 #define MAX_PENDING_MESSAGES 16
400 
401 typedef struct {
402  int frame_to_process, hwnd, id, wparam, lparam;
404 
406 
407 // Process messages that needed to wait until a frame had gone by.
409 {
410  int i;
411 
412  for (i=0; i<MAX_PENDING_MESSAGES; i++)
413  if (Pending_messages[i].frame_to_process != -1)
414  if (Pending_messages[i].frame_to_process <= FrameCount) {
415  pending_message *pmp = &Pending_messages[i];
416  PostMessage((HWND) pmp->hwnd, pmp->id, pmp->wparam, pmp->lparam);
417  Pending_messages[i].frame_to_process = -1;
418  }
419 }
420 
421 // Add a message to be processed to a buffer.
422 // Wait skip_count frames before processing.
423 void add_pending_message(HWND hwnd, int id, int wparam, int lparam, int skip_count)
424 {
425  int i;
426 
427  for (i=0; i<MAX_PENDING_MESSAGES; i++)
428  if (Pending_messages[i].frame_to_process == -1) {
429  Pending_messages[i].hwnd = (int) hwnd;
430  Pending_messages[i].id = id;
431  Pending_messages[i].wparam = wparam;
432  Pending_messages[i].lparam = lparam;
433  Pending_messages[i].frame_to_process = FrameCount + skip_count;
434  }
435 }
436 
438 {
439  int i;
440 
441  for (i=0; i<MAX_PENDING_MESSAGES; i++)
442  Pending_messages[i].frame_to_process = -1;
443 }
444 
445 // void win32_blit(HDC hSrcDC, HPALETTE hPalette, int x, int y, int w, int h )
446 #if 0
447 void win32_blit(void *xx, void *yy, int x, int y, int w, int h )
448 {
449  HPALETTE hOldPalette = NULL;
450  HDC hdc = GetDC(hwndApp);
451 
452  if ( !hdc ) return;
453  if ( !fAppActive ) return;
454 
455  if (hPalette) {
456  hOldPalette = SelectPalette(hdc, hPalette, FALSE);
457  RealizePalette( hdc );
458  }
459 
460  BitBlt(hdc, 0, 0, w, h, hSrcDC, x, y, SRCCOPY);
461 
462  if ( hOldPalette )
463  SelectPalette(hdc, hOldPalette, FALSE);
464 
465  ReleaseDC( hwndApp, hdc );
466 }
467 #endif
468 
470 {
471  int adjust = 0;
472  CWnd *top, *wnd;
473 
474  if (!Show_sexp_help)
475  adjust = -SEXP_HELP_BOX_SIZE;
476 
477  if (!app_init) {
478  app_init = 1;
479  theApp.init_window(&Ship_wnd_data, &Ship_editor_dialog, adjust, 1);
480  theApp.init_window(&Wing_wnd_data, &Wing_editor_dialog, adjust, 1);
481  theApp.init_window(&Waypoint_wnd_data, &Waypoint_editor_dialog, 0, 1);
482  init_window(&Main_wnd_data, Fred_main_wnd);
483  Fred_main_wnd->SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
484 
485  Ship_editor_dialog.calc_cue_height();
486  Wing_editor_dialog.calc_cue_height();
487  }
488 
489  CWinApp::OnIdle(lCount);
490 // internal_integrity_check();
491  if (Update_ship) {
492  Ship_editor_dialog.initialize_data(1);
493  Update_ship = 0;
494  }
495 
496  if (Update_wing) {
497  Wing_editor_dialog.initialize_data(1);
498  Update_wing = 0;
499  }
500 
501  Prev_window = CFREDView::GetActiveWindow();
502 
503  // Find the root window of the active window
504  wnd = top = Prev_window;
505  while (wnd) {
506  top = wnd;
507  wnd = wnd->GetParent();
508  }
509 
510  // See if the active window is a child of Fred
511  if (Prev_window)
512  Fred_active = ( (top == Fred_main_wnd) || (top == Campaign_wnd) );
513  else
514  Fred_active = 0;
515 
516  if (!Fred_active)
517  return FALSE; // if fred isn't active, don't waste any time with it.
518 
519  game_do_frame(); // do stuff that needs doing, whether we render or not.
521 
522  if (!Update_window)
523  return FALSE;
524 
525  render_frame(); // "do the rendering!" Renders image to offscreen buffer
527 
528  FrameCount++;
529  return TRUE;
530 }
531 
533 {
534  if (Fred_active) {
535  Update_window++; // on idle will handle the drawing already.
536  return;
537  }
538 
539  if (!Fred_main_wnd)
540  return;
541 
542  render_frame(); // "do the rendering!"
543 
544  gr_flip();
545 
548 
549  FrameCount++;
550 }
551 
552 void CFREDApp::write_ini_file(int degree)
553 {
554  WriteProfileInt("Preferences", "User interface", User_interface);
555  WriteProfileInt("Preferences", "Show stars", Show_stars);
556  WriteProfileInt("Preferences", "Show grid positions", Show_grid_positions);
557  WriteProfileInt("Preferences", "Show coordinates", Show_coordinates);
558  WriteProfileInt("Preferences", "Show compass", Show_compass);
559  WriteProfileInt("Preferences", "Show ship models", Show_ship_models);
560  WriteProfileInt("Preferences", "Show ship info", Show_ship_info);
561  WriteProfileInt("Preferences", "Show outlines", Show_outlines);
562  WriteProfileInt("Preferences", "Physics speed", physics_speed);
563  WriteProfileInt("Preferences", "Physics rotation", physics_rot);
564  WriteProfileInt("Preferences", "Show waypoints", Show_waypoints);
565  WriteProfileInt("Preferences", "Show sexp help", Show_sexp_help);
566  WriteProfileInt("Preferences", "Hide ship cues", Hide_ship_cues);
567  WriteProfileInt("Preferences", "Hide wing cues", Hide_wing_cues);
568  WriteProfileInt("Preferences", "Autosave disabled", Autosave_disabled);
569  WriteProfileInt("Preferences", "Double fine gridlines", double_fine_gridlines);
570  WriteProfileInt("Preferences", "Anti aliased gridlines", Aa_gridlines);
571  WriteProfileInt("Preferences", "Show dock points", Show_dock_points);
572  WriteProfileInt("Preferences", "Show paths", Show_paths_fred);
573  WriteProfileInt("Preferences", "Lighting On", Lighting_on);
574 
575  // Goober5000
576  WriteProfileInt("Preferences", "FS2 open format", Format_fs2_open);
577  WriteProfileInt("Preferences", "FS2 retail format", Format_fs2_retail);
578  WriteProfileInt("Preferences", "FS1 retail format", Format_fs1_retail);
579 
580  if (!degree) {
581  record_window_data(&Waypoint_wnd_data, &Waypoint_editor_dialog);
582  record_window_data(&Wing_wnd_data, &Wing_editor_dialog);
583  record_window_data(&Ship_wnd_data, &Ship_editor_dialog);
584  record_window_data(&Main_wnd_data, Fred_main_wnd);
585 
586  write_window("Main window", &Main_wnd_data);
587  write_window("Ship window", &Ship_wnd_data);
588  write_window("Wing window", &Wing_wnd_data);
589  write_window("Waypoint window", &Waypoint_wnd_data);
590  write_window("Object window", &Object_wnd_data);
591  write_window("Mission goals window", &Mission_goals_wnd_data);
592  write_window("Messages window", &Messages_wnd_data);
593  write_window("Player window", &Player_wnd_data);
594  write_window("Events window", &Events_wnd_data);
595  write_window("Bg window", &Bg_wnd_data);
596  write_window("Briefing window", &Briefing_wnd_data);
597  write_window("Reinforcement window", &Reinforcement_wnd_data);
598  write_window("Starfield window", &Starfield_wnd_data);
599  write_window("Asteroid window", &Asteroid_wnd_data);
600  write_window("Mission notes window", &Mission_notes_wnd_data);
601  }
602 }
603 
605 {
606  WriteProfileInt(name, "valid", wndd->valid);
607  WriteProfileInt(name, "length", wndd->p.length);
608  WriteProfileInt(name, "flags", wndd->p.flags);
609  WriteProfileInt(name, "showCmd", wndd->p.showCmd);
610  WriteProfileInt(name, "ptMinPosition.x", wndd->p.ptMinPosition.x);
611  WriteProfileInt(name, "ptMinPosition.y", wndd->p.ptMinPosition.y);
612  WriteProfileInt(name, "ptMaxPosition.x", wndd->p.ptMaxPosition.x);
613  WriteProfileInt(name, "ptMaxPosition.y", wndd->p.ptMaxPosition.y);
614  WriteProfileInt(name, "rcNormalPosition.left", wndd->p.rcNormalPosition.left);
615  WriteProfileInt(name, "rcNormalPosition.top", wndd->p.rcNormalPosition.top);
616  WriteProfileInt(name, "rcNormalPosition.right", wndd->p.rcNormalPosition.right);
617  WriteProfileInt(name, "rcNormalPosition.bottom", wndd->p.rcNormalPosition.bottom);
618  WriteProfileInt(name, "Visible", wndd->visible);
619 }
620 
622 {
623  wndd->processed = 0;
624  wndd->valid = GetProfileInt(name, "valid", FALSE);
625  wndd->p.length = GetProfileInt(name, "length", 0);
626  wndd->p.flags = GetProfileInt(name, "flags", 0);
627  wndd->p.showCmd = GetProfileInt(name, "showCmd", SW_SHOWMAXIMIZED);
628  wndd->p.ptMinPosition.x = GetProfileInt(name, "ptMinPosition.x", 0);
629  wndd->p.ptMinPosition.y = GetProfileInt(name, "ptMinPosition.y", 0);
630  wndd->p.ptMaxPosition.x = GetProfileInt(name, "ptMaxPosition.x", 0);
631  wndd->p.ptMaxPosition.y = GetProfileInt(name, "ptMaxPosition.y", 0);
632  wndd->p.rcNormalPosition.left = GetProfileInt(name, "rcNormalPosition.left", 0);
633  wndd->p.rcNormalPosition.top = GetProfileInt(name, "rcNormalPosition.top", 0);
634  wndd->p.rcNormalPosition.right = GetProfileInt(name, "rcNormalPosition.right", 0);
635  wndd->p.rcNormalPosition.bottom = GetProfileInt(name, "rcNormalPosition.bottom", 0);
636  wndd->visible = GetProfileInt(name, "Visible", 1);
637 }
638 
639 int CFREDApp::init_window(window_data *wndd, CWnd *wnd, int adjust, int pre)
640 {
641  int width, height;
642  WINDOWPLACEMENT p;
643 
644  if (pre && !wndd->visible)
645  return -1;
646 
647  if (wndd->processed)
648  return -2;
649 
650  Assert(wnd->GetSafeHwnd());
651  wnd->GetWindowPlacement(&p);
652  width = p.rcNormalPosition.right - p.rcNormalPosition.left;
653  height = p.rcNormalPosition.bottom - p.rcNormalPosition.top + adjust;
654  wndd->p.rcNormalPosition.right = wndd->p.rcNormalPosition.left + width;
655  wndd->p.rcNormalPosition.bottom = wndd->p.rcNormalPosition.top + height;
656 
657  if (wndd->valid) {
658  wnd->SetWindowPlacement(&wndd->p);
659 // if (!wndd->visible)
660 // wnd->ShowWindow(SW_SHOW);
661 // else
662 // wnd->ShowWindow(SW_HIDE);
663  }
664 
665  record_window_data(wndd, wnd);
666  wndd->processed = 1;
667  return 0;
668 }
669 
671 {
672  wnd->GetWindowPlacement(&wndd->p);
673  wndd->visible = wnd->IsWindowVisible();
674  wndd->valid = TRUE;
675 }
676 
678 {
679  char *path = "http://scp.indiegames.us/mantis/";
680 
681  char buffer[MAX_PATH];
682  sprintf(buffer,"explorer.exe \"%s\"", path);
683 
684  WinExec(buffer,SW_SHOW);
685 }
686 
688 {
689  char *path = "http://www.hard-light.net/forums/";
690 
691  char buffer[MAX_PATH];
692  sprintf(buffer,"explorer.exe \"%s\"", path);
693 
694  WinExec(buffer,SW_SHOW);
695 }
696 
698 {
699 
700  return CWinApp::ExitInstance();
701 }
702 
703 // Empty functions to make fred link with the sexp_mission_set_subspace
706 
707 // Variables to make fred.ccp more like freespace2.cpp so fred will link
708 float Sun_spot = 0.0f;
void record_window_data(window_data *wndd, CWnd *wnd)
Definition: fred.cpp:670
#define IDC_CURSOR1
Definition: resource.h:70
void * HWND
Definition: config.h:104
int i
Definition: multi_pxo.cpp:466
CFREDApp theApp
Definition: fred.cpp:115
void show_control_mode(void)
Definition: fred.cpp:361
window_data Main_wnd_data
Definition: fred.cpp:61
int Aa_gridlines
Definition: fredrender.cpp:74
float square_size
Definition: missiongrid.h:26
window_data Reinforcement_wnd_data
Definition: fred.cpp:71
void init_pending_messages(void)
Definition: fred.cpp:437
int Show_coordinates
Definition: fredrender.cpp:85
int Show_outlines
Definition: fredrender.cpp:82
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
void gr_flip()
Definition: 2d.cpp:2113
void calc_cue_height()
void outwnd_init(int display_under_freespace_window)
Definition: outwnd.cpp:1165
window_data Object_wnd_data
Definition: fred.cpp:64
CShipEditorDlg Ship_editor_dialog
Definition: fred.cpp:55
window_data Waypoint_wnd_data
Definition: fred.cpp:72
void render_frame()
int Format_fs1_retail
Definition: fredview.cpp:122
#define MAX_PATH
int Fred_running
Definition: fred.cpp:44
char * object_name(int obj)
CAboutDlg()
Definition: fred.cpp:297
int visible
Definition: fred.h:42
Assert(pm!=NULL)
int init_window(window_data *wndd, CWnd *wnd, int adjust=0, int pre=0)
Definition: fred.cpp:639
int Show_paths_fred
Definition: fredview.cpp:94
#define HOFFOSS_INTERFACE
Definition: fred.h:37
void write_ini_file(int degree=0)
Definition: fred.cpp:552
afx_msg void OnFileOpen()
Definition: fred.cpp:325
#define TRUE
Definition: pstypes.h:399
#define IDC_BUG
Definition: resource.h:338
int FrameCount
Definition: fred.cpp:46
window_data Starfield_wnd_data
Definition: fred.cpp:73
CMainFrame * Fred_main_wnd
Definition: mainfrm.cpp:89
int physics_speed
Definition: fredview.cpp:105
int Marked
Definition: fredview.cpp:101
void game_start_subspace_ambient_sound()
Definition: fred.cpp:704
void SCP_mspdbcs_Initialise()
bg_bitmap_dlg * Bg_bitmap_dialog
Definition: fred.cpp:58
int double_fine_gridlines
Definition: missiongrid.cpp:21
char * c
Definition: fred.cpp:119
window_data Mission_notes_wnd_data
Definition: fred.cpp:75
WINDOWPLACEMENT p
Definition: fred.h:41
GLint GLsizei width
Definition: Gl.h:1505
virtual void DoDataExchange(CDataExchange *pDX)
Definition: fred.cpp:303
window_data Messages_wnd_data
Definition: fred.cpp:66
void process_pending_messages(void)
Definition: fred.cpp:408
void SCP_mspdbcs_Cleanup()
window_data Mission_goals_wnd_data
Definition: fred.cpp:65
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
int physics_rot
Definition: fredview.cpp:106
int Show_ship_models
Definition: fredview.cpp:91
window_data Asteroid_wnd_data
Definition: fred.cpp:74
int User_interface
Definition: fred.cpp:45
float Sun_spot
Definition: fred.cpp:708
int Hide_ship_cues
Definition: fredview.cpp:113
int Show_stars
Definition: fredrender.cpp:83
int Update_wing
Definition: management.cpp:88
virtual BOOL OnIdle(LONG lCount)
Definition: fred.cpp:469
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
#define MAX_PENDING_MESSAGES
Definition: fred.cpp:399
Definition: fred.h:52
char * tok
Definition: fred.cpp:120
GLuint buffer
Definition: Glext.h:5492
CWnd * Prev_window
Definition: fred.cpp:54
CStatusBar m_wndStatusBar
Definition: mainfrm.h:51
void initialize_data(int full)
CFREDDoc * FREDDoc_ptr
Definition: freddoc.cpp:90
~CFREDApp()
Definition: fred.cpp:107
GLenum GLuint id
Definition: Glext.h:5156
HCURSOR h_cursor_move
Definition: fred.cpp:49
char Fred_base_dir[512]
Definition: management.cpp:91
#define IDR_MAINFRAME
Definition: resource.h:13
campaign_tree_wnd * Campaign_wnd
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
int viewpoint
Definition: fredview.cpp:98
int valid
Definition: fred.h:43
HCURSOR h_cursor_rotate
Definition: fred.cpp:49
virtual int ExitInstance()
Definition: fred.cpp:697
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
virtual BOOL InitInstance()
Definition: fred.cpp:121
long LONG
Definition: config.h:95
window_data Briefing_wnd_data
Definition: fred.cpp:70
int Autosave_disabled
Definition: fredview.cpp:86
int view_obj
Definition: fredview.cpp:99
char * control_mode_text[]
Definition: fred.cpp:356
wing_editor Wing_editor_dialog
Definition: fred.cpp:56
afx_msg void OnBug()
Definition: fred.cpp:677
int Show_grid_positions
Definition: fredrender.cpp:84
GLuint const GLchar * name
Definition: Glext.h:5608
int BOOL
Definition: config.h:80
void write_window(char *name, window_data *wndd)
Definition: fred.cpp:604
#define GetCurrentDirectory(i, s)
Definition: config.h:224
int Show_cpu
Definition: fred.cpp:52
#define IDC_FORUMS
Definition: resource.h:566
int Hide_wing_cues
Definition: fredview.cpp:113
GLint GLsizei GLsizei height
Definition: Gl.h:1505
#define strcat_s(...)
Definition: safe_strings.h:68
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
char * edit_mode_text[]
Definition: fred.cpp:346
pending_message Pending_messages[MAX_PENDING_MESSAGES]
Definition: fred.cpp:405
int Fred_active
Definition: fred.cpp:47
GLsizei const GLchar ** path
Definition: Glext.h:6795
int Show_dock_points
Definition: fredview.cpp:93
GLfloat GLfloat p
Definition: Glext.h:8373
waypoint_path_dlg Waypoint_editor_dialog
Definition: fred.cpp:57
window_data Ship_wnd_data
Definition: fred.cpp:62
int frame_to_process
Definition: fred.cpp:402
window_data Events_wnd_data
Definition: fred.cpp:68
void game_do_frame()
int Format_fs2_retail
Definition: fredview.cpp:121
int Format_fs2_open
Definition: fredview.cpp:120
int Update_ship
Definition: management.cpp:87
window_data Wing_wnd_data
Definition: fred.cpp:63
void game_stop_subspace_ambient_sound()
Definition: fred.cpp:705
void read_window(char *name, window_data *wndd)
Definition: fred.cpp:621
int Show_ship_info
Definition: fredview.cpp:90
grid * The_grid
Definition: missiongrid.cpp:20
int Show_compass
Definition: fredview.cpp:92
#define IDC_CURSOR2
Definition: resource.h:71
int processed
Definition: fred.h:44
briefing_editor_dlg * Briefing_dialog
Definition: fred.cpp:59
void add_pending_message(HWND hwnd, int id, int wparam, int lparam, int skip_count)
Definition: fred.cpp:423
afx_msg void OnForums()
Definition: fred.cpp:687
#define SEXP_HELP_BOX_SIZE
Definition: fredview.h:18
int Show_waypoints
Definition: object.cpp:73
GLdouble GLdouble GLdouble GLdouble top
Definition: Glext.h:10330
#define FALSE
Definition: pstypes.h:400
char Fred_exe_dir[512]
Definition: management.cpp:90
#define IDD_ABOUTBOX
Definition: resource.h:9
int Show_sexp_help
Definition: fredview.cpp:87
window_data Player_wnd_data
Definition: fred.cpp:67
GLint y
Definition: Gl.h:1505
int Update_window
Definition: fred.cpp:48
int Lighting_on
Definition: fredview.cpp:95
#define strcpy_s(...)
Definition: safe_strings.h:67
void update_map_window()
Definition: fred.cpp:532
void initialize_data(int full)
window_data Bg_wnd_data
Definition: fred.cpp:69