mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-23 16:27:44 +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
|
|
@ -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