mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +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));
|
||||
|
||||
string initializationStatusText = null;
|
||||
(string Text, Vector4 Color) initializationStatusText = (null, ImGuiColors.DalamudGrey);
|
||||
if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.InProgress)
|
||||
{
|
||||
initializationStatusText = Loc.Localize("InstallerLoading", "Loading plugins...");
|
||||
initializationStatusText.Text = Loc.Localize("InstallerLoading", "Loading plugins...");
|
||||
this.pluginListAvailable = null;
|
||||
}
|
||||
else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail)
|
||||
{
|
||||
initializationStatusText = 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.");
|
||||
initializationStatusText.Text = Loc.Localize("InstallerDownloadFailed", "Download failed.");
|
||||
this.pluginListAvailable = null;
|
||||
}
|
||||
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)
|
||||
{
|
||||
this.RefetchPlugins();
|
||||
|
|
@ -310,9 +311,6 @@ namespace Dalamud.Plugin
|
|||
|
||||
private void ResortPlugins()
|
||||
{
|
||||
if (this.dalamud.PluginRepository.State != PluginRepository.InitializationState.Success)
|
||||
return;
|
||||
|
||||
var availableDefs = this.dalamud.PluginRepository.PluginMaster.Where(
|
||||
x => this.pluginListInstalled.All(y => x.InternalName != y.InternalName))
|
||||
.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")
|
||||
: Loc.Localize("InstallerAvailablePluginList", "Available Plugins")))
|
||||
|
|
@ -349,10 +347,13 @@ namespace Dalamud.Plugin
|
|||
ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground);
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 5);
|
||||
|
||||
if (statusText != null)
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, statusText);
|
||||
else
|
||||
this.DrawPluginList(installed ? this.pluginListInstalled : this.pluginListAvailable, installed);
|
||||
if (statusText.Text != null)
|
||||
ImGui.TextColored(statusText.Color, statusText.Text);
|
||||
var list = installed ? this.pluginListInstalled : this.pluginListAvailable;
|
||||
if (list != null)
|
||||
{
|
||||
this.DrawPluginList(list, installed);
|
||||
}
|
||||
|
||||
ImGui.EndChild();
|
||||
ImGui.EndTabItem();
|
||||
|
|
|
|||
|
|
@ -97,15 +97,16 @@ namespace Dalamud.Plugin
|
|||
var repos = this.dalamud.Configuration.ThirdRepoList.Where(x => x.IsEnabled).Select(x => x.Url)
|
||||
.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;
|
||||
foreach (var repo in repos)
|
||||
try
|
||||
{
|
||||
Log.Information("[PLUGINR] Fetching repo: {0}", repo);
|
||||
|
||||
var data = client.DownloadString(repo);
|
||||
|
||||
var unsortedPluginMaster = JsonConvert.DeserializeObject<List<PluginDefinition>>(data);
|
||||
|
|
@ -116,18 +117,23 @@ namespace Dalamud.Plugin
|
|||
}
|
||||
|
||||
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();
|
||||
this.State = InitializationState.Success;
|
||||
repoNumber++;
|
||||
}
|
||||
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 =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue