/* * Copyright (C) Volition, Inc. 1999. All rights reserved. * * All source code herein is the property of Volition, Inc. You may not sell * or otherwise commercially exploit the source or things you created based on the * source. * */ /* * $Logfile: /Freespace2/code/GameHelp/ContextHelp.cpp $ * $Revision: 2.13 $ * $Date: 2006-12-28 00:59:26 $ * $Author: wmcoolmon $ * * Functions to drive the context-sensitive help * * $Log: not supported by cvs2svn $ * Revision 2.12 2006/09/11 06:49:39 taylor * fixes for stuff_string() bounds checking * * Revision 2.11 2005/07/18 03:44:00 taylor * cleanup hudtargetbox rendering from that total hack job that had been done on it (fixes wireframe view as well) * more non-standard res fixing * - I think everything should default to resize now (much easier than having to figure that crap out) * - new mouse_get_pos_unscaled() function to return 1024x768/640x480 relative values so we don't have to do it later * - lots of little cleanups which fix several strange offset/size problems * - fix gr_resize/unsize_screen_pos() so that it won't wrap on int (took too long to track this down) * * Revision 2.10 2005/05/12 17:49:11 taylor * use vm_malloc(), vm_free(), vm_realloc(), vm_strdup() rather than system named macros * fixes various problems and is past time to make the switch * * Revision 2.9 2005/04/24 02:39:36 wmcoolmon * Context help fixing goodness * * Revision 2.8 2005/04/05 05:53:16 taylor * s/vector/vec3d/g, better support for different compilers (Jens Granseuer) * * Revision 2.7 2005/01/29 08:05:31 wmcoolmon * Update to work with optimized shader func * * Revision 2.6 2004/07/26 20:47:30 Kazan * remove MCD complete * * Revision 2.5 2004/07/12 16:32:47 Kazan * MCD - define _MCD_CHECK to use memory tracking * * Revision 2.4 2004/03/08 22:02:38 Kazan * Lobby GUI screen restored * * Revision 2.3 2004/03/05 09:01:58 Goober5000 * Uber pass at reducing #includes * --Goober5000 * * Revision 2.2 2004/02/20 04:29:54 bobboau * pluged memory leaks, * 3D HTL lasers (they work perfictly) * and posably fixed Turnsky's shinemap bug * * Revision 2.1 2002/08/01 01:41:04 penguin * The big include file move * * Revision 2.0 2002/06/03 04:02:22 penguin * Warpcore CVS sync * * Revision 1.2 2002/05/03 22:07:08 mharris * got some stuff to compile * * Revision 1.1 2002/05/02 18:03:07 mharris * Initial checkin - converted filenames and includes to lower case * * * 16 8/22/99 4:22p Jefff * removed 2nd tech room overlay stuff * * 15 8/09/99 5:54p Jefff * tech room overlay changes * * 14 7/27/99 7:18p Jefff * fixed a debug function for adjsuting overlays in-game * * 13 7/20/99 1:49p Dave * Peter Drake build. Fixed some release build warnings. * * 12 7/16/99 10:07a Jefff * Removed legacy bitmap overlay code * * 11 7/16/99 10:04a Jefff * * 10 7/15/99 9:20a Andsager * FS2_DEMO initial checkin * * 9 7/11/99 6:40p Jefff * * 8 7/08/99 6:25p Jefff * got new help system working * * 7 6/03/99 10:15p Dave * Put in temporary main hall screen. * * 6 3/25/99 8:32p Neilk * temporary barracks help removal * * 5 2/15/99 9:37a Dave * Removed infinite loop from context help parse code. * * 4 2/11/99 4:05p Neilk * Temporary checkin * * 3 1/29/99 2:37p Neilk * foundation for a new help system * * 2 10/07/98 10:52a Dave * Initial checkin. * * 1 10/07/98 10:48a Dave * * 92 5/06/98 11:49p Lawrance * Add help overlay for command brief * * 91 5/05/98 1:49a Lawrance * Add in missing help overlays * * 90 4/25/98 2:00p Dave * Installed a bunch of multiplayer context help screens. Reworked ingame * join ship select screen. Fix places where network timestamps get hosed. * * 89 4/20/98 12:03a Lawrance * make gray help shader lighter * * 88 4/11/98 7:59p Lawrance * Add support for help overlays * * 87 3/12/98 5:36p John * Took out any unused shaders. Made shader code take rgbc instead of * matrix and vector since noone used it like a matrix and it would have * been impossible to do in hardware. Made Glide implement a basic * shader for online help. * * 86 3/09/98 9:55p Lawrance * split off gameplay help, rip out obsolete code * * 85 3/05/98 11:15p Hoffoss * Changed non-game key checking to use game_check_key() instead of * game_poll(). * * 84 2/28/98 9:47p Lawrance * Fix couple of typos * * 83 2/28/98 7:02p Lawrance * overhaul on-line help * */ #include #include #include "gamehelp/contexthelp.h" #include "gamesequence/gamesequence.h" #include "menuui/mainhallmenu.h" #include "graphics/2d.h" #include "parse/parselo.h" #include "localization/localize.h" #include "globalincs/alphacolors.h" #include "globalincs/systemvars.h" //////////////////////////////////////////////////////////////////// // private function prototypes / structs //////////////////////////////////////////////////////////////////// void parse_helptbl(); void help_overlay_blit(int overlay_id); void help_overlay_init(); typedef struct { int x_begin, y_begin, x_end, y_end; } help_line; typedef struct { vec3d vtx[HELP_MAX_PLINE_VERTICES]; vec3d *pvtx[HELP_MAX_PLINE_VERTICES]; int vtxcount; } help_pline; typedef struct { int x_coord, y_coord; char* string; } help_text; typedef struct { int x_coord, y_coord; } help_left_bracket; typedef struct { int x_coord, y_coord; } help_right_bracket; typedef struct { help_pline plinelist[GR_NUM_RESOLUTIONS][HELP_MAX_ITEM]; help_text textlist[GR_NUM_RESOLUTIONS][HELP_MAX_ITEM]; help_left_bracket lbracketlist[GR_NUM_RESOLUTIONS][HELP_MAX_ITEM]; help_right_bracket rbracketlist[GR_NUM_RESOLUTIONS][HELP_MAX_ITEM]; int plinecount; int textcount; int lbracketcount; int rbracketcount; } help_overlay; // new help.tbl file way char *help_overlay_section_names[MAX_HELP_OVERLAYS] = { "$ship", // ship_help "$weapon", // weapon_help "$briefing", // briefing "$main", // main help overlay "$barracks", // barracks "$control", // control help "$debrief", // debrief help "$multicreate", // multicreate help "$multistart", // multistart help "$multijoin", // multijoin help "$main2", // main help overlay2 "$hotkey", // hotkey help "$campaign", // campaign help "$simulator", // simulator help "$tech", // tech help "$command" // command help }; //////////////////////////////////////////////////////////////////// // Game-wide globals //////////////////////////////////////////////////////////////////// shader Grey_shader; //////////////////////////////////////////////////////////////////// // Module globals //////////////////////////////////////////////////////////////////// static int help_left_bracket_bitmap = -1; static int help_right_bracket_bitmap = -1; static help_overlay help_overlaylist[MAX_HELP_OVERLAYS]; static int current_helpid = -1; // the currently active overlay_id, only really used for the debug console funxions int Help_overlay_flags; static int Source_game_state; // state from where F1 was pressed //////////////////////////////////////////////////////////////////// // Public Functions //////////////////////////////////////////////////////////////////// // query whether a help overlay is active (ie being displayed) int help_overlay_active(int overlay_id) { Assert(overlay_id >= 0 && overlay_id < MAX_HELP_OVERLAYS); return Help_overlay_flags & (1<= 0 && overlay_id < MAX_HELP_OVERLAYS); if ( state > 0 ) { Help_overlay_flags |= (1<= 0 && overlay_id < MAX_HELP_OVERLAYS); if ( Help_overlay_flags & (1< There is no context help available for state %s\n", GS_state_text[Source_game_state-1])); break; } // end switch } void close_help(){ for (int overlay_id=0; overlay_id= 0 && overlay_id < MAX_HELP_OVERLAYS); // this draws each line of help text with white on black text (use the GR_640 index for the string) for (idx = 0; idx < textcount; idx++) { gr_set_color_fast(&Color_black); gr_get_string_size(&width, &height, help_overlaylist[overlay_id].textlist[GR_640][idx].string, strlen(help_overlaylist[overlay_id].textlist[GR_640][idx].string)); gr_rect(help_overlaylist[overlay_id].textlist[gr_screen.res][idx].x_coord-2*HELP_PADDING, help_overlaylist[overlay_id].textlist[gr_screen.res][idx].y_coord-3*HELP_PADDING, width+4*HELP_PADDING, height+4*HELP_PADDING); gr_set_color_fast(&Color_bright_white); gr_printf(help_overlaylist[overlay_id].textlist[gr_screen.res][idx].x_coord, help_overlaylist[overlay_id].textlist[gr_screen.res][idx].y_coord, help_overlaylist[overlay_id].textlist[GR_640][idx].string); } // this draws each right bracket if(help_right_bracket_bitmap > 0) { for (idx = 0; idx < rbracketcount; idx++) { gr_set_bitmap(help_right_bracket_bitmap); gr_bitmap(help_overlaylist[overlay_id].rbracketlist[gr_screen.res][idx].x_coord, help_overlaylist[overlay_id].rbracketlist[gr_screen.res][idx].y_coord); } } if(help_left_bracket_bitmap > 0) { // this draws each left bracket for (idx = 0; idx < lbracketcount; idx++) { gr_set_bitmap(help_left_bracket_bitmap); gr_bitmap(help_overlaylist[overlay_id].lbracketlist[gr_screen.res][idx].x_coord, help_overlaylist[overlay_id].lbracketlist[gr_screen.res][idx].y_coord); } } // this draws each 2d line for the help screen //gr_set_color_fast(&Color_yellow); gr_set_color(255, 255, 0); for (idx = 0; idx