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/MenuUI/TechMenu.cpp $
15 * C module that contains functions to drive the Tech Menu user interface
18 * Revision 1.9 2005/03/29 02:18:47 taylor
19 * Various 64-bit platform fixes
20 * Fix compiler errors with MAKE_FS1 and fix gr_set_bitmap() too
21 * Make sure that turrets can fire at asteroids for FS1 (needed for a couple missions)
22 * Streaming audio support (big thanks to Pierre Willenbrock!!)
23 * Removed dependance on strings.tbl for FS1 since we don't actually need it now
25 * Revision 1.8 2004/09/20 01:31:44 theoddone33
28 * Revision 1.7 2003/08/03 16:10:29 taylor
29 * cleanup; compile warning fixes
31 * Revision 1.6 2003/05/25 02:30:42 taylor
34 * Revision 1.5 2002/06/17 06:33:09 relnev
35 * ryan's struct patch for gcc 2.95
37 * Revision 1.4 2002/06/09 04:41:22 relnev
38 * added copyright header
40 * Revision 1.3 2002/06/02 04:26:34 relnev
43 * Revision 1.2 2002/05/07 03:16:46 theoddone33
44 * The Great Newline Fix
46 * Revision 1.1.1.1 2002/05/03 03:28:09 root
50 * 43 11/02/99 3:22p Jefff
51 * translate ship names in tech room
53 * 42 10/25/99 5:47p Jefff
54 * reassigned some xstr ids
56 * 41 10/12/99 4:50p Jefff
58 * 40 9/08/99 11:09a Dave
59 * Use stills for intel and weapon stuff in the techroom if animations
62 * 39 9/05/99 11:19p Dave
63 * Made d3d texture cache much more safe. Fixed training scoring bug where
64 * it would backout scores without ever having applied them in the first
67 * 38 9/03/99 11:19a Jefff
68 * fixed double render of intel descriptions
70 * 37 9/03/99 1:32a Dave
71 * CD checking by act. Added support to play 2 cutscenes in a row
72 * seamlessly. Fixed super low level cfile bug related to files in the
73 * root directory of a CD. Added cheat code to set campaign mission # in
76 * 36 9/01/99 5:12p Jefff
77 * Fixed bad scroll bug
79 * 35 8/25/99 3:03p Jefff
80 * 'more' indicator, lotsa coord changes for new background, disabling of
81 * buttons in trackball mode, list follows selected item when prev/next
84 * 34 8/24/99 8:55p Dave
85 * Make sure nondimming pixels work properly in tech menu.
87 * 33 8/24/99 10:47a Jefff
88 * tech room weapon anims. added tech anim field to weapons.tbl
90 * 32 8/10/99 5:29p Jefff
91 * use new tech_title field in weapons array
93 * 31 8/10/99 3:45p Jefff
94 * Put the smack down on the tech room. Its all new, but tastefully done.
96 * 30 8/09/99 5:53p Jefff
98 * 29 8/02/99 10:27a Jefff
99 * removed a warning for the time being
101 * 28 8/02/99 10:13a Jefff
102 * started scrubbing, waiting till after demo to continue
104 * 27 7/28/99 1:02p Jefff
105 * Changed "Species" to "Intelligence" -- also changed in strings.tbl.
107 * 26 7/26/99 4:33p Jordonr
108 * Don't need techroom palette
110 * 25 7/20/99 1:49p Dave
111 * Peter Drake build. Fixed some release build warnings.
113 * 24 7/19/99 2:13p Dave
114 * Added some new strings for Heiko.
116 * 23 7/14/99 9:42a Dave
117 * Put in clear_color debug function. Put in base for 3dnow stuff / P3
120 * 22 6/16/99 4:06p Dave
121 * New pilot info popup. Added new draw-bitmap-as-poly function.
123 * 21 5/09/99 8:57p Dave
124 * Final E3 build preparations.
126 * 20 5/09/99 6:00p Dave
127 * Lots of cool new effects. E3 build tweaks.
129 * 19 4/29/99 2:16p Neilk
130 * added a 2nd callback for slider so its model is not loaded on mouselock
131 * until mouse button is released
133 * 18 4/26/99 5:05p Neilk
134 * updated to new artwork, added slider support
136 * 17 4/25/99 3:02p Dave
137 * Build defines for the E3 build.
139 * 16 4/23/99 12:01p Johnson
140 * Added SIF_HUGE_SHIP
142 * 15 4/12/99 10:07p Dave
143 * Made network startup more forgiving. Added checkmarks to dogfight
144 * screen for players who hit commit.
146 * 14 4/08/99 2:10a Dave
147 * Numerous bug fixes for the beta. Added builtin mission info for the
150 * 13 2/19/99 11:42a Dave
151 * Put in model rendering autocentering.
153 * 12 2/01/99 5:55p Dave
154 * Removed the idea of explicit bitmaps for buttons. Fixed text
155 * highlighting for disabled gadgets.
157 * 11 1/30/99 5:08p Dave
158 * More new hi-res stuff.Support for nice D3D textures.
160 * 10 1/29/99 3:56p Neilk
161 * Converted tech_infos screens to multiresolution
163 * 9 1/29/99 3:54p Neilk
165 * 8 1/29/99 12:47a Dave
166 * Put in sounds for beam weapon. A bunch of interface screens (tech
169 * 7 11/30/98 1:07p Dave
170 * 16 bit conversion, first run.
172 * 6 10/23/98 3:51p Dave
173 * Full support for tstrings.tbl and foreign languages. All that remains
174 * is to make it active in Fred.
176 * 5 10/16/98 9:40a Andsager
177 * Remove ".h" files from model.h
179 * 4 10/13/98 2:47p Andsager
180 * Remove reference to Tech_shivan_species_avail
182 * 3 10/13/98 9:28a Dave
183 * Started neatening up freespace.h. Many variables renamed and
184 * reorganized. Added AlphaColors.[h,cpp]
186 * 2 10/07/98 10:53a Dave
189 * 1 10/07/98 10:49a Dave
191 * 67 9/21/98 10:02p Dave
192 * Last minute changes to techroom weapon/ship/species stuff.
194 * 66 9/07/98 2:49p Dan
195 * Removed spurious Assert
197 * 65 7/06/98 2:42p Hoffoss
198 * Fixed bug with weapons shown in tech database.
200 * 64 6/10/98 11:48a Lawrance
201 * fix bug with trying to free NULL anims
203 * 63 6/05/98 9:54a Lawrance
206 * 62 6/01/98 11:43a John
207 * JAS & MK: Classified all strings for localization.
209 * 61 5/26/98 11:10a Lawrance
210 * Fix bug where window controls get disabled when F1 pressed twice
212 * 60 5/23/98 10:38p Lawrance
213 * Avoid doing a cfile refresh when running debug
215 * 59 5/23/98 6:49p Lawrance
216 * Fix problems with refreshing the file list when a CD is inserted
218 * 58 5/22/98 11:15a Lawrance
219 * Tweak how CD gets asked for
221 * 57 5/22/98 1:06a Hoffoss
222 * Made Fred not use OLE.
224 * 56 5/21/98 6:57p Lawrance
225 * Only ask for the CD once
227 * 55 5/21/98 12:46a Hoffoss
228 * Made text offset reset when new description is loaded.
230 * 54 5/20/98 9:46p John
231 * added code so the places in code that change half the palette don't
232 * have to clear the screen.
234 * 53 5/20/98 3:28p Sandeep
235 * Fixed bug where in multi only discovered weapons show up, and in single
236 * all weapons showed up (backwards).
238 * 52 5/20/98 2:11p Hoffoss
239 * Fixed some species description problems.
241 * 51 5/18/98 6:45p Hoffoss
242 * Added species descriptions to species database in techroom.
244 * 50 5/17/98 6:13p Hoffoss
245 * Fixed scrolling of info text area.
251 #include "gamesequence.h"
252 #include "techmenu.h"
255 #include "snazzyui.h"
256 #include "managepilot.h"
260 #include "missioncampaign.h"
261 #include "missionshipchoice.h"
262 #include "freespace.h"
263 #include "mainhallmenu.h"
264 #include "missionscreencommon.h"
270 #include "contexthelp.h"
271 #include "alphacolors.h"
272 #include "animplay.h"
273 #include "localize.h"
274 #include "lighting.h"
276 #define REVOLUTION_RATE 5.2f
279 #define NUM_BUTTONS 18
281 #define NUM_BUTTONS 16
284 #define LIST_BUTTONS_MAX 41
286 #define SHIPS_DATA_MODE (1<<0)
287 #define WEAPONS_DATA_MODE (1<<1)
288 #define SPECIES_DATA_MODE (1<<2)
289 #define WEAPONS_SPECIES_DATA_MODE (WEAPONS_DATA_MODE | SPECIES_DATA_MODE)
291 #define SHIPS_DATA_TAB 0
292 #define WEAPONS_DATA_TAB 1
293 #define INTEL_DATA_TAB 2
294 #define TECH_DATABASE_TAB 3
295 #define SIMULATOR_TAB 4
296 #define CUTSCENES_TAB 5
297 #define CREDITS_TAB 6
299 #define SCROLL_LIST_UP 7
300 #define SCROLL_LIST_DOWN 8
301 #define SCROLL_INFO_UP 9
302 #define SCROLL_INFO_DOWN 10
304 #define PREV_ENTRY_BUTTON 11
305 #define NEXT_ENTRY_BUTTON 12
307 #define HELP_BUTTON 13
308 #define OPTIONS_BUTTON 14
309 #define EXIT_BUTTON 15
312 #define PREV_ENTRY_BUTTON2 16
313 #define NEXT_ENTRY_BUTTON2 17
317 #define REPEAT (1<<0)
318 #define NO_MOUSE_OVER_SOUND (1<<1)
320 // indicies for coords
321 #define SHIP_X_COORD 0
322 #define SHIP_Y_COORD 1
323 #define SHIP_W_COORD 2
324 #define SHIP_H_COORD 3
326 // background filename for species
327 // note weapon filename is now same as ship filename
328 char *Tech_background_filename[GR_NUM_RESOLUTIONS] = {
332 char *Tech_mask_filename[GR_NUM_RESOLUTIONS] = {
337 char *Tech_slider_filename[GR_NUM_RESOLUTIONS] = {
344 // need the second background for FS1
345 char *Tech_data_background_filename = {
348 char *Tech_data_mask_filename = {
353 int Tech_list_coords[GR_NUM_RESOLUTIONS][4] = {
366 int Tech_ship_display_coords[GR_NUM_RESOLUTIONS][4] = {
379 int Tech_desc_coords[GR_NUM_RESOLUTIONS][4] = {
392 int Tech_ani_coords[GR_NUM_RESOLUTIONS][2] = {
406 int Tech_data_desc_coords[GR_NUM_RESOLUTIONS][4] = {
417 int Tech_slider_coords[GR_NUM_RESOLUTIONS][4] = {
428 int Tech_detail_backup;
429 int Tech_texture_backup;
431 #define MAX_TEXT_LINES 100
432 #define MAX_TEXT_LINE_LEN 256
434 struct techroom_buttons {
440 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
442 techroom_buttons(char *name, int x1, int y1, int xt1, int yt1, int h, int t, int f = 0) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), tab(t), flags(f) {}
445 static techroom_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS] = {
448 techroom_buttons("TDB_04", 20, 429, -1, -1, 4, -1), // ship data tab
449 techroom_buttons("TDB_05", 70, 429, -1, -1, 5, -1), // weapons data tab
450 techroom_buttons("TDB_06", 147, 429, -1, -1, 6, -1), // species data tab
451 techroom_buttons("TDB_00", 0, 0, -1, -1, 0, -1), // technical database tab
452 techroom_buttons("TDB_01", 0, 19, -1, -1, 1, -1), // mission simulator tab
453 techroom_buttons("TDB_02", 0, 35, -1, -1, 2, -1), // cutscenes tab
454 techroom_buttons("TDB_03", 0, 56, -1, -1, 3, -1), // credits tab
455 techroom_buttons("TSB_16", 0, 206, -1, -1, 16, SHIPS_DATA_MODE), // list up
456 techroom_buttons("TSB_17", 0, 254, -1, -1, 17, SHIPS_DATA_MODE), // list down
457 techroom_buttons("TSB_18", 411, 351, -1, -1, 18, SHIPS_DATA_MODE), // description up
458 techroom_buttons("TSB_19", 411, 397, -1, -1, 19, SHIPS_DATA_MODE), // description down
459 // techroom_buttons("TDB_11", 558, 272, -1, -1, 11, WEAPONS_SPECIES_DATA_MODE), // prev data entry
460 // techroom_buttons("TDB_12", 606, 272, -1, -1, 12, WEAPONS_SPECIES_DATA_MODE), // next data entry
461 techroom_buttons("TSB_22", 477, 338, -1, -1, 22, SHIPS_DATA_MODE), // prev data entry
462 techroom_buttons("TSB_23", 524, 338, -1, -1, 23, SHIPS_DATA_MODE), // next data entry
463 techroom_buttons("TDB_13", 469, 425, -1, -1, 13, -1), // help
464 techroom_buttons("TDB_14", 448, 452, -1, -1, 14, -1), // options
465 techroom_buttons("TDB_15", 552, 411, -1, -1, 15, -1), // exit
466 techroom_buttons("TDB_11", 477, 291, -1, -1, 11, WEAPONS_SPECIES_DATA_MODE), // prev data entry
467 techroom_buttons("TDB_12", 524, 291, -1, -1, 12, WEAPONS_SPECIES_DATA_MODE), // next data entry
469 techroom_buttons("TDB_04", 406, 384, 447, 393, 4, -1), // ship data tab
470 techroom_buttons("TDB_05", 404, 418, 447, 429, 5, -1), // weapons data tab
471 techroom_buttons("TDB_06", 404, 447, 447, 461, 6, -1), // species data tab
472 techroom_buttons("TDB_00", 7, 3, 37, 7, 0, -1), // technical database tab
473 techroom_buttons("TDB_01", 7, 18, 37, 23, 1, -1), // mission simulator tab
474 techroom_buttons("TDB_02", 7, 34, 37, 38, 2, -1), // cutscenes tab
475 techroom_buttons("TDB_03", 7, 49, 37, 54, 3, -1), // credits tab
476 techroom_buttons("TDB_07", 1, 86, -1, -1, 7, SHIPS_DATA_MODE, REPEAT), // prev data entry
477 techroom_buttons("TDB_08", 1, 317, -1, -1, 8, SHIPS_DATA_MODE, REPEAT), // next data entry
478 techroom_buttons("TDB_09", 1, 406, -1, -1, 9, SHIPS_DATA_MODE, REPEAT), // prev data entry
479 techroom_buttons("TDB_10", 1, 447, -1, -1, 10, SHIPS_DATA_MODE, REPEAT), // next data entry
480 //techroom_buttons("TDB_11", 558, 272, -1, -1, 11, WEAPONS_SPECIES_DATA_MODE), // prev data entry
481 //techroom_buttons("TDB_12", 606, 272, -1, -1, 12, WEAPONS_SPECIES_DATA_MODE), // next data entry
482 techroom_buttons("TDB_11a",559, 323, -1, -1, 11, SHIPS_DATA_MODE, REPEAT), // prev data entry
483 techroom_buttons("TDB_12a",609, 323, -1, -1, 12, SHIPS_DATA_MODE, REPEAT), // next data entry
484 techroom_buttons("TDB_13", 533, 425, 500, 440, 13, -1), // help
485 techroom_buttons("TDB_14", 533, 455, 479, 464, 14, -1), // options
486 techroom_buttons("TDB_15a",571, 425, 588, 413, 15, -1), // exit
490 techroom_buttons("2_TDB_04", 649, 614, 717, 630, 4, -1), // ship data tab
491 techroom_buttons("2_TDB_05", 646, 669, 717, 687, 5, -1), // weapons data tab
492 techroom_buttons("2_TDB_06", 646, 716, 717, 739, 6, -1), // species data tab
493 techroom_buttons("2_TDB_00", 12, 5, 59, 12, 0, -1), // technical database tab
494 techroom_buttons("2_TDB_01", 12, 31, 59, 37, 1, -1), // mission simulator tab
495 techroom_buttons("2_TDB_02", 12, 56, 59, 62, 2, -1), // cutscenes tab
496 techroom_buttons("2_TDB_03", 12, 81, 59, 88, 3, -1), // credits tab
497 techroom_buttons("2_TDB_07", 1, 138, -1, -1, 7, SHIPS_DATA_MODE, REPEAT), // prev data entry
498 techroom_buttons("2_TDB_08", 1, 507, -1, -1, 8, SHIPS_DATA_MODE, REPEAT), // next data entry
499 techroom_buttons("2_TDB_09", 1, 649, -1, -1, 9, SHIPS_DATA_MODE, REPEAT), // prev data entry
500 techroom_buttons("2_TDB_10", 1, 716, -1, -1, 10, SHIPS_DATA_MODE, REPEAT), // next data entry
503 techroom_buttons("2_TDB_11", 893, 436, -1, -1, 11, WEAPONS_SPECIES_DATA_MODE), // prev data entry
504 techroom_buttons("2_TDB_12", 970, 436, -1, -1, 12, WEAPONS_SPECIES_DATA_MODE), // next data entry
506 techroom_buttons("2_TDB_11a", 895, 518, -1, -1, 11, SHIPS_DATA_MODE, REPEAT), // prev data entry
507 techroom_buttons("2_TDB_12a", 974, 518, -1, -1, 12, SHIPS_DATA_MODE, REPEAT), // next data entry
508 techroom_buttons("2_TDB_13", 854, 681, 800, 704, 13, -1), // help
509 techroom_buttons("2_TDB_14", 854, 728, 780, 743, 14, -1), // options
510 techroom_buttons("2_TDB_15a", 914, 681, 930, 660, 15, -1), // exit
514 static UI_WINDOW Ui_window;
515 static UI_BUTTON View_window;
516 //static int Background_bitmap;
518 static int Tech_data_background_bitmap;
520 static int Tech_background_bitmap;
522 // static int List_size;
523 static int List_offset;
524 static int Select_tease_line;
525 static int Trackball_mode = 1;
526 static int Trackball_active = 0;
527 static matrix Techroom_ship_orient = IDENTITY_MATRIX;
528 // static int Tech_room_ask_for_cd;
530 static int Text_size;
531 static int Text_offset;
532 static int Text_line_size[MAX_TEXT_LINES];
533 static char *Text_lines[MAX_TEXT_LINES];
535 static int Cur_entry; // this is the current entry selected, using entry indexing
536 static int Cur_entry_index; // this is the current entry selected, using master list indexing
537 static int Techroom_ship_modelnum;
538 static float Techroom_ship_rot;
539 static UI_BUTTON List_buttons[LIST_BUTTONS_MAX]; // buttons for each line of text in list
540 static int Anim_playing_id = -1;
541 static anim_instance *Cur_anim_instance = NULL;
542 //static int Palette_bmp;
544 static int ShipWin01;
545 static int ShipWin02;
546 static int ShipWin03;
547 static int ShipWin04;
549 static ubyte Palette[768];
550 //static char Palette_name[128]; // no longer used
552 static int Ships_loaded = 0;
553 static int Weapons_loaded = 0;
554 static int Intel_loaded = 0;
556 // out entry data struct & vars
558 int index; // index into the master table that its in (ie Ship_info[])
559 char* name; // ptr to name string
560 char* desc; // ptr to description string
561 anim* animation; // ptr to the animation
562 int bitmap; // bitmap handle
563 int has_anim; // flag to indicate the presence of an animation for this item
566 static tech_list_entry Ship_list[MAX_SHIP_TYPES];
567 static int Ship_list_size = 0;
568 static tech_list_entry Weapon_list[MAX_WEAPON_TYPES];
569 static int Weapon_list_size = 0;
570 static tech_list_entry Intel_list[MAX_INTEL_ENTRIES];
571 static int Intel_list_size = 0;
572 static tech_list_entry *Current_list; // points to currently valid display list
573 static int Current_list_size = 0;
577 static UI_SLIDER2 Tech_slider;
582 static char *Intel_anim_filenames[MAX_INTEL_ENTRIES] = {
590 // Intelligence master data structs (these get inited @ game startup from species.tbl)
591 intel_data Intel_info[MAX_INTEL_ENTRIES];
592 int Intel_info_size = 0;
594 // some prototypes to make you happy
595 int techroom_load_ani(anim **animpp, char *name);
596 void tech_common_render();
597 void techroom_start_anim();
598 void tech_scroll_list_up();
599 void tech_scroll_list_down();
601 void techroom_data_init();
602 void techroom_tab_setup(int set_palette);
608 ////////////////////////////////////////////////////
609 // like, functions and stuff
611 void techroom_init_desc(char *src, int w)
613 Text_size = Text_offset = 0;
618 Text_size = split_str(src, w, Text_line_size, Text_lines, MAX_TEXT_LINES);
619 Assert(Text_size >= 0 && Text_size < MAX_TEXT_LINES);
622 void techroom_select_new_entry()
624 Assert(Current_list != NULL);
625 if (Current_list == NULL) return;
627 Cur_entry_index = Current_list[Cur_entry].index;
629 // if we are in the ships tab, load the ship model
630 if (Tab == SHIPS_DATA_TAB) {
631 ship_info *sip = &Ship_info[Cur_entry_index];
633 #ifdef MULTIPLAYER_BETA_BUILD
634 // don't load supercaps in the beta
635 if((sip->flags & SIF_SUPERCAP) || (sip->flags & SIF_DRYDOCK)){
636 Techroom_ship_modelnum = -1;
638 Techroom_ship_modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);
641 // page in ship textures properly (takes care of nondimming pixels)
642 model_page_in_textures(Techroom_ship_modelnum, Cur_entry_index);
644 Techroom_ship_modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);
646 // page in ship textures properly (takes care of nondimming pixels)
647 model_page_in_textures(Techroom_ship_modelnum, Cur_entry_index);
650 Techroom_ship_modelnum = -1;
654 // Techroom_ship_rot = PI;
657 if (Tab == (WEAPONS_DATA_TAB || INTEL_DATA_TAB)){
658 techroom_init_desc(Current_list[Cur_entry].desc, Tech_data_desc_coords[gr_screen.res][SHIP_W_COORD]);
660 techroom_init_desc(Current_list[Cur_entry].desc, Tech_desc_coords[gr_screen.res][SHIP_W_COORD]);
663 techroom_init_desc(Current_list[Cur_entry].desc, Tech_desc_coords[gr_screen.res][SHIP_W_COORD]);
665 techroom_start_anim();
668 // write out the current description in the bottom window
669 void techroom_render_desc(int xo, int yo, int h)
671 int y, z, len, font_height;
672 char line[MAX_TEXT_LINE_LEN + 1];
674 font_height = gr_get_font_height();
678 while (y + font_height <= h) {
683 len = Text_line_size[z];
684 if (len > MAX_TEXT_LINE_LEN){
685 len = MAX_TEXT_LINE_LEN;
688 strncpy(line, Text_lines[z], len);
690 gr_string(xo, yo + y, line);
696 // maybe output 'more' indicator
697 #ifndef MAKE_FS1 // not used in original
698 if ( z < Text_size ) {
699 // can be scrolled down
700 int more_txt_x = Tech_desc_coords[gr_screen.res][0] + (Tech_desc_coords[gr_screen.res][2]/2) - 10; // FIXME should move these to constants since they dont move
701 int more_txt_y = Tech_desc_coords[gr_screen.res][1] + Tech_desc_coords[gr_screen.res][3]; // located below brief text, centered
703 gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469)));
704 gr_set_color_fast(&Color_black);
705 gr_rect(more_txt_x-2, more_txt_y, w+3, h);
706 gr_set_color_fast(&Color_red);
707 gr_string(more_txt_x, more_txt_y, XSTR("more", 1469)); // base location on the input x and y?
713 // new version of weapons
714 void techroom_weapons_render2(float frametime)
716 // render common stuff
718 tech_common_render();
720 // render description in its box
721 gr_set_color_fast(&Color_text_normal);
722 techroom_render_desc(Tech_data_desc_coords[gr_screen.res][SHIP_X_COORD], Tech_data_desc_coords[gr_screen.res][SHIP_Y_COORD], Tech_data_desc_coords[gr_screen.res][SHIP_H_COORD]);
725 // render the animation
727 // JAS: This code is hacked to allow the animation to use all 256 colors
728 extern int Palman_allow_any_color;
729 Palman_allow_any_color = 1;
730 anim_render_all(0, frametime);
731 Palman_allow_any_color = 0;
734 // if our active item has a bitmap instead of an animation, draw it
735 if((Cur_entry > 0) && (Current_list[Cur_entry].animation == NULL) && (Current_list[Cur_entry].bitmap >= 0)){
736 gr_set_bitmap(Current_list[Cur_entry].bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
737 gr_bitmap(Tech_ani_coords[gr_screen.res][0], Tech_ani_coords[gr_screen.res][1]);
741 // renders the stuff common to all 3 tech room tabs
742 void tech_common_render()
745 int y, z, font_height;
747 // render description in its box
748 gr_set_color_fast(&Color_text_normal);
749 techroom_render_desc(Tech_desc_coords[gr_screen.res][SHIP_X_COORD], Tech_desc_coords[gr_screen.res][SHIP_Y_COORD], Tech_desc_coords[gr_screen.res][SHIP_H_COORD]);
751 font_height = gr_get_font_height();
753 // draw the list of entries
756 while (y + font_height <= Tech_list_coords[gr_screen.res][SHIP_H_COORD]) {
757 if (z >= Current_list_size) {
761 if (z == Cur_entry) {
762 gr_set_color_fast(&Color_text_selected);
763 } else if (z == Select_tease_line) {
764 gr_set_color_fast(&Color_text_subselected);
766 gr_set_color_fast(&Color_text_normal);
769 strcpy(buf, Current_list[z].name);
771 lcl_translate_ship_name(buf);
774 gr_force_fit_string(buf, 255, Tech_list_coords[gr_screen.res][SHIP_W_COORD]);
775 gr_string(Tech_list_coords[gr_screen.res][SHIP_X_COORD], Tech_list_coords[gr_screen.res][SHIP_Y_COORD] + y, buf);
777 List_buttons[z - List_offset].update_dimensions(Tech_list_coords[gr_screen.res][SHIP_X_COORD], Tech_list_coords[gr_screen.res][SHIP_Y_COORD] + y, Tech_list_coords[gr_screen.res][SHIP_W_COORD], font_height);
778 List_buttons[z - List_offset].enable(1);
784 // disable the rest of the list buttons
786 while (z < LIST_BUTTONS_MAX) {
787 List_buttons[z++].disable();
791 void techroom_ships_render(float frametime)
793 // render all the common stuff
794 tech_common_render();
796 // now render the trackball ship, which is unique to the ships tab
798 angles rot_angles, view_angles;
800 ship_info *sip = &Ship_info[Cur_entry_index];
802 // get correct revolution rate
803 rev_rate = REVOLUTION_RATE;
805 if (z & SIF_BIG_SHIP) {
808 if (z & SIF_HUGE_SHIP) {
812 // rotate the ship as much as required for this frame
813 Techroom_ship_rot += PI2 * frametime / rev_rate;
814 while (Techroom_ship_rot > PI2){
815 Techroom_ship_rot -= PI2;
819 gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0, -1.0f, -1.0f);
822 if (Trackball_active) {
826 if (Trackball_active) {
827 mouse_get_delta(&dx, &dy);
829 vm_trackball(-dx, -dy, &mat1);
830 vm_matrix_x_matrix(&mat2, &mat1, &Techroom_ship_orient);
831 Techroom_ship_orient = mat2;
836 // setup stuff needed to render the ship
837 view_angles.p = -0.6f;
838 view_angles.b = 0.0f;
839 view_angles.h = 0.0f;
840 vm_angles_2_matrix(&Techroom_ship_orient, &view_angles);
844 rot_angles.h = Techroom_ship_rot;
845 vm_rotate_matrix_by_angles(&Techroom_ship_orient, &rot_angles);
848 gr_set_clip(Tech_ship_display_coords[gr_screen.res][SHIP_X_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_Y_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_W_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_H_COORD]);
851 #ifdef MULTIPLAYER_BETA_BUILD
852 if((sip->flags & SIF_SUPERCAP) || (sip->flags & SIF_DRYDOCK)) {
853 gr_set_color_fast(&Color_bright);
854 gr_string(Tech_ship_display_coords[gr_screen.res][SHIP_X_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_Y_COORD] + 50, NOX("No soup for you!"));
858 g3_set_view_matrix(&sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 1.3f);
860 // lighting for techroom
862 vector light_dir = vmd_zero_vector;
864 light_add_directional(&light_dir, 0.85f, 1.0f, 1.0f, 1.0f);
865 // light_filter_reset();
867 // lighting for techroom
869 model_clear_instance(Techroom_ship_modelnum);
870 model_set_detail_level(0);
871 model_render(Techroom_ship_modelnum, &Techroom_ship_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER);
878 g3_set_view_matrix(&sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 1.3f);
880 // lighting for techroom
882 vector light_dir = vmd_zero_vector;
883 light_dir.xyz.y = 1.0f;
884 light_add_directional(&light_dir, 0.85f, 1.0f, 1.0f, 1.0f);
885 // light_filter_reset();
887 // lighting for techroom
889 model_clear_instance(Techroom_ship_modelnum);
890 model_set_detail_level(0);
891 model_render(Techroom_ship_modelnum, &Techroom_ship_orient, &vmd_zero_vector, MR_LOCK_DETAIL | MR_AUTOCENTER);
899 // select previous entry in current list
900 void tech_prev_entry()
904 Cur_entry = Current_list_size - 1;
906 // scroll to end of list
907 List_offset = Cur_entry - Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() + 1;
908 if (List_offset < 0) {
909 // this happens when there are not enough items to scroll
913 Tech_slider.force_currentItem(Tech_slider.get_numberItems());
916 // maybe adjust list position by 1
917 if (List_offset > Cur_entry) {
918 tech_scroll_list_up();
920 Tech_slider.forceUp();
925 techroom_select_new_entry();
926 gamesnd_play_iface(SND_SCROLL);
929 // select next entry in current list
930 void tech_next_entry()
933 if (Cur_entry >= Current_list_size) {
936 // scroll to beginning of list
939 Tech_slider.force_currentItem(Cur_entry);
942 // maybe adjust list position by 1
943 if (List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() <= Cur_entry) {
944 tech_scroll_list_down();
946 Tech_slider.forceDown();
951 techroom_select_new_entry();
952 gamesnd_play_iface(SND_SCROLL);
955 void tech_scroll_info_up()
959 gamesnd_play_iface(SND_SCROLL);
961 gamesnd_play_iface(SND_GENERAL_FAIL);
965 void tech_scroll_info_down()
969 if (Tab == SHIPS_DATA_TAB){
970 h = Tech_desc_coords[gr_screen.res][SHIP_H_COORD];
972 h = Tech_desc_coords[gr_screen.res][3];
975 if (Text_offset + h / gr_get_font_height() < Text_size) {
977 gamesnd_play_iface(SND_SCROLL);
979 gamesnd_play_iface(SND_GENERAL_FAIL);
983 void tech_scroll_list_up()
987 if (List_offset > 0) {
989 //last = List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() - 1;
990 gamesnd_play_iface(SND_SCROLL);
992 gamesnd_play_iface(SND_GENERAL_FAIL);
996 void tech_scroll_list_down()
998 if (List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() < Current_list_size) {
1000 gamesnd_play_iface(SND_SCROLL);
1002 gamesnd_play_iface(SND_GENERAL_FAIL);
1006 // this doesnt do a damn thing...
1007 void tech_ship_scroll_capture()
1009 techroom_select_new_entry();
1013 // this is obsolete - see techroom_weapons_render2(...)
1014 void techroom_weapons_render(float frametime)
1016 gr_set_color_fast(&Color_text_normal);
1017 techroom_render_desc(Tech_desc_coords[gr_screen.res][0], Tech_desc_coords[gr_screen.res][1], Tech_desc_coords[gr_screen.res][3]);
1020 // JAS: This code is hacked to allow the animation to use all 256 colors
1021 extern int Palman_allow_any_color;
1022 Palman_allow_any_color = 1;
1023 anim_render_all(0, frametime);
1024 Palman_allow_any_color = 0;
1027 // if our active item has a bitmap instead of an animation, draw it
1028 if((Cur_entry >= 0) && (Current_list[Cur_entry].animation == NULL) && (Current_list[Cur_entry].bitmap >= 0)){
1029 gr_set_bitmap(Current_list[Cur_entry].bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1030 gr_bitmap(Tech_ani_coords[gr_screen.res][0], Tech_ani_coords[gr_screen.res][1]);
1034 void techroom_intel_render(float frametime)
1037 tech_common_render();
1039 // render description in its box
1040 gr_set_color_fast(&Color_text_normal);
1041 techroom_render_desc(Tech_data_desc_coords[gr_screen.res][SHIP_X_COORD], Tech_data_desc_coords[gr_screen.res][SHIP_Y_COORD], Tech_data_desc_coords[gr_screen.res][SHIP_H_COORD]);
1045 // JAS: This code is hacked to allow the animation to use all 256 colors
1046 extern int Palman_allow_any_color;
1047 Palman_allow_any_color = 1;
1048 anim_render_all(0, frametime);
1049 Palman_allow_any_color = 0;
1052 // if our active item has a bitmap instead of an animation, draw it
1053 if((Cur_entry >= 0) && (Current_list[Cur_entry].animation == NULL) && (Current_list[Cur_entry].bitmap >= 0)){
1054 gr_set_bitmap(Current_list[Cur_entry].bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1055 gr_bitmap(Tech_ani_coords[gr_screen.res][0], Tech_ani_coords[gr_screen.res][1]);
1059 void techroom_stop_anim(int id)
1061 if (Cur_anim_instance && (id != Anim_playing_id)) {
1062 anim_stop_playing(Cur_anim_instance);
1063 Cur_anim_instance = NULL;
1067 void techroom_start_anim()
1071 anim_play_struct aps;
1073 if (Cur_entry < 0) {
1074 techroom_stop_anim(-1);
1075 Anim_playing_id = -1;
1078 if (Tab == WEAPONS_DATA_TAB) {
1081 id = Cur_entry + 2000; // this offset is arbitrary?
1084 techroom_stop_anim(id);
1086 // if we actually have an animation
1087 if(Current_list[Cur_entry].animation != NULL){
1088 animp = Current_list[Cur_entry].animation;
1090 if (id != Anim_playing_id) {
1091 Anim_playing_id = -1;
1093 anim_play_init(&aps, animp, Tech_ani_coords[gr_screen.res][0], Tech_ani_coords[gr_screen.res][1]);
1095 Cur_anim_instance = anim_play(&aps);
1096 Anim_playing_id = id;
1100 memcpy(Palette, animp->palette, 384);
1101 gr_set_palette(animp->name, Palette, 1);
1108 void techroom_change_tab(int num)
1110 int i, multi = 0, mask, font_height, max_num_entries_viewable;
1113 // Assert(Current_list_size >= 0);
1116 multi = Player->flags & PLAYER_FLAGS_IS_MULTI;
1118 for (i=0; i<LIST_BUTTONS_MAX; i++){
1119 List_buttons[i].disable();
1122 // disable some stuff in multiplayer
1123 if (Player->flags & PLAYER_FLAGS_IS_MULTI) {
1124 Buttons[gr_screen.res][SIMULATOR_TAB].button.disable();
1125 Buttons[gr_screen.res][CUTSCENES_TAB].button.disable();
1129 case SHIPS_DATA_TAB:
1130 mask = multi ? SIF_IN_TECH_DATABASE_M : SIF_IN_TECH_DATABASE;
1132 // load ship info if necessary
1133 if (Ships_loaded == 0) {
1135 for (i=0; i<Num_ship_types; i++) {
1137 if (Ship_info[i].flags & mask) {
1139 // make sure it has a description before displaying
1140 if ((Ship_info[i].flags && mask) && (Ship_info[i].tech_desc)) {
1142 // this ship should be displayed, fill out the entry struct
1143 Ship_list[Ship_list_size].bitmap = -1;
1144 Ship_list[Ship_list_size].index = i;
1145 Ship_list[Ship_list_size].animation = NULL; // no anim for ships
1146 Ship_list[Ship_list_size].has_anim = 0; // no anim for ships
1147 Ship_list[Ship_list_size].name = Ship_info[i].name;
1148 Ship_list[Ship_list_size].desc = Ship_info[i].tech_desc;
1155 Current_list = Ship_list;
1156 Current_list_size = Ship_list_size;
1158 font_height = gr_get_font_height();
1159 max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
1161 Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
1164 // no anim to start here
1167 case WEAPONS_DATA_TAB:
1169 techroom_data_init();
1171 // load weapon info & anims if necessary
1172 if (Weapons_loaded == 0) {
1173 Weapon_list_size = 0;
1174 mask = multi ? WIF_PLAYER_ALLOWED : WIF_IN_TECH_DATABASE;
1176 for (i=0; i<MAX_WEAPON_TYPES; i++) {
1177 if (Weapon_info[i].wi_flags & mask) {
1179 // note: hack here to exclude dogfight weapons -- dont put weapon in if it has same description as pvs weapon
1180 if ((Weapon_list_size > 0) && (!strcmp(Weapon_info[i].tech_desc, Weapon_list[Weapon_list_size-1].desc))) {
1182 // exclude entries with no description, basically the same as above but helps get rid of special cases as well
1183 if ((Weapon_list_size > 0) && (!Weapon_info[i].tech_desc)) {
1188 // we have a weapon that should be in the tech db, so fill out the entry struct
1189 Weapon_list[Weapon_list_size].index = i;
1190 Weapon_list[Weapon_list_size].desc = Weapon_info[i].tech_desc;
1191 Weapon_list[Weapon_list_size].has_anim = 1;
1192 Weapon_list[Weapon_list_size].name = Weapon_info[i].tech_title;
1193 Weapon_list[Weapon_list_size].bitmap = -1;
1194 if (Weapon_list[Weapon_list_size].name[0] == 0) {
1195 Weapon_list[Weapon_list_size].name = Weapon_info[i].name;
1199 // figure out the animation based on weapon name
1200 if (!strcmp(Weapon_info[i].name, "ML-16 Laser")) {
1201 strncpy(Weapon_info[i].tech_anim_filename, "CB_ML16.ani", NAME_LENGTH);
1202 } else if (!strcmp(Weapon_info[i].name, "Disruptor")) {
1203 strncpy(Weapon_info[i].tech_anim_filename, "CB_Disruptor.ani", NAME_LENGTH);
1204 } else if (!strcmp(Weapon_info[i].name, "D-Advanced")) {
1205 strncpy(Weapon_info[i].tech_anim_filename, "CB_DAdvanced.ani", NAME_LENGTH);
1206 } else if (!strcmp(Weapon_info[i].name, "Avenger")) {
1207 strncpy(Weapon_info[i].tech_anim_filename, "CB_Avenger.ani", NAME_LENGTH);
1208 } else if (!strcmp(Weapon_info[i].name, "Flail")) {
1209 strncpy(Weapon_info[i].tech_anim_filename, "CB_Flail.ani", NAME_LENGTH);
1210 } else if (!strcmp(Weapon_info[i].name, "Prometheus")) {
1211 strncpy(Weapon_info[i].tech_anim_filename, "CB_Prometheus.ani", NAME_LENGTH);
1212 } else if (!strcmp(Weapon_info[i].name, "Banshee")) {
1213 strncpy(Weapon_info[i].tech_anim_filename, "CB_Banshee.ani", NAME_LENGTH);
1214 } else if (!strcmp(Weapon_info[i].name, "MX-50")) {
1215 strncpy(Weapon_info[i].tech_anim_filename, "CB_MX50.ani", NAME_LENGTH);
1216 } else if (!strcmp(Weapon_info[i].name, "D-Missile")) {
1217 strncpy(Weapon_info[i].tech_anim_filename, "CB_DisruptorMissile.ani", NAME_LENGTH);
1218 } else if (!strcmp(Weapon_info[i].name, "Fury")) {
1219 strncpy(Weapon_info[i].tech_anim_filename, "CB_Fury.ani", NAME_LENGTH);
1220 } else if (!strcmp(Weapon_info[i].name, "Hornet")) {
1221 strncpy(Weapon_info[i].tech_anim_filename, "CB_Hornet.ani", NAME_LENGTH);
1222 } else if (!strcmp(Weapon_info[i].name, "Interceptor")) {
1223 strncpy(Weapon_info[i].tech_anim_filename, "CB_Interceptor.ani", NAME_LENGTH);
1224 } else if (!strcmp(Weapon_info[i].name, "Phoenix V")) {
1225 strncpy(Weapon_info[i].tech_anim_filename, "CB_Phoenix.ani", NAME_LENGTH);
1226 } else if (!strcmp(Weapon_info[i].name, "Synaptic")) {
1227 strncpy(Weapon_info[i].tech_anim_filename, "CB_Synaptic.ani", NAME_LENGTH);
1228 } else if (!strcmp(Weapon_info[i].name, "Stiletto")) {
1229 strncpy(Weapon_info[i].tech_anim_filename, "CB_Stiletto.ani", NAME_LENGTH);
1230 } else if (!strcmp(Weapon_info[i].name, "Tsunami")) {
1231 strncpy(Weapon_info[i].tech_anim_filename, "CB_Tsunami.ani", NAME_LENGTH);
1232 } else if (!strcmp(Weapon_info[i].name, "Harbinger")) {
1233 strncpy(Weapon_info[i].tech_anim_filename, "CB_Harbinger.ani", NAME_LENGTH);
1234 } else if (!strcmp(Weapon_info[i].name, "Leech Cannon")) {
1235 strncpy(Weapon_info[i].tech_anim_filename, "CB_leech.ani", NAME_LENGTH);
1236 } else if (!strcmp(Weapon_info[i].name, "EM Pulse")) {
1237 strncpy(Weapon_info[i].tech_anim_filename, "CB_empulse.ani", NAME_LENGTH);
1238 } else if (!strcmp(Weapon_info[i].name, "S-Breaker")) {
1239 strncpy(Weapon_info[i].tech_anim_filename, "CB_sbreaker.ani", NAME_LENGTH);
1240 } else if (!strcmp(Weapon_info[i].name, "Cluster Bomb")) {
1241 strncpy(Weapon_info[i].tech_anim_filename, "CB_cluster.ani", NAME_LENGTH);
1245 // load the weapon animation
1246 if(!techroom_load_ani(&Weapon_list[Weapon_list_size].animation, Weapon_info[i].tech_anim_filename)){
1247 Weapon_list[Weapon_list_size].has_anim = 0;
1248 Weapon_list[Weapon_list_size].animation = NULL;
1250 // hmm. try a bitmap instead
1251 Weapon_list[Weapon_list_size].bitmap = bm_load(Weapon_info[i].tech_anim_filename);
1261 Current_list = Weapon_list;
1262 Current_list_size = Weapon_list_size;
1264 font_height = gr_get_font_height();
1265 max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
1267 Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
1270 techroom_start_anim();
1273 case INTEL_DATA_TAB:
1276 techroom_data_init();
1278 // load intel if necessary
1279 if ( Intel_loaded == 0 ) {
1280 // now populate the entry structs
1281 Intel_list_size = 0;
1282 for (i=0; i<Intel_info_size; i++) {
1284 if (Intel_info[i].in_tech_db != 0) {
1285 // leave option for no animation if string == "none"
1286 if (!strcmp(Intel_info[i].anim_filename, "none")) {
1287 Intel_list[Intel_list_size].has_anim = 0;
1288 Intel_list[Intel_list_size].animation = NULL;
1290 // try and load as an animation
1291 Intel_list[Intel_list_size].has_anim = 0;
1292 Intel_list[Intel_list_size].bitmap = -1;
1293 if(techroom_load_ani(&Intel_list[Intel_list_size].animation, Intel_info[i].anim_filename)){
1294 Intel_list[Intel_list_size].has_anim = 1;
1296 Intel_list[Intel_list_size].bitmap = bm_load(Intel_info[i].anim_filename);
1300 Intel_list[Intel_list_size].desc = Intel_info[i].desc;
1301 Intel_list[Intel_list_size].index = i;
1302 Intel_list[Intel_list_size].name = Intel_info[i].name;
1309 // index lookup on intel is a pretty pointless, but it keeps everything
1310 // consistent and doesnt really hurt anything
1311 Current_list = Intel_list;
1312 Current_list_size = Intel_list_size;
1314 font_height = gr_get_font_height();
1315 max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
1317 Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
1320 techroom_start_anim();
1326 techroom_select_new_entry();
1329 techroom_tab_setup(1);
1333 int techroom_button_pressed(int num)
1336 case SHIPS_DATA_TAB:
1337 case WEAPONS_DATA_TAB:
1338 case INTEL_DATA_TAB:
1339 techroom_change_tab(num);
1343 #if !defined(E3_BUILD) && !defined(PD_BUILD)
1344 gamesnd_play_iface(SND_SWITCH_SCREENS);
1345 gameseq_post_event(GS_EVENT_SIMULATOR_ROOM);
1352 #if !defined(E3_BUILD) && !defined(PD_BUILD)
1353 gamesnd_play_iface(SND_SWITCH_SCREENS);
1354 gameseq_post_event(GS_EVENT_GOTO_VIEW_CUTSCENES_SCREEN);
1361 #if !defined(E3_BUILD) && !defined(PD_BUILD)
1362 gamesnd_play_iface(SND_SWITCH_SCREENS);
1363 gameseq_post_event(GS_EVENT_CREDITS);
1369 case PREV_ENTRY_BUTTON:
1373 case NEXT_ENTRY_BUTTON:
1378 case PREV_ENTRY_BUTTON2:
1382 case NEXT_ENTRY_BUTTON2:
1387 case SCROLL_LIST_UP:
1388 tech_scroll_list_up();
1390 Tech_slider.forceUp();
1394 case SCROLL_LIST_DOWN:
1395 tech_scroll_list_down();
1397 Tech_slider.forceDown();
1401 case SCROLL_INFO_UP:
1402 tech_scroll_info_up();
1405 case SCROLL_INFO_DOWN:
1406 tech_scroll_info_down();
1410 launch_context_help();
1411 gamesnd_play_iface(SND_HELP_PRESSED);
1414 case OPTIONS_BUTTON:
1415 gamesnd_play_iface(SND_SWITCH_SCREENS);
1416 gameseq_post_event(GS_EVENT_OPTIONS_MENU);
1420 gamesnd_play_iface(SND_COMMIT_PRESSED);
1421 gameseq_post_event(GS_EVENT_MAIN_MENU);
1428 int techroom_load_ani(anim **animpp, char *name)
1430 int load_attempts = 0;
1431 char anim_filename[64] = "2_";
1434 // (i dont think there are any hi-res anims for these tho)
1435 if (gr_screen.res == GR_1024) {
1436 strcat(anim_filename, name);
1438 strcpy(anim_filename, name);
1442 if ( load_attempts++ > 5 ) {
1443 // Tech_room_ask_for_cd = 0;
1447 *animpp = anim_load(anim_filename, 1);
1450 } else if (gr_screen.res == GR_1024) {
1451 // try to load low-res version if hi-res failed
1452 *animpp = anim_load(name, 1);
1458 // couldn't load animation, ask user to insert CD (if necessary)
1459 // if ( Tech_room_ask_for_cd ) {
1460 // if ( game_do_cd_check() == 0 ) {
1461 // Tech_room_ask_for_cd = 0;
1472 void techroom_intel_init()
1475 static int inited = 0;
1477 // open localization
1481 if ((rval = setjmp(parse_abort)) != 0) {
1482 // close localization
1487 read_file_text("species.tbl");
1490 Intel_info_size = 0;
1493 while (optional_string("$Entry:")) {
1494 Assert(Intel_info_size < MAX_INTEL_ENTRIES);
1495 if (Intel_info_size >= MAX_INTEL_ENTRIES) break;
1497 required_string("$Name:");
1498 stuff_string(Intel_info[Intel_info_size].name, F_NAME, NULL, 32);
1499 required_string("$Anim:");
1500 stuff_string(Intel_info[Intel_info_size].anim_filename, F_NAME, NULL, 32);
1501 required_string("$AlwaysInTechRoom:");
1502 stuff_int(&Intel_info[Intel_info_size].in_tech_db);
1503 required_string("$Description:");
1504 stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, NULL, TECH_INTEL_DESC_LEN);
1510 if (optional_string("$Terran Tech Description:")) {
1511 stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, NULL, TECH_INTEL_DESC_LEN);
1512 strcpy(Intel_info[Intel_info_size].name, "Terran");
1513 strcpy(Intel_info[Intel_info_size].anim_filename, Intel_anim_filenames[0]);
1514 Intel_info[Intel_info_size].in_tech_db = 1;
1519 if (optional_string("$Vasudan Tech Description:")) {
1521 stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, NULL, TECH_INTEL_DESC_LEN);
1522 strcpy(Intel_info[Intel_info_size].name, "Vasudan");
1523 strcpy(Intel_info[Intel_info_size].anim_filename, Intel_anim_filenames[1]);
1524 Intel_info[Intel_info_size].in_tech_db = 1;
1529 if (optional_string("$Shivan Tech Description:")) {
1531 stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, NULL, TECH_INTEL_DESC_LEN);
1532 strcpy(Intel_info[Intel_info_size].name, "Shivan");
1533 strcpy(Intel_info[Intel_info_size].anim_filename, Intel_anim_filenames[2]);
1534 // FIXME: shouldn't always be in the intel database but no choice at this point
1535 // there are only about 4 missions before they show up anyway so it may not be worth it
1536 Intel_info[Intel_info_size].in_tech_db = 1;
1545 // close localization
1549 void techroom_init()
1552 techroom_buttons *b;
1564 // Tech_room_ask_for_cd = 1;
1566 // backup and bash detail level stuff
1567 Tech_detail_backup = Detail.detail_distance;
1568 Detail.detail_distance = MAX_DETAIL_LEVEL;
1569 Tech_texture_backup = Detail.hardware_textures;
1570 Detail.hardware_textures = MAX_DETAIL_LEVEL;
1573 Palette_bmp = bm_load("TechDataPalette");
1574 Assert(Palette_bmp);
1575 bm_get_palette(Palette_bmp, Palette, Palette_name); // get the palette for this bitmap
1576 gr_set_palette(Palette_name, Palette, 1);
1580 common_set_interface_palette("TechDataPalette");
1584 The_mission.flags &= ~MISSION_FLAG_FULLNEB;
1587 Ui_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
1588 #ifndef MAKE_FS1 // do this with techroom_tab_setup()
1589 Ui_window.set_mask_bmap(Tech_mask_filename[gr_screen.res]);
1592 Tech_background_bitmap = bm_load(Tech_background_filename[gr_screen.res]);
1593 if (Tech_background_bitmap < 0) {
1594 // failed to load bitmap, not a good thing
1598 #ifdef MAKE_FS1 // for weapons/species tab
1599 Tech_data_background_bitmap = bm_load(Tech_data_background_filename);
1600 if (Tech_data_background_bitmap < 0) {
1601 // failed to load bitmap, not a good thing
1605 techroom_tab_setup(0);
1607 // don't draw buttons that are only on other tabs
1608 for (i=0; i<PREV_ENTRY_BUTTON2; i++) {
1610 for (i=0; i<NUM_BUTTONS; i++) {
1612 b = &Buttons[gr_screen.res][i];
1614 b->button.create(&Ui_window, "", b->x, b->y, 60, 30, b->flags & REPEAT, 1);
1615 // set up callback for when a mouse first goes over a button
1617 b->button.set_bmaps(b->filename);
1618 // if ( !(b->flags & NO_MOUSE_OVER_SOUND) ) {
1619 b->button.set_highlight_action(common_play_highlight_sound);
1626 b->button.link_hotspot(b->hotspot);
1630 // common tab button text
1631 Ui_window.add_XSTR("Technical Database", 1055, Buttons[gr_screen.res][TECH_DATABASE_TAB].xt, Buttons[gr_screen.res][TECH_DATABASE_TAB].yt, &Buttons[gr_screen.res][TECH_DATABASE_TAB].button, UI_XSTR_COLOR_GREEN);
1632 Ui_window.add_XSTR("Mission Simulator", 1056, Buttons[gr_screen.res][SIMULATOR_TAB].xt, Buttons[gr_screen.res][SIMULATOR_TAB].yt, &Buttons[gr_screen.res][SIMULATOR_TAB].button, UI_XSTR_COLOR_GREEN);
1633 Ui_window.add_XSTR("Cutscenes", 1057, Buttons[gr_screen.res][CUTSCENES_TAB].xt, Buttons[gr_screen.res][CUTSCENES_TAB].yt, &Buttons[gr_screen.res][CUTSCENES_TAB].button, UI_XSTR_COLOR_GREEN);
1634 Ui_window.add_XSTR("Credits", 1058, Buttons[gr_screen.res][CREDITS_TAB].xt, Buttons[gr_screen.res][CREDITS_TAB].yt, &Buttons[gr_screen.res][CREDITS_TAB].button, UI_XSTR_COLOR_GREEN);
1636 // common ship/weapon/intel text
1637 Ui_window.add_XSTR("Ships", 293, Buttons[gr_screen.res][SHIPS_DATA_TAB].xt, Buttons[gr_screen.res][SHIPS_DATA_TAB].yt, &Buttons[gr_screen.res][SHIPS_DATA_TAB].button, UI_XSTR_COLOR_GREEN);
1638 Ui_window.add_XSTR("Weapons", 1553, Buttons[gr_screen.res][WEAPONS_DATA_TAB].xt, Buttons[gr_screen.res][WEAPONS_DATA_TAB].yt, &Buttons[gr_screen.res][WEAPONS_DATA_TAB].button, UI_XSTR_COLOR_GREEN);
1639 Ui_window.add_XSTR("Intelligence", 1066, Buttons[gr_screen.res][INTEL_DATA_TAB].xt, Buttons[gr_screen.res][INTEL_DATA_TAB].yt, &Buttons[gr_screen.res][INTEL_DATA_TAB].button, UI_XSTR_COLOR_GREEN);
1641 // common help/options/commit text
1643 // NK: removed these two text labels on Tech screen update 4/26/99
1644 // Ui_window.add_XSTR("Help", 928, Buttons[gr_screen.res][HELP_BUTTON].xt, Buttons[gr_screen.res][HELP_BUTTON].yt, &Buttons[gr_screen.res][HELP_BUTTON].button, UI_XSTR_COLOR_GREEN);
1645 // Ui_window.add_XSTR("Options", 1036, Buttons[gr_screen.res][OPTIONS_BUTTON].xt, Buttons[gr_screen.res][OPTIONS_BUTTON].yt, &Buttons[gr_screen.res][OPTIONS_BUTTON].button, UI_XSTR_COLOR_GREEN);
1646 Ui_window.add_XSTR("Exit", 1418, Buttons[gr_screen.res][EXIT_BUTTON].xt, Buttons[gr_screen.res][EXIT_BUTTON].yt, &Buttons[gr_screen.res][EXIT_BUTTON].button, UI_XSTR_COLOR_PINK);
1649 if (Player->flags & PLAYER_FLAGS_IS_MULTI) {
1650 Buttons[gr_screen.res][SIMULATOR_TAB].button.disable();
1651 Buttons[gr_screen.res][CUTSCENES_TAB].button.disable();
1655 Buttons[gr_screen.res][PREV_ENTRY_BUTTON].button.set_hotkey(KEY_LEFT);
1656 Buttons[gr_screen.res][NEXT_ENTRY_BUTTON].button.set_hotkey(KEY_RIGHT);
1657 #ifndef MAKE_FS1 // set per tab
1658 Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(KEY_UP);
1659 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(KEY_DOWN);
1663 for (i=0; i<LIST_BUTTONS_MAX; i++) {
1664 List_buttons[i].create(&Ui_window, "", 0, 0, 60, 30, 0, 1);
1665 List_buttons[i].hide();
1666 List_buttons[i].disable();
1669 View_window.create(&Ui_window, "", Tech_ship_display_coords[gr_screen.res][SHIP_X_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_Y_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_W_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_H_COORD], 1, 1);
1673 ShipWin01 = bm_load(NOX("ShipWin01"));
1674 ShipWin02 = bm_load(NOX("ShipWin02"));
1675 ShipWin03 = bm_load(NOX("ShipWin03"));
1676 ShipWin04 = bm_load(NOX("ShipWin04"));
1679 Buttons[gr_screen.res][HELP_BUTTON].button.set_hotkey(KEY_F1);
1680 Buttons[gr_screen.res][EXIT_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER);
1681 Buttons[gr_screen.res][SCROLL_LIST_UP].button.set_hotkey(KEY_PAGEUP);
1682 Buttons[gr_screen.res][SCROLL_LIST_DOWN].button.set_hotkey(KEY_PAGEDOWN);
1684 // init help overlay states
1685 help_overlay_set_state(TECH_ROOM_OVERLAY, 0);
1689 Tech_slider.create(&Ui_window, Tech_slider_coords[gr_screen.res][SHIP_X_COORD], Tech_slider_coords[gr_screen.res][SHIP_Y_COORD], Tech_slider_coords[gr_screen.res][SHIP_W_COORD], Tech_slider_coords[gr_screen.res][SHIP_H_COORD], Num_ship_types, Tech_slider_filename[gr_screen.res], &tech_scroll_list_up, &tech_scroll_list_down, &tech_ship_scroll_capture);
1692 Cur_anim_instance = NULL;
1694 // zero weapon and intel anim/bitmap stuff
1695 for(idx=0; idx<MAX_WEAPON_TYPES; idx++){
1696 Weapon_list[idx].animation = NULL;
1697 Weapon_list[idx].bitmap = -1;
1699 for(idx=0; idx<MAX_INTEL_ENTRIES; idx++){
1700 Intel_list[idx].animation = NULL;
1701 Intel_list[idx].bitmap = -1;
1704 Anim_playing_id = -1;
1705 techroom_change_tab(Tab);
1708 void techroom_close()
1712 techroom_stop_anim(-1);
1713 for (i=0; i<MAX_WEAPON_TYPES; i++) {
1714 if ( Weapon_list[i].animation ) {
1715 anim_free(Weapon_list[i].animation);
1716 Weapon_list[i].animation = NULL;
1718 if( Weapon_list[i].bitmap >= 0 ){
1719 bm_unload(Weapon_list[i].bitmap);
1720 Weapon_list[i].bitmap = -1;
1724 for (i=0; i<MAX_INTEL_ENTRIES; i++){
1725 if (Intel_list[i].animation != NULL) {
1726 anim_free(Intel_list[i].animation);
1727 Intel_list[i].animation = NULL;
1729 if( Intel_list[i].bitmap >= 0 ){
1730 bm_unload(Intel_list[i].bitmap);
1731 Intel_list[i].bitmap = -1;
1741 bm_unload(ShipWin01);
1744 bm_unload(ShipWin02);
1747 bm_unload(ShipWin03);
1750 bm_unload(ShipWin04);
1753 if (Tech_data_background_bitmap) {
1754 bm_unload(Tech_data_background_bitmap);
1758 if (Tech_background_bitmap) {
1759 bm_unload(Tech_background_bitmap);
1762 Ui_window.destroy();
1763 common_free_interface_palette(); // restore game palette
1766 bm_unload(Palette_bmp);
1770 // restore detail settings
1771 Detail.detail_distance = Tech_detail_backup;
1772 Detail.hardware_textures = Tech_texture_backup;
1776 void techroom_data_init()
1779 techroom_buttons *b;
1781 for (i=PREV_ENTRY_BUTTON2; i<NUM_BUTTONS; i++) {
1782 b = &Buttons[gr_screen.res][i];
1784 b->button.create(&Ui_window, "", b->x, b->y, 60, 30, b->flags & REPEAT, 1);
1785 // set up callback for when a mouse first goes over a button
1787 b->button.set_bmaps(b->filename);
1788 b->button.set_highlight_action(common_play_highlight_sound);
1793 b->button.link_hotspot(b->hotspot);
1797 void techroom_tab_setup(int set_palette)
1803 for (i=0; i<256; i++){
1807 // activate, deactivate any necessary controls
1808 for (i=0; i<NUM_BUTTONS; i++) {
1809 Buttons[gr_screen.res][i].button.enable();
1810 if (Buttons[gr_screen.res][i].filename)
1811 Buttons[gr_screen.res][i].button.unhide();
1814 // do other special processing
1816 case SHIPS_DATA_TAB:
1817 // set the mask for this tab
1818 Ui_window.set_mask_bmap(Tech_mask_filename[gr_screen.res]);
1820 // setup hotkeys to scroll list
1821 Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(KEY_UP);
1822 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(KEY_DOWN);
1824 // hide extra buttons
1825 Buttons[gr_screen.res][PREV_ENTRY_BUTTON2].button.hide();
1826 Buttons[gr_screen.res][NEXT_ENTRY_BUTTON2].button.hide();
1829 case WEAPONS_DATA_TAB:
1830 // set the mask for this tab
1831 Ui_window.set_mask_bmap(Tech_data_mask_filename);
1833 // the list isn't supposed to scroll so clear the hotkeys
1834 Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(-1);
1835 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(-1);
1837 // hide extra buttons
1838 Buttons[gr_screen.res][SCROLL_LIST_UP].button.hide();
1839 Buttons[gr_screen.res][SCROLL_LIST_DOWN].button.hide();
1840 Buttons[gr_screen.res][SCROLL_INFO_UP].button.hide();
1841 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.hide();
1842 Buttons[gr_screen.res][PREV_ENTRY_BUTTON].button.hide();
1843 Buttons[gr_screen.res][NEXT_ENTRY_BUTTON].button.hide();
1846 case INTEL_DATA_TAB:
1847 // set the mask for this tab
1848 Ui_window.set_mask_bmap(Tech_data_mask_filename);
1850 // the list isn't supposed to scroll so clear the hotkeys
1851 Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(-1);
1852 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(-1);
1854 // hide extra buttons
1855 Buttons[gr_screen.res][SCROLL_LIST_UP].button.hide();
1856 Buttons[gr_screen.res][SCROLL_LIST_DOWN].button.hide();
1857 Buttons[gr_screen.res][SCROLL_INFO_UP].button.hide();
1858 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.hide();
1859 Buttons[gr_screen.res][PREV_ENTRY_BUTTON].button.hide();
1860 Buttons[gr_screen.res][NEXT_ENTRY_BUTTON].button.hide();
1866 void techroom_do_frame(float frametime)
1870 // turn off controls when overlay is on
1871 if ( help_overlay_active(TECH_ROOM_OVERLAY) ) {
1872 Buttons[gr_screen.res][HELP_BUTTON].button.reset_status();
1873 Ui_window.set_ignore_gadgets(1);
1876 // turn off controls in trackball mode
1877 if (Trackball_active) {
1878 Ui_window.set_ignore_gadgets(1);
1880 Ui_window.set_ignore_gadgets(0);
1883 k = Ui_window.process() & ~KEY_DEBUGGED;
1885 if ( (k > 0) || B1_JUST_RELEASED ) {
1886 if ( help_overlay_active(TECH_ROOM_OVERLAY) ) {
1887 help_overlay_set_state(TECH_ROOM_OVERLAY, 0);
1888 Ui_window.set_ignore_gadgets(0);
1893 if ( !help_overlay_active(TECH_ROOM_OVERLAY) ) {
1894 Ui_window.set_ignore_gadgets(0);
1898 case KEY_SHIFTED | KEY_TAB: // activate previous tab
1904 techroom_change_tab(i);
1907 case KEY_TAB: // activate next tab
1909 if (i >= NUM_TABS) {
1913 techroom_change_tab(i);
1916 case KEY_CTRLED | KEY_DOWN:
1917 if ( !(Player->flags & PLAYER_FLAGS_IS_MULTI) ) {
1918 techroom_button_pressed(SIMULATOR_TAB);
1923 case KEY_CTRLED | KEY_UP:
1924 techroom_button_pressed(CREDITS_TAB);
1935 case KEY_CTRLED | KEY_ENTER:
1937 gameseq_post_event(GS_EVENT_MAIN_MENU);
1941 // check ship model window for activity
1942 if (View_window.pressed()) {
1943 Trackball_active = 1;
1947 Trackball_active = 0;
1950 // check all da buttons
1951 for (i=0; i<NUM_BUTTONS; i++) {
1952 if (Buttons[gr_screen.res][i].button.pressed()) {
1953 if (techroom_button_pressed(i)) {
1959 // check for mouseovers/clicks on the selection list
1960 Select_tease_line = -1;
1961 for (i=0; i<LIST_BUTTONS_MAX; i++) {
1962 if (List_buttons[i].is_mouse_on()) {
1963 Select_tease_line = i + List_offset;
1966 if (List_buttons[i].pressed()) {
1967 Cur_entry = i + List_offset;
1968 gamesnd_play_iface(SND_USER_SELECT);
1969 techroom_select_new_entry();
1973 #ifndef MAKE_FS1 // do this per tab instead
1974 // clear & draw bg bitmap
1975 GR_MAYBE_CLEAR_RES(Tech_background_bitmap);
1976 if (Tech_background_bitmap >= 0) {
1977 gr_set_bitmap(Tech_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1984 case SHIPS_DATA_TAB:
1986 // clear & draw bg bitmap
1987 GR_MAYBE_CLEAR_RES(Tech_background_bitmap);
1988 if (Tech_background_bitmap >= 0) {
1989 gr_set_bitmap(Tech_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1993 techroom_ships_render(frametime);
1997 gr_set_bitmap(ShipWin01, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1998 gr_bitmap(223, 104);
2002 gr_set_bitmap(ShipWin02, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2003 gr_bitmap(621, 124);
2007 gr_set_bitmap(ShipWin03, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2008 gr_bitmap(223, 338);
2012 gr_set_bitmap(ShipWin04, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2013 gr_bitmap(218, 124);
2019 case WEAPONS_DATA_TAB:
2021 // clear & draw bg bitmap
2022 GR_MAYBE_CLEAR_RES(Tech_data_background_bitmap);
2023 if (Tech_data_background_bitmap >= 0) {
2024 gr_set_bitmap(Tech_data_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2028 techroom_weapons_render2(frametime);
2032 case INTEL_DATA_TAB:
2034 // clear & draw bg bitmap
2035 GR_MAYBE_CLEAR_RES(Tech_data_background_bitmap);
2036 if (Tech_data_background_bitmap >= 0) {
2037 gr_set_bitmap(Tech_data_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2041 techroom_intel_render(frametime);
2048 for (i=TECH_DATABASE_TAB; i<=CREDITS_TAB; i++) {
2049 if (Buttons[gr_screen.res][i].button.button_down()) {
2053 if (i > CREDITS_TAB) {
2054 Buttons[gr_screen.res][TECH_DATABASE_TAB].button.draw_forced(2);
2057 for (i=0; i<NUM_TABS; i++){
2058 if (Buttons[gr_screen.res][i].button.button_down()){
2063 Buttons[gr_screen.res][Tab].button.draw_forced(2);
2066 // blit help overlay if active
2067 help_overlay_maybe_blit(TECH_ROOM_OVERLAY);