Reload plugins when change in settings + fix scaling

This commit is contained in:
Aireil 2021-01-25 01:06:41 +01:00
parent b1b6621c2a
commit 5f9191ff20
4 changed files with 44 additions and 33 deletions

View file

@ -182,7 +182,7 @@ namespace Dalamud.Injector {
$"DefaultPluginDirectory: {startInfo.DefaultPluginDirectory}\n" + $"DefaultPluginDirectory: {startInfo.DefaultPluginDirectory}\n" +
$"Language: {startInfo.Language}\n" + $"Language: {startInfo.Language}\n" +
$"GameVersion: {startInfo.GameVersion}\n" + $"GameVersion: {startInfo.GameVersion}\n" +
$"OptOutMbCollection: {startInfo.OptOutMbCollection}" + $"OptOutMbCollection: {startInfo.OptOutMbCollection}\n" +
$"AssetDirectory: {startInfo.AssetDirectory}"); $"AssetDirectory: {startInfo.AssetDirectory}");
return startInfo; return startInfo;

View file

@ -9,5 +9,12 @@ namespace Dalamud.Configuration
class ThirdRepoSetting { class ThirdRepoSetting {
public string Url { get; set; } public string Url { get; set; }
public bool IsEnabled { get;set; } public bool IsEnabled { get;set; }
public ThirdRepoSetting Clone() {
return new ThirdRepoSetting {
Url = this.Url,
IsEnabled = this.IsEnabled
};
}
} }
} }

View file

@ -30,7 +30,7 @@ namespace Dalamud.Interface
this.doToggleUiHideDuringGpose = this.dalamud.Configuration.ToggleUiHideDuringGpose; this.doToggleUiHideDuringGpose = this.dalamud.Configuration.ToggleUiHideDuringGpose;
this.doPluginTest = this.dalamud.Configuration.DoPluginTest; 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.printPluginsWelcomeMsg = this.dalamud.Configuration.PrintPluginsWelcomeMsg;
this.autoUpdatePlugins = this.dalamud.Configuration.AutoUpdatePlugins; this.autoUpdatePlugins = this.dalamud.Configuration.AutoUpdatePlugins;
@ -114,7 +114,7 @@ namespace Dalamud.Interface
} }
var windowSize = ImGui.GetWindowSize(); 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.BeginTabBar("SetTabBar")) {
if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsGeneral", "General"))) { if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsGeneral", "General"))) {
@ -179,10 +179,6 @@ namespace Dalamud.Interface
} }
if (ImGui.BeginTabItem(Loc.Localize("DalamudSettingsExperimental", "Experimental"))) { 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.Checkbox(Loc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"), ref this.doPluginTest);
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPluginTestHint", "Receive testing prereleases for plugins.")); ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPluginTestHint", "Receive testing prereleases for plugins."));
@ -202,8 +198,8 @@ namespace Dalamud.Interface
ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale); ImGui.Dummy(new Vector2(5f, 5f) * ImGui.GetIO().FontGlobalScale);
ImGui.Columns(3); ImGui.Columns(3);
ImGui.SetColumnWidth(0, ImGui.GetWindowWidth() - 350); ImGui.SetColumnWidth(0, ImGui.GetWindowWidth() - (16 + 14) - (45 + 26) * ImGui.GetIO().FontGlobalScale);
ImGui.SetColumnWidth(1, 60); ImGui.SetColumnWidth(1, 16 + (45 * ImGui.GetIO().FontGlobalScale));
ImGui.Separator(); ImGui.Separator();
@ -229,8 +225,9 @@ namespace Dalamud.Interface
ImGui.PushID($"thirdRepo_{thirdRepoSetting.Url}"); ImGui.PushID($"thirdRepo_{thirdRepoSetting.Url}");
ImGui.Text(thirdRepoSetting.Url); ImGui.TextWrapped(thirdRepoSetting.Url);
ImGui.NextColumn(); ImGui.NextColumn();
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - (12 * ImGui.GetIO().FontGlobalScale) - 7);
ImGui.Checkbox("##thirdRepoCheck", ref isEnabled); ImGui.Checkbox("##thirdRepoCheck", ref isEnabled);
ImGui.NextColumn(); ImGui.NextColumn();
ImGui.PushFont(InterfaceManager.IconFont); ImGui.PushFont(InterfaceManager.IconFont);
@ -267,14 +264,13 @@ namespace Dalamud.Interface
} }
} }
ImGui.PopFont(); ImGui.PopFont();
if (!string.IsNullOrEmpty(this.thirdRepoAddError)) {
ImGui.SameLine();
ImGui.TextColored(new Vector4(1, 0, 0, 1), this.thirdRepoAddError);
}
ImGui.Columns(1); ImGui.Columns(1);
ImGui.EndTabItem(); ImGui.EndTabItem();
if (!string.IsNullOrEmpty(this.thirdRepoAddError)) {
ImGui.TextColored(new Vector4(1, 0, 0, 1), this.thirdRepoAddError);
}
} }
ImGui.EndTabBar(); ImGui.EndTabBar();
@ -284,6 +280,7 @@ namespace Dalamud.Interface
if (!isOpen) { if (!isOpen) {
ImGui.GetIO().FontGlobalScale = this.dalamud.Configuration.GlobalUiScale; 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"))) { if (ImGui.Button(Loc.Localize("Save", "Save"))) {
Save(); Save();
@ -314,12 +311,14 @@ namespace Dalamud.Interface
this.dalamud.Configuration.ToggleUiHideDuringGpose = this.doToggleUiHideDuringGpose; this.dalamud.Configuration.ToggleUiHideDuringGpose = this.doToggleUiHideDuringGpose;
this.dalamud.Configuration.DoPluginTest = this.doPluginTest; 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.PrintPluginsWelcomeMsg = this.printPluginsWelcomeMsg;
this.dalamud.Configuration.AutoUpdatePlugins = this.autoUpdatePlugins; this.dalamud.Configuration.AutoUpdatePlugins = this.autoUpdatePlugins;
this.dalamud.Configuration.Save(); this.dalamud.Configuration.Save();
this.dalamud.PluginRepository.ReloadPluginMasterAsync();
} }
} }
} }

View file

@ -62,6 +62,22 @@ namespace Dalamud.Plugin
this.dalamud.PluginRepository.ReloadPluginMasterAsync(); 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() { private void ResortPlugins() {
var availableDefs = this.dalamud.PluginRepository.PluginMaster.Where( var availableDefs = this.dalamud.PluginRepository.PluginMaster.Where(
x => this.pluginListInstalled.All(y => x.InternalName != y.InternalName)).ToList(); x => this.pluginListInstalled.All(y => x.InternalName != y.InternalName)).ToList();
@ -136,27 +152,16 @@ namespace Dalamud.Plugin
string initializationStatusText = null; string initializationStatusText = null;
if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.InProgress) { if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.InProgress) {
initializationStatusText = Loc.Localize("InstallerLoading", "Loading plugins..."); initializationStatusText = Loc.Localize("InstallerLoading", "Loading plugins...");
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 = Loc.Localize("InstallerDownloadFailed", "Download failed.");
} this.pluginListAvailable = null;
else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.FailThirdRepo) { } 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 = Loc.Localize("InstallerDownloadFailedThird", "One of your third party repos is unreachable or there is no internet connection.");
} this.pluginListAvailable = null;
else { } else {
if (this.pluginListAvailable == null) { if (this.pluginListAvailable == null) {
var hiddenPlugins = this.dalamud.PluginManager.Plugins.Where( RefetchPlugins();
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();
} }
} }