2024-09-02 07:53:58 +00:00
|
|
|
|
using SPT.Launcher.Utilities;
|
2023-03-03 19:25:33 +00:00
|
|
|
|
|
2024-05-21 20:15:19 +01:00
|
|
|
|
namespace SPT.Launcher.Models.SPT
|
2023-03-03 19:25:33 +00:00
|
|
|
|
{
|
2024-09-02 07:53:58 +00:00
|
|
|
|
public class SPTVersion : NotifyPropertyChangedBase
|
2023-03-03 19:25:33 +00:00
|
|
|
|
{
|
|
|
|
|
public int Major;
|
|
|
|
|
public int Minor;
|
|
|
|
|
public int Build;
|
|
|
|
|
|
2024-09-02 07:53:58 +00:00
|
|
|
|
public bool HasTag => Tag != string.Empty;
|
2023-03-03 19:25:33 +00:00
|
|
|
|
|
2024-09-02 07:53:58 +00:00
|
|
|
|
private string _tag = string.Empty;
|
2023-03-03 19:25:33 +00:00
|
|
|
|
public string Tag
|
|
|
|
|
{
|
2024-09-02 07:53:58 +00:00
|
|
|
|
get => _tag;
|
|
|
|
|
set => SetProperty(ref _tag, value, () => RaisePropertyChanged(nameof(HasTag)));
|
2023-03-03 19:25:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-02 07:53:58 +00:00
|
|
|
|
public void ParseVersionInfo(string sptVersion)
|
2023-03-03 19:25:33 +00:00
|
|
|
|
{
|
2024-09-02 07:53:58 +00:00
|
|
|
|
if (sptVersion.Contains('-'))
|
2023-03-03 19:25:33 +00:00
|
|
|
|
{
|
2024-09-02 07:53:58 +00:00
|
|
|
|
string[] versionInfo = sptVersion.Split('-');
|
2023-03-03 19:25:33 +00:00
|
|
|
|
|
2024-09-02 07:53:58 +00:00
|
|
|
|
sptVersion = versionInfo[0];
|
2023-03-03 19:25:33 +00:00
|
|
|
|
|
|
|
|
|
Tag = versionInfo[1];
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-02 07:53:58 +00:00
|
|
|
|
string[] splitVersion = sptVersion.Split('.');
|
2023-03-03 19:25:33 +00:00
|
|
|
|
|
2024-07-12 15:21:43 -04:00
|
|
|
|
if (splitVersion.Length >= 3)
|
2023-03-03 19:25:33 +00:00
|
|
|
|
{
|
|
|
|
|
int.TryParse(splitVersion[0], out Major);
|
|
|
|
|
int.TryParse(splitVersion[1], out Minor);
|
|
|
|
|
int.TryParse(splitVersion[2], out Build);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-21 20:15:19 +01:00
|
|
|
|
public SPTVersion() { }
|
2023-03-03 19:25:33 +00:00
|
|
|
|
|
2024-09-02 07:53:58 +00:00
|
|
|
|
public SPTVersion(string sptVersion)
|
2023-03-03 19:25:33 +00:00
|
|
|
|
{
|
2024-09-02 07:53:58 +00:00
|
|
|
|
ParseVersionInfo(sptVersion);
|
2023-03-03 19:25:33 +00:00
|
|
|
|
}
|
2024-02-05 16:06:28 -05:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return HasTag ? $"{Major}.{Minor}.{Build}-{Tag}" : $"{Major}.{Minor}.{Build}";
|
|
|
|
|
}
|
2023-03-03 19:25:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|