0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-13 09:50:43 -05:00

69 lines
1.7 KiB
C#
Raw Normal View History

2023-03-03 19:25:33 +00:00
using System.ComponentModel;
2024-05-21 20:15:19 +01:00
namespace SPT.Launcher.Models.SPT
2023-03-03 19:25:33 +00:00
{
2024-05-21 20:15:19 +01:00
public class SPTVersion : INotifyPropertyChanged
2023-03-03 19:25:33 +00:00
{
public int Major;
public int Minor;
public int Build;
public bool HasTag => Tag != null;
private string _Tag = null;
public string Tag
{
get => _Tag;
set
{
if(_Tag != value)
{
_Tag = value;
RaisePropertyChanged(nameof(Tag));
RaisePropertyChanged(nameof(HasTag));
}
}
}
2024-05-21 20:15:19 +01:00
public void ParseVersionInfo(string SPTVersion)
2023-03-03 19:25:33 +00:00
{
2024-05-21 20:15:19 +01:00
if (SPTVersion.Contains('-'))
2023-03-03 19:25:33 +00:00
{
2024-05-21 20:15:19 +01:00
string[] versionInfo = SPTVersion.Split('-');
2023-03-03 19:25:33 +00:00
2024-05-21 20:15:19 +01:00
SPTVersion = versionInfo[0];
2023-03-03 19:25:33 +00:00
Tag = versionInfo[1];
}
2024-05-21 20:15:19 +01:00
string[] splitVersion = SPTVersion.Split('.');
2023-03-03 19:25:33 +00:00
if (splitVersion.Length == 3)
{
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-05-21 20:15:19 +01:00
public SPTVersion(string SPTVersion)
2023-03-03 19:25:33 +00:00
{
2024-05-21 20:15:19 +01:00
ParseVersionInfo(SPTVersion);
2023-03-03 19:25:33 +00:00
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void RaisePropertyChanged(string property)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
}
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
}
}