| 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/screens.cpp $ |
| 21 | * $Revision: 52 $ |
| 22 | * $Date: 10/21/99 9:29p $ |
| 23 | * $Author: Jeff $ |
| 24 | * |
| 25 | * |
| 26 | * |
| 27 | * $Log: /DescentIII/main/screens.cpp $ |
| 28 | * |
| 29 | * 52 10/21/99 9:29p Jeff |
| 30 | * B.A. Macintosh code merge |
| 31 | * |
| 32 | * 51 5/24/99 4:16a Jeff |
| 33 | * fixed screenshot bug for multiplayer |
| 34 | * |
| 35 | * 50 5/23/99 7:22p Samir |
| 36 | * flush keyboard and mouse when entering screen! |
| 37 | * |
| 38 | * 49 5/23/99 3:53a Samir |
| 39 | * fixed printscreen. |
| 40 | * |
| 41 | * 47 5/20/99 6:14p Kevin |
| 42 | * fixed mouse button to close PLR |
| 43 | * |
| 44 | * 46 5/11/99 6:33p Kevin |
| 45 | * fixed problem with sound being played as 3d and view position not being |
| 46 | * equal to the player position! Doh |
| 47 | * |
| 48 | * 45 5/07/99 5:38p Jeff |
| 49 | * use new multiplayer plr screen |
| 50 | * |
| 51 | * 44 5/07/99 2:51p Jason |
| 52 | * fixed a bunch of endlevel multiplayer issues |
| 53 | * |
| 54 | * 43 5/05/99 7:46p Kevin |
| 55 | * Fixed some post level results things |
| 56 | * |
| 57 | * 42 5/02/99 5:30p Kevin |
| 58 | * fixed shield and energy ratings. |
| 59 | * |
| 60 | * 41 4/30/99 3:03p Kevin |
| 61 | * improved times restored count |
| 62 | * |
| 63 | * 40 4/26/99 11:34a Samir |
| 64 | * wrap startframe and endframe around plrresults UI callback. |
| 65 | * |
| 66 | * 39 4/23/99 1:56a Matt |
| 67 | * Added system for counting kills of friendly objects |
| 68 | * |
| 69 | * 38 4/21/99 4:49p Kevin |
| 70 | * |
| 71 | * 37 4/20/99 8:58p Jeff |
| 72 | * included joystick.h so it compiles in Linux |
| 73 | * |
| 74 | * 36 4/20/99 2:34p Kevin |
| 75 | * multiplayer post level results will automatically go to the next level |
| 76 | * after 30 seconds so the client doesn't timeout in the reliable code. |
| 77 | * This number should never be higher than the timeout for the reliable |
| 78 | * networking code in networking.cpp (currently 2 minutes) |
| 79 | * |
| 80 | * 35 4/20/99 2:00p Kevin |
| 81 | * Improved post level results screens |
| 82 | * |
| 83 | * 34 4/20/99 12:45a Matt |
| 84 | * Use briefing font instead of HUD font for post-level results screen. |
| 85 | * |
| 86 | * 33 4/18/99 2:48p Kevin |
| 87 | * lock PLR at 30 fps |
| 88 | * |
| 89 | * 32 4/14/99 3:57a Jeff |
| 90 | * fixed case mismatch in #includes |
| 91 | * |
| 92 | * 31 4/07/99 12:41p Kevin |
| 93 | * New strings |
| 94 | * |
| 95 | * 30 4/07/99 12:31p Matt |
| 96 | * Added code for failed missions. |
| 97 | * |
| 98 | * 29 4/07/99 11:31a Kevin |
| 99 | * Added success/failure to Post level results |
| 100 | * |
| 101 | * 28 4/06/99 6:02p Matt |
| 102 | * Added score system |
| 103 | * |
| 104 | * 27 3/28/99 4:11p Kevin |
| 105 | * Fixed compiler warning |
| 106 | * |
| 107 | * 26 3/23/99 5:04p Kevin |
| 108 | * Post level results stuff. |
| 109 | * |
| 110 | * 25 3/23/99 12:33p Kevin |
| 111 | * More post level results improvements |
| 112 | * |
| 113 | * 24 3/22/99 7:02p Kevin |
| 114 | * New post level results screens.... not done. |
| 115 | * |
| 116 | * 23 3/09/99 6:36p Samir |
| 117 | * space bar to quit |
| 118 | * |
| 119 | * 22 2/15/99 9:17p Jeff |
| 120 | * table parse for plr screens |
| 121 | * |
| 122 | * 21 1/08/99 2:56p Samir |
| 123 | * Ripped out OSIRIS1. |
| 124 | * |
| 125 | * 20 10/22/98 10:50a Samir |
| 126 | * only register kill for robots so accuracy rating can be closer. |
| 127 | * |
| 128 | * 19 10/18/98 12:15p Jeff |
| 129 | * set multi_bail_ui_menu to false when starting PLR screen, else it bails |
| 130 | * immediatly |
| 131 | * |
| 132 | * 18 10/17/98 7:26p Samir |
| 133 | * destroy window after closing. |
| 134 | * |
| 135 | * 17 10/14/98 1:02p Jason |
| 136 | * fixed FindSoundName issues |
| 137 | * |
| 138 | * 16 10/07/98 12:08p Samir |
| 139 | * took out buttons. |
| 140 | * |
| 141 | * 15 10/02/98 5:46p Samir |
| 142 | * took out mission file objective text and replaced with level goals. |
| 143 | * |
| 144 | * 14 9/15/98 5:44p Jason |
| 145 | * more work on dedicated server |
| 146 | * |
| 147 | * 13 9/15/98 4:31p Jason |
| 148 | * added more functionality for the dedicated server |
| 149 | * |
| 150 | * 12 6/17/98 3:27p Jeff |
| 151 | * Changes made for localization |
| 152 | * |
| 153 | * 11 6/16/98 10:54a Jeff |
| 154 | * |
| 155 | * 10 6/11/98 1:56p Jeff |
| 156 | * use d3m files instead of dll |
| 157 | * |
| 158 | * 9 6/10/98 2:08p Samir |
| 159 | * multiplayer screens loaded. |
| 160 | * |
| 161 | * 8 5/25/98 8:19p Samir |
| 162 | * Added E3 speed demo to pass through screens. |
| 163 | * |
| 164 | * 7 5/15/98 2:22p Jeff |
| 165 | * Sets default colors for Post level results screen |
| 166 | * |
| 167 | * 6 5/14/98 5:27p Jason |
| 168 | * fixed some more sequencing bugs |
| 169 | * |
| 170 | * 5 5/14/98 3:18p Jason |
| 171 | * finished multiplayer sequencing issues |
| 172 | * |
| 173 | * 4 5/11/98 7:45p Samir |
| 174 | * hopefully fixed some flash in bugs. |
| 175 | * |
| 176 | * 3 4/18/98 7:18a Samir |
| 177 | * added level objectives text to result screen. |
| 178 | * |
| 179 | * 2 4/18/98 2:08a Samir |
| 180 | * update. |
| 181 | * |
| 182 | * 1 4/14/98 8:18p Samir |
| 183 | * initial revision. |
| 184 | * |
| 185 | * $NoKeywords: $ |
| 186 | */ |
| 187 | |
| 188 | #include "screens.h" |
| 189 | #include "newui.h" |
| 190 | #include "game.h" |
| 191 | #include "ddio.h" |
| 192 | #include "descent.h" |
| 193 | #include "application.h" |
| 194 | #include "gamefont.h" |
| 195 | #include "hlsoundlib.h" |
| 196 | #include "soundload.h" |
| 197 | #include "player.h" |
| 198 | #include "Mission.h" |
| 199 | #include "game2dll.h" |
| 200 | #include "stringtable.h" |
| 201 | #include "dedicated_server.h" |
| 202 | #include "levelgoal.h" |
| 203 | #include "sounds.h" |
| 204 | #include "pilot.h" |
| 205 | #include "joystick.h" |
| 206 | |
| 207 | #define LVLRES_FADEIN_TIME 0.50f |
| 208 | #define TEXT_REDRAW_COUNT 6.0f |
| 209 | #define LVLRES_STATS 7 |
| 210 | |
| 211 | /* |
| 212 | $$TABLE_GAMEFILE "mplvlr1.ogf" |
| 213 | $$TABLE_GAMEFILE "lvlres0.ogf" |
| 214 | $$TABLE_GAMEFILE "mplvlr2.ogf" |
| 215 | $$TABLE_GAMEFILE "lvlres1.ogf" |
| 216 | $$TABLE_GAMEFILE "mplvlr3.ogf" |
| 217 | $$TABLE_GAMEFILE "lvlres2.ogf" |
| 218 | */ |
| 219 | #define BACKGROUND_VIS 0 |
| 220 | #define OVERLAY_VIS 1 |
| 221 | |
| 222 | static int Stat_ratings[] = {TXI_SCRNNONE, TXI_SCRNFEEBLE, TXI_SCRNPOOR, TXI_SCRNAVG, |
| 223 | TXI_SCRNGOOD, TXI_SCRNEXCELLENT, TXI_SCRNSUPREME}; |
| 224 | |
| 225 | static struct { |
| 226 | int state; |
| 227 | float state_time, this_frame_time, last_frame_time; |
| 228 | |
| 229 | tLargeBitmap first_back; |
| 230 | tLargeBitmap glow_back; |
| 231 | tLargeBitmap shade_back; |
| 232 | |
| 233 | struct { |
| 234 | tLargeBitmap *bmp; |
| 235 | } vis_list[2]; |
| 236 | |
| 237 | int16_t time_min, time_sec; |
| 238 | float shield_rating, energy_rating; |
| 239 | float accuracy_rating; |
| 240 | } PLR; |
| 241 | |
| 242 | void PLResultsFrame(); |
| 243 | void PLResultsText(float draw_mag); |
| 244 | void PLResultsVisFrame(); |
| 245 | const char *GetNormalizedRating(float mag); |
| 246 | void PaintPLRSinglePlayerText(); |
| 247 | void SinglePlayerPostLevelResults(); |
| 248 | |
| 249 | static tLargeBitmap level_bmp; |
| 250 | bool background_loaded = false; |
| 251 | bool PLR_success = true; |
| 252 | |
| 253 | void PLResultsFrame() { |
| 254 | StartFrame(0, 0, Max_window_w, Max_window_h); |
| 255 | Sound_system.BeginSoundFrame(false); |
| 256 | // Right now we don't want you to do anything |
| 257 | if (background_loaded) |
| 258 | DrawLargeBitmap(&level_bmp, 0, 0, 1.0f); |
| 259 | // Call the DLL so it can do it's thing |
| 260 | if (Game_mode & GM_MULTI) { |
| 261 | CallGameDLL(EVT_CLIENT_GAMEPOSTLEVELRESULTS, &DLLInfo); |
| 262 | } else { |
| 263 | // Draw the text here |
| 264 | PaintPLRSinglePlayerText(); |
| 265 | } |
| 266 | grtext_Flush(); |
| 267 | Sound_system.EndSoundFrame(); |
| 268 | EndFrame(); |
| 269 | } |
| 270 | |
| 271 | float paint_start = 0.0f; |
| 272 | #define MAX_PLR_LINES 20 |
| 273 | bool val_printed[MAX_PLR_LINES]; |
| 274 | |
| 275 | int paint_in_sound_id = -1; |
| 276 | int paint_in_sound_handle = -1; |
| 277 | int chunk_sound_id = -1; |
| 278 | |
| 279 | #define MAX_PLR_FPS_TIME .033 |
| 280 | extern void DoScreenshot(); |
| 281 | bool PostLevelResults(bool success) { |
| 282 | PLR_success = success; |
| 283 | |
| 284 | if (Dedicated_server) |
| 285 | return true; |
| 286 | |
| 287 | paint_in_sound_id = FindSoundName("PPR paint in"); |
| 288 | chunk_sound_id = FindSoundName("PPR chunk"); |
| 289 | |
| 290 | float timelast = timer_GetTime(); |
| 291 | |
| 292 | int old_mode = GetScreenMode(); |
| 293 | SetScreenMode(SM_MENU); |
| 294 | SetUICallback(PLResultsFrame); |
| 295 | ui_HideCursor(); |
| 296 | ddio_KeyFlush(); |
| 297 | ddio_MouseQueueFlush(); |
| 298 | |
| 299 | // Do the multiplayer stuff |
| 300 | if (Game_mode & GM_MULTI) { |
| 301 | // Draw the background |
| 302 | if (!LoadLargeBitmap("mplvlr.ogf", &level_bmp)) |
| 303 | Error("Unable to load %s.", "mplvlr.ogf"); |
| 304 | else |
| 305 | background_loaded = true; |
| 306 | |
| 307 | // Play a sound |
| 308 | Sound_system.Play2dSound(SOUND_LIGHTNING); |
| 309 | |
| 310 | float start_time = timer_GetTime(); |
| 311 | float time_to_wait; |
| 312 | |
| 313 | if (Netgame.local_role == LR_SERVER) |
| 314 | time_to_wait = 10; |
| 315 | else |
| 316 | time_to_wait = 15; |
| 317 | |
| 318 | while ((timer_GetTime() - start_time) < time_to_wait) { |
| 319 | Multi_bail_ui_menu = 0; |
| 320 | Descent->defer(); |
| 321 | DoUIFrame(); |
| 322 | rend_Flip(); |
| 323 | GetUIFrameResult(); |
| 324 | } |
| 325 | |
| 326 | int keypressed = ddio_KeyInKey(); |
| 327 | if (keypressed == KEY_PRINT_SCREEN) { |
| 328 | DoScreenshot(); |
| 329 | } |
| 330 | ddio_KeyFlush(); |
| 331 | } else { |
| 332 | // Do the single player stuff |
| 333 | if (!background_loaded) { |
| 334 | if (LoadLargeBitmap("multimain.ogf", &level_bmp)) { |
| 335 | background_loaded = true; |
| 336 | } |
| 337 | SinglePlayerPostLevelResults(); |
| 338 | float start_time = timer_GetTime(); |
| 339 | float time_to_wait = 2; |
| 340 | |
| 341 | while ((timer_GetTime() - start_time) < time_to_wait) { |
| 342 | while ((timer_GetTime() - timelast) < MAX_PLR_FPS_TIME) { |
| 343 | Descent->delay(0); |
| 344 | } |
| 345 | timelast = timer_GetTime(); |
| 346 | |
| 347 | Descent->defer(); |
| 348 | DoUIFrame(); |
| 349 | rend_Flip(); |
| 350 | GetUIFrameResult(); |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | bool rval = true; |
| 356 | float max_wait_time = 10; |
| 357 | float start_time = timer_GetTime(); |
| 358 | // Wait for input and move on |
| 359 | while (Netgame.local_role != LR_SERVER) { |
| 360 | if (Game_mode & GM_MULTI) { |
| 361 | if ((timer_GetTime() - start_time) > max_wait_time) { |
| 362 | break; |
| 363 | } |
| 364 | } |
| 365 | while ((timer_GetTime() - timelast) < MAX_PLR_FPS_TIME) { |
| 366 | Descent->delay(0); |
| 367 | } |
| 368 | timelast = timer_GetTime(); |
| 369 | |
| 370 | Multi_bail_ui_menu = 0; |
| 371 | Descent->defer(); |
| 372 | int x, y, dx, dy; |
| 373 | if (ddio_MouseGetState(&x, &y, &dx, &dy)) { |
| 374 | rval = true; |
| 375 | break; |
| 376 | } |
| 377 | |
| 378 | DoUIFrame(); |
| 379 | rend_Flip(); |
| 380 | GetUIFrameResult(); |
| 381 | |
| 382 | int key = ddio_KeyInKey(); |
| 383 | |
| 384 | tJoyPos jp; |
| 385 | joy_GetPos((tJoystick)JOYSTICK_1, &jp); |
| 386 | if (jp.buttons) { |
| 387 | rval = true; |
| 388 | break; |
| 389 | } |
| 390 | |
| 391 | if ((key == KEY_ENTER) || (key == KEY_SPACEBAR)) { |
| 392 | rval = true; |
| 393 | break; |
| 394 | } else if (key == KEY_ESC) { |
| 395 | rval = false; |
| 396 | break; |
| 397 | } else if (key == KEY_PRINT_SCREEN) { |
| 398 | DoScreenshot(); |
| 399 | } |
| 400 | #ifndef RELEASE |
| 401 | else if (key == KEY_R) { |
| 402 | paint_start = timer_GetTime(); |
| 403 | for (int a = 0; a < MAX_PLR_LINES; a++) { |
| 404 | val_printed[a] = false; |
| 405 | } |
| 406 | if (paint_in_sound_handle != -1) { |
| 407 | Sound_system.StopSoundImmediate(paint_in_sound_handle); |
| 408 | paint_in_sound_handle = -1; |
| 409 | } |
| 410 | if (paint_in_sound_id != -1) { |
| 411 | paint_in_sound_handle = Sound_system.Play3dSound(paint_in_sound_id, &Objects[Players[Player_num].objnum]); |
| 412 | } |
| 413 | } |
| 414 | #endif |
| 415 | } |
| 416 | |
| 417 | if (background_loaded) |
| 418 | FreeLargeBitmap(&level_bmp); |
| 419 | |
| 420 | ui_ShowCursor(); |
| 421 | background_loaded = false; |
| 422 | SetScreenMode(old_mode); |
| 423 | SetUICallback(NULL); |
| 424 | return rval; |
| 425 | } |
| 426 | |
| 427 | #define PLR_COLS 100 |
| 428 | |
| 429 | char PLRHeader[PLR_COLS]; |
| 430 | char PLRLevel[PLR_COLS]; |
| 431 | |
| 432 | char PLRText[MAX_PLR_LINES][PLR_COLS]; |
| 433 | char PLRVal[MAX_PLR_LINES][PLR_COLS]; |
| 434 | |
| 435 | extern int Times_game_restored; |
| 436 | |
| 437 | void SinglePlayerPostLevelResults() { |
| 438 | const char *difficulty_levels[] = {TXT_TRAINEE, TXT_ROOKIE, TXT_HOTSHOT, TXT_ACE, TXT_INSANE}; |
| 439 | |
| 440 | // Setup all the text to display |
| 441 | // Initialize all the characters |
| 442 | |
| 443 | if (paint_in_sound_id != -1) { |
| 444 | paint_in_sound_handle = Sound_system.Play2dSound(paint_in_sound_id, (float)1.0); |
| 445 | } |
| 446 | |
| 447 | memset(PLRText, 0, sizeof(PLRText)); |
| 448 | memset(PLRVal, 0, sizeof(PLRVal)); |
| 449 | for (int a = 0; a < MAX_PLR_LINES; a++) { |
| 450 | val_printed[a] = false; |
| 451 | } |
| 452 | paint_start = timer_GetTime(); |
| 453 | |
| 454 | int curline = 0; |
| 455 | int j; |
| 456 | PLR.time_min = (int16_t)Players[Player_num].time_level / 60.0f; |
| 457 | PLR.time_sec = (int16_t)(Players[Player_num].time_level - ((float)PLR.time_min * 60.0f)); |
| 458 | PLR.shield_rating = Objects[Players[Player_num].objnum].shields; |
| 459 | PLR.energy_rating = Players[Player_num].energy; |
| 460 | if (Players[Player_num].num_discharges_level > 0) |
| 461 | PLR.accuracy_rating = (float)Players[Player_num].num_hits_level / (float)Players[Player_num].num_discharges_level; |
| 462 | else |
| 463 | PLR.accuracy_rating = 0.5f; |
| 464 | |
| 465 | // strcpy(PLRHeader,PLR_success?"Mission Successfull":"Mission Failed"); |
| 466 | strcpy(PLRHeader, PLR_success ? TXT_PLR_MSN_SUCCESS : TXT_PLR_MSN_FAILED); |
| 467 | |
| 468 | snprintf(PLRLevel, sizeof(PLRLevel), "%s", Level_info.name); |
| 469 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_PLTDIFFICULT); |
| 470 | uint8_t dif; |
| 471 | Current_pilot.get_difficulty(&dif); |
| 472 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%s", difficulty_levels[dif]); |
| 473 | curline++; |
| 474 | curline++; |
| 475 | |
| 476 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_SCORE); |
| 477 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%d", Players[Player_num].score); |
| 478 | curline++; |
| 479 | curline++; |
| 480 | |
| 481 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_PLRTIME); |
| 482 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%d:%.2d", PLR.time_min, PLR.time_sec); |
| 483 | curline++; |
| 484 | curline++; |
| 485 | |
| 486 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_PLRENEMIESKILL); |
| 487 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%d", Players[Player_num].num_kills_level); |
| 488 | curline++; |
| 489 | curline++; |
| 490 | |
| 491 | if (Players[Player_num].friendly_kills_level) { |
| 492 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_PLRFRIENDSKILL); |
| 493 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%d", Players[Player_num].friendly_kills_level); |
| 494 | curline++; |
| 495 | curline++; |
| 496 | } |
| 497 | |
| 498 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_PLRSHIELD); |
| 499 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%.0f", PLR.shield_rating); |
| 500 | curline++; |
| 501 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_PLRENERGY); |
| 502 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%.0f", PLR.energy_rating); |
| 503 | curline++; |
| 504 | curline++; |
| 505 | |
| 506 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_NUMDEATHS); |
| 507 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%d", Players[Player_num].num_deaths_level); |
| 508 | curline++; |
| 509 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_PLRSAVERESRAT); |
| 510 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%d", Times_game_restored); |
| 511 | curline++; |
| 512 | curline++; |
| 513 | |
| 514 | bool has_objectives = false; |
| 515 | for (j = 0; (j < Level_goals.GetNumGoals()) && (curline < MAX_PLR_LINES); j++) { |
| 516 | int goal_status; |
| 517 | |
| 518 | if (Level_goals.GoalStatus(j, LO_GET_SPECIFIED, &goal_status)) { |
| 519 | if ((goal_status & LGF_ENABLED) && (goal_status & LGF_TELCOM_LISTS)) { |
| 520 | has_objectives = true; |
| 521 | break; |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | if (has_objectives) { |
| 527 | snprintf(PLRText[curline], sizeof(PLRText[curline]), "%s", TXT_OBJECTIVES1); |
| 528 | curline++; |
| 529 | curline++; |
| 530 | } |
| 531 | |
| 532 | for (j = 0; (j < Level_goals.GetNumGoals()) && (curline < MAX_PLR_LINES); j++) { |
| 533 | int goal_status; |
| 534 | |
| 535 | if (Level_goals.GoalStatus(j, LO_GET_SPECIFIED, &goal_status)) { |
| 536 | if ((goal_status & LGF_ENABLED) && (goal_status & LGF_TELCOM_LISTS)) |
| 537 | // if(goal_status & LGF_ENABLED) |
| 538 | { |
| 539 | char txt[64]; |
| 540 | Level_goals.GoalGetName(j, txt, sizeof(txt)); |
| 541 | if (goal_status & LGF_COMPLETED) { |
| 542 | snprintf(PLRText[curline], sizeof(PLRText[curline]), " %s:", txt); |
| 543 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%s", TXT_COMPLETED); |
| 544 | } else { |
| 545 | snprintf(PLRText[curline], sizeof(PLRText[curline]), " %s:", txt); |
| 546 | snprintf(PLRVal[curline], sizeof(PLRVal[curline]), "%s", TXT_NOTCOMPLETEDYET); |
| 547 | } |
| 548 | curline++; |
| 549 | } |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | #define PLR_PAINT_TIME .8 // Seconds it takes to paint the text across the screen |
| 555 | #define PLR_START_VAL_TIME 2.0 |
| 556 | #define PLR_VAL_INTERVAL .20 |
| 557 | |
| 558 | int paint_progress = 0; |
| 559 | |
| 560 | #define PLR_VALUE_TOP 125 |
| 561 | |
| 562 | int line_progress[MAX_PLR_LINES]; // This is where we currently are |
| 563 | char line_replace[MAX_PLR_LINES]; // The character we replaced with a NULL. Draw this bright |
| 564 | |
| 565 | void PaintPLRSinglePlayerText() { |
| 566 | |
| 567 | const int TEXT_HEIGHT = 14; |
| 568 | const int LEFT_COL = 50; |
| 569 | const int RIGHT_COL = 450; |
| 570 | char hi[3] = "\0\0"; |
| 571 | |
| 572 | #define PLR_TXT_HEADER TXT_PLRTITLE |
| 573 | int i; |
| 574 | |
| 575 | // Put everything back where it was... |
| 576 | for (i = 0; i < MAX_PLR_LINES; i++) { |
| 577 | if (line_replace[i]) { |
| 578 | PLRText[i][line_progress[i]] = line_replace[i]; |
| 579 | } |
| 580 | line_progress[i] = 0; |
| 581 | line_replace[i] = 0; |
| 582 | } |
| 583 | |
| 584 | paint_progress = 25 * ((timer_GetTime() - paint_start) / PLR_PAINT_TIME); |
| 585 | |
| 586 | bool all_done_painting = true; |
| 587 | |
| 588 | for (i = 0; i < MAX_PLR_LINES; i++) { |
| 589 | int curpos = paint_progress + (-2 * i); |
| 590 | if (curpos < 0) |
| 591 | curpos = 0; |
| 592 | int tlen = strlen(PLRText[i]); |
| 593 | if (tlen > curpos) { |
| 594 | line_progress[i] = curpos; |
| 595 | line_replace[i] = PLRText[i][curpos]; |
| 596 | PLRText[i][curpos] = '\0'; |
| 597 | all_done_painting = false; |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | if (all_done_painting) { |
| 602 | if (paint_in_sound_handle != -1) { |
| 603 | mprintf(0, "Stopping paint in sound\n"); |
| 604 | Sound_system.StopSoundImmediate(paint_in_sound_handle); |
| 605 | paint_in_sound_handle = -1; |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | grtext_SetAlpha(255); |
| 610 | |
| 611 | grtext_SetFlags(GRTEXTFLAG_SHADOW); |
| 612 | |
| 613 | grtext_SetColor(UICOL_TEXT_NORMAL); |
| 614 | grtext_SetFont(BIG_BRIEFING_FONT); |
| 615 | int centerx = (Max_window_w / 2) - (grtext_GetTextLineWidth(PLR_TXT_HEADER) / 2); |
| 616 | if (centerx < 0) |
| 617 | centerx = 0; |
| 618 | grtext_Printf(centerx, 30, PLR_TXT_HEADER); |
| 619 | |
| 620 | grtext_SetColor(UICOL_WINDOW_TITLE); |
| 621 | centerx = (Max_window_w / 2) - (grtext_GetTextLineWidth(PLRLevel) / 2); |
| 622 | if (centerx < 0) |
| 623 | centerx = 0; |
| 624 | grtext_Printf(centerx, 55, PLRLevel); |
| 625 | |
| 626 | centerx = (Max_window_w / 2) - (grtext_GetTextLineWidth(PLRHeader) / 2); |
| 627 | if (centerx < 0) |
| 628 | centerx = 0; |
| 629 | grtext_Printf(centerx, 80, PLRHeader); |
| 630 | |
| 631 | grtext_SetFont(BRIEFING_FONT); |
| 632 | int adjusted_line_no = 0; |
| 633 | // depending on where we are paint part or all of the text. |
| 634 | for (i = 0; i < MAX_PLR_LINES; i++) { |
| 635 | // This way we paint the values at better interval |
| 636 | if (*PLRVal[i]) |
| 637 | adjusted_line_no++; |
| 638 | |
| 639 | grtext_SetAlpha(255); |
| 640 | grtext_SetColor(UICOL_TEXT_NORMAL); |
| 641 | grtext_Printf(LEFT_COL, (TEXT_HEIGHT * i) + PLR_VALUE_TOP, PLRText[i]); |
| 642 | if (line_replace[i] && (line_progress[i] > 0)) { |
| 643 | grtext_SetAlpha(64); |
| 644 | hi[0] = line_replace[i]; |
| 645 | grtext_Printf(LEFT_COL + grtext_GetTextLineWidth(PLRText[i]), (TEXT_HEIGHT * i) + PLR_VALUE_TOP, hi); |
| 646 | } |
| 647 | grtext_SetAlpha(255); |
| 648 | float now = timer_GetTime(); |
| 649 | if ((now - paint_start) > (PLR_START_VAL_TIME + (adjusted_line_no * PLR_VAL_INTERVAL))) { |
| 650 | if (!val_printed[i]) { |
| 651 | if ((chunk_sound_id != -1) && (*PLRVal[i])) |
| 652 | Sound_system.Play2dSound(chunk_sound_id, (float)1.0); |
| 653 | } |
| 654 | val_printed[i] = true; |
| 655 | grtext_SetColor(UICOL_WINDOW_TITLE); |
| 656 | grtext_Printf(RIGHT_COL, (TEXT_HEIGHT * i) + PLR_VALUE_TOP, PLRVal[i]); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | grtext_SetAlpha(255); |
| 661 | grtext_SetColor(UICOL_WINDOW_TITLE); |
| 662 | centerx = (Max_window_w / 2) - (grtext_GetTextLineWidth(TXT_HITAKEYORBUTTON) / 2); |
| 663 | if (centerx < 0) |
| 664 | centerx = 0; |
| 665 | grtext_Printf(centerx, Max_window_h - (TEXT_HEIGHT * 1.2), TXT_HITAKEYORBUTTON); |
| 666 | } |
| 667 | |
| 668 | /* |
| 669 | |
| 670 | const char *GetNormalizedRating(float mag) |
| 671 | { |
| 672 | int rating; |
| 673 | |
| 674 | // determine rating. |
| 675 | rating = (int)(mag*5.0f); |
| 676 | |
| 677 | if (rating < 0) |
| 678 | rating = 0; |
| 679 | else if (rating >= LVLRES_STATS) |
| 680 | rating = LVLRES_STATS-1; |
| 681 | |
| 682 | return TXT(Stat_ratings[rating]); |
| 683 | } |
| 684 | |
| 685 | */ |