1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-02-04 02:43:32 +00:00

Workshop - Update workshop schema

This commit is contained in:
Robert 2025-12-23 08:36:13 +01:00
parent d063f13ca5
commit 7985cde6a3
5 changed files with 657 additions and 783 deletions

View File

@ -16,8 +16,8 @@ public static class ReleaseExtensions
{
if (release.MinimumVersion == null || Constants.CurrentVersion == "local")
return true;
return release.MinimumVersion <= Version.Parse(Constants.CurrentVersion).ArtemisVersionToLong();
return Version.Parse(release.MinimumVersion) <= Version.Parse(Constants.CurrentVersion);
}
}
}

View File

@ -1,45 +0,0 @@
using System;
namespace Artemis.UI.Extensions;
public static class VersionExtensions
{
/// <param name="version">The version to convert</param>
extension(Version version)
{
/// <summary>
/// Convert a Version to a long representation for easy comparison in PostgreSQL
/// <remarks>Assumes format: major.year.dayOfYear.revision (e.g., 1.2024.0225.2)</remarks>
/// </summary>
/// <returns>A long value that preserves version comparison order</returns>
public long ArtemisVersionToLong()
{
// Format: major.year.dayOfYear.revision
// Convert to: majorYYYYDDDRRRR (16 digits)
// Major: 1 digit (0-9)
// Year: 4 digits (e.g., 2024)
// Day: 3 digits (001-366, padded)
// Revision: 4 digits (0000-9999, padded)
long major = Math.Max(0, Math.Min(9, version.Major));
long year = Math.Max(1000, Math.Min(9999, version.Minor));
long day = Math.Max(1, Math.Min(366, version.Build));
long revision = Math.Max(0, Math.Min(9999, version.Revision >= 0 ? version.Revision : 0));
return major * 100000000000L +
year * 10000000L +
day * 10000L +
revision;
}
public static Version FromLong(long versionLong)
{
int major = (int)(versionLong / 100000000000L);
int year = (int)((versionLong / 10000000L) % 10000);
int day = (int)((versionLong / 10000L) % 1000);
int revision = (int)(versionLong % 10000L);
return new Version(major, year, day, revision);
}
}
}

View File

@ -69,11 +69,11 @@ public partial class EntryReleaseInfoViewModel : ActivatableViewModelBase
}).DisposeWith(d);
IsCurrentVersion = Release != null && _workshopService.GetInstalledEntry(Release.Entry.Id)?.ReleaseId == Release.Id;
IncompatibilityReason = Release != null && !Release.IsCompatible() ? $"Requires Artemis v{Version.FromLong(Release.MinimumVersion!.Value)} or later" : null;
IncompatibilityReason = Release != null && !Release.IsCompatible() ? $"Requires Artemis v{Release.MinimumVersion} or later" : null;
});
this.WhenAnyValue(vm => vm.Release).Subscribe(r => IsCurrentVersion = r != null && _workshopService.GetInstalledEntry(r.Entry.Id)?.ReleaseId == r.Id);
this.WhenAnyValue(vm => vm.Release).Subscribe(r => IncompatibilityReason = r != null && !r.IsCompatible() ? $"Requires Artemis v{Version.FromLong(r.MinimumVersion!.Value)} or later" : null);
this.WhenAnyValue(vm => vm.Release).Subscribe(r => IncompatibilityReason = r != null && !r.IsCompatible() ? $"Requires Artemis v{r.MinimumVersion} or later" : null);
InDetailsScreen = true;
}

View File

@ -37,7 +37,7 @@ public partial class EntryReleaseItemViewModel : ActivatableViewModelBase
}).DisposeWith(d);
IsCurrentVersion = _workshopService.GetInstalledEntry(_entry.Id)?.ReleaseId == Release.Id;
IncompatibilityReason = !Release.IsCompatible() ? $"Requires Artemis v{Version.FromLong(Release.MinimumVersion!.Value)} or later" : null;
IncompatibilityReason = !Release.IsCompatible() ? $"Requires Artemis v{Release.MinimumVersion} or later" : null;
});
}

File diff suppressed because it is too large Load Diff