From 348b8a5e3a8bb5a184edc6c8600caf49c221de7b Mon Sep 17 00:00:00 2001
From: Aireil <33433913+Aireil@users.noreply.github.com>
Date: Mon, 25 Jan 2021 14:20:43 +0100
Subject: [PATCH] Add third repo number and use it in the installer
---
Dalamud/Interface/DalamudSettingsWindow.cs | 26 ++++++++++++++++++----
Dalamud/Plugin/PluginDefinition.cs | 4 ++--
Dalamud/Plugin/PluginInstallerWindow.cs | 5 ++---
Dalamud/Plugin/PluginRepository.cs | 6 +++--
4 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/Dalamud/Interface/DalamudSettingsWindow.cs b/Dalamud/Interface/DalamudSettingsWindow.cs
index fdb3b816d..c1b5123d3 100644
--- a/Dalamud/Interface/DalamudSettingsWindow.cs
+++ b/Dalamud/Interface/DalamudSettingsWindow.cs
@@ -197,12 +197,16 @@ namespace Dalamud.Interface
ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale);
- ImGui.Columns(3);
- ImGui.SetColumnWidth(0, ImGui.GetWindowWidth() - (16 + 14) - (45 + 26) * ImGui.GetIO().FontGlobalScale);
- ImGui.SetColumnWidth(1, 16 + (45 * ImGui.GetIO().FontGlobalScale));
+ ImGui.Columns(4);
+ ImGui.SetColumnWidth(0, 18 + 5 * ImGui.GetIO().FontGlobalScale);
+ ImGui.SetColumnWidth(1, ImGui.GetWindowWidth() - (18 + 16 + 14) - (5 + 45 + 26) * ImGui.GetIO().FontGlobalScale);
+ ImGui.SetColumnWidth(2, 16 + (45 * ImGui.GetIO().FontGlobalScale));
+ ImGui.SetColumnWidth(3, 14 + (26 * ImGui.GetIO().FontGlobalScale));
ImGui.Separator();
+ ImGui.Text("#");
+ ImGui.NextColumn();
ImGui.Text("URL");
ImGui.NextColumn();
ImGui.Text("Enabled");
@@ -212,6 +216,8 @@ namespace Dalamud.Interface
ImGui.Separator();
+ ImGui.Text("0");
+ ImGui.NextColumn();
ImGui.Text("XIVLauncher");
ImGui.NextColumn();
ImGui.NextColumn();
@@ -220,16 +226,23 @@ namespace Dalamud.Interface
ThirdRepoSetting toRemove = null;
+ var repoNumber = 1;
foreach (var thirdRepoSetting in this.thirdRepoList) {
var isEnabled = thirdRepoSetting.IsEnabled;
ImGui.PushID($"thirdRepo_{thirdRepoSetting.Url}");
+ ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - 8 - (ImGui.CalcTextSize(repoNumber.ToString()).X / 2));
+ ImGui.Text(repoNumber.ToString());
+ ImGui.NextColumn();
+
ImGui.TextWrapped(thirdRepoSetting.Url);
ImGui.NextColumn();
- ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - (12 * ImGui.GetIO().FontGlobalScale) - 7);
+
+ ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - 7 - 12 * ImGui.GetIO().FontGlobalScale);
ImGui.Checkbox("##thirdRepoCheck", ref isEnabled);
ImGui.NextColumn();
+
ImGui.PushFont(InterfaceManager.IconFont);
if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString())) {
toRemove = thirdRepoSetting;
@@ -239,12 +252,17 @@ namespace Dalamud.Interface
ImGui.Separator();
thirdRepoSetting.IsEnabled = isEnabled;
+
+ repoNumber++;
}
if (toRemove != null) {
this.thirdRepoList.Remove(toRemove);
}
+ ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - 8 - (ImGui.CalcTextSize(repoNumber.ToString()).X / 2));
+ ImGui.Text(repoNumber.ToString());
+ ImGui.NextColumn();
ImGui.SetNextItemWidth(-1);
ImGui.InputText("##thirdRepoUrlInput", ref this.thirdRepoTempUrl, 300);
ImGui.NextColumn();
diff --git a/Dalamud/Plugin/PluginDefinition.cs b/Dalamud/Plugin/PluginDefinition.cs
index 3b866ff51..2b2fb0e70 100644
--- a/Dalamud/Plugin/PluginDefinition.cs
+++ b/Dalamud/Plugin/PluginDefinition.cs
@@ -79,9 +79,9 @@ namespace Dalamud.Plugin
public long LastUpdate { get; set; }
///
- /// Domain of the origin repo
+ /// Number of the repo.
///
- public string FromRepo { get; set; }
+ public int RepoNumber { get; set; }
///
/// Download link used to install the plugin.
diff --git a/Dalamud/Plugin/PluginInstallerWindow.cs b/Dalamud/Plugin/PluginInstallerWindow.cs
index 5cd97d788..7361264f5 100644
--- a/Dalamud/Plugin/PluginInstallerWindow.cs
+++ b/Dalamud/Plugin/PluginInstallerWindow.cs
@@ -365,9 +365,8 @@ namespace Dalamud.Plugin
info += pluginDefinition.DownloadCount != 0
? $", {pluginDefinition.DownloadCount} downloads"
: ", download count unavailable";
- if (pluginDefinition.FromRepo != "goatcorp.github.io" &&
- !string.IsNullOrWhiteSpace(pluginDefinition.FromRepo))
- info += $", from {pluginDefinition.FromRepo}";
+ if (pluginDefinition.RepoNumber != 0)
+ info += $", from custom plugin repository #{pluginDefinition.RepoNumber}";
ImGui.TextColored(new Vector4(0.5f, 0.5f, 0.5f, 1.0f), info);
if (!string.IsNullOrWhiteSpace(pluginDefinition.Description))
diff --git a/Dalamud/Plugin/PluginRepository.cs b/Dalamud/Plugin/PluginRepository.cs
index af55fbcc2..68e8d7fd8 100644
--- a/Dalamud/Plugin/PluginRepository.cs
+++ b/Dalamud/Plugin/PluginRepository.cs
@@ -51,19 +51,21 @@ namespace Dalamud.Plugin
try {
using var client = new WebClient();
+ var repoNumber = 0;
foreach (var repo in repos) {
Log.Information("[PLUGINR] Fetching repo: {0}", repo);
var data = client.DownloadString(repo);
var unsortedPluginMaster = JsonConvert.DeserializeObject>(data);
- var host = new Uri(repo).Host;
foreach (var pluginDefinition in unsortedPluginMaster) {
- pluginDefinition.FromRepo = host;
+ pluginDefinition.RepoNumber = repoNumber;
}
allPlugins.AddRange(unsortedPluginMaster);
+
+ repoNumber++;
}
this.PluginMaster = allPlugins.AsReadOnly();