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.6 2003/05/25 02:30:42 taylor
21 * Revision 1.5 2002/06/17 06:33:09 relnev
22 * ryan's struct patch for gcc 2.95
24 * Revision 1.4 2002/06/09 04:41:22 relnev
25 * added copyright header
27 * Revision 1.3 2002/06/02 04:26:34 relnev
30 * Revision 1.2 2002/05/07 03:16:46 theoddone33
31 * The Great Newline Fix
33 * Revision 1.1.1.1 2002/05/03 03:28:09 root
37 * 43 11/02/99 3:22p Jefff
38 * translate ship names in tech room
40 * 42 10/25/99 5:47p Jefff
41 * reassigned some xstr ids
43 * 41 10/12/99 4:50p Jefff
45 * 40 9/08/99 11:09a Dave
46 * Use stills for intel and weapon stuff in the techroom if animations
49 * 39 9/05/99 11:19p Dave
50 * Made d3d texture cache much more safe. Fixed training scoring bug where
51 * it would backout scores without ever having applied them in the first
54 * 38 9/03/99 11:19a Jefff
55 * fixed double render of intel descriptions
57 * 37 9/03/99 1:32a Dave
58 * CD checking by act. Added support to play 2 cutscenes in a row
59 * seamlessly. Fixed super low level cfile bug related to files in the
60 * root directory of a CD. Added cheat code to set campaign mission # in
63 * 36 9/01/99 5:12p Jefff
64 * Fixed bad scroll bug
66 * 35 8/25/99 3:03p Jefff
67 * 'more' indicator, lotsa coord changes for new background, disabling of
68 * buttons in trackball mode, list follows selected item when prev/next
71 * 34 8/24/99 8:55p Dave
72 * Make sure nondimming pixels work properly in tech menu.
74 * 33 8/24/99 10:47a Jefff
75 * tech room weapon anims. added tech anim field to weapons.tbl
77 * 32 8/10/99 5:29p Jefff
78 * use new tech_title field in weapons array
80 * 31 8/10/99 3:45p Jefff
81 * Put the smack down on the tech room. Its all new, but tastefully done.
83 * 30 8/09/99 5:53p Jefff
85 * 29 8/02/99 10:27a Jefff
86 * removed a warning for the time being
88 * 28 8/02/99 10:13a Jefff
89 * started scrubbing, waiting till after demo to continue
91 * 27 7/28/99 1:02p Jefff
92 * Changed "Species" to "Intelligence" -- also changed in strings.tbl.
94 * 26 7/26/99 4:33p Jordonr
95 * Don't need techroom palette
97 * 25 7/20/99 1:49p Dave
98 * Peter Drake build. Fixed some release build warnings.
100 * 24 7/19/99 2:13p Dave
101 * Added some new strings for Heiko.
103 * 23 7/14/99 9:42a Dave
104 * Put in clear_color debug function. Put in base for 3dnow stuff / P3
107 * 22 6/16/99 4:06p Dave
108 * New pilot info popup. Added new draw-bitmap-as-poly function.
110 * 21 5/09/99 8:57p Dave
111 * Final E3 build preparations.
113 * 20 5/09/99 6:00p Dave
114 * Lots of cool new effects. E3 build tweaks.
116 * 19 4/29/99 2:16p Neilk
117 * added a 2nd callback for slider so its model is not loaded on mouselock
118 * until mouse button is released
120 * 18 4/26/99 5:05p Neilk
121 * updated to new artwork, added slider support
123 * 17 4/25/99 3:02p Dave
124 * Build defines for the E3 build.
126 * 16 4/23/99 12:01p Johnson
127 * Added SIF_HUGE_SHIP
129 * 15 4/12/99 10:07p Dave
130 * Made network startup more forgiving. Added checkmarks to dogfight
131 * screen for players who hit commit.
133 * 14 4/08/99 2:10a Dave
134 * Numerous bug fixes for the beta. Added builtin mission info for the
137 * 13 2/19/99 11:42a Dave
138 * Put in model rendering autocentering.
140 * 12 2/01/99 5:55p Dave
141 * Removed the idea of explicit bitmaps for buttons. Fixed text
142 * highlighting for disabled gadgets.
144 * 11 1/30/99 5:08p Dave
145 * More new hi-res stuff.Support for nice D3D textures.
147 * 10 1/29/99 3:56p Neilk
148 * Converted tech_infos screens to multiresolution
150 * 9 1/29/99 3:54p Neilk
152 * 8 1/29/99 12:47a Dave
153 * Put in sounds for beam weapon. A bunch of interface screens (tech
156 * 7 11/30/98 1:07p Dave
157 * 16 bit conversion, first run.
159 * 6 10/23/98 3:51p Dave
160 * Full support for tstrings.tbl and foreign languages. All that remains
161 * is to make it active in Fred.
163 * 5 10/16/98 9:40a Andsager
164 * Remove ".h" files from model.h
166 * 4 10/13/98 2:47p Andsager
167 * Remove reference to Tech_shivan_species_avail
169 * 3 10/13/98 9:28a Dave
170 * Started neatening up freespace.h. Many variables renamed and
171 * reorganized. Added AlphaColors.[h,cpp]
173 * 2 10/07/98 10:53a Dave
176 * 1 10/07/98 10:49a Dave
178 * 67 9/21/98 10:02p Dave
179 * Last minute changes to techroom weapon/ship/species stuff.
181 * 66 9/07/98 2:49p Dan
182 * Removed spurious Assert
184 * 65 7/06/98 2:42p Hoffoss
185 * Fixed bug with weapons shown in tech database.
187 * 64 6/10/98 11:48a Lawrance
188 * fix bug with trying to free NULL anims
190 * 63 6/05/98 9:54a Lawrance
193 * 62 6/01/98 11:43a John
194 * JAS & MK: Classified all strings for localization.
196 * 61 5/26/98 11:10a Lawrance
197 * Fix bug where window controls get disabled when F1 pressed twice
199 * 60 5/23/98 10:38p Lawrance
200 * Avoid doing a cfile refresh when running debug
202 * 59 5/23/98 6:49p Lawrance
203 * Fix problems with refreshing the file list when a CD is inserted
205 * 58 5/22/98 11:15a Lawrance
206 * Tweak how CD gets asked for
208 * 57 5/22/98 1:06a Hoffoss
209 * Made Fred not use OLE.
211 * 56 5/21/98 6:57p Lawrance
212 * Only ask for the CD once
214 * 55 5/21/98 12:46a Hoffoss
215 * Made text offset reset when new description is loaded.
217 * 54 5/20/98 9:46p John
218 * added code so the places in code that change half the palette don't
219 * have to clear the screen.
221 * 53 5/20/98 3:28p Sandeep
222 * Fixed bug where in multi only discovered weapons show up, and in single
223 * all weapons showed up (backwards).
225 * 52 5/20/98 2:11p Hoffoss
226 * Fixed some species description problems.
228 * 51 5/18/98 6:45p Hoffoss
229 * Added species descriptions to species database in techroom.
231 * 50 5/17/98 6:13p Hoffoss
232 * Fixed scrolling of info text area.
238 #include "gamesequence.h"
239 #include "techmenu.h"
242 #include "snazzyui.h"
243 #include "managepilot.h"
247 #include "missioncampaign.h"
248 #include "missionshipchoice.h"
249 #include "freespace.h"
250 #include "mainhallmenu.h"
251 #include "missionscreencommon.h"
257 #include "contexthelp.h"
258 #include "alphacolors.h"
259 #include "animplay.h"
260 #include "localize.h"
261 #include "lighting.h"
263 #define REVOLUTION_RATE 5.2f
266 #define NUM_BUTTONS 18
268 #define NUM_BUTTONS 16
271 #define LIST_BUTTONS_MAX 41
273 #define SHIPS_DATA_MODE (1<<0)
274 #define WEAPONS_DATA_MODE (1<<1)
275 #define SPECIES_DATA_MODE (1<<2)
276 #define WEAPONS_SPECIES_DATA_MODE (WEAPONS_DATA_MODE | SPECIES_DATA_MODE)
278 #define SHIPS_DATA_TAB 0
279 #define WEAPONS_DATA_TAB 1
280 #define INTEL_DATA_TAB 2
281 #define TECH_DATABASE_TAB 3
282 #define SIMULATOR_TAB 4
283 #define CUTSCENES_TAB 5
284 #define CREDITS_TAB 6
286 #define SCROLL_LIST_UP 7
287 #define SCROLL_LIST_DOWN 8
288 #define SCROLL_INFO_UP 9
289 #define SCROLL_INFO_DOWN 10
291 #define PREV_ENTRY_BUTTON 11
292 #define NEXT_ENTRY_BUTTON 12
294 #define HELP_BUTTON 13
295 #define OPTIONS_BUTTON 14
296 #define EXIT_BUTTON 15
299 #define PREV_ENTRY_BUTTON2 16
300 #define NEXT_ENTRY_BUTTON2 17
304 #define REPEAT (1<<0)
305 #define NO_MOUSE_OVER_SOUND (1<<1)
307 // indicies for coords
308 #define SHIP_X_COORD 0
309 #define SHIP_Y_COORD 1
310 #define SHIP_W_COORD 2
311 #define SHIP_H_COORD 3
313 // background filename for species
314 // note weapon filename is now same as ship filename
315 char *Tech_background_filename[GR_NUM_RESOLUTIONS] = {
319 char *Tech_mask_filename[GR_NUM_RESOLUTIONS] = {
324 char *Tech_slider_filename[GR_NUM_RESOLUTIONS] = {
331 // need the second background for FS1
332 char *Tech_data_background_filename = {
335 char *Tech_data_mask_filename = {
340 int Tech_list_coords[GR_NUM_RESOLUTIONS][4] = {
353 int Tech_ship_display_coords[GR_NUM_RESOLUTIONS][4] = {
366 int Tech_desc_coords[GR_NUM_RESOLUTIONS][4] = {
379 int Tech_ani_coords[GR_NUM_RESOLUTIONS][2] = {
393 int Tech_data_desc_coords[GR_NUM_RESOLUTIONS][4] = {
404 int Tech_slider_coords[GR_NUM_RESOLUTIONS][4] = {
415 int Tech_detail_backup;
416 int Tech_texture_backup;
418 #define MAX_TEXT_LINES 100
419 #define MAX_TEXT_LINE_LEN 256
421 struct techroom_buttons {
427 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
429 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) {}
432 static techroom_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS] = {
435 techroom_buttons("TDB_04", 20, 429, -1, -1, 4, -1), // ship data tab
436 techroom_buttons("TDB_05", 70, 429, -1, -1, 5, -1), // weapons data tab
437 techroom_buttons("TDB_06", 147, 429, -1, -1, 6, -1), // species data tab
438 techroom_buttons("TDB_00", 0, 0, -1, -1, 0, -1), // technical database tab
439 techroom_buttons("TDB_01", 0, 19, -1, -1, 1, -1), // mission simulator tab
440 techroom_buttons("TDB_02", 0, 35, -1, -1, 2, -1), // cutscenes tab
441 techroom_buttons("TDB_03", 0, 56, -1, -1, 3, -1), // credits tab
442 techroom_buttons("TSB_16", 0, 206, -1, -1, 16, SHIPS_DATA_MODE), // list up
443 techroom_buttons("TSB_17", 0, 254, -1, -1, 17, SHIPS_DATA_MODE), // list down
444 techroom_buttons("TSB_18", 411, 351, -1, -1, 18, SHIPS_DATA_MODE), // description up
445 techroom_buttons("TSB_19", 411, 397, -1, -1, 19, SHIPS_DATA_MODE), // description down
446 // techroom_buttons("TDB_11", 558, 272, -1, -1, 11, WEAPONS_SPECIES_DATA_MODE), // prev data entry
447 // techroom_buttons("TDB_12", 606, 272, -1, -1, 12, WEAPONS_SPECIES_DATA_MODE), // next data entry
448 techroom_buttons("TSB_22", 477, 338, -1, -1, 22, SHIPS_DATA_MODE), // prev data entry
449 techroom_buttons("TSB_23", 524, 338, -1, -1, 23, SHIPS_DATA_MODE), // next data entry
450 techroom_buttons("TDB_13", 469, 425, -1, -1, 13, -1), // help
451 techroom_buttons("TDB_14", 448, 452, -1, -1, 14, -1), // options
452 techroom_buttons("TDB_15", 552, 411, -1, -1, 15, -1), // exit
453 techroom_buttons("TDB_11", 477, 291, -1, -1, 11, WEAPONS_SPECIES_DATA_MODE), // prev data entry
454 techroom_buttons("TDB_12", 524, 291, -1, -1, 12, WEAPONS_SPECIES_DATA_MODE), // next data entry
456 techroom_buttons("TDB_04", 406, 384, 447, 393, 4, -1), // ship data tab
457 techroom_buttons("TDB_05", 404, 418, 447, 429, 5, -1), // weapons data tab
458 techroom_buttons("TDB_06", 404, 447, 447, 461, 6, -1), // species data tab
459 techroom_buttons("TDB_00", 7, 3, 37, 7, 0, -1), // technical database tab
460 techroom_buttons("TDB_01", 7, 18, 37, 23, 1, -1), // mission simulator tab
461 techroom_buttons("TDB_02", 7, 34, 37, 38, 2, -1), // cutscenes tab
462 techroom_buttons("TDB_03", 7, 49, 37, 54, 3, -1), // credits tab
463 techroom_buttons("TDB_07", 1, 86, -1, -1, 7, SHIPS_DATA_MODE, REPEAT), // prev data entry
464 techroom_buttons("TDB_08", 1, 317, -1, -1, 8, SHIPS_DATA_MODE, REPEAT), // next data entry
465 techroom_buttons("TDB_09", 1, 406, -1, -1, 9, SHIPS_DATA_MODE, REPEAT), // prev data entry
466 techroom_buttons("TDB_10", 1, 447, -1, -1, 10, SHIPS_DATA_MODE, REPEAT), // next data entry
467 //techroom_buttons("TDB_11", 558, 272, -1, -1, 11, WEAPONS_SPECIES_DATA_MODE), // prev data entry
468 //techroom_buttons("TDB_12", 606, 272, -1, -1, 12, WEAPONS_SPECIES_DATA_MODE), // next data entry
469 techroom_buttons("TDB_11a",559, 323, -1, -1, 11, SHIPS_DATA_MODE, REPEAT), // prev data entry
470 techroom_buttons("TDB_12a",609, 323, -1, -1, 12, SHIPS_DATA_MODE, REPEAT), // next data entry
471 techroom_buttons("TDB_13", 533, 425, 500, 440, 13, -1), // help
472 techroom_buttons("TDB_14", 533, 455, 479, 464, 14, -1), // options
473 techroom_buttons("TDB_15a",571, 425, 588, 413, 15, -1), // exit
477 techroom_buttons("2_TDB_04", 649, 614, 717, 630, 4, -1), // ship data tab
478 techroom_buttons("2_TDB_05", 646, 669, 717, 687, 5, -1), // weapons data tab
479 techroom_buttons("2_TDB_06", 646, 716, 717, 739, 6, -1), // species data tab
480 techroom_buttons("2_TDB_00", 12, 5, 59, 12, 0, -1), // technical database tab
481 techroom_buttons("2_TDB_01", 12, 31, 59, 37, 1, -1), // mission simulator tab
482 techroom_buttons("2_TDB_02", 12, 56, 59, 62, 2, -1), // cutscenes tab
483 techroom_buttons("2_TDB_03", 12, 81, 59, 88, 3, -1), // credits tab
484 techroom_buttons("2_TDB_07", 1, 138, -1, -1, 7, SHIPS_DATA_MODE, REPEAT), // prev data entry
485 techroom_buttons("2_TDB_08", 1, 507, -1, -1, 8, SHIPS_DATA_MODE, REPEAT), // next data entry
486 techroom_buttons("2_TDB_09", 1, 649, -1, -1, 9, SHIPS_DATA_MODE, REPEAT), // prev data entry
487 techroom_buttons("2_TDB_10", 1, 716, -1, -1, 10, SHIPS_DATA_MODE, REPEAT), // next data entry
490 techroom_buttons("2_TDB_11", 893, 436, -1, -1, 11, WEAPONS_SPECIES_DATA_MODE), // prev data entry
491 techroom_buttons("2_TDB_12", 970, 436, -1, -1, 12, WEAPONS_SPECIES_DATA_MODE), // next data entry
493 techroom_buttons("2_TDB_11a", 895, 518, -1, -1, 11, SHIPS_DATA_MODE, REPEAT), // prev data entry
494 techroom_buttons("2_TDB_12a", 974, 518, -1, -1, 12, SHIPS_DATA_MODE, REPEAT), // next data entry
495 techroom_buttons("2_TDB_13", 854, 681, 800, 704, 13, -1), // help
496 techroom_buttons("2_TDB_14", 854, 728, 780, 743, 14, -1), // options
497 techroom_buttons("2_TDB_15a", 914, 681, 930, 660, 15, -1), // exit
501 static UI_WINDOW Ui_window;
502 static UI_BUTTON View_window;
503 //static int Background_bitmap;
505 static int Tech_data_background_bitmap;
507 static int Tech_background_bitmap;
509 // static int List_size;
510 static int List_offset;
511 static int Select_tease_line;
512 static int Trackball_mode = 1;
513 static int Trackball_active = 0;
514 static matrix Techroom_ship_orient = IDENTITY_MATRIX;
515 // static int Tech_room_ask_for_cd;
517 static int Text_size;
518 static int Text_offset;
519 static int Text_line_size[MAX_TEXT_LINES];
520 static char *Text_lines[MAX_TEXT_LINES];
522 static int Cur_entry; // this is the current entry selected, using entry indexing
523 static int Cur_entry_index; // this is the current entry selected, using master list indexing
524 static int Techroom_ship_modelnum;
525 static float Techroom_ship_rot;
526 static UI_BUTTON List_buttons[LIST_BUTTONS_MAX]; // buttons for each line of text in list
527 static int Anim_playing_id = -1;
528 static anim_instance *Cur_anim_instance = NULL;
529 //static int Palette_bmp;
531 static int ShipWin01;
532 static int ShipWin02;
533 static int ShipWin03;
534 static int ShipWin04;
536 static ubyte Palette[768];
537 static char Palette_name[128];
539 static int Ships_loaded = 0;
540 static int Weapons_loaded = 0;
541 static int Intel_loaded = 0;
543 // out entry data struct & vars
545 int index; // index into the master table that its in (ie Ship_info[])
546 char* name; // ptr to name string
547 char* desc; // ptr to description string
548 anim* animation; // ptr to the animation
549 int bitmap; // bitmap handle
550 int has_anim; // flag to indicate the presence of an animation for this item
553 static tech_list_entry Ship_list[MAX_SHIP_TYPES];
554 static int Ship_list_size = 0;
555 static tech_list_entry Weapon_list[MAX_WEAPON_TYPES];
556 static int Weapon_list_size = 0;
557 static tech_list_entry Intel_list[MAX_INTEL_ENTRIES];
558 static int Intel_list_size = 0;
559 static tech_list_entry *Current_list; // points to currently valid display list
560 static int Current_list_size = 0;
564 static UI_SLIDER2 Tech_slider;
569 static char *Intel_anim_filenames[MAX_INTEL_ENTRIES] = {
577 // Intelligence master data structs (these get inited @ game startup from species.tbl)
578 intel_data Intel_info[MAX_INTEL_ENTRIES];
579 int Intel_info_size = 0;
581 // some prototypes to make you happy
582 int techroom_load_ani(anim **animpp, char *name);
583 void tech_common_render();
584 void techroom_start_anim();
585 void tech_scroll_list_up();
586 void tech_scroll_list_down();
588 void techroom_data_init();
589 void techroom_tab_setup(int set_palette);
595 ////////////////////////////////////////////////////
596 // like, functions and stuff
598 void techroom_init_desc(char *src, int w)
600 Text_size = Text_offset = 0;
605 Text_size = split_str(src, w, Text_line_size, Text_lines, MAX_TEXT_LINES);
606 Assert(Text_size >= 0 && Text_size < MAX_TEXT_LINES);
609 void techroom_select_new_entry()
611 Assert(Current_list != NULL);
612 if (Current_list == NULL) return;
614 Cur_entry_index = Current_list[Cur_entry].index;
616 // if we are in the ships tab, load the ship model
617 if (Tab == SHIPS_DATA_TAB) {
618 ship_info *sip = &Ship_info[Cur_entry_index];
620 #ifdef MULTIPLAYER_BETA_BUILD
621 // don't load supercaps in the beta
622 if((sip->flags & SIF_SUPERCAP) || (sip->flags & SIF_DRYDOCK)){
623 Techroom_ship_modelnum = -1;
625 Techroom_ship_modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);
628 // page in ship textures properly (takes care of nondimming pixels)
629 model_page_in_textures(Techroom_ship_modelnum, Cur_entry_index);
631 Techroom_ship_modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);
633 // page in ship textures properly (takes care of nondimming pixels)
634 model_page_in_textures(Techroom_ship_modelnum, Cur_entry_index);
637 Techroom_ship_modelnum = -1;
641 // Techroom_ship_rot = PI;
644 if (Tab == (WEAPONS_DATA_TAB || INTEL_DATA_TAB)){
645 techroom_init_desc(Current_list[Cur_entry].desc, Tech_data_desc_coords[gr_screen.res][SHIP_W_COORD]);
647 techroom_init_desc(Current_list[Cur_entry].desc, Tech_desc_coords[gr_screen.res][SHIP_W_COORD]);
650 techroom_init_desc(Current_list[Cur_entry].desc, Tech_desc_coords[gr_screen.res][SHIP_W_COORD]);
652 techroom_start_anim();
655 // write out the current description in the bottom window
656 void techroom_render_desc(int xo, int yo, int h)
658 int y, z, len, font_height;
659 char line[MAX_TEXT_LINE_LEN + 1];
661 font_height = gr_get_font_height();
665 while (y + font_height <= h) {
670 len = Text_line_size[z];
671 if (len > MAX_TEXT_LINE_LEN){
672 len = MAX_TEXT_LINE_LEN;
675 strncpy(line, Text_lines[z], len);
677 gr_string(xo, yo + y, line);
683 // maybe output 'more' indicator
684 #ifndef MAKE_FS1 // not used in original
685 if ( z < Text_size ) {
686 // can be scrolled down
687 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
688 int more_txt_y = Tech_desc_coords[gr_screen.res][1] + Tech_desc_coords[gr_screen.res][3]; // located below brief text, centered
690 gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469)));
691 gr_set_color_fast(&Color_black);
692 gr_rect(more_txt_x-2, more_txt_y, w+3, h);
693 gr_set_color_fast(&Color_red);
694 gr_string(more_txt_x, more_txt_y, XSTR("more", 1469)); // base location on the input x and y?
700 // new version of weapons
701 void techroom_weapons_render2(float frametime)
703 // render common stuff
705 tech_common_render();
707 // render description in its box
708 gr_set_color_fast(&Color_text_normal);
709 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]);
712 // render the animation
714 // JAS: This code is hacked to allow the animation to use all 256 colors
715 extern int Palman_allow_any_color;
716 Palman_allow_any_color = 1;
717 anim_render_all(0, frametime);
718 Palman_allow_any_color = 0;
721 // if our active item has a bitmap instead of an animation, draw it
722 if((Cur_entry > 0) && (Current_list[Cur_entry].animation == NULL) && (Current_list[Cur_entry].bitmap >= 0)){
723 gr_set_bitmap(Current_list[Cur_entry].bitmap);
724 gr_bitmap(Tech_ani_coords[gr_screen.res][0], Tech_ani_coords[gr_screen.res][1]);
728 // renders the stuff common to all 3 tech room tabs
729 void tech_common_render()
732 int y, z, font_height;
734 // render description in its box
735 gr_set_color_fast(&Color_text_normal);
736 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]);
738 font_height = gr_get_font_height();
740 // draw the list of entries
743 while (y + font_height <= Tech_list_coords[gr_screen.res][SHIP_H_COORD]) {
744 if (z >= Current_list_size) {
748 if (z == Cur_entry) {
749 gr_set_color_fast(&Color_text_selected);
750 } else if (z == Select_tease_line) {
751 gr_set_color_fast(&Color_text_subselected);
753 gr_set_color_fast(&Color_text_normal);
756 strcpy(buf, Current_list[z].name);
758 lcl_translate_ship_name(buf);
761 gr_force_fit_string(buf, 255, Tech_list_coords[gr_screen.res][SHIP_W_COORD]);
762 gr_string(Tech_list_coords[gr_screen.res][SHIP_X_COORD], Tech_list_coords[gr_screen.res][SHIP_Y_COORD] + y, buf);
764 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);
765 List_buttons[z - List_offset].enable(1);
771 // disable the rest of the list buttons
773 while (z < LIST_BUTTONS_MAX) {
774 List_buttons[z++].disable();
778 void techroom_ships_render(float frametime)
780 // render all the common stuff
781 tech_common_render();
783 // now render the trackball ship, which is unique to the ships tab
785 angles rot_angles, view_angles;
787 ship_info *sip = &Ship_info[Cur_entry_index];
789 // get correct revolution rate
790 rev_rate = REVOLUTION_RATE;
792 if (z & SIF_BIG_SHIP) {
795 if (z & SIF_HUGE_SHIP) {
799 // rotate the ship as much as required for this frame
800 Techroom_ship_rot += PI2 * frametime / rev_rate;
801 while (Techroom_ship_rot > PI2){
802 Techroom_ship_rot -= PI2;
806 gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0);
809 if (Trackball_active) {
813 if (Trackball_active) {
814 mouse_get_delta(&dx, &dy);
816 vm_trackball(-dx, -dy, &mat1);
817 vm_matrix_x_matrix(&mat2, &mat1, &Techroom_ship_orient);
818 Techroom_ship_orient = mat2;
823 // setup stuff needed to render the ship
824 view_angles.p = -0.6f;
825 view_angles.b = 0.0f;
826 view_angles.h = 0.0f;
827 vm_angles_2_matrix(&Techroom_ship_orient, &view_angles);
831 rot_angles.h = Techroom_ship_rot;
832 vm_rotate_matrix_by_angles(&Techroom_ship_orient, &rot_angles);
835 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]);
838 #ifdef MULTIPLAYER_BETA_BUILD
839 if((sip->flags & SIF_SUPERCAP) || (sip->flags & SIF_DRYDOCK)) {
840 gr_set_color_fast(&Color_bright);
841 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!"));
845 g3_set_view_matrix(&sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 1.3f);
847 // lighting for techroom
849 vector light_dir = vmd_zero_vector;
851 light_add_directional(&light_dir, 0.85f, 1.0f, 1.0f, 1.0f);
852 // light_filter_reset();
854 // lighting for techroom
856 model_clear_instance(Techroom_ship_modelnum);
857 model_set_detail_level(0);
858 model_render(Techroom_ship_modelnum, &Techroom_ship_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER);
865 g3_set_view_matrix(&sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 1.3f);
867 // lighting for techroom
869 vector light_dir = vmd_zero_vector;
870 light_dir.xyz.y = 1.0f;
871 light_add_directional(&light_dir, 0.85f, 1.0f, 1.0f, 1.0f);
872 // light_filter_reset();
874 // lighting for techroom
876 model_clear_instance(Techroom_ship_modelnum);
877 model_set_detail_level(0);
878 model_render(Techroom_ship_modelnum, &Techroom_ship_orient, &vmd_zero_vector, MR_LOCK_DETAIL | MR_AUTOCENTER);
886 // select previous entry in current list
887 void tech_prev_entry()
891 Cur_entry = Current_list_size - 1;
893 // scroll to end of list
894 List_offset = Cur_entry - Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() + 1;
895 if (List_offset < 0) {
896 // this happens when there are not enough items to scroll
900 Tech_slider.force_currentItem(Tech_slider.get_numberItems());
903 // maybe adjust list position by 1
904 if (List_offset > Cur_entry) {
905 tech_scroll_list_up();
907 Tech_slider.forceUp();
912 techroom_select_new_entry();
913 gamesnd_play_iface(SND_SCROLL);
916 // select next entry in current list
917 void tech_next_entry()
920 if (Cur_entry >= Current_list_size) {
923 // scroll to beginning of list
926 Tech_slider.force_currentItem(Cur_entry);
929 // maybe adjust list position by 1
930 if (List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() <= Cur_entry) {
931 tech_scroll_list_down();
933 Tech_slider.forceDown();
938 techroom_select_new_entry();
939 gamesnd_play_iface(SND_SCROLL);
942 void tech_scroll_info_up()
946 gamesnd_play_iface(SND_SCROLL);
948 gamesnd_play_iface(SND_GENERAL_FAIL);
952 void tech_scroll_info_down()
956 if (Tab == SHIPS_DATA_TAB){
957 h = Tech_desc_coords[gr_screen.res][SHIP_H_COORD];
959 h = Tech_desc_coords[gr_screen.res][3];
962 if (Text_offset + h / gr_get_font_height() < Text_size) {
964 gamesnd_play_iface(SND_SCROLL);
966 gamesnd_play_iface(SND_GENERAL_FAIL);
970 void tech_scroll_list_up()
974 if (List_offset > 0) {
976 //last = List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() - 1;
977 gamesnd_play_iface(SND_SCROLL);
979 gamesnd_play_iface(SND_GENERAL_FAIL);
983 void tech_scroll_list_down()
985 if (List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() < Current_list_size) {
987 gamesnd_play_iface(SND_SCROLL);
989 gamesnd_play_iface(SND_GENERAL_FAIL);
993 // this doesnt do a damn thing...
994 void tech_ship_scroll_capture()
996 techroom_select_new_entry();
1000 // this is obsolete - see techroom_weapons_render2(...)
1001 void techroom_weapons_render(float frametime)
1003 gr_set_color_fast(&Color_text_normal);
1004 techroom_render_desc(Tech_desc_coords[gr_screen.res][0], Tech_desc_coords[gr_screen.res][1], Tech_desc_coords[gr_screen.res][3]);
1007 // JAS: This code is hacked to allow the animation to use all 256 colors
1008 extern int Palman_allow_any_color;
1009 Palman_allow_any_color = 1;
1010 anim_render_all(0, frametime);
1011 Palman_allow_any_color = 0;
1014 // if our active item has a bitmap instead of an animation, draw it
1015 if((Cur_entry >= 0) && (Current_list[Cur_entry].animation == NULL) && (Current_list[Cur_entry].bitmap >= 0)){
1016 gr_set_bitmap(Current_list[Cur_entry].bitmap);
1017 gr_bitmap(Tech_ani_coords[gr_screen.res][0], Tech_ani_coords[gr_screen.res][1]);
1021 void techroom_intel_render(float frametime)
1024 tech_common_render();
1026 // render description in its box
1027 gr_set_color_fast(&Color_text_normal);
1028 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]);
1032 // JAS: This code is hacked to allow the animation to use all 256 colors
1033 extern int Palman_allow_any_color;
1034 Palman_allow_any_color = 1;
1035 anim_render_all(0, frametime);
1036 Palman_allow_any_color = 0;
1039 // if our active item has a bitmap instead of an animation, draw it
1040 if((Cur_entry >= 0) && (Current_list[Cur_entry].animation == NULL) && (Current_list[Cur_entry].bitmap >= 0)){
1041 gr_set_bitmap(Current_list[Cur_entry].bitmap);
1042 gr_bitmap(Tech_ani_coords[gr_screen.res][0], Tech_ani_coords[gr_screen.res][1]);
1046 void techroom_stop_anim(int id)
1048 if (Cur_anim_instance && (id != Anim_playing_id)) {
1049 anim_stop_playing(Cur_anim_instance);
1050 Cur_anim_instance = NULL;
1054 void techroom_start_anim()
1058 anim_play_struct aps;
1060 if (Cur_entry < 0) {
1061 techroom_stop_anim(-1);
1062 Anim_playing_id = -1;
1065 if (Tab == WEAPONS_DATA_TAB) {
1068 id = Cur_entry + 2000; // this offset is arbitrary?
1071 techroom_stop_anim(id);
1073 // if we actually have an animation
1074 if(Current_list[Cur_entry].animation != NULL){
1075 animp = Current_list[Cur_entry].animation;
1077 if (id != Anim_playing_id) {
1078 Anim_playing_id = -1;
1080 anim_play_init(&aps, animp, Tech_ani_coords[gr_screen.res][0], Tech_ani_coords[gr_screen.res][1]);
1082 Cur_anim_instance = anim_play(&aps);
1083 Anim_playing_id = id;
1087 memcpy(Palette, animp->palette, 384);
1088 gr_set_palette(animp->name, Palette, 1);
1095 void techroom_change_tab(int num)
1097 int i, multi = 0, mask, font_height, max_num_entries_viewable;
1100 // Assert(Current_list_size >= 0);
1103 multi = Player->flags & PLAYER_FLAGS_IS_MULTI;
1105 for (i=0; i<LIST_BUTTONS_MAX; i++){
1106 List_buttons[i].disable();
1109 // disable some stuff in multiplayer
1110 if (Player->flags & PLAYER_FLAGS_IS_MULTI) {
1111 Buttons[gr_screen.res][SIMULATOR_TAB].button.disable();
1112 Buttons[gr_screen.res][CUTSCENES_TAB].button.disable();
1116 case SHIPS_DATA_TAB:
1117 mask = multi ? SIF_IN_TECH_DATABASE_M : SIF_IN_TECH_DATABASE;
1119 // load ship info if necessary
1120 if (Ships_loaded == 0) {
1122 for (i=0; i<Num_ship_types; i++) {
1124 if (Ship_info[i].flags & mask) {
1126 // make sure it has a description before displaying
1127 if ((Ship_info[i].flags && mask) && (Ship_info[i].tech_desc)) {
1129 // this ship should be displayed, fill out the entry struct
1130 Ship_list[Ship_list_size].bitmap = -1;
1131 Ship_list[Ship_list_size].index = i;
1132 Ship_list[Ship_list_size].animation = NULL; // no anim for ships
1133 Ship_list[Ship_list_size].has_anim = 0; // no anim for ships
1134 Ship_list[Ship_list_size].name = Ship_info[i].name;
1135 Ship_list[Ship_list_size].desc = Ship_info[i].tech_desc;
1142 Current_list = Ship_list;
1143 Current_list_size = Ship_list_size;
1145 font_height = gr_get_font_height();
1146 max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
1148 Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
1151 // no anim to start here
1154 case WEAPONS_DATA_TAB:
1156 techroom_data_init();
1158 // load weapon info & anims if necessary
1159 if (Weapons_loaded == 0) {
1160 Weapon_list_size = 0;
1161 mask = multi ? WIF_PLAYER_ALLOWED : WIF_IN_TECH_DATABASE;
1163 for (i=0; i<MAX_WEAPON_TYPES; i++) {
1164 if (Weapon_info[i].wi_flags & mask) {
1166 // note: hack here to exclude dogfight weapons -- dont put weapon in if it has same description as pvs weapon
1167 if ((Weapon_list_size > 0) && (!strcmp(Weapon_info[i].tech_desc, Weapon_list[Weapon_list_size-1].desc))) {
1169 // exclude entries with no description, basically the same as above but helps get rid of special cases as well
1170 if ((Weapon_list_size > 0) && (!Weapon_info[i].tech_desc)) {
1175 // we have a weapon that should be in the tech db, so fill out the entry struct
1176 Weapon_list[Weapon_list_size].index = i;
1177 Weapon_list[Weapon_list_size].desc = Weapon_info[i].tech_desc;
1178 Weapon_list[Weapon_list_size].has_anim = 1;
1179 Weapon_list[Weapon_list_size].name = Weapon_info[i].tech_title;
1180 Weapon_list[Weapon_list_size].bitmap = -1;
1181 if (Weapon_list[Weapon_list_size].name[0] == 0) {
1182 Weapon_list[Weapon_list_size].name = Weapon_info[i].name;
1186 // figure out the animation based on weapon name
1187 if (!strcmp(Weapon_info[i].name, "ML-16 Laser")) {
1188 strncpy(Weapon_info[i].tech_anim_filename, "CB_ML16.ani", NAME_LENGTH);
1189 } else if (!strcmp(Weapon_info[i].name, "Disruptor")) {
1190 strncpy(Weapon_info[i].tech_anim_filename, "CB_Disruptor.ani", NAME_LENGTH);
1191 } else if (!strcmp(Weapon_info[i].name, "D-Advanced")) {
1192 strncpy(Weapon_info[i].tech_anim_filename, "CB_DAdvanced.ani", NAME_LENGTH);
1193 } else if (!strcmp(Weapon_info[i].name, "Avenger")) {
1194 strncpy(Weapon_info[i].tech_anim_filename, "CB_Avenger.ani", NAME_LENGTH);
1195 } else if (!strcmp(Weapon_info[i].name, "Flail")) {
1196 strncpy(Weapon_info[i].tech_anim_filename, "CB_Flail.ani", NAME_LENGTH);
1197 } else if (!strcmp(Weapon_info[i].name, "Prometheus")) {
1198 strncpy(Weapon_info[i].tech_anim_filename, "CB_Prometheus.ani", NAME_LENGTH);
1199 } else if (!strcmp(Weapon_info[i].name, "Banshee")) {
1200 strncpy(Weapon_info[i].tech_anim_filename, "CB_Banshee.ani", NAME_LENGTH);
1201 } else if (!strcmp(Weapon_info[i].name, "MX-50")) {
1202 strncpy(Weapon_info[i].tech_anim_filename, "CB_MX50.ani", NAME_LENGTH);
1203 } else if (!strcmp(Weapon_info[i].name, "D-Missile")) {
1204 strncpy(Weapon_info[i].tech_anim_filename, "CB_DisruptorMissile.ani", NAME_LENGTH);
1205 } else if (!strcmp(Weapon_info[i].name, "Fury")) {
1206 strncpy(Weapon_info[i].tech_anim_filename, "CB_Fury.ani", NAME_LENGTH);
1207 } else if (!strcmp(Weapon_info[i].name, "Hornet")) {
1208 strncpy(Weapon_info[i].tech_anim_filename, "CB_Hornet.ani", NAME_LENGTH);
1209 } else if (!strcmp(Weapon_info[i].name, "Interceptor")) {
1210 strncpy(Weapon_info[i].tech_anim_filename, "CB_Interceptor.ani", NAME_LENGTH);
1211 } else if (!strcmp(Weapon_info[i].name, "Phoenix V")) {
1212 strncpy(Weapon_info[i].tech_anim_filename, "CB_Phoenix.ani", NAME_LENGTH);
1213 } else if (!strcmp(Weapon_info[i].name, "Synaptic")) {
1214 strncpy(Weapon_info[i].tech_anim_filename, "CB_Synaptic.ani", NAME_LENGTH);
1215 } else if (!strcmp(Weapon_info[i].name, "Stiletto")) {
1216 strncpy(Weapon_info[i].tech_anim_filename, "CB_Stiletto.ani", NAME_LENGTH);
1217 } else if (!strcmp(Weapon_info[i].name, "Tsunami")) {
1218 strncpy(Weapon_info[i].tech_anim_filename, "CB_Tsunami.ani", NAME_LENGTH);
1219 } else if (!strcmp(Weapon_info[i].name, "Harbinger")) {
1220 strncpy(Weapon_info[i].tech_anim_filename, "CB_Harbinger.ani", NAME_LENGTH);
1221 } else if (!strcmp(Weapon_info[i].name, "Leech Cannon")) {
1222 strncpy(Weapon_info[i].tech_anim_filename, "CB_leech.ani", NAME_LENGTH);
1223 } else if (!strcmp(Weapon_info[i].name, "EM Pulse")) {
1224 strncpy(Weapon_info[i].tech_anim_filename, "CB_empulse.ani", NAME_LENGTH);
1225 } else if (!strcmp(Weapon_info[i].name, "S-Breaker")) {
1226 strncpy(Weapon_info[i].tech_anim_filename, "CB_sbreaker.ani", NAME_LENGTH);
1227 } else if (!strcmp(Weapon_info[i].name, "Cluster Bomb")) {
1228 strncpy(Weapon_info[i].tech_anim_filename, "CB_cluster.ani", NAME_LENGTH);
1232 // load the weapon animation
1233 if(!techroom_load_ani(&Weapon_list[Weapon_list_size].animation, Weapon_info[i].tech_anim_filename)){
1234 Weapon_list[Weapon_list_size].has_anim = 0;
1235 Weapon_list[Weapon_list_size].animation = NULL;
1237 // hmm. try a bitmap instead
1238 Weapon_list[Weapon_list_size].bitmap = bm_load(Weapon_info[i].tech_anim_filename);
1248 Current_list = Weapon_list;
1249 Current_list_size = Weapon_list_size;
1251 font_height = gr_get_font_height();
1252 max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
1254 Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
1257 techroom_start_anim();
1260 case INTEL_DATA_TAB:
1263 techroom_data_init();
1265 // load intel if necessary
1266 if ( Intel_loaded == 0 ) {
1267 // now populate the entry structs
1268 Intel_list_size = 0;
1269 for (i=0; i<Intel_info_size; i++) {
1271 if (Intel_info[i].in_tech_db != 0) {
1272 // leave option for no animation if string == "none"
1273 if (!strcmp(Intel_info[i].anim_filename, "none")) {
1274 Intel_list[Intel_list_size].has_anim = 0;
1275 Intel_list[Intel_list_size].animation = NULL;
1277 // try and load as an animation
1278 Intel_list[Intel_list_size].has_anim = 0;
1279 Intel_list[Intel_list_size].bitmap = -1;
1280 if(techroom_load_ani(&Intel_list[Intel_list_size].animation, Intel_info[i].anim_filename)){
1281 Intel_list[Intel_list_size].has_anim = 1;
1283 Intel_list[Intel_list_size].bitmap = bm_load(Intel_info[i].anim_filename);
1287 Intel_list[Intel_list_size].desc = Intel_info[i].desc;
1288 Intel_list[Intel_list_size].index = i;
1289 Intel_list[Intel_list_size].name = Intel_info[i].name;
1296 // index lookup on intel is a pretty pointless, but it keeps everything
1297 // consistent and doesnt really hurt anything
1298 Current_list = Intel_list;
1299 Current_list_size = Intel_list_size;
1301 font_height = gr_get_font_height();
1302 max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
1304 Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
1307 techroom_start_anim();
1313 techroom_select_new_entry();
1316 techroom_tab_setup(1);
1320 int techroom_button_pressed(int num)
1323 case SHIPS_DATA_TAB:
1324 case WEAPONS_DATA_TAB:
1325 case INTEL_DATA_TAB:
1326 techroom_change_tab(num);
1330 #if !defined(E3_BUILD) && !defined(PD_BUILD)
1331 gamesnd_play_iface(SND_SWITCH_SCREENS);
1332 gameseq_post_event(GS_EVENT_SIMULATOR_ROOM);
1339 #if !defined(E3_BUILD) && !defined(PD_BUILD)
1340 gamesnd_play_iface(SND_SWITCH_SCREENS);
1341 gameseq_post_event(GS_EVENT_GOTO_VIEW_CUTSCENES_SCREEN);
1348 #if !defined(E3_BUILD) && !defined(PD_BUILD)
1349 gamesnd_play_iface(SND_SWITCH_SCREENS);
1350 gameseq_post_event(GS_EVENT_CREDITS);
1356 case PREV_ENTRY_BUTTON:
1360 case NEXT_ENTRY_BUTTON:
1365 case PREV_ENTRY_BUTTON2:
1369 case NEXT_ENTRY_BUTTON2:
1374 case SCROLL_LIST_UP:
1375 tech_scroll_list_up();
1377 Tech_slider.forceUp();
1381 case SCROLL_LIST_DOWN:
1382 tech_scroll_list_down();
1384 Tech_slider.forceDown();
1388 case SCROLL_INFO_UP:
1389 tech_scroll_info_up();
1392 case SCROLL_INFO_DOWN:
1393 tech_scroll_info_down();
1397 launch_context_help();
1398 gamesnd_play_iface(SND_HELP_PRESSED);
1401 case OPTIONS_BUTTON:
1402 gamesnd_play_iface(SND_SWITCH_SCREENS);
1403 gameseq_post_event(GS_EVENT_OPTIONS_MENU);
1407 gamesnd_play_iface(SND_COMMIT_PRESSED);
1408 gameseq_post_event(GS_EVENT_MAIN_MENU);
1415 int techroom_load_ani(anim **animpp, char *name)
1417 int load_attempts = 0;
1418 char anim_filename[64] = "2_";
1421 // (i dont think there are any hi-res anims for these tho)
1422 if (gr_screen.res == GR_1024) {
1423 strcat(anim_filename, name);
1425 strcpy(anim_filename, name);
1429 if ( load_attempts++ > 5 ) {
1430 // Tech_room_ask_for_cd = 0;
1434 *animpp = anim_load(anim_filename, 1);
1437 } else if (gr_screen.res == GR_1024) {
1438 // try to load low-res version if hi-res failed
1439 *animpp = anim_load(name, 1);
1445 // couldn't load animation, ask user to insert CD (if necessary)
1446 // if ( Tech_room_ask_for_cd ) {
1447 // if ( game_do_cd_check() == 0 ) {
1448 // Tech_room_ask_for_cd = 0;
1459 void techroom_intel_init()
1462 static int inited = 0;
1464 // open localization
1468 if ((rval = setjmp(parse_abort)) != 0) {
1469 // close localization
1474 read_file_text("species.tbl");
1477 Intel_info_size = 0;
1480 while (optional_string("$Entry:")) {
1481 Assert(Intel_info_size < MAX_INTEL_ENTRIES);
1482 if (Intel_info_size >= MAX_INTEL_ENTRIES) break;
1484 required_string("$Name:");
1485 stuff_string(Intel_info[Intel_info_size].name, F_NAME, NULL, 32);
1486 required_string("$Anim:");
1487 stuff_string(Intel_info[Intel_info_size].anim_filename, F_NAME, NULL, 32);
1488 required_string("$AlwaysInTechRoom:");
1489 stuff_int(&Intel_info[Intel_info_size].in_tech_db);
1490 required_string("$Description:");
1491 stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, NULL, TECH_INTEL_DESC_LEN);
1497 if (optional_string("$Terran Tech Description:")) {
1498 stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, NULL, TECH_INTEL_DESC_LEN);
1499 strcpy(Intel_info[Intel_info_size].name, "Terran");
1500 strcpy(Intel_info[Intel_info_size].anim_filename, Intel_anim_filenames[0]);
1501 Intel_info[Intel_info_size].in_tech_db = 1;
1506 if (optional_string("$Vasudan Tech Description:")) {
1508 stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, NULL, TECH_INTEL_DESC_LEN);
1509 strcpy(Intel_info[Intel_info_size].name, "Vasudan");
1510 strcpy(Intel_info[Intel_info_size].anim_filename, Intel_anim_filenames[1]);
1511 Intel_info[Intel_info_size].in_tech_db = 1;
1516 if (optional_string("$Shivan Tech Description:")) {
1518 stuff_string(Intel_info[Intel_info_size].desc, F_MULTITEXT, NULL, TECH_INTEL_DESC_LEN);
1519 strcpy(Intel_info[Intel_info_size].name, "Shivan");
1520 strcpy(Intel_info[Intel_info_size].anim_filename, Intel_anim_filenames[2]);
1521 // FIXME: shouldn't always be in the intel database but no choice at this point
1522 // there are only about 4 missions before they show up anyway so it may not be worth it
1523 Intel_info[Intel_info_size].in_tech_db = 1;
1532 // close localization
1536 void techroom_init()
1539 techroom_buttons *b;
1551 // Tech_room_ask_for_cd = 1;
1553 // backup and bash detail level stuff
1554 Tech_detail_backup = Detail.detail_distance;
1555 Detail.detail_distance = MAX_DETAIL_LEVEL;
1556 Tech_texture_backup = Detail.hardware_textures;
1557 Detail.hardware_textures = MAX_DETAIL_LEVEL;
1560 Palette_bmp = bm_load("TechDataPalette");
1561 Assert(Palette_bmp);
1562 bm_get_palette(Palette_bmp, Palette, Palette_name); // get the palette for this bitmap
1563 gr_set_palette(Palette_name, Palette, 1);
1567 common_set_interface_palette("TechDataPalette");
1571 The_mission.flags &= ~MISSION_FLAG_FULLNEB;
1574 Ui_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
1575 #ifndef MAKE_FS1 // do this with techroom_tab_setup()
1576 Ui_window.set_mask_bmap(Tech_mask_filename[gr_screen.res]);
1579 Tech_background_bitmap = bm_load(Tech_background_filename[gr_screen.res]);
1580 if (Tech_background_bitmap < 0) {
1581 // failed to load bitmap, not a good thing
1585 #ifdef MAKE_FS1 // for weapons/species tab
1586 Tech_data_background_bitmap = bm_load(Tech_data_background_filename);
1587 if (Tech_data_background_bitmap < 0) {
1588 // failed to load bitmap, not a good thing
1592 techroom_tab_setup(0);
1594 // don't draw buttons that are only on other tabs
1595 for (i=0; i<PREV_ENTRY_BUTTON2; i++) {
1597 for (i=0; i<NUM_BUTTONS; i++) {
1599 b = &Buttons[gr_screen.res][i];
1601 b->button.create(&Ui_window, "", b->x, b->y, 60, 30, b->flags & REPEAT, 1);
1602 // set up callback for when a mouse first goes over a button
1604 b->button.set_bmaps(b->filename);
1605 // if ( !(b->flags & NO_MOUSE_OVER_SOUND) ) {
1606 b->button.set_highlight_action(common_play_highlight_sound);
1613 b->button.link_hotspot(b->hotspot);
1617 // common tab button text
1618 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);
1619 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);
1620 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);
1621 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);
1623 // common ship/weapon/intel text
1624 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);
1625 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);
1626 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);
1628 // common help/options/commit text
1630 // NK: removed these two text labels on Tech screen update 4/26/99
1631 // 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);
1632 // 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);
1633 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);
1636 if (Player->flags & PLAYER_FLAGS_IS_MULTI) {
1637 Buttons[gr_screen.res][SIMULATOR_TAB].button.disable();
1638 Buttons[gr_screen.res][CUTSCENES_TAB].button.disable();
1642 Buttons[gr_screen.res][PREV_ENTRY_BUTTON].button.set_hotkey(KEY_LEFT);
1643 Buttons[gr_screen.res][NEXT_ENTRY_BUTTON].button.set_hotkey(KEY_RIGHT);
1644 #ifndef MAKE_FS1 // set per tab
1645 Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(KEY_UP);
1646 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(KEY_DOWN);
1650 for (i=0; i<LIST_BUTTONS_MAX; i++) {
1651 List_buttons[i].create(&Ui_window, "", 0, 0, 60, 30, 0, 1);
1652 List_buttons[i].hide();
1653 List_buttons[i].disable();
1656 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);
1660 ShipWin01 = bm_load(NOX("ShipWin01"));
1661 ShipWin02 = bm_load(NOX("ShipWin02"));
1662 ShipWin03 = bm_load(NOX("ShipWin03"));
1663 ShipWin04 = bm_load(NOX("ShipWin04"));
1666 Buttons[gr_screen.res][HELP_BUTTON].button.set_hotkey(KEY_F1);
1667 Buttons[gr_screen.res][EXIT_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER);
1668 Buttons[gr_screen.res][SCROLL_LIST_UP].button.set_hotkey(KEY_PAGEUP);
1669 Buttons[gr_screen.res][SCROLL_LIST_DOWN].button.set_hotkey(KEY_PAGEDOWN);
1671 // init help overlay states
1672 help_overlay_set_state(TECH_ROOM_OVERLAY, 0);
1676 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);
1679 Cur_anim_instance = NULL;
1681 // zero weapon and intel anim/bitmap stuff
1682 for(idx=0; idx<MAX_WEAPON_TYPES; idx++){
1683 Weapon_list[idx].animation = NULL;
1684 Weapon_list[idx].bitmap = -1;
1686 for(idx=0; idx<MAX_INTEL_ENTRIES; idx++){
1687 Intel_list[idx].animation = NULL;
1688 Intel_list[idx].bitmap = -1;
1691 Anim_playing_id = -1;
1692 techroom_change_tab(Tab);
1695 void techroom_close()
1699 techroom_stop_anim(-1);
1700 for (i=0; i<MAX_WEAPON_TYPES; i++) {
1701 if ( Weapon_list[i].animation ) {
1702 anim_free(Weapon_list[i].animation);
1703 Weapon_list[i].animation = NULL;
1705 if( Weapon_list[i].bitmap >= 0 ){
1706 bm_unload(Weapon_list[i].bitmap);
1707 Weapon_list[i].bitmap = -1;
1711 for (i=0; i<MAX_INTEL_ENTRIES; i++){
1712 if (Intel_list[i].animation != NULL) {
1713 anim_free(Intel_list[i].animation);
1714 Intel_list[i].animation = NULL;
1716 if( Intel_list[i].bitmap >= 0 ){
1717 bm_unload(Intel_list[i].bitmap);
1718 Intel_list[i].bitmap = -1;
1728 bm_unload(ShipWin01);
1731 bm_unload(ShipWin02);
1734 bm_unload(ShipWin03);
1737 bm_unload(ShipWin04);
1740 if (Tech_data_background_bitmap) {
1741 bm_unload(Tech_data_background_bitmap);
1745 if (Tech_background_bitmap) {
1746 bm_unload(Tech_background_bitmap);
1749 Ui_window.destroy();
1750 common_free_interface_palette(); // restore game palette
1753 bm_unload(Palette_bmp);
1757 // restore detail settings
1758 Detail.detail_distance = Tech_detail_backup;
1759 Detail.hardware_textures = Tech_texture_backup;
1763 void techroom_data_init()
1766 techroom_buttons *b;
1768 for (i=PREV_ENTRY_BUTTON2; i<NUM_BUTTONS; i++) {
1769 b = &Buttons[gr_screen.res][i];
1771 b->button.create(&Ui_window, "", b->x, b->y, 60, 30, b->flags & REPEAT, 1);
1772 // set up callback for when a mouse first goes over a button
1774 b->button.set_bmaps(b->filename);
1775 b->button.set_highlight_action(common_play_highlight_sound);
1780 b->button.link_hotspot(b->hotspot);
1784 void techroom_tab_setup(int set_palette)
1790 for (i=0; i<256; i++){
1794 // activate, deactivate any necessary controls
1795 for (i=0; i<NUM_BUTTONS; i++) {
1796 Buttons[gr_screen.res][i].button.enable();
1797 if (Buttons[gr_screen.res][i].filename)
1798 Buttons[gr_screen.res][i].button.unhide();
1801 // do other special processing
1803 case SHIPS_DATA_TAB:
1804 // set the mask for this tab
1805 Ui_window.set_mask_bmap(Tech_mask_filename[gr_screen.res]);
1807 // setup hotkeys to scroll list
1808 Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(KEY_UP);
1809 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(KEY_DOWN);
1811 // hide extra buttons
1812 Buttons[gr_screen.res][PREV_ENTRY_BUTTON2].button.hide();
1813 Buttons[gr_screen.res][NEXT_ENTRY_BUTTON2].button.hide();
1816 case WEAPONS_DATA_TAB:
1817 // set the mask for this tab
1818 Ui_window.set_mask_bmap(Tech_data_mask_filename);
1820 // the list isn't supposed to scroll so clear the hotkeys
1821 Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(-1);
1822 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(-1);
1824 // hide extra buttons
1825 Buttons[gr_screen.res][SCROLL_LIST_UP].button.hide();
1826 Buttons[gr_screen.res][SCROLL_LIST_DOWN].button.hide();
1827 Buttons[gr_screen.res][SCROLL_INFO_UP].button.hide();
1828 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.hide();
1829 Buttons[gr_screen.res][PREV_ENTRY_BUTTON].button.hide();
1830 Buttons[gr_screen.res][NEXT_ENTRY_BUTTON].button.hide();
1833 case INTEL_DATA_TAB:
1834 // set the mask for this tab
1835 Ui_window.set_mask_bmap(Tech_data_mask_filename);
1837 // the list isn't supposed to scroll so clear the hotkeys
1838 Buttons[gr_screen.res][SCROLL_INFO_UP].button.set_hotkey(-1);
1839 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.set_hotkey(-1);
1841 // hide extra buttons
1842 Buttons[gr_screen.res][SCROLL_LIST_UP].button.hide();
1843 Buttons[gr_screen.res][SCROLL_LIST_DOWN].button.hide();
1844 Buttons[gr_screen.res][SCROLL_INFO_UP].button.hide();
1845 Buttons[gr_screen.res][SCROLL_INFO_DOWN].button.hide();
1846 Buttons[gr_screen.res][PREV_ENTRY_BUTTON].button.hide();
1847 Buttons[gr_screen.res][NEXT_ENTRY_BUTTON].button.hide();
1853 void techroom_do_frame(float frametime)
1857 // turn off controls when overlay is on
1858 if ( help_overlay_active(TECH_ROOM_OVERLAY) ) {
1859 Buttons[gr_screen.res][HELP_BUTTON].button.reset_status();
1860 Ui_window.set_ignore_gadgets(1);
1863 // turn off controls in trackball mode
1864 if (Trackball_active) {
1865 Ui_window.set_ignore_gadgets(1);
1867 Ui_window.set_ignore_gadgets(0);
1870 k = Ui_window.process() & ~KEY_DEBUGGED;
1872 if ( (k > 0) || B1_JUST_RELEASED ) {
1873 if ( help_overlay_active(TECH_ROOM_OVERLAY) ) {
1874 help_overlay_set_state(TECH_ROOM_OVERLAY, 0);
1875 Ui_window.set_ignore_gadgets(0);
1880 if ( !help_overlay_active(TECH_ROOM_OVERLAY) ) {
1881 Ui_window.set_ignore_gadgets(0);
1885 case KEY_SHIFTED | KEY_TAB: // activate previous tab
1891 techroom_change_tab(i);
1894 case KEY_TAB: // activate next tab
1896 if (i >= NUM_TABS) {
1900 techroom_change_tab(i);
1903 case KEY_CTRLED | KEY_DOWN:
1904 if ( !(Player->flags & PLAYER_FLAGS_IS_MULTI) ) {
1905 techroom_button_pressed(SIMULATOR_TAB);
1910 case KEY_CTRLED | KEY_UP:
1911 techroom_button_pressed(CREDITS_TAB);
1922 case KEY_CTRLED | KEY_ENTER:
1924 gameseq_post_event(GS_EVENT_MAIN_MENU);
1928 // check ship model window for activity
1929 if (View_window.pressed()) {
1930 Trackball_active = 1;
1934 Trackball_active = 0;
1937 // check all da buttons
1938 for (i=0; i<NUM_BUTTONS; i++) {
1939 if (Buttons[gr_screen.res][i].button.pressed()) {
1940 if (techroom_button_pressed(i)) {
1946 // check for mouseovers/clicks on the selection list
1947 Select_tease_line = -1;
1948 for (i=0; i<LIST_BUTTONS_MAX; i++) {
1949 if (List_buttons[i].is_mouse_on()) {
1950 Select_tease_line = i + List_offset;
1953 if (List_buttons[i].pressed()) {
1954 Cur_entry = i + List_offset;
1955 gamesnd_play_iface(SND_USER_SELECT);
1956 techroom_select_new_entry();
1960 #ifndef MAKE_FS1 // do this per tab instead
1961 // clear & draw bg bitmap
1962 GR_MAYBE_CLEAR_RES(Tech_background_bitmap);
1963 if (Tech_background_bitmap >= 0) {
1964 gr_set_bitmap(Tech_background_bitmap);
1971 case SHIPS_DATA_TAB:
1973 // clear & draw bg bitmap
1974 GR_MAYBE_CLEAR_RES(Tech_background_bitmap);
1975 if (Tech_background_bitmap >= 0) {
1976 gr_set_bitmap(Tech_background_bitmap);
1980 techroom_ships_render(frametime);
1984 gr_set_bitmap(ShipWin01);
1985 gr_bitmap(223, 104);
1989 gr_set_bitmap(ShipWin02);
1990 gr_bitmap(621, 124);
1994 gr_set_bitmap(ShipWin03);
1995 gr_bitmap(223, 338);
1999 gr_set_bitmap(ShipWin04);
2000 gr_bitmap(218, 124);
2006 case WEAPONS_DATA_TAB:
2008 // clear & draw bg bitmap
2009 GR_MAYBE_CLEAR_RES(Tech_data_background_bitmap);
2010 if (Tech_data_background_bitmap >= 0) {
2011 gr_set_bitmap(Tech_data_background_bitmap);
2015 techroom_weapons_render2(frametime);
2019 case INTEL_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);
2028 techroom_intel_render(frametime);
2035 for (i=TECH_DATABASE_TAB; i<=CREDITS_TAB; i++) {
2036 if (Buttons[gr_screen.res][i].button.button_down()) {
2040 if (i > CREDITS_TAB) {
2041 Buttons[gr_screen.res][TECH_DATABASE_TAB].button.draw_forced(2);
2044 for (i=0; i<NUM_TABS; i++){
2045 if (Buttons[gr_screen.res][i].button.button_down()){
2050 Buttons[gr_screen.res][Tab].button.draw_forced(2);
2053 // blit help overlay if active
2054 help_overlay_maybe_blit(TECH_ROOM_OVERLAY);