OPTIONS.CPP 56 KB

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