CREDITS.CPP 11 KB

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