EntryPoint.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. using Content.Client.Administration.Managers;
  2. using Content.Client.Changelog;
  3. using Content.Client.Chat.Managers;
  4. using Content.Client.DebugMon;
  5. using Content.Client.Eui;
  6. using Content.Client.Fullscreen;
  7. using Content.Client.GameTicking.Managers;
  8. using Content.Client.GhostKick;
  9. using Content.Client.Guidebook;
  10. using Content.Client.Input;
  11. using Content.Client.IoC;
  12. using Content.Client.Launcher;
  13. using Content.Client.Lobby;
  14. using Content.Client.MainMenu;
  15. using Content.Client.Parallax.Managers;
  16. using Content.Client.Players.PlayTimeTracking;
  17. using Content.Client.Radiation.Overlays;
  18. using Content.Client.Replay;
  19. using Content.Client.Screenshot;
  20. using Content.Client.Singularity;
  21. using Content.Client.Stylesheets;
  22. using Content.Client.Viewport;
  23. using Content.Client.Voting;
  24. using Content.Shared.Ame.Components;
  25. using Content.Shared.Gravity;
  26. using Content.Shared.Localizations;
  27. using Robust.Client;
  28. using Robust.Client.Graphics;
  29. using Robust.Client.Input;
  30. using Robust.Client.Replays.Loading;
  31. using Robust.Client.State;
  32. using Robust.Client.UserInterface;
  33. using Robust.Shared;
  34. using Robust.Shared.Configuration;
  35. using Robust.Shared.ContentPack;
  36. using Robust.Shared.Prototypes;
  37. using Robust.Shared.Replays;
  38. using Robust.Shared.Timing;
  39. namespace Content.Client.Entry
  40. {
  41. public sealed class EntryPoint : GameClient
  42. {
  43. [Dependency] private readonly IBaseClient _baseClient = default!;
  44. [Dependency] private readonly IGameController _gameController = default!;
  45. [Dependency] private readonly IStateManager _stateManager = default!;
  46. [Dependency] private readonly IComponentFactory _componentFactory = default!;
  47. [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
  48. [Dependency] private readonly IClientAdminManager _adminManager = default!;
  49. [Dependency] private readonly IParallaxManager _parallaxManager = default!;
  50. [Dependency] private readonly IConfigurationManager _configManager = default!;
  51. [Dependency] private readonly IStylesheetManager _stylesheetManager = default!;
  52. [Dependency] private readonly IScreenshotHook _screenshotHook = default!;
  53. [Dependency] private readonly FullscreenHook _fullscreenHook = default!;
  54. [Dependency] private readonly ChangelogManager _changelogManager = default!;
  55. [Dependency] private readonly ViewportManager _viewportManager = default!;
  56. [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
  57. [Dependency] private readonly IInputManager _inputManager = default!;
  58. [Dependency] private readonly IOverlayManager _overlayManager = default!;
  59. [Dependency] private readonly IChatManager _chatManager = default!;
  60. [Dependency] private readonly IClientPreferencesManager _clientPreferencesManager = default!;
  61. [Dependency] private readonly EuiManager _euiManager = default!;
  62. [Dependency] private readonly IVoteManager _voteManager = default!;
  63. [Dependency] private readonly DocumentParsingManager _documentParsingManager = default!;
  64. [Dependency] private readonly GhostKickManager _ghostKick = default!;
  65. [Dependency] private readonly ExtendedDisconnectInformationManager _extendedDisconnectInformation = default!;
  66. [Dependency] private readonly JobRequirementsManager _jobRequirements = default!;
  67. [Dependency] private readonly ContentLocalizationManager _contentLoc = default!;
  68. [Dependency] private readonly ContentReplayPlaybackManager _playbackMan = default!;
  69. [Dependency] private readonly IResourceManager _resourceManager = default!;
  70. [Dependency] private readonly IReplayLoadManager _replayLoad = default!;
  71. [Dependency] private readonly ILogManager _logManager = default!;
  72. [Dependency] private readonly DebugMonitorManager _debugMonitorManager = default!;
  73. [Dependency] private readonly TitleWindowManager _titleWindowManager = default!;
  74. public override void Init()
  75. {
  76. ClientContentIoC.Register();
  77. foreach (var callback in TestingCallbacks)
  78. {
  79. var cast = (ClientModuleTestingCallbacks)callback;
  80. cast.ClientBeforeIoC?.Invoke();
  81. }
  82. IoCManager.BuildGraph();
  83. IoCManager.InjectDependencies(this);
  84. _contentLoc.Initialize();
  85. _componentFactory.DoAutoRegistrations();
  86. _componentFactory.IgnoreMissingComponents();
  87. // Do not add to these, they are legacy.
  88. _componentFactory.RegisterClass<SharedGravityGeneratorComponent>();
  89. _componentFactory.RegisterClass<SharedAmeControllerComponent>();
  90. // Do not add to the above, they are legacy
  91. _prototypeManager.RegisterIgnore("utilityQuery");
  92. _prototypeManager.RegisterIgnore("utilityCurvePreset");
  93. _prototypeManager.RegisterIgnore("accent");
  94. _prototypeManager.RegisterIgnore("gasReaction");
  95. _prototypeManager.RegisterIgnore("seed"); // Seeds prototypes are server-only.
  96. _prototypeManager.RegisterIgnore("objective");
  97. _prototypeManager.RegisterIgnore("holiday");
  98. _prototypeManager.RegisterIgnore("htnCompound");
  99. _prototypeManager.RegisterIgnore("htnPrimitive");
  100. _prototypeManager.RegisterIgnore("gameMap");
  101. _prototypeManager.RegisterIgnore("gameMapPool");
  102. _prototypeManager.RegisterIgnore("lobbyBackground");
  103. _prototypeManager.RegisterIgnore("gamePreset");
  104. _prototypeManager.RegisterIgnore("noiseChannel");
  105. _prototypeManager.RegisterIgnore("playerConnectionWhitelist");
  106. _prototypeManager.RegisterIgnore("spaceBiome");
  107. _prototypeManager.RegisterIgnore("worldgenConfig");
  108. _prototypeManager.RegisterIgnore("gameRule");
  109. _prototypeManager.RegisterIgnore("worldSpell");
  110. _prototypeManager.RegisterIgnore("entitySpell");
  111. _prototypeManager.RegisterIgnore("instantSpell");
  112. _prototypeManager.RegisterIgnore("roundAnnouncement");
  113. _prototypeManager.RegisterIgnore("wireLayout");
  114. _prototypeManager.RegisterIgnore("alertLevels");
  115. _prototypeManager.RegisterIgnore("nukeopsRole");
  116. _prototypeManager.RegisterIgnore("ghostRoleRaffleDecider");
  117. _componentFactory.GenerateNetIds();
  118. _adminManager.Initialize();
  119. _screenshotHook.Initialize();
  120. _fullscreenHook.Initialize();
  121. _changelogManager.Initialize();
  122. _viewportManager.Initialize();
  123. _ghostKick.Initialize();
  124. _extendedDisconnectInformation.Initialize();
  125. _jobRequirements.Initialize();
  126. _playbackMan.Initialize();
  127. //AUTOSCALING default Setup!
  128. _configManager.SetCVar("interface.resolutionAutoScaleUpperCutoffX", 1080);
  129. _configManager.SetCVar("interface.resolutionAutoScaleUpperCutoffY", 720);
  130. _configManager.SetCVar("interface.resolutionAutoScaleLowerCutoffX", 520);
  131. _configManager.SetCVar("interface.resolutionAutoScaleLowerCutoffY", 240);
  132. _configManager.SetCVar("interface.resolutionAutoScaleMinimum", 0.5f);
  133. }
  134. public override void Shutdown()
  135. {
  136. base.Shutdown();
  137. _titleWindowManager.Shutdown();
  138. }
  139. public override void PostInit()
  140. {
  141. base.PostInit();
  142. _stylesheetManager.Initialize();
  143. // Setup key contexts
  144. ContentContexts.SetupContexts(_inputManager.Contexts);
  145. _parallaxManager.LoadDefaultParallax();
  146. _overlayManager.AddOverlay(new SingularityOverlay());
  147. _overlayManager.AddOverlay(new RadiationPulseOverlay());
  148. _chatManager.Initialize();
  149. _clientPreferencesManager.Initialize();
  150. _euiManager.Initialize();
  151. _voteManager.Initialize();
  152. _userInterfaceManager.SetDefaultTheme("SS14CivTheme");
  153. _userInterfaceManager.SetActiveTheme(_configManager.GetCVar(CVars.InterfaceTheme));
  154. _documentParsingManager.Initialize();
  155. _titleWindowManager.Initialize();
  156. _baseClient.RunLevelChanged += (_, args) =>
  157. {
  158. if (args.NewLevel == ClientRunLevel.Initialize)
  159. {
  160. SwitchToDefaultState(args.OldLevel == ClientRunLevel.Connected ||
  161. args.OldLevel == ClientRunLevel.InGame);
  162. }
  163. };
  164. // Disable engine-default viewport since we use our own custom viewport control.
  165. _userInterfaceManager.MainViewport.Visible = false;
  166. SwitchToDefaultState();
  167. }
  168. private void SwitchToDefaultState(bool disconnected = false)
  169. {
  170. // Fire off into state dependent on launcher or not.
  171. // Check if we're loading a replay via content bundle!
  172. if (_configManager.GetCVar(CVars.LaunchContentBundle)
  173. && _resourceManager.ContentFileExists(
  174. ReplayConstants.ReplayZipFolder.ToRootedPath() / ReplayConstants.FileMeta))
  175. {
  176. _logManager.GetSawmill("entry").Info("Loading content bundle replay from VFS!");
  177. var reader = new ReplayFileReaderResources(
  178. _resourceManager,
  179. ReplayConstants.ReplayZipFolder.ToRootedPath());
  180. _playbackMan.LastLoad = (null, ReplayConstants.ReplayZipFolder.ToRootedPath());
  181. _replayLoad.LoadAndStartReplay(reader);
  182. }
  183. else if (_gameController.LaunchState.FromLauncher)
  184. {
  185. _stateManager.RequestStateChange<LauncherConnecting>();
  186. var state = (LauncherConnecting)_stateManager.CurrentState;
  187. if (disconnected)
  188. {
  189. state.SetDisconnected();
  190. }
  191. }
  192. else
  193. {
  194. _stateManager.RequestStateChange<MainScreen>();
  195. }
  196. }
  197. public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs)
  198. {
  199. if (level == ModUpdateLevel.FramePreEngine)
  200. {
  201. _debugMonitorManager.FrameUpdate();
  202. }
  203. }
  204. }
  205. }