mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Add progress bar to boot plugin loads, show which are pending
This commit is contained in:
parent
e29171cc99
commit
f482badd8e
2 changed files with 46 additions and 30 deletions
|
|
@ -9,7 +9,6 @@ using System.Runtime.InteropServices;
|
||||||
using CheapLoc;
|
using CheapLoc;
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Console;
|
using Dalamud.Console;
|
||||||
using Dalamud.Data;
|
|
||||||
using Dalamud.Game.Addon.Lifecycle;
|
using Dalamud.Game.Addon.Lifecycle;
|
||||||
using Dalamud.Game.ClientState;
|
using Dalamud.Game.ClientState;
|
||||||
using Dalamud.Game.ClientState.Conditions;
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
|
|
@ -46,12 +45,10 @@ using ImPlotNET;
|
||||||
using PInvoke;
|
using PInvoke;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
using Task = System.Threading.Tasks.Task;
|
|
||||||
|
|
||||||
namespace Dalamud.Interface.Internal;
|
namespace Dalamud.Interface.Internal;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This plugin implements all of the Dalamud interface separately, to allow for reloading of the interface and rapid prototyping.
|
/// This plugin implements all the Dalamud interface separately, to allow for reloading of the interface and rapid prototyping.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ServiceManager.EarlyLoadedService]
|
[ServiceManager.EarlyLoadedService]
|
||||||
internal class DalamudInterface : IInternalDisposableService
|
internal class DalamudInterface : IInternalDisposableService
|
||||||
|
|
@ -1015,7 +1012,7 @@ internal class DalamudInterface : IInternalDisposableService
|
||||||
|
|
||||||
if (ImGui.MenuItem("Scan dev plugins"))
|
if (ImGui.MenuItem("Scan dev plugins"))
|
||||||
{
|
{
|
||||||
Task.Run(pluginManager.ScanDevPluginsAsync);
|
_ = pluginManager.ScanDevPluginsAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
|
||||||
|
|
@ -473,6 +473,36 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
configuration.QueueSave();
|
configuration.QueueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void DrawProgressBar<T>(IEnumerable<T> items, Func<T, bool> pendingFunc, Func<T, bool> totalFunc, Action<T> renderPending)
|
||||||
|
{
|
||||||
|
var windowSize = ImGui.GetWindowSize();
|
||||||
|
|
||||||
|
var numLoaded = 0;
|
||||||
|
var total = 0;
|
||||||
|
|
||||||
|
var itemsArray = items as T[] ?? items.ToArray();
|
||||||
|
var allPending = itemsArray.Where(pendingFunc)
|
||||||
|
.ToArray();
|
||||||
|
var allLoadedOrLoading = itemsArray.Count(totalFunc);
|
||||||
|
|
||||||
|
// Cap number of items we show to avoid clutter
|
||||||
|
const int maxShown = 3;
|
||||||
|
foreach (var repo in allPending.Take(maxShown))
|
||||||
|
{
|
||||||
|
renderPending(repo);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGuiHelpers.ScaledDummy(10);
|
||||||
|
|
||||||
|
numLoaded += allLoadedOrLoading - allPending.Length;
|
||||||
|
total += allLoadedOrLoading;
|
||||||
|
if (numLoaded != total)
|
||||||
|
{
|
||||||
|
ImGui.SetCursorPosX(windowSize.X / 3);
|
||||||
|
ImGui.ProgressBar(numLoaded / (float)total, new Vector2(windowSize.X / 3, 50), $"{numLoaded}/{total}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SetOpenPage(PluginInstallerOpenKind kind)
|
private void SetOpenPage(PluginInstallerOpenKind kind)
|
||||||
{
|
{
|
||||||
switch (kind)
|
switch (kind)
|
||||||
|
|
@ -576,40 +606,29 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
if (pluginManager.PluginsReady && !pluginManager.ReposReady)
|
if (pluginManager.PluginsReady && !pluginManager.ReposReady)
|
||||||
{
|
{
|
||||||
ImGuiHelpers.CenteredText("Loading repositories...");
|
ImGuiHelpers.CenteredText("Loading repositories...");
|
||||||
|
ImGuiHelpers.ScaledDummy(10);
|
||||||
|
|
||||||
|
DrawProgressBar(pluginManager.Repos, x => x.State != PluginRepositoryState.Success &&
|
||||||
|
x.State != PluginRepositoryState.Fail &&
|
||||||
|
x.IsEnabled,
|
||||||
|
x => x.IsEnabled,
|
||||||
|
x => ImGuiHelpers.CenteredText($"Loading {x.PluginMasterUrl}"));
|
||||||
}
|
}
|
||||||
else if (!pluginManager.PluginsReady && pluginManager.ReposReady)
|
else if (!pluginManager.PluginsReady && pluginManager.ReposReady)
|
||||||
{
|
{
|
||||||
ImGuiHelpers.CenteredText("Loading installed plugins...");
|
ImGuiHelpers.CenteredText("Loading installed plugins...");
|
||||||
|
ImGuiHelpers.ScaledDummy(10);
|
||||||
|
|
||||||
|
DrawProgressBar(pluginManager.InstalledPlugins, x => x.State == PluginState.Loading,
|
||||||
|
x => x.State is PluginState.Loaded or
|
||||||
|
PluginState.LoadError or
|
||||||
|
PluginState.Loading,
|
||||||
|
x => ImGuiHelpers.CenteredText($"Loading {x.Name}"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImGuiHelpers.CenteredText("Loading repositories and plugins...");
|
ImGuiHelpers.CenteredText("Loading repositories and plugins...");
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentProgress = 0;
|
|
||||||
var total = 0;
|
|
||||||
|
|
||||||
var pendingRepos = pluginManager.Repos.ToArray()
|
|
||||||
.Where(x => (x.State != PluginRepositoryState.Success &&
|
|
||||||
x.State != PluginRepositoryState.Fail) &&
|
|
||||||
x.IsEnabled)
|
|
||||||
.ToArray();
|
|
||||||
var allRepoCount =
|
|
||||||
pluginManager.Repos.Count(x => x.State != PluginRepositoryState.Fail && x.IsEnabled);
|
|
||||||
|
|
||||||
foreach (var repo in pendingRepos)
|
|
||||||
{
|
|
||||||
ImGuiHelpers.CenteredText($"{repo.PluginMasterUrl}: {repo.State}");
|
|
||||||
}
|
|
||||||
|
|
||||||
currentProgress += allRepoCount - pendingRepos.Length;
|
|
||||||
total += allRepoCount;
|
|
||||||
|
|
||||||
if (currentProgress != total)
|
|
||||||
{
|
|
||||||
ImGui.SetCursorPosX(windowSize.X / 3);
|
|
||||||
ImGui.ProgressBar(currentProgress / (float)total, new Vector2(windowSize.X / 3, 50));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue