mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: add ban reason in the installer
This commit is contained in:
parent
daaf3c9328
commit
f8966318c8
3 changed files with 27 additions and 2 deletions
|
|
@ -1430,7 +1430,7 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
ImGui.TextWrapped(manifest.Description);
|
ImGui.TextWrapped(manifest.Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.IsOutdated)
|
if (plugin.IsOutdated && !plugin.IsBanned)
|
||||||
{
|
{
|
||||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||||
ImGui.TextWrapped(Locs.PluginBody_Outdated);
|
ImGui.TextWrapped(Locs.PluginBody_Outdated);
|
||||||
|
|
@ -1440,7 +1440,10 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
if (plugin.IsBanned)
|
if (plugin.IsBanned)
|
||||||
{
|
{
|
||||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||||
ImGui.TextWrapped(Locs.PluginBody_Banned);
|
ImGui.TextWrapped(plugin.BanReason.IsNullOrEmpty()
|
||||||
|
? Locs.PluginBody_Banned
|
||||||
|
: Locs.PluginBody_BannedReason(plugin.BanReason));
|
||||||
|
|
||||||
ImGui.PopStyleColor();
|
ImGui.PopStyleColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2436,6 +2439,9 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
|
|
||||||
public static string PluginBody_Banned => Loc.Localize("InstallerBannedPluginBody ", "This plugin version is banned due to incompatibilities and not available at the moment. Please wait for it to be updated by its author.");
|
public static string PluginBody_Banned => Loc.Localize("InstallerBannedPluginBody ", "This plugin version is banned due to incompatibilities and not available at the moment. Please wait for it to be updated by its author.");
|
||||||
|
|
||||||
|
public static string PluginBody_BannedReason(string message) =>
|
||||||
|
Loc.Localize("InstallerBannedPluginBodyReason ", "This plugin is banned: {0}").Format(message);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Plugin buttons
|
#region Plugin buttons
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
|
|
||||||
var pluginManager = Service<PluginManager>.Get();
|
var pluginManager = Service<PluginManager>.Get();
|
||||||
this.IsBanned = pluginManager.IsManifestBanned(this.Manifest);
|
this.IsBanned = pluginManager.IsManifestBanned(this.Manifest);
|
||||||
|
this.BanReason = pluginManager.GetBanReason(this.Manifest);
|
||||||
|
|
||||||
this.SaveManifest();
|
this.SaveManifest();
|
||||||
}
|
}
|
||||||
|
|
@ -167,6 +168,11 @@ namespace Dalamud.Plugin.Internal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name => this.instance?.Name ?? this.Manifest.Name ?? this.DllFile.Name;
|
public string Name => this.instance?.Name ?? this.Manifest.Name ?? this.DllFile.Name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an optional reason, if the plugin is banned.
|
||||||
|
/// </summary>
|
||||||
|
public string BanReason { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the plugin is loaded and running.
|
/// Gets a value indicating whether the plugin is loaded and running.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -954,6 +954,16 @@ namespace Dalamud.Plugin.Internal
|
||||||
return this.bannedPlugins.Any(ban => ban.Name == manifest.InternalName && ban.AssemblyVersion == manifest.AssemblyVersion);
|
return this.bannedPlugins.Any(ban => ban.Name == manifest.InternalName && ban.AssemblyVersion == manifest.AssemblyVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the reason of a banned plugin by inspecting the manifest.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="manifest">Manifest to inspect.</param>
|
||||||
|
/// <returns>The reason of the ban, if any.</returns>
|
||||||
|
public string GetBanReason(PluginManifest manifest)
|
||||||
|
{
|
||||||
|
return this.bannedPlugins.FirstOrDefault(ban => ban.Name == manifest.InternalName).Reason;
|
||||||
|
}
|
||||||
|
|
||||||
private void DetectAvailablePluginUpdates()
|
private void DetectAvailablePluginUpdates()
|
||||||
{
|
{
|
||||||
var updatablePlugins = new List<AvailablePluginUpdate>();
|
var updatablePlugins = new List<AvailablePluginUpdate>();
|
||||||
|
|
@ -1024,6 +1034,9 @@ namespace Dalamud.Plugin.Internal
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public Version AssemblyVersion { get; private set; }
|
public Version AssemblyVersion { get; private set; }
|
||||||
|
|
||||||
|
[JsonProperty]
|
||||||
|
public string Reason { get; private set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct PluginDef
|
private struct PluginDef
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue