]> icculus.org git repositories - taylor/freespace2.git/blob - include/fredview.h
embed standalone web in executable
[taylor/freespace2.git] / include / fredview.h
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
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/fred2/FREDView.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
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.
19  *
20  * $Log$
21  * Revision 1.2  2002/06/09 04:41:13  relnev
22  * added copyright header
23  *
24  * Revision 1.1.1.1  2002/05/03 03:28:12  root
25  * Initial import.
26  *
27  * 
28  * 6     6/04/99 2:20p Andsager
29  * Add dump stats basic functionality
30  * 
31  * 5     3/26/99 4:49p Dave
32  * Made cruisers able to dock with stuff. Made docking points and paths
33  * visible in fred.
34  * 
35  * 4     1/27/99 4:09p Andsager
36  * Added highlight to ship subsystems
37  * 
38  * 3     10/13/98 9:27a Dave
39  * Started neatening up freespace.h
40  * 
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.
45  * 
46  * 1     10/07/98 3:01p Dave
47  * 
48  * 1     10/07/98 3:00p Dave
49  * 
50  * 84    5/21/98 11:48a Hoffoss
51  * Removed check in and check out options.
52  * 
53  * 83    5/14/98 5:32p Hoffoss
54  * Added some more error checking.
55  * 
56  * 82    4/01/98 10:48a Hoffoss
57  * Changed Fred to not allow command briefings in multiplayer missions.
58  * 
59  * 81    3/25/98 4:14p Hoffoss
60  * Split ship editor up into ship editor and a misc dialog, which tracks
61  * flags and such.
62  * 
63  * 80    3/09/98 10:56a Hoffoss
64  * Added jump node objects to Fred.
65  * 
66  * 79    3/05/98 3:59p Hoffoss
67  * Added a bunch of new command brief stuff, and asteroid initialization
68  * to Fred.
69  * 
70  * 78    1/29/98 5:14p Hoffoss
71  * Added error checking for more than 4 ships in a player starting wing.
72  * 
73  * 77    10/30/97 3:30p Hoffoss
74  * Made anti-aliased gridlines an option in Fred.
75  * 
76  * 76    10/14/97 10:59a Allender
77  * more persona work.  Made global error checker call funciton to assign
78  * and check personas
79  * 
80  * 75    9/06/97 2:13p Mike
81  * Replace support for TEAM_NEUTRAL
82  * 
83  * 74    9/01/97 6:59p Hoffoss
84  * Added source safe checkin and checkout capabilities to Fred.
85  * 
86  * 73    8/26/97 4:18p Hoffoss
87  * Added error checking to initial orders dialog when ok is clicked.
88  * 
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.
92  * 
93  * 71    8/18/97 9:31p Hoffoss
94  * Added grid adjustment dialog and shield system editor dialog.
95  * 
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.
99  * 
100  * 69    8/12/97 6:32p Hoffoss
101  * Added code to allow hiding of arrival and departure cues in editors.
102  * 
103  * 68    8/11/97 6:54p Hoffoss
104  * Groups now supported in Fred.
105  * 
106  * 67    8/11/97 11:51a Allender
107  * added stamp stuff to Fred
108  * 
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.
112  * 
113  * 65    8/01/97 3:10p Hoffoss
114  * Made Sexp help hidable.
115  * 
116  * 64    8/01/97 12:52p Hoffoss
117  * Added variable, fixed bug with global error check.
118  * 
119  * 63    7/28/97 2:51p Hoffoss
120  * Re-evaluated and improved global error checker in Fred.
121  * 
122  * 62    7/24/97 12:45p Hoffoss
123  * Added camera position save and restore.
124  * 
125  * 61    7/08/97 2:03p Hoffoss
126  * Debriefing editor coded and implemented.
127  * 
128  * 60    6/18/97 3:07p Hoffoss
129  * Wing ship names are 1 indexes instead of 0 indexed now.
130  * 
131  * 59    6/09/97 4:57p Hoffoss
132  * Added autosave and undo to Fred.
133  * 
134  * 58    6/05/97 6:10p Hoffoss
135  * Added features: Autosaving, object hiding.  Also fixed some minor bugs.
136  * 
137  * 57    6/02/97 11:52a Hoffoss
138  * Custom cursors displayed when over objects in different modes.
139  * 
140  * 56    5/21/97 5:43p Hoffoss
141  * Added features requested on Todo list.
142  * 
143  * 55    5/06/97 3:01p Hoffoss
144  * Added some accelerator keys.
145  * 
146  * 54    5/05/97 5:44p Hoffoss
147  * Added specialized popup menu choices, save before running FreeSpace,
148  * and display filters.
149  * 
150  * 53    5/05/97 9:42a Hoffoss
151  * Single axis contraint code changed to operate better.
152  * 
153  * 52    4/24/97 5:15p Hoffoss
154  * fixes to Fred.
155  * 
156  * 51    4/17/97 5:23p Hoffoss
157  * Implemented ability to run FreeSpace from Fred.
158  * 
159  * 50    4/16/97 5:18p Hoffoss
160  * Moved Asteroid field editor stuff to a seperate dialog box.
161  * 
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.
165  * 
166  * 48    3/12/97 12:40p Hoffoss
167  * Fixed bugs in wing object management functions, several small additions
168  * and rearrangements.
169  * 
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.
173  * 
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.
177  * 
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.
181  * 
182  * 44    3/04/97 6:27p Hoffoss
183  * Changes to Fred to handle new wing structure.
184  * 
185  * 43    2/28/97 11:31a Hoffoss
186  * Implemented modeless dialog saving and restoring, and changed some
187  * variables names.
188  * 
189  * 42    2/27/97 5:54p Hoffoss
190  * Implemented support for saving and restoring window positions.
191  * 
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.
195  * 
196  * 72    2/12/97 5:50p Hoffoss
197  * Expanded on error checking.
198  * 
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.
202  * 
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!
206  * 
207  * 69    2/04/97 3:09p Hoffoss
208  * Background bitmap editor implemented fully.
209  * 
210  * 68    1/30/97 2:24p Hoffoss
211  * Added remaining mission file structures and implemented load/save of
212  * them.
213  *
214  * $NoKeywords: $
215  */
216
217 #ifndef STAMPER_PROGRAM
218
219 #include "freddoc.h"
220
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
224
225 typedef struct Marking_box {
226         int x1, y1, x2, y2;
227 } Marking_box;
228
229 typedef struct subsys_to_render
230 {
231         bool                            do_render;
232         object                  *ship_obj;
233         ship_subsys             *cur_subsys;
234 } subsys_to_render;
235
236 class CShipEditorDlg;
237 class   CGrid;
238
239 class CFREDView : public CView
240 {
241 private:
242         CGrid*          m_pGDlg;
243         int global_error_check_player_wings(int multi);
244
245 protected: // create from serialization only
246         CFREDView();
247         DECLARE_DYNCREATE(CFREDView)
248
249 // Attributes
250 public:
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();
259
260         static CFREDView *GetView();
261         
262 LONG OnGoodbye(UINT wParam, LONG lParam);
263 // LONG OnMenuPopupShips(CWnd *pWnd, CPoint point);
264 // LONG OnMenuPopupShips(UINT wParam, LONG lParam);
265
266         //BOOL  m_ConfirmDeleting;
267         //BOOL  m_ShowCapitalShips;
268         //BOOL  m_ShowElevations;
269         //BOOL  m_ShowFighters;
270         //BOOL  m_ShowGrid;
271         //BOOL  m_ShowMiscObjects;
272         //BOOL  m_ShowPlanets;
273         //BOOL  m_ShowWaypoints;        
274
275         // Operations
276 public:
277
278 // Overrides
279         // ClassWizard generated virtual function overrides
280         //{{AFX_VIRTUAL(CFREDView)
281         public:
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();
286         protected:
287         virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
288         virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
289         virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
290         //}}AFX_VIRTUAL
291
292 // Implementation
293 public:
294         virtual ~CFREDView();
295 #ifdef _DEBUG
296         virtual void AssertValid() const;
297         virtual void Dump(CDumpContext& dc) const;
298 #endif
299         
300 //      virtual void SEDlg_destroy();
301
302 // Generated message map functions
303 protected:
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);
476         //}}AFX_MSG
477         afx_msg void OnGroup(UINT nID);
478         afx_msg void OnSetGroup(UINT nID);
479
480 // LONG OnMenuPopupShips(CWnd *pWnd, CPoint point);
481 LONG OnMenuPopupShips(UINT wParam, LONG lParam);
482 LONG OnMenuPopupEdit(UINT wParam, LONG lParam);
483
484         DECLARE_MESSAGE_MAP()
485 };
486
487 #ifndef _DEBUG  // debug version in FREDView.cpp
488 inline CFREDDoc* CFREDView::GetDocument()
489    { return (CFREDDoc*)m_pDocument; }
490 #endif
491
492 /////////////////////////////////////////////////////////////////////////////
493
494 void cancel_drag();
495 char *error_check_initial_orders(ai_goal *goals, int ship, int wing);
496 extern void fred_check_message_personas();
497
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;
508 extern int view_obj;
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];
526
527 extern CFREDView *Fred_view_wnd;
528
529 #endif          // if #ifndef STAMPER_PROGRAM
530