mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge pull request #254 from Aireil/add_reload_plugins_settings
This commit is contained in:
commit
17d6901cd3
6 changed files with 71 additions and 41 deletions
|
|
@ -182,7 +182,7 @@ namespace Dalamud.Injector {
|
|||
$"DefaultPluginDirectory: {startInfo.DefaultPluginDirectory}\n" +
|
||||
$"Language: {startInfo.Language}\n" +
|
||||
$"GameVersion: {startInfo.GameVersion}\n" +
|
||||
$"OptOutMbCollection: {startInfo.OptOutMbCollection}" +
|
||||
$"OptOutMbCollection: {startInfo.OptOutMbCollection}\n" +
|
||||
$"AssetDirectory: {startInfo.AssetDirectory}");
|
||||
|
||||
return startInfo;
|
||||
|
|
|
|||
|
|
@ -9,5 +9,12 @@ namespace Dalamud.Configuration
|
|||
class ThirdRepoSetting {
|
||||
public string Url { get; set; }
|
||||
public bool IsEnabled { get;set; }
|
||||
|
||||
public ThirdRepoSetting Clone() {
|
||||
return new ThirdRepoSetting {
|
||||
Url = this.Url,
|
||||
IsEnabled = this.IsEnabled
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Dalamud.Interface
|
|||
this.doToggleUiHideDuringGpose = this.dalamud.Configuration.ToggleUiHideDuringGpose;
|
||||
|
||||
this.doPluginTest = this.dalamud.Configuration.DoPluginTest;
|
||||
this.thirdRepoList = this.dalamud.Configuration.ThirdRepoList;
|
||||
this.thirdRepoList = this.dalamud.Configuration.ThirdRepoList.Select(x => x.Clone()).ToList();
|
||||
|
||||
this.printPluginsWelcomeMsg = this.dalamud.Configuration.PrintPluginsWelcomeMsg;
|
||||
this.autoUpdatePlugins = this.dalamud.Configuration.AutoUpdatePlugins;
|
||||
|
|
@ -114,7 +114,7 @@ namespace Dalamud.Interface
|
|||
}
|
||||
|
||||
var windowSize = ImGui.GetWindowSize();
|
||||
ImGui.BeginChild("scrolling", new Vector2(windowSize.X - 10, windowSize.Y - 70) * ImGui.GetIO().FontGlobalScale, false, ImGuiWindowFlags.HorizontalScrollbar);
|
||||
ImGui.BeginChild("scrolling", new Vector2(windowSize.X - 5 - (5 * ImGui.GetIO().FontGlobalScale), windowSize.Y - 35 - (35 * ImGui.GetIO().FontGlobalScale)), false, ImGuiWindowFlags.HorizontalScrollbar);
|
||||
|
||||
if (ImGui.BeginTabBar("SetTabBar")) {
|
||||
if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsGeneral", "General"))) {
|
||||
|
|
@ -179,10 +179,6 @@ namespace Dalamud.Interface
|
|||
}
|
||||
|
||||
if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsExperimental", "Experimental"))) {
|
||||
ImGui.Text(Loc.Localize("DalamudSettingsRestartHint", "You need to restart your game after changing these settings."));
|
||||
|
||||
ImGui.Dummy(new Vector2(10f, 10f) * ImGui.GetIO().FontGlobalScale);
|
||||
|
||||
ImGui.Checkbox(Loc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"), ref this.doPluginTest);
|
||||
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPluginTestHint", "Receive testing prereleases for plugins."));
|
||||
|
||||
|
|
@ -201,12 +197,16 @@ namespace Dalamud.Interface
|
|||
|
||||
ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale);
|
||||
|
||||
ImGui.Columns(3);
|
||||
ImGui.SetColumnWidth(0, ImGui.GetWindowWidth() - 350);
|
||||
ImGui.SetColumnWidth(1, 60);
|
||||
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");
|
||||
|
|
@ -216,6 +216,8 @@ namespace Dalamud.Interface
|
|||
|
||||
ImGui.Separator();
|
||||
|
||||
ImGui.Text("0");
|
||||
ImGui.NextColumn();
|
||||
ImGui.Text("XIVLauncher");
|
||||
ImGui.NextColumn();
|
||||
ImGui.NextColumn();
|
||||
|
|
@ -224,15 +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.Text(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) - 7 - 12 * ImGui.GetIO().FontGlobalScale);
|
||||
ImGui.Checkbox("##thirdRepoCheck", ref isEnabled);
|
||||
ImGui.NextColumn();
|
||||
|
||||
ImGui.PushFont(InterfaceManager.IconFont);
|
||||
if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString())) {
|
||||
toRemove = thirdRepoSetting;
|
||||
|
|
@ -242,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();
|
||||
|
|
@ -267,14 +282,13 @@ namespace Dalamud.Interface
|
|||
}
|
||||
}
|
||||
ImGui.PopFont();
|
||||
|
||||
if (!string.IsNullOrEmpty(this.thirdRepoAddError)) {
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(new Vector4(1, 0, 0, 1), this.thirdRepoAddError);
|
||||
}
|
||||
ImGui.Columns(1);
|
||||
|
||||
ImGui.EndTabItem();
|
||||
|
||||
if (!string.IsNullOrEmpty(this.thirdRepoAddError)) {
|
||||
ImGui.TextColored(new Vector4(1, 0, 0, 1), this.thirdRepoAddError);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTabBar();
|
||||
|
|
@ -284,6 +298,7 @@ namespace Dalamud.Interface
|
|||
|
||||
if (!isOpen) {
|
||||
ImGui.GetIO().FontGlobalScale = this.dalamud.Configuration.GlobalUiScale;
|
||||
this.thirdRepoList = this.dalamud.Configuration.ThirdRepoList.Select(x => x.Clone()).ToList();
|
||||
}
|
||||
if (ImGui.Button(Loc.Localize("Save", "Save"))) {
|
||||
Save();
|
||||
|
|
@ -314,12 +329,14 @@ namespace Dalamud.Interface
|
|||
this.dalamud.Configuration.ToggleUiHideDuringGpose = this.doToggleUiHideDuringGpose;
|
||||
|
||||
this.dalamud.Configuration.DoPluginTest = this.doPluginTest;
|
||||
this.dalamud.Configuration.ThirdRepoList = this.thirdRepoList;
|
||||
this.dalamud.Configuration.ThirdRepoList = this.thirdRepoList.Select(x => x.Clone()).ToList();
|
||||
|
||||
this.dalamud.Configuration.PrintPluginsWelcomeMsg = this.printPluginsWelcomeMsg;
|
||||
this.dalamud.Configuration.AutoUpdatePlugins = this.autoUpdatePlugins;
|
||||
|
||||
this.dalamud.Configuration.Save();
|
||||
|
||||
this.dalamud.PluginRepository.ReloadPluginMasterAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,9 +79,9 @@ namespace Dalamud.Plugin
|
|||
public long LastUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Domain of the origin repo
|
||||
/// Number of the repo.
|
||||
/// </summary>
|
||||
public string FromRepo { get; set; }
|
||||
public int RepoNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Download link used to install the plugin.
|
||||
|
|
|
|||
|
|
@ -62,6 +62,22 @@ namespace Dalamud.Plugin
|
|||
this.dalamud.PluginRepository.ReloadPluginMasterAsync();
|
||||
}
|
||||
|
||||
private void RefetchPlugins() {
|
||||
var hiddenPlugins = this.dalamud.PluginManager.Plugins.Where(
|
||||
x => this.dalamud.PluginRepository.PluginMaster.All(
|
||||
y => y.InternalName != x.Definition.InternalName || y.InternalName == x.Definition.InternalName && y.IsHide)).Select(x => x.Definition).ToList();
|
||||
this.pluginListInstalled = this.dalamud.PluginRepository.PluginMaster
|
||||
.Where(def => {
|
||||
return this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).Any(
|
||||
x => x.Definition.InternalName == def.InternalName);
|
||||
})
|
||||
.ToList();
|
||||
this.pluginListInstalled.AddRange(hiddenPlugins);
|
||||
this.pluginListInstalled.Sort((x, y) => x.Name.CompareTo(y.Name));
|
||||
|
||||
ResortPlugins();
|
||||
}
|
||||
|
||||
private void ResortPlugins() {
|
||||
var availableDefs = this.dalamud.PluginRepository.PluginMaster.Where(
|
||||
x => this.pluginListInstalled.All(y => x.InternalName != y.InternalName)).ToList();
|
||||
|
|
@ -136,27 +152,16 @@ namespace Dalamud.Plugin
|
|||
string initializationStatusText = null;
|
||||
if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.InProgress) {
|
||||
initializationStatusText = Loc.Localize("InstallerLoading", "Loading plugins...");
|
||||
this.pluginListAvailable = null;
|
||||
} else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail) {
|
||||
initializationStatusText = Loc.Localize("InstallerDownloadFailed", "Download failed.");
|
||||
}
|
||||
else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.FailThirdRepo) {
|
||||
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.");
|
||||
}
|
||||
else {
|
||||
this.pluginListAvailable = null;
|
||||
} else {
|
||||
if (this.pluginListAvailable == null) {
|
||||
var hiddenPlugins = this.dalamud.PluginManager.Plugins.Where(
|
||||
x => this.dalamud.PluginRepository.PluginMaster.All(
|
||||
y => y.InternalName != x.Definition.InternalName || y.InternalName == x.Definition.InternalName && y.IsHide)).Select(x => x.Definition).ToList();
|
||||
this.pluginListInstalled = this.dalamud.PluginRepository.PluginMaster
|
||||
.Where(def => {
|
||||
return this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).Any(
|
||||
x => x.Definition.InternalName == def.InternalName);
|
||||
})
|
||||
.ToList();
|
||||
this.pluginListInstalled.AddRange(hiddenPlugins);
|
||||
this.pluginListInstalled.Sort((x, y) => x.Name.CompareTo(y.Name));
|
||||
|
||||
ResortPlugins();
|
||||
RefetchPlugins();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -360,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))
|
||||
|
|
|
|||
|
|
@ -53,19 +53,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<List<PluginDefinition>>(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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue