Debian Codegraph @

editor/d3edit.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/editor/d3edit.h $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:37 $
23 * $Author: kevinb $
24 *
25 * <insert description of file here>
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 45 3/30/99 6:24p Matt
30 * Added new error system, where instead of putting up an error message, a
31 * function returns a failure code & returns an error message that the
32 * caller can display if it wants.
33 *
34 * 44 1/29/99 12:48p Matt
35 * Rewrote the doorway system
36 *
37 * 43 12/01/98 11:17p Matt
38 * Added menu option to disable drawing objects in the wireframe view
39 *
40 * 42 10/14/98 4:34p Matt
41 * Added a macro to make EditorMessageBox() do OutrageMessageBox() if
42 * EDITOR is defined.
43 *
44 * 41 9/04/98 3:16p Samir
45 * control whether to allow joystick slewing.
46 *
47 * 40 9/04/98 12:29p Matt
48 * Added marked edge & vertex in the editor
49 *
50 * 39 8/27/98 6:42p Chris
51 * Added the goal keypad and the start of the matcen keypad
52 *
53 * 38 6/17/98 12:30p Samir
54 * don't draw wireframe when moving an object.
55 *
56 * 37 6/15/98 4:00p Jason
57 * replaced monochromatic polymodel lighting with rgb lighting
58 *
59 * 36 6/10/98 12:18p Matt
60 * Added hack to fix bug until Samir can fix it for real.
61 *
62 * 35 2/10/98 1:58p Chris
63 * Improved the path system
64 *
65 * 34 1/28/98 5:07p Samir
66 * Object modeless settings added.
67 *
68 * 33 1/26/98 4:33p Samir
69 * Added ability to copy object ids.
70 *
71 * 32 1/21/98 12:32p Matt
72 * Revamped viewer system
73 *
74 * 31 1/02/98 6:35p Matt
75 * Got rid of Render_viewport
76 *
77 * 30 12/29/97 5:44p Samir
78 * Took out references to grViewport and old 2d library.
79 *
80 * 29 12/19/97 11:25a Samir
81 * g3_StartFrame and g3_EndFrame replaced by EditorStartFrame and
82 * EditorEndFrame
83 *
84 * 28 12/02/97 5:30p Samir
85 * New file dialog interface implemented.
86 *
87 * 27 12/01/97 6:06p Samir
88 * Implemented new FileDialog tracker system.
89 *
90 * 26 10/28/97 3:41p Jason
91 * added "use hemicubes" option
92 *
93 * 25 9/29/97 12:09p Jason
94 * added functionality to doorway system
95 *
96 * 24 9/17/97 12:58p Samir
97 * Got rid of Curve Keypad.
98 *
99 * 23 9/17/97 11:40a Matt
100 * Ripped out segment code
101 *
102 * 22 9/17/97 11:16a Matt
103 * Ripped out segment code
104 *
105 * 21 9/11/97 5:46p Jason
106 * first pass at getting doors to work with room engine
107 *
108 * 20 9/08/97 4:05p Samir
109 * Fixed some warnings and took out extranneous includes to windows.h in
110 * important headers.
111 *
112 * 19 9/06/97 3:15p Matt
113 * Ripped out current trigger, added current portal
114 *
115 * 18 9/04/97 4:44p Matt
116 * Declare room, group, & segment types here so we don't need to include
117 * those header files, reducing compile times when one of them changes.
118 *
119 * 17 8/29/97 5:25p Matt
120 * Added Placed_group
121 *
122 * 16 8/29/97 3:31p Samir
123 * Fixed problem with room keypad not showing up. had to remove segment
124 * tab constant.
125 *
126 * 15 8/29/97 1:50p Samir
127 * Added object_move_axis to d3editstate.
128 *
129 * 14 8/18/97 6:59p Matt
130 * Implemented Place Room/Attach room system
131 *
132 * 13 8/12/97 4:09p Matt
133 * Added vars for current building & clutter
134 *
135 * 12 8/01/97 11:59a Samir
136 * Added a preference for debugging in fullscreen.
137 *
138 * 11 7/29/97 12:26p Jason
139 * added gamefile field to d3editstate
140 *
141 * 10 7/24/97 2:56p Matt
142 * Got rid of D3EditState fields that duplicated other variables
143 *
144 * 9 7/22/97 7:07p Matt
145 * Cleaned up D3EditState, moving some vars in and some out, and renaming
146 * and changing a few others
147 *
148 * 8 7/17/97 7:21p Matt
149 * Added var for current level script
150 *
151 * 51 6/30/97 1:29p Jason
152 * added yet more room functions (netherspace stuff)
153 *
154 * 50 6/27/97 3:04p Jason
155 * added cool room stuff
156 *
157 * 49 6/27/97 12:18p Samir
158 * Added RoomKeypadDialog
159 *
160 * 48 6/16/97 2:34p Jason
161 * added 3dfx support
162 *
163 * 47 6/05/97 6:10p Jason
164 * added support for zbuffering and bilinear filtering
165 *
166 * 46 6/05/97 3:38p Samir
167 * Added megacell keypad.
168 *
169 * 45 6/05/97 2:52p Jason
170 * added megacell functions
171 *
172 * 44 5/27/97 5:41p Jason
173 * added toggling of opengl renderer
174 *
175 * 43 5/21/97 3:39p Jason
176 * added terrain editing stuff
177 *
178 * 42 5/21/97 12:29p Jason
179 * added the ability to draw terrain dots in mine view
180 *
181 * 41 4/30/97 5:43p Jason
182 * added ability to toggle whether or not you want to run in 16 bit mode
183 *
184 * 40 4/08/97 10:41a Jason
185 * implemented path following interface
186 *
187 * 39 4/04/97 3:15p Samir
188 * Added paths keypad, removed player keypad since it's joined with object
189 * keypad.
190 *
191 * 38 4/02/97 8:07p Matt
192 * Added variable & button to toggle object move state
193 *
194 * 37 4/02/97 3:24p Jason
195 * got rid of WV_changed and made TV_changed update the textured view and
196 * flag "World_changed"
197 *
198 * 36 3/31/97 5:57p Matt
199 * Revamped mine update flags
200 *
201 * 35 3/31/97 3:47p Matt
202 * Added code to keep track of, render, and display current vertex.
203 *
204 * 34 3/31/97 3:13p Jason
205 * added ship,weapon,and sounds to d3edit and zeroed it out upon startup
206 *
207 * 33 3/26/97 6:32p Samir
208 * Changed order of keypads.
209 *
210 * 32 3/26/97 4:38p Samir
211 * Added SplashMessage function.
212 *
213 * 31 3/25/97 2:50p Jason
214 * added current_robot field
215 *
216 * 30 3/24/97 12:33p Samir
217 * Added current trigger type.
218 *
219 * 29 3/20/97 4:22p Samir
220 * Added Segment Sizing mode and side sizing.
221 *
222 * 28 3/17/97 12:24a Matt
223 * Added warning segs list
224 *
225 * 27 3/12/97 3:27p Matt
226 * Added scrap buffer
227 *
228 * 26 3/11/97 2:54p Samir
229 * Add some vars useful for rotation of segments.
230 *
231 * 25 3/07/97 4:18p Jason
232 * implemented terrain functionality in the editor
233 *
234 * 24 3/05/97 1:01p Samir
235 * Added current doorway global
236 *
237 * 23 3/05/97 11:49a Samir
238 * Added doorway and terrain keypad tabs.
239 *
240 * 22 3/04/97 7:13p Samir
241 * Added current_door and Current_trigger globals.
242 *
243 * 21 2/28/97 6:37p Matt
244 * Added variable & toggle button for box selection mode
245 *
246 * 20 2/28/97 12:11p Matt
247 * Added vars for selected seg list
248 *
249 * 19 2/24/97 5:51p Matt
250 * Added vars for Markedsegp & Markedside
251 *
252 * 18 2/19/97 5:39p Matt
253 * Made EditorStatus() take printf-type args, as the D1/D2 function did.
254 *
255 * 17 2/18/97 6:21p Samir
256 * Added EditorStatus function to print messages on the status bar.
257 *
258 * 16 2/18/97 12:46p Samir
259 * Added current object type editor state.
260 *
261 * 15 2/10/97 5:41p Matt
262 * Added a couple more vars
263 *
264 * 14 2/07/97 6:00p Matt
265 * Added Mine_changed
266 *
267 * 13 2/06/97 11:59a Matt
268 * Added externs for Cursegp,Curside,Curedge
269 *
270 * 12 2/05/97 11:13a Samir
271 * Added D3windowed preference
272 *
273 * 11 2/03/97 5:57p Matt
274 * Added missing include
275 *
276 * 10 1/30/97 7:48p Jason
277 * added support for powerup pages
278 *
279 * 9 1/23/97 4:57p Samir
280 * Added a bunch of window position vars.
281 *
282 * 8 1/21/97 12:52p Samir
283 * Added texture and wireframe screen dims to d3editstate struct.
284 *
285 * 7 1/20/97 3:51p Samir
286 * Took out EDITOR define. This should be put in the MAKEFILE for
287 * INFERNO.INI style implementation.
288 *
289 * $NoKeywords: $
290 */
291
292 /* D3 Editor Globals */
293
294 #ifndef _D3EDIT_H
295 #define _D3EDIT_H
296
297 #include "pstypes.h"
298 #include "descent.h"
299 #include "vecmat.h"
300
301 #include <stdlib.h>
302
303 // For putting up editor messageboxes in the main body (& should be in the editor code too, probably)
304 #ifdef EDITOR
305 #define EditorMessageBox OutrageMessageBox
306 #endif
307
308 // Define group & room structs so we don't have to include group.h & room.h
309 struct group;
310 struct room;
311
312 const int TEXSCREEN_WIDTH = 512, // Texture screen base width and height
313 TEXSCREEN_HEIGHT = 384,
314 WIRESCREEN_WIDTH = 640, // Wirefrane screen base width and height
315 WIRESCREEN_HEIGHT = 480;
316
317 const int EDITOR_RESOLUTION_X = 1024, // Used to try to make editor resolution independent
318 EDITOR_RESOLUTION_Y = 768;
319
320 int CALC_PIXELS_WITH_ASPECTX(int pixels);
321 int CALC_PIXELS_WITH_ASPECTY(int pixels);
322
323 // keypad constants
324 enum {
325 TAB_TEXTURE_KEYPAD,
326 TAB_MEGACELL_KEYPAD,
327 TAB_TERRAIN_KEYPAD,
328 TAB_OBJECTS_KEYPAD,
329 TAB_ROOM_KEYPAD,
330 TAB_DOORWAY_KEYPAD,
331 TAB_TRIGGER_KEYPAD,
332 TAB_LIGHTING_KEYPAD,
333 TAB_PATHS_KEYPAD,
334 TAB_LEVEL_KEYPAD,
335 TAB_MATCEN_KEYPAD
336 };
337
338 // Constants for d3edit_state variables
339 enum { IN_WINDOW, ACROSS_EDGE }; // values for box_selection_mode
340 enum { REL_OBJECT, REL_VIEWER }; // values for object_move_mode
341 enum { GM_WINDOWED, GM_FULLSCREEN_SW, GM_FULLSCREEN_HW }; // values for game_render_mode
342
343 class grSurface;
344 class grViewport;
345
346 // Structure to store various editor state & preference values
347 struct d3edit_state {
348
349 // Values for current item in the various dialogs
350 int texdlg_texture; // current texture in texdialog
351 int current_obj_type; // current type of object
352 int current_powerup; // current powerup id
353 int current_door; // current door in door page dialog
354 int current_robot; // current robot in robot page dialog
355 int current_ship; // current ship in ship page dialog
356 int current_sound; // current sound in sound page dialog
357 int current_weapon; // current weapon in weapon page dialog
358 int current_path; // currently selected path for a robot to follow
359 int current_node; // currently selected node of preceding path
360 int current_megacell; // currently selected megacell
361 int current_room; // currently selected room
362 int current_gamefile; // currently selected gamefile
363 int current_building; // currently selected building
364 int current_clutter; // currently selected clutter
365
366 // Values for the different editor windows
367 bool texscr_visible; // is texture mine view up?
368 int texscr_x, texscr_y, texscr_w, texscr_h; // dims of floating texture mine view
369
370 bool wirescr_visible; // is wireframe model up?
371 int wirescr_x, wirescr_y, wirescr_w, wirescr_h; // dims of floating wireframe model
372
373 bool keypad_visible; // is keypad visible?
374 int keypad_current; // which keypad tab are we on?
375 bool float_keypad_moved; // has floating keypad moved?
376 int float_keypad_x, float_keypad_y, float_keypad_w, float_keypad_h; // floating keypad width and height, x, y
377 int objmodeless_x, objmodeless_y; // object modeless list x and y.
378 bool objmodeless_on; // is modeless on?
379
380 bool tile_views; // tile or floating view windows, keypad
381
382 // Values for terrain renderer
383 bool terrain_dots; // show terrain dots?
384 bool terrain_flat_shade; // flat shade terrain?
385
386 // Misc preferences
387 int game_render_mode; // what mode to we play the game in? See constants above.
388 bool randomize_megacell; // randomize when placing a megacell?
389 int box_selection_mode; // How editor box selection works. See constants above.
390 int object_move_mode; // How object movements works. See constants above.
391 int object_move_axis; // This is the axis on which objects move with mouse.
392 bool fullscreen_debug_state; // do we allow for fullscreen debugging?
393 bool hemicube_radiosity;
394 float node_movement_inc;
395 int texture_display_flags; // which textures to display on the texture tab
396 float texscale; // the scalar for moving texture UVs
397 bool joy_slewing; // shall we allow joystick slewing?
398 bool objects_in_wireframe; // should we draw objects in the wireframe view?
399 };
400
401 // Editor.cpp:: Current state of the editor UI.
402 extern d3edit_state D3EditState;
403
404 // Editor.cpp:: Surface describing the actual desktop where the editor is running.
405 extern grSurface *Desktop_surf;
406
407 // flags for the textured views changed
408 extern int TV_changed;
409
410 // Set this flag if a new world is loaded/created
411 extern int New_mine;
412
413 // Set this when the mine has changed
414 extern int World_changed;
415
416 // Set this when the editor state (but not the world itself) has changed
417 extern int State_changed;
418
419 // Set this when the viewer (i.e., player) has moved
420 extern int Viewer_moved;
421
422 // Set this when an object has moved
423 extern int Object_moved;
424
425 // Set this when the editor viewpoint has changed
426 extern int Edview_changed;
427
428 // Current room & face
429 extern room *Curroomp;
430 extern int Curface, Curedge, Curvert;
431 extern int Curportal;
432
433 // Current object
434 extern int Cur_object_index;
435
436 // Marked room & face
437 extern room *Markedroomp;
438 extern int Markedface, Markededge, Markedvert;
439
440 // Placed room info
441 extern int Placed_room;
442 extern group *Placed_group;
443 extern int Placed_room_face;
444 extern int Placed_door;
445 extern float Placed_room_angle;
446 extern vector Placed_room_origin;
447 extern matrix Placed_room_orient;
448 extern vector Placed_room_attachpoint;
449 extern matrix Placed_room_rotmat;
450 extern room *Placed_baseroomp;
451 extern int Placed_baseface;
452
453 // Vars for the list of selected rooms
454 extern int N_selected_rooms;
455 extern int Selected_rooms[];
456
457 // Flag for if mine has changed (& thus needs to be saved)
458 extern int Mine_changed;
459
460 // Current trigger in mine displayed in trigger dialog
461 extern int Current_trigger;
462
463 // The scrap buffer
464 extern group *Scrap;
465
466 // Pointer to the scripts for this level
467 extern char *Current_level_script;
468
469 // What mode we're currently in
470 enum { VM_MINE, VM_TERRAIN, VM_ROOM, NUM_VIEW_MODES };
471 extern int Editor_view_mode;
472
473 // The ID of the most recent viewer object (not counting room view)
474 extern int Editor_viewer_id;
475
476 // current directories for file dialogs.
477 extern char Current_files_dir[_MAX_PATH];
478 extern char Current_bitmap_dir[_MAX_PATH];
479 extern char Current_scrap_dir[_MAX_PATH];
480 extern char Current_room_dir[_MAX_PATH];
481 extern char Current_model_dir[_MAX_PATH];
482 extern char Current_sounds_dir[_MAX_PATH];
483 extern char Current_weapon_dir[_MAX_PATH];
484
485 // object id clipboard.
486 extern int Copied_object_id;
487
488 // FUNCTIONS
489 void EditorStatus(const char *format, ...);
490 void SplashMessage(const char *format, ...);
491 void StartEditorFrame(grViewport *vp, vector *view_vec, matrix *id_mat, float zoom);
492 void EndEditorFrame();
493
494 // Set the editor error message. A function that's going to return a failure
495 // code should call this with the error message.
496 void SetErrorMessage(const char *fmt, ...);
497
498 // Get the error message from the last function that returned failure
499 const char *GetErrorMessage();
500
501 #endif