fix: DalamudInterface load after scene init

This commit is contained in:
goat 2021-04-28 16:39:45 +02:00
parent 2d47ae61ef
commit d83aabafe2
No known key found for this signature in database
GPG key ID: F18F057873895461
3 changed files with 32 additions and 39 deletions

View file

@ -189,7 +189,7 @@ namespace Dalamud
/// </summary> /// </summary>
internal DirectoryInfo AssetDirectory => new DirectoryInfo(this.StartInfo.AssetDirectory); internal DirectoryInfo AssetDirectory => new DirectoryInfo(this.StartInfo.AssetDirectory);
public void Start() public void LoadTier1()
{ {
// Initialize the process information. // Initialize the process information.
this.TargetModule = Process.GetCurrentProcess().MainModule; this.TargetModule = Process.GetCurrentProcess().MainModule;
@ -198,42 +198,40 @@ namespace Dalamud
// Initialize game subsystem // Initialize game subsystem
this.Framework = new Framework(this.SigScanner, this); this.Framework = new Framework(this.SigScanner, this);
Log.Information("[SPRE] Framework OK!"); Log.Information("[T1] Framework OK!");
this.Framework.Enable(); this.Framework.Enable();
Log.Information("[SPRE] Framework ENABLE!"); Log.Information("[T1] Framework ENABLE!");
} }
/// <summary> /// <summary>
/// Start and initialize Dalamud subsystems. /// Start and initialize Dalamud subsystems.
/// </summary> /// </summary>
public void StartSubsystems() public void LoadTier2()
{ {
try try
{ {
this.Configuration = DalamudConfiguration.Load(this.StartInfo.ConfigurationPath); this.Configuration = DalamudConfiguration.Load(this.StartInfo.ConfigurationPath);
Log.Information("[SPOST] Scanner OK!");
this.AntiDebug = new AntiDebug(this.SigScanner); this.AntiDebug = new AntiDebug(this.SigScanner);
#if DEBUG #if DEBUG
this.AntiDebug.Enable(); this.AntiDebug.Enable();
#endif #endif
Log.Information("[SPOST] AntiDebug OK!"); Log.Information("[T2] AntiDebug OK!");
this.WinSock2 = new WinSockHandlers(); this.WinSock2 = new WinSockHandlers();
Log.Information("[SPOST] WinSock OK!"); Log.Information("[T2] WinSock OK!");
this.NetworkHandlers = new NetworkHandlers(this, this.StartInfo.OptOutMbCollection); this.NetworkHandlers = new NetworkHandlers(this, this.StartInfo.OptOutMbCollection);
Log.Information("[SPOST] NH OK!"); Log.Information("[T2] NH OK!");
this.ClientState = new ClientState(this, this.StartInfo, this.SigScanner); this.ClientState = new ClientState(this, this.StartInfo, this.SigScanner);
Log.Information("[SPOST] CS OK!"); Log.Information("[T2] CS OK!");
this.LocalizationManager = new Localization(Path.Combine(this.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_"); this.LocalizationManager = new Localization(Path.Combine(this.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_");
if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride)) if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride))
@ -241,10 +239,8 @@ namespace Dalamud
else else
this.LocalizationManager.SetupWithUiCulture(); this.LocalizationManager.SetupWithUiCulture();
Log.Information("[SPOST] LOC OK!"); Log.Information("[T2] LOC OK!");
var isInterfaceLoaded = false;
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") ?? "false")) if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") ?? "false"))
{ {
try try
@ -252,9 +248,8 @@ namespace Dalamud
this.InterfaceManager = new InterfaceManager(this, this.SigScanner); this.InterfaceManager = new InterfaceManager(this, this.SigScanner);
this.InterfaceManager.Enable(); this.InterfaceManager.Enable();
isInterfaceLoaded = true;
Log.Information("[SPOST] IM OK!"); Log.Information("[T2] IM OK!");
} }
catch (Exception e) catch (Exception e)
{ {
@ -274,43 +269,34 @@ namespace Dalamud
return; return;
} }
Log.Information("[SPOST] Data OK!"); Log.Information("[T2] Data OK!");
this.SeStringManager = new SeStringManager(this.Data); this.SeStringManager = new SeStringManager(this.Data);
Log.Information("[SPOST] SeString OK!"); Log.Information("[T2] SeString OK!");
// Initialize managers. Basically handlers for the logic // Initialize managers. Basically handlers for the logic
this.CommandManager = new CommandManager(this, this.StartInfo.Language); this.CommandManager = new CommandManager(this, this.StartInfo.Language);
this.DalamudCommands = new DalamudCommands(this); this.DalamudCommands = new DalamudCommands(this);
this.DalamudCommands.SetupCommands(); this.DalamudCommands.SetupCommands();
Log.Information("[SPOST] CM OK!"); Log.Information("[T2] CM OK!");
this.ChatHandlers = new ChatHandlers(this); this.ChatHandlers = new ChatHandlers(this);
Log.Information("[SPOST] CH OK!"); Log.Information("[T2] CH OK!");
this.ClientState.Enable(); this.ClientState.Enable();
Log.Information("[SPOST] CS ENABLE!"); Log.Information("[T2] CS ENABLE!");
this.DalamudUi = new DalamudInterface(this);
this.InterfaceManager.OnDraw += this.DalamudUi.Draw;
Log.Information("[SPOST] DUI OK!");
this.SystemMenu = new DalamudSystemMenu(this); this.SystemMenu = new DalamudSystemMenu(this);
this.SystemMenu.Enable(); this.SystemMenu.Enable();
this.IsReady = true; this.IsReady = true;
Troubleshooting.LogTroubleshooting(this, isInterfaceLoaded);
Log.Information("Dalamud is ready.");
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "Dalamud::Start() failed."); Log.Error(ex, "Dalamud::LoadTier2() failed.");
this.Unload(); this.Unload();
} }
} }
@ -318,14 +304,19 @@ namespace Dalamud
/// <summary> /// <summary>
/// Loads the plugin manager and repository. /// Loads the plugin manager and repository.
/// </summary> /// </summary>
public void LoadPluginSystem() public void LoadTier3()
{ {
Log.Information("[LPS] START!"); Log.Information("[T3] START!");
this.DalamudUi = new DalamudInterface(this);
this.InterfaceManager.OnDraw += this.DalamudUi.Draw;
Log.Information("[T3] DUI OK!");
this.PluginRepository = this.PluginRepository =
new PluginRepository(this, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion); new PluginRepository(this, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion);
Log.Information("[LPS] PREPO OK!"); Log.Information("[T3] PREPO OK!");
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false")) if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false"))
{ {
@ -333,7 +324,7 @@ namespace Dalamud
{ {
this.PluginRepository.CleanupPlugins(); this.PluginRepository.CleanupPlugins();
Log.Information("[LPS] PRC OK!"); Log.Information("[T3] PRC OK!");
this.PluginManager = new PluginManager( this.PluginManager = new PluginManager(
this, this,
@ -341,7 +332,7 @@ namespace Dalamud
this.StartInfo.DefaultPluginDirectory); this.StartInfo.DefaultPluginDirectory);
this.PluginManager.LoadPlugins(); this.PluginManager.LoadPlugins();
Log.Information("[LPS] PM OK!"); Log.Information("[T3] PM OK!");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -349,7 +340,9 @@ namespace Dalamud
} }
} }
Log.Information("[LPS] OK!"); Troubleshooting.LogTroubleshooting(this, this.InterfaceManager != null);
Log.Information("Dalamud is ready.");
} }
/// <summary> /// <summary>

View file

@ -57,7 +57,7 @@ namespace Dalamud
Log.Information("Starting a session.."); Log.Information("Starting a session..");
// Run session // Run session
dalamud.Start(); dalamud.LoadTier1();
dalamud.WaitForUnload(); dalamud.WaitForUnload();
dalamud.Dispose(); dalamud.Dispose();

View file

@ -132,10 +132,10 @@ namespace Dalamud.Game.Internal {
private bool HandleFrameworkUpdate(IntPtr framework) { private bool HandleFrameworkUpdate(IntPtr framework) {
// If this is the first time we are running this loop, we need to init Dalamud subsystems synchronously // If this is the first time we are running this loop, we need to init Dalamud subsystems synchronously
if (!this.dalamud.IsReady) if (!this.dalamud.IsReady)
this.dalamud.StartSubsystems(); this.dalamud.LoadTier2();
if (!this.dalamud.IsLoadedPluginSystem && this.dalamud.InterfaceManager.IsReady) if (!this.dalamud.IsLoadedPluginSystem && this.dalamud.InterfaceManager.IsReady)
this.dalamud.LoadPluginSystem(); this.dalamud.LoadTier3();
try { try {
Gui.Chat.UpdateQueue(this); Gui.Chat.UpdateQueue(this);