forked from aly/qstbak
muffin v7.4.3
This commit is contained in:
parent
bddffe21ae
commit
5791858984
4 changed files with 835 additions and 816 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,37 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Questionable.Model.Changelog;
|
||||
|
||||
internal sealed record ChangelogEntry(string Version, DateOnly ReleaseDate, List<ChangeEntry> Changes)
|
||||
{
|
||||
public bool IsNewVersion(string? lastViewedVersion)
|
||||
public bool IsNewVersion(string? lastViewedVersion, IReadOnlyList<ChangelogEntry> allChangelogs)
|
||||
{
|
||||
if (string.IsNullOrEmpty(lastViewedVersion))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return CompareVersions(Version, lastViewedVersion) > 0;
|
||||
}
|
||||
|
||||
private static int CompareVersions(string version1, string version2)
|
||||
{
|
||||
int result;
|
||||
int[] array = (from p in version1.Split('.')
|
||||
select int.TryParse(p, out result) ? result : 0).ToArray();
|
||||
int[] array2 = (from p in version2.Split('.')
|
||||
select int.TryParse(p, out result) ? result : 0).ToArray();
|
||||
int num = Math.Max(array.Length, array2.Length);
|
||||
for (int num2 = 0; num2 < num; num2++)
|
||||
int num = -1;
|
||||
int num2 = -1;
|
||||
for (int i = 0; i < allChangelogs.Count; i++)
|
||||
{
|
||||
int num3 = ((num2 < array.Length) ? array[num2] : 0);
|
||||
int num4 = ((num2 < array2.Length) ? array2[num2] : 0);
|
||||
if (num3 != num4)
|
||||
if (allChangelogs[i].Version == Version)
|
||||
{
|
||||
return num3.CompareTo(num4);
|
||||
num = i;
|
||||
}
|
||||
if (allChangelogs[i].Version == lastViewedVersion)
|
||||
{
|
||||
num2 = i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
if (num2 == -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (num == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return num < num2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Numerics;
|
|||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Questionable.Data;
|
||||
using Questionable.Model.Changelog;
|
||||
|
||||
namespace Questionable.Windows.ChangelogComponents;
|
||||
|
|
@ -26,7 +27,7 @@ internal sealed class ChangelogEntryComponent
|
|||
|
||||
public void Draw(ChangelogEntry changelog, bool isLatest, bool hasSetInitialState)
|
||||
{
|
||||
bool isNew = changelog.IsNewVersion(_configuration.LastViewedChangelogVersion);
|
||||
bool isNew = changelog.IsNewVersion(_configuration.LastViewedChangelogVersion, ChangelogData.Changelogs);
|
||||
ImGui.GetWindowDrawList();
|
||||
string text = changelog.ReleaseDate.ToString("MMMM dd, yyyy", CultureInfo.InvariantCulture);
|
||||
if (!hasSetInitialState)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ using Questionable.Controller.Utils;
|
|||
using Questionable.Data;
|
||||
using Questionable.External;
|
||||
using Questionable.Functions;
|
||||
using Questionable.Model.Changelog;
|
||||
using Questionable.Validation;
|
||||
using Questionable.Validation.Validators;
|
||||
using Questionable.Windows;
|
||||
|
|
@ -300,8 +301,8 @@ public sealed class QuestionablePlugin : IDalamudPlugin, IDisposable
|
|||
Configuration requiredService2 = serviceProvider.GetRequiredService<Configuration>();
|
||||
if (requiredService2.IsPluginSetupComplete() && requiredService2.General.ShowChangelogOnUpdate)
|
||||
{
|
||||
string text = ChangelogData.Changelogs.FirstOrDefault()?.Version;
|
||||
if (text != null && (string.IsNullOrEmpty(requiredService2.LastViewedChangelogVersion) || string.CompareOrdinal(text, requiredService2.LastViewedChangelogVersion) > 0))
|
||||
ChangelogEntry changelogEntry = ChangelogData.Changelogs.FirstOrDefault();
|
||||
if (changelogEntry != null && changelogEntry.IsNewVersion(requiredService2.LastViewedChangelogVersion, ChangelogData.Changelogs))
|
||||
{
|
||||
requiredService.IsOpenAndUncollapsed = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue