]> icculus.org git repositories - taylor/freespace2.git/blob - src/gamehelp/gameplayhelp.cpp
Freespace 1 support
[taylor/freespace2.git] / src / gamehelp / gameplayhelp.cpp
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
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/GameHelp/GameplayHelp.cpp $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Module for displaying in-game help
16  *
17  * $Log$
18  * Revision 1.4  2003/05/25 02:30:42  taylor
19  * Freespace 1 support
20  *
21  * Revision 1.3  2002/06/09 04:41:17  relnev
22  * added copyright header
23  *
24  * Revision 1.2  2002/05/07 03:16:44  theoddone33
25  * The Great Newline Fix
26  *
27  * Revision 1.1.1.1  2002/05/03 03:28:09  root
28  * Initial import.
29  *
30  * 
31  * 8     9/08/99 2:38p Jefff
32  * sound pausing going to menu from game
33  * 
34  * 7     9/01/99 2:56p Jefff
35  * a few control key description changes
36  * 
37  * 6     7/29/99 4:43p Jefff
38  * updated for fs2 -- fixed buttons, added "press esc" text, hi-res
39  * support, the works.
40  * 
41  * 5     7/15/99 9:20a Andsager
42  * FS2_DEMO initial checkin
43  * 
44  * 4     1/30/99 5:08p Dave
45  * More new hi-res stuff.Support for nice D3D textures.
46  * 
47  * 3     10/13/98 9:28a Dave
48  * Started neatening up freespace.h. Many variables renamed and
49  * reorganized. Added AlphaColors.[h,cpp]
50  * 
51  * 2     10/07/98 10:52a Dave
52  * Initial checkin.
53  * 
54  * 1     10/07/98 10:48a Dave
55  * 
56  * 21    6/17/98 11:01a Lawrance
57  * ensure translated descriptions appear in the online help
58  * 
59  * 20    6/09/98 10:31a Hoffoss
60  * Created index numbers for all xstr() references.  Any new xstr() stuff
61  * added from here on out should be added to the end if the list.  The
62  * current list count can be found in FreeSpace.cpp (search for
63  * XSTR_SIZE).
64  * 
65  * 19    5/17/98 3:33p Lawrance
66  * Add 'target last ship to send transmission' key to online help
67  * 
68  * 18    5/15/98 8:36p Lawrance
69  * Add 'target ship that last sent transmission' target key
70  * 
71  * 17    5/09/98 4:52p Lawrance
72  * Implement padlock view (up/rear/left/right)
73  * 
74  * 16    4/27/98 10:11a Lawrance
75  * Add in disabled beep for missing buttons
76  * 
77  * 15    4/25/98 1:25p Lawrance
78  * Change screen shot key to Print Scrn
79  * 
80  * 14    4/22/98 2:50p John
81  * Made PrintScreen actually be Shift+PrintScreen.
82  * 
83  * 13    4/18/98 9:21p Lawrance
84  * show correct key binding for screen shots
85  * 
86  * 12    4/11/98 7:59p Lawrance
87  * Allow space, tab and enter to cycle through pages
88  * 
89  * 11    4/05/98 7:44p Lawrance
90  * remove obsolete 'show goals' binding
91  * 
92  * 10    4/02/98 11:40a Lawrance
93  * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
94  * 
95  * 9     4/01/98 2:22p Lawrance
96  * remove hotkey references in on-line help for demo builds
97  * 
98  * 8     3/31/98 4:57p Lawrance
99  * update text for taking a screen shot
100  * 
101  * 7     3/30/98 1:31p Lawrance
102  * Take out debug key help
103  * 
104  * 6     3/25/98 5:34p Dave
105  * First rev of multiplayer online key help.
106  * 
107  * 5     3/25/98 2:16p Dave
108  * Select random default image for newly created pilots. Fixed several
109  * multi-pause messaging bugs. Begin work on online help for multiplayer
110  * keys.
111  * 
112  * 4     3/18/98 12:03p John
113  * Marked all the new strings as externalized or not.
114  * 
115  * 3     3/16/98 5:53p Lawrance
116  * Fix bug that was causing joystick only bindings to mess up
117  * 
118  * 2     3/09/98 9:54p Lawrance
119  * integrate new art for gameplay help
120  * 
121  * 1     3/09/98 5:05p Lawrance
122  *
123  * $NoKeywords: $
124  */
125
126 #include "contexthelp.h"
127 #include "gamesequence.h"
128 #include "freespace.h"
129 #include "key.h"
130 #include "bmpman.h"
131 #include "2d.h"
132 #include "timer.h"
133 #include "math.h"
134 #include "mouse.h"
135 #include "controlsconfig.h"
136 #include "ui.h"
137 #include "gamesnd.h"
138 #include "missionscreencommon.h"
139 #include "alphacolors.h"
140 #include "beam.h"
141 #include "audiostr.h"
142
143 // text positioning constats
144 #define TITLE_Y                 35
145 #define Y_START                 70
146 #define X_OFFSET_1              70
147
148 // pixel offset for description of key from where key binding starts
149 #define KEY_DESCRIPTION_OFFSET  193     
150
151 // different gameplay help pages
152 #define GP_FIRST_SCREEN                                                                 0               // keep up to date
153
154 #define GP_HELP_BASIC_KEYS                                                              0
155 #define GP_HELP_MOVEMENT_KEYS                                                   1
156 #define GP_HELP_COMMON_TARGET_KEYS                                      2
157 #define GP_HELP_ADVANCED_TARGET_KEYS                            3
158 #define GP_HELP_MESSAGING                                                               4
159 #define GP_HELP_WEAPON_KEYS                                                     5
160 #define GP_HELP_THROTTLE_AND_ETS_KEYS                           6
161 #define GP_HELP_VIEW_KEYS                                                               7
162 #define GP_HELP_MISC_KEYS                                                               8
163 #define GP_HELP_MULTI_KEYS                                                              9
164
165 #define GP_LAST_SCREEN_SINGLE                                                   8               // keep up to date
166 #define GP_LAST_SCREEN_MULTI                                                    9               // keep up to date
167
168 // set this to GP_LAST_SCREEN_SINGLE or GP_LAST_SCREEN_MULTI based upon what game mode we're in
169 int Gp_last_screen;
170
171 #define NUM_BUTTONS                                             3
172 #define PREVIOUS_PAGE_BUTTON                    0
173 #define NEXT_PAGE_BUTTON                                1
174 #define CONTINUE_BUTTON                                 2
175
176 struct gameplay_help_buttons {
177         char *filename;
178         int x, y;
179         int hotspot;
180         int tab;
181         int flags;
182         UI_BUTTON button;  // because we have a class inside this struct, we need the constructor below..
183
184         gameplay_help_buttons(char *name, int x1, int y1, int h) : filename(name), x(x1), y(y1), hotspot(h) {}
185 };
186
187 static gameplay_help_buttons Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS] = {
188 //XSTR:OFF
189         {
190 #ifdef MAKE_FS1
191                 gameplay_help_buttons("F1B_00", 71,             373,    0),             // previous
192                 gameplay_help_buttons("F1B_01", 121,    373,    1),             // next
193 //              gameplay_help_buttons("F1B_02", 447,    452,    2),             // options
194                 gameplay_help_buttons("F1B_03", 554,    411,    3),             // continue
195 #else
196                 gameplay_help_buttons("F1B_00", 15,     389,    0),
197                 gameplay_help_buttons("F1B_01", 60,     389,    1),
198                 gameplay_help_buttons("F1B_02", 574,    431,    2)
199 #endif
200         },
201         {
202                 gameplay_help_buttons("2_F1B_00",       24,     622,    0),
203                 gameplay_help_buttons("2_F1B_01",       96,     622,    1),
204                 gameplay_help_buttons("2_F1B_02",       919,    689,    2)
205         },
206 //XSTR:ON
207 };
208
209 #ifdef MAKE_FS1
210         #define GAME_HELP_NUM_TEXT              0
211 #else
212         #define GAME_HELP_NUM_TEXT              2
213 #endif
214 static UI_XSTR Game_help_text[GR_NUM_RESOLUTIONS][GAME_HELP_NUM_TEXT] = {
215         { // GR_640
216                 // not needed for FS1
217 #ifndef MAKE_FS1
218                 { "Press ESC to return to the game",    1441,   263,    389,    UI_XSTR_COLOR_GREEN, -1, NULL },
219                 { "Continue",           1069,           571,    413,    UI_XSTR_COLOR_GREEN, -1, &Buttons[gr_screen.res][CONTINUE_BUTTON].button }
220 #endif
221         }, 
222         { // GR_1024
223                 // not needed for FS1
224 #ifndef MAKE_FS1
225                 { "Press ESC to return to the game",    1441,   421,    622,    UI_XSTR_COLOR_GREEN, -1, NULL },
226                 { "Continue",           1069,           928,    663,    UI_XSTR_COLOR_GREEN, -1, &Buttons[gr_screen.res][CONTINUE_BUTTON].button }
227 #endif
228         }
229 };
230
231 static char *Game_help_filename[GR_NUM_RESOLUTIONS] = {
232         "F1",
233         "2_F1"
234 };
235
236 static char *Game_help_mask_filename[GR_NUM_RESOLUTIONS] = {
237         "F1-m",
238         "2_F1-m"
239 };
240
241 static UI_WINDOW Ui_window;
242 static int Background_bitmap;
243 static int Gameplay_help_inited = 0;
244
245 static int Current_help_page;
246
247 // generate a line for the on-line help for a control item with specified id
248 // input:       id              =>      index for control item within Control_config[]
249 //                              buf     => buffer with enough space to hold ouput string
250 char *gameplay_help_control_text(int id, char *buf)
251 {
252         int                     has_key=0, has_joy=0;
253         config_item     *ci;
254
255         ci = &Control_config[id];
256
257         if ( ci->key_id >= 0 ) {
258                 sprintf(buf, textify_scancode(ci->key_id));
259                 has_key=1;
260         }
261
262         if ( ci->joy_id >= 0 ) {
263                 if ( has_key ) {
264                         strcat(buf, XSTR( ", ", 129));
265                 }
266                 strcat(buf, Joy_button_text[ci->joy_id]);
267                 has_joy=1;
268         }
269
270         if ( !has_key && !has_joy ) {
271                 strcpy(buf, XSTR( "no binding", 130));
272         }
273
274         strcat(buf, XSTR( " - ", 131));
275         strcat(buf, ci->text);
276
277         return buf;
278 }
279
280 void gameplay_help_blit_control_line(int x, int y, int id)
281 {
282         int                     has_key=0, has_joy=0;
283         char                    buf[256];
284         config_item     *ci;
285
286         ci = &Control_config[id];
287
288         buf[0] = 0;
289
290         if ( ci->key_id >= 0 ) {
291                 sprintf(buf, textify_scancode(ci->key_id));
292                 has_key=1;
293         }
294
295         if ( ci->joy_id >= 0 ) {
296                 if ( has_key ) {
297                         strcat(buf, XSTR( ", ", 129));
298                 }
299                 strcat(buf, Joy_button_text[ci->joy_id]);
300                 has_joy=1;
301         }
302
303         if ( !has_key && !has_joy ) {
304                 strcpy(buf, XSTR( "no binding", 130));
305         }
306
307         gr_string(x,y,buf);
308
309 //      gr_string(x+KEY_DESCRIPTION_OFFSET,y,ci->text);
310         gr_string(x+KEY_DESCRIPTION_OFFSET, y, XSTR(ci->text, CONTROL_CONFIG_XSTR + id));
311 }
312
313 void gameplay_help_blit_control_line_raw(int x, int y, char *control_text, char *control_description)
314 {
315         gr_string(x,y,control_text);
316         gr_string(x+KEY_DESCRIPTION_OFFSET,y,control_description);
317 }
318
319 // game_play_help_set_title() will display the title for the help screen and
320 // set the font for the rest of the screen
321 void gameplay_help_set_title(char *title)
322 {
323         int sy=TITLE_Y;
324         char buf[128];
325
326         gr_set_color_fast(&Color_bright);
327         gr_printf(0x8000,sy,title);
328         sprintf(buf, XSTR( "Page %d of %d", 132),  Current_help_page+1, Gp_last_screen+1);
329         gr_printf(0x8000,sy+gr_get_font_height()+2,buf);
330         gr_set_color_fast(&Color_normal);
331 }
332
333 // called once when the gameplay help state is entered
334 void gameplay_help_init()
335 {
336         int i;
337         gameplay_help_buttons *b;
338
339         if ( Gameplay_help_inited ) {
340                 return;
341         }
342
343         common_set_interface_palette("InterfacePalette");  // set the interface palette
344         Ui_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
345         Ui_window.set_mask_bmap(Game_help_mask_filename[gr_screen.res]);
346
347         for (i=0; i<NUM_BUTTONS; i++) {
348                 b = &Buttons[gr_screen.res][i];
349
350                 b->button.create(&Ui_window, "", b->x, b->y, 60, 30, 0, 1);
351                 // set up callback for when a mouse first goes over a button
352                 b->button.set_highlight_action(common_play_highlight_sound);
353                 b->button.set_bmaps(b->filename);
354                 b->button.link_hotspot(b->hotspot);
355         }
356
357         // add all xstrs
358         for (i=0; i<GAME_HELP_NUM_TEXT; i++)
359         {
360                 Ui_window.add_XSTR(&Game_help_text[gr_screen.res][i]);
361         }
362
363         // set the proper last screen # based upon game mode
364         if(Game_mode & GM_MULTIPLAYER){
365                 Gp_last_screen = GP_LAST_SCREEN_MULTI;
366         } else {
367                 Gp_last_screen = GP_LAST_SCREEN_SINGLE;
368         }
369
370         // setup hotkeys so lights flash when keys are pressed
371         Buttons[gr_screen.res][CONTINUE_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER);
372         Buttons[gr_screen.res][PREVIOUS_PAGE_BUTTON].button.set_hotkey(KEY_LEFT);
373         Buttons[gr_screen.res][NEXT_PAGE_BUTTON].button.set_hotkey(KEY_RIGHT);
374
375         Background_bitmap = bm_load(Game_help_filename[gr_screen.res]);
376
377         Current_help_page = GP_HELP_BASIC_KEYS;
378         Gameplay_help_inited = 1;
379 }
380
381 // called when moving to the previous help page
382 void gameplay_help_goto_prev_screen()
383 {
384         Current_help_page--;
385         if (Current_help_page < GP_FIRST_SCREEN) {
386                 Current_help_page = Gp_last_screen;
387         }
388         gamesnd_play_iface(SND_SWITCH_SCREENS);
389
390 }
391
392 // called when proceeding to the next help page
393 void gameplay_help_goto_next_screen()
394 {
395         Current_help_page++;
396         if (Current_help_page > Gp_last_screen) {
397                 Current_help_page = GP_FIRST_SCREEN;
398         }
399         gamesnd_play_iface(SND_SWITCH_SCREENS);
400 }
401
402 // called when the screen is exited
403 void gameplay_help_leave()
404 {
405         // unpause all game sounds
406         beam_unpause_sounds();
407         audiostream_unpause_all();
408
409         gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
410         game_flush();
411 }
412
413 // deal with a keypress on the gameplay help screen
414 void gameplay_help_process_key(int k)
415 {
416         switch ( k ) {
417                 case KEY_ESC:
418                         gameplay_help_leave();
419                         break;
420
421                 case KEY_ENTER:
422                 case KEY_SPACEBAR:
423                 case KEY_TAB:
424                         //gameplay_help_goto_next_screen();
425                         Buttons[gr_screen.res][NEXT_PAGE_BUTTON].button.press_button();
426                         break;
427
428                 case KEY_SHIFTED | KEY_TAB:
429                         Buttons[gr_screen.res][PREVIOUS_PAGE_BUTTON].button.press_button();
430 //                      gameplay_help_goto_prev_screen();
431                         break;
432
433                 default:
434                         break;
435
436         } // end switch
437 }
438
439 // deal with buttons being pressed on the gameplay help screen
440 void gameplay_help_button_pressed(int n)
441 {
442         switch (n) {
443
444         case PREVIOUS_PAGE_BUTTON:
445                 gameplay_help_goto_prev_screen();
446                 break;
447
448         case NEXT_PAGE_BUTTON:
449                 gameplay_help_goto_next_screen();
450                 break;
451
452         case CONTINUE_BUTTON:
453                 gameplay_help_leave();
454                 gamesnd_play_iface(SND_COMMIT_PRESSED);
455                 break;
456
457         default:
458                 Int3();
459                 break;
460         }
461 }
462
463 // Draw the help text onto the screen
464 void gameplay_help_draw_text()
465 {
466         int x_offset, y_offset, separation;
467
468         separation = gr_get_font_height() + 3;
469
470         switch ( Current_help_page ) {
471
472                 case GP_HELP_BASIC_KEYS:
473                         gameplay_help_set_title(XSTR( "Basic Keys", 133));
474                         x_offset=X_OFFSET_1;
475                         y_offset=Y_START;
476
477                         y_offset += separation;
478                         gameplay_help_blit_control_line(x_offset, y_offset,END_MISSION);
479
480                         y_offset += separation;
481                         gameplay_help_blit_control_line(x_offset, y_offset,FIRE_PRIMARY);
482
483                         y_offset += separation;
484                         gameplay_help_blit_control_line(x_offset, y_offset,MAX_THROTTLE);
485
486                         y_offset += separation;
487                         gameplay_help_blit_control_line(x_offset, y_offset,ZERO_THROTTLE);
488
489                         y_offset += separation;
490                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT);
491
492                         y_offset += separation;
493                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV);
494
495                         y_offset += separation;
496                         gameplay_help_blit_control_line(x_offset, y_offset,TOGGLE_AUTO_TARGETING);
497
498                         y_offset += separation;
499                         y_offset += separation;
500
501                         gr_set_color_fast(&Color_bright);
502                         gr_printf(0x8000,y_offset,XSTR( "Function Keys", 134));
503                         gr_set_color_fast(&Color_normal);
504
505                         y_offset += separation;
506                         y_offset += separation;
507
508                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F1", 135), XSTR( "context-sensitive help", 136));
509
510                         y_offset += separation;
511                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F2", 137), XSTR( "options screen (available anywhere in game)", 138));
512
513 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
514                         y_offset += separation;
515                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F3", 139), XSTR( "hotkey assignment", 140));
516 #endif
517
518                         y_offset += separation;
519                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F4", 141), XSTR( "HUD message scroll-back", 142));
520
521 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
522                         y_offset += separation;
523                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "F5...F12", 143), XSTR( "hotkeys", 144));
524 #endif
525
526                         y_offset += separation;
527                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "Shift-Esc", 145), XSTR( "quit FreeSpace 2 immediately", 146));
528
529                         break;
530
531                 case GP_HELP_MOVEMENT_KEYS:
532                         gameplay_help_set_title(XSTR( "Movement Keys", 147));
533                         x_offset=X_OFFSET_1;
534                         y_offset=Y_START;
535
536                         gameplay_help_blit_control_line(x_offset, y_offset,FORWARD_THRUST);
537
538                         y_offset += separation;
539                         gameplay_help_blit_control_line(x_offset, y_offset,MAX_THROTTLE);
540
541                         y_offset += separation;
542                         gameplay_help_blit_control_line(x_offset, y_offset,ONE_THIRD_THROTTLE);
543
544                         y_offset += separation;
545                         gameplay_help_blit_control_line(x_offset, y_offset,TWO_THIRDS_THROTTLE);
546
547                         y_offset += separation;
548                         gameplay_help_blit_control_line(x_offset, y_offset,MINUS_5_PERCENT_THROTTLE);
549
550                         y_offset += separation;
551                         gameplay_help_blit_control_line(x_offset, y_offset,PLUS_5_PERCENT_THROTTLE);
552
553                         y_offset += separation;
554                         gameplay_help_blit_control_line(x_offset, y_offset,ZERO_THROTTLE);
555
556                         y_offset += separation;
557                         gameplay_help_blit_control_line(x_offset, y_offset,AFTERBURNER);
558
559                         y_offset += separation;
560                         gameplay_help_blit_control_line(x_offset, y_offset,REVERSE_THRUST);
561
562                         y_offset += separation;
563                         gameplay_help_blit_control_line(x_offset, y_offset,PITCH_FORWARD);
564
565                         y_offset += separation;
566                         gameplay_help_blit_control_line(x_offset, y_offset,PITCH_BACK);
567
568                         y_offset += separation;
569                         gameplay_help_blit_control_line(x_offset, y_offset,YAW_LEFT);
570
571                         y_offset += separation;
572                         gameplay_help_blit_control_line(x_offset, y_offset,YAW_RIGHT);
573
574                         y_offset += separation;
575                         gameplay_help_blit_control_line(x_offset, y_offset,BANK_LEFT);
576
577                         y_offset += separation;
578                         gameplay_help_blit_control_line(x_offset, y_offset,BANK_RIGHT);
579
580                         y_offset += separation;
581                         gameplay_help_blit_control_line(x_offset, y_offset,BANK_WHEN_PRESSED);
582                         break;
583
584                 case GP_HELP_COMMON_TARGET_KEYS:
585                         gameplay_help_set_title(XSTR( "Basic Targeting Keys", 148));
586                         x_offset=X_OFFSET_1;
587                         y_offset=Y_START;
588
589                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT);
590
591                         y_offset += separation;
592                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV);
593
594                         y_offset += separation;
595                         gameplay_help_blit_control_line(x_offset, y_offset,TOGGLE_AUTO_TARGETING);
596
597                         y_offset += separation;
598                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_SHIP_IN_RETICLE);
599
600                         y_offset += separation;
601                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT_CLOSEST_HOSTILE);
602
603                         y_offset += separation;
604                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV_CLOSEST_HOSTILE);
605
606                         y_offset += separation;
607                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT_CLOSEST_FRIENDLY);
608
609                         y_offset += separation;
610                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV_CLOSEST_FRIENDLY);
611
612                         y_offset += separation;
613                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT_SUBOBJECT);
614
615                         y_offset += separation;
616                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV_SUBOBJECT);
617
618                         y_offset += separation;
619                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_SUBOBJECT_IN_RETICLE);
620
621                         y_offset += separation;
622                         gameplay_help_blit_control_line(x_offset, y_offset,MATCH_TARGET_SPEED);
623
624                         y_offset += separation;
625                         gameplay_help_blit_control_line(x_offset, y_offset,TOGGLE_AUTO_MATCH_TARGET_SPEED);
626                         break;
627
628                 case GP_HELP_ADVANCED_TARGET_KEYS:
629                         gameplay_help_set_title(XSTR( "Advanced Targeting Keys", 149));
630                         x_offset=X_OFFSET_1;
631                         y_offset=Y_START;
632
633                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_CLOSEST_SHIP_ATTACKING_SELF);
634
635                         y_offset += separation;
636                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_CLOSEST_SHIP_ATTACKING_TARGET);
637
638                         y_offset += separation;
639                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_LAST_TRANMISSION_SENDER);
640
641                         y_offset += separation;
642                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_TARGETS_TARGET);
643
644                         y_offset += separation;
645                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT_ESCORT_SHIP);
646
647                         y_offset += separation;
648                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_CLOSEST_REPAIR_SHIP);
649
650                         y_offset += separation;
651                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT_UNINSPECTED_CARGO);
652
653                         y_offset += separation;
654                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV_UNINSPECTED_CARGO);
655
656                         y_offset += separation;
657                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEWEST_SHIP);
658
659                         y_offset += separation;
660                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT_BOMB);
661
662                         y_offset += separation;
663                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV_BOMB);
664
665                         y_offset += separation;
666                         gameplay_help_blit_control_line(x_offset, y_offset,STOP_TARGETING_SHIP);
667
668                         y_offset += separation;
669                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_NEXT_LIVE_TURRET);
670
671                         y_offset += separation;
672                         gameplay_help_blit_control_line(x_offset, y_offset,TARGET_PREV_LIVE_TURRET);
673
674                         y_offset += separation;
675                         gameplay_help_blit_control_line(x_offset, y_offset,STOP_TARGETING_SUBSYSTEM);
676
677 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
678
679                         y_offset += separation;
680                         gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR( "F5...F12", 143), XSTR( "Select target assigned to that hotkey", 150));
681
682                         y_offset += separation;
683                         gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR( "Shift-F5...F12", 151), XSTR( "Add/remove target from that hotkey", 152));
684
685                         y_offset += separation;
686                         gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR( "Alt-Shift-F5...F12", 153), XSTR( "Clear that hotkey", 154));
687
688 #endif
689
690                         break;
691
692                 case GP_HELP_MESSAGING:
693                         gameplay_help_set_title(XSTR( "Messaging Keys", 155));
694                         x_offset=X_OFFSET_1;
695                         y_offset=Y_START;
696
697                         gameplay_help_blit_control_line(x_offset, y_offset,SQUADMSG_MENU);
698
699                         y_offset += separation;
700                         gameplay_help_blit_control_line(x_offset, y_offset,REARM_MESSAGE);
701
702                         y_offset += separation;
703                         gameplay_help_blit_control_line(x_offset, y_offset,ATTACK_MESSAGE);
704
705                         y_offset += separation;
706                         gameplay_help_blit_control_line(x_offset, y_offset,DISARM_MESSAGE);
707
708                         y_offset += separation;
709                         gameplay_help_blit_control_line(x_offset, y_offset,DISABLE_MESSAGE);
710
711                         y_offset += separation;
712                         gameplay_help_blit_control_line(x_offset, y_offset,CAPTURE_MESSAGE);
713
714                         y_offset += separation;
715                         gameplay_help_blit_control_line(x_offset, y_offset,ENGAGE_MESSAGE);
716
717                         y_offset += separation;
718                         gameplay_help_blit_control_line(x_offset, y_offset,FORM_MESSAGE);
719
720                         y_offset += separation;
721                         gameplay_help_blit_control_line(x_offset, y_offset,IGNORE_MESSAGE);
722
723                         y_offset += separation;
724                         gameplay_help_blit_control_line(x_offset, y_offset,PROTECT_MESSAGE);
725
726                         y_offset += separation;
727                         gameplay_help_blit_control_line(x_offset, y_offset,COVER_MESSAGE);
728
729                         y_offset += separation;
730                         gameplay_help_blit_control_line(x_offset, y_offset,WARP_MESSAGE);
731
732 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
733                         y_offset += separation;
734                         gameplay_help_blit_control_line_raw(x_offset, y_offset, XSTR( "F5...F12", 143), XSTR( "send specified order to these target(s)", 156));
735 #endif
736                         break;
737
738                 case GP_HELP_WEAPON_KEYS:
739                         gameplay_help_set_title(XSTR( "Weapon Keys", 157));
740                         x_offset=X_OFFSET_1;
741                         y_offset=Y_START;
742
743                         gameplay_help_blit_control_line(x_offset, y_offset,FIRE_PRIMARY);
744
745                         y_offset += separation;
746                         gameplay_help_blit_control_line(x_offset, y_offset,FIRE_SECONDARY);
747
748                         y_offset += separation;
749                         gameplay_help_blit_control_line(x_offset, y_offset,CYCLE_NEXT_PRIMARY);
750
751                         y_offset += separation;
752                         gameplay_help_blit_control_line(x_offset, y_offset,CYCLE_PREV_PRIMARY);
753
754                         y_offset += separation;
755                         gameplay_help_blit_control_line(x_offset, y_offset,CYCLE_SECONDARY);
756
757                         y_offset += separation;
758                         gameplay_help_blit_control_line(x_offset, y_offset,CYCLE_NUM_MISSLES);
759
760                         y_offset += separation;
761                         gameplay_help_blit_control_line(x_offset, y_offset,LAUNCH_COUNTERMEASURE);
762                         break;
763
764                 case GP_HELP_THROTTLE_AND_ETS_KEYS:
765                         gameplay_help_set_title(XSTR( "Energy Management Keys", 158));
766                         x_offset=X_OFFSET_1;
767                         y_offset=Y_START;
768
769                         gameplay_help_blit_control_line(x_offset, y_offset,SHIELD_EQUALIZE);
770
771                         y_offset += separation;
772                         gameplay_help_blit_control_line(x_offset, y_offset,SHIELD_XFER_TOP);
773
774                         y_offset += separation;
775                         gameplay_help_blit_control_line(x_offset, y_offset,SHIELD_XFER_BOTTOM);
776
777                         y_offset += separation;
778                         gameplay_help_blit_control_line(x_offset, y_offset,SHIELD_XFER_LEFT);
779
780                         y_offset += separation;
781                         gameplay_help_blit_control_line(x_offset, y_offset,SHIELD_XFER_RIGHT);
782
783                         y_offset += separation;
784                         gameplay_help_blit_control_line(x_offset, y_offset,INCREASE_WEAPON);
785
786                         y_offset += separation;
787                         gameplay_help_blit_control_line(x_offset, y_offset,DECREASE_WEAPON);
788
789                         y_offset += separation;
790                         gameplay_help_blit_control_line(x_offset, y_offset,INCREASE_SHIELD);
791
792                         y_offset += separation;
793                         gameplay_help_blit_control_line(x_offset, y_offset,DECREASE_SHIELD);
794
795                         y_offset += separation;
796                         gameplay_help_blit_control_line(x_offset, y_offset,INCREASE_ENGINE);
797
798                         y_offset += separation;
799                         gameplay_help_blit_control_line(x_offset, y_offset,DECREASE_ENGINE);
800
801                         y_offset += separation;
802                         gameplay_help_blit_control_line(x_offset, y_offset,ETS_EQUALIZE);
803 /*
804                         y_offset += separation;
805                         gameplay_help_blit_control_line(x_offset, y_offset,XFER_LASER);
806
807                         y_offset += separation;
808                         gameplay_help_blit_control_line(x_offset, y_offset,XFER_SHIELD);
809 */
810                         break;
811
812                 case GP_HELP_MISC_KEYS:
813                         gameplay_help_set_title(XSTR( "Miscellaneous Keys", 159));
814                         x_offset=X_OFFSET_1;
815                         y_offset=Y_START;
816
817                         // ending mission
818                         //
819                         y_offset += separation;
820                         gameplay_help_blit_control_line(x_offset, y_offset,END_MISSION);
821
822                         y_offset += separation;
823                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "ESC", 160), XSTR( "invoke abort mission popup", 161));
824
825                         // time compression
826                         //
827                         y_offset += separation;
828                         gameplay_help_blit_control_line(x_offset, y_offset,TIME_SPEED_UP);
829
830                         y_offset += separation;
831                         gameplay_help_blit_control_line(x_offset, y_offset,TIME_SLOW_DOWN);
832
833                         // radar keys
834                         //
835                         y_offset += separation;
836                         gameplay_help_blit_control_line(x_offset, y_offset,RADAR_RANGE_CYCLE);
837
838                         // escort view keys
839                         //
840                         y_offset += separation;
841                         gameplay_help_blit_control_line(x_offset, y_offset,ADD_REMOVE_ESCORT);
842
843                         y_offset += separation;
844                         gameplay_help_blit_control_line(x_offset, y_offset,ESCORT_CLEAR);
845
846                         // Pause, Print Screenshot
847                         y_offset += separation;
848                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "Pause", 162), XSTR( "pause game", 163));            
849
850                         y_offset += separation;
851                         gameplay_help_blit_control_line_raw(x_offset,y_offset, XSTR( "Print Scrn", 164), XSTR( "take screen shot", 165));            
852
853                         break;
854
855                 case GP_HELP_VIEW_KEYS:
856                         gameplay_help_set_title(XSTR( "View Keys", 166));
857                         x_offset=X_OFFSET_1;
858                         y_offset=Y_START;
859
860                         gameplay_help_blit_control_line(x_offset, y_offset,PADLOCK_UP);
861
862                         y_offset += separation;
863                         gameplay_help_blit_control_line(x_offset, y_offset,PADLOCK_DOWN);
864
865                         y_offset += separation;
866                         gameplay_help_blit_control_line(x_offset, y_offset,PADLOCK_LEFT);
867
868                         y_offset += separation;
869                         gameplay_help_blit_control_line(x_offset, y_offset,PADLOCK_RIGHT);
870
871                         y_offset += separation;
872                         gameplay_help_blit_control_line(x_offset, y_offset,VIEW_CHASE);
873
874                         y_offset += separation;
875                         gameplay_help_blit_control_line(x_offset, y_offset,VIEW_EXTERNAL);
876
877                         y_offset += separation;
878                         gameplay_help_blit_control_line(x_offset, y_offset,VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK);
879
880                         y_offset += separation;
881                         gameplay_help_blit_control_line(x_offset, y_offset,VIEW_SLEW);
882
883                         y_offset += separation;
884                         gameplay_help_blit_control_line(x_offset, y_offset,VIEW_DIST_INCREASE);
885
886                         y_offset += separation;
887                         gameplay_help_blit_control_line(x_offset, y_offset,VIEW_DIST_DECREASE);
888
889                         y_offset += separation;
890                         gameplay_help_blit_control_line(x_offset, y_offset,VIEW_CENTER);
891
892                         y_offset += separation;
893                         gameplay_help_blit_control_line(x_offset, y_offset,VIEW_OTHER_SHIP);
894                         break;
895
896                 case GP_HELP_MULTI_KEYS:
897                         gameplay_help_set_title(XSTR( "Multiplayer Keys", 167));
898                         x_offset=X_OFFSET_1;
899                         y_offset=Y_START;
900
901                         // ingame messaging
902                         gr_set_color_fast(&Color_bright);
903                         gr_printf(0x8000,y_offset,XSTR( "Ingame messaging keys (tap for text, hold for voice)", 168));
904                         gr_set_color_fast(&Color_normal);
905                         
906                         y_offset += separation;
907                         
908                         y_offset += separation;
909                         gameplay_help_blit_control_line(x_offset, y_offset,MULTI_MESSAGE_ALL);
910
911                         y_offset += separation;
912                         gameplay_help_blit_control_line(x_offset, y_offset,MULTI_MESSAGE_FRIENDLY);
913
914                         y_offset += separation;
915                         gameplay_help_blit_control_line(x_offset, y_offset,MULTI_MESSAGE_HOSTILE);
916
917                         y_offset += separation;
918                         gameplay_help_blit_control_line(x_offset, y_offset,MULTI_MESSAGE_TARGET);
919
920                         break;
921
922         } //    end switch              
923 }
924
925 // gameplay_help_do_frame() is the function that displays help when acutally playing the game
926 void gameplay_help_do_frame(float frametime)
927 {
928         int i, k;       
929
930         // ensure the gameplay help interface has been initialized
931         if (!Gameplay_help_inited) {
932                 Int3();
933                 return;
934         }
935
936         // make sure game sounds are paused
937         beam_pause_sounds();
938         audiostream_pause_all();
939
940         k = Ui_window.process() & ~KEY_DEBUGGED;
941         gameplay_help_process_key(k);
942
943         for (i=0; i<NUM_BUTTONS; i++){
944                 if (Buttons[gr_screen.res][i].button.pressed()){
945                         gameplay_help_button_pressed(i);
946                 }
947         }
948         
949         GR_MAYBE_CLEAR_RES(Background_bitmap);
950         if (Background_bitmap >= 0) {
951                 gr_set_bitmap(Background_bitmap);
952                 gr_bitmap(0, 0);
953         }
954
955         Ui_window.draw();
956
957         gameplay_help_draw_text();
958         gr_flip();
959 }
960
961
962 // called once when leaving the gameplay help state
963 void gameplay_help_close()
964 {
965         if ( Gameplay_help_inited ) {
966                 if (Background_bitmap >= 0) {
967                         bm_unload(Background_bitmap);
968                 }
969
970                 Ui_window.destroy();
971                 common_free_interface_palette();                // restore game palette
972                 game_flush();
973         }
974
975         Gameplay_help_inited = 0;
976 }
977