mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Merge pull request #373 from ascclemens/installer
This commit is contained in:
commit
0a10ff8139
2 changed files with 36 additions and 29 deletions
|
|
@ -142,24 +142,25 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - (5 * ImGui.GetIO().FontGlobalScale));
|
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - (5 * ImGui.GetIO().FontGlobalScale));
|
||||||
|
|
||||||
string initializationStatusText = null;
|
(string Text, Vector4 Color) initializationStatusText = (null, ImGuiColors.DalamudGrey);
|
||||||
if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.InProgress)
|
if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.InProgress)
|
||||||
{
|
{
|
||||||
initializationStatusText = Loc.Localize("InstallerLoading", "Loading plugins...");
|
initializationStatusText.Text = Loc.Localize("InstallerLoading", "Loading plugins...");
|
||||||
this.pluginListAvailable = null;
|
this.pluginListAvailable = null;
|
||||||
}
|
}
|
||||||
else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail)
|
else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail)
|
||||||
{
|
{
|
||||||
initializationStatusText = Loc.Localize("InstallerDownloadFailed", "Download failed.");
|
initializationStatusText.Text = Loc.Localize("InstallerDownloadFailed", "Download failed.");
|
||||||
this.pluginListAvailable = null;
|
|
||||||
}
|
|
||||||
else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.FailThirdRepo)
|
|
||||||
{
|
|
||||||
initializationStatusText = Loc.Localize("InstallerDownloadFailedThird", "One of your third party repos is unreachable or there is no internet connection.");
|
|
||||||
this.pluginListAvailable = null;
|
this.pluginListAvailable = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.FailThirdRepo)
|
||||||
|
{
|
||||||
|
initializationStatusText.Text = Loc.Localize("InstallerDownloadFailedThird", "One of your third party repos is unreachable or there is no internet connection.");
|
||||||
|
initializationStatusText.Color = ImGuiColors.DalamudRed;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.pluginListAvailable == null)
|
if (this.pluginListAvailable == null)
|
||||||
{
|
{
|
||||||
this.RefetchPlugins();
|
this.RefetchPlugins();
|
||||||
|
|
@ -310,9 +311,6 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
private void ResortPlugins()
|
private void ResortPlugins()
|
||||||
{
|
{
|
||||||
if (this.dalamud.PluginRepository.State != PluginRepository.InitializationState.Success)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var availableDefs = this.dalamud.PluginRepository.PluginMaster.Where(
|
var availableDefs = this.dalamud.PluginRepository.PluginMaster.Where(
|
||||||
x => this.pluginListInstalled.All(y => x.InternalName != y.InternalName))
|
x => this.pluginListInstalled.All(y => x.InternalName != y.InternalName))
|
||||||
.GroupBy(x => new { x.InternalName, x.AssemblyVersion })
|
.GroupBy(x => new { x.InternalName, x.AssemblyVersion })
|
||||||
|
|
@ -337,7 +335,7 @@ namespace Dalamud.Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawTab(bool installed, string statusText)
|
private void DrawTab(bool installed, (string Text, Vector4 Color) statusText)
|
||||||
{
|
{
|
||||||
if (ImGui.BeginTabItem(installed ? Loc.Localize("InstallerInstalledPluginList", "Installed Plugins")
|
if (ImGui.BeginTabItem(installed ? Loc.Localize("InstallerInstalledPluginList", "Installed Plugins")
|
||||||
: Loc.Localize("InstallerAvailablePluginList", "Available Plugins")))
|
: Loc.Localize("InstallerAvailablePluginList", "Available Plugins")))
|
||||||
|
|
@ -349,10 +347,13 @@ namespace Dalamud.Plugin
|
||||||
ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground);
|
ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground);
|
||||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 5);
|
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 5);
|
||||||
|
|
||||||
if (statusText != null)
|
if (statusText.Text != null)
|
||||||
ImGui.TextColored(ImGuiColors.DalamudGrey, statusText);
|
ImGui.TextColored(statusText.Color, statusText.Text);
|
||||||
else
|
var list = installed ? this.pluginListInstalled : this.pluginListAvailable;
|
||||||
this.DrawPluginList(installed ? this.pluginListInstalled : this.pluginListAvailable, installed);
|
if (list != null)
|
||||||
|
{
|
||||||
|
this.DrawPluginList(list, installed);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
|
|
|
||||||
|
|
@ -97,15 +97,16 @@ namespace Dalamud.Plugin
|
||||||
var repos = this.dalamud.Configuration.ThirdRepoList.Where(x => x.IsEnabled).Select(x => x.Url)
|
var repos = this.dalamud.Configuration.ThirdRepoList.Where(x => x.IsEnabled).Select(x => x.Url)
|
||||||
.Prepend(PluginMasterUrl).ToArray();
|
.Prepend(PluginMasterUrl).ToArray();
|
||||||
|
|
||||||
try
|
using var client = new WebClient();
|
||||||
|
|
||||||
|
var repoNumber = 0;
|
||||||
|
var anyError = false;
|
||||||
|
foreach (var repo in repos)
|
||||||
{
|
{
|
||||||
using var client = new WebClient();
|
Log.Information("[PLUGINR] Fetching repo: {0}", repo);
|
||||||
|
|
||||||
var repoNumber = 0;
|
try
|
||||||
foreach (var repo in repos)
|
|
||||||
{
|
{
|
||||||
Log.Information("[PLUGINR] Fetching repo: {0}", repo);
|
|
||||||
|
|
||||||
var data = client.DownloadString(repo);
|
var data = client.DownloadString(repo);
|
||||||
|
|
||||||
var unsortedPluginMaster = JsonConvert.DeserializeObject<List<PluginDefinition>>(data);
|
var unsortedPluginMaster = JsonConvert.DeserializeObject<List<PluginDefinition>>(data);
|
||||||
|
|
@ -116,18 +117,23 @@ namespace Dalamud.Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
allPlugins.AddRange(unsortedPluginMaster);
|
allPlugins.AddRange(unsortedPluginMaster);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Could not download PluginMaster");
|
||||||
|
|
||||||
repoNumber++;
|
this.State = repos.Length > 1 ? InitializationState.FailThirdRepo : InitializationState.Fail;
|
||||||
|
|
||||||
|
anyError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.PluginMaster = allPlugins.AsReadOnly();
|
repoNumber++;
|
||||||
this.State = InitializationState.Success;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex, "Could not download PluginMaster");
|
|
||||||
|
|
||||||
this.State = repos.Length > 1 ? InitializationState.FailThirdRepo : InitializationState.Fail;
|
this.PluginMaster = allPlugins.AsReadOnly();
|
||||||
|
if (!anyError)
|
||||||
|
{
|
||||||
|
this.State = InitializationState.Success;
|
||||||
}
|
}
|
||||||
}).ContinueWith(t =>
|
}).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue