FS2_Open
Open source remastering of the Freespace 2 engine
techmenu.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #include "anim/animplay.h"
13 #include "anim/packunpack.h"
14 #include "cmdline/cmdline.h"
15 #include "gamehelp/contexthelp.h"
17 #include "gamesnd/gamesnd.h"
18 #include "globalincs/alphacolors.h"
19 #include "graphics/font.h"
20 #include "io/key.h"
21 #include "io/mouse.h"
22 #include "lighting/lighting.h"
23 #include "localization/localize.h"
24 #include "menuui/techmenu.h"
26 #include "parse/parselo.h"
27 #include "playerman/player.h"
28 #include "render/3d.h"
29 #include "ship/ship.h"
30 #include "sound/fsspeech.h"
31 #include "ui/ui.h"
32 #include "ui/uidefs.h"
33 #include "weapon/weapon.h"
34 
35 
36 
37 #define REVOLUTION_RATE 5.2f
38 
39 #define NUM_BUTTONS 16
40 #define NUM_TABS 3
41 #define LIST_BUTTONS_MAX 42
42 
43 #define SHIPS_DATA_MODE (1<<0)
44 #define WEAPONS_DATA_MODE (1<<1)
45 #define SPECIES_DATA_MODE (1<<2)
46 #define WEAPONS_SPECIES_DATA_MODE (WEAPONS_DATA_MODE | SPECIES_DATA_MODE)
47 
48 #define SHIPS_DATA_TAB 0
49 #define WEAPONS_DATA_TAB 1
50 #define INTEL_DATA_TAB 2
51 #define TECH_DATABASE_TAB 3
52 #define SIMULATOR_TAB 4
53 #define CUTSCENES_TAB 5
54 #define CREDITS_TAB 6
55 
56 #define SCROLL_LIST_UP 7
57 #define SCROLL_LIST_DOWN 8
58 #define SCROLL_INFO_UP 9
59 #define SCROLL_INFO_DOWN 10
60 
61 #define PREV_ENTRY_BUTTON 11
62 #define NEXT_ENTRY_BUTTON 12
63 
64 #define HELP_BUTTON 13
65 #define OPTIONS_BUTTON 14
66 #define EXIT_BUTTON 15
67 
68 
69 #define REPEAT (1<<0)
70 #define NO_MOUSE_OVER_SOUND (1<<1)
71 
72 // indicies for coords
73 #define SHIP_X_COORD 0
74 #define SHIP_Y_COORD 1
75 #define SHIP_W_COORD 2
76 #define SHIP_H_COORD 3
77 
78 // background filename for species
79 // note weapon filename is now same as ship filename
81  "TechShipData",
82  "2_TechShipData"
83 };
85  "TechShipData-M",
86  "2_TechShipData-M"
87 };
89  "slider",
90  "2_slider"
91 };
92 
94  { // GR_640
95  27, 98, 161, 234
96  },
97  { // GR_1024
98  43, 157, 253, 374
99  }
100 };
101 
103  { // GR_640
104  239, 98, 393, 222
105  },
106  { // GR_1024
107  382, 158, 629, 355
108  }
109 };
110 
112  { // GR_640
113  29, 347, 365, 125
114  },
115  { // GR_1024
116  47, 555, 584, 200
117  }
118 };
119 
121  { // GR_640
122  416, 215
123  },
124  { // GR_1024
125  669, 345
126  }
127 };
128 
130  { // GR_640
131  2, 118, 20, 194
132  },
133  { // GR_1024
134  3, 190, 32, 310
135  }
136 };
137 
138 #define MAX_TEXT_LINES 150
139 #define MAX_TEXT_LINE_LEN 256
140 
142  char *filename;
143  int x, y, xt, yt;
144  int hotspot;
145  int tab;
146  int flags;
147  UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
148 
149  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) {}
150 };
151 
153  { // GR_640
154  techroom_buttons("TDB_04", 406, 384, 447, 393, 4, -1), // ship data tab
155  techroom_buttons("TDB_05", 404, 418, 447, 429, 5, -1), // weapons data tab
156  techroom_buttons("TDB_06", 404, 447, 447, 461, 6, -1), // species data tab
157  techroom_buttons("TDB_00", 7, 3, 37, 7, 0, -1), // technical database tab
158  techroom_buttons("TDB_01", 7, 18, 37, 23, 1, -1), // mission simulator tab
159  techroom_buttons("TDB_02", 7, 34, 37, 38, 2, -1), // cutscenes tab
160  techroom_buttons("TDB_03", 7, 49, 37, 54, 3, -1), // credits tab
161  techroom_buttons("TDB_07", 1, 86, -1, -1, 7, SHIPS_DATA_MODE, REPEAT), // prev data entry
162  techroom_buttons("TDB_08", 1, 317, -1, -1, 8, SHIPS_DATA_MODE, REPEAT), // next data entry
163  techroom_buttons("TDB_09", 1, 406, -1, -1, 9, SHIPS_DATA_MODE, REPEAT), // prev data entry
164  techroom_buttons("TDB_10", 1, 447, -1, -1, 10, SHIPS_DATA_MODE, REPEAT), // next data entry
165  techroom_buttons("TDB_11a",559, 323, -1, -1, 11, SHIPS_DATA_MODE, REPEAT), // prev data entry
166  techroom_buttons("TDB_12a",609, 323, -1, -1, 12, SHIPS_DATA_MODE, REPEAT), // next data entry
167  techroom_buttons("TDB_13", 533, 425, 500, 440, 13, -1), // help
168  techroom_buttons("TDB_14", 533, 455, 479, 464, 14, -1), // options
169  techroom_buttons("TDB_15a",571, 425, 588, 413, 15, -1), // exit
170  },
171  { // GR_1024
172  techroom_buttons("2_TDB_04", 649, 614, 717, 630, 4, -1), // ship data tab
173  techroom_buttons("2_TDB_05", 646, 669, 717, 687, 5, -1), // weapons data tab
174  techroom_buttons("2_TDB_06", 646, 716, 717, 739, 6, -1), // species data tab
175  techroom_buttons("2_TDB_00", 12, 5, 59, 12, 0, -1), // technical database tab
176  techroom_buttons("2_TDB_01", 12, 31, 59, 37, 1, -1), // mission simulator tab
177  techroom_buttons("2_TDB_02", 12, 56, 59, 62, 2, -1), // cutscenes tab
178  techroom_buttons("2_TDB_03", 12, 81, 59, 88, 3, -1), // credits tab
179  techroom_buttons("2_TDB_07", 1, 138, -1, -1, 7, SHIPS_DATA_MODE, REPEAT), // prev data entry
180  techroom_buttons("2_TDB_08", 1, 507, -1, -1, 8, SHIPS_DATA_MODE, REPEAT), // next data entry
181  techroom_buttons("2_TDB_09", 1, 649, -1, -1, 9, SHIPS_DATA_MODE, REPEAT), // prev data entry
182  techroom_buttons("2_TDB_10", 1, 716, -1, -1, 10, SHIPS_DATA_MODE, REPEAT), // next data entry
183  techroom_buttons("2_TDB_11a", 895, 518, -1, -1, 11, SHIPS_DATA_MODE, REPEAT), // prev data entry
184  techroom_buttons("2_TDB_12a", 974, 518, -1, -1, 12, SHIPS_DATA_MODE, REPEAT), // next data entry
185  techroom_buttons("2_TDB_13", 854, 681, 800, 704, 13, -1), // help
186  techroom_buttons("2_TDB_14", 854, 728, 780, 743, 14, -1), // options
187  techroom_buttons("2_TDB_15a", 914, 681, 930, 660, 15, -1), // exit
188  },
189 };
190 
191 static UI_WINDOW Ui_window;
192 static UI_BUTTON View_window;
193 static int Tech_background_bitmap;
194 static int Tab = SHIPS_DATA_TAB;
195 static int List_offset;
196 static int Select_tease_line;
197 static int Trackball_mode = 1;
198 static int Trackball_active = 0;
199 static matrix Techroom_ship_orient = IDENTITY_MATRIX;
200 static int Techroom_show_all = 0;
201 
202 static int Text_size;
203 static int Text_offset;
204 static int Text_line_size[MAX_TEXT_LINES];
205 static const char *Text_lines[MAX_TEXT_LINES];
206 
207 static int Cur_entry = -1; // this is the current entry selected, using entry indexing
208 static int Cur_entry_index = -1; // this is the current entry selected, using master list indexing
209 static int Techroom_ship_modelnum;
210 static float Techroom_ship_rot;
211 static UI_BUTTON List_buttons[LIST_BUTTONS_MAX]; // buttons for each line of text in list
212 static int Palette_bmp;
213 
214 static int Ships_loaded = 0;
215 static int Weapons_loaded = 0;
216 static int Intel_loaded = 0;
217 
219 
220 // out entry data struct & vars
221 typedef struct {
222  int index; // index into the master table that its in (ie Ship_info[])
223  char* name; // ptr to name string
224  char* desc; // ptr to description string
225  char tech_anim_filename[MAX_FILENAME_LEN]; //duh
226  generic_anim animation; // animation info
227  int bitmap; // bitmap handle
228  int has_anim; // flag to indicate the presence of an animation for this item
229  int model_num; // model reference handle
230  int textures_loaded; // if the model has textures loaded for it or not (hacky mem management)
232 
233 static tech_list_entry *Ship_list = NULL;
234 static int Ship_list_size = 0;
235 static tech_list_entry *Weapon_list = NULL;
236 static int Weapon_list_size = 0;
237 static tech_list_entry Intel_list[MAX_INTEL_ENTRIES];
238 static int Intel_list_size = 0;
239 static tech_list_entry *Current_list; // points to currently valid display list
240 static int Current_list_size = 0;
241 
242 // slider stuff
243 static UI_SLIDER2 Tech_slider;
244 
245 // Intelligence master data structs (these get inited @ game startup from species.tbl)
248 
249 // some prototypes to make you happy
250 int techroom_load_ani(anim **animpp, char *name);
251 void tech_common_render();
252 void tech_scroll_list_up();
253 void tech_scroll_list_down();
254 
255 
256 //stuff for ht&l, vars and such
257 extern int Cmdline_nohtl;
258 
260 // like, functions and stuff
261 
262 void techroom_init_desc(char *src, int w)
263 {
264  Text_size = Text_offset = 0;
265  if (!src) {
266  return;
267  }
268 
269  Text_size = split_str(src, w, Text_line_size, Text_lines, MAX_TEXT_LINES);
270  Assert(Text_size >= 0 && Text_size < MAX_TEXT_LINES);
271 }
272 
274 {
275  int i;
276 
277  //clear everything, just in case, it will get loaded when needed later
278  if (Weapon_list != NULL) {
279  for (i = 0; i < Weapon_list_size; i++) {
280  if (Weapon_list[i].animation.num_frames != 0) {
281  generic_anim_unload(&Weapon_list[i].animation);
282  }
283 
284  if (Weapon_list[i].bitmap >= 0) {
285  bm_release(Weapon_list[i].bitmap);
286  Weapon_list[i].bitmap = -1;
287  }
288  }
289  }
290 
291  for (i = 0; i < Intel_list_size; i++) {
292  if (Intel_list[i].animation.num_frames != 0) {
293  generic_anim_unload(&Intel_list[i].animation);
294  }
295 
296  if (Intel_list[i].bitmap >= 0) {
297  bm_release(Intel_list[i].bitmap);
298  Intel_list[i].bitmap = -1;
299  }
300  }
301 }
302 
304 {
305  Assert(Current_list != NULL);
306  if (Current_list == NULL || Current_list_size <= 0) {
307  Cur_entry_index = Cur_entry = -1;
308  techroom_init_desc(NULL,0);
309  return;
310  }
311 
312  Cur_entry_index = Current_list[Cur_entry].index;
313  Assert( Cur_entry_index >= 0 );
314 
315  // if we are in the ships tab, load the ship model
316  if (Tab == SHIPS_DATA_TAB) {
317  ship_info *sip = &Ship_info[Cur_entry_index];
318 
319  // little memory management, kinda hacky but it should keep the techroom at around
320  // 100meg rather than the 700+ it can get to with all ships loaded - taylor
321  for (int i=0; i<Current_list_size; i++) {
322  if ((Current_list[i].model_num > -1) && (Current_list[i].textures_loaded)) {
323  // don't unload any spot within 5 of current
324  if ( (i < Cur_entry + 5) && (i > Cur_entry - 5) )
325  continue;
326 
327  mprintf(("TECH ROOM: Dumping excess ship textures...\n"));
328 
329  model_page_out_textures(Current_list[i].model_num);
330 
331  Current_list[i].textures_loaded = 0;
332  }
333  }
334 
335  Techroom_ship_modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);
336 
337  Current_list[Cur_entry].model_num = Techroom_ship_modelnum;
338 
339  // page in ship textures properly (takes care of nondimming pixels)
340  model_page_in_textures(Techroom_ship_modelnum, Cur_entry_index);
341 
342  Current_list[Cur_entry].textures_loaded = 1;
343  } else {
344  Techroom_ship_modelnum = -1;
345  Trackball_mode = 0;
346 
347  // load animation here, we now only have one loaded
348  int stream_result = generic_anim_init_and_stream(&Current_list[Cur_entry].animation, Current_list[Cur_entry].tech_anim_filename, bm_get_type(Tech_background_bitmap), true);
349 
350  if (stream_result >= 0) {
351  Current_list[Cur_entry].has_anim = 1;
352  } else {
353  // we've failed to load any animation
354  // load an image and treat it like a 1 frame animation
355  Current_list[Cur_entry].bitmap = bm_load(Current_list[Cur_entry].tech_anim_filename);
356  }
357  }
358 
359  techroom_init_desc(Current_list[Cur_entry].desc, Tech_desc_coords[gr_screen.res][SHIP_W_COORD]);
360  fsspeech_play(FSSPEECH_FROM_TECHROOM, Current_list[Cur_entry].desc);
361 }
362 
363 // write out the current description in the bottom window
364 void techroom_render_desc(int xo, int yo, int ho)
365 {
366  int y, z, len, font_height;
367  char line[MAX_TEXT_LINE_LEN + 1];
368 
369  font_height = gr_get_font_height();
370 
371  y = 0;
372  z = Text_offset;
373  while (y + font_height <= ho) {
374  if (z >= Text_size){
375  break;
376  }
377 
378  len = Text_line_size[z];
379  if (len > MAX_TEXT_LINE_LEN){
380  len = MAX_TEXT_LINE_LEN;
381  }
382 
383  strncpy(line, Text_lines[z], len);
384  line[len] = 0;
385  gr_string(xo, yo + y, line, GR_RESIZE_MENU);
386 
387  y += font_height;
388  z++;
389  }
390 
391  // maybe output 'more' indicator
392  if ( z < Text_size ) {
393  // can be scrolled down
394  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 don't move
395  int more_txt_y = Tech_desc_coords[gr_screen.res][1] + Tech_desc_coords[gr_screen.res][3]; // located below brief text, centered
396  int w, h;
397  gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469)));
399  gr_rect(more_txt_x-2, more_txt_y, w+3, h, GR_RESIZE_MENU);
401  gr_string(more_txt_x, more_txt_y, XSTR("more", 1469), GR_RESIZE_MENU); // base location on the input x and y?
402  }
403 
404 }
405 
406 // renders the stuff common to all 3 tech room tabs
408 {
409  char buf[256];
410  int y, z, font_height;
411 
412  // render description in its box
415 
416  font_height = gr_get_font_height();
417 
418  // draw the list of entries
419  y = 0;
420  z = List_offset;
421  while (y + font_height <= Tech_list_coords[gr_screen.res][SHIP_H_COORD]) {
422  if (z >= Current_list_size) {
423  break;
424  }
425 
426  if (z == Cur_entry) {
428  } else if (z == Select_tease_line) {
430  } else {
432  }
433 
434  memset( buf, 0, sizeof(buf) );
435  strncpy(buf, Current_list[z].name, sizeof(buf) - 1);
436 
437  if (Lcl_gr)
439 
441  gr_string(Tech_list_coords[gr_screen.res][SHIP_X_COORD], Tech_list_coords[gr_screen.res][SHIP_Y_COORD] + y, buf, GR_RESIZE_MENU);
442 
443  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);
444  List_buttons[z - List_offset].enable(1);
445 
446  y += font_height;
447  z++;
448  }
449 
450  // disable the rest of the list buttons
451  z -= List_offset;
452  while (z < LIST_BUTTONS_MAX) {
453  List_buttons[z++].disable();
454  }
455 }
456 
458 
459 void techroom_ships_render(float frametime)
460 {
461  // render all the common stuff
463 
464  if(Cur_entry_index == -1)
465  return;
466 
467  // now render the trackball ship, which is unique to the ships tab
468  float rev_rate = REVOLUTION_RATE;
469  angles rot_angles, view_angles;
470  int z, i, j;
471  ship_info *sip = &Ship_info[Cur_entry_index];
472  model_render_params render_info;
473 
474  if (sip->uses_team_colors) {
475  render_info.set_team_color(sip->default_team_name, "none", 0, 0);
476  }
477 
478  // get correct revolution rate
479  z = sip->flags;
480  if (z & SIF_BIG_SHIP) {
481  rev_rate *= 1.7f;
482  }
483  if (z & SIF_HUGE_SHIP) {
484  rev_rate *= 3.0f;
485  }
486 
487  // rotate the ship as much as required for this frame
488  Techroom_ship_rot += PI2 * frametime / rev_rate;
489  while (Techroom_ship_rot > PI2){
490  Techroom_ship_rot -= PI2;
491  }
492 
493  // reorient ship
494  if (Trackball_active) {
495  int dx, dy;
496  matrix mat1, mat2;
497 
498  if (Trackball_active) {
499  mouse_get_delta(&dx, &dy);
500  if (dx || dy) {
501  vm_trackball(-dx, -dy, &mat1);
502  vm_matrix_x_matrix(&mat2, &mat1, &Techroom_ship_orient);
503  Techroom_ship_orient = mat2;
504  }
505  }
506 
507  } else {
508  // setup stuff needed to render the ship
509  view_angles.p = -0.6f;
510  view_angles.b = 0.0f;
511  view_angles.h = 0.0f;
512  vm_angles_2_matrix(&Techroom_ship_orient, &view_angles);
513 
514  rot_angles.p = 0.0f;
515  rot_angles.b = 0.0f;
516  rot_angles.h = Techroom_ship_rot;
517  vm_rotate_matrix_by_angles(&Techroom_ship_orient, &rot_angles);
518  }
519 
521 
522  // render the ship
523  g3_start_frame(1);
525 
526 
527 
528  // lighting for techroom
529  light_reset();
530  vec3d light_dir = vmd_zero_vector;
531  light_dir.xyz.y = 1.0f;
532  light_dir.xyz.x = 0.0000001f;
533  light_add_directional(&light_dir, 0.85f, 1.0f, 1.0f, 1.0f);
535  // lighting for techroom
536 
538 
539  model_clear_instance(Techroom_ship_modelnum);
540  render_info.set_detail_level_lock(0);
541 
542  polymodel *pm = model_get(Techroom_ship_modelnum);
543 
544  for (i = 0; i < sip->n_subsystems; i++) {
545  model_subsystem *msp = &sip->subsystems[i];
546  if (msp->type == SUBSYSTEM_TURRET) {
547 
548  float p = 0.0f;
549  float h = 0.0f;
550 
551  for (j = 0; j < msp->n_triggers; j++) {
552 
553  // special case for turrets
554  p = msp->triggers[j].angle.xyz.x;
555  h = msp->triggers[j].angle.xyz.y;
556  }
557  if ( msp->subobj_num >= 0 ) {
558  model_set_instance_techroom(Techroom_ship_modelnum, msp->subobj_num, 0.0f, h );
559  }
560  if ( (msp->subobj_num != msp->turret_gun_sobj) && (msp->turret_gun_sobj >= 0) ) {
561  model_set_instance_techroom(Techroom_ship_modelnum, msp->turret_gun_sobj, p, 0.0f );
562  }
563  }
564  }
565 
567  {
568  gr_reset_clip();
569 
570  shadows_start_render(&Eye_matrix, &Eye_position, Proj_fov, gr_screen.clip_aspect, -sip->closeup_pos.xyz.z + pm->rad, -sip->closeup_pos.xyz.z + pm->rad + 200.0f, -sip->closeup_pos.xyz.z + pm->rad + 2000.0f, -sip->closeup_pos.xyz.z + pm->rad + 10000.0f);
572 
573  model_render_immediate(&render_info, Techroom_ship_modelnum, &Techroom_ship_orient, &vmd_zero_vector);
575 
577  }
578 
579  if (!Cmdline_nohtl) {
582  }
583 
584  uint render_flags = MR_AUTOCENTER;
585 
586  if(sip->flags2 & SIF2_NO_LIGHTING)
587  render_flags |= MR_NO_LIGHTING;
588 
589  render_info.set_flags(render_flags);
590 
591  model_render_immediate(&render_info, Techroom_ship_modelnum, &Techroom_ship_orient, &vmd_zero_vector);
592 
594 
596 
597  if (!Cmdline_nohtl)
598  {
601  }
602 
603  g3_end_frame();
604 
605  gr_reset_clip();
606 }
607 
608 // select previous entry in current list
610 {
611  //unload the current animation, we load another one for the new current entry
613 
614  Cur_entry--;
615  if (Cur_entry < 0) {
616  Cur_entry = Current_list_size - 1;
617 
618  // scroll to end of list
619  List_offset = Cur_entry - Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() + 1;
620  if (List_offset < 0) {
621  // this happens when there are not enough items to scroll
622  List_offset = 0;
623  }
624  Tech_slider.force_currentItem(Tech_slider.get_numberItems());
625  } else {
626  // maybe adjust list position by 1
627  if (List_offset > Cur_entry) {
629  Tech_slider.forceUp();
630  }
631  }
632 
635 }
636 
637 // select next entry in current list
639 {
640  //unload the current animation, we load another one for the new current entry
642 
643  Cur_entry++;
644  if (Cur_entry >= Current_list_size) {
645  Cur_entry = 0;
646 
647  // scroll to beginning of list
648  List_offset = 0;
649  Tech_slider.force_currentItem(Cur_entry);
650  } else {
651  // maybe adjust list position by 1
652  if (List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() <= Cur_entry) {
654  Tech_slider.forceDown();
655  }
656  }
657 
660 }
661 
663 {
664  if (Text_offset) {
665  Text_offset--;
667  } else {
669  }
670 }
671 
673 {
674  int h;
675 
677 
678  if (Text_offset + h / gr_get_font_height() < Text_size) {
679  Text_offset++;
681  } else { //-V523
683  }
684 }
685 
687 {
688  //int last;
689 
690  if (List_offset > 0) {
691  List_offset--;
693  } else {
695  }
696 }
697 
699 {
700  if (List_offset + Tech_list_coords[gr_screen.res][SHIP_H_COORD] / gr_get_font_height() < Current_list_size) {
701  List_offset++;
703  } else {
705  }
706 }
707 
708 // this doesn't do a thing...
710 {
711  //unload the current animation, we load another one for the new current entry
713 
715 }
716 
717 void techroom_anim_render(float frametime)
718 {
719  int x, y;
720 
721  // render common stuff
723 
724  // render the animation
725  if(Current_list[Cur_entry].animation.num_frames > 0)
726  {
727  //grab dimensions
728  bm_get_info((Current_list[Cur_entry].animation.streaming) ? Current_list[Cur_entry].animation.bitmap_id : Current_list[Cur_entry].animation.first_frame, &x, &y, NULL, NULL, NULL);
729  //get the centre point - adjust
730  x = Tech_ani_centre_coords[gr_screen.res][0] - x / 2;
731  y = Tech_ani_centre_coords[gr_screen.res][1] - y / 2;
732  generic_anim_render(&Current_list[Cur_entry].animation, frametime, x, y, true);
733  }
734  // if our active item has a bitmap instead of an animation, draw it
735  else if((Cur_entry >= 0) && (Current_list[Cur_entry].bitmap >= 0)){
736  //grab dimensions
737  bm_get_info(Current_list[Cur_entry].bitmap, &x, &y, NULL, NULL, NULL);
738  //get the centre point - adjust
739  x = Tech_ani_centre_coords[gr_screen.res][0] - x / 2;
740  y = Tech_ani_centre_coords[gr_screen.res][1] - y / 2;
741  gr_set_bitmap(Current_list[Cur_entry].bitmap);
742  gr_bitmap(x, y, GR_RESIZE_MENU);
743  }
744 }
745 
747 {
748  int i, multi = 0, mask, mask2, font_height, max_num_entries_viewable;
749 
750  //unload the current animation, we load another one for the new current entry
751  if(Tab != SHIPS_DATA_TAB)
753 
754  Tab = num;
755  List_offset = 0;
756  Cur_entry = 0;
758 
759  for (i=0; i<LIST_BUTTONS_MAX; i++){
760  List_buttons[i].disable();
761  }
762 
763  // disable some stuff in multiplayer
767  }
768 
769  switch (Tab) {
770  case SHIPS_DATA_TAB:
773 
774  // load ship info if necessary
775  if ( Ships_loaded == 0 ) {
776  if (Ship_list == NULL) {
777  Ship_list = new tech_list_entry[Ship_info.size()];
778 
779  if (Ship_list == NULL)
780  Error(LOCATION, "Couldn't init ships list!");
781  }
782 
783  Ship_list_size = 0;
784 
785  for (auto it = Ship_info.begin(); it != Ship_info.end(); ++it)
786  {
787  if (Techroom_show_all || (it->flags & mask) || (it->flags2 & mask2))
788  {
789  // this ship should be displayed, fill out the entry struct
790  Ship_list[Ship_list_size].bitmap = -1;
791  Ship_list[Ship_list_size].index = std::distance(Ship_info.begin(), it);
792  Ship_list[Ship_list_size].animation.num_frames = 0; // no anim for ships
793  Ship_list[Ship_list_size].has_anim = 0; // no anim for ships
794  Ship_list[Ship_list_size].name = *it->tech_title ? it->tech_title : (*it->alt_name ? it->alt_name : it->name);
795  Ship_list[Ship_list_size].desc = it->tech_desc;
796  Ship_list[Ship_list_size].model_num = -1;
797  Ship_list[Ship_list_size].textures_loaded = 0;
798 
799  Ship_list_size++;
800  }
801  }
802 
803  // make sure that at least the default entry is cleared out if we didn't grab anything
804  if (!Ship_info.empty() && !Ship_list_size) {
805  Ship_list[0].index = -1;
806  Ship_list[0].desc = NULL;
807  Ship_list[0].name = NULL;
808  Ship_list[0].bitmap = -1;
809  Ship_list[0].has_anim = 0;
810  Ship_list[0].animation.num_frames = 0;
811  Ship_list[0].model_num = -1;
812  Ship_list[0].textures_loaded = 0;
813  }
814 
815  Ships_loaded = 1;
816  }
817 
818  Current_list = Ship_list;
819  Current_list_size = Ship_list_size;
820 
821  font_height = gr_get_font_height();
822  max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
823  Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
824 
825  // no anim to start here
826  break;
827 
828  case WEAPONS_DATA_TAB:
829 
830  // load weapon info & anims if necessary
831  if ( Weapons_loaded == 0 ) {
832  if (Weapon_list == NULL) {
833  Weapon_list = new tech_list_entry[Num_weapon_types];
834 
835  if (Weapon_list == NULL)
836  Error(LOCATION, "Couldn't init ships list!");
837  }
838 
839  Weapon_list_size = 0;
842 
843  for (i=0; i<Num_weapon_types; i++)
844  {
845  if (Techroom_show_all || (Weapon_info[i].wi_flags & mask) || (Weapon_info[i].wi_flags2 & mask2))
846  {
847  // we have a weapon that should be in the tech db, so fill out the entry struct
848  Weapon_list[Weapon_list_size].index = i;
849  Weapon_list[Weapon_list_size].desc = Weapon_info[i].tech_desc;
850  Weapon_list[Weapon_list_size].has_anim = 1;
851  Weapon_list[Weapon_list_size].name = *Weapon_info[i].tech_title ? Weapon_info[i].tech_title : Weapon_info[i].name;
852  Weapon_list[Weapon_list_size].bitmap = -1;
853  Weapon_list[Weapon_list_size].animation.num_frames = 0;
854  Weapon_list[Weapon_list_size].model_num = -1;
855  Weapon_list[Weapon_list_size].textures_loaded = 0;
856  // copy the weapon animation filename
857  strncpy(Weapon_list[Weapon_list_size].tech_anim_filename, Weapon_info[i].tech_anim_filename, MAX_FILENAME_LEN - 1);
858 
859  Weapon_list_size++;
860  }
861  }
862 
863  // make sure that at least the default entry is cleared out if we didn't grab anything
864  if (Num_weapon_types && !Weapon_list_size) {
865  Weapon_list[0].index = -1;
866  Weapon_list[0].desc = NULL;
867  Weapon_list[0].name = NULL;
868  Weapon_list[0].bitmap = -1;
869  Weapon_list[0].has_anim = 0;
870  Weapon_list[0].animation.num_frames = 0;
871  Weapon_list[0].model_num = -1;
872  Weapon_list[0].textures_loaded = 0;
873  }
874 
875  Weapons_loaded = 1;
876  }
877 
878  Current_list = Weapon_list;
879  Current_list_size = Weapon_list_size;
880 
881  font_height = gr_get_font_height();
882  max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
883  Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
884 
885  break;
886 
887  case INTEL_DATA_TAB:
888 
889  // load intel if necessary
890  if ( Intel_loaded == 0 ) {
891  // now populate the entry structs
892  Intel_list_size = 0;
893 
894  for (i=0; i<Intel_info_size; i++) {
895  if (Techroom_show_all || (Intel_info[i].flags & IIF_IN_TECH_DATABASE) || (Intel_info[i].flags & IIF_DEFAULT_IN_TECH_DATABASE)) {
896  // leave option for no animation if string == "none"
897  if (!strcmp(Intel_info[i].anim_filename, "none")) {
898  Intel_list[Intel_list_size].has_anim = 0;
899  Intel_list[Intel_list_size].animation.num_frames = 0;
900  } else {
901  // try and load as an animation
902  Intel_list[Intel_list_size].has_anim = 0;
903  Intel_list[Intel_list_size].bitmap = -1;
904  strncpy(Intel_list[Intel_list_size].tech_anim_filename, Intel_info[i].anim_filename, NAME_LENGTH - 1);
905  }
906 
907  Intel_list[Intel_list_size].desc = Intel_info[i].desc;
908  Intel_list[Intel_list_size].index = i;
909  Intel_list[Intel_list_size].name = Intel_info[i].name;
910  Intel_list[Intel_list_size].model_num = -1;
911  Intel_list[Intel_list_size].textures_loaded = 0;
912 
913  Intel_list_size++;
914  }
915  }
916 
917  // make sure that at least the default entry is cleared out if we didn't grab anything
918  if (Intel_info_size && !Intel_list_size) {
919  Intel_list[0].index = -1;
920  Intel_list[0].desc = NULL;
921  Intel_list[0].name = NULL;
922  Intel_list[0].bitmap = -1;
923  Intel_list[0].has_anim = 0;
924  Intel_list[0].animation.num_frames = 0;
925  Intel_list[0].model_num = -1;
926  Intel_list[0].textures_loaded = 0;
927  }
928 
929  Intel_loaded = 1;
930  }
931 
932  // index lookup on intel is a pretty pointless, but it keeps everything
933  // consistent and doesn't really hurt anything
934  Current_list = Intel_list;
935  Current_list_size = Intel_list_size;
936 
937  font_height = gr_get_font_height();
938  max_num_entries_viewable = Tech_list_coords[gr_screen.res][SHIP_H_COORD] / font_height;
939  Tech_slider.set_numberItems(Current_list_size > max_num_entries_viewable ? Current_list_size-max_num_entries_viewable : 0);
940 
941  break;
942  }
943 
944  // reset the entry
945  Cur_entry = 0;
947 
948 }
949 
951 {
952  switch (num) {
953  case SHIPS_DATA_TAB:
954  case WEAPONS_DATA_TAB:
955  case INTEL_DATA_TAB:
956  fsspeech_stop();
957  techroom_change_tab(num);
958  break;
959 
960  case SIMULATOR_TAB:
961  fsspeech_stop();
964  return 1;
965 
966  case CUTSCENES_TAB:
967  fsspeech_stop();
970  return 1;
971 
972  case CREDITS_TAB:
973  fsspeech_stop();
976  return 1;
977 
978  case PREV_ENTRY_BUTTON:
979  tech_prev_entry();
980  break;
981 
982  case NEXT_ENTRY_BUTTON:
983  tech_next_entry();
984  break;
985 
986  case SCROLL_LIST_UP:
988  Tech_slider.forceUp();
989  break;
990 
991  case SCROLL_LIST_DOWN:
993  Tech_slider.forceDown();
994  break;
995 
996  case SCROLL_INFO_UP:
998  break;
999 
1000  case SCROLL_INFO_DOWN:
1002  break;
1003 
1004  case HELP_BUTTON:
1007  break;
1008 
1009  case OPTIONS_BUTTON:
1012  break;
1013 
1014  case EXIT_BUTTON:
1015  fsspeech_stop();
1018  break;
1019  }
1020 
1021  return 0;
1022 }
1023 
1024 int techroom_load_ani(anim **animpp, char *name)
1025 {
1026  int load_attempts = 0;
1027  char anim_filename[64] = "2_";
1028 
1029  // hi-res support
1030  // (i don't think there are any hi-res anims for these tho)
1031  if (gr_screen.res == GR_1024) {
1032  strcat_s(anim_filename, name);
1033  } else {
1034  strcpy_s(anim_filename, name);
1035  }
1036 
1037  while(1) {
1038  if ( load_attempts++ > 5 ) {
1039  return 0;
1040  }
1041 
1042  return 1;
1043  }
1044 
1045  // bogus
1046  return 0;
1047 }
1048 
1049 
1051 {
1052  int temp;
1053  static int inited = 0;
1054 
1055  if (inited)
1056  return;
1057 
1058  try
1059  {
1060  read_file_text("species.tbl", CF_TYPE_TABLES);
1061  reset_parse();
1062 
1063  Intel_info_size = 0;
1064  while (optional_string("$Entry:")) {
1067  mprintf(("TECHMENU: Too many intel entries!\n"));
1068  break;
1069  }
1070 
1071  Intel_info[Intel_info_size].flags = IIF_DEFAULT_VALUE;
1072 
1073  required_string("$Name:");
1075 
1076  required_string("$Anim:");
1077  stuff_string(Intel_info[Intel_info_size].anim_filename, F_NAME, NAME_LENGTH);
1078 
1079  required_string("$AlwaysInTechRoom:");
1080  stuff_int(&temp);
1081  if (temp) {
1082  // set default to align with what we read - Goober5000
1085  }
1086 
1087  required_string("$Description:");
1089 
1090  Intel_info_size++;
1091  }
1092 
1093  inited = 1;
1094  }
1095  catch (const parse::ParseException& e)
1096  {
1097  mprintf(("TABLES: Unable to parse '%s'! Error message = %s.\n", "species.tbl", e.what()));
1098  return;
1099  }
1100 }
1101 
1103 {
1104  int i, idx;
1106 
1107  Ships_loaded = 0;
1108  Weapons_loaded = 0;
1109  Intel_loaded = 0;
1110 
1111  Techroom_show_all = 0;
1112 
1113  // set up UI stuff
1116 
1117  Tech_background_bitmap = bm_load(Tech_background_filename[gr_screen.res]);
1118  if (Tech_background_bitmap < 0) {
1119  // failed to load bitmap, not a good thing
1120  Error(LOCATION,"Couldn't load techroom background bitmap");
1121  }
1122 
1123  for (i=0; i<NUM_BUTTONS; i++) {
1124  b = &Buttons[gr_screen.res][i];
1125 
1126  b->button.create(&Ui_window, "", b->x, b->y, 60, 30, b->flags & REPEAT, 1);
1127  // set up callback for when a mouse first goes over a button
1128  if (b->filename) {
1129  b->button.set_bmaps(b->filename);
1131  } else {
1132  b->button.hide();
1133  }
1134 
1135  b->button.link_hotspot(b->hotspot);
1136  }
1137 
1138  // common tab button text
1139  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);
1140  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);
1141  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);
1142  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);
1143 
1144  // common ship/weapon/intel text
1145  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);
1146  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);
1147  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);
1148 
1149  // common help/options/commit text
1150  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);
1151 
1155  }
1156 
1157  // set some hotkeys
1162 
1163 
1164  for (i=0; i<LIST_BUTTONS_MAX; i++) {
1165  List_buttons[i].create(&Ui_window, "", 0, 0, 60, 30, 0, 1);
1166  List_buttons[i].hide();
1167  List_buttons[i].disable();
1168  }
1169 
1171  View_window.hide();
1172 
1177 
1178  // init help overlay states
1181 
1182  // setup slider
1184 
1185  // zero intel anim/bitmap stuff
1186  for(idx=0; idx<MAX_INTEL_ENTRIES; idx++){
1187  Intel_list[idx].animation.num_frames = 0;
1188  Intel_list[idx].bitmap = -1;
1189  }
1190 
1191  mprintf(("Techroom successfully initialized, now changing tab...\n"));
1192  techroom_change_tab(Tab);
1193 }
1194 
1196 {
1197  int i;
1198 
1199  //unload the current animation, we load another one for the new current entry
1200  if(Tab != SHIPS_DATA_TAB)
1202 
1203  Current_list = NULL;
1204  Current_list_size = 0;
1205 
1206  model_free_all();
1207 
1208  if (Ship_list != NULL) {
1209  delete[] Ship_list;
1210  Ship_list = NULL;
1211  }
1212 
1213  Ship_list_size = 0;
1214  Ships_loaded = 0;
1215 
1216  if (Weapon_list != NULL) {
1217  for (i = 0; i < Weapon_list_size; i++) {
1218  if (Weapon_list[i].animation.num_frames != 0) {
1219  generic_anim_unload(&Weapon_list[i].animation);
1220  }
1221 
1222  if (Weapon_list[i].bitmap >= 0) {
1223  bm_release(Weapon_list[i].bitmap);
1224  Weapon_list[i].bitmap = -1;
1225  }
1226  }
1227 
1228  delete[] Weapon_list;
1229  Weapon_list = NULL;
1230  }
1231 
1232  Weapon_list_size = 0;
1233  Weapons_loaded = 0;
1234 
1235  for (i = 0; i < Intel_list_size; i++) {
1236  if (Intel_list[i].animation.num_frames != 0) {
1237  generic_anim_unload(&Intel_list[i].animation);
1238  }
1239 
1240  if (Intel_list[i].bitmap >= 0) {
1241  bm_release(Intel_list[i].bitmap);
1242  Intel_list[i].bitmap = -1;
1243  }
1244  }
1245 
1246  Intel_list_size = 0;
1247  Intel_loaded = 0;
1248 }
1249 
1251 {
1252  fsspeech_stop();
1253 
1255 
1256  Techroom_show_all = 0;
1257 
1258  if (Tech_background_bitmap) {
1259  bm_release(Tech_background_bitmap);
1260  }
1261 
1262  Ui_window.destroy();
1263  common_free_interface_palette(); // restore game palette
1264  if (Palette_bmp){
1265  bm_release(Palette_bmp);
1266  }
1267 }
1268 
1269 void techroom_do_frame(float frametime)
1270 {
1271 
1272  int i, k;
1273 
1274  // turn off controls when overlay is on
1277  Ui_window.set_ignore_gadgets(1);
1278  }
1279 
1280  // turn off controls in trackball mode
1281  if (Trackball_active) {
1282  Ui_window.set_ignore_gadgets(1);
1283  } else {
1284  Ui_window.set_ignore_gadgets(0);
1285  }
1286 
1287  k = Ui_window.process() & ~KEY_DEBUGGED;
1288 
1289  if ( (k > 0) || B1_JUST_RELEASED ) {
1292  Ui_window.set_ignore_gadgets(0);
1293  k = 0;
1294  }
1295  }
1296 
1298  Ui_window.set_ignore_gadgets(0);
1299  }
1300 
1301  switch (k) {
1302  case KEY_SHIFTED | KEY_TAB: // activate previous tab
1303  i = Tab - 1;
1304  if (i < 0) {
1305  i = NUM_TABS - 1;
1306  }
1307 
1309  break;
1310 
1311  case KEY_TAB: // activate next tab
1312  i = Tab + 1;
1313  if (i >= NUM_TABS) {
1314  i = 0;
1315  }
1316 
1318  break;
1319 
1320  case KEY_CTRLED | KEY_DOWN:
1321  if ( !(Player->flags & PLAYER_FLAGS_IS_MULTI) ) {
1323  break;
1324  }
1325  // fall through
1326 
1327  case KEY_CTRLED | KEY_UP:
1329  break;
1330 
1331  case KEY_CTRLED | KEY_ENTER:
1332  case KEY_ESC:
1334  break;
1335 
1336  case KEY_CTRLED | KEY_SHIFTED | KEY_S:
1337  Techroom_show_all = 1;
1339  techroom_change_tab(Tab);
1340  break;
1341 
1342  }
1343 
1344  // check ship model window for activity
1345  if (View_window.pressed()) {
1346  Trackball_active = 1;
1347  Trackball_mode = 1;
1348  }
1349  if (B1_RELEASED) {
1350  Trackball_active = 0;
1351  }
1352 
1353  // check all da buttons
1354  for (i=0; i<NUM_BUTTONS; i++) {
1355  if (Buttons[gr_screen.res][i].button.pressed()) {
1356  if (techroom_button_pressed(i)) {
1357  return;
1358  }
1359  }
1360  }
1361 
1362  // check for mouseovers/clicks on the selection list
1363  Select_tease_line = -1;
1364  for (i=0; i<LIST_BUTTONS_MAX; i++) {
1365  if (List_buttons[i].is_mouse_on()) {
1366  Select_tease_line = i + List_offset;
1367  }
1368 
1369  if (List_buttons[i].pressed()) {
1370  Cur_entry = i + List_offset;
1373  }
1374  }
1375 
1376  // clear & draw bg bitmap
1377  GR_MAYBE_CLEAR_RES(Tech_background_bitmap);
1378  if (Tech_background_bitmap >= 0) {
1379  gr_set_bitmap(Tech_background_bitmap);
1380  gr_bitmap(0, 0, GR_RESIZE_MENU);
1381  }
1382 
1383  // render
1384  switch (Tab) {
1385  case SHIPS_DATA_TAB:
1386  techroom_ships_render(frametime);
1387  break;
1388 
1389  case WEAPONS_DATA_TAB:
1390  case INTEL_DATA_TAB:
1391  techroom_anim_render(frametime);
1392  break;
1393  }
1394 
1395  Ui_window.draw();
1396 
1397  for (i=TECH_DATABASE_TAB; i<=CREDITS_TAB; i++) {
1398  if (Buttons[gr_screen.res][i].button.button_down()) {
1399  break;
1400  }
1401  }
1402  if (i > CREDITS_TAB) {
1404  }
1405 
1406  for (i=0; i<NUM_TABS; i++){
1407  if (Buttons[gr_screen.res][i].button.button_down()){
1408  break;
1409  }
1410  }
1411  if (i == NUM_TABS){
1412  Buttons[gr_screen.res][Tab].button.draw_forced(2);
1413  }
1414 
1415  // blit help overlay if active
1417 
1418  gr_flip();
1419 }
1420 
1421 // note: the name has to be pre-translated before being passed into this function
1423 {
1424  int i;
1425 
1426  // bogus
1427  if (!name)
1428  return -1;
1429 
1430  for (i=0; i<Intel_info_size; i++)
1431  if (!stricmp(name, Intel_info[i].name))
1432  return i;
1433 
1434  return -1;
1435 }
1436 
1437 // Goober5000
1439 {
1440  int i;
1441 
1442  // ships
1443  for (auto it = Ship_info.begin(); it != Ship_info.end(); ++it)
1444  {
1445  if (it->flags2 & SIF2_DEFAULT_IN_TECH_DATABASE)
1446  it->flags |= SIF_IN_TECH_DATABASE;
1447  else
1448  it->flags &= ~SIF_IN_TECH_DATABASE;
1449 
1450  if (it->flags2 & SIF2_DEFAULT_IN_TECH_DATABASE_M)
1451  it->flags |= SIF_IN_TECH_DATABASE_M;
1452  else
1453  it->flags &= ~SIF_IN_TECH_DATABASE_M;
1454  }
1455 
1456  // weapons
1457  for (i=0; i<Num_weapon_types; i++)
1458  {
1459  if (Weapon_info[i].wi_flags2 & WIF2_DEFAULT_IN_TECH_DATABASE)
1461  else
1463  }
1464 
1465  // intelligence
1466  for (i=0; i<Intel_info_size; i++)
1467  {
1468  if (Intel_info[i].flags & IIF_DEFAULT_IN_TECH_DATABASE)
1469  Intel_info[i].flags |= IIF_IN_TECH_DATABASE;
1470  else
1471  Intel_info[i].flags &= ~IIF_IN_TECH_DATABASE;
1472  }
1473 }
Definition: techmenu.cpp:221
void light_add_directional(const vec3d *dir, float intensity, float r, float g, float b, float spec_r, float spec_g, float spec_b, bool specular)
Definition: lighting.cpp:209
void gr_rect(int x, int y, int w, int h, int resize_mode)
Definition: 2d.cpp:2068
bool uses_team_colors
Definition: ship.h:1365
void tech_common_render()
Definition: techmenu.cpp:407
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
void set_highlight_action(void(*_user_function)(void))
Definition: button.cpp:375
int i
Definition: multi_pxo.cpp:466
void techroom_unload_animation()
Definition: techmenu.cpp:273
int bitmap_id
Definition: generic.h:46
float p
Definition: pstypes.h:111
#define SHIPS_DATA_MODE
Definition: techmenu.cpp:43
void add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id=-1)
Definition: window.cpp:476
char * tech_desc
Definition: weapon.h:335
void reset_status()
Definition: button.cpp:78
float Proj_fov
Definition: 3dsetup.cpp:31
void fsspeech_stop()
Definition: fsspeech.h:45
#define KEY_DOWN
Definition: key.h:180
int flags
Definition: player.h:104
matrix * vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1)
Definition: vecmat.cpp:1006
char name[NAME_LENGTH]
Definition: weapon.h:322
#define REPEAT
Definition: techmenu.cpp:69
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
#define MAX_TEXT_LINES
Definition: techmenu.cpp:138
#define KEY_LEFT
Definition: key.h:181
void gr_flip()
Definition: 2d.cpp:2113
commit pressed
Definition: gamesnd.h:294
polymodel * model_get(int model_num)
Definition: modelread.cpp:3134
weapon_info Weapon_info[MAX_WEAPON_TYPES]
Definition: weapons.cpp:79
#define KEY_PAGEDOWN
Definition: key.h:178
#define GR_RESIZE_MENU
Definition: 2d.h:684
#define SIF_IN_TECH_DATABASE_M
Definition: ship.h:898
#define gr_end_view_matrix
Definition: 2d.h:896
color Color_more_indicator
Definition: alphacolors.cpp:28
int turret_gun_sobj
Definition: model.h:193
#define MAX_TEXT_LINE_LEN
Definition: techmenu.cpp:139
matrix * vm_angles_2_matrix(matrix *m, const angles *a)
Definition: vecmat.cpp:752
#define KEY_RIGHT
Definition: key.h:182
void vm_rotate_matrix_by_angles(matrix *orient, const angles *tangles)
Definition: vecmat.cpp:1338
Assert(pm!=NULL)
#define WIF2_DEFAULT_IN_TECH_DATABASE
Definition: weapon.h:86
Definition: pstypes.h:88
#define GR_NUM_RESOLUTIONS
Definition: 2d.h:651
#define mprintf(args)
Definition: pstypes.h:238
UI_BUTTON button
Definition: techmenu.cpp:147
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:769
char desc[TECH_INTEL_DESC_LEN]
Definition: techmenu.h:22
general failure sound for any event
Definition: gamesnd.h:297
#define EXIT_BUTTON
Definition: techmenu.cpp:66
matrix Eye_matrix
Definition: 3dsetup.cpp:26
help pressed
Definition: gamesnd.h:293
int res
Definition: 2d.h:370
int max_h_unscaled
Definition: 2d.h:361
int bm_get_info(int handle, int *w, int *h, ubyte *flags, int *nframes, int *fps)
Gets info on the bitmap indexed by handle.
Definition: bmpman.cpp:769
void set_flags(uint flags)
void tech_reset_to_default()
Definition: techmenu.cpp:1438
#define MR_NO_LIGHTING
Definition: model.h:867
#define LIST_BUTTONS_MAX
Definition: techmenu.cpp:41
struct vec3d::@225::@227 xyz
#define SCROLL_LIST_UP
Definition: techmenu.cpp:56
void techroom_lists_reset()
Definition: techmenu.cpp:1195
void model_render_immediate(model_render_params *render_info, int model_num, matrix *orient, vec3d *pos, int render, bool sort)
GLclampf f
Definition: Glext.h:7097
void forceUp()
Definition: slider2.cpp:309
#define SCROLL_LIST_DOWN
Definition: techmenu.cpp:57
#define GR_MAYBE_CLEAR_RES(bmap)
Definition: 2d.h:639
model_subsystem * subsystems
Definition: ship.h:1271
void set_detail_level_lock(int detail_level_lock)
int model_num
Definition: techmenu.cpp:229
void help_overlay_set_state(int overlay_id, int resolution_index, int state)
void set_ignore_gadgets(int state)
Definition: window.cpp:471
virtual void hide(int n)
Definition: gadget.cpp:207
void gr_set_color_fast(color *dst)
Definition: 2d.cpp:1197
#define SHIP_H_COORD
Definition: techmenu.cpp:76
#define KEY_PAGEUP
Definition: key.h:175
Definition: ui.h:195
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
Definition: 2d.cpp:2105
int max_w_unscaled
Definition: 2d.h:361
void techroom_intel_init()
Definition: techmenu.cpp:1050
int index
Definition: techmenu.cpp:222
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: Glext.h:7308
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
Definition: bmpman.cpp:2603
void forceDown()
Definition: slider2.cpp:302
#define gr_end_proj_matrix
Definition: 2d.h:894
#define SCROLL_INFO_DOWN
Definition: techmenu.cpp:59
void techroom_anim_render(float frametime)
Definition: techmenu.cpp:717
int subobj_num
Definition: model.h:175
#define SHIPS_DATA_TAB
Definition: techmenu.cpp:48
#define WEAPONS_DATA_TAB
Definition: techmenu.cpp:49
#define B1_JUST_RELEASED
Definition: uidefs.h:50
void generic_anim_unload(generic_anim *ga)
Definition: generic.cpp:291
void tech_prev_entry()
Definition: techmenu.cpp:609
int Tech_ship_display_coords[GR_NUM_RESOLUTIONS][4]
Definition: techmenu.cpp:102
void shadows_end_render()
Definition: shadows.cpp:386
void tech_scroll_list_up()
Definition: techmenu.cpp:686
#define TECH_INTEL_DESC_LEN
Definition: techmenu.h:18
#define SIF2_DEFAULT_IN_TECH_DATABASE
Definition: ship.h:918
void techroom_select_new_entry()
Definition: techmenu.cpp:303
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:741
void draw_forced(int frame_num)
Definition: button.cpp:104
#define gr_set_view_matrix
Definition: 2d.h:895
#define SIF2_NO_LIGHTING
Definition: ship.h:932
void destroy()
Definition: window.cpp:189
int num_frames
Definition: generic.h:20
void techroom_ships_render(float frametime)
Definition: techmenu.cpp:459
#define gr_reset_clip
Definition: 2d.h:745
void set_mask_bmap(char *fname)
Definition: window.cpp:75
matrix shadows_start_render(matrix *eye_orient, vec3d *eye_pos, float fov, float aspect, float veryneardist, float neardist, float middist, float fardist)
Definition: shadows.cpp:349
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
Definition: gadget.cpp:71
#define NUM_TABS
Definition: techmenu.cpp:40
void batch_render_all(int stream_buffer)
Definition: grbatch.cpp:1124
const float PI2
Definition: pstypes.h:305
char pof_file[MAX_FILENAME_LEN]
Definition: ship.h:1183
#define gr_set_proj_matrix
Definition: 2d.h:893
void common_free_interface_palette()
void set_numberItems(int _numberItems, int _reset=1)
Definition: slider2.cpp:217
char * Tech_mask_filename[GR_NUM_RESOLUTIONS]
Definition: techmenu.cpp:84
#define SIF_BIG_SHIP
Definition: ship.h:944
int intel_info_lookup(char *name)
Definition: techmenu.cpp:1422
unsigned int uint
Definition: pstypes.h:64
char name[NAME_LENGTH]
Definition: techmenu.h:21
int first_frame
Definition: generic.h:19
void tech_scroll_info_up()
Definition: techmenu.cpp:662
void tech_ship_scroll_capture()
Definition: techmenu.cpp:709
#define TECH_ROOM_OVERLAY
Definition: contexthelp.h:35
#define WIF_IN_TECH_DATABASE
Definition: weapon.h:67
float clip_aspect
Definition: 2d.h:372
#define MR_NO_TEXTURING
Definition: model.h:868
void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, char *_bitmapSliderControl, void(*_upCallback)(), void(*_downCallback)(), void(*_captureCallback)())
Definition: slider2.cpp:21
int flags
Definition: ship.h:1227
void g3_set_view_matrix(const vec3d *view_pos, const matrix *view_matrix, float zoom)
Definition: 3dsetup.cpp:152
void model_clear_instance(int model_num)
Definition: modelread.cpp:4624
void techroom_render_desc(int xo, int yo, int ho)
Definition: techmenu.cpp:364
int pressed()
Definition: button.cpp:325
#define PREV_ENTRY_BUTTON
Definition: techmenu.cpp:61
Switching to a new screen, but not commit.
Definition: gamesnd.h:292
#define KEY_SHIFTED
Definition: key.h:62
void stuff_string(char *outstr, int type, int len, char *terminators)
Definition: parselo.cpp:1189
float Max_draw_distance
Definition: 2d.cpp:85
void generic_anim_render(generic_anim *ga, float frametime, int x, int y, bool menu)
Definition: generic.cpp:437
#define w(p)
Definition: modelsinc.h:68
#define CF_TYPE_TABLES
Definition: cfile.h:50
void set_team_color(team_color &clr)
int Intel_info_size
Definition: techmenu.cpp:247
#define SHIP_W_COORD
Definition: techmenu.cpp:75
SCP_string default_team_name
Definition: ship.h:1366
int Cmdline_nohtl
Definition: cmdline.cpp:438
GLdouble GLdouble z
Definition: Glext.h:5451
#define KEY_ENTER
Definition: key.h:125
void tech_next_entry()
Definition: techmenu.cpp:638
int n_subsystems
Definition: ship.h:1270
#define SUBSYSTEM_TURRET
Definition: model.h:54
int required_string(const char *pstr)
Definition: parselo.cpp:468
queued_animation * triggers
Definition: model.h:225
#define SHIP_X_COORD
Definition: techmenu.cpp:73
Definition: bmpman.h:101
Definition: ui.h:428
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char)
Definition: parselo.cpp:3412
int optional_string(const char *pstr)
Definition: parselo.cpp:539
#define CUTSCENES_TAB
Definition: techmenu.cpp:53
vec3d closeup_pos
Definition: ship.h:1327
#define SIF2_DEFAULT_IN_TECH_DATABASE_M
Definition: ship.h:919
char tech_title[NAME_LENGTH]
Definition: weapon.h:337
int flags2
Definition: ship.h:1228
char * Tech_slider_filename[GR_NUM_RESOLUTIONS]
Definition: techmenu.cpp:88
void tech_scroll_list_down()
Definition: techmenu.cpp:698
int model_load(char *filename, int n_subsystems, model_subsystem *subsystems, int ferror=1, int duplicate=0)
Definition: modelread.cpp:2573
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
Definition: parselo.cpp:1995
#define B1_RELEASED
Definition: uidefs.h:48
int has_anim
Definition: techmenu.cpp:228
void fsspeech_play(int type, const char *text)
Definition: fsspeech.h:44
void model_page_in_textures(int modelnum, int ship_info_index=-1)
int Tech_list_coords[GR_NUM_RESOLUTIONS][4]
Definition: techmenu.cpp:93
int idx
Definition: multiui.cpp:761
generic_anim animation
Definition: techmenu.cpp:226
GLdouble GLdouble t
Definition: Glext.h:5329
#define HELP_BUTTON
Definition: techmenu.cpp:64
#define SIF_IN_TECH_DATABASE
Definition: ship.h:897
int n_triggers
Definition: model.h:224
void mouse_get_delta(int *dx, int *dy, int *dz)
Definition: mouse.cpp:358
#define INTEL_DATA_TAB
Definition: techmenu.cpp:50
int get_numberItems()
Definition: slider2.cpp:202
int Cmdline_shadow_quality
Definition: cmdline.cpp:344
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
int textures_loaded
Definition: techmenu.cpp:230
bool Glowpoint_use_depth_buffer
Definition: systemvars.cpp:76
int wi_flags
Definition: weapon.h:384
const char * XSTR(const char *str, int index)
Definition: localize.cpp:851
user_click (mouse selects a control)
Definition: gamesnd.h:305
void force_currentItem(int _currentItem)
Definition: slider2.cpp:279
char * desc
Definition: techmenu.cpp:224
void vm_trackball(int idx, int idy, matrix *RotMat)
Definition: vecmat.cpp:1151
int inited
Definition: fredrender.cpp:76
#define KEY_F1
Definition: key.h:143
void model_page_out_textures(int model_num, bool release=false)
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
#define IIF_IN_TECH_DATABASE
Definition: techmenu.h:29
void tech_scroll_info_down()
Definition: techmenu.cpp:672
GLbitfield flags
Definition: Glext.h:6722
int Num_weapon_types
Definition: weapons.cpp:105
void set_hotkey(int keycode)
Definition: gadget.cpp:280
#define SIF_HUGE_SHIP
Definition: ship.h:945
void reset_parse(char *text)
Definition: parselo.cpp:3305
int flags
Definition: techmenu.h:24
GLuint const GLchar * name
Definition: Glext.h:5608
#define IDENTITY_MATRIX
Definition: vecmat.h:64
char * name
Definition: techmenu.cpp:223
void techroom_close()
Definition: techmenu.cpp:1250
color Color_black
Definition: alphacolors.cpp:32
#define REVOLUTION_RATE
Definition: techmenu.cpp:37
vec3d Eye_position
Definition: 3dsetup.cpp:27
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
Definition: bmpman.cpp:1119
color Color_text_subselected
Definition: alphacolors.cpp:26
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
void stuff_int(int *i)
Definition: parselo.cpp:2372
void lcl_translate_ship_name_gr(char *name)
Definition: localize.cpp:1388
#define CREDITS_TAB
Definition: techmenu.cpp:54
void update_dimensions(int _x, int _y, int _w, int _h)
Definition: gadget.cpp:187
intel_data Intel_info[MAX_INTEL_ENTRIES]
Definition: techmenu.cpp:246
color Color_text_selected
Definition: alphacolors.cpp:26
#define NEXT_ENTRY_BUTTON
Definition: techmenu.cpp:62
GLuint GLuint num
Definition: Glext.h:9089
#define WIF_PLAYER_ALLOWED
Definition: weapon.h:68
void model_free_all()
Definition: modelread.cpp:337
scroll pressed (and scroll)
Definition: gamesnd.h:296
void light_set_all_relevent()
Definition: lighting.cpp:644
void link_hotspot(int num)
Definition: gadget.cpp:50
#define strcat_s(...)
Definition: safe_strings.h:68
void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus=0)
Definition: button.cpp:26
#define KEY_ESC
Definition: key.h:124
#define NAME_LENGTH
Definition: globals.h:15
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
#define TECH_DATABASE_TAB
Definition: techmenu.cpp:51
float rad
Definition: model.h:757
#define UI_XSTR_COLOR_PINK
Definition: ui.h:161
int button_down()
Definition: button.cpp:363
#define SIMULATOR_TAB
Definition: techmenu.cpp:52
int Tech_desc_coords[GR_NUM_RESOLUTIONS][4]
Definition: techmenu.cpp:111
void create(int _x, int _y, int _w, int _h, int _flags, int _f_id=-1)
Definition: window.cpp:140
player * Player
int gr_force_fit_string(char *str, int max_str, int max_width)
Definition: font.cpp:48
#define IIF_DEFAULT_IN_TECH_DATABASE
Definition: techmenu.h:30
#define g3_end_frame()
Definition: 3d.h:49
#define SCROLL_INFO_UP
Definition: techmenu.cpp:58
Definition: ui.h:584
screen gr_screen
Definition: 2d.cpp:46
float Min_draw_distance
Definition: 2d.cpp:84
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
Definition: font.cpp:196
techroom_buttons(char *name, int x1, int y1, int xt1, int yt1, int h, int t, int f=0)
Definition: techmenu.cpp:149
void enable(int n=1)
Definition: gadget.cpp:440
int techroom_button_pressed(int num)
Definition: techmenu.cpp:950
int gr_get_font_height()
Definition: font.cpp:187
void light_reset()
Definition: lighting.cpp:150
#define KEY_DEBUGGED
Definition: key.h:65
GLfloat GLfloat p
Definition: Glext.h:8373
#define F_NAME
Definition: parselo.h:34
GLenum src
Definition: Glext.h:5917
SCP_vector< ship_info > Ship_info
Definition: ship.cpp:164
#define LOCATION
Definition: pstypes.h:245
void common_play_highlight_sound()
Definition: gamesnd.cpp:1151
#define OPTIONS_BUTTON
Definition: techmenu.cpp:65
BM_TYPE bm_get_type(int handle)
Returns the image type of the given bitmap handle.
Definition: bmpman.cpp:894
#define KEY_CTRLED
Definition: key.h:64
#define KEY_TAB
Definition: key.h:127
int Techroom_overlay_id
Definition: techmenu.cpp:218
void gr_bitmap(int _x, int _y, int resize_mode)
Definition: 2d.cpp:1303
int techroom_load_ani(anim **animpp, char *name)
Definition: techmenu.cpp:1024
#define KEY_UP
Definition: key.h:179
#define UI_XSTR_COLOR_GREEN
Definition: ui.h:160
GLenum GLsizei len
Definition: Glext.h:6283
color Color_text_normal
Definition: alphacolors.cpp:26
int Tech_ani_centre_coords[GR_NUM_RESOLUTIONS][2]
Definition: techmenu.cpp:120
int generic_anim_init_and_stream(generic_anim *ga, const char *anim_filename, BM_TYPE bg_type, bool attempt_hi_res)
Definition: generic.cpp:32
int temp
Definition: lua.cpp:4996
int bitmap
Definition: techmenu.cpp:227
polymodel * pm
Definition: lua.cpp:1598
float closeup_zoom
Definition: ship.h:1328
#define PLAYER_FLAGS_IS_MULTI
Definition: player.h:42
void techroom_init_desc(char *src, int w)
Definition: techmenu.cpp:262
void model_set_instance_techroom(int model_num, int sub_model_num, float angle_1, float angle_2)
Definition: modelread.cpp:4772
#define IIF_DEFAULT_VALUE
Definition: techmenu.h:28
void launch_context_help()
void gamesnd_play_iface(int n)
Definition: gamesnd.cpp:260
void disable()
Definition: gadget.cpp:432
void draw()
Definition: window.cpp:220
float h
Definition: pstypes.h:111
int model_num
Definition: lua.cpp:4996
#define SHIP_Y_COORD
Definition: techmenu.cpp:74
#define KEY_S
Definition: key.h:100
vec3d vmd_zero_vector
Definition: vecmat.cpp:24
#define NUM_BUTTONS
Definition: techmenu.cpp:39
int process(int key_in=-1, int process_mouse=1)
Definition: window.cpp:401
int help_overlay_get_index(const char *overlay_name)
#define MAX_INTEL_ENTRIES
Definition: techmenu.h:17
char * Tech_background_filename[GR_NUM_RESOLUTIONS]
Definition: techmenu.cpp:80
void gameseq_post_event(int event)
GLenum GLint GLuint mask
Definition: Glext.h:5605
#define F_MULTITEXT
Definition: parselo.h:43
#define stricmp(s1, s2)
Definition: config.h:271
matrix vmd_identity_matrix
Definition: vecmat.cpp:28
void help_overlay_maybe_blit(int overlay_id, int resolution_index)
int help_overlay_active(int overlay_id)
#define GR_1024
Definition: 2d.h:653
void techroom_init()
Definition: techmenu.cpp:1102
void techroom_do_frame(float frametime)
Definition: techmenu.cpp:1269
void light_rotate_all()
Definition: lighting.cpp:585
int Lcl_gr
Definition: localize.cpp:48
float b
Definition: pstypes.h:111
GLint y
Definition: Gl.h:1505
int Tech_slider_coords[GR_NUM_RESOLUTIONS][4]
Definition: techmenu.cpp:129
#define g3_start_frame(zbuffer_flag)
Definition: 3d.h:39
#define strcpy_s(...)
Definition: safe_strings.h:67
void techroom_change_tab(int num)
Definition: techmenu.cpp:746
#define MR_AUTOCENTER
Definition: model.h:875