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;
|
2024-09-02 07:53:58 +00:00
|
|
|
|
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
|
|
|
|
{
|
2024-09-02 07:53:58 +00:00
|
|
|
|
public class ModInfoCollection : NotifyPropertyChangedBase
|
2023-08-14 09:50:00 -04:00
|
|
|
|
{
|
|
|
|
|
private int _serverModsCount;
|
|
|
|
|
public int ServerModsCount
|
|
|
|
|
{
|
|
|
|
|
get => _serverModsCount;
|
2024-09-02 07:53:58 +00:00
|
|
|
|
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;
|
2024-09-02 07:53:58 +00:00
|
|
|
|
set => SetProperty(ref _profileModsCount, value);
|
2023-08-14 09:50:00 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _hasMods;
|
|
|
|
|
public bool HasMods
|
|
|
|
|
{
|
|
|
|
|
get => _hasMods;
|
2024-09-02 07:53:58 +00:00
|
|
|
|
set => SetProperty(ref _hasMods, value);
|
2023-08-14 09:50:00 -04:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-02 07:53:58 +00: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
|
|
|
|
{
|
2024-09-02 07:53:58 +00: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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|