OPTIONS.CPP 56 KB

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