| 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/menu.cpp $ |
| 21 | * $Revision: 194 $ |
| 22 | * $Date: 10/17/01 3:43p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * main menu code |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/menu.cpp $ |
| 28 | * |
| 29 | * 194 10/17/01 3:43p Matt |
| 30 | * Took out Kevin's -mission changes since we decided to change the readme |
| 31 | * instead. |
| 32 | * |
| 33 | * 193 10/03/01 10:57p Kevin |
| 34 | * fixed -mission |
| 35 | * |
| 36 | * 192 8/30/01 10:48a Matt |
| 37 | * Check pilot command-line arg only once, not every time we go into main |
| 38 | * menu. |
| 39 | * |
| 40 | * 191 4/19/00 5:17p Matt |
| 41 | * From Duane for 1.4 |
| 42 | * Added Mac-only mem free |
| 43 | * |
| 44 | * 190 3/20/00 12:16p Matt |
| 45 | * Merge of Duane's post-1.3 changes. |
| 46 | * Index fix in building mission list (Mac only) |
| 47 | * |
| 48 | * 189 11/04/99 8:07a Kevin |
| 49 | * don't put the player into the training mission the first time in if the |
| 50 | * -mission flag was specified |
| 51 | * |
| 52 | * 188 10/25/99 9:51a Matt |
| 53 | * Mac merge |
| 54 | * |
| 55 | * 187 8/02/99 10:31a Kevin |
| 56 | * Fixed duplicate games in new game menu |
| 57 | * |
| 58 | * 186 7/30/99 1:49p Kevin |
| 59 | * Fixed Mac related menu bug |
| 60 | * |
| 61 | * 185 7/28/99 4:04p Kevin |
| 62 | * Macintosh! |
| 63 | * |
| 64 | * 184 5/25/99 3:44a Jeff |
| 65 | * reset cheater flag when going into multiplayer game |
| 66 | * |
| 67 | * 183 5/24/99 2:12a Matt |
| 68 | * Fixed stupid bug that caused -pilot to not work. |
| 69 | * |
| 70 | * 182 5/12/99 10:54a Kevin |
| 71 | * When going to the load game screen from the main menu, always set the |
| 72 | * game mode to none. In some cases where loading a multiplayer level |
| 73 | * failed, the mode was still GM_MULTI |
| 74 | * |
| 75 | * 181 5/05/99 11:16p Kevin |
| 76 | * heat.net stuff among other things |
| 77 | * |
| 78 | * 180 5/03/99 10:16p Kevin |
| 79 | * added -pilot to work just like +name |
| 80 | * |
| 81 | * 179 5/03/99 3:35p Kevin |
| 82 | * bug fixes |
| 83 | * |
| 84 | * 178 5/02/99 7:26p Samir |
| 85 | * changed some sequencing so when finishing training mission, the main |
| 86 | * menu does not pop up. |
| 87 | * |
| 88 | * 177 5/02/99 12:55a Jeff |
| 89 | * save ship permissions at highest level achieved and use that on restore |
| 90 | * to a level previously played |
| 91 | * |
| 92 | * 176 4/29/99 3:21a Samir |
| 93 | * reorganized main menu music to work in config, multiplayer, whereever. |
| 94 | * |
| 95 | * 175 4/25/99 6:14p Kevin |
| 96 | * added "-timetest file.dem" to behave like gamegauge does |
| 97 | * |
| 98 | * 174 4/20/99 7:30p Jeff |
| 99 | * use last directory when displaying load level dialog |
| 100 | * |
| 101 | * 173 4/18/99 7:55p Samir |
| 102 | * new progress indicator for delays when loading data. |
| 103 | * |
| 104 | * 172 4/17/99 3:44p Kevin |
| 105 | * Demo2 changes & fixes |
| 106 | * |
| 107 | * 171 4/16/99 11:15p Jeff |
| 108 | * itoa for linux added |
| 109 | * |
| 110 | * 170 4/16/99 6:00p Kevin |
| 111 | * Bunches of Demo stuff |
| 112 | * |
| 113 | * 169 4/16/99 11:56a Matt |
| 114 | * Changed directplay code to be "ifdef _WIN32" instead of "ifndef |
| 115 | * __LINUX__" so it will work on the Mac. |
| 116 | * |
| 117 | * 168 4/15/99 1:40a Jeff |
| 118 | * changes for linux compile |
| 119 | * |
| 120 | * 167 4/14/99 3:07p Kevin |
| 121 | * Fixed some multiple CD bugs |
| 122 | * |
| 123 | * 166 4/14/99 2:51a Jeff |
| 124 | * fixed some case mismatched #includes |
| 125 | * |
| 126 | * 165 4/08/99 3:12p Matt |
| 127 | * Finished cleaning up level sequencing code. Got rid of all the "level |
| 128 | * minus one" stuff. |
| 129 | * |
| 130 | * 164 4/07/99 3:40p Kevin |
| 131 | * Fixes for Beta 1 |
| 132 | * |
| 133 | * 163 4/05/99 10:57a Samir |
| 134 | * fixed potential crash in mission list generation. |
| 135 | * |
| 136 | * 162 3/31/99 3:04p Jeff |
| 137 | * added _real_ temporary credits system... |
| 138 | * |
| 139 | * 161 3/29/99 5:32p Kevin |
| 140 | * Build fixes |
| 141 | * |
| 142 | * 160 3/29/99 11:19a Matt |
| 143 | * Fixed compile warning |
| 144 | * |
| 145 | * 159 3/24/99 2:58p Kevin |
| 146 | * Doh! I forgot to save the files first!!@#@#$ |
| 147 | * |
| 148 | * 158 3/24/99 2:56p Kevin |
| 149 | * Fixed level specific progress indicator to have a default for single |
| 150 | * player missions, and fixed the default mission name (put it in the |
| 151 | * stringtable) |
| 152 | * |
| 153 | * 157 3/24/99 10:54a Kevin |
| 154 | * Fixed some problems related to splitting up the main d3.mn3 file across |
| 155 | * 2 CDs |
| 156 | * |
| 157 | * 156 3/18/99 3:51p Kevin |
| 158 | * Fixed support for MN3 files |
| 159 | * |
| 160 | * 155 3/18/99 12:51p Samir |
| 161 | * debug info. |
| 162 | * |
| 163 | * 154 3/18/99 10:13a Samir |
| 164 | * added music. |
| 165 | * |
| 166 | * 153 3/09/99 6:34p Kevin |
| 167 | * Made the training mission not be branching, and fixed the crash with |
| 168 | * people dying in the demo playback |
| 169 | * |
| 170 | * 152 3/09/99 1:37p Kevin |
| 171 | * Fixed lame sequencing bug in multiplayer |
| 172 | * |
| 173 | * 151 3/04/99 6:09p Samir |
| 174 | * wait message for mission load dialog. |
| 175 | * |
| 176 | * 150 3/03/99 7:19p Jeff |
| 177 | * removed levelwarp dialog for OEM |
| 178 | * |
| 179 | * 149 3/03/99 1:56p Samir |
| 180 | * always assert that game mode is set to GM_NONE when entering main menu. |
| 181 | * (when trying load game after escaping from multiplayer game list menu, |
| 182 | * the game mode still seemed to be in GM_MULTI.) |
| 183 | * |
| 184 | * 148 3/02/99 11:31p Kevin |
| 185 | * |
| 186 | * 147 3/02/99 7:20p Kevin |
| 187 | * |
| 188 | * 146 3/02/99 11:52a Kevin |
| 189 | * Fixes for OEM Beta 4.1 |
| 190 | * |
| 191 | * 145 3/01/99 9:49p Jeff |
| 192 | * fixed stray paren |
| 193 | * |
| 194 | * 144 3/01/99 9:03p Kevin |
| 195 | * OEM Beta 4 |
| 196 | * |
| 197 | * 143 2/28/99 3:26a Samir |
| 198 | * redid newgame dialog. |
| 199 | * |
| 200 | * 142 2/26/99 7:36p Kevin |
| 201 | * Fixed the oem mission name |
| 202 | * |
| 203 | * 141 2/26/99 7:16p Kevin |
| 204 | * Added extern for ShowStaticScreen so it will compile in OEM |
| 205 | * |
| 206 | * 140 2/26/99 5:36p Samir |
| 207 | * Added credits screens. |
| 208 | * |
| 209 | * 139 2/25/99 4:29p Jeff |
| 210 | * mission data of pilot keeps track of all missions, not just after you |
| 211 | * beat a level |
| 212 | * |
| 213 | * 138 2/24/99 3:15p Kevin |
| 214 | * OEM menu changes, and bug fixes for the save/load system |
| 215 | * |
| 216 | * 137 2/20/99 2:30p Kevin |
| 217 | * Made multiplayer DLLs return to the game list after a game. |
| 218 | * |
| 219 | * 136 2/20/99 1:14a Kevin |
| 220 | * enabled choosing any mission number in the oem build (for now) |
| 221 | * |
| 222 | * 135 2/16/99 12:06p Samir |
| 223 | * revamped ui for config menus. |
| 224 | * |
| 225 | * 134 2/16/99 12:36a Kevin |
| 226 | * Fixes for release builds of OEM V3 and KAtmai |
| 227 | * |
| 228 | * 133 2/15/99 7:49p Jeff |
| 229 | * new pilot file class and read/write system checked in...should be more |
| 230 | * robust than old |
| 231 | * |
| 232 | * 132 2/08/99 2:39p Kevin |
| 233 | * Fixed command line joining & disabled gamespy launching in OEM builds |
| 234 | * |
| 235 | * 131 2/05/99 7:23p Kevin |
| 236 | * OEM Changes |
| 237 | * |
| 238 | * 130 2/03/99 4:20p Kevin |
| 239 | * Got multiplayer working with .mn3 files, and setup autodownloading |
| 240 | * |
| 241 | * 129 1/31/99 7:26p Matt |
| 242 | * Renamed a bunch of functions to have HUD capitalized |
| 243 | * |
| 244 | * 128 1/29/99 5:22p Jeff |
| 245 | * localization |
| 246 | * |
| 247 | * 127 1/19/99 1:15p Samir |
| 248 | * add on missions. |
| 249 | * |
| 250 | * 126 1/04/99 6:12p Jeff |
| 251 | * close mission window when displaying level select |
| 252 | * |
| 253 | * 125 1/04/99 5:43p Kevin |
| 254 | * new command line args |
| 255 | * |
| 256 | * 124 12/30/98 5:24p Kevin |
| 257 | * Added +name to specify a default pilot (for gamespy) fixed a gamespy |
| 258 | * bug, and improved the pxo dll game list screen |
| 259 | * |
| 260 | * 123 12/21/98 6:32p Matt |
| 261 | * Fixed small bug |
| 262 | * |
| 263 | * 122 12/21/98 3:33p Samir |
| 264 | * level warp fully implemented. |
| 265 | * |
| 266 | * 121 12/16/98 3:24p Samir |
| 267 | * new way to get info on a mission (used to determine training mission |
| 268 | * too.) |
| 269 | * |
| 270 | * 120 12/15/98 4:28p Jeff |
| 271 | * added mission data information to the pilot files to save what the |
| 272 | * highest level they achieved on a mission is. Added level select dialog |
| 273 | * (not hooked up) and level warp cheat. |
| 274 | * |
| 275 | * 119 11/23/98 4:52p Kevin |
| 276 | * Demo system enhancments |
| 277 | * |
| 278 | * 118 11/19/98 5:40p Kevin |
| 279 | * Demo system |
| 280 | * |
| 281 | * 117 11/18/98 3:26p Kevin |
| 282 | * Put multiplayer options into con_dll.h |
| 283 | * |
| 284 | * 116 11/06/98 10:53a Kevin |
| 285 | * Added demo playback |
| 286 | * |
| 287 | * 115 10/22/98 10:03a Jeff |
| 288 | * renamed some things to keep them consistent |
| 289 | * |
| 290 | * 114 10/22/98 12:45a Matt |
| 291 | * Before starting the game, get rid of the menu and leave just the |
| 292 | * background screen up (while the briefing stuff is loading). |
| 293 | * |
| 294 | * 113 10/21/98 7:18p Matt |
| 295 | * Added quick-exit system to not free individual mem chunks on exit, |
| 296 | * since the whole heap gets freed at the end. |
| 297 | * |
| 298 | * 112 10/19/98 8:07p Matt |
| 299 | * Added credits screens, and took out blank line in the main menu. |
| 300 | * |
| 301 | * 111 10/18/98 7:28p Samir |
| 302 | * added weapon selection to options menu. |
| 303 | * |
| 304 | * 110 10/17/98 7:34p Samir |
| 305 | * fixed bug when changing video modes, causing screen to not refresh. |
| 306 | * |
| 307 | * 109 10/17/98 6:11p Jeff |
| 308 | * pilot select appears before main menu is shown |
| 309 | * |
| 310 | * 108 10/16/98 1:54p Kevin |
| 311 | * Changes for Demo Beta 4 |
| 312 | * |
| 313 | * 107 10/15/98 1:15p Kevin |
| 314 | * Changed #ifndef RELEASE to #ifdef _DEBUG |
| 315 | * |
| 316 | * 106 10/13/98 3:48p Samir |
| 317 | * added credits menu. |
| 318 | * |
| 319 | * 105 10/12/98 1:46p Samir |
| 320 | * initial new main menu |
| 321 | * |
| 322 | * 104 10/08/98 10:47p Samir |
| 323 | * added copyright message. |
| 324 | * |
| 325 | * 103 10/08/98 7:31p Samir |
| 326 | * fixed memory crash bug if there are nomissions to load in listbox. |
| 327 | * |
| 328 | * 102 10/08/98 12:00p Kevin |
| 329 | * Demo system work |
| 330 | * |
| 331 | * 101 10/07/98 6:23p Samir |
| 332 | * added code to bail if in multiplayer for options menu. |
| 333 | * |
| 334 | * 100 10/07/98 1:08p Craig |
| 335 | * fixed some simple multiplayer thing. |
| 336 | * |
| 337 | * 99 10/06/98 5:34p Jeff |
| 338 | * various UI changes/improvements |
| 339 | * |
| 340 | * 98 10/02/98 12:30p Samir |
| 341 | * added version information for beta/demo. |
| 342 | * |
| 343 | * 97 10/01/98 12:57p Samir |
| 344 | * resized mission listbox. |
| 345 | * |
| 346 | * 96 9/30/98 12:33p Kevin |
| 347 | * Added web launching support |
| 348 | * |
| 349 | * 95 9/30/98 10:36a Kevin |
| 350 | * Added command line launching of URLs and command line directory |
| 351 | * specification |
| 352 | * |
| 353 | * 94 9/28/98 4:35p Jeff |
| 354 | * general UI changes and improvements |
| 355 | * |
| 356 | * 93 9/23/98 6:19p Jeff |
| 357 | * finished up (hopefully) updating the config/ui dialogs to meet our |
| 358 | * standard. Keyboard/joystick config still needs some work |
| 359 | * |
| 360 | * 92 9/23/98 3:07p Jeff |
| 361 | * updated the colors and various other items of config and UI |
| 362 | * |
| 363 | * 91 9/22/98 3:56p Samir |
| 364 | * special demo code doesn't allow pilot and mission stuff. |
| 365 | * |
| 366 | * 90 9/22/98 10:37a Jason |
| 367 | * added loadlevel command line argument for autostarting of levels |
| 368 | * |
| 369 | * 89 9/08/98 11:41a Jeff |
| 370 | * call new pilot selection dialog |
| 371 | * |
| 372 | * 88 9/02/98 2:54p Jeff |
| 373 | * added defines for text colors to be used throughout the game...fixed up |
| 374 | * buddy menu too |
| 375 | * |
| 376 | * 87 9/01/98 12:44p Jeff |
| 377 | * clear screen as soon as user double clicks on mission |
| 378 | * |
| 379 | * 86 8/31/98 12:38p Samir |
| 380 | * new game dialog is no longer a 'menu' based window. |
| 381 | * |
| 382 | * 85 8/25/98 10:53a Samir |
| 383 | * restored simple menu system |
| 384 | * |
| 385 | * 84 8/24/98 10:55a Kevin |
| 386 | * new directplay stuff |
| 387 | * |
| 388 | * 83 8/20/98 11:29a Samir |
| 389 | * adjusted placement of main menu items. |
| 390 | * |
| 391 | * 82 8/20/98 10:52a Samir |
| 392 | * added load game(restore game) functionality from main menu. |
| 393 | * |
| 394 | * 81 8/14/98 7:37p Matt |
| 395 | * Since PSFILENAME_LEN is now considered to be the max length of the |
| 396 | * string itself (not counting the terminating null), buffers for file |
| 397 | * name need to be PSFILENAME_LEN+1 bytes long. |
| 398 | * |
| 399 | * 80 8/07/98 2:44p Jeff |
| 400 | * set all ships allowed when going into multiplayer. Reset permissions |
| 401 | * when selecting new game |
| 402 | * |
| 403 | * 79 7/29/98 6:43p Jeff |
| 404 | * changed so menu loadlevel used file dialog |
| 405 | * |
| 406 | * 78 7/27/98 6:25p Jeff |
| 407 | * fixed bug when changing screen size in menu |
| 408 | * |
| 409 | * 77 7/10/98 12:08p Kevin |
| 410 | * fixed auto connect to only happen once |
| 411 | * |
| 412 | * 76 7/10/98 10:47a Kevin |
| 413 | * Added command line connecting to games |
| 414 | * |
| 415 | * 75 6/19/98 5:40p Samir |
| 416 | * added hud configuration. |
| 417 | * |
| 418 | * 74 6/16/98 10:56a Jeff |
| 419 | * localization changes |
| 420 | * |
| 421 | * 73 6/15/98 4:00p Jason |
| 422 | * replaced monochromatic polymodel lighting with rgb lighting |
| 423 | * |
| 424 | * 72 5/25/98 8:19p Samir |
| 425 | * display mission menu. |
| 426 | * |
| 427 | * 71 5/24/98 2:58a Jeff |
| 428 | * Options menu changes. MenuOptions now takes a parameter, whether its |
| 429 | * being called from the game or not |
| 430 | * |
| 431 | * 70 5/23/98 6:33p Jeff |
| 432 | * renamed the hotspots for the Options menu |
| 433 | * |
| 434 | * 69 5/18/98 3:56p Samir |
| 435 | * added D3_FAST mode to quickly enter and exit games. |
| 436 | * |
| 437 | * 68 5/12/98 2:48p Samir |
| 438 | * show cursor in main menu. |
| 439 | * |
| 440 | * 67 5/08/98 4:31p Samir |
| 441 | * set ui callback to nothing if we're done with main menu. |
| 442 | * |
| 443 | * 66 5/08/98 3:58p Samir |
| 444 | * reposition options menu after video config. |
| 445 | * |
| 446 | * 65 5/05/98 5:15p Samir |
| 447 | * adjusted menus to work in 512x384 as well as 640x480. |
| 448 | * |
| 449 | * 64 5/04/98 10:51a Jeff |
| 450 | * changed menu font color |
| 451 | * |
| 452 | * 63 5/01/98 6:25p Samir |
| 453 | * brightened up options menu. |
| 454 | * |
| 455 | * 62 5/01/98 4:25p Samir |
| 456 | * sped up menu animation. |
| 457 | * |
| 458 | * 61 5/01/98 3:26p Samir |
| 459 | * menu items should be aligned properly. |
| 460 | * |
| 461 | * 60 4/29/98 1:04p Jeff |
| 462 | * fixed up colors in the windows, text strings and others |
| 463 | * |
| 464 | * 59 4/28/98 4:46p Samir |
| 465 | * use new menu font for menu. |
| 466 | * |
| 467 | * 58 4/28/98 11:55a Jeff |
| 468 | * Removed ConfigSave and replaced with SaveGameSettings |
| 469 | * |
| 470 | * 57 4/20/98 11:30a Jason |
| 471 | * Added ShowProgressScreen function |
| 472 | * |
| 473 | * 56 4/13/98 7:01p Samir |
| 474 | * added snazzy listbox and edit box art. |
| 475 | * |
| 476 | * 55 4/10/98 7:55p Samir |
| 477 | * new main menu interface system. |
| 478 | * |
| 479 | * 54 4/09/98 5:30p Samir |
| 480 | * new main menu art. |
| 481 | * |
| 482 | * 53 4/02/98 3:54p Jason |
| 483 | * first pass in getting polymodel paging to work |
| 484 | * |
| 485 | * 52 4/02/98 11:11a Samir |
| 486 | * Error checking for level load/misison init fail. |
| 487 | * |
| 488 | * 51 3/20/98 1:19p Jeff |
| 489 | * Changes made to use Default_pilot string for pilot filename to use. |
| 490 | * |
| 491 | * 50 3/13/98 8:55p Jeff |
| 492 | * Various changes to move control configuration into Pilot file |
| 493 | * |
| 494 | * 49 3/13/98 12:49p Jeff |
| 495 | * Fixed "Load Level" option it now works |
| 496 | * |
| 497 | * 48 3/13/98 12:10p Samir |
| 498 | * Added a simple load level menu function, UI must be implemented. |
| 499 | * |
| 500 | * 47 3/12/98 8:31p Jeff |
| 501 | * fixed bug in Load A Level option |
| 502 | * |
| 503 | * 46 3/12/98 8:29p Jeff |
| 504 | * Put in Load Level option for non-release |
| 505 | * |
| 506 | * 45 3/12/98 7:09p Jeff |
| 507 | * Added "Pilots" to main menu |
| 508 | * |
| 509 | * 44 3/12/98 2:15p Jeff |
| 510 | * changed options menu text colors |
| 511 | * |
| 512 | * 43 3/12/98 2:01p Jeff |
| 513 | * Made it so user can't cancel out of Pilot dialog (passed true to |
| 514 | * PilotDisplay) |
| 515 | * |
| 516 | * 42 3/11/98 5:38p Jeff |
| 517 | * Automatically calls PilotDisplay to choose pilot before main menu |
| 518 | * |
| 519 | * 41 3/10/98 12:48p Samir |
| 520 | * Options menu has new look. |
| 521 | * |
| 522 | * 40 3/09/98 4:00p Jeff |
| 523 | * Pilot test (temp) added to main menu for Pilot screen testing |
| 524 | * |
| 525 | * 39 3/05/98 6:38p Samir |
| 526 | * Use UI_FONT now. |
| 527 | * |
| 528 | * 38 3/02/98 5:53p Samir |
| 529 | * Don't set alpha of UI windows. |
| 530 | * |
| 531 | * 37 2/27/98 5:35p Jeff |
| 532 | * Added in loading and saving of a game configuration file |
| 533 | * |
| 534 | * 36 2/24/98 3:43p Jeff |
| 535 | * added more configuration options in the Options menu |
| 536 | * |
| 537 | * 35 2/16/98 9:27p Samir |
| 538 | * Added test code for movies. |
| 539 | * |
| 540 | * 34 2/15/98 7:07p Samir |
| 541 | * Added two controller options in the options menu. |
| 542 | * |
| 543 | * 33 2/13/98 6:38p Samir |
| 544 | * Added menu movie. |
| 545 | * |
| 546 | * 32 2/11/98 4:36p Samir |
| 547 | * Call SetGameMode to modify game mode. |
| 548 | * |
| 549 | * 31 2/10/98 3:46p Samir |
| 550 | * Call config function when choosing 'configuration'. |
| 551 | * |
| 552 | * 30 1/30/98 7:33p Samir |
| 553 | * Jazzed up menus. |
| 554 | * |
| 555 | * 29 1/30/98 2:39p Samir |
| 556 | * Commented out real-time code. |
| 557 | * |
| 558 | * 28 1/26/98 2:28p Jason |
| 559 | * fixed main menu arguments |
| 560 | * |
| 561 | * 27 1/26/98 10:36a Samir |
| 562 | * Changed UI a bit. |
| 563 | * |
| 564 | * 26 1/19/98 10:56a Samir |
| 565 | * Adjusted menu a bit. |
| 566 | * |
| 567 | * 25 1/18/98 4:22p Samir |
| 568 | * Implemented new UIItem system. |
| 569 | * |
| 570 | * 24 1/15/98 11:14a Jeff |
| 571 | * Added/Changed code to get Telcom working again |
| 572 | * |
| 573 | * 23 1/13/98 6:29p Samir |
| 574 | * Moved Large Bitmap code from Menu.cpp to newui.cpp. |
| 575 | * |
| 576 | * 22 1/13/98 4:28p Samir |
| 577 | * Added sliders. |
| 578 | * |
| 579 | * 21 1/12/98 5:24p Samir |
| 580 | * Menu uses new font. |
| 581 | * |
| 582 | * 20 1/08/98 12:18p Samir |
| 583 | * New menu interface. |
| 584 | * |
| 585 | * 19 1/06/98 2:44p Jason |
| 586 | * another pass for multiplayer |
| 587 | * |
| 588 | * 18 1/06/98 2:15p Samir |
| 589 | * Took out test stuff. |
| 590 | * |
| 591 | * 17 1/05/98 10:56a Samir |
| 592 | * New menu stuff. |
| 593 | * |
| 594 | * 16 12/19/97 2:12p Samir |
| 595 | * Fixed menu. |
| 596 | * |
| 597 | * 15 12/11/97 3:15p Samir |
| 598 | * Stubbed out menu code. |
| 599 | * |
| 600 | * 14 11/19/97 10:44a Jason |
| 601 | * minor changes to menu |
| 602 | * |
| 603 | * 13 11/18/97 6:34p Jason |
| 604 | * sped up main menu animation, added alpha support, and made it work in |
| 605 | * software mode. |
| 606 | * |
| 607 | * 12 11/17/97 4:31p Matt |
| 608 | * Got rid of compile warning |
| 609 | * |
| 610 | * 11 11/14/97 7:02p Samir |
| 611 | * Milestone menu. |
| 612 | * |
| 613 | * 10 11/12/97 2:52p Samir |
| 614 | * Slightly more complicated, slower frame rate animating background. |
| 615 | * |
| 616 | * 9 11/11/97 1:28p Samir |
| 617 | * Simple 3d background. |
| 618 | * |
| 619 | * 8 11/04/97 4:56p Samir |
| 620 | * Main menu beginning to work. |
| 621 | * |
| 622 | * 7 10/15/97 3:05p Samir |
| 623 | * Redraw menu each frame. |
| 624 | * |
| 625 | * 6 10/02/97 12:36p Samir |
| 626 | * Redid game sequencing flow. |
| 627 | * |
| 628 | * 5 7/23/97 4:46p Jeff |
| 629 | * Added call to SetScreenMode() in MainMenu() to init Game_view |
| 630 | * |
| 631 | * 7 6/11/97 2:25p Samir |
| 632 | * Changed gameos to new system |
| 633 | * |
| 634 | * 6 5/15/97 2:09p Samir |
| 635 | * Start mission when new game. |
| 636 | * |
| 637 | * 5 4/29/97 5:29p Samir |
| 638 | * New game calls mission functions. |
| 639 | * |
| 640 | * 4 3/17/97 1:15p Matt |
| 641 | * Cleaned up menu a little |
| 642 | * |
| 643 | * 3 2/04/97 5:33p Samir |
| 644 | * Added Editor option to 'menu'. |
| 645 | * |
| 646 | * 2 2/04/97 2:33p Samir |
| 647 | * Cheap menu |
| 648 | * |
| 649 | * 1 2/03/97 5:27p Samir |
| 650 | * Initial version |
| 651 | * |
| 652 | * $NoKeywords: $ |
| 653 | */ |
| 654 | |
| 655 | #include <cstdio> |
| 656 | #include <cstring> |
| 657 | |
| 658 | #include "menu.h" |
| 659 | #include "mmItem.h" |
| 660 | #include "game.h" |
| 661 | #include "Mission.h" |
| 662 | #include "multi_ui.h" |
| 663 | #include "ctlconfig.h" |
| 664 | #include "config.h" |
| 665 | #include "gamesave.h" |
| 666 | #include "gamesequence.h" |
| 667 | #include "demofile.h" |
| 668 | #include "pilot.h" |
| 669 | #include "LoadLevel.h" |
| 670 | #include "stringtable.h" |
| 671 | #include "mem.h" |
| 672 | #include "args.h" |
| 673 | #include "cinematics.h" |
| 674 | #include "multi_dll_mgr.h" |
| 675 | #include "newui_core.h" |
| 676 | |
| 677 | #ifdef _WIN32 |
| 678 | #define USE_DIRECTPLAY |
| 679 | #endif |
| 680 | |
| 681 | #ifdef USE_DIRECTPLAY |
| 682 | #include "directplay.h" |
| 683 | #else |
| 684 | bool Directplay_lobby_launched_game = false; |
| 685 | #endif |
| 686 | |
| 687 | #define IDV_QUIT 0xff |
| 688 | // Menu Item Defines |
| 689 | #define IDV_NEWGAME 10 |
| 690 | #define IDV_MULTIPLAYER 11 |
| 691 | #define IDV_OPTIONS 12 |
| 692 | #define IDV_PILOT 13 |
| 693 | #define IDV_LOADGAME 14 |
| 694 | #define IDV_PLAYDEMO 15 |
| 695 | #define IDV_CREDITS 16 |
| 696 | #ifdef _DEBUG |
| 697 | #define IDV_LOADLEVEL 20 |
| 698 | #define IDV_OK 1 |
| 699 | #define IDV_CANCEL 2 |
| 700 | bool MenuLoadLevel(void); |
| 701 | #endif |
| 702 | // for command line joining of games |
| 703 | bool Auto_connected = false; |
| 704 | |
| 705 | // runs command line options. |
| 706 | bool ProcessCommandLine(); |
| 707 | // new game selection |
| 708 | bool MenuNewGame(); |
| 709 | extern bool Mem_quick_exit; |
| 710 | bool IsRestoredGame = false; |
| 711 | ////////////////////////////////////////////////////////////////////////////// |
| 712 | extern bool Demo_looping; |
| 713 | bool FirstGame = false; |
| 714 | |
| 715 | int MainMenu() { |
| 716 | mmInterface main_menu; |
| 717 | bool exit_game = false; |
| 718 | bool exit_menu = false; |
| 719 | |
| 720 | // okay over here, we'll decide whether we've finished the training mission and are going into game. |
| 721 | if (!Demo_looping && !Demo_restart && !MultiDLLGameStarting) { |
| 722 | if (FirstGame) { |
| 723 | if (MenuNewGame()) { |
| 724 | return 0; |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | // setup screen |
| 730 | SetScreenMode(SM_MENU); |
| 731 | // create interface |
| 732 | main_menu.Create(); |
| 733 | main_menu.AddItem(IDV_NEWGAME, KEY_N, TXT_MENUNEWGAME, MM_STARTMENU_TYPE); |
| 734 | main_menu.AddItem(IDV_LOADGAME, KEY_L, TXT_LOADGAME); |
| 735 | // #ifndef DEMO |
| 736 | main_menu.AddItem(IDV_PLAYDEMO, KEY_D, TXT_VIEWDEMO); |
| 737 | // #endif |
| 738 | main_menu.AddItem(IDV_OPTIONS, KEY_O, TXT_MENUOPTIONS); |
| 739 | main_menu.AddItem(IDV_PILOT, KEY_P, TXT_MENUPILOTS); |
| 740 | main_menu.AddItem(IDV_MULTIPLAYER, KEY_M, TXT_MENUMULTIPLAYER); |
| 741 | main_menu.AddItem(IDV_CREDITS, KEY_C, TXT_MENUCREDITS); |
| 742 | main_menu.AddItem(IDV_QUIT, KEY_Q, TXT_MENUQUIT, MM_ENDMENU_TYPE); |
| 743 | #ifdef _DEBUG |
| 744 | main_menu.AddItem(0, 0, NULL); |
| 745 | main_menu.AddItem(IDV_LOADLEVEL, 0, "Load Level"); |
| 746 | #endif |
| 747 | // page in ui data. |
| 748 | newuiCore_PageInBitmaps(); |
| 749 | // do special junk. |
| 750 | |
| 751 | // Only check for pilot arg first time, not every tme |
| 752 | static bool first_time = true; |
| 753 | if (first_time) { |
| 754 | int pilotarg = FindArg("+name"); |
| 755 | if (!pilotarg) { |
| 756 | pilotarg = FindArg("-pilot"); |
| 757 | } |
| 758 | if (pilotarg) { |
| 759 | char pfilename[_MAX_FNAME]; |
| 760 | strcpy(pfilename, GameArgs[pilotarg + 1]); |
| 761 | strcat(pfilename, ".plt"); |
| 762 | Current_pilot.set_filename(pfilename); |
| 763 | PltReadFile(&Current_pilot, true); |
| 764 | } |
| 765 | first_time = false; |
| 766 | } |
| 767 | char pfilename[_MAX_FNAME]; |
| 768 | Current_pilot.get_filename(pfilename); |
| 769 | |
| 770 | if ((pfilename[0] == '\0') || (strlen(pfilename) == 0) || (!strcmp(pfilename, " "))) |
| 771 | PilotSelect(); |
| 772 | |
| 773 | // always enforce that in main menu we are in normal game mode. |
| 774 | SetGameMode(GM_NONE); |
| 775 | // open main menu |
| 776 | main_menu.Open(); |
| 777 | exit_menu = ProcessCommandLine(); |
| 778 | // Main Menu Code Here |
| 779 | while (!exit_menu) { |
| 780 | int res; |
| 781 | // handle all UI results. |
| 782 | if ((Demo_looping) || (Demo_restart)) { |
| 783 | Demo_restart = false; |
| 784 | SetGameMode(GM_NORMAL); |
| 785 | SetFunctionMode(LOADDEMO_MODE); |
| 786 | exit_menu = 1; |
| 787 | continue; |
| 788 | } else if (MultiDLLGameStarting) { |
| 789 | // Go back into the multiplayer DLL @ the game list |
| 790 | |
| 791 | mprintf(0, "Returning to Multiplayer!\n"); |
| 792 | |
| 793 | if (ReturnMultiplayerGameMenu()) { |
| 794 | exit_menu = 1; |
| 795 | SetFunctionMode(GAME_MODE); |
| 796 | continue; |
| 797 | } |
| 798 | } |
| 799 | /* |
| 800 | else |
| 801 | { |
| 802 | if(FirstGame) |
| 803 | { |
| 804 | //MenuScene(); |
| 805 | //ui_ShowCursor(); |
| 806 | //Descent->defer(); |
| 807 | //DoUIFrame(); |
| 808 | //rend_Flip(); |
| 809 | //GetUIFrameResult(); |
| 810 | res = IDV_NEWGAME; |
| 811 | } |
| 812 | else { |
| 813 | main_menu.SetMusicRegion(MM_MUSIC_REGION); |
| 814 | res = main_menu.DoUI(); |
| 815 | } |
| 816 | } |
| 817 | if (FirstGame) |
| 818 | res = IDV_NEWGAME; |
| 819 | */ |
| 820 | res = FirstGame ? IDV_NEWGAME : -1; |
| 821 | if (res == -1) { |
| 822 | main_menu.SetMusicRegion(MM_MUSIC_REGION); |
| 823 | res = main_menu.DoUI(); |
| 824 | } |
| 825 | switch (res) { |
| 826 | case IDV_NEWGAME: |
| 827 | main_menu.SetMusicRegion(NEWGAME_MUSIC_REGION); |
| 828 | DoWaitMessage(true); |
| 829 | IsCheater = false; |
| 830 | IsRestoredGame = false; |
| 831 | // make only the default ships available (we may need to move this depending on load a saved game) |
| 832 | PlayerResetShipPermissions(-1, true); |
| 833 | if (MenuNewGame()) { |
| 834 | exit_menu = 1; |
| 835 | MenuScene(); |
| 836 | rend_Flip(); |
| 837 | } |
| 838 | break; |
| 839 | case IDV_QUIT: |
| 840 | if (DoMessageBox(TXT_MENUQUIT, TXT_QUITMESSAGE, MSGBOX_YESNO)) { |
| 841 | exit_game = 1; |
| 842 | exit_menu = 1; |
| 843 | Mem_quick_exit = 1; // tell the mem library to not free up each chunk individually |
| 844 | } |
| 845 | break; |
| 846 | case IDV_LOADGAME: |
| 847 | SetGameMode(GM_NONE); |
| 848 | if (LoadGameDialog()) { |
| 849 | SetGameMode(GM_NORMAL); |
| 850 | SetFunctionMode(RESTORE_GAME_MODE); |
| 851 | exit_menu = 1; |
| 852 | } |
| 853 | break; |
| 854 | case IDV_OPTIONS: |
| 855 | main_menu.SetMusicRegion(OPTIONS_MUSIC_REGION); |
| 856 | OptionsMenu(); |
| 857 | break; |
| 858 | case IDV_PILOT: |
| 859 | main_menu.SetMusicRegion(OPTIONS_MUSIC_REGION); |
| 860 | DoWaitMessage(true); |
| 861 | PilotSelect(); |
| 862 | break; |
| 863 | case IDV_MULTIPLAYER: { |
| 864 | IsCheater = false; |
| 865 | main_menu.SetMusicRegion(MULTI_MUSIC_REGION); |
| 866 | mprintf(0, "Multiplayer!\n"); |
| 867 | // make all ships available |
| 868 | mprintf(0, "Making all ships available\n"); |
| 869 | for (int i = 0; i < MAX_SHIPS; i++) { |
| 870 | if (Ships[i].used) |
| 871 | PlayerSetShipPermission(-1, Ships[i].name, true); |
| 872 | } |
| 873 | if (MainMultiplayerMenu()) { |
| 874 | exit_menu = 1; |
| 875 | SetFunctionMode(GAME_MODE); |
| 876 | } |
| 877 | } break; |
| 878 | case IDV_PLAYDEMO: |
| 879 | if (LoadDemoDialog()) { |
| 880 | SetGameMode(GM_NORMAL); |
| 881 | SetFunctionMode(LOADDEMO_MODE); |
| 882 | exit_menu = 1; |
| 883 | } |
| 884 | break; |
| 885 | case IDV_CREDITS: |
| 886 | SetFunctionMode(CREDITS_MODE); |
| 887 | exit_menu = 1; |
| 888 | /* |
| 889 | #if defined(DEMO) |
| 890 | //extern void ShowStaticScreen(char *bitmap_filename); |
| 891 | ShowStaticScreen("democredits1.ogf"); |
| 892 | ShowStaticScreen("democredits2.ogf"); |
| 893 | #elif defined(OEM) |
| 894 | ShowStaticScreen("oemcredits1.ogf"); |
| 895 | ShowStaticScreen("oemcredits2.ogf"); |
| 896 | #else |
| 897 | // ShowStaticScreen("oemcredits1.ogf"); |
| 898 | // ShowStaticScreen("oemcredits2.ogf"); |
| 899 | #endif |
| 900 | */ |
| 901 | break; |
| 902 | #ifdef _DEBUG |
| 903 | case IDV_LOADLEVEL: { |
| 904 | if (MenuLoadLevel()) { |
| 905 | ShowProgressScreen(TXT_LOADINGLEVEL); |
| 906 | exit_menu = 1; |
| 907 | } |
| 908 | } break; |
| 909 | #endif |
| 910 | } |
| 911 | } |
| 912 | // close menu |
| 913 | main_menu.Close(); |
| 914 | main_menu.Destroy(); |
| 915 | // page in ui data. |
| 916 | newuiCore_ReleaseBitmaps(); |
| 917 | return exit_game ? 1 : 0; |
| 918 | } |
| 919 | // runs command line options. |
| 920 | bool ProcessCommandLine() { |
| 921 | int exit_menu = 0; |
| 922 | // Auto connect to a network game if the parm is there. |
| 923 | if ((!Auto_connected) && (TCP_active) && (FindArg("-url"))) { |
| 924 | Auto_connected = true; |
| 925 | int urlarg = FindArg("-url") + 1; |
| 926 | char szurl[200]; |
| 927 | char *p; |
| 928 | char *tokp; |
| 929 | strcpy(szurl, GameArgs[urlarg]); |
| 930 | #ifdef DEMO |
| 931 | szurl[strlen("d3demo2://") - 1] = '\0'; // Should make the string "d3demo:/" |
| 932 | p = szurl + strlen("d3demo2://"); // pointer to the first character of the url after the // |
| 933 | if (stricmp(szurl, "d3demo2:/") == 0) { |
| 934 | mprintf(0, "Got a url passed: %s\n", p); |
| 935 | } |
| 936 | #else |
| 937 | szurl[strlen("descent3://") - 1] = '\0'; // Should make the string "descent3:/" |
| 938 | p = szurl + strlen("descent3://"); // pointer to the first character of the url after the // |
| 939 | if (stricmp(szurl, "descent3:/") == 0) { |
| 940 | mprintf(0, "Got a url passed: %s\n", p); |
| 941 | } |
| 942 | #endif |
| 943 | tokp = strtok(p, "/"); |
| 944 | if (stricmp(tokp, "ip") == 0) { |
| 945 | tokp = strtok(NULL, "/"); |
| 946 | Auto_login_port[0] = '\0'; |
| 947 | strcpy(Auto_login_addr, tokp); |
| 948 | // char seldll[_MAX_PATH*2]; |
| 949 | // ddio_MakePath(seldll,Base_directory,"online","Direct TCP~IP Game.d3c",NULL); |
| 950 | if (LoadMultiDLL("Direct TCP~IP")) { |
| 951 | CallMultiDLL(MT_AUTO_LOGIN); |
| 952 | if (MultiDLLGameStarting) { |
| 953 | mprintf(0, "Successfully connected to server at specified url.\n"); |
| 954 | exit_menu = 1; |
| 955 | } else { |
| 956 | mprintf(0, "Couldn't connect to server at specified url.\n"); |
| 957 | } |
| 958 | } else { |
| 959 | mprintf(0, "Couldn't load DLL.\n"); |
| 960 | } |
| 961 | } else if (stricmp(tokp, "pxo") == 0) { |
| 962 | tokp = strtok(NULL, "/"); |
| 963 | Auto_login_port[0] = '\0'; |
| 964 | strcpy(Auto_login_addr, tokp); |
| 965 | // char seldll[_MAX_PATH*2]; |
| 966 | // ddio_MakePath(seldll,Base_directory,"online","parallax online.d3c",NULL); |
| 967 | if (LoadMultiDLL("parallax online")) { |
| 968 | CallMultiDLL(MT_AUTO_LOGIN); |
| 969 | if (MultiDLLGameStarting) { |
| 970 | mprintf(0, "Successfully connected to server at specified url.\n"); |
| 971 | exit_menu = 1; |
| 972 | } else { |
| 973 | mprintf(0, "Couldn't connect to server at specified url.\n"); |
| 974 | } |
| 975 | } else { |
| 976 | mprintf(0, "Couldn't load DLL.\n"); |
| 977 | } |
| 978 | } |
| 979 | } else if ((!Auto_connected) && (FindArg("-pxo"))) { |
| 980 | Auto_connected = true; |
| 981 | if (AutoConnectPXO()) { |
| 982 | exit_menu = 1; |
| 983 | } |
| 984 | } else if ((!Auto_connected) && (FindArg("-directip"))) { |
| 985 | Auto_connected = true; |
| 986 | if (AutoConnectLANIP()) { |
| 987 | exit_menu = 1; |
| 988 | } |
| 989 | } else if ((!Auto_connected) && (FindArg("-heat"))) { |
| 990 | Auto_connected = true; |
| 991 | if (AutoConnectHeat()) { |
| 992 | exit_menu = 1; |
| 993 | } |
| 994 | } |
| 995 | #ifndef OEM |
| 996 | else if ((!Auto_connected) && (FindArg("+connect"))) { |
| 997 | Auto_connected = true; |
| 998 | int connarg = FindArg("+connect"); |
| 999 | char connhost[300]; |
| 1000 | strcpy(connhost, GameArgs[connarg + 1]); |
| 1001 | char *port = strchr(connhost, ':'); |
| 1002 | if (port) { |
| 1003 | // terminate the hostname |
| 1004 | *port = '\0'; |
| 1005 | // Increment to the first character of the port name |
| 1006 | port++; |
| 1007 | // get the port number |
| 1008 | strcpy(Auto_login_port, port); |
| 1009 | } |
| 1010 | strcpy(Auto_login_addr, connhost); |
| 1011 | int trackedarg = FindArg("+cl_pxotrack"); |
| 1012 | if (trackedarg) { |
| 1013 | if (strcmp("1", GameArgs[trackedarg + 1]) == 0) { |
| 1014 | if (AutoConnectPXO()) { |
| 1015 | exit_menu = 1; |
| 1016 | } |
| 1017 | } else if (AutoConnectLANIP()) { |
| 1018 | exit_menu = 1; |
| 1019 | } |
| 1020 | } |
| 1021 | } |
| 1022 | #endif |
| 1023 | else if ((!Auto_connected) && (Directplay_lobby_launched_game)) { |
| 1024 | Auto_connected = true; |
| 1025 | #ifdef USE_DIRECTPLAY |
| 1026 | if (dp_AutoConnect()) { |
| 1027 | exit_menu = 1; |
| 1028 | } |
| 1029 | #else |
| 1030 | exit_menu = 1; |
| 1031 | #endif |
| 1032 | } |
| 1033 | #ifndef RELEASE |
| 1034 | int t = FindArg("-loadlevel"); |
| 1035 | if (t) { |
| 1036 | SimpleStartLevel(GameArgs[t + 1]); |
| 1037 | exit_menu = 1; |
| 1038 | } |
| 1039 | #endif |
| 1040 | // at some point the code above sets exit_menu, so we're going to game mode. |
| 1041 | if (exit_menu) { |
| 1042 | SetFunctionMode(GAME_MODE); |
| 1043 | } |
| 1044 | SetUICallback(DEFAULT_UICALLBACK); |
| 1045 | return exit_menu ? true : false; |
| 1046 | } |
| 1047 | ////////////////////////////////////////////////////////////////////////////// |
| 1048 | // Start New Game |
| 1049 | #define MSNDLG_WIDTH 512 |
| 1050 | #define MSNDLG_HEIGHT 384 |
| 1051 | #define MSNDLG_X (Max_window_w - MSNDLG_WIDTH) / 2 |
| 1052 | #define MSNDLG_Y (Max_window_h - MSNDLG_HEIGHT) / 2 |
| 1053 | #define MSNLB_WIDTH (MSNDLG_WIDTH - 64) |
| 1054 | #define MSNLB_HEIGHT (MSNDLG_HEIGHT - 160) |
| 1055 | #define MSNLB_X (MSNDLG_WIDTH - MSNLB_WIDTH) / 2 |
| 1056 | #define MSNLB_Y (MSNDLG_HEIGHT - MSNLB_HEIGHT) / 2 |
| 1057 | #define MSNBTN_W 96 |
| 1058 | #define MSNBTN_X ((MSNDLG_WIDTH / 4) - (MSNBTN_W / 2)) |
| 1059 | #define MSNBTN_X2 ((3 * MSNDLG_WIDTH / 4) - (MSNBTN_W / 2)) |
| 1060 | #define MSNBTN_Y (MSNDLG_HEIGHT - 64) |
| 1061 | #define UID_MSNLB 100 |
| 1062 | #define UID_MSNINFO 0x1000 |
| 1063 | #define TRAINING_MISSION_NAME "Pilot Training" |
| 1064 | static inline int count_missions(const char *pathname, const char *wildcard) { |
| 1065 | int c = 0; |
| 1066 | char fullpath[_MAX_PATH]; |
| 1067 | char filename[_MAX_PATH]; |
| 1068 | tMissionInfo msninfo; |
| 1069 | filename[0] = 0; |
| 1070 | ddio_MakePath(fullpath, pathname, wildcard, NULL); |
| 1071 | |
| 1072 | if (ddio_FindFileStart(fullpath, filename)) { |
| 1073 | do { |
| 1074 | const char *name; |
| 1075 | ddio_MakePath(fullpath, pathname, filename, NULL); |
| 1076 | |
| 1077 | if (stricmp("d3_2.mn3", filename) == 0) |
| 1078 | continue; |
| 1079 | mprintf(0, "Mission path:%s\n", fullpath); |
| 1080 | name = GetMissionName(filename); |
| 1081 | GetMissionInfo(filename, &msninfo); |
| 1082 | if (name && name[0] && msninfo.single) { |
| 1083 | mprintf(0, "Name:%s\n", name); |
| 1084 | c++; |
| 1085 | if (!(c % 2)) |
| 1086 | DoWaitMessage(true); |
| 1087 | } else { |
| 1088 | mprintf(0, "Illegal mission:%s\n", fullpath); |
| 1089 | } |
| 1090 | filename[0] = 0; |
| 1091 | } while (ddio_FindNextFile(filename)); |
| 1092 | ddio_FindFileClose(); |
| 1093 | } |
| 1094 | return c; |
| 1095 | } |
| 1096 | static inline int generate_mission_listbox(newuiListBox *lb, int n_maxfiles, char **filelist, const char *pathname, |
| 1097 | const char *wildcard) { |
| 1098 | int c = 0; |
| 1099 | char fullpath[_MAX_PATH]; |
| 1100 | char filename[_MAX_PATH]; |
| 1101 | ddio_MakePath(fullpath, pathname, wildcard, NULL); |
| 1102 | |
| 1103 | if (ddio_FindFileStart(fullpath, filename)) { |
| 1104 | do { |
| 1105 | tMissionInfo msninfo; |
| 1106 | if (n_maxfiles > c) { |
| 1107 | ddio_MakePath(fullpath, pathname, filename, NULL); |
| 1108 | if (stricmp("d3_2.mn3", filename) == 0) |
| 1109 | continue; |
| 1110 | if (GetMissionInfo(filename, &msninfo) && msninfo.name[0] && msninfo.single) { |
| 1111 | // if (!msninfo.training || (msninfo.training && Current_pilot.find_mission_data(TRAINING_MISSION_NAME)!= -1)) |
| 1112 | // { |
| 1113 | filelist[c] = mem_strdup(filename); |
| 1114 | lb->AddItem(msninfo.name); |
| 1115 | filename[0] = 0; |
| 1116 | c++; |
| 1117 | if (!(c % 2)) |
| 1118 | DoWaitMessage(true); |
| 1119 | //} |
| 1120 | } |
| 1121 | } |
| 1122 | } while (ddio_FindNextFile(filename)); |
| 1123 | ddio_FindFileClose(); |
| 1124 | } |
| 1125 | return c; |
| 1126 | } |
| 1127 | |
| 1128 | #define OEM_TRAINING_FILE "training.mn3" |
| 1129 | #define OEM_MISSION_FILE "d3oem.mn3" |
| 1130 | |
| 1131 | bool MenuNewGame() { |
| 1132 | newuiTiledWindow menu; |
| 1133 | newuiSheet *select_sheet; |
| 1134 | newuiListBox *msn_lb; |
| 1135 | char **filelist = nullptr; |
| 1136 | int n_missions, i, res; |
| 1137 | bool found = false; |
| 1138 | bool do_menu = true, load_mission = false, retval = true; |
| 1139 | #ifdef DEMO |
| 1140 | if (LoadMission("d3demo.mn3")) { |
| 1141 | CurrentPilotUpdateMissionStatus(true); |
| 1142 | // go into game mode. |
| 1143 | SetGameMode(GM_NORMAL); |
| 1144 | SetFunctionMode(GAME_MODE); |
| 1145 | return true; |
| 1146 | } else { |
| 1147 | DoMessageBox(TXT_ERROR, TXT_ERRLOADMSN, MSGBOX_OK); |
| 1148 | return false; |
| 1149 | } |
| 1150 | #else |
| 1151 | if ((!FindArg("-mission")) && (!FirstGame) && (-1 == Current_pilot.find_mission_data(TRAINING_MISSION_NAME))) { |
| 1152 | |
| 1153 | FirstGame = true; |
| 1154 | |
| 1155 | if (LoadMission("training.mn3")) { |
| 1156 | CurrentPilotUpdateMissionStatus(true); |
| 1157 | // go into game mode. |
| 1158 | SetGameMode(GM_NORMAL); |
| 1159 | SetFunctionMode(GAME_MODE); |
| 1160 | return true; |
| 1161 | } else { |
| 1162 | DoMessageBox(TXT_ERROR, TXT_ERRLOADMSN, MSGBOX_OK); |
| 1163 | return false; |
| 1164 | } |
| 1165 | } else if (FirstGame) { |
| 1166 | FirstGame = false; |
| 1167 | #ifdef OEM |
| 1168 | if (LoadMission(OEM_MISSION_FILE)) |
| 1169 | #else |
| 1170 | if (LoadMission("d3.mn3")) |
| 1171 | #endif |
| 1172 | { |
| 1173 | CurrentPilotUpdateMissionStatus(true); |
| 1174 | // go into game mode. |
| 1175 | SetGameMode(GM_NORMAL); |
| 1176 | SetFunctionMode(GAME_MODE); |
| 1177 | return true; |
| 1178 | } else { |
| 1179 | DoMessageBox(TXT_ERROR, TXT_ERRLOADMSN, MSGBOX_OK); |
| 1180 | return false; |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | // create menu. |
| 1185 | menu.Create(TXT_MENUNEWGAME, 0, 0, 448, 384); |
| 1186 | |
| 1187 | select_sheet = menu.GetSheet(); |
| 1188 | select_sheet->NewGroup(NULL, 10, 0); |
| 1189 | msn_lb = select_sheet->AddListBox(352, 256, UID_MSNLB); |
| 1190 | select_sheet->NewGroup(NULL, 160, 280, NEWUI_ALIGN_HORIZ); |
| 1191 | select_sheet->AddButton(TXT_OK, UID_OK); |
| 1192 | select_sheet->AddButton(TXT_CANCEL, UID_CANCEL); |
| 1193 | #ifndef OEM |
| 1194 | select_sheet->AddButton(TXT_MSNINFO, UID_MSNINFO); |
| 1195 | #endif |
| 1196 | #ifndef OEM |
| 1197 | // add mission names to listbox |
| 1198 | // count valid mission files. |
| 1199 | // add a please wait dialog here. |
| 1200 | n_missions = 0; |
| 1201 | #ifndef RELEASE |
| 1202 | n_missions = count_missions(LocalLevelsDir, "*.msn"); |
| 1203 | #endif |
| 1204 | n_missions += count_missions(D3MissionsDir, "*.mn3"); |
| 1205 | if (n_missions) { |
| 1206 | // allocate extra mission slot because of check below which adds a name to the filelist. |
| 1207 | filelist = (char **)mem_malloc(sizeof(char *) * (n_missions + 1)); |
| 1208 | for (i = 0; i < (n_missions + 1); i++) |
| 1209 | filelist[i] = NULL; |
| 1210 | } else { |
| 1211 | DoMessageBox(TXT_ERROR, TXT_NOMISSIONS, MSGBOX_OK); |
| 1212 | retval = false; |
| 1213 | DoWaitMessage(false); |
| 1214 | goto missions_fail; |
| 1215 | } |
| 1216 | // generate real listbox now. |
| 1217 | i = 0; |
| 1218 | #ifndef RELEASE |
| 1219 | i = generate_mission_listbox(msn_lb, n_missions, filelist, LocalLevelsDir, "*.msn"); |
| 1220 | #endif |
| 1221 | i += generate_mission_listbox(msn_lb, n_missions - i, filelist + i, D3MissionsDir, "*.mn3"); |
| 1222 | // #ifdef RELEASE |
| 1223 | int k; |
| 1224 | for (k = 0; k < n_missions; k++) { |
| 1225 | if (!filelist[k]) |
| 1226 | continue; |
| 1227 | if (stricmp(filelist[k], "d3.mn3") == 0) { |
| 1228 | found = true; |
| 1229 | break; |
| 1230 | } |
| 1231 | } |
| 1232 | if (!found) { |
| 1233 | filelist[n_missions] = mem_strdup("d3.mn3"); |
| 1234 | msn_lb->AddItem(TXT_MAINMISSION); |
| 1235 | n_missions++; |
| 1236 | } |
| 1237 | // #endif |
| 1238 | #else |
| 1239 | #define OEM_MISSION_NAME "Descent 3: Sol Ascent" |
| 1240 | #define OEM_TRAINING_NAME "Pilot Training " |
| 1241 | n_missions = 2; |
| 1242 | filelist = (char **)mem_malloc(sizeof(char *) * 2); |
| 1243 | filelist[0] = mem_strdup(OEM_MISSION_FILE); |
| 1244 | ; |
| 1245 | msn_lb->AddItem(OEM_MISSION_NAME); |
| 1246 | filelist[1] = mem_strdup(OEM_TRAINING_FILE); |
| 1247 | msn_lb->AddItem(OEM_TRAINING_NAME); |
| 1248 | #endif |
| 1249 | DoWaitMessage(false); |
| 1250 | redo_newgame_menu: |
| 1251 | // run menu |
| 1252 | menu.Open(); |
| 1253 | |
| 1254 | do { |
| 1255 | res = menu.DoUI(); |
| 1256 | #ifndef OEM |
| 1257 | if (res == UID_MSNINFO) { |
| 1258 | tMissionInfo msninfo; |
| 1259 | int index = msn_lb->GetCurrentIndex(); |
| 1260 | if (index >= 0 && index < n_missions) { |
| 1261 | if (GetMissionInfo(filelist[index], &msninfo)) { |
| 1262 | if (msninfo.name[0]) { |
| 1263 | newuiTiledWindow infownd; |
| 1264 | newuiSheet *sheet; |
| 1265 | infownd.Create(NULL, 0, 0, 384, 192); |
| 1266 | infownd.Open(); |
| 1267 | sheet = infownd.GetSheet(); |
| 1268 | sheet->NewGroup(TXT_MSNNAME, 0, 0); |
| 1269 | sheet->AddText(msninfo.name); |
| 1270 | sheet->NewGroup(TXT_MSNAUTHOR, 0, 32); |
| 1271 | if (msninfo.author[0]) |
| 1272 | sheet->AddText(msninfo.author); |
| 1273 | else |
| 1274 | sheet->AddText(TXT_NONE); |
| 1275 | sheet->NewGroup(TXT_MSNNOTES, 0, 64); |
| 1276 | if (msninfo.desc[0]) |
| 1277 | sheet->AddText(msninfo.desc); |
| 1278 | else |
| 1279 | sheet->AddText(TXT_NONE); |
| 1280 | sheet->NewGroup(NULL, 240, 118); |
| 1281 | sheet->AddButton(TXT_OK, UID_OK); |
| 1282 | infownd.DoUI(); |
| 1283 | infownd.Close(); |
| 1284 | infownd.Destroy(); |
| 1285 | } |
| 1286 | } |
| 1287 | } |
| 1288 | } |
| 1289 | #endif |
| 1290 | } while (res != UID_OK && res != UID_CANCEL && res != UID_MSNLB); |
| 1291 | menu.Close(); |
| 1292 | // check stuff |
| 1293 | if (res == UID_CANCEL) { |
| 1294 | retval = false; |
| 1295 | } else if (res == UID_OK || res == UID_MSNLB) { |
| 1296 | int index = msn_lb->GetCurrentIndex(); |
| 1297 | char *nameptr = NULL; |
| 1298 | if (index >= 0 && index < n_missions) { |
| 1299 | nameptr = filelist[index]; |
| 1300 | } |
| 1301 | #ifndef OEM |
| 1302 | if (!nameptr || !LoadMission(nameptr)) { |
| 1303 | #else |
| 1304 | if (!LoadMission(nameptr)) { |
| 1305 | #endif |
| 1306 | DoMessageBox(TXT_ERROR, TXT_ERRLOADMSN, MSGBOX_OK); |
| 1307 | retval = false; |
| 1308 | } else { |
| 1309 | // if we didn't escape out of any part of new game start, then go to game. |
| 1310 | int highest; |
| 1311 | CurrentPilotUpdateMissionStatus(true); |
| 1312 | // gets highest level flown for mission |
| 1313 | #if defined(_DEBUG) || defined(DAJ_DEBUG) |
| 1314 | highest = Current_mission.num_levels; |
| 1315 | #else |
| 1316 | highest = PilotGetHighestLevelAchieved(&Current_pilot, Current_mission.name); |
| 1317 | highest = std::min(highest + 1, Current_mission.num_levels); |
| 1318 | #endif |
| 1319 | if (highest > 1) { |
| 1320 | int start_level; |
| 1321 | start_level = DisplayLevelWarpDlg(highest); |
| 1322 | if (start_level == -1) { |
| 1323 | goto redo_newgame_menu; |
| 1324 | } else { |
| 1325 | Current_mission.cur_level = start_level; |
| 1326 | // pull out the ship permissions and use them |
| 1327 | Players[0].ship_permissions = GetPilotShipPermissions(&Current_pilot, Current_mission.name); |
| 1328 | } |
| 1329 | } |
| 1330 | // go into game mode. |
| 1331 | SetGameMode(GM_NORMAL); |
| 1332 | SetFunctionMode(GAME_MODE); |
| 1333 | retval = true; |
| 1334 | } |
| 1335 | } |
| 1336 | menu.Destroy(); |
| 1337 | missions_fail: |
| 1338 | // free all memory |
| 1339 | for (i = 0; i < n_missions; i++) { |
| 1340 | if (filelist[i]) { |
| 1341 | mem_free(filelist[i]); |
| 1342 | } |
| 1343 | } |
| 1344 | if (filelist) { |
| 1345 | mem_free(filelist); |
| 1346 | } |
| 1347 | return retval; |
| 1348 | #endif |
| 1349 | } |
| 1350 | // DisplayLevelWarpDlg |
| 1351 | // pass in the max level allowed to be chosen, if -1, than all levels are allowed (a.k.a level warp cheat) |
| 1352 | int DisplayLevelWarpDlg(int max_level) { |
| 1353 | newuiMessageBox hwnd; |
| 1354 | newuiSheet *sheet; |
| 1355 | int chosen_level = 1, res; |
| 1356 | int highest_allowed; |
| 1357 | char buffer[128]; |
| 1358 | char *input_text; |
| 1359 | // creates a sheet |
| 1360 | sheet = hwnd.GetSheet(); |
| 1361 | if (max_level != -1) { |
| 1362 | hwnd.Create(TXT_LEVELSELECT, MSGBOX_OKCANCEL); |
| 1363 | highest_allowed = max_level; |
| 1364 | snprintf(buffer, sizeof(buffer), TXT_LEVELSELECTB, highest_allowed); |
| 1365 | } else { |
| 1366 | // level warp |
| 1367 | hwnd.Create(TXT_LEVELWARP, MSGBOX_OKCANCEL); |
| 1368 | highest_allowed = Current_mission.num_levels; |
| 1369 | snprintf(buffer, sizeof(buffer), TXT_LEVELWARPB, Current_mission.num_levels); |
| 1370 | } |
| 1371 | sheet->NewGroup(buffer, 0, 0); |
| 1372 | input_text = sheet->AddEditBox(NULL, 4, 64, IDV_QUIT, UIED_NUMBERS); |
| 1373 | sprintf(input_text, "%d", chosen_level); |
| 1374 | redo_level_choose: |
| 1375 | hwnd.Open(); |
| 1376 | res = hwnd.DoUI(); |
| 1377 | hwnd.Close(); |
| 1378 | if (res == UID_OK || res == IDV_QUIT) { |
| 1379 | chosen_level = atoi(input_text); |
| 1380 | if (chosen_level < 1 || chosen_level > highest_allowed) { |
| 1381 | snprintf(buffer, sizeof(buffer), TXT_CHOOSELEVEL, highest_allowed); |
| 1382 | DoMessageBox(TXT_ERROR, buffer, MSGBOX_OK); |
| 1383 | goto redo_level_choose; |
| 1384 | } |
| 1385 | } else { |
| 1386 | chosen_level = -1; |
| 1387 | } |
| 1388 | hwnd.Destroy(); |
| 1389 | return chosen_level; |
| 1390 | } |
| 1391 | #ifdef _DEBUG |
| 1392 | // Loads a level and starts the game |
| 1393 | bool MenuLoadLevel(void) { |
| 1394 | char buffer[_MAX_PATH]; |
| 1395 | buffer[0] = '\0'; |
| 1396 | if (DoPathFileDialog(false, buffer, "Load Level", "*.d3l", PFDF_FILEMUSTEXIST)) { |
| 1397 | SimpleStartLevel(buffer); |
| 1398 | SetFunctionMode(GAME_MODE); |
| 1399 | return true; |
| 1400 | } |
| 1401 | return false; |
| 1402 | } |
| 1403 | #endif |