/* * 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. * */ #include #include #include "gamehelp/contexthelp.h" #include "gamesequence/gamesequence.h" #include "menuui/mainhallmenu.h" #include "missionui/missionbrief.h" #include "missionui/missionshipchoice.h" #include "missionui/missionweaponchoice.h" #include "menuui/barracks.h" #include "controlconfig/controlsconfig.h" #include "missionui/missiondebrief.h" #include "network/multiui.h" #include "mission/missionhotkey.h" #include "menuui/readyroom.h" #include "menuui/techmenu.h" #include "missionui/missioncmdbrief.h" #include "graphics/2d.h" #include "parse/parselo.h" #include "localization/localize.h" #include "globalincs/alphacolors.h" #include "globalincs/systemvars.h" #include "debugconsole/console.h" //////////////////////////////////////////////////////////////////// // private function prototypes / structs //////////////////////////////////////////////////////////////////// void parse_helptbl(const char *filename); 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 { char name[HELP_MAX_NAME_LENGTH]; 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; //////////////////////////////////////////////////////////////////// // Game-wide globals //////////////////////////////////////////////////////////////////// shader Grey_shader; //////////////////////////////////////////////////////////////////// // Module globals //////////////////////////////////////////////////////////////////// static int help_left_bracket_bitmap; static int help_right_bracket_bitmap; static help_overlay help_overlaylist[MAX_HELP_OVERLAYS]; int num_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 //////////////////////////////////////////////////////////////////// int help_overlay_get_index(const char* overlay_name) { for (int i = 0; i < num_help_overlays; i++) { if (!stricmp(overlay_name, help_overlaylist[i].name)) { return i; } } return -1; } // query whether a help overlay is active (ie being displayed) int help_overlay_active(int overlay_id) { Assert(overlay_id < MAX_HELP_OVERLAYS); if (overlay_id < 0) { return 0; } return Help_overlay_flags & (1<= 0 && overlay_id < num_help_overlays) { if ( state > 0 ) { Help_overlay_flags |= (1<= 0 && (Help_overlay_flags & (1< There is no context help available for state %s\n", GS_state_text[Source_game_state-1])); break; } // end switch if (overlay_id >= 0) { if ( !help_overlay_active(overlay_id) ) { help_overlay_set_state(overlay_id, 1); } else { help_overlay_set_state(overlay_id, 0); } } } void close_help(){ for (int overlay_id=0; overlay_id= 0, "Failed to load bitmap right_bracket for help overlay\n"); // load left_bracket bitmap help_left_bracket_bitmap = bm_load("left_bracket"); // we failed to load the bitmap - this is very bad Assertion( help_left_bracket_bitmap >= 0, "Failed to load bitmap left_bracket for help overlay\n"); atexit(close_help); num_help_overlays = 0; // parse help.tbl parse_helptbl(HELP_OVERLAY_FILENAME); // look for any modular tables parse_modular_table(NOX("*-hlp.tbm"), parse_helptbl); } // parses help.tbl and populates help_overlaylist[] void parse_helptbl(const char *filename) { int overlay_id, currcount; char name[HELP_MAX_NAME_LENGTH]; char buf[HELP_MAX_STRING_LENGTH + 1]; int i, rval; // open localization lcl_ext_open(); if ((rval = setjmp(parse_abort)) != 0) { mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", filename, rval)); lcl_ext_close(); return; } read_file_text(filename, CF_TYPE_TABLES); reset_parse(); // for each overlay... while (optional_string("$")) { stuff_string(name, F_NAME, HELP_MAX_NAME_LENGTH); overlay_id = help_overlay_get_index(name); if (overlay_id < 0) { if (num_help_overlays >= MAX_HELP_OVERLAYS) { Warning(LOCATION, "Could not load help overlay after '%s' as maximum number of help overlays was reached (Max is %d)", help_overlaylist[overlay_id - 1].name, MAX_HELP_OVERLAYS); if (!skip_to_string("$end")) { Error(LOCATION, "Couldn't find $end. Help.tbl or -hlp.tbm is invalid.\n"); } continue; } else { overlay_id = num_help_overlays; strcpy_s(help_overlaylist[overlay_id].name, name); num_help_overlays++; } } // clear out counters in the overlay struct help_overlaylist[overlay_id].plinecount = 0; help_overlaylist[overlay_id].textcount = 0; help_overlaylist[overlay_id].rbracketcount = 0; help_overlaylist[overlay_id].lbracketcount = 0; // read in all elements for this overlay while (!(optional_string("$end"))) { if (optional_string("+pline")) { currcount = help_overlaylist[overlay_id].plinecount; int a, b; // temp vars to read in int before cast to float; if (currcount < HELP_MAX_ITEM) { // read number of pline vertices stuff_int(&help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtxcount); // note that it is read into GR_640 // help_overlaylist[overlay_id].plinelist[GR_1024][currcount].vtxcount = help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtxcount; // set equal to 1024 version vertex count to prevent bugs Assert(help_overlaylist[overlay_id].plinelist[GR_640][currcount].vtxcount <= HELP_MAX_PLINE_VERTICES); // get 640x480 vertex coordinates for (i=0; i= 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_RESIZE_MENU); gr_set_color_fast(&Color_bright_white); gr_printf_menu(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 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, GR_RESIZE_MENU); } // 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, GR_RESIZE_MENU); } // 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