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 #ifndef STAMPER_PROGRAM
13
14 #include "FREDDoc.h"
15
16 #define WM_MENU_POPUP_SHIPS (WM_USER+6)
17 #define WM_MENU_POPUP_EDIT (WM_USER+7)
18 #define SEXP_HELP_BOX_SIZE 170
19
20 typedef struct Marking_box {
21 int x1, y1, x2, y2;
22 } Marking_box;
23
24 typedef struct subsys_to_render
25 {
26 bool do_render;
27 object *ship_obj;
28 ship_subsys *cur_subsys;
29 } subsys_to_render;
30
31 class CShipEditorDlg;
32 class CGrid;
33
34 class CFREDView : public CView
35 {
36 private:
37 CGrid* m_pGDlg;
38 int global_error_check_player_wings(int multi);
39
40 protected: // create from serialization only
41 CFREDView();
42 DECLARE_DYNCREATE(CFREDView)
43
44 // Attributes
45 public:
46
47 int global_error_check_mixed_player_wing(int w);
48 int fred_check_sexp(int sexp, int type, const char *msg, ...);
49 int internal_error(const char *msg, ...);
50 int error(const char *msg, ...);
51 int global_error_check();
52 void place_background_bitmap(vec3d v);
53 void cycle_constraint();
54 CFREDDoc *GetDocument();
55
56 static CFREDView *GetView();
57
58 LRESULT OnGoodbye(WPARAM wParam, LPARAM lParam);
59 // LONG OnMenuPopupShips(CWnd *pWnd, CPoint point);
60 // LONG OnMenuPopupShips(UINT wParam, LONG lParam);
61
62 //BOOL m_ConfirmDeleting;
63 //BOOL m_ShowCapitalShips;
64 //BOOL m_ShowElevations;
65 //BOOL m_ShowFighters;
66 //BOOL m_ShowGrid;
67 //BOOL m_ShowMiscObjects;
68 //BOOL m_ShowPlanets;
69 //BOOL m_ShowWaypoints;
70
71 // Operations
72 public:
73
74 // Overrides
75 // ClassWizard generated virtual function overrides
76 //{{AFX_VIRTUAL(CFREDView)
77 public:
78 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
79 virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
80 virtual BOOL DestroyWindow();
81 protected:
82 virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
83 virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
84 virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
85 virtual void OnDraw(CDC* pDC);
86 //}}AFX_VIRTUAL
87
88
89
90 // Implementation
91 public:
92 virtual ~CFREDView();
93 #ifdef _DEBUG
94 virtual void AssertValid() const;
95 virtual void Dump(CDumpContext& dc) const;
96 #endif
97
98 // virtual void SEDlg_destroy();
99
100 // Generated message map functions
101 protected:
102 //{{AFX_MSG(CFREDView)
103 afx_msg void OnViewGrid();
104 afx_msg void OnUpdateViewGrid(CCmdUI* pCmdUI);
105 afx_msg void OnViewWaypoints();
106 afx_msg void OnUpdateViewWaypoints(CCmdUI* pCmdUI);
107 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
108 afx_msg void OnEditorsShips();
109 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
110 afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
111 afx_msg void OnSetFocus(CWnd* pOldWnd);
112 afx_msg void OnKillFocus(CWnd* pNewWnd);
113 afx_msg void OnSize(UINT nType, int cx, int cy);
114 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
115 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
116 afx_msg void OnMiscstuffShowshipsasicons();
117 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
118 afx_msg void OnEditPopupShowShipIcons();
119 afx_msg void OnUpdateEditPopupShowShipIcons(CCmdUI* pCmdUI);
120 afx_msg void OnEditPopupShowShipModels();
121 afx_msg void OnUpdateEditPopupShowShipModels(CCmdUI* pCmdUI);
122 afx_msg void OnMiscStatistics();
123 afx_msg void OnEditPopupShowCompass();
124 afx_msg void OnUpdateEditPopupShowCompass(CCmdUI* pCmdUI);
125 afx_msg void OnUpdateChangeViewpointExternal(CCmdUI* pCmdUI);
126 afx_msg void OnChangeViewpointExternal();
127 afx_msg void OnUpdateChangeViewpointFollow(CCmdUI* pCmdUI);
128 afx_msg void OnChangeViewpointFollow();
129 afx_msg void OnEditorsGoals();
130 afx_msg void OnSpeed1();
131 afx_msg void OnSpeed2();
132 afx_msg void OnSpeed5();
133 afx_msg void OnSpeed10();
134 afx_msg void OnUpdateSpeed1(CCmdUI* pCmdUI);
135 afx_msg void OnSpeed3();
136 afx_msg void OnSpeed8();
137 afx_msg void OnRot1();
138 afx_msg void OnRot2();
139 afx_msg void OnRot3();
140 afx_msg void OnRot4();
141 afx_msg void OnRot5();
142 afx_msg void OnUpdateSpeed2(CCmdUI* pCmdUI);
143 afx_msg void OnUpdateSpeed3(CCmdUI* pCmdUI);
144 afx_msg void OnUpdateSpeed5(CCmdUI* pCmdUI);
145 afx_msg void OnUpdateSpeed8(CCmdUI* pCmdUI);
146 afx_msg void OnUpdateSpeed10(CCmdUI* pCmdUI);
147 afx_msg void OnUpdateRot1(CCmdUI* pCmdUI);
148 afx_msg void OnUpdateRot2(CCmdUI* pCmdUI);
149 afx_msg void OnUpdateRot3(CCmdUI* pCmdUI);
150 afx_msg void OnUpdateRot4(CCmdUI* pCmdUI);
151 afx_msg void OnUpdateRot5(CCmdUI* pCmdUI);
152 afx_msg void OnControlModeCamera();
153 afx_msg void OnUpdateControlModeCamera(CCmdUI* pCmdUI);
154 afx_msg void OnControlModeShip();
155 afx_msg void OnUpdateControlModeShip(CCmdUI* pCmdUI);
156 afx_msg void OnShowGridPositions();
157 afx_msg void OnUpdateShowGridPositions(CCmdUI* pCmdUI);
158 afx_msg void OnShowCoordinates();
159 afx_msg void OnUpdateShowCoordinates(CCmdUI* pCmdUI);
160 afx_msg void OnSpeed50();
161 afx_msg void OnUpdateSpeed50(CCmdUI* pCmdUI);
162 afx_msg void OnSpeed100();
163 afx_msg void OnUpdateSpeed100(CCmdUI* pCmdUI);
164 afx_msg void OnSelect();
165 afx_msg void OnUpdateSelect(CCmdUI* pCmdUI);
166 afx_msg void OnSelectAndMove();
167 afx_msg void OnUpdateSelectAndMove(CCmdUI* pCmdUI);
168 afx_msg void OnSelectAndRotate();
169 afx_msg void OnUpdateSelectAndRotate(CCmdUI* pCmdUI);
170 afx_msg void OnConstrainX();
171 afx_msg void OnUpdateConstrainX(CCmdUI* pCmdUI);
172 afx_msg void OnConstrainY();
173 afx_msg void OnUpdateConstrainY(CCmdUI* pCmdUI);
174 afx_msg void OnConstrainZ();
175 afx_msg void OnUpdateConstrainZ(CCmdUI* pCmdUI);
176 afx_msg void OnConstrainXz();
177 afx_msg void OnUpdateConstrainXz(CCmdUI* pCmdUI);
178 afx_msg void OnSelectionLock();
179 afx_msg void OnUpdateSelectionLock(CCmdUI* pCmdUI);
180 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
181 afx_msg void OnDoubleFineGridlines();
182 afx_msg void OnUpdateDoubleFineGridlines(CCmdUI* pCmdUI);
183 afx_msg void OnShowDistances();
184 afx_msg void OnUpdateShowDistances(CCmdUI* pCmdUI);
185 afx_msg void OnUniversalHeading();
186 afx_msg void OnUpdateUniversalHeading(CCmdUI* pCmdUI);
187 afx_msg void OnFlyingControls();
188 afx_msg void OnUpdateFlyingControls(CCmdUI* pCmdUI);
189 afx_msg void OnRotateLocally();
190 afx_msg void OnUpdateRotateLocally(CCmdUI* pCmdUI);
191 afx_msg void OnConstrainXy();
192 afx_msg void OnUpdateConstrainXy(CCmdUI* pCmdUI);
193 afx_msg void OnUpdateConstrainYz(CCmdUI* pCmdUI);
194 afx_msg void OnConstrainYz();
195 afx_msg void OnSelectList();
196 afx_msg void OnZoomExtents();
197 afx_msg void OnZoomSelected();
198 afx_msg void OnUpdateZoomSelected(CCmdUI* pCmdUI);
199 afx_msg void OnFormWing();
200 afx_msg void OnUpdateFormWing(CCmdUI* pCmdUI);
201 afx_msg void OnDisbandWing();
202 afx_msg void OnUpdateDisbandWing(CCmdUI* pCmdUI);
203 afx_msg void OnShowHorizon();
204 afx_msg void OnUpdateShowHorizon(CCmdUI* pCmdUI);
205 afx_msg void OnEditorsWing();
206 afx_msg void OnEditorsPlayer();
207 afx_msg void OnEditorsOrient();
208 afx_msg void OnEditorsEvents();
209 afx_msg void OnUpdateEditorsOrient(CCmdUI* pCmdUI);
210 afx_msg void OnEditorsMessage();
211 afx_msg void OnEditorsStarfield();
212 afx_msg void OnEditorsBgBitmaps();
213 afx_msg void OnEditorsReinforcement();
214 afx_msg void OnErrorChecker();
215 afx_msg void OnEditorsWaypoint();
216 afx_msg void OnViewOutlines();
217 afx_msg void OnUpdateViewOutlines(CCmdUI* pCmdUI);
218 afx_msg void OnViewOutlinesOnSelected();
219 afx_msg void OnUpdateViewOutlinesOnSelected(CCmdUI* pCmdUI);
220 afx_msg void OnUpdateNewShipType(CCmdUI* pCmdUI);
221 afx_msg void OnShowStarfield();
222 afx_msg void OnUpdateShowStarfield(CCmdUI* pCmdUI);
223 afx_msg void OnAsteroidEditor();
224 afx_msg void OnRunFreeSpace();
225 afx_msg void OnEditorCampaign();
226 afx_msg void OnShowShips();
227 afx_msg void OnUpdateShowShips(CCmdUI* pCmdUI);
228 afx_msg void OnShowStarts();
229 afx_msg void OnUpdateShowStarts(CCmdUI* pCmdUI);
230 afx_msg void OnShowIFF0();
231 afx_msg void OnUpdateShowIFF0(CCmdUI* pCmdUI);
232 afx_msg void OnShowIFF1();
233 afx_msg void OnUpdateShowIFF1(CCmdUI* pCmdUI);
234 afx_msg void OnShowIFF2();
235 afx_msg void OnUpdateShowIFF2(CCmdUI* pCmdUI);
236 afx_msg void OnShowIFF3();
237 afx_msg void OnUpdateShowIFF3(CCmdUI* pCmdUI);
238 afx_msg void OnShowIFF4();
239 afx_msg void OnUpdateShowIFF4(CCmdUI* pCmdUI);
240 afx_msg void OnShowIFF5();
241 afx_msg void OnUpdateShowIFF5(CCmdUI* pCmdUI);
242 afx_msg void OnShowIFF6();
243 afx_msg void OnUpdateShowIFF6(CCmdUI* pCmdUI);
244 afx_msg void OnShowIFF7();
245 afx_msg void OnUpdateShowIFF7(CCmdUI* pCmdUI);
246 afx_msg void OnShowIFF8();
247 afx_msg void OnUpdateShowIFF8(CCmdUI* pCmdUI);
248 afx_msg void OnShowIFF9();
249 afx_msg void OnUpdateShowIFF9(CCmdUI* pCmdUI);
250 afx_msg void OnToggleViewpoint();
251 afx_msg void OnRevert();
252 afx_msg void OnUpdateRevert(CCmdUI* pCmdUI);
253 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
254 afx_msg void OnHideObjects();
255 afx_msg void OnShowHiddenObjects();
256 afx_msg void OnEditUndo();
257 afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
258 afx_msg void OnEditorsBriefing();
259 afx_msg void OnEditorsDebriefing();
260 afx_msg void OnSaveCamera();
261 afx_msg void OnRestoreCamera();
262 afx_msg void OnUpdateRestoreCamera(CCmdUI* pCmdUI);
263 afx_msg void OnShowSexpHelp();
264 afx_msg void OnUpdateShowSexpHelp(CCmdUI* pCmdUI);
265 afx_msg void OnLookatObj();
266 afx_msg void OnUpdateLookatObj(CCmdUI* pCmdUI);
267 afx_msg void OnEditorsAdjustGrid();
268 afx_msg void OnEditorsShieldSys();
269 afx_msg void OnLevelObj();
270 afx_msg void OnAlignObj();
271 afx_msg void OnControlObj();
272 afx_msg void OnNextObj();
273 afx_msg void OnPrevObj();
274 afx_msg void OnEditCloneMarkedObjects();
275 afx_msg void OnEditDeleteWing();
276 afx_msg void OnMarkWing();
277 afx_msg void OnUpdateControlObj(CCmdUI* pCmdUI);
278 afx_msg void OnEditDelete();
279 afx_msg void OnAaGridlines();
280 afx_msg void OnUpdateAaGridlines(CCmdUI* pCmdUI);
281 afx_msg void OnCmdBrief();
282 afx_msg void OnDisableUndo();
283 afx_msg void OnUpdateDisableUndo(CCmdUI* pCmdUI);
284 afx_msg void OnUpdateCmdBrief(CCmdUI* pCmdUI);
285 afx_msg void OnNextSubsys();
286 afx_msg void OnPrevSubsys();
287 afx_msg void OnCancelSubsys();
288 afx_msg void OnDumpStats();
289 afx_msg void OnShowPaths();
290 afx_msg void OnUpdateShowPaths(CCmdUI* pCmdUI);
291 afx_msg void OnShowDockPoints();
292 afx_msg void OnUpdateShowDockPoints(CCmdUI* pCmdUI);
293 afx_msg void OnFormatFs2Open();
294 afx_msg void OnUpdateFormatFs2Open(CCmdUI* pCmdUI);
295 afx_msg void OnFormatFs2OpenComp();
296 afx_msg void OnUpdateFormatFs2OpenComp(CCmdUI* pCmdUI);
297 afx_msg void OnFormatFs2Retail();
298 afx_msg void OnUpdateFormatFs2Retail(CCmdUI* pCmdUI);
299 afx_msg void OnFormatFs1Retail();
300 afx_msg void OnUpdateFormatFs1Retail(CCmdUI* pCmdUI);
301 afx_msg void OnMoveShipsWhenUndocking();
302 afx_msg void OnUpdateMoveShipsWhenUndocking(CCmdUI* pCmdUI);
303 afx_msg void OnHighlightSubsys();
304 afx_msg void OnUpdateHighlightSubsys(CCmdUI* pCmdUI);
305 afx_msg void OnEditorsSetGlobalShipFlags();
306 afx_msg void OnEditorsVoiceManager();
307 afx_msg void OnEditorsFiction();
308 afx_msg void OnDestroy();
309 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
310 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
311 afx_msg void OnViewLighting();
312 afx_msg void OnUpdateViewLighting(CCmdUI* pCmdUI);
313 afx_msg void OnViewFullDetail();
314 afx_msg void OnUpdateViewFullDetail(CCmdUI *pCmdUI);
315 //}}AFX_MSG
316 afx_msg void OnGroup(UINT nID);
317 afx_msg void OnSetGroup(UINT nID);
318
319 void OnShowIFF(int iff);
320 void OnUpdateShowIFF(int iff, CCmdUI* pCmdUI);
321
322 // LONG OnMenuPopupShips(CWnd *pWnd, CPoint point);
323 LRESULT OnMenuPopupShips(WPARAM wParam, LPARAM lParam);
324 LRESULT OnMenuPopupEdit(WPARAM wParam, LPARAM lParam);
325
326 DECLARE_MESSAGE_MAP()
327 };
328
329 #ifndef _DEBUG // debug version in FREDView.cpp
GetDocument()330 inline CFREDDoc* CFREDView::GetDocument()
331 { return (CFREDDoc*)m_pDocument; }
332 #endif
333
334 /////////////////////////////////////////////////////////////////////////////
335
336 void cancel_drag();
337 char *error_check_initial_orders(ai_goal *goals, int ship, int wing);
338 extern void fred_check_message_personas();
339
340 extern int Autosave_disabled;
341 extern int Show_sexp_help;
342 extern int Show_ships;
343 extern int Show_starts;
344 extern int physics_speed;
345 extern int physics_rot;
346 extern int viewpoint;
347 extern int view_obj;
348 extern int box_marking; // Are we currently box marking? (i.e. draging out a box to mark)
349 extern int button_down; // Is the left mouse button down and we are handling it?
350 extern int Marked; // number of marked objects
351 extern int Show_compass;
352 extern int Show_ship_models;
353 extern int Show_ship_info;
354 extern int Show_dock_points;
355 extern int Lighting_on;
356 extern int FullDetail;
357 extern int Show_paths_fred;
358 extern int Selection_lock;
359 extern int Cursor_over;
360 extern int Cur_bitmap;
361 extern int Id_select_type_jump_node;
362 extern int Id_select_type_start;
363 extern int Id_select_type_waypoint;
364 extern int Hide_ship_cues, Hide_wing_cues;
365 extern int Move_ships_when_undocking;
366 extern int Highlight_selectable_subsys;
367
368 extern Marking_box marking_box;
369 extern object_orient_pos rotation_backup[MAX_OBJECTS];
370
371 enum FSO_FORMAT
372 {
373 FSO_FORMAT_RETAIL = 0,
374 FSO_FORMAT_STANDARD = 1,
375 FSO_FORMAT_COMPATIBILITY_MODE = 2
376 };
377 extern int Mission_save_format;
378
379 extern CFREDView *Fred_view_wnd;
380
381 #endif // if #ifndef STAMPER_PROGRAM
382