fix: defer plugin load until after ImGui has rendered its first frame

This commit is contained in:
goat 2021-04-26 22:22:11 +02:00
parent f6548fbec7
commit 51e81d8dfd
No known key found for this signature in database
GPG key ID: F18F057873895461
3 changed files with 43 additions and 28 deletions

View file

@ -182,6 +182,8 @@ namespace Dalamud
/// </summary>
internal bool IsReady { get; private set; }
internal bool IsLoadedPluginSystem => this.PluginManager != null;
/// <summary>
/// Gets location of stored assets.
/// </summary>
@ -241,10 +243,6 @@ namespace Dalamud
Log.Information("[SPOST] LOC OK!");
this.PluginRepository =
new PluginRepository(this, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion);
Log.Information("[SPOST] PREPO OK!");
var isInterfaceLoaded = false;
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") ?? "false"))
@ -293,28 +291,6 @@ namespace Dalamud
Log.Information("[SPOST] CH OK!");
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false"))
{
try
{
this.PluginRepository.CleanupPlugins();
Log.Information("[SPOST] PRC OK!");
this.PluginManager = new PluginManager(
this,
this.StartInfo.PluginDirectory,
this.StartInfo.DefaultPluginDirectory);
this.PluginManager.LoadPlugins();
Log.Information("[SPOST] PM OK!");
}
catch (Exception ex)
{
Log.Error(ex, "Plugin load failed.");
}
}
this.ClientState.Enable();
Log.Information("[SPOST] CS ENABLE!");
@ -339,6 +315,40 @@ namespace Dalamud
}
}
public void LoadPluginSystem()
{
Log.Information("[LPS] START!");
this.PluginRepository =
new PluginRepository(this, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion);
Log.Information("[LPS] PREPO OK!");
if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false"))
{
try
{
this.PluginRepository.CleanupPlugins();
Log.Information("[LPS] PRC OK!");
this.PluginManager = new PluginManager(
this,
this.StartInfo.PluginDirectory,
this.StartInfo.DefaultPluginDirectory);
this.PluginManager.LoadPlugins();
Log.Information("[LPS] PM OK!");
}
catch (Exception ex)
{
Log.Error(ex, "Plugin load failed.");
}
}
Log.Information("[LPS] OK!");
}
/// <summary>
/// Queue an unload of Dalamud when it gets the chance.
/// </summary>

View file

@ -134,6 +134,9 @@ namespace Dalamud.Game.Internal {
if (!this.dalamud.IsReady)
this.dalamud.StartSubsystems();
if (!this.dalamud.IsLoadedPluginSystem && this.dalamud.InterfaceManager.IsReady)
this.dalamud.LoadPluginSystem();
try {
Gui.Chat.UpdateQueue(this);
Gui.Toast.UpdateQueue();

View file

@ -70,6 +70,8 @@ namespace Dalamud.Interface
public bool FontsReady { get; set; } = false;
public bool IsReady => this.scene != null;
public InterfaceManager(Dalamud dalamud, SigScanner scanner)
{
this.dalamud = dalamud;
@ -281,8 +283,8 @@ namespace Dalamud.Interface
}
ImGuiHelpers.MainViewport = ImGui.GetMainViewport();
Log.Information("[IM] Scene & ImGui setup OK!");
Log.Information("[IM] Scene & ImGui setup OK!");
}
// Process information needed by ImGuiHelpers each frame.