Installer.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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/Installer.h $*
  25. * *
  26. * $Author:: Ian_l $*
  27. * *
  28. * $Modtime:: 1/17/02 5:01p $*
  29. * *
  30. * $Revision:: 13 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef _INSTALLER_H
  36. #define _INSTALLER_H
  37. // Includes.
  38. #include "RegistryManager.h"
  39. #include "Utilities.h"
  40. #include "Wwuiinput.h"
  41. // Forward declarations.
  42. class AudibleSoundClass;
  43. class CardSelectionDialogClass;
  44. class CopyDialogClass;
  45. class DialogBaseClass;
  46. class FinalDialogClass;
  47. class GameDirectoryDialogClass;
  48. class GameFolderDialogClass;
  49. class INIClass;
  50. class NDADialogClass;
  51. class LicenseDialogClass;
  52. class MixFileFactoryClass;
  53. class ReviewDialogClass;
  54. class SerialDialogClass;
  55. class WelcomeDialogClass;
  56. class WhatToInstallDialogClass;
  57. class WOL1DialogClass;
  58. class WOL2DialogClass;
  59. class WOLDirectoryDialogClass;
  60. class WOLFolderDialogClass;
  61. class WWAudioClass;
  62. class WW3DAssetManager;
  63. // Class definitions.
  64. class InstallerUIInputClass : public WWUIInputClass
  65. {
  66. public:
  67. InstallerUIInputClass() : WWUIInputClass(), MousePosition (Vector3 (0.0f, 0.0f, 0.0f)) {}
  68. void Add_Mouse_Wheel (short delta)
  69. {
  70. MousePosition.Z += delta;
  71. }
  72. private:
  73. const Vector3 &Get_Mouse_Pos (void) const
  74. {
  75. POINT cursorposition;
  76. GetCursorPos (&cursorposition);
  77. ScreenToClient (MainWindow, &cursorposition);
  78. MousePosition.X = cursorposition.x;
  79. MousePosition.Y = cursorposition.y;
  80. return (MousePosition);
  81. }
  82. void Set_Mouse_Pos (const Vector3 &position)
  83. {
  84. POINT p;
  85. if (GameInFocus) {
  86. p.x = position.X;
  87. p.y = position.Y;
  88. ClientToScreen (MainWindow, &p);
  89. SetCursorPos (p.x, p.y);
  90. MousePosition.X = p.x;
  91. MousePosition.Y = p.y;
  92. }
  93. }
  94. bool Is_Button_Down (int vk_mouse_button_id)
  95. {
  96. bool retval = false;
  97. switch (vk_mouse_button_id)
  98. {
  99. case VK_LBUTTON:
  100. case VK_MBUTTON:
  101. case VK_RBUTTON:
  102. retval = (GetKeyState (vk_mouse_button_id) & 0x80000000) != 0x0;
  103. break;
  104. }
  105. return retval;
  106. }
  107. mutable Vector3 MousePosition;
  108. };
  109. class FileLogClass {
  110. public:
  111. // Equality operator.
  112. bool operator == (const FileLogClass &f) {
  113. return ((RelativePathname == f.RelativePathname) && (Size == f.Size));
  114. }
  115. // Inequality operator.
  116. bool operator != (const FileLogClass &f) {
  117. return (!(*this == f));
  118. }
  119. WideStringClass RelativePathname; // Relative pathname of file.
  120. __int64 Size; // Size of file (in bytes).
  121. };
  122. class InstallerClass
  123. {
  124. public:
  125. InstallerClass();
  126. ~InstallerClass();
  127. InstallerUIInputClass *Get_Input() {return (UIInput);}
  128. void Cancel_Introduction() {CancelIntroduction = true;}
  129. void Install (MixFileFactoryClass *mixfilefactory);
  130. void Dialog_Callback (DialogBaseClass *dialog, int ctrl_id, int message_id, DWORD param);
  131. void On_Prog_End();
  132. // Main interface.
  133. const WCHAR *Get_Source_Game_Path (WideStringClass &path) {path = SourceGamePath; return (path);}
  134. const WCHAR *Get_Source_WOL_Path (WideStringClass &path) {path = SourceWOLPath; return (path);}
  135. bool Install_Game();
  136. bool Install_WOL();
  137. bool Install_Game_Shortcut();
  138. __int64 Get_Game_Size (bool ondisk);
  139. __int64 Get_WOL_Size (bool ondisk);
  140. __int64 Get_Total_Size (bool ondisk);
  141. bool Get_Game_Space_Available (const WideStringClass &path, __int64 &diskspace) {return (Get_Disk_Space_Available (path, diskspace));}
  142. bool Get_WOL_Space_Available (const WideStringClass &path, __int64 &diskspace);
  143. const char *Get_Serial_Number (StringClass &serialnumber);
  144. const WCHAR *Get_Target_Game_Path (WideStringClass &path);
  145. bool Get_Target_Sub_Path (unsigned index, WideStringClass &subdirectoryname);
  146. const WCHAR *Get_Target_WOL_Path (WideStringClass &path);
  147. const WCHAR *Get_Target_Game_Folder (WideStringClass &folder);
  148. const WCHAR *Get_Target_WOL_Folder (WideStringClass &folder);
  149. bool Is_Fresh_Game_Install() {return (FreshGameInstall);}
  150. bool Is_Fresh_WOL_Install() {return (FreshWOLInstall);}
  151. bool Is_Target_WOL_Older_Than_Source() {return (TargetWOLOlder);}
  152. WW3DAssetManager *Get_Asset_Manager() {return (AssetManager);}
  153. bool Can_Use_IGR_Settings();
  154. bool Use_IGR_Settings();
  155. bool Beta_Test();
  156. // Registry interface.
  157. void Update_Registry();
  158. void Create_Links();
  159. bool Get_WOL_Account (unsigned index, WideStringClass &name, WideStringClass &password);
  160. void Set_Preferred_WOL_Account (const WideStringClass &accountname) {_RegistryManager.Set_Preferred_WOL_Account (accountname);}
  161. // File/subdirectory logging interface.
  162. void Log (const WideStringClass &pathname, __int64 size = -1);
  163. void Create_Uninstall_Logs();
  164. protected:
  165. enum ProgEndActionEnum {
  166. ACTION_NONE,
  167. ACTION_RUN_GAME,
  168. ACTION_DISPLAY_README
  169. };
  170. // Internal initialization/shutdown.
  171. void Initialize();
  172. void Shutdown();
  173. bool WW3D_Initialize (int cardselection = -1);
  174. void WW3D_Shutdown();
  175. // Support functions.
  176. bool Check_Source();
  177. void Count_Source_Files (const WideStringClass &sourcepath, unsigned &filecount, __int64 &filesize);
  178. void Check_Existing_Install();
  179. void Auto_Configure();
  180. bool Register_COM_Server (const WideStringClass &comdll);
  181. void Create_Encryption_File (const WideStringClass &pathname);
  182. void Encrypt (const char *number, const WideStringClass &pathname, StringClass &encryptednumber);
  183. bool Create_File_Link (const WideStringClass &linkpath, const WideStringClass &title, const WideStringClass &targetpathname, const WideStringClass &iconpathname, const WideStringClass *arguments = NULL);
  184. bool Create_URL_Link (const WideStringClass &linkpath, const WideStringClass &title, const WideStringClass &url);
  185. bool Has_WOL_Account();
  186. void Create_Game_Uninstall_Log();
  187. void Create_WOL_Uninstall_Log();
  188. void Run_Game();
  189. void Display_Readme();
  190. // Data.
  191. INIClass *SetupIni;
  192. INIClass *GameIni;
  193. INIClass *WOLIni;
  194. WideStringClass SourceGamePath;
  195. WideStringClass SourceWOLPath;
  196. MixFileFactoryClass *MixFileFactory;
  197. DynamicVectorClass <WideStringClass> FontNames;
  198. WideStringClass TargetGamePath;
  199. bool FreshGameInstall;
  200. bool FreshWOLInstall;
  201. bool TargetWOLOlder;
  202. unsigned GameFileCount;
  203. __int64 GameSize;
  204. unsigned WOLFileCount;
  205. __int64 WOLSize;
  206. WW3DAssetManager *AssetManager;
  207. bool WwmathInitialized;
  208. bool DialogMgrInitialized;
  209. WWAudioClass *AudioSystem;
  210. AudibleSoundClass *TransitionMusic;
  211. AudibleSoundClass *InstallMusic;
  212. InstallerUIInputClass *UIInput;
  213. bool CancelIntroduction;
  214. bool CancelApplication;
  215. WelcomeDialogClass *WelcomeDialog;
  216. NDADialogClass *NDADialog;
  217. LicenseDialogClass *LicenseDialog;
  218. SerialDialogClass *SerialDialog;
  219. WhatToInstallDialogClass *WhatToInstallDialog;
  220. GameDirectoryDialogClass *GameDirectoryDialog;
  221. GameFolderDialogClass *GameFolderDialog;
  222. WOLDirectoryDialogClass *WOLDirectoryDialog;
  223. WOLFolderDialogClass *WOLFolderDialog;
  224. ReviewDialogClass *ReviewDialog;
  225. CopyDialogClass *CopyDialog;
  226. WOL1DialogClass *WOL1Dialog;
  227. WOL2DialogClass *WOL2Dialog;
  228. FinalDialogClass *FinalDialog;
  229. CardSelectionDialogClass *CardSelectionDialog;
  230. DynamicVectorClass <WideStringClass> GameSubdirectories;
  231. DynamicVectorClass <FileLogClass> GameFiles;
  232. DynamicVectorClass <FileLogClass> WOLFiles;
  233. ProgEndActionEnum ProgEndAction;
  234. };
  235. // Singleton.
  236. extern InstallerClass _Installer;
  237. #endif // INSTALLER_H