2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
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
10 * $Logfile: /Freespace2/code/fred2/FREDView.h $
15 * View class for a document/view architechure design program, which we don't
16 * want or need, but MFC forces us to use. This is the main place we handle
17 * MFC messages, events, etc. Sort of the interface between our code and MFC.
18 * There is also a lot of our code in here related to these things.
21 * Revision 1.2 2002/06/09 04:41:13 relnev
22 * added copyright header
24 * Revision 1.1.1.1 2002/05/03 03:28:12 root
28 * 6 6/04/99 2:20p Andsager
29 * Add dump stats basic functionality
31 * 5 3/26/99 4:49p Dave
32 * Made cruisers able to dock with stuff. Made docking points and paths
35 * 4 1/27/99 4:09p Andsager
36 * Added highlight to ship subsystems
38 * 3 10/13/98 9:27a Dave
39 * Started neatening up freespace.h
41 * 2 10/07/98 6:28p Dave
42 * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
43 * Fred. Globalized mission and campaign file extensions. Removed Silent
44 * Threat specific code.
46 * 1 10/07/98 3:01p Dave
48 * 1 10/07/98 3:00p Dave
50 * 84 5/21/98 11:48a Hoffoss
51 * Removed check in and check out options.
53 * 83 5/14/98 5:32p Hoffoss
54 * Added some more error checking.
56 * 82 4/01/98 10:48a Hoffoss
57 * Changed Fred to not allow command briefings in multiplayer missions.
59 * 81 3/25/98 4:14p Hoffoss
60 * Split ship editor up into ship editor and a misc dialog, which tracks
63 * 80 3/09/98 10:56a Hoffoss
64 * Added jump node objects to Fred.
66 * 79 3/05/98 3:59p Hoffoss
67 * Added a bunch of new command brief stuff, and asteroid initialization
70 * 78 1/29/98 5:14p Hoffoss
71 * Added error checking for more than 4 ships in a player starting wing.
73 * 77 10/30/97 3:30p Hoffoss
74 * Made anti-aliased gridlines an option in Fred.
76 * 76 10/14/97 10:59a Allender
77 * more persona work. Made global error checker call funciton to assign
80 * 75 9/06/97 2:13p Mike
81 * Replace support for TEAM_NEUTRAL
83 * 74 9/01/97 6:59p Hoffoss
84 * Added source safe checkin and checkout capabilities to Fred.
86 * 73 8/26/97 4:18p Hoffoss
87 * Added error checking to initial orders dialog when ok is clicked.
89 * 72 8/25/97 5:58p Hoffoss
90 * Created menu items for keypress functions in Fred, and fixed bug this
91 * uncovered with wing_delete function.
93 * 71 8/18/97 9:31p Hoffoss
94 * Added grid adjustment dialog and shield system editor dialog.
96 * 70 8/14/97 2:32p Hoffoss
97 * fixed bug where controlling an object doesn't cause screen updates, and
98 * added a number of cool features to viewpoint/control object code.
100 * 69 8/12/97 6:32p Hoffoss
101 * Added code to allow hiding of arrival and departure cues in editors.
103 * 68 8/11/97 6:54p Hoffoss
104 * Groups now supported in Fred.
106 * 67 8/11/97 11:51a Allender
107 * added stamp stuff to Fred
109 * 66 8/07/97 6:01p Hoffoss
110 * Added a rotate about selected object button to toolbar and
111 * functionality, as requested by Comet.
113 * 65 8/01/97 3:10p Hoffoss
114 * Made Sexp help hidable.
116 * 64 8/01/97 12:52p Hoffoss
117 * Added variable, fixed bug with global error check.
119 * 63 7/28/97 2:51p Hoffoss
120 * Re-evaluated and improved global error checker in Fred.
122 * 62 7/24/97 12:45p Hoffoss
123 * Added camera position save and restore.
125 * 61 7/08/97 2:03p Hoffoss
126 * Debriefing editor coded and implemented.
128 * 60 6/18/97 3:07p Hoffoss
129 * Wing ship names are 1 indexes instead of 0 indexed now.
131 * 59 6/09/97 4:57p Hoffoss
132 * Added autosave and undo to Fred.
134 * 58 6/05/97 6:10p Hoffoss
135 * Added features: Autosaving, object hiding. Also fixed some minor bugs.
137 * 57 6/02/97 11:52a Hoffoss
138 * Custom cursors displayed when over objects in different modes.
140 * 56 5/21/97 5:43p Hoffoss
141 * Added features requested on Todo list.
143 * 55 5/06/97 3:01p Hoffoss
144 * Added some accelerator keys.
146 * 54 5/05/97 5:44p Hoffoss
147 * Added specialized popup menu choices, save before running FreeSpace,
148 * and display filters.
150 * 53 5/05/97 9:42a Hoffoss
151 * Single axis contraint code changed to operate better.
153 * 52 4/24/97 5:15p Hoffoss
156 * 51 4/17/97 5:23p Hoffoss
157 * Implemented ability to run FreeSpace from Fred.
159 * 50 4/16/97 5:18p Hoffoss
160 * Moved Asteroid field editor stuff to a seperate dialog box.
162 * 49 4/11/97 4:22p Hoffoss
163 * Fixed bug in Sexp trees, moved Show starfield option to view menu and
164 * removed preferences dialog box.
166 * 48 3/12/97 12:40p Hoffoss
167 * Fixed bugs in wing object management functions, several small additions
168 * and rearrangements.
170 * 47 3/10/97 4:58p Hoffoss
171 * Added waypoint and start types to drop down toolbar combo box and fixed
172 * context menu new ship type selection to also work.
174 * 46 3/10/97 12:54p Hoffoss
175 * Added drop down combo box to toolbar and fixed compiling errors Mark
176 * (maybe Mike?) introduced to code.
178 * 45 3/06/97 3:35p Hoffoss
179 * Added Show_outline stuff, moved show options to the view menu, fixed a
180 * bug in message dialog editor.
182 * 44 3/04/97 6:27p Hoffoss
183 * Changes to Fred to handle new wing structure.
185 * 43 2/28/97 11:31a Hoffoss
186 * Implemented modeless dialog saving and restoring, and changed some
189 * 42 2/27/97 5:54p Hoffoss
190 * Implemented support for saving and restoring window positions.
192 * 41 2/17/97 5:28p Hoffoss
193 * Checked RCS headers, added them were missing, changing description to
194 * something better, etc where needed.
196 * 72 2/12/97 5:50p Hoffoss
197 * Expanded on error checking.
199 * 71 2/12/97 12:25p Hoffoss
200 * Expanded on global error checker, added initial orders conflict
201 * checking and warning, added waypoint editor dialog and code.
203 * 70 2/10/97 5:18p Hoffoss
204 * Global error checker work. Added checks for many things, but still
205 * more to add tomorrow!
207 * 69 2/04/97 3:09p Hoffoss
208 * Background bitmap editor implemented fully.
210 * 68 1/30/97 2:24p Hoffoss
211 * Added remaining mission file structures and implemented load/save of
217 #ifndef STAMPER_PROGRAM
221 #define WM_MENU_POPUP_SHIPS (WM_USER+6)
222 #define WM_MENU_POPUP_EDIT (WM_USER+7)
223 #define SEXP_HELP_BOX_SIZE 170
225 typedef struct Marking_box {
229 typedef struct subsys_to_render
233 ship_subsys *cur_subsys;
236 class CShipEditorDlg;
239 class CFREDView : public CView
243 int global_error_check_player_wings(int multi);
245 protected: // create from serialization only
247 DECLARE_DYNCREATE(CFREDView)
251 int global_error_check_mixed_player_wing(int w);
252 int fred_check_sexp(int sexp, int type, char *msg, ...);
253 int internal_error(char *msg, ...);
254 int error(char *msg, ...);
255 int global_error_check();
256 void place_background_bitmap(vector v);
257 void cycle_constraint();
258 CFREDDoc *GetDocument();
260 static CFREDView *GetView();
262 LONG OnGoodbye(UINT wParam, LONG lParam);
263 // LONG OnMenuPopupShips(CWnd *pWnd, CPoint point);
264 // LONG OnMenuPopupShips(UINT wParam, LONG lParam);
266 //BOOL m_ConfirmDeleting;
267 //BOOL m_ShowCapitalShips;
268 //BOOL m_ShowElevations;
269 //BOOL m_ShowFighters;
271 //BOOL m_ShowMiscObjects;
272 //BOOL m_ShowPlanets;
273 //BOOL m_ShowWaypoints;
279 // ClassWizard generated virtual function overrides
280 //{{AFX_VIRTUAL(CFREDView)
282 virtual void OnDraw(CDC* pDC); // overridden to draw this view
283 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
284 virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
285 virtual void OnInitialUpdate();
287 virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
288 virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
289 virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
294 virtual ~CFREDView();
296 virtual void AssertValid() const;
297 virtual void Dump(CDumpContext& dc) const;
300 // virtual void SEDlg_destroy();
302 // Generated message map functions
304 //{{AFX_MSG(CFREDView)
305 afx_msg void OnViewGrid();
306 afx_msg void OnUpdateViewGrid(CCmdUI* pCmdUI);
307 afx_msg void OnViewWaypoints();
308 afx_msg void OnUpdateViewWaypoints(CCmdUI* pCmdUI);
309 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
310 afx_msg void OnEditorsShips();
311 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
312 afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
313 afx_msg void OnSetFocus(CWnd* pOldWnd);
314 afx_msg void OnKillFocus(CWnd* pNewWnd);
315 afx_msg void OnSize(UINT nType, int cx, int cy);
316 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
317 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
318 afx_msg void OnMiscstuffShowshipsasicons();
319 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
320 afx_msg void OnEditPopupShowShipIcons();
321 afx_msg void OnUpdateEditPopupShowShipIcons(CCmdUI* pCmdUI);
322 afx_msg void OnEditPopupShowShipModels();
323 afx_msg void OnUpdateEditPopupShowShipModels(CCmdUI* pCmdUI);
324 afx_msg void OnMiscStatistics();
325 afx_msg void OnEditPopupShowCompass();
326 afx_msg void OnUpdateEditPopupShowCompass(CCmdUI* pCmdUI);
327 afx_msg void OnUpdateChangeViewpointExternal(CCmdUI* pCmdUI);
328 afx_msg void OnChangeViewpointExternal();
329 afx_msg void OnUpdateChangeViewpointFollow(CCmdUI* pCmdUI);
330 afx_msg void OnChangeViewpointFollow();
331 afx_msg void OnEditorsGoals();
332 afx_msg void OnSpeed1();
333 afx_msg void OnSpeed2();
334 afx_msg void OnSpeed5();
335 afx_msg void OnSpeed10();
336 afx_msg void OnUpdateSpeed1(CCmdUI* pCmdUI);
337 afx_msg void OnSpeed3();
338 afx_msg void OnSpeed8();
339 afx_msg void OnRot1();
340 afx_msg void OnRot2();
341 afx_msg void OnRot3();
342 afx_msg void OnRot4();
343 afx_msg void OnRot5();
344 afx_msg void OnUpdateSpeed2(CCmdUI* pCmdUI);
345 afx_msg void OnUpdateSpeed3(CCmdUI* pCmdUI);
346 afx_msg void OnUpdateSpeed5(CCmdUI* pCmdUI);
347 afx_msg void OnUpdateSpeed8(CCmdUI* pCmdUI);
348 afx_msg void OnUpdateSpeed10(CCmdUI* pCmdUI);
349 afx_msg void OnUpdateRot1(CCmdUI* pCmdUI);
350 afx_msg void OnUpdateRot2(CCmdUI* pCmdUI);
351 afx_msg void OnUpdateRot3(CCmdUI* pCmdUI);
352 afx_msg void OnUpdateRot4(CCmdUI* pCmdUI);
353 afx_msg void OnUpdateRot5(CCmdUI* pCmdUI);
354 afx_msg void OnControlModeCamera();
355 afx_msg void OnUpdateControlModeCamera(CCmdUI* pCmdUI);
356 afx_msg void OnControlModeShip();
357 afx_msg void OnUpdateControlModeShip(CCmdUI* pCmdUI);
358 afx_msg void OnShowGridPositions();
359 afx_msg void OnUpdateShowGridPositions(CCmdUI* pCmdUI);
360 afx_msg void OnShowCoordinates();
361 afx_msg void OnUpdateShowCoordinates(CCmdUI* pCmdUI);
362 afx_msg void OnSpeed50();
363 afx_msg void OnUpdateSpeed50(CCmdUI* pCmdUI);
364 afx_msg void OnSpeed100();
365 afx_msg void OnUpdateSpeed100(CCmdUI* pCmdUI);
366 afx_msg void OnSelect();
367 afx_msg void OnUpdateSelect(CCmdUI* pCmdUI);
368 afx_msg void OnSelectAndMove();
369 afx_msg void OnUpdateSelectAndMove(CCmdUI* pCmdUI);
370 afx_msg void OnSelectAndRotate();
371 afx_msg void OnUpdateSelectAndRotate(CCmdUI* pCmdUI);
372 afx_msg void OnConstrainX();
373 afx_msg void OnUpdateConstrainX(CCmdUI* pCmdUI);
374 afx_msg void OnConstrainY();
375 afx_msg void OnUpdateConstrainY(CCmdUI* pCmdUI);
376 afx_msg void OnConstrainZ();
377 afx_msg void OnUpdateConstrainZ(CCmdUI* pCmdUI);
378 afx_msg void OnConstrainXz();
379 afx_msg void OnUpdateConstrainXz(CCmdUI* pCmdUI);
380 afx_msg void OnSelectionLock();
381 afx_msg void OnUpdateSelectionLock(CCmdUI* pCmdUI);
382 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
383 afx_msg void OnDoubleFineGridlines();
384 afx_msg void OnUpdateDoubleFineGridlines(CCmdUI* pCmdUI);
385 afx_msg void OnShowDistances();
386 afx_msg void OnUpdateShowDistances(CCmdUI* pCmdUI);
387 afx_msg void OnUniversalHeading();
388 afx_msg void OnUpdateUniversalHeading(CCmdUI* pCmdUI);
389 afx_msg void OnFlyingControls();
390 afx_msg void OnUpdateFlyingControls(CCmdUI* pCmdUI);
391 afx_msg void OnRotateLocally();
392 afx_msg void OnUpdateRotateLocally(CCmdUI* pCmdUI);
393 afx_msg void OnConstrainXy();
394 afx_msg void OnUpdateConstrainXy(CCmdUI* pCmdUI);
395 afx_msg void OnUpdateConstrainYz(CCmdUI* pCmdUI);
396 afx_msg void OnConstrainYz();
397 afx_msg void OnSelectList();
398 afx_msg void OnZoomExtents();
399 afx_msg void OnZoomSelected();
400 afx_msg void OnUpdateZoomSelected(CCmdUI* pCmdUI);
401 afx_msg void OnFormWing();
402 afx_msg void OnUpdateFormWing(CCmdUI* pCmdUI);
403 afx_msg void OnDisbandWing();
404 afx_msg void OnUpdateDisbandWing(CCmdUI* pCmdUI);
405 afx_msg void OnShowHorizon();
406 afx_msg void OnUpdateShowHorizon(CCmdUI* pCmdUI);
407 afx_msg void OnEditorsWing();
408 afx_msg void OnEditorsPlayer();
409 afx_msg void OnEditorsOrient();
410 afx_msg void OnEditorsEvents();
411 afx_msg void OnUpdateEditorsOrient(CCmdUI* pCmdUI);
412 afx_msg void OnEditorsMessage();
413 afx_msg void OnEditorsStarfield();
414 afx_msg void OnEditorsBgBitmaps();
415 afx_msg void OnEditorsReinforcement();
416 afx_msg void OnErrorChecker();
417 afx_msg void OnEditorsWaypoint();
418 afx_msg void OnViewOutlines();
419 afx_msg void OnUpdateViewOutlines(CCmdUI* pCmdUI);
420 afx_msg void OnUpdateNewShipType(CCmdUI* pCmdUI);
421 afx_msg void OnShowStarfield();
422 afx_msg void OnUpdateShowStarfield(CCmdUI* pCmdUI);
423 afx_msg void OnAsteroidEditor();
424 afx_msg void OnRunFreespace();
425 afx_msg void OnEditorCampaign();
426 afx_msg void OnShowShips();
427 afx_msg void OnUpdateShowShips(CCmdUI* pCmdUI);
428 afx_msg void OnShowStarts();
429 afx_msg void OnUpdateShowStarts(CCmdUI* pCmdUI);
430 afx_msg void OnShowFriendly();
431 afx_msg void OnUpdateShowFriendly(CCmdUI* pCmdUI);
432 afx_msg void OnShowHostile();
433 afx_msg void OnUpdateShowHostile(CCmdUI* pCmdUI);
434 afx_msg void OnToggleViewpoint();
435 afx_msg void OnRevert();
436 afx_msg void OnUpdateRevert(CCmdUI* pCmdUI);
437 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
438 afx_msg void OnHideObjects();
439 afx_msg void OnShowHiddenObjects();
440 afx_msg void OnEditUndo();
441 afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
442 afx_msg void OnEditorsBriefing();
443 afx_msg void OnEditorsDebriefing();
444 afx_msg void OnSaveCamera();
445 afx_msg void OnRestoreCamera();
446 afx_msg void OnUpdateRestoreCamera(CCmdUI* pCmdUI);
447 afx_msg void OnShowSexpHelp();
448 afx_msg void OnUpdateShowSexpHelp(CCmdUI* pCmdUI);
449 afx_msg void OnLookatObj();
450 afx_msg void OnUpdateLookatObj(CCmdUI* pCmdUI);
451 afx_msg void OnEditorsAdjustGrid();
452 afx_msg void OnEditorsShieldSys();
453 afx_msg void OnLevelObj();
454 afx_msg void OnAlignObj();
455 afx_msg void OnControlObj();
456 afx_msg void OnNextObj();
457 afx_msg void OnPrevObj();
458 afx_msg void OnEditDeleteWing();
459 afx_msg void OnMarkWing();
460 afx_msg void OnUpdateControlObj(CCmdUI* pCmdUI);
461 afx_msg void OnEditDelete();
462 afx_msg void OnAaGridlines();
463 afx_msg void OnUpdateAaGridlines(CCmdUI* pCmdUI);
464 afx_msg void OnCmdBrief();
465 afx_msg void OnDisableUndo();
466 afx_msg void OnUpdateDisableUndo(CCmdUI* pCmdUI);
467 afx_msg void OnUpdateCmdBrief(CCmdUI* pCmdUI);
468 afx_msg void OnNextSubsys();
469 afx_msg void OnPrevSubsys();
470 afx_msg void OnCancelSubsys();
471 afx_msg void OnDumpStats();
472 afx_msg void OnShowPaths();
473 afx_msg void OnUpdateShowPaths(CCmdUI* pCmdUI);
474 afx_msg void OnShowDockPoints();
475 afx_msg void OnUpdateShowDockPoints(CCmdUI* pCmdUI);
477 afx_msg void OnGroup(UINT nID);
478 afx_msg void OnSetGroup(UINT nID);
480 // LONG OnMenuPopupShips(CWnd *pWnd, CPoint point);
481 LONG OnMenuPopupShips(UINT wParam, LONG lParam);
482 LONG OnMenuPopupEdit(UINT wParam, LONG lParam);
484 DECLARE_MESSAGE_MAP()
487 #ifndef _DEBUG // debug version in FREDView.cpp
488 inline CFREDDoc* CFREDView::GetDocument()
489 { return (CFREDDoc*)m_pDocument; }
492 /////////////////////////////////////////////////////////////////////////////
495 char *error_check_initial_orders(ai_goal *goals, int ship, int wing);
496 extern void fred_check_message_personas();
498 extern int Autosave_disabled;
499 extern int Show_sexp_help;
500 extern int Show_ships;
501 extern int Show_starts;
502 extern int Show_friendly;
503 extern int Show_hostile;
504 extern int Show_neutral;
505 extern int physics_speed;
506 extern int physics_rot;
507 extern int viewpoint;
509 extern int box_marking; // Are we currently box marking? (i.e. draging out a box to mark)
510 extern int button_down; // Is the left mouse button down and we are handling it?
511 extern int Marked; // number of marked objects
512 extern int Show_compass;
513 extern int Show_ship_models;
514 extern int Show_ship_info;
515 extern int Show_dock_points;
516 extern int Show_paths_fred;
517 extern int Selection_lock;
518 extern int Cursor_over;
519 extern int Cur_bitmap;
520 extern int Id_select_type_jump_node;
521 extern int Id_select_type_start;
522 extern int Id_select_type_waypoint;
523 extern int Hide_ship_cues, Hide_wing_cues;
524 extern Marking_box marking_box;
525 extern object_orient_pos rotation_backup[MAX_OBJECTS];
527 extern CFREDView *Fred_view_wnd;
529 #endif // if #ifndef STAMPER_PROGRAM