mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
pi: show a warning if a non-release dalamud version is outdated
This commit is contained in:
parent
baa875f516
commit
10f9f0b37b
2 changed files with 110 additions and 5 deletions
|
|
@ -135,6 +135,8 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
private LoadingIndicatorKind loadingIndicatorKind = LoadingIndicatorKind.Unknown;
|
private LoadingIndicatorKind loadingIndicatorKind = LoadingIndicatorKind.Unknown;
|
||||||
|
|
||||||
private string verifiedCheckmarkHoveredPlugin = string.Empty;
|
private string verifiedCheckmarkHoveredPlugin = string.Empty;
|
||||||
|
|
||||||
|
private string? staleDalamudNewVersion = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PluginInstallerWindow"/> class.
|
/// Initializes a new instance of the <see cref="PluginInstallerWindow"/> class.
|
||||||
|
|
@ -292,6 +294,20 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
this.profileManagerWidget.Reset();
|
this.profileManagerWidget.Reset();
|
||||||
|
|
||||||
|
// TODO: Actually check if we are on a tag-0 version here. We might be opted into a beta but have a wrong key.
|
||||||
|
if (this.staleDalamudNewVersion == null && !Service<DalamudConfiguration>.Get().DalamudBetaKind.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
Service<DalamudReleases>.Get().GetVersionForCurrentTrack().ContinueWith(t =>
|
||||||
|
{
|
||||||
|
if (!t.IsCompletedSuccessfully)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var versionInfo = t.Result;
|
||||||
|
if (versionInfo.AssemblyVersion != Util.GetGitHash())
|
||||||
|
this.staleDalamudNewVersion = versionInfo.AssemblyVersion;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
@ -1488,8 +1504,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pm = Service<PluginManager>.Get();
|
void DrawWarningIcon()
|
||||||
if (pm.SafeMode)
|
|
||||||
{
|
{
|
||||||
ImGuiHelpers.ScaledDummy(10);
|
ImGuiHelpers.ScaledDummy(10);
|
||||||
|
|
||||||
|
|
@ -1498,15 +1513,34 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
ImGuiHelpers.CenteredText(FontAwesomeIcon.ExclamationTriangle.ToIconString());
|
ImGuiHelpers.CenteredText(FontAwesomeIcon.ExclamationTriangle.ToIconString());
|
||||||
ImGui.PopFont();
|
ImGui.PopFont();
|
||||||
ImGui.PopStyleColor();
|
ImGui.PopStyleColor();
|
||||||
|
}
|
||||||
var lines = Locs.SafeModeDisclaimer.Split('\n');
|
|
||||||
|
void DrawLinesCentered(string text)
|
||||||
|
{
|
||||||
|
var lines = text.Split('\n');
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
{
|
{
|
||||||
ImGuiHelpers.CenteredText(line);
|
ImGuiHelpers.CenteredText(line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pm = Service<PluginManager>.Get();
|
||||||
|
if (pm.SafeMode)
|
||||||
|
{
|
||||||
|
DrawWarningIcon();
|
||||||
|
DrawLinesCentered(Locs.SafeModeDisclaimer);
|
||||||
|
|
||||||
|
ImGuiHelpers.ScaledDummy(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.staleDalamudNewVersion != null)
|
||||||
|
{
|
||||||
|
DrawWarningIcon();
|
||||||
|
DrawLinesCentered("A new version of Dalamud is available.\n" +
|
||||||
|
"Please restart the game to ensure compatibility with updated plugins.\n" +
|
||||||
|
$"old: {Util.GetGitHash()} new: {this.staleDalamudNewVersion}");
|
||||||
|
|
||||||
ImGuiHelpers.ScaledDummy(10);
|
ImGuiHelpers.ScaledDummy(10);
|
||||||
ImGui.Separator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, ImGuiHelpers.ScaledVector2(1, 3));
|
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, ImGuiHelpers.ScaledVector2(1, 3));
|
||||||
|
|
|
||||||
71
Dalamud/Support/DalamudReleases.cs
Normal file
71
Dalamud/Support/DalamudReleases.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Dalamud.Configuration.Internal;
|
||||||
|
using Dalamud.Networking.Http;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Dalamud.Support;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Service for fetching Dalamud release information.
|
||||||
|
/// </summary>
|
||||||
|
[ServiceManager.EarlyLoadedService]
|
||||||
|
internal class DalamudReleases : IServiceType
|
||||||
|
{
|
||||||
|
private const string VersionInfoUrl = "https://kamori.goats.dev/Dalamud/Release/VersionInfo?track={0}";
|
||||||
|
|
||||||
|
private readonly HappyHttpClient httpClient;
|
||||||
|
private readonly DalamudConfiguration config;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="DalamudReleases"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="httpClient">The shared HTTP client.</param>
|
||||||
|
/// <param name="config">The Dalamud configuration.</param>
|
||||||
|
[ServiceManager.ServiceConstructor]
|
||||||
|
public DalamudReleases(HappyHttpClient httpClient, DalamudConfiguration config)
|
||||||
|
{
|
||||||
|
this.httpClient = httpClient;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the latest version info for the current track.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The version info for the current track.</returns>
|
||||||
|
public async Task<DalamudVersionInfo> GetVersionForCurrentTrack()
|
||||||
|
{
|
||||||
|
var url = string.Format(VersionInfoUrl, [this.config.DalamudBetaKind]);
|
||||||
|
var response = await this.httpClient.SharedHttpClient.GetAsync(url);
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
return JsonConvert.DeserializeObject<DalamudVersionInfo>(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "laziness")]
|
||||||
|
public class DalamudVersionInfo
|
||||||
|
{
|
||||||
|
[JsonProperty("key")]
|
||||||
|
public string? Key { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("track")]
|
||||||
|
public string Track { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonProperty("assemblyVersion")]
|
||||||
|
public string AssemblyVersion { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonProperty("runtimeVersion")]
|
||||||
|
public string RuntimeVersion { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonProperty("runtimeRequired")]
|
||||||
|
public bool RuntimeRequired { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("supportedGameVer")]
|
||||||
|
public string SupportedGameVer { get; set; } = null!;
|
||||||
|
|
||||||
|
[JsonProperty("isApplicableForCurrentGameVer")]
|
||||||
|
public bool IsApplicableForCurrentGameVer { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue