OPTIONS.CPP (57108B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/OPTIONS.CPP 1 3/03/97 10:25a Joe_bostic $ */ 17 /*********************************************************************************************** 18 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : OPTIONS.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : June 8, 1994 * 28 * * 29 * Last Update : July 30, 1996 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * OptionsClass::Adjust_Palette -- Adjusts the palette according to the settings specified. * 34 * OptionsClass::Fixup_Palette -- Adjusts the real palette to match the palette sliders. * 35 * OptionsClass::Get_Brightness -- Fetches the current brightness setting. * 36 * OptionsClass::Get_Contrast -- Gets the current contrast setting. * 37 * OptionsClass::Get_Game_Speed -- Fetches the current game speed setting. * 38 * OptionsClass::Get_Saturation -- Fetches the current color setting. * 39 * OptionsClass::Get_Scroll_Rate -- Fetches the current scroll rate setting. * 40 * OptionsClass::Get_Tint -- Fetches the current tint setting. * 41 * OptionsClass::Load_Settings -- reads options settings from the INI file * 42 * OptionsClass::Normalize_Delay -- Normalizes delay factor to keep rate constant. * 43 * OptionsClass::Normalize_Volume -- Convert to a real volume value. * 44 * OptionsClass::One_Time -- This performs any one time initialization for the options class.* 45 * OptionsClass::OptionsClass -- The default constructor for the options class. * 46 * OptionsClass::Process -- Handles all the options graphic interface. * 47 * OptionsClass::Save_Settings -- writes options settings to the INI file * 48 * OptionsClass::Set -- Sets options based on current settings * 49 * OptionsClass::Set_Brightness -- Sets the brightness level to that specified. * 50 * OptionsClass::Set_Contrast -- Sets the contrast to the value specified. * 51 * OptionsClass::Set_Game_Speed -- Sets the game speed as specified. * 52 * OptionsClass::Set_Repeat -- Controls the score repeat option. * 53 * OptionsClass::Set_Saturation -- Sets the color to the value specified. * 54 * OptionsClass::Set_Score_Volume -- Sets the global score volume to that specified. * 55 * OptionsClass::Set_Scroll_Rate -- Sets the scroll rate as specified. * 56 * OptionsClass::Set_Shuffle -- Controls the play shuffle setting. * 57 * OptionsClass::Set_Sound_Volume -- Sets the sound effects volume level. * 58 * OptionsClass::Set_Tint -- Sets the tint setting. * 59 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 60 61 #include "function.h" 62 #include "options.h" 63 64 65 #ifdef WIN32 66 char const * const OptionsClass::HotkeyName = "WinHotkeys"; 67 #else 68 char const * const OptionsClass::HotkeyName = "DOSHotkeys"; 69 #endif 70 71 72 /*********************************************************************************************** 73 * OptionsClass::OptionsClass -- The default constructor for the options class. * 74 * * 75 * This is the constructor for the options class. It handles setting up all the globals * 76 * necessary for the options. This includes setting them to their default state. * 77 * * 78 * INPUT: none * 79 * * 80 * OUTPUT: none * 81 * * 82 * WARNINGS: none * 83 * * 84 * HISTORY: * 85 * 07/21/1994 JLB : Created. * 86 *=============================================================================================*/ 87 OptionsClass::OptionsClass(void) : 88 GameSpeed(3), 89 ScrollRate(3), 90 #ifdef WIN32 91 Volume(".40"), // was .295 92 ScoreVolume(".25"), 93 #ifdef FIXIT_VERSION_3 94 MultiScoreVolume("0"), 95 #endif 96 #else 97 Volume(".8"), 98 ScoreVolume(".6"), 99 #endif 100 Brightness(fixed::_1_2), 101 Tint(fixed::_1_2), 102 Saturation(fixed::_1_2), 103 Contrast(fixed::_1_2), 104 AutoScroll(true), 105 IsScoreRepeat(false), 106 IsScoreShuffle(false), 107 IsPaletteScroll(true), 108 109 KeyForceMove1(KN_LALT), 110 KeyForceMove2(KN_RALT), 111 KeyForceAttack1(KN_LCTRL), 112 KeyForceAttack2(KN_RCTRL), 113 KeySelect1(KN_LSHIFT), 114 KeySelect2(KN_RSHIFT), 115 KeyScatter(KN_X), 116 KeyStop(KN_S), 117 KeyGuard(KN_G), 118 KeyNext(KN_N), 119 KeyPrevious(KN_B), 120 KeyFormation(KN_F), 121 KeyHome1(KN_HOME), 122 KeyHome2(KN_E_HOME), 123 KeyBase(KN_H), 124 KeyResign(KN_R), 125 KeyAlliance(KN_A), 126 KeyBookmark1(KN_F9), 127 KeyBookmark2(KN_F10), 128 KeyBookmark3(KN_F11), 129 KeyBookmark4(KN_F12), 130 KeySelectView(KN_E), 131 KeyRepair(KN_T), 132 KeyRepairOn(KN_NONE), 133 KeyRepairOff(KN_NONE), 134 KeySell(KN_Y), 135 KeySellOn(KN_NONE), 136 KeySellOff(KN_NONE), 137 KeyMap(KN_U), 138 KeySidebarUp(KN_UP), 139 KeySidebarDown(KN_DOWN), 140 KeyOption1(KN_ESC), 141 KeyOption2(KN_SPACE), 142 KeyScrollLeft(KN_NONE), 143 KeyScrollRight(KN_NONE), 144 KeyScrollUp(KN_NONE), 145 KeyScrollDown(KN_NONE), 146 KeyQueueMove1(KN_Q), 147 KeyQueueMove2(KN_Q), 148 KeyTeam1(KN_1), 149 KeyTeam2(KN_2), 150 KeyTeam3(KN_3), 151 KeyTeam4(KN_4), 152 KeyTeam5(KN_5), 153 KeyTeam6(KN_6), 154 KeyTeam7(KN_7), 155 KeyTeam8(KN_8), 156 KeyTeam9(KN_9), 157 KeyTeam10(KN_0) 158 { 159 } 160 161 162 /*********************************************************************************************** 163 * OptionsClass::One_Time -- This performs any one time initialization for the options class. * 164 * * 165 * This routine should be called only once and it will perform any initializations for the * 166 * options class that is needed. This may include things like file loading and memory * 167 * allocation. * 168 * * 169 * INPUT: none * 170 * * 171 * OUTPUT: none * 172 * * 173 * WARNINGS: Only call this routine once. * 174 * * 175 * HISTORY: * 176 * 07/21/1994 JLB : Created. * 177 *=============================================================================================*/ 178 void OptionsClass::One_Time(void) 179 { 180 Set_Score_Vol(ScoreVolume * 256); 181 } 182 183 184 /*********************************************************************************************** 185 * OptionsClass::Process -- Handles all the options graphic interface. * 186 * * 187 * This routine is the main control for the visual representation of the options * 188 * screen. It handles the visual overlay and the player input. * 189 * * 190 * INPUT: none * 191 * * 192 * OUTPUT: none * 193 * * 194 * WARNINGS: none * 195 * * 196 * HISTORY: * 197 * 07/21/1994 JLB : Created. * 198 *=============================================================================================*/ 199 void OptionsClass::Process(void) 200 { 201 } 202 203 204 /*********************************************************************************************** 205 * OptionsClass::Set_Shuffle -- Controls the play shuffle setting. * 206 * * 207 * This routine will control the score shuffle flag. The setting to use is provided as * 208 * a parameter. When shuffling is on, the score play order is scrambled. * 209 * * 210 * INPUT: on -- Should the shuffle option be activated? * 211 * * 212 * OUTPUT: none * 213 * * 214 * WARNINGS: none * 215 * * 216 * HISTORY: * 217 * 01/19/1995 JLB : Created. * 218 *=============================================================================================*/ 219 void OptionsClass::Set_Shuffle(int on) 220 { 221 IsScoreShuffle = on; 222 } 223 224 225 /*********************************************************************************************** 226 * OptionsClass::Set_Repeat -- Controls the score repeat option. * 227 * * 228 * This routine is used to control whether scores repeat or not. The setting to use for * 229 * the repeat flag is provided as a parameter. * 230 * * 231 * INPUT: on -- Should the scores repeat? * 232 * * 233 * OUTPUT: none * 234 * * 235 * WARNINGS: none * 236 * * 237 * HISTORY: * 238 * 01/19/1995 JLB : Created. * 239 *=============================================================================================*/ 240 void OptionsClass::Set_Repeat(int on) 241 { 242 IsScoreRepeat = on; 243 } 244 245 246 /*********************************************************************************************** 247 * OptionsClass::Set_Score_Volume -- Sets the global score volume to that specified. * 248 * * 249 * This routine will set the global score volume to the value specified. The value ranges * 250 * from zero to 255. * 251 * * 252 * INPUT: volume -- The new volume setting to use for scores. * 253 * * 254 * feedback -- Should a feedback sound effect be generated? * 255 * * 256 * OUTPUT: none * 257 * * 258 * WARNINGS: none * 259 * * 260 * HISTORY: * 261 * 01/19/1995 JLB : Created. * 262 *=============================================================================================*/ 263 void OptionsClass::Set_Score_Volume(fixed volume, bool feedback) 264 { 265 ScoreVolume = Sub_Saturate(volume, 1); 266 Set_Score_Vol(ScoreVolume * 256); 267 if (feedback && !Theme.Still_Playing()) { 268 Sound_Effect(VOC_BEEP, ScoreVolume); 269 } 270 } 271 272 273 /*********************************************************************************************** 274 * OptionsClass::Set_Sound_Volume -- Sets the sound effects volume level. * 275 * * 276 * This routine will set the sound effect volume level as indicated. It can generate a * 277 * sound effect for feedback purposes if desired. The volume setting can range from zero * 278 * to 255. The value of 255 is the loudest. * 279 * * 280 * INPUT: volume -- The volume setting to use for the new value. 0 to 255. * 281 * * 282 * feedback -- Should a feedback sound effect be generated? * 283 * * 284 * OUTPUT: none * 285 * * 286 * WARNINGS: none * 287 * * 288 * HISTORY: * 289 * 01/19/1995 JLB : Created. * 290 *=============================================================================================*/ 291 void OptionsClass::Set_Sound_Volume(fixed volume, bool feedback) 292 { 293 Volume = Sub_Saturate(volume, 1); 294 if (feedback) { 295 Sound_Effect(VOC_BEEP); 296 } 297 } 298 299 300 /*********************************************************************************************** 301 * OptionsClass::Set_Brightness -- Sets the brightness level to that specified. * 302 * * 303 * This routine will set the current brightness level to the value specified. This value * 304 * can range from zero to 255, with 128 being the normal (default) brightness level. * 305 * * 306 * INPUT: brightness -- The brightness level to set as current. * 307 * * 308 * OUTPUT: none * 309 * * 310 * WARNINGS: none * 311 * * 312 * HISTORY: * 313 * 01/19/1995 JLB : Created. * 314 *=============================================================================================*/ 315 void OptionsClass::Set_Brightness(fixed brightness) 316 { 317 Brightness = fixed::_1_4 + (fixed::_1_2 * brightness); 318 Adjust_Palette(OriginalPalette, InGamePalette, Brightness, Saturation, Tint, Contrast); 319 InGamePalette.Set(); 320 } 321 322 323 /*********************************************************************************************** 324 * OptionsClass::Get_Brightness -- Fetches the current brightness setting. * 325 * * 326 * This routine will fetch the current setting for the brightness level. The value ranges * 327 * from zero to 255, with 128 being the normal (default) value. * 328 * * 329 * INPUT: none * 330 * * 331 * OUTPUT: Returns with the current brightness setting. * 332 * * 333 * WARNINGS: none * 334 * * 335 * HISTORY: * 336 * 01/19/1995 JLB : Created. * 337 *=============================================================================================*/ 338 fixed OptionsClass::Get_Brightness(void) const 339 { 340 return((Brightness - fixed::_1_4) / fixed::_1_2); 341 } 342 343 344 /*********************************************************************************************** 345 * OptionsClass::Set_Saturation -- Sets the color to the value specified. * 346 * * 347 * This routine will set the color value to that specified. The value specified can range * 348 * from zero to 255. The value of 128 is the normal default color setting. * 349 * * 350 * INPUT: color -- The new color value to set as current. * 351 * * 352 * OUTPUT: none * 353 * * 354 * WARNINGS: none * 355 * * 356 * HISTORY: * 357 * 01/19/1995 JLB : Created. * 358 *=============================================================================================*/ 359 void OptionsClass::Set_Saturation(fixed color) 360 { 361 Saturation = color; 362 Adjust_Palette(OriginalPalette, InGamePalette, Brightness, Saturation, Tint, Contrast); 363 InGamePalette.Set(); 364 } 365 366 367 /*********************************************************************************************** 368 * OptionsClass::Get_Saturation -- Fetches the current color setting. * 369 * * 370 * This routine will fetch the current color setting. This value ranges from zero to * 371 * 255. * 372 * * 373 * INPUT: none * 374 * * 375 * OUTPUT: Returns with the current color setting. The value of 128 is the normal (default) * 376 * color setting. * 377 * * 378 * WARNINGS: none * 379 * * 380 * HISTORY: * 381 * 01/19/1995 JLB : Created. * 382 *=============================================================================================*/ 383 fixed OptionsClass::Get_Saturation(void) const 384 { 385 return(Saturation); 386 } 387 388 389 /*********************************************************************************************** 390 * OptionsClass::Set_Contrast -- Sets the contrast to the value specified. * 391 * * 392 * This routine will set the contrast to the setting specified. This setting ranges from * 393 * zero to 255. The value o 128 is the normal default value. * 394 * * 395 * INPUT: contrast -- The contrast setting to make as the current setting. * 396 * * 397 * OUTPUT: none * 398 * * 399 * WARNINGS: none * 400 * * 401 * HISTORY: * 402 * 01/19/1995 JLB : Created. * 403 *=============================================================================================*/ 404 void OptionsClass::Set_Contrast(fixed contrast) 405 { 406 Contrast = fixed::_1_4 + (fixed::_1_2 * contrast); 407 Adjust_Palette(OriginalPalette, InGamePalette, Brightness, Saturation, Tint, Contrast); 408 InGamePalette.Set(); 409 } 410 411 412 /*********************************************************************************************** 413 * OptionsClass::Get_Contrast -- Gets the current contrast setting. * 414 * * 415 * This routine will get the current contrast setting. The value returned is in the range * 416 * of zero to 255. * 417 * * 418 * INPUT: none * 419 * * 420 * OUTPUT: Returns the current contrast setting. A setting of 128 is the normal default value.* 421 * * 422 * WARNINGS: none * 423 * * 424 * HISTORY: * 425 * 01/19/1995 JLB : Created. * 426 *=============================================================================================*/ 427 fixed OptionsClass::Get_Contrast(void) const 428 { 429 return((Contrast - fixed::_1_4) / fixed::_1_2); 430 } 431 432 433 /*********************************************************************************************** 434 * OptionsClass::Set_Tint -- Sets the tint setting. * 435 * * 436 * This routine will change the current tint setting according to the value specified. * 437 * * 438 * INPUT: tint -- The desired tint setting. This value ranges from zero to 255. * 439 * * 440 * OUTPUT: none * 441 * * 442 * WARNINGS: The value of 128 is the default (normal) tint setting. * 443 * * 444 * HISTORY: * 445 * 01/19/1995 JLB : Created. * 446 *=============================================================================================*/ 447 void OptionsClass::Set_Tint(fixed tint) 448 { 449 Tint = tint; 450 Adjust_Palette(OriginalPalette, InGamePalette, Brightness, Saturation, Tint, Contrast); 451 InGamePalette.Set(); 452 } 453 454 455 /*********************************************************************************************** 456 * OptionsClass::Get_Tint -- Fetches the current tint setting. * 457 * * 458 * This fetches the current tint setting. The value is returned as a number between * 459 * zero and 255. This has been adjusted for the valid range allowed. * 460 * * 461 * INPUT: none * 462 * * 463 * OUTPUT: Returns with the current tint setting. Normal tint setting is 128. * 464 * * 465 * WARNINGS: none * 466 * * 467 * HISTORY: * 468 * 01/19/1995 JLB : Created. * 469 *=============================================================================================*/ 470 fixed OptionsClass::Get_Tint(void) const 471 { 472 return(Tint); 473 } 474 475 476 /*********************************************************************************************** 477 * OptionsClass::Adjust_Palette -- Adjusts the palette according to the settings specified. * 478 * * 479 * This routine is used to adjust the palette according to the settings provided. It is * 480 * used by the options class to monkey with the palette. * 481 * * 482 * INPUT: oldpal -- Pointer to the original (unmodified) palette. * 483 * * 484 * newpal -- The new palette to create according to the settings provided. * 485 * * 486 * brightness -- The brightness level (0..255). * 487 * * 488 * color -- The color level (0..255). * 489 * * 490 * tint -- The tint (hue) level (0..255). * 491 * * 492 * contrast -- The contrast level (0..255). * 493 * * 494 * OUTPUT: none * 495 * * 496 * WARNINGS: none * 497 * * 498 * HISTORY: * 499 * 07/21/1994 JLB : Created. * 500 * 12/02/1995 JLB : Uses palette class objects. * 501 *=============================================================================================*/ 502 void OptionsClass::Adjust_Palette(PaletteClass const & oldpal, PaletteClass & newpal, fixed brightness, fixed color, fixed tint, fixed contrast) const 503 { 504 //if (!oldpal || !newpal) return; Can't be NULL... ST - 5/9/2019 505 506 /* 507 ** Adjust for palette. 508 */ 509 for (int index = 0; index < PaletteClass::COLOR_COUNT; index++) { 510 if (index == CC_MOUSE_COLOR) { 511 newpal[index] = oldpal[index]; 512 } else { 513 /* 514 ** Convert the working palette entry into an HSV format for 515 ** manipulation. 516 */ 517 HSVClass hsv = oldpal[index]; 518 519 /* 520 ** Adjust contrast by moving the value toward the center according to the 521 ** percentage indicated. 522 */ 523 int temp; 524 temp = (hsv.Value_Component() * (brightness * 256)) / 0x80; // Brightness 525 temp = Bound(temp, 0, 0xFF); 526 int v = temp; 527 temp = (((((int)v) - 0x80) * (contrast * 256)) / 0x80) + 0x80; // Contrast 528 temp = Bound(temp, 0, 0xFF); 529 v = temp; 530 temp = (hsv.Saturation_Component() * (color * 256)) / 0x80; // Color 531 temp = Bound(temp, 0, 0xFF); 532 int s = temp; 533 temp = (hsv.Hue_Component() * (tint * 256)) / 0x80; // Tint 534 temp = Bound(temp, 0, 0xFF); 535 int h = temp; 536 537 /* 538 ** Replace the working palette entry according to the newly calculated 539 ** hue, saturation, and value. 540 */ 541 newpal[index] = HSVClass(h, s, v); 542 } 543 } 544 } 545 546 547 /*********************************************************************************************** 548 * OptionsClass::Load_Settings -- reads options settings from the INI file * 549 * * 550 * INPUT: * 551 * none. * 552 * * 553 * OUTPUT: * 554 * none. * 555 * * 556 * WARNINGS: * 557 * none. * 558 * * 559 * HISTORY: * 560 * 02/14/1995 BR : Created. * 561 * 07/03/1996 JLB : Reworked to use new INI handler. * 562 * 07/30/1996 JLB : Handles hotkeys. * 563 *=============================================================================================*/ 564 void OptionsClass::Load_Settings(void) 565 { 566 /* 567 ** Create filename and read the file. 568 */ 569 CCFileClass file(CONFIG_FILE_NAME); 570 INIClass ini; 571 ini.Load(file); 572 573 /* 574 ** Read in the Options values 575 */ 576 static char const * const OPTIONS = "Options"; 577 GameSpeed = ini.Get_Int(OPTIONS, "GameSpeed", GameSpeed); 578 ScrollRate = ini.Get_Int(OPTIONS, "ScrollRate", ScrollRate); 579 Set_Brightness(ini.Get_Fixed(OPTIONS, "Brightness", Brightness)); 580 Set_Sound_Volume(ini.Get_Fixed(OPTIONS, "Volume", Volume), false); 581 Set_Score_Volume(ini.Get_Fixed(OPTIONS, "ScoreVolume", ScoreVolume), false); 582 #ifdef FIXIT_VERSION_3 583 MultiScoreVolume = ini.Get_Fixed(OPTIONS, "MultiplayerScoreVolume", MultiScoreVolume); 584 #endif 585 Set_Contrast(ini.Get_Fixed(OPTIONS, "Contrast", Contrast)); 586 Set_Saturation(ini.Get_Fixed(OPTIONS, "Color", Saturation)); 587 Set_Tint(ini.Get_Fixed(OPTIONS, "Tint", Tint)); 588 AutoScroll = ini.Get_Bool(OPTIONS, "AutoScroll", AutoScroll); 589 Set_Repeat(ini.Get_Bool(OPTIONS, "IsScoreRepeat", IsScoreRepeat)); 590 Set_Shuffle(ini.Get_Bool(OPTIONS, "IsScoreShuffle", IsScoreShuffle)); 591 SlowPalette = ini.Get_Bool(OPTIONS, "SlowPalette", SlowPalette); 592 IsPaletteScroll = ini.Get_Bool(OPTIONS, "PaletteScroll", IsPaletteScroll); 593 594 KeyForceMove1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceMove1", KeyForceMove1); 595 KeyForceMove2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceMove2", KeyForceMove2); 596 KeyForceAttack1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceAttack1", KeyForceAttack1); 597 KeyForceAttack2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceAttack2", KeyForceAttack2); 598 KeySelect1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeySelect1", KeySelect1); 599 KeySelect2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeySelect2", KeySelect2); 600 KeyScatter = (KeyNumType)ini.Get_Int(HotkeyName, "KeyScatter", KeyScatter); 601 KeyStop = (KeyNumType)ini.Get_Int(HotkeyName, "KeyStop", KeyStop); 602 KeyGuard = (KeyNumType)ini.Get_Int(HotkeyName, "KeyGuard", KeyGuard); 603 KeyNext = (KeyNumType)ini.Get_Int(HotkeyName, "KeyNext", KeyNext); 604 KeyPrevious = (KeyNumType)ini.Get_Int(HotkeyName, "KeyPrevious", KeyPrevious); 605 KeyFormation = (KeyNumType)ini.Get_Int(HotkeyName, "KeyFormation", KeyFormation); 606 KeyHome1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyHome1", KeyHome1); 607 KeyHome2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyHome2", KeyHome2); 608 KeyBase = (KeyNumType)ini.Get_Int(HotkeyName, "KeyBase", KeyBase); 609 KeyResign = (KeyNumType)ini.Get_Int(HotkeyName, "KeyResign", KeyResign); 610 KeyAlliance = (KeyNumType)ini.Get_Int(HotkeyName, "KeyAlliance", KeyAlliance); 611 KeyBookmark1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyBookmark1", KeyBookmark1); 612 KeyBookmark2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyBookmark2", KeyBookmark2); 613 KeyBookmark3 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyBookmark3", KeyBookmark3); 614 KeyBookmark4 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyBookmark4", KeyBookmark4); 615 KeySelectView = (KeyNumType)ini.Get_Int(HotkeyName, "KeySelectView", KeySelectView); 616 KeyRepair = (KeyNumType)ini.Get_Int(HotkeyName, "KeyRepairToggle", KeyRepair); 617 KeyRepairOn = (KeyNumType)ini.Get_Int(HotkeyName, "KeyRepairOn", KeyRepairOn); 618 KeyRepairOff = (KeyNumType)ini.Get_Int(HotkeyName, "KeyRepairOff", KeyRepairOff); 619 KeySell = (KeyNumType)ini.Get_Int(HotkeyName, "KeySellToggle", KeySell); 620 KeySellOn = (KeyNumType)ini.Get_Int(HotkeyName, "KeySellOn", KeySellOn); 621 KeySellOff = (KeyNumType)ini.Get_Int(HotkeyName, "KeySellOff", KeySellOff); 622 KeyMap = (KeyNumType)ini.Get_Int(HotkeyName, "KeyMapToggle", KeyMap); 623 KeySidebarUp = (KeyNumType)ini.Get_Int(HotkeyName, "KeySidebarUp", KeySidebarUp); 624 KeySidebarDown = (KeyNumType)ini.Get_Int(HotkeyName, "KeySidebarDown", KeySidebarDown); 625 KeyOption1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyOption1", KeyOption1); 626 KeyOption2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyOption2", KeyOption2); 627 KeyScrollLeft = (KeyNumType)ini.Get_Int(HotkeyName, "KeyScrollLeft", KeyScrollLeft); 628 KeyScrollRight = (KeyNumType)ini.Get_Int(HotkeyName, "KeyScrollRight", KeyScrollRight); 629 KeyScrollUp = (KeyNumType)ini.Get_Int(HotkeyName, "KeyScrollUp", KeyScrollUp); 630 KeyScrollDown = (KeyNumType)ini.Get_Int(HotkeyName, "KeyScrollDown", KeyScrollDown); 631 KeyQueueMove1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyQueueMove1", KeyQueueMove1); 632 KeyQueueMove2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyQueueMove2", KeyQueueMove2); 633 KeyTeam1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam1", KeyTeam1); 634 KeyTeam2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam2", KeyTeam2); 635 KeyTeam3 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam3", KeyTeam3); 636 KeyTeam4 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam4", KeyTeam4); 637 KeyTeam5 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam5", KeyTeam5); 638 KeyTeam6 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam6", KeyTeam6); 639 KeyTeam7 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam7", KeyTeam7); 640 KeyTeam8 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam8", KeyTeam8); 641 KeyTeam9 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam9", KeyTeam9); 642 KeyTeam10 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam10", KeyTeam10); 643 644 645 #ifdef WIN32 646 KeyForceMove1 = (KeyNumType)(KeyForceMove1 & ~WWKEY_VK_BIT); 647 KeyForceMove2 = (KeyNumType)(KeyForceMove2 & ~WWKEY_VK_BIT); 648 KeyForceAttack1 = (KeyNumType)(KeyForceAttack1 & ~WWKEY_VK_BIT); 649 KeyForceAttack2 = (KeyNumType)(KeyForceAttack2 & ~WWKEY_VK_BIT); 650 KeySelect1 = (KeyNumType)(KeySelect1 & ~WWKEY_VK_BIT); 651 KeySelect2 = (KeyNumType)(KeySelect2 & ~WWKEY_VK_BIT); 652 KeyScatter = (KeyNumType)(KeyScatter & ~WWKEY_VK_BIT); 653 KeyStop = (KeyNumType)(KeyStop & ~WWKEY_VK_BIT); 654 KeyGuard = (KeyNumType)(KeyGuard & ~WWKEY_VK_BIT); 655 KeyNext = (KeyNumType)(KeyNext & ~WWKEY_VK_BIT); 656 KeyPrevious = (KeyNumType)(KeyPrevious & ~WWKEY_VK_BIT); 657 KeyFormation = (KeyNumType)(KeyFormation & ~WWKEY_VK_BIT); 658 KeyHome1 = (KeyNumType)(KeyHome1 & ~WWKEY_VK_BIT); 659 KeyHome2 = (KeyNumType)(KeyHome2 & ~WWKEY_VK_BIT); 660 KeyBase = (KeyNumType)(KeyBase & ~WWKEY_VK_BIT); 661 KeyResign = (KeyNumType)(KeyResign & ~WWKEY_VK_BIT); 662 KeyAlliance = (KeyNumType)(KeyAlliance & ~WWKEY_VK_BIT); 663 KeyBookmark1 = (KeyNumType)(KeyBookmark1 & ~WWKEY_VK_BIT); 664 KeyBookmark2 = (KeyNumType)(KeyBookmark2 & ~WWKEY_VK_BIT); 665 KeyBookmark3 = (KeyNumType)(KeyBookmark3 & ~WWKEY_VK_BIT); 666 KeyBookmark4 = (KeyNumType)(KeyBookmark4 & ~WWKEY_VK_BIT); 667 KeySelectView = (KeyNumType)(KeySelectView & ~WWKEY_VK_BIT); 668 KeyRepair = (KeyNumType)(KeyRepair & ~WWKEY_VK_BIT); 669 KeyRepairOn = (KeyNumType)(KeyRepairOn & ~WWKEY_VK_BIT); 670 KeyRepairOff = (KeyNumType)(KeyRepairOff & ~WWKEY_VK_BIT); 671 KeySell = (KeyNumType)(KeySell & ~WWKEY_VK_BIT); 672 KeySellOn = (KeyNumType)(KeySellOn & ~WWKEY_VK_BIT); 673 KeySellOff = (KeyNumType)(KeySellOff & ~WWKEY_VK_BIT); 674 KeyMap = (KeyNumType)(KeyMap & ~WWKEY_VK_BIT); 675 KeySidebarUp = (KeyNumType)(KeySidebarUp & ~WWKEY_VK_BIT); 676 KeySidebarDown = (KeyNumType)(KeySidebarDown & ~WWKEY_VK_BIT); 677 KeyOption1 = (KeyNumType)(KeyOption1 & ~WWKEY_VK_BIT); 678 KeyOption2 = (KeyNumType)(KeyOption2 & ~WWKEY_VK_BIT); 679 KeyScrollLeft = (KeyNumType)(KeyScrollLeft & ~WWKEY_VK_BIT); 680 KeyScrollRight = (KeyNumType)(KeyScrollRight & ~WWKEY_VK_BIT); 681 KeyScrollUp = (KeyNumType)(KeyScrollUp & ~WWKEY_VK_BIT); 682 KeyScrollDown = (KeyNumType)(KeyScrollDown & ~WWKEY_VK_BIT); 683 KeyQueueMove1 = (KeyNumType)(KeyQueueMove1 & ~WWKEY_VK_BIT); 684 KeyQueueMove2 = (KeyNumType)(KeyQueueMove2 & ~WWKEY_VK_BIT); 685 KeyTeam1 = (KeyNumType)(KeyTeam1 & ~WWKEY_VK_BIT); 686 KeyTeam2 = (KeyNumType)(KeyTeam2 & ~WWKEY_VK_BIT); 687 KeyTeam3 = (KeyNumType)(KeyTeam3 & ~WWKEY_VK_BIT); 688 KeyTeam4 = (KeyNumType)(KeyTeam4 & ~WWKEY_VK_BIT); 689 KeyTeam5 = (KeyNumType)(KeyTeam5 & ~WWKEY_VK_BIT); 690 KeyTeam6 = (KeyNumType)(KeyTeam6 & ~WWKEY_VK_BIT); 691 KeyTeam7 = (KeyNumType)(KeyTeam7 & ~WWKEY_VK_BIT); 692 KeyTeam8 = (KeyNumType)(KeyTeam8 & ~WWKEY_VK_BIT); 693 KeyTeam9 = (KeyNumType)(KeyTeam9 & ~WWKEY_VK_BIT); 694 KeyTeam10 = (KeyNumType)(KeyTeam10 & ~WWKEY_VK_BIT); 695 #endif 696 } 697 698 699 /*********************************************************************************************** 700 * OptionsClass::Save_Settings -- writes options settings to the INI file * 701 * * 702 * INPUT: * 703 * none. * 704 * * 705 * OUTPUT: * 706 * none. * 707 * * 708 * WARNINGS: * 709 * none. * 710 * * 711 * HISTORY: * 712 * 02/14/1995 BR : Created. * 713 * 07/03/1996 JLB : Revamped and tightened up. * 714 * 07/30/1996 JLB : Handles hotkeys. * 715 *=============================================================================================*/ 716 void OptionsClass::Save_Settings (void) 717 { 718 CCFileClass file(CONFIG_FILE_NAME); 719 INIClass ini; 720 721 /* 722 ** Load any existing options file because it may contain entries that won't be 723 ** explicitly written out by this routine. By preloading the database, these entries 724 ** will be carried over. 725 */ 726 if (file.Is_Available()) { 727 ini.Load(file); 728 } 729 730 /* 731 ** Save Options settings 732 */ 733 static char const * const OPTIONS = "Options"; 734 ini.Put_Int(OPTIONS, "GameSpeed", GameSpeed); 735 ini.Put_Int(OPTIONS, "ScrollRate", ScrollRate); 736 ini.Put_Fixed(OPTIONS, "Brightness", Brightness); 737 ini.Put_Fixed(OPTIONS, "Volume", Volume); 738 #ifdef FIXIT_VERSION_3 739 if( Session.Type == GAME_NORMAL ) // Save only when non-multiplayer. 740 ini.Put_Fixed(OPTIONS, "ScoreVolume", ScoreVolume); 741 #else 742 ini.Put_Fixed(OPTIONS, "ScoreVolume", ScoreVolume); 743 #endif 744 #ifdef FIXIT_VERSION_3 745 ini.Put_Fixed(OPTIONS, "MultiplayerScoreVolume", MultiScoreVolume); 746 #endif 747 ini.Put_Fixed(OPTIONS, "Contrast", Contrast); 748 ini.Put_Fixed(OPTIONS, "Color", Saturation); 749 ini.Put_Fixed(OPTIONS, "Tint", Tint); 750 ini.Put_Bool(OPTIONS, "AutoScroll", AutoScroll); 751 ini.Put_Bool(OPTIONS, "IsScoreRepeat", IsScoreRepeat); 752 ini.Put_Bool(OPTIONS, "IsScoreShuffle", IsScoreShuffle); 753 ini.Put_Bool(OPTIONS, "PaletteScroll", IsPaletteScroll); 754 755 ini.Put_Int(HotkeyName, "KeyForceMove1", KeyForceMove1); 756 ini.Put_Int(HotkeyName, "KeyForceMove2", KeyForceMove2); 757 ini.Put_Int(HotkeyName, "KeyForceAttack1", KeyForceAttack1); 758 ini.Put_Int(HotkeyName, "KeyForceAttack2", KeyForceAttack2); 759 ini.Put_Int(HotkeyName, "KeySelect1", KeySelect1); 760 ini.Put_Int(HotkeyName, "KeySelect2", KeySelect2); 761 ini.Put_Int(HotkeyName, "KeyScatter", KeyScatter); 762 ini.Put_Int(HotkeyName, "KeyStop", KeyStop); 763 ini.Put_Int(HotkeyName, "KeyGuard", KeyGuard); 764 ini.Put_Int(HotkeyName, "KeyNext", KeyNext); 765 ini.Put_Int(HotkeyName, "KeyPrevious", KeyPrevious); 766 ini.Put_Int(HotkeyName, "KeyFormation", KeyFormation); 767 ini.Put_Int(HotkeyName, "KeyHome1", KeyHome1); 768 ini.Put_Int(HotkeyName, "KeyHome2", KeyHome2); 769 ini.Put_Int(HotkeyName, "KeyBase", KeyBase); 770 ini.Put_Int(HotkeyName, "KeyResign", KeyResign); 771 ini.Put_Int(HotkeyName, "KeyAlliance", KeyAlliance); 772 ini.Put_Int(HotkeyName, "KeyBookmark1", KeyBookmark1); 773 ini.Put_Int(HotkeyName, "KeyBookmark2", KeyBookmark2); 774 ini.Put_Int(HotkeyName, "KeyBookmark3", KeyBookmark3); 775 ini.Put_Int(HotkeyName, "KeyBookmark4", KeyBookmark4); 776 ini.Put_Int(HotkeyName, "KeySelectView", KeySelectView); 777 ini.Put_Int(HotkeyName, "KeyRepairToggle", KeyRepair); 778 ini.Put_Int(HotkeyName, "KeyRepairOn", KeyRepairOn); 779 ini.Put_Int(HotkeyName, "KeyRepairOff", KeyRepairOff); 780 ini.Put_Int(HotkeyName, "KeySellToggle", KeySell); 781 ini.Put_Int(HotkeyName, "KeySellOn", KeySellOn); 782 ini.Put_Int(HotkeyName, "KeySellOff", KeySellOff); 783 ini.Put_Int(HotkeyName, "KeyMapToggle", KeyMap); 784 ini.Put_Int(HotkeyName, "KeySidebarUp", KeySidebarUp); 785 ini.Put_Int(HotkeyName, "KeySidebarDown", KeySidebarDown); 786 ini.Put_Int(HotkeyName, "KeyOption1", KeyOption1); 787 ini.Put_Int(HotkeyName, "KeyOption2", KeyOption2); 788 ini.Put_Int(HotkeyName, "KeyScrollLeft", KeyScrollLeft); 789 ini.Put_Int(HotkeyName, "KeyScrollRight", KeyScrollRight); 790 ini.Put_Int(HotkeyName, "KeyScrollUp", KeyScrollUp); 791 ini.Put_Int(HotkeyName, "KeyScrollDown", KeyScrollDown); 792 ini.Put_Int(HotkeyName, "KeyQueueMove1", KeyQueueMove1); 793 ini.Put_Int(HotkeyName, "KeyQueueMove2", KeyQueueMove2); 794 ini.Put_Int(HotkeyName, "KeyTeam1", KeyTeam1); 795 ini.Put_Int(HotkeyName, "KeyTeam2", KeyTeam2); 796 ini.Put_Int(HotkeyName, "KeyTeam3", KeyTeam3); 797 ini.Put_Int(HotkeyName, "KeyTeam4", KeyTeam4); 798 ini.Put_Int(HotkeyName, "KeyTeam5", KeyTeam5); 799 ini.Put_Int(HotkeyName, "KeyTeam6", KeyTeam6); 800 ini.Put_Int(HotkeyName, "KeyTeam7", KeyTeam7); 801 ini.Put_Int(HotkeyName, "KeyTeam8", KeyTeam8); 802 ini.Put_Int(HotkeyName, "KeyTeam9", KeyTeam9); 803 ini.Put_Int(HotkeyName, "KeyTeam10", KeyTeam10); 804 805 /* 806 ** Write the INI data out to a file. 807 */ 808 ini.Save(file); 809 } 810 811 812 /*********************************************************************************************** 813 * OptionsClass::Set -- Sets options based on current settings * 814 * * 815 * Use this routine to adjust the palette or sound settings after a fresh scenario load. * 816 * It assumes the values needed are already loaded into OptionsClass. * 817 * * 818 * INPUT: * 819 * * 820 * OUTPUT: * 821 * * 822 * WARNINGS: * 823 * * 824 * HISTORY: * 825 * 06/24/1995 BRR : Created. * 826 *=============================================================================================*/ 827 void OptionsClass::Set(void) 828 { 829 Set_Brightness(Brightness); 830 Set_Contrast(Contrast); 831 Set_Saturation(Saturation); 832 Set_Tint(Tint); 833 Set_Sound_Volume(Volume, false); 834 Set_Score_Volume(ScoreVolume, false); 835 Set_Repeat(IsScoreRepeat); 836 Set_Shuffle(IsScoreShuffle); 837 } 838 839 840 /*********************************************************************************************** 841 * OptionsClass::Normalize_Delay -- Normalizes delay factor to keep rate constant. * 842 * * 843 * This routine is used to adjust delay factors that MUST be synchronized on all machines * 844 * but should maintain a speed as close to constant as possible. Building animations are * 845 * a good example of this. * 846 * * 847 * INPUT: delay -- The normal delay factor. * 848 * * 849 * OUTPUT: Returns with the delay to use that has been modified so that a reasonably constant * 850 * rate will result. * 851 * * 852 * WARNINGS: This calculation is crude due to the coarse resolution that a 1/15 second timer * 853 * allows. * 854 * * 855 * Use of this routine ASSUMES that the GameSpeed is synchronized on all machines. * 856 * * 857 * HISTORY: * 858 * 06/18/1995 JLB : Created. * 859 * 06/30/1995 JLB : Handles low values in a more consistent manner. * 860 *=============================================================================================*/ 861 int OptionsClass::Normalize_Delay(int delay) const 862 { 863 static int _adjust[][8] = { 864 {2,2,1,1,1,1,1,1}, 865 {3,3,3,2,2,2,1,1}, 866 {5,4,4,3,3,2,2,1}, 867 {7,6,5,4,4,4,3,2} 868 }; 869 if (delay) { 870 if (delay < 5) { 871 delay = _adjust[delay-1][GameSpeed]; 872 } else { 873 delay = ((delay * 8) / (GameSpeed+1)); 874 } 875 } 876 return(delay); 877 } 878 879 880 /*********************************************************************************************** 881 * OptionsClass::Fixup_Palette -- Adjusts the real palette to match the palette sliders. * 882 * * 883 * This routine is used to adjust the real palette to match the values for the palette * 884 * control. The adjusted palette is placed into the palette buffer specified. * 885 * * 886 * INPUT: none * 887 * * 888 * OUTPUT: none * 889 * * 890 * WARNINGS: The palette is not actually set by this routine. * 891 * * 892 * HISTORY: * 893 * 09/22/1995 JLB : Created. * 894 *=============================================================================================*/ 895 void OptionsClass::Fixup_Palette(void) const 896 { 897 Adjust_Palette(OriginalPalette, InGamePalette, Brightness, Saturation, Tint, Contrast); 898 CCPalette = InGamePalette; 899 } 900 901 902 /*********************************************************************************************** 903 * OptionsClass::Normalize_Volume -- Convert to a real volume value. * 904 * * 905 * This routine will take a relative volume value and convert it to the real volume value * 906 * to use. This allows all the game volumes to be corrected to the correct global volume. * 907 * * 908 * INPUT: volume -- Requested volume level. * 909 * * 910 * OUTPUT: Returns with the actual volume level to use. * 911 * * 912 * WARNINGS: none * 913 * * 914 * HISTORY: * 915 * 09/22/1995 JLB : Created. * 916 *=============================================================================================*/ 917 int OptionsClass::Normalize_Volume(int volume) const 918 { 919 return(volume * Volume); 920 }