1 #ifndef __INTERFACE_H
2 #define __INTERFACE_H
3 
4 /*
5 INTERFACE.H
6 
7 	Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
8 	and the "Aleph One" developers.
9 
10 	This program is free software; you can redistribute it and/or modify
11 	it under the terms of the GNU General Public License as published by
12 	the Free Software Foundation; either version 3 of the License, or
13 	(at your option) any later version.
14 
15 	This program is distributed in the hope that it will be useful,
16 	but WITHOUT ANY WARRANTY; without even the implied warranty of
17 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 	GNU General Public License for more details.
19 
20 	This license is contained in the file "COPYING",
21 	which is included with this source code; it is available online at
22 	http://www.gnu.org/licenses/gpl.html
23 
24 Monday, August 23, 1993 4:35:53 PM
25 
26 Feb 24, 2000 (Loren Petrich):
27 	Added get_number_of_collection_frames(), so as to assist in wall-texture error checking
28 
29 Feb 25, 2000 (Loren Petrich):
30 	Added chase-cam and crosshair data structures and dialogs
31 
32 Mar 2, 2000 (Loren Petrich):
33 	Moved the chase-cam and crosshair stuff out to ChaseCam.h and Crosshairs.h
34 
35 Mar 22, 2000 (Loren Petrich):
36 	Added ResetFieldOfView(), a function that sets the field of view to the player's current state
37 	(if extravision is active, then extravision, otherwise normal). It's defined in screen.c
38 
39 Apr 27, 2000 (Loren Petrich):
40 	Added Josh Elsasser's "don't switch weapons" patch
41 
42 Apr 30, 2000 (Loren Petrich):
43 	Added reloading of view context when reverting, so that OpenGL won't look funny when one
44 	changes a level.
45 
46 May 1, 2000 (Loren Petrich): Added XML parser object for the infravision stuff.
47 
48 May 16, 2000 (Loren Petrich): Added XML parser for the control panels
49 
50 May 16, 2002 (Woody Zenfell):
51     Interfaces to dont_auto_recenter and to routines to help make such modifications safer
52     for films and netplay.
53 */
54 
55 #include "cseries.h"
56 
57 class FileSpecifier;
58 class OpenedResourceFile;
59 
60 /* ---------- constants */
61 
62 #define strFILENAMES 129
63 enum /* filenames in strFILENAMES */
64 {
65 	filenameSHAPES8,
66 	filenameSHAPES16,
67 	filenameSOUNDS8,
68 	filenameSOUNDS16,
69 	filenamePREFERENCES,
70 	filenameDEFAULT_MAP,
71 	filenameDEFAULT_SAVE_GAME,
72 	filenameMARATHON_NAME,
73 	filenameMARATHON_RECORDING,
74 	filenamePHYSICS_MODEL,
75 	filenameMUSIC,
76 	filenameIMAGES,
77 	filenameMOVIE,
78 	filenameDEFAULT_THEME,
79 	filenameEXTERNAL_RESOURCES,
80 };
81 
82 #define strPATHS 138
83 
84 #define strERRORS 128
85 enum /* errors in strERRORS */
86 {
87 	badProcessor= 0,
88 	badQuickDraw,
89 	badSystem,
90 	badMemory,
91 	badMonitor,
92 	badExtraFileLocations,
93 	badSoundChannels,
94 	fileError,
95 	copyHasBeenModified, // bad serial number
96 	copyHasExpired,
97 	keyIsUsedForSound,
98 	keyIsUsedForMapZooming,
99 	keyIsUsedForScrolling,
100 	keyIsUsedAlready,
101 	outOfMemory,
102 	warningExternalPhysicsModel,
103 	warningExternalMapsFile,
104 	badReadMapGameError,
105 	badReadMapSystemError,
106 	badWriteMap,
107 	badSerialNumber,
108 	duplicateSerialNumbers,
109 	networkOnlySerialNumber,
110 	corruptedMap,
111 	checkpointNotFound,
112 	pictureNotFound,
113 	networkNotSupportedForDemo,
114 	serverQuitInCooperativeNetGame,
115 	unableToGracefullyChangeLevelsNet,
116 	cantFindMap,	// called when the save game can't find the map.  Reverts to default map.
117 	cantFindReplayMap, // called when you can't find the map that the replay references..
118 	notEnoughNetworkMemory,
119 	luascriptconflict,
120 	replayVersionTooNew,
121 	keyScrollWheelDoesntWork
122 };
123 
124 enum /* animation types */
125 {
126 	_animated1= 1,
127 	_animated2to8= 2, /* ?? */
128 	_animated3to4= 3,
129 	_animated4= 4,
130 	_animated5to8= 5,
131 	_animated8= 8,
132 	_animated3to5= 9,
133 	_unanimated= 10,
134 	_animated5= 11
135 };
136 
137 enum /* shading tables */
138 {
139 	_darkening_table
140 };
141 
142 enum /* shape types (this is for the editor) */
143 {
144 	_wall_shape, /* things designated as walls */
145 	_floor_or_ceiling_shape, /* walls in raw format */
146 	_object_shape, /* things designated as objects */
147 	_other_shape /* anything not falling into the above categories (guns, interface elements, etc) */
148 };
149 
150 #define TOTAL_SHAPE_COLLECTIONS 128
151 
152 enum /* The various default key setups a user can select. for vbl.c and it's callers */
153 {
154 	_standard_keyboard_setup,
155 	_left_handed_keyboard_setup,
156 	_powerbook_keyboard_setup,
157 	NUMBER_OF_KEY_SETUPS,
158 
159 	_custom_keyboard_setup = NONE
160 };
161 
162 #define INDEFINATE_TIME_DELAY (INT32_MAX)
163 
164 /* ---------- shape descriptors */
165 
166 #include "shape_descriptors.h"
167 
168 /* ---------- structures */
169 
170 #define _X_MIRRORED_BIT 0x8000
171 #define _Y_MIRRORED_BIT 0x4000
172 #define _KEYPOINT_OBSCURED_BIT 0x2000
173 
174 struct shape_information_data
175 {
176 	uint16 flags; /* [x-mirror.1] [y-mirror.1] [keypoint_obscured.1] [unused.13] */
177 
178 	_fixed minimum_light_intensity; /* in [0,FIXED_ONE] */
179 
180 	short unused[5];
181 
182 	short world_left, world_right, world_top, world_bottom;
183 	short world_x0, world_y0;
184 };
185 
186 struct shape_animation_data // Also used in high_level_shape_definition
187 {
188 	int16 number_of_views; /* must be 1, 2, 5 or 8 */
189 
190 	int16 frames_per_view, ticks_per_frame;
191 	int16 key_frame;
192 
193 	int16 transfer_mode;
194 	int16 transfer_mode_period; /* in ticks */
195 
196 	int16 first_frame_sound, key_frame_sound, last_frame_sound;
197 
198 	int16 pixels_to_world;
199 
200 	int16 loop_frame;
201 
202 	int16 unused[14];
203 
204 	/* N*frames_per_view indexes of low-level shapes follow, where
205 	   N = 1 if number_of_views = _unanimated/_animated1,
206 	   N = 4 if number_of_views = _animated3to4/_animated4,
207 	   N = 5 if number_of_views = _animated3to5/_animated5,
208 	   N = 8 if number_of_views = _animated2to8/_animated5to8/_animated8 */
209 	int16 low_level_shape_indexes[1];
210 };
211 
212 /* ---------- prototypes/SHELL.C */
213 
214 enum { /* controllers */
215 	_single_player,
216 	_network_player,
217 	_demo,
218 	_replay,
219 	_replay_from_file,
220 	NUMBER_OF_PSEUDO_PLAYERS
221 };
222 
223 enum { /* states. */
224 	_display_intro_screens,
225 	_display_main_menu,
226 	_display_chapter_heading,
227 	_display_prologue,
228 	_display_epilogue,
229 	_display_credits,
230 	_display_intro_screens_for_demo,
231 	_display_quit_screens,
232 	NUMBER_OF_SCREENS,
233 	_game_in_progress= NUMBER_OF_SCREENS,
234 	_quit_game,
235 	_close_game,
236 	_switch_demo,
237 	_revert_game,
238 	_change_level,
239 	_begin_display_of_epilogue,
240 	_displaying_network_game_dialogs,
241 	NUMBER_OF_GAME_STATES
242 };
243 
244 bool game_window_is_full_screen(void);
245 void set_change_level_destination(short level_number);
246 bool networking_available(void);
247 void free_and_unlock_memory(void);
248 
249 /* ---------- prototypes/INTERFACE.C */
250 
251 void initialize_game_state(void);
252 void force_game_state_change(void);
253 bool player_controlling_game(void);
254 
255 void toggle_suppression_of_background_tasks(void);
256 bool suppress_background_events(void);
257 
258 void set_game_state(short new_state);
259 short get_game_state(void);
260 short get_game_controller(void);
261 bool current_netgame_allows_microphone();
262 void set_change_level_destination(short level_number);
263 bool check_level_change(void);
264 void pause_game(void);
265 void resume_game(void);
266 void portable_process_screen_click(short x, short y, bool cheatkeys_down);
267 void process_main_menu_highlight_advance(bool reverse);
268 void process_main_menu_highlight_select(bool cheatkeys_down);
269 void draw_menu_button_for_command(short index);
270 void update_interface_display(void);
271 bool idle_game_state(uint32 ticks);
272 void display_main_menu(void);
273 void do_menu_item_command(short menu_id, short menu_item, bool cheat);
274 bool interface_fade_finished(void);
275 void stop_interface_fade(void);
276 bool enabled_item(short item);
277 void paint_window_black(void);
278 
279 /* ---------- prototypes/INTERFACE_MACINTOSH.C */
280 void do_preferences(void);
281 short get_level_number_from_user(void);
282 void toggle_menus(bool game_started);
283 void install_network_microphone(void);
284 void remove_network_microphone(void);
285 
286 // Should return NONE if user cancels, 0 for single player, or 1 for multiplayer.
287 // Game has been loaded from file before this is called so elements like
288 // dynamic_world->player_count are available.  Cursor has been hidden when called.
289 size_t should_restore_game_networked(FileSpecifier& file);
290 
291 void show_movie(short index);
292 
293 void exit_networking(void);
294 
295 void load_main_menu_buffers(short base_id);
296 bool main_menu_buffers_loaded(void);
297 void main_menu_bit_depth_changed(short base_id);
298 void free_main_menu_buffers(void);
299 void draw_main_menu(void);
300 void draw_menu_button(short index, bool pressed);
301 
302 /* ---------- prototypes/INTERFACE_MACINTOSH.C- couldn't think of a better place... */
303 void hide_cursor(void);
304 void show_cursor(void);
305 void set_drawing_clip_rectangle(short top, short left, short bottom, short right);
306 
307 /* ---------- prototypes/SHAPES.C */
308 void *get_global_shading_table(void);
309 
310 short get_shape_descriptors(short shape_type, shape_descriptor *buffer);
311 
312 #define get_shape_bitmap_and_shading_table(shape, bitmap, shading_table, shading_mode) extended_get_shape_bitmap_and_shading_table(GET_DESCRIPTOR_COLLECTION(shape), \
313 	GET_DESCRIPTOR_SHAPE(shape), (bitmap), (shading_table), (shading_mode))
314 void extended_get_shape_bitmap_and_shading_table(short collection_code, short low_level_shape_index,
315 	struct bitmap_definition **bitmap, void **shading_tables, short shading_mode);
316 
317 #define get_shape_information(shape) extended_get_shape_information(GET_DESCRIPTOR_COLLECTION(shape), GET_DESCRIPTOR_SHAPE(shape))
318 struct shape_information_data *extended_get_shape_information(short collection_code, short low_level_shape_index);
319 
320 void get_shape_hotpoint(shape_descriptor texture, short *x0, short *y0);
321 struct shape_animation_data *get_shape_animation_data(shape_descriptor texture);
322 void process_collection_sounds(short colleciton_code, void (*process_sound)(short sound_index));
323 
324 #define mark_collection_for_loading(c) mark_collection((c), true)
325 #define mark_collection_for_unloading(c) mark_collection((c), false)
326 void mark_collection(short collection_code, bool loading);
327 void strip_collection(short collection_code);
328 void load_collections(bool with_progress_bar, bool is_opengl);
329 int count_replacement_collections();
330 void load_replacement_collections();
331 void unload_all_collections(void);
332 
333 void set_shapes_patch_data(uint8 *data, size_t length);
334 uint8* get_shapes_patch_data(size_t &length);
335 
336 // LP additions:
337 // Whether or not collection is present
338 bool is_collection_present(short collection_index);
339 // Number of texture frames in a collection (good for wall-texture error checking)
340 short get_number_of_collection_frames(short collection_index);
341 // Number of bitmaps in a collection (good for allocating texture information for OpenGL)
342 short get_number_of_collection_bitmaps(short collection_index);
343 // Which bitmap index for a frame (good for OpenGL texture rendering)
344 short get_bitmap_index(short collection_index, short low_level_shape_index);
345 // Get CLUT for collection
346 struct rgb_color_value *get_collection_colors(short collection_index, short clut_number, int &num_colors);
347 
348 // ZZZ: made these visible
349 struct low_level_shape_definition *get_low_level_shape_definition(short collection_index, short low_level_shape_index);
350 
351 
352 /* ---------- prototypes/PREPROCESS_MAP_MAC.C */
353 void setup_revert_game_info(struct game_data *game_info, struct player_start_data *start, struct entry_point *entry);
354 bool revert_game(void);
355 bool load_game(bool use_last_load);
356 bool save_game(void);
357 bool save_game_full_auto(bool inOverwriteRecent);
358 void restart_game(void);
359 
360 /* ---------- prototypes/GAME_WAD.C */
361 /* Map transferring fuctions */
362 int32 get_net_map_data_length(void *data);
363 bool process_net_map_data(void *data); /* Note that this frees it as well */
364 void *get_map_for_net_transfer(struct entry_point *entry);
365 
366 /* ---------- prototypes/VBL.C */
367 
368 void set_keyboard_controller_status(bool active);
369 bool get_keyboard_controller_status(void);
370 void pause_keyboard_controller(bool active);
371 int32 get_heartbeat_count(void);
372 void sync_heartbeat_count(void);
373 void process_action_flags(short player_identifier, const uint32 *action_flags, short count);
374 void rewind_recording(void);
375 void stop_recording(void);
376 void stop_replay(void);
377 void move_replay(void);
378 void check_recording_replaying(void);
379 bool has_recording_file(void);
380 void increment_replay_speed(void);
381 void decrement_replay_speed(void);
382 void reset_recording_and_playback_queues(void);
383 uint32 parse_keymap(void);
384 
385 /* ---------- prototypes/GAME_DIALOGS.C */
386 
387 bool handle_preferences_dialog(void);
388 void handle_load_game(void);
389 void handle_save_game(void);
390 bool handle_start_game(void);
391 bool quit_without_saving(void);
392 
393 /* ---------- prototypes/GAME_WINDOW.C */
394 void scroll_inventory(short dy);
395 
396 /* ---------- prototypes/NETWORK.C */
397 
398 enum {	// Results for network_join
399 	kNetworkJoinFailedUnjoined,
400         kNetworkJoinFailedJoined,
401         kNetworkJoinedNewGame,
402         kNetworkJoinedResumeGame
403 };
404 
405 bool network_gather(bool inResumingGame);
406 int network_join(void);
407 
408 /* ---------- prototypes/NETWORK_MICROPHONE.C */
409 
410 void handle_microphone(bool triggered);
411 
412 /* ---------- prototypes/PHYSICS.C */
413 
414 void reset_absolute_positioning_device(_fixed yaw, _fixed pitch, _fixed velocity);
415 
416 /* ---------- prototypes/IMPORT_DEFINITIONS.C */
417 
418 void init_physics_wad_data();
419 void import_definition_structures(void);
420 
421 /* ---------- prototypes/KEYBOARD_DIALOG.C */
422 bool configure_key_setup(short *keycodes);
423 
424 /* --------- from PREPROCESS_MAP_MAC.C */
425 bool have_default_files(void);
426 void get_default_external_resources_spec(FileSpecifier& File);
427 void get_default_map_spec(FileSpecifier& File);
428 void get_default_physics_spec(FileSpecifier& File);
429 void get_default_sounds_spec(FileSpecifier& File);
430 void get_default_shapes_spec(FileSpecifier& File);
431 bool get_default_theme_spec(FileSpecifier& File);
432 // ZZZ addition: since Mac versions now search for any candidate files instead of picking
433 // by name, new interface to search for all simultaneously instead of duplicating effort.
434 void get_default_file_specs(FileSpecifier* outMapSpec, FileSpecifier* outShapesSpec, FileSpecifier* outSoundsSpec, FileSpecifier* outPhysicsSpec);
435 
436 // external resources: terminals for Marathon 1
437 void set_external_resources_file(FileSpecifier&);
438 void close_external_resources();
439 extern OpenedResourceFile ExternalResources;
440 
441 // LP change: resets field of view to whatever the player had had when reviving
442 void ResetFieldOfView();
443 
444 // LP change: modification of Josh Elsasser's dont-switch-weapons patch
445 bool dont_switch_to_new_weapon();
446 
447 bool dont_auto_recenter();
448 
449 // ZZZ: let code disable (standardize)/enable behavior modifiers like
450 // dont_switch
451 void standardize_player_behavior_modifiers();
452 void restore_custom_player_behavior_modifiers();
453 
454 // ZZZ: return whether the user's behavior matches standard behavior
455 // (either by being forced so or by chosen that way)
456 bool is_player_behavior_standard();
457 
458 // LP change: force reload of view context
459 void ReloadViewContext();
460 
461 class InfoTree;
462 void parse_mml_infravision(const InfoTree& root);
463 void reset_mml_infravision();
464 void parse_mml_control_panels(const InfoTree& root);
465 void reset_mml_control_panels();
466 
467 #endif
468