mirror of
https://github.com/sp-tarkov/launcher.git
synced 2025-02-12 17:10:44 -05:00
add mods info colleciton, some cleanup
This commit is contained in:
parent
a7f36c5c63
commit
08dfba17f1
106
project/Aki.Launcher.Base/Models/Launcher/ModInfoCollection.cs
Normal file
106
project/Aki.Launcher.Base/Models/Launcher/ModInfoCollection.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using Aki.Launcher.Models.Aki;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aki.Launcher.Models.Launcher
|
||||
{
|
||||
public class ModInfoCollection : INotifyPropertyChanged
|
||||
{
|
||||
private int _serverModsCount;
|
||||
public int ServerModsCount
|
||||
{
|
||||
get => _serverModsCount;
|
||||
set
|
||||
{
|
||||
if (_serverModsCount != value)
|
||||
{
|
||||
_serverModsCount = value;
|
||||
RaisePropertyChanged(nameof(ServerModsCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _profileModsCount;
|
||||
public int ProfileModsCount
|
||||
{
|
||||
get => _profileModsCount;
|
||||
set
|
||||
{
|
||||
if (_profileModsCount != value)
|
||||
{
|
||||
_profileModsCount = value;
|
||||
RaisePropertyChanged(nameof(ProfileModsCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _hasProfileOnlyMods;
|
||||
public bool HasProfileOnlyMods
|
||||
{
|
||||
get => _hasProfileOnlyMods;
|
||||
set
|
||||
{
|
||||
if (_hasProfileOnlyMods != value)
|
||||
{
|
||||
_hasProfileOnlyMods = value;
|
||||
RaisePropertyChanged(nameof(HasProfileOnlyMods));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _hasMods;
|
||||
public bool HasMods
|
||||
{
|
||||
get => _hasMods;
|
||||
set
|
||||
{
|
||||
if (_hasMods != value)
|
||||
{
|
||||
_hasMods = value;
|
||||
RaisePropertyChanged(nameof(HasMods));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<AkiMod> Mods { get; private set; } = new ObservableCollection<AkiMod>();
|
||||
|
||||
public ModInfoCollection()
|
||||
{
|
||||
var serverMods = ServerManager.GetLoadedServerMods().Values.ToList();
|
||||
var profileMods = ServerManager.GetProfileMods().ToList();
|
||||
|
||||
ServerModsCount = serverMods?.Count() ?? 0;
|
||||
ProfileModsCount = profileMods?.Count() ?? 0;
|
||||
|
||||
foreach (var serverMod in serverMods)
|
||||
{
|
||||
serverMod.InServer = true;
|
||||
Mods.Add(serverMod);
|
||||
}
|
||||
|
||||
foreach (var profileMod in profileMods)
|
||||
{
|
||||
var existingMod = Mods.Where(x => x.Name == profileMod.Name && x.Version == profileMod.Version && x.Author == profileMod.Author).FirstOrDefault();
|
||||
|
||||
if (existingMod != null)
|
||||
{
|
||||
existingMod.InProfile = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
profileMod.InProfile = true;
|
||||
Mods.Add(profileMod);
|
||||
}
|
||||
|
||||
HasMods = Mods.Count() > 0;
|
||||
HasProfileOnlyMods = Mods.Where(x => x.InProfile && !x.InServer).Count() > 0;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void RaisePropertyChanged(string property)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
|
||||
}
|
||||
}
|
||||
}
|
@ -12,9 +12,6 @@ using System.Reactive.Disposables;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Aki.Launcher.Models.Aki;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Aki.Launcher.ViewModels
|
||||
{
|
||||
@ -37,22 +34,13 @@ namespace Aki.Launcher.ViewModels
|
||||
set => this.RaiseAndSetIfChanged(ref _ModsListIsVisible, value);
|
||||
}
|
||||
|
||||
private PathGeometry _ModsListToggleButtonIcon;
|
||||
public PathGeometry ModsListToggleButtonIcon
|
||||
{
|
||||
get => _ModsListToggleButtonIcon;
|
||||
set => this.RaiseAndSetIfChanged(ref _ModsListToggleButtonIcon, value);
|
||||
}
|
||||
|
||||
public string CurrentID { get; set; }
|
||||
|
||||
public ProfileInfo ProfileInfo { get; set; } = AccountManager.SelectedProfileInfo;
|
||||
|
||||
public ImageHelper SideImage { get; } = new ImageHelper();
|
||||
|
||||
public ObservableCollection<AkiMod> Mods { get; set; } = new ObservableCollection<AkiMod>();
|
||||
public int ServerModsCount { get; set; }
|
||||
public int ProfileModsCount { get; set; }
|
||||
public ModInfoCollection ModInfoCollection { get; set; } = new ModInfoCollection();
|
||||
|
||||
private GameStarter gameStarter = new GameStarter(new GameStarterFrontend());
|
||||
|
||||
@ -84,33 +72,7 @@ namespace Aki.Launcher.ViewModels
|
||||
|
||||
CurrentID = AccountManager.SelectedAccount.id;
|
||||
|
||||
var serverMods = ServerManager.GetLoadedServerMods().Values.ToList();
|
||||
var profileMods = ServerManager.GetProfileMods().ToList();
|
||||
|
||||
ProfileModsCount = profileMods?.Count() ?? 0;
|
||||
ServerModsCount = serverMods?.Count() ?? 0;
|
||||
|
||||
ModsListIsVisible = false;
|
||||
|
||||
foreach (var serverMod in serverMods)
|
||||
{
|
||||
serverMod.InServer = true;
|
||||
Mods.Add(serverMod);
|
||||
}
|
||||
|
||||
foreach (var profileMod in profileMods)
|
||||
{
|
||||
var existingMod = Mods.Where(x => x.Name == profileMod.Name && x.Version == profileMod.Version && x.Author == profileMod.Author).FirstOrDefault();
|
||||
|
||||
if (existingMod != null)
|
||||
{
|
||||
existingMod.InProfile = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
profileMod.InProfile = true;
|
||||
Mods.Add(profileMod);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task GameVersionCheck()
|
||||
@ -137,15 +99,7 @@ namespace Aki.Launcher.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleModsListCommand()
|
||||
{
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
ModsListIsVisible = !ModsListIsVisible;
|
||||
//ModsListToggleButtonIcon = ModsListIsVisible ? "<" : ">";
|
||||
});
|
||||
}
|
||||
public void ToggleModsListCommand() => ModsListIsVisible = !ModsListIsVisible;
|
||||
|
||||
public void LogoutCommand()
|
||||
{
|
||||
|
@ -60,23 +60,23 @@
|
||||
<!-- Total Mods Info -->
|
||||
<Border Grid.Row="3" Grid.Column="1" CornerRadius="5"
|
||||
BorderBrush="{StaticResource AKI_Background_Dark}"
|
||||
BorderThickness="5"
|
||||
BorderThickness="5" IsVisible="{Binding ModInfoCollection.HasMods}"
|
||||
>
|
||||
<Grid RowDefinitions="10,AUTO,AUTO,10" ColumnDefinitions="10,AUTO,*,AUTO,AUTO,AUTO,10"
|
||||
Background="{StaticResource AKI_Background_Dark}">
|
||||
<Label Grid.Row="1" Grid.Column="1" Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=server_mods}"
|
||||
/>
|
||||
<Label Grid.Row="2" Grid.Column="1" Content="{Binding ServerModsCount}"
|
||||
<Label Grid.Row="2" Grid.Column="1" Content="{Binding ModInfoCollection.ServerModsCount}"
|
||||
/>
|
||||
<Label Grid.Row="1" Grid.Column="3" Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=profile_mods}"
|
||||
/>
|
||||
<Path Grid.Row="1" Grid.Column="4" Margin="10 4 10 0"
|
||||
<Path Grid.Row="1" Grid.Column="4" Margin="10 4 0 0" IsVisible="{Binding ModInfoCollection.HasProfileOnlyMods}"
|
||||
Data="{StaticResource Alert}" Fill="{StaticResource AKI_Brush_Yellow}"
|
||||
/>
|
||||
<Label Grid.Row="2" Grid.Column="3" Content="{Binding ProfileModsCount}"
|
||||
<Label Grid.Row="2" Grid.Column="3" Content="{Binding ModInfoCollection.ProfileModsCount}"
|
||||
/>
|
||||
<Button Grid.Row="0" Grid.RowSpan="4" Grid.Column="5" Grid.ColumnSpan="2"
|
||||
VerticalAlignment="Stretch" FontSize="18"
|
||||
VerticalAlignment="Stretch" FontSize="18" Margin="10 0 0 0"
|
||||
Command="{Binding ToggleModsListCommand}"
|
||||
Classes="icon"
|
||||
>
|
||||
@ -98,7 +98,7 @@
|
||||
|
||||
<!-- Mods List -->
|
||||
<ScrollViewer Grid.Row="1" Grid.RowSpan="5" Grid.Column="3" IsVisible="{Binding ModsListIsVisible}">
|
||||
<ItemsControl Items="{Binding Mods}">
|
||||
<ItemsControl Items="{Binding ModInfoCollection.Mods}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type launcher:AkiMod}">
|
||||
<cc:ModInfoCard ModName="{Binding Name}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user