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

67 lines
2.0 KiB
C#
Raw Normal View History

2024-05-21 20:15:19 +01:00
using SPT.Launcher.Models.SPT;
2023-08-14 09:50:00 -04:00
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using SPT.Launcher.Utilities;
2023-08-14 09:50:00 -04:00
2024-05-21 20:15:19 +01:00
namespace SPT.Launcher.Models.Launcher
2023-08-14 09:50:00 -04:00
{
public class ModInfoCollection : NotifyPropertyChangedBase
2023-08-14 09:50:00 -04:00
{
private int _serverModsCount;
public int ServerModsCount
{
get => _serverModsCount;
set => SetProperty(ref _serverModsCount, value);
2023-08-14 09:50:00 -04:00
}
2024-01-26 21:46:39 -05:00
2023-08-14 09:50:00 -04:00
private int _profileModsCount;
public int ProfileModsCount
{
get => _profileModsCount;
set => SetProperty(ref _profileModsCount, value);
2023-08-14 09:50:00 -04:00
}
private bool _hasMods;
public bool HasMods
{
get => _hasMods;
set => SetProperty(ref _hasMods, value);
2023-08-14 09:50:00 -04:00
}
public ObservableCollection<SPTMod> ActiveMods { get; private set; } = [];
public ObservableCollection<SPTMod> InactiveMods { get; private set; } = [];
2023-08-14 09:50:00 -04:00
public ModInfoCollection()
{
var serverMods = ServerManager.GetLoadedServerMods().Values.ToList();
var profileMods = ServerManager.GetProfileMods().ToList();
ServerModsCount = serverMods?.Count() ?? 0;
ProfileModsCount = profileMods?.Count() ?? 0;
2024-01-26 21:46:39 -05:00
foreach (var activeMod in serverMods)
2023-08-14 09:50:00 -04:00
{
2024-01-26 21:46:39 -05:00
activeMod.InServer = true;
ActiveMods.Add(activeMod);
2023-08-14 09:50:00 -04:00
}
2024-01-26 21:46:39 -05:00
foreach (var inactiveMod in profileMods)
2023-08-14 09:50:00 -04:00
{
var existingMod = ActiveMods.FirstOrDefault(x => x.Name == inactiveMod.Name && x.Version == inactiveMod.Version && x.Author == inactiveMod.Author);
2023-08-14 09:50:00 -04:00
if (existingMod != null)
{
existingMod.InProfile = true;
continue;
}
2024-01-26 21:46:39 -05:00
inactiveMod.InProfile = true;
InactiveMods.Add(inactiveMod);
2023-08-14 09:50:00 -04:00
}
2024-01-26 21:46:39 -05:00
HasMods = ActiveMods.Count > 0 || InactiveMods.Count > 0;
2023-08-14 09:50:00 -04:00
}
}
}