CREDITS.CPP 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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/CREDITS.CPP 1 3/03/97 10:24a 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 : CREDITS.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : April 17, 1994 *
  26. * *
  27. * Last Update : March 13, 1995 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * CreditClass::AI -- Handles updating the credit display. *
  32. * CreditClass::CreditClass -- Default constructor for the credit class object. *
  33. * CreditClass::Graphic_Logic -- Handles the credit redraw logic. *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "function.h"
  36. /***********************************************************************************************
  37. * CreditClass::CreditClass -- Default constructor for the credit class object. *
  38. * *
  39. * This is the constructor for the credit class object. It merely sets the credit display *
  40. * state to null. *
  41. * *
  42. * INPUT: none *
  43. * *
  44. * OUTPUT: none *
  45. * *
  46. * WARNINGS: none *
  47. * *
  48. * HISTORY: *
  49. * 03/13/1995 JLB : Created. *
  50. *=============================================================================================*/
  51. CreditClass::CreditClass(void) :
  52. Credits(0),
  53. Current(0),
  54. IsToRedraw(false),
  55. IsUp(false),
  56. IsAudible(false),
  57. Countdown(0)
  58. {
  59. }
  60. /***********************************************************************************************
  61. * CreditClass::Graphic_Logic -- Handles the credit redraw logic. *
  62. * *
  63. * This routine should be called whenever the main game screen is to be updated. It will *
  64. * check to see if the credit display should be redrawn. If so, it will redraw it. *
  65. * *
  66. * INPUT: forced -- Should the credit display be redrawn regardless of whether the redraw *
  67. * flag is set? This is typically the case when the screen needs to be *
  68. * redrawn from scratch. *
  69. * *
  70. * OUTPUT: none *
  71. * *
  72. * WARNINGS: none *
  73. * *
  74. * HISTORY: *
  75. * 03/13/1995 JLB : Created. *
  76. *=============================================================================================*/
  77. //#define XX (320-120)
  78. //#define WW 50
  79. void CreditClass::Graphic_Logic(bool forced)
  80. {
  81. if (forced || IsToRedraw) {
  82. BStart(BENCH_TABS);
  83. int xx = SeenBuff.Get_Width() - (120 * RESFACTOR);
  84. /*
  85. ** Adjust the credits display to be above the sidebar for 640x400
  86. */
  87. #ifdef WIN32
  88. xx += 80 * RESFACTOR;
  89. #endif
  90. /*
  91. ** Play a sound effect when the money display changes, but only if a sound
  92. ** effect was requested.
  93. */
  94. if (IsAudible) {
  95. if (IsUp) {
  96. Sound_Effect(VOC_MONEY_UP, fixed(1, 2));
  97. } else {
  98. Sound_Effect(VOC_MONEY_DOWN, fixed(1, 2));
  99. }
  100. }
  101. /*
  102. ** Display the new current value.
  103. */
  104. // PG TabClass::Draw_Credits_Tab();
  105. #ifdef WIN32
  106. //PG Fancy_Text_Print("%ld", xx, 0, &MetalScheme, TBLACK, TPF_METAL12 | TPF_CENTER | TPF_USE_GRAD_PAL, Current);
  107. #else
  108. Fancy_Text_Print("%ld", xx, 0, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_NOSHADOW|TPF_6PT_GRAD|TPF_CENTER|TPF_BRIGHT_COLOR, Current);
  109. #endif //WIN32
  110. if (Scen.MissionTimer.Is_Active()) {
  111. long secs = Scen.MissionTimer / TICKS_PER_SECOND;
  112. long mins = secs / 60;
  113. long hours = mins / 60;
  114. secs %= 60;
  115. mins %= 60;
  116. #if (0) //Moved to LOGIC.CPP
  117. /*
  118. ** Speak mission timer reminders.
  119. */
  120. VoxType vox = VOX_NONE;
  121. if (Scen.MissionTimer == (1 * TICKS_PER_MINUTE)) vox = VOX_TIME_1;
  122. if (Scen.MissionTimer == (2 * TICKS_PER_MINUTE)) vox = VOX_TIME_2;
  123. if (Scen.MissionTimer == (3 * TICKS_PER_MINUTE)) vox = VOX_TIME_3;
  124. if (Scen.MissionTimer == (4 * TICKS_PER_MINUTE)) vox = VOX_TIME_4;
  125. if (Scen.MissionTimer == (5 * TICKS_PER_MINUTE)) vox = VOX_TIME_5;
  126. if (Scen.MissionTimer == (10 * TICKS_PER_MINUTE)) vox = VOX_TIME_10;
  127. if (Scen.MissionTimer == (20 * TICKS_PER_MINUTE)) vox = VOX_TIME_20;
  128. if (Scen.MissionTimer == (30 * TICKS_PER_MINUTE)) vox = VOX_TIME_30;
  129. if (Scen.MissionTimer == (40 * TICKS_PER_MINUTE)) vox = VOX_TIME_40;
  130. if (vox != VOX_NONE) {
  131. Speak(vox);
  132. Map.FlasherTimer = 7;
  133. }
  134. #endif
  135. #ifdef WIN32
  136. #if (0) //PG
  137. if (hours) {
  138. Fancy_Text_Print(TXT_TIME_FORMAT_HOURS, 200 * RESFACTOR, 0, &MetalScheme, TBLACK, TPF_METAL12|TPF_CENTER|TPF_USE_GRAD_PAL, hours, mins, secs);
  139. } else {
  140. Fancy_Text_Print(TXT_TIME_FORMAT_NO_HOURS, 200 * RESFACTOR, 0, &MetalScheme, TBLACK, TPF_METAL12|TPF_CENTER|TPF_USE_GRAD_PAL, mins, secs);
  141. }
  142. #endif
  143. #else
  144. if (hours) {
  145. Fancy_Text_Print("%02d:%02d:%02d", 120 * RESFACTOR, 0, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_NOSHADOW|TPF_6PT_GRAD|TPF_CENTER|TPF_BRIGHT_COLOR, hours, mins, secs);
  146. } else {
  147. Fancy_Text_Print("%02d:%02d", 120 * RESFACTOR, 0, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_NOSHADOW|TPF_6PT_GRAD|TPF_CENTER|TPF_BRIGHT_COLOR, mins, secs);
  148. }
  149. #endif //WIN32
  150. }
  151. IsToRedraw = false;
  152. IsAudible = false;
  153. BEnd(BENCH_TABS);
  154. }
  155. }
  156. /***********************************************************************************************
  157. * CreditClass::AI -- Handles updating the credit display. *
  158. * *
  159. * This routine handles the logic that controls the rate of credit change in the credit *
  160. * display. It doesn't actually redraw the credit display, but will flag it to be redrawn *
  161. * if it detects that a change is to occur. *
  162. * *
  163. * INPUT: forced -- Should the credit display immediately reflect the current credit *
  164. * total for the player? This is usually desired when initially loading *
  165. * a scenario or saved game. *
  166. * player_ptr -- Player to calculate visible credits for *
  167. * logic_only -- If true, don't flag map for redraw *
  168. * *
  169. * OUTPUT: none *
  170. * *
  171. * WARNINGS: none *
  172. * *
  173. * HISTORY: *
  174. * 03/13/1995 JLB : Created. *
  175. * 10/16/2019 ST : Added house and logic parameters so we can call this from HouseClass::AI *
  176. *=============================================================================================*/
  177. void CreditClass::AI(bool forced, HouseClass *player_ptr, bool logic_only)
  178. {
  179. static int _last = 0;
  180. if (!forced && !logic_only && Frame == _last) return;
  181. if (!logic_only) {
  182. _last = Frame;
  183. }
  184. if (player_ptr == NULL) {
  185. return;
  186. }
  187. Credits = player_ptr->Available_Money();
  188. /*
  189. ** Make sure that the credit counter doesn't drop below zero.
  190. */
  191. Credits = max(Credits, 0L);
  192. if (Scen.MissionTimer.Is_Active() || Scen.MissionTimer) {
  193. IsToRedraw = true;
  194. Map.Flag_To_Redraw(false);
  195. }
  196. if (Current == Credits) return;
  197. if (forced) {
  198. IsAudible = false;
  199. Current = Credits;
  200. } else {
  201. if (Countdown) Countdown--;
  202. if (Countdown) return;
  203. /*
  204. ** Determine the amount to change the display toward the
  205. ** desired value.
  206. */
  207. int adder = Credits - Current;
  208. if (adder > 0) {
  209. Countdown = 1;
  210. } else {
  211. Countdown = 3;
  212. }
  213. adder = ABS(adder);
  214. adder >>= 3;
  215. // adder >>= 4;
  216. // adder >>= 5;
  217. adder = Bound(adder, 1, 71+72);
  218. if (Current > Credits) adder = -adder;
  219. Current += adder;
  220. if (Current-adder != Current) {
  221. IsAudible = true;
  222. IsUp = (adder > 0);
  223. }
  224. }
  225. IsToRedraw = true;
  226. if (!logic_only) {
  227. Map.Flag_To_Redraw(false);
  228. }
  229. }