| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/main/help.cpp $ |
| 21 | * $Revision: 32 $ |
| 22 | * $Date: 3/20/00 12:10p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Help functions (when user presses F1 in the game) |
| 26 | * |
| 27 | * $Log: /DescentIII/main/help.cpp $ |
| 28 | * |
| 29 | * 32 3/20/00 12:10p Matt |
| 30 | * Merge of Duane's post-1.3 changes. |
| 31 | * Added help for PageDown pause key. |
| 32 | * |
| 33 | * 31 5/21/99 11:14p Samir |
| 34 | * changed some text in help dialog. (SHIFT-TAB) |
| 35 | * |
| 36 | * 30 5/21/99 12:45p Samir |
| 37 | * added help strings for F8 and F9 keys. |
| 38 | * |
| 39 | * 29 4/16/99 12:17p Samir |
| 40 | * new help menu with new ui. |
| 41 | * |
| 42 | * 28 4/16/99 4:25a Jeff |
| 43 | * removed ifdef of linux since new compiler compiles it |
| 44 | * |
| 45 | * 27 4/15/99 1:39a Jeff |
| 46 | * changes for linux compile |
| 47 | * |
| 48 | * 26 4/14/99 2:50a Jeff |
| 49 | * fixed some case mismatched #includes |
| 50 | * |
| 51 | * 25 4/06/99 12:11p Doug |
| 52 | * Made ESC key work (Samir) |
| 53 | * |
| 54 | * 24 4/03/99 9:26p Jeff |
| 55 | * changed dialogs that weren't using UID_OK and UID_CANCEL to use and |
| 56 | * handle them properly |
| 57 | * |
| 58 | * 23 3/04/99 11:41a Jeff |
| 59 | * fixed text going off window |
| 60 | * |
| 61 | * 22 3/03/99 7:21p Jeff |
| 62 | * adjusted help file window text to make room for new text |
| 63 | * |
| 64 | * 21 3/03/99 1:18p Jeff |
| 65 | * added telcom main menu item |
| 66 | * |
| 67 | * 20 2/28/99 9:19p Jeff |
| 68 | * added some strings to help window |
| 69 | * |
| 70 | * 19 10/20/98 12:15p Jeff |
| 71 | * removed SHIFT-F2 Center Missile view |
| 72 | * |
| 73 | * 18 10/19/98 7:08p Jeff |
| 74 | * added "F6 Multiplayer On-Screen Menu" |
| 75 | * |
| 76 | * 17 10/08/98 7:27p Samir |
| 77 | * made multiplayer friendly. |
| 78 | * |
| 79 | * 16 10/07/98 2:54p Jeff |
| 80 | * General UI fixes and additions |
| 81 | * |
| 82 | * 15 10/06/98 5:34p Jeff |
| 83 | * various UI changes/improvements |
| 84 | * |
| 85 | * 14 9/21/98 4:34p Jeff |
| 86 | * updates to Help menu |
| 87 | * |
| 88 | * 13 9/02/98 2:54p Jeff |
| 89 | * added defines for text colors to be used throughout the game...fixed up |
| 90 | * buddy menu too |
| 91 | * |
| 92 | * 12 8/15/98 2:49p Matt |
| 93 | * Took out unneeded include |
| 94 | * |
| 95 | * 11 7/09/98 12:33p Jeff |
| 96 | * f1 closes help screen |
| 97 | * |
| 98 | * 10 7/08/98 4:58p Jeff |
| 99 | * a bit more updated |
| 100 | * |
| 101 | * 9 6/17/98 3:27p Jeff |
| 102 | * Changes made for localization |
| 103 | * |
| 104 | * 8 6/16/98 10:38a Jeff |
| 105 | * localization, strings pulled out to stringtable.h and d3.str |
| 106 | * |
| 107 | * 7 5/05/98 6:26p Samir |
| 108 | * adjusted to work in 512 384 |
| 109 | * |
| 110 | * 6 4/24/98 3:27p Jeff |
| 111 | * removed briefing.h dependency |
| 112 | * |
| 113 | * 5 3/05/98 2:51p Jeff |
| 114 | * Made help system use UI |
| 115 | * |
| 116 | * 4 3/04/98 3:09p Jeff |
| 117 | * Now gives key descriptions |
| 118 | * |
| 119 | * 3 3/03/98 4:01p Jeff |
| 120 | * Got it displaying a "cheap" help screen |
| 121 | * |
| 122 | * 2 3/02/98 5:14p Jeff |
| 123 | * initial help system created |
| 124 | * |
| 125 | * $NoKeywords: $ |
| 126 | */ |
| 127 | |
| 128 | #include "help.h" |
| 129 | #include "mono.h" |
| 130 | #include "renderer.h" |
| 131 | #include "render.h" |
| 132 | #include "ddio.h" |
| 133 | #include "descent.h" |
| 134 | #include "game.h" |
| 135 | #include "cfile.h" |
| 136 | #include "application.h" |
| 137 | #include <stdlib.h> |
| 138 | #include <string.h> |
| 139 | #include <stdarg.h> |
| 140 | #include "newui.h" |
| 141 | #include "grtext.h" |
| 142 | #include "gamefont.h" |
| 143 | #include "stringtable.h" |
| 144 | |
| 145 | #define TITLETEXT TXT_HELP |
| 146 | static const int HelpText[] = {TXI_ESC, |
| 147 | TXI_HLPQUIT, |
| 148 | #ifndef DEMO // Do Not include in the PC Gamer Demo |
| 149 | TXI_HLPALTF2, |
| 150 | TXI_HLPSAVEGAME, |
| 151 | TXI_HLPALTF3, |
| 152 | TXI_HLPLOADGAME, |
| 153 | #endif |
| 154 | TXI_F2, |
| 155 | TXI_HLPCONFIG, |
| 156 | TXI_F3, |
| 157 | TXI_HLPCOCKPIT, |
| 158 | TXI_HLPF4, |
| 159 | TXI_HLPGUIDEBOT, |
| 160 | TXI_F5, |
| 161 | TXI_TOGGLEDEMO, |
| 162 | TXI_F6, |
| 163 | TXI_MLTMENU, |
| 164 | TXI_F8, |
| 165 | TXI_HLP_MULTIMSG, |
| 166 | TXI_F9, |
| 167 | TXI_HLP_QUIKSAVE, |
| 168 | TXI_F12, |
| 169 | TXI_DROPSMARKER, |
| 170 | TXI_SHFTTAB, |
| 171 | TXI_TCMM, |
| 172 | TXI_HLPPAUSE, |
| 173 | TXI_HLPPAUSEDESC, |
| 174 | TXI_PLUSMINUS, |
| 175 | TXI_HLPSCRNSIZE, |
| 176 | TXI_HLPPRNTSCRN, |
| 177 | TXI_HLPTAKESCRNSHT, |
| 178 | TXI_HLP1_5, |
| 179 | TXI_HLPSELPRIM, |
| 180 | TXI_HLP6_0, |
| 181 | TXI_HLPSELSECN, |
| 182 | TXI_SF1, |
| 183 | TXI_HLPREARLEFT, |
| 184 | TXI_SF2, |
| 185 | TXI_HLPREARRIGHT, |
| 186 | TXI_SHFTF8, |
| 187 | TXI_DISPLAYGAMEMSGCONSOLE, |
| 188 | TXI_SHFTF9, |
| 189 | TXI_DISPLAYHUDMSGCONSOLE, |
| 190 | 0}; |
| 191 | |
| 192 | #define HELP_X_KEY_POS 60 |
| 193 | #define HELP_X_DESC_POS 160 |
| 194 | #define HELP_Y 32 |
| 195 | |
| 196 | #define IDH_QUIT UID_CANCEL |
| 197 | #define WND_HELP_W 448 |
| 198 | #define WND_HELP_H 384 |
| 199 | #define WND_HELP_X (Game_window_w - WND_HELP_W) / 2 |
| 200 | #define WND_HELP_Y (Game_window_h - WND_HELP_H) / 2 |
| 201 | |
| 202 | void HelpDisplay(void) { |
| 203 | newuiTiledWindow help_wnd; |
| 204 | newuiSheet *sheet; |
| 205 | int strs_to_print = 0; |
| 206 | int index, res; |
| 207 | bool exit_menu = false; |
| 208 | |
| 209 | help_wnd.Create(TITLETEXT, 0, 0, WND_HELP_W, WND_HELP_H); |
| 210 | sheet = help_wnd.GetSheet(); |
| 211 | |
| 212 | // add commands |
| 213 | help_wnd.AddAcceleratorKey(KEY_F1, UID_CANCEL); |
| 214 | |
| 215 | strs_to_print = 0; |
| 216 | |
| 217 | // find out how many strings to print out |
| 218 | while (HelpText[strs_to_print] > 0) |
| 219 | strs_to_print++; |
| 220 | |
| 221 | sheet->NewGroup(NULL, 30, 10); |
| 222 | for (index = 0; index < strs_to_print; index += 2) { |
| 223 | if (index < strs_to_print) { |
| 224 | sheet->AddText(TXT(HelpText[index])); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | sheet->NewGroup(NULL, 130, 10); |
| 229 | for (index = 1; index < strs_to_print; index += 2) { |
| 230 | if (index < strs_to_print) { |
| 231 | sheet->AddText(TXT(HelpText[index])); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | sheet->NewGroup(NULL, WND_HELP_W - 160, WND_HELP_H - 96, NEWUI_ALIGN_HORIZ); |
| 236 | sheet->AddButton(TXT_OK, UID_CANCEL); |
| 237 | |
| 238 | // quit_hot.Create(&help_wnd, UID_CANCEL, 0, &UITextItem(TXT_PRESSESCRET, UICOL_HOTSPOT_LO,UIALPHA_HOTSPOT_LO), |
| 239 | // &UITextItem(TXT_PRESSESCRET,UICOL_HOTSPOT_HI,UIALPHA_HOTSPOT_HI), |
| 240 | // HELP_X_KEY_POS, WND_HELP_H - OKCANCEL_YOFFSET, |
| 241 | // 0,0,UIF_FIT|UIF_CENTER); |
| 242 | help_wnd.Open(); |
| 243 | |
| 244 | while (!exit_menu) { |
| 245 | res = help_wnd.DoUI(); |
| 246 | |
| 247 | // handle all UI results. |
| 248 | switch (res) { |
| 249 | case UID_CANCEL: |
| 250 | case NEWUIRES_FORCEQUIT: |
| 251 | exit_menu = true; |
| 252 | break; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | help_wnd.Close(); |
| 257 | help_wnd.Destroy(); |
| 258 | } |