diff --git a/OpenDreamClient/ClientContentIoC.cs b/OpenDreamClient/ClientContentIoC.cs index 608d1c6535..3236e9e161 100644 --- a/OpenDreamClient/ClientContentIoC.cs +++ b/OpenDreamClient/ClientContentIoC.cs @@ -4,14 +4,14 @@ using OpenDreamClient.Resources; using OpenDreamClient.States; -namespace OpenDreamClient { - public static class ClientContentIoC { - public static void Register() { - IoCManager.Register(); - IoCManager.Register(); - IoCManager.Register(); - IoCManager.Register(); - IoCManager.Register(); - } +namespace OpenDreamClient; + +internal static class ClientContentIoC { + public static void Register() { + IoCManager.Register(); + IoCManager.Register(); + IoCManager.Register(); + IoCManager.Register(); + IoCManager.Register(); } } diff --git a/OpenDreamClient/EntryPoint.cs b/OpenDreamClient/EntryPoint.cs index 1f4fa8484e..60e3541716 100644 --- a/OpenDreamClient/EntryPoint.cs +++ b/OpenDreamClient/EntryPoint.cs @@ -3,10 +3,12 @@ using OpenDreamClient.Interface; using OpenDreamClient.Resources; using OpenDreamClient.States; +using OpenDreamClient.States.MainMenu; using OpenDreamShared; using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Map; +using Robust.Client.State; using Robust.Client.UserInterface; using Robust.Client.WebView; using Robust.Shared; @@ -14,89 +16,90 @@ using Robust.Shared.ContentPack; using Robust.Shared.Timing; -namespace OpenDreamClient { - public sealed class EntryPoint : GameClient { - [Dependency] private readonly IDreamInterfaceManager _dreamInterface = default!; - [Dependency] private readonly IDreamResourceManager _dreamResource = default!; - [Dependency] private readonly IDreamSoundEngine _soundEngine = default!; - [Dependency] private readonly IOverlayManager _overlayManager = default!; - [Dependency] private readonly ILightManager _lightManager = default!; - - private const string UserAgent = - "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)"; - - public override void PreInit() { - var config = IoCManager.Resolve(); - if (config.GetCVar(OpenDreamCVars.SpoofIEUserAgent)) { - config.OverrideDefault(WCVars.WebUserAgentOverride, UserAgent); - } - - IoCManager.Resolve().SystemLoaded += OnEntitySystemLoaded; +namespace OpenDreamClient; + +public sealed class EntryPoint : GameClient { + [Dependency] private readonly IDreamInterfaceManager _dreamInterface = default!; + [Dependency] private readonly IDreamResourceManager _dreamResource = default!; + [Dependency] private readonly IDreamSoundEngine _soundEngine = default!; + [Dependency] private readonly IOverlayManager _overlayManager = default!; + [Dependency] private readonly ILightManager _lightManager = default!; + [Dependency] private readonly IConfigurationManager _configManager = default!; + [Dependency] private readonly IStateManager _stateManager = default!; + [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; + [Dependency] private readonly IComponentFactory _componentFactory = default!; + [Dependency] private readonly ILocalizationManager _contentLoc = default!; + + private const string UserAgent = + "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)"; + + public override void PreInit() { + var config = IoCManager.Resolve(); + if (config.GetCVar(OpenDreamCVars.SpoofIEUserAgent)) { + config.OverrideDefault(WCVars.WebUserAgentOverride, UserAgent); } - public override void Init() { - IoCManager.Resolve().OverrideDefault(CVars.NetPredict, false); - - IComponentFactory componentFactory = IoCManager.Resolve(); - componentFactory.DoAutoRegistrations(); - - ClientContentIoC.Register(); - - // This needs to happen after all IoC registrations, but before IoC.BuildGraph(); - foreach (var callback in TestingCallbacks) { - var cast = (ClientModuleTestingCallbacks) callback; - cast.ClientBeforeIoC?.Invoke(); - } + IoCManager.Resolve().SystemLoaded += OnEntitySystemLoaded; + } - IoCManager.BuildGraph(); - IoCManager.InjectDependencies(this); + public override void Init() { + ClientContentIoC.Register(); - IoCManager.Resolve().Initialize(); + // This needs to happen after all IoC registrations, but before IoC.BuildGraph(); + foreach (var callback in TestingCallbacks) { + var cast = (ClientModuleTestingCallbacks) callback; + cast.ClientBeforeIoC?.Invoke(); + } - componentFactory.GenerateNetIds(); + IoCManager.BuildGraph(); + IoCManager.InjectDependencies(this); - _dreamResource.Initialize(); + _componentFactory.DoAutoRegistrations(); - // Load localization. Needed for some engine texts, such as the ones in Robust ViewVariables. - IoCManager.Resolve().LoadCulture(new CultureInfo("en-US")); + _componentFactory.GenerateNetIds(); + // Load localization. Needed for some engine texts, such as the ones in Robust ViewVariables. + _contentLoc.LoadCulture(new CultureInfo("en-US")); + _dreamResource.Initialize(); - IoCManager.Resolve().SetWindowTitle("OpenDream"); - } + _configManager.OverrideDefault(CVars.NetPredict, false); + } - public override void PostInit() { - _lightManager.Enabled = false; + public override void PostInit() { + base.PostInit(); + _lightManager.Enabled = false; - // In PostInit() since the engine stylesheet gets set in Init() - IoCManager.Resolve().Stylesheet = DreamStylesheet.Make(); + // In PostInit() since the engine stylesheet gets set in Init() + _userInterfaceManager.Stylesheet = DreamStylesheet.Make(); + IoCManager.Resolve().Initialize(); // later hooked for stylesheet + _stateManager.RequestStateChange(); // reset state - _dreamInterface.Initialize(); - IoCManager.Resolve().Initialize(); - } + _dreamInterface.Initialize(); + IoCManager.Resolve().Initialize(); + } - protected override void Dispose(bool disposing) { - _dreamResource.Shutdown(); - } + protected override void Dispose(bool disposing) { + _dreamResource.Shutdown(); + } - public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs) { - switch (level) { - case ModUpdateLevel.FramePostEngine: - _dreamInterface.FrameUpdate(frameEventArgs); - break; - case ModUpdateLevel.PostEngine: - _soundEngine.StopFinishedChannels(); - break; - } + public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs) { + switch (level) { + case ModUpdateLevel.FramePostEngine: + _dreamInterface.FrameUpdate(frameEventArgs); + break; + case ModUpdateLevel.PostEngine: + _soundEngine.StopFinishedChannels(); + break; } + } - // As of RobustToolbox v0.90.0.0 there's a TileEdgeOverlay that breaks our rendering - // because we don't have an ITileDefinition for each tile. - // This removes that overlay immediately after MapSystem adds it. - // TODO: Fix this engine-side - private void OnEntitySystemLoaded(object? sender, SystemChangedArgs e) { - if (e.System is not MapSystem) - return; + // As of RobustToolbox v0.90.0.0 there's a TileEdgeOverlay that breaks our rendering + // because we don't have an ITileDefinition for each tile. + // This removes that overlay immediately after MapSystem adds it. + // TODO: Fix this engine-side + private void OnEntitySystemLoaded(object? sender, SystemChangedArgs e) { + if (e.System is not MapSystem) + return; - _overlayManager.RemoveOverlay(); - } + _overlayManager.RemoveOverlay(); } }