TransitionDialog.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. /*
  2. ** Command & Conquer Renegade(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. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Installer *
  23. * *
  24. * $Archive:: /Commando/Code/Installer/TransitionDialog.c $*
  25. * *
  26. * $Author:: Ian_l $*
  27. * *
  28. * $Modtime:: 12/15/01 6:37p $*
  29. * *
  30. * $Revision:: 6 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. // Includes.
  36. #include "TransitionDialog.h"
  37. #include "AssetMgr.h"
  38. #include "DialogText.h"
  39. #include "HAnim.h"
  40. #include "MenuBackDrop.h"
  41. #include "Mesh.h"
  42. #include "MeshMdl.h"
  43. #include "MessageBox.h"
  44. #include "MouseMgr.h"
  45. #include "RendObj.h"
  46. #include "Resource.h"
  47. #include "StyleMgr.h"
  48. #include "Translator.h"
  49. #include "Scene.h"
  50. #include "TooltipMgr.h"
  51. #include "Ww3D.h"
  52. /***********************************************************************************************
  53. * TransitionDialogClass::TransitionDialogClass -- Constructor *
  54. * *
  55. * INPUT: *
  56. * *
  57. * OUTPUT: *
  58. * *
  59. * WARNINGS: *
  60. * *
  61. * HISTORY: *
  62. * 08/22/01 IML : Created. *
  63. *=============================================================================================*/
  64. TransitionDialogClass::TransitionDialogClass()
  65. : MenuDialogClass (IDD_DIALOG_TRANSITION),
  66. Time (0.0f)
  67. {
  68. const char *modelname = "IN_STATICTRANS2";
  69. const char *animname = "IN_STATICTRANS2.IN_STATICTRANS2";
  70. Get_BackDrop()->Set_Model (modelname);
  71. Get_BackDrop()->Set_Animation (animname);
  72. // Null materials.
  73. for (unsigned mesh = 0; mesh < MESH_COUNT; mesh++) {
  74. Materials [mesh] = NULL;
  75. }
  76. }
  77. /***********************************************************************************************
  78. * TransitionDialogClass::~TransitionDialogClass -- Destructor *
  79. * *
  80. * INPUT: *
  81. * *
  82. * OUTPUT: *
  83. * *
  84. * WARNINGS: *
  85. * *
  86. * HISTORY: *
  87. * 08/22/01 IML : Created. *
  88. *=============================================================================================*/
  89. TransitionDialogClass::~TransitionDialogClass()
  90. {
  91. Get_BackDrop()->Remove_Model();
  92. }
  93. /***********************************************************************************************
  94. * TransitionDialogClass::On_Init_Dialog -- *
  95. * *
  96. * INPUT: *
  97. * *
  98. * OUTPUT: *
  99. * *
  100. * WARNINGS: *
  101. * *
  102. * HISTORY: *
  103. * 08/22/01 IML : Created. *
  104. *=============================================================================================*/
  105. void TransitionDialogClass::On_Init_Dialog (void)
  106. {
  107. const int textstringids [LABEL_COUNT] = {IDS_INSTALLER_TEXT094,
  108. IDS_INSTALLER_TEXT070,
  109. IDS_SCANNING_LOCAL_RADAR,
  110. IDS_BIO_MONITOR_ACTIVATING,
  111. IDS_UPDATING_WEAPON_STATUS,
  112. IDS_INITIALIZING_OBJECTIVES_SYSTEM,
  113. IDS_TARGETING_SYSTEM_ONLINE};
  114. const int textcontrolids [LABEL_COUNT] = {IDC_EVA_UPDATING1,
  115. IDC_PLEASE_STANDBY,
  116. IDC_SCANNING_LOCAL_RADAR,
  117. IDC_BIO_MONITOR_ACTIVATING,
  118. IDC_UPDATING_WEAPON_STATUS,
  119. IDC_INITIALIZING_OBJECTIVES_SYSTEM,
  120. IDC_TARGETING_SYSTEM_ONLINE};
  121. const char *meshnames [MESH_COUNT] = {"RADAR",
  122. "HEALTH",
  123. "WEAPONS",
  124. "POGS",
  125. "TARGETING"};
  126. MouseMgrClass::Show_Cursor (false);
  127. // Create labels.
  128. for (unsigned label = 0; label < LABEL_COUNT; label++) {
  129. TxWideStringClass text (textstringids [label]);
  130. TextRenderers [label] = new Render2DSentenceClass;
  131. StyleMgrClass::Assign_Font (TextRenderers [label], StyleMgrClass::FONT_CREDITS);
  132. TextRenderers [label]->Build_Sentence (text);
  133. TextRenderers [label]->Set_Location (Position (textcontrolids [label], text));
  134. }
  135. Digits.Set_Growth_Step (1024);
  136. // For each model...
  137. for (unsigned mesh = 0; mesh < MESH_COUNT; mesh++) {
  138. for (int index = 0; index < Get_BackDrop()->Peek_Model()->Get_Num_Sub_Objects(); index++) {
  139. RenderObjClass *sub_obj = Get_BackDrop()->Peek_Model()->Get_Sub_Object (index);
  140. if (sub_obj->Class_ID() == RenderObjClass::CLASSID_MESH) {
  141. if (::strstr (sub_obj->Get_Name(), meshnames [mesh]) != 0) {
  142. Materials [mesh] = ((MeshClass*) sub_obj)->Peek_Model()->Get_Single_Material();
  143. }
  144. }
  145. REF_PTR_RELEASE (sub_obj);
  146. }
  147. }
  148. MenuDialogClass::On_Init_Dialog();
  149. }
  150. /***********************************************************************************************
  151. * TransitionDialogClass::End_Dialog -- *
  152. * *
  153. * INPUT: *
  154. * *
  155. * OUTPUT: *
  156. * *
  157. * WARNINGS: *
  158. * *
  159. * HISTORY: *
  160. * 08/22/01 IML : Created. *
  161. *=============================================================================================*/
  162. void TransitionDialogClass::End_Dialog (void)
  163. {
  164. MouseMgrClass::Show_Cursor (true);
  165. // Remove materials.
  166. for (unsigned mesh = 0; mesh < MESH_COUNT; mesh++) {
  167. REF_PTR_RELEASE (Materials [mesh]);
  168. }
  169. // Remove all digits.
  170. for (int d = 0; d < Digits.Count(); d++) {
  171. delete Digits [d];
  172. }
  173. // Remove labels.
  174. for (unsigned label = 0; label < LABEL_COUNT; label++) {
  175. delete TextRenderers [label];
  176. }
  177. MenuDialogClass::End_Dialog();
  178. }
  179. /***********************************************************************************************
  180. * TransitionDialogClass::On_Frame_Update -- *
  181. * *
  182. * INPUT: *
  183. * *
  184. * OUTPUT: *
  185. * *
  186. * WARNINGS: *
  187. * *
  188. * HISTORY: *
  189. * 08/22/01 IML : Created. *
  190. *=============================================================================================*/
  191. void TransitionDialogClass::On_Frame_Update (void)
  192. {
  193. static Random2Class _randomnumber (0x236ae371);
  194. const float labelcontroltimes [LABEL_COUNT][4] = {{ 1.67f, 1.73f, 6.60f, 6.67f},
  195. { 6.86f, 6.93f, 17.59f, 17.67f},
  196. {17.97f, 17.97f, 38.97f, 38.97f},
  197. {21.97f, 21.97f, 38.97f, 38.97f},
  198. {25.97f, 25.97f, 38.97f, 38.97f},
  199. {29.97f, 29.97f, 38.97f, 38.97f},
  200. {33.97f, 33.97f, 38.97f, 38.97f}};
  201. const float digitstarttime = 7.00f;
  202. const float digitdecaytime = 14.00f;
  203. const float digitendtime = 15.00f;
  204. const float meshcontroltimes [MESH_COUNT][4] = {{18.97f, 20.97f, 38.97f, 38.97f},
  205. {22.97f, 24.97f, 38.97f, 38.97f},
  206. {26.97f, 28.97f, 38.97f, 38.97f},
  207. {30.97f, 32.97f, 38.97f, 38.97f},
  208. {34.97f, 36.97f, 38.97f, 38.97f}};
  209. Time += WW3D::Get_Frame_Time() * 0.001f;
  210. // For each label...
  211. for (unsigned label = 0; label < LABEL_COUNT; label++) {
  212. uint32 color;
  213. float f;
  214. if ((Time < labelcontroltimes [label][0]) || (Time > labelcontroltimes [label][3])) {
  215. f = 0.0f;
  216. } else {
  217. if (Time < labelcontroltimes [label][1]) {
  218. f = (Time - labelcontroltimes [label][0]) / (labelcontroltimes [label][1] - labelcontroltimes [label][0]);
  219. } else {
  220. if (Time < labelcontroltimes [label][2]) {
  221. f = 1.0f;
  222. } else {
  223. f = 1.0f - (Time - labelcontroltimes [label][2]) / (labelcontroltimes [label][3] - labelcontroltimes [label][2]);
  224. }
  225. }
  226. }
  227. color = ((uint32)(f * 0xff)) << 24;
  228. TextRenderers [label]->Reset_Polys();
  229. TextRenderers [label]->Draw_Sentence (color | (RGBA_TO_INT32 (255, 213, 40, 0)));
  230. }
  231. // Process binary digits.
  232. if (Time > digitstarttime) {
  233. if (Time < digitendtime) {
  234. const int digitthreshhold = 32;
  235. if (Time < digitdecaytime) {
  236. const unsigned randomness = 32;
  237. const WCHAR *text [2] = {L"0", L"1"};
  238. Render2DSentenceClass *digit;
  239. int w, h, bits;
  240. bool windowed;
  241. float oow, ooh;
  242. // Remove a digit?
  243. if (Digits.Count() > digitthreshhold) {
  244. delete Digits [0];
  245. Digits.Delete (0);
  246. }
  247. // Add another digit.
  248. WW3D::Get_Render_Target_Resolution (w, h, bits, windowed);
  249. oow = ((float) w) / randomness;
  250. ooh = ((float) h) / randomness;
  251. digit = new Render2DSentenceClass;
  252. StyleMgrClass::Assign_Font (digit, StyleMgrClass::FONT_CREDITS);
  253. digit->Build_Sentence (text [_randomnumber (0, 1)]);
  254. digit->Set_Location (Vector2 (floorf (_randomnumber (0, randomness) * oow), floorf (_randomnumber (0, randomness) * ooh)));
  255. digit->Reset_Polys();
  256. digit->Draw_Sentence (RGBA_TO_INT32 (255, 213, 40, 255));
  257. Digits.Add (digit);
  258. } else {
  259. // Remove a digit?
  260. if (Digits.Count() > 0) {
  261. delete Digits [0];
  262. Digits.Delete (0);
  263. }
  264. }
  265. } else {
  266. // Remove all digits.
  267. for (int d = 0; d < Digits.Count(); d++) {
  268. delete Digits [d];
  269. }
  270. Digits.Clear();
  271. }
  272. }
  273. // For each mesh...
  274. for (unsigned mesh = 0; mesh < MESH_COUNT; mesh++) {
  275. float f;
  276. if ((Time < meshcontroltimes [mesh][0]) || (Time > meshcontroltimes [mesh][3])) {
  277. f = 0.0f;
  278. } else {
  279. if (Time < meshcontroltimes [mesh][1]) {
  280. f = (Time - meshcontroltimes [mesh][0]) / (meshcontroltimes [mesh][1] - meshcontroltimes [mesh][0]);
  281. } else {
  282. if (Time < meshcontroltimes [mesh][2]) {
  283. f = 1.0f;
  284. } else {
  285. f = 1.0f - (Time - meshcontroltimes [mesh][2]) / (meshcontroltimes [mesh][3] - meshcontroltimes [mesh][2]);
  286. }
  287. }
  288. }
  289. Materials [mesh]->Set_Opacity (f);
  290. }
  291. MenuDialogClass::On_Frame_Update();
  292. // Has the animation played out?
  293. if (Time > Get_BackDrop()->Peek_Model()->Peek_Animation()->Get_Total_Time()) {
  294. End_Dialog();
  295. }
  296. }
  297. /***********************************************************************************************
  298. * TransitionDialogClass::Position -- *
  299. * *
  300. * INPUT: *
  301. * *
  302. * OUTPUT: *
  303. * *
  304. * WARNINGS: *
  305. * *
  306. * HISTORY: *
  307. * 08/22/01 IML : Created. *
  308. *=============================================================================================*/
  309. Vector2 TransitionDialogClass::Position (int controlid, const WideStringClass &text)
  310. {
  311. DialogTextClass *textcontrol;
  312. RectClass rect;
  313. Vector2 textextent;
  314. DWORD style;
  315. Vector2 position;
  316. textcontrol = Get_Dlg_Item (controlid)->As_DialogTextClass();
  317. rect = textcontrol->Get_Client_Rect();
  318. textextent = TextRenderers [0]->Get_Text_Extents (text);
  319. style = textcontrol->Get_Style();
  320. if ((style & 0xF) == SS_RIGHT) {
  321. position.X = rect.Right - textextent.X;
  322. } else {
  323. if ((style & 0xF) == SS_CENTER) {
  324. position.X = rect.Left + (0.5f * (rect.Width() - textextent.X));
  325. } else {
  326. position.X = rect.Left;
  327. }
  328. }
  329. position.Y = rect.Top;
  330. position.X = (int) position.X;
  331. position.Y = (int) position.Y;
  332. return (position);
  333. }
  334. /***********************************************************************************************
  335. * TransitionDialogClass::Render -- *
  336. * *
  337. * INPUT: *
  338. * *
  339. * OUTPUT: *
  340. * *
  341. * WARNINGS: *
  342. * *
  343. * HISTORY: *
  344. * 08/22/01 IML : Created. *
  345. *=============================================================================================*/
  346. void TransitionDialogClass::Render (void)
  347. {
  348. MenuDialogClass::Render();
  349. // Render the binary digits.
  350. for (int d = 0; d < Digits.Count(); d++) {
  351. Digits [d]->Render();
  352. }
  353. // Render the labels.
  354. for (unsigned label = 0; label < LABEL_COUNT; label++) {
  355. TextRenderers [label]->Render();
  356. }
  357. }