diff --git a/project/SPT.Launcher.Base/Controllers/GameStarter.cs b/project/SPT.Launcher.Base/Controllers/GameStarter.cs index 2853616..253450b 100644 --- a/project/SPT.Launcher.Base/Controllers/GameStarter.cs +++ b/project/SPT.Launcher.Base/Controllers/GameStarter.cs @@ -141,7 +141,6 @@ namespace SPT.Launcher try { - Process.Start(clientProcess); LogManager.Instance.Info("[LaunchGame] Game process started"); } diff --git a/project/SPT.Launcher.Base/SPT.Launcher.Base.csproj b/project/SPT.Launcher.Base/SPT.Launcher.Base.csproj index 5c039d0..d7cf473 100644 --- a/project/SPT.Launcher.Base/SPT.Launcher.Base.csproj +++ b/project/SPT.Launcher.Base/SPT.Launcher.Base.csproj @@ -13,7 +13,7 @@ - + diff --git a/project/SPT.Launcher/App.axaml b/project/SPT.Launcher/App.axaml index 5377cca..f7def06 100644 --- a/project/SPT.Launcher/App.axaml +++ b/project/SPT.Launcher/App.axaml @@ -1,32 +1,49 @@ + x:Class="SPT.Launcher.App" + RequestedThemeVariant="Dark" + > - + - - #121212 - #FFC107 - #FFFFFF - #282828 - #323947 - - - - - - - - - + + + + + #436082 + #567ca8 + #6998ce + #6a6357 + #908676 + #b6a995 + White + #cccccc + #cca480 + Black + + + #54a4ff + #4383cc + #326299 + #b2a58d + #7f7564 + #4c463b + #181a1b + #393e41 + #37332d + White + + + + diff --git a/project/SPT.Launcher/Assets/Styles.axaml b/project/SPT.Launcher/Assets/Styles.axaml index 8f31d4f..658405f 100644 --- a/project/SPT.Launcher/Assets/Styles.axaml +++ b/project/SPT.Launcher/Assets/Styles.axaml @@ -1,24 +1,64 @@  - - + + + + + + + \ No newline at end of file diff --git a/project/SPT.Launcher/CustomControls/LoginBox.axaml.cs b/project/SPT.Launcher/CustomControls/LoginBox.axaml.cs new file mode 100644 index 0000000..4ff5060 --- /dev/null +++ b/project/SPT.Launcher/CustomControls/LoginBox.axaml.cs @@ -0,0 +1,40 @@ +using System.Windows.Input; +using Avalonia; +using Avalonia.Controls; + +namespace SPT.Launcher.CustomControls; + +public partial class LoginBox : UserControl +{ + public LoginBox() + { + InitializeComponent(); + } + + public static readonly StyledProperty UsernameProperty = AvaloniaProperty.Register( + "Username"); + + public string Username + { + get => GetValue(UsernameProperty); + set => SetValue(UsernameProperty, value); + } + + public static readonly StyledProperty LoginCommandProperty = AvaloniaProperty.Register( + "LoginCommand"); + + public ICommand LoginCommand + { + get => GetValue(LoginCommandProperty); + set => SetValue(LoginCommandProperty, value); + } + + public static readonly StyledProperty IsLoggedInProperty = AvaloniaProperty.Register( + "IsLoggedIn"); + + public bool IsLoggedIn + { + get => GetValue(IsLoggedInProperty); + set => SetValue(IsLoggedInProperty, value); + } +} \ No newline at end of file diff --git a/project/SPT.Launcher/CustomControls/ModInfoCard.axaml b/project/SPT.Launcher/CustomControls/ModInfoCard.axaml index dd4fadc..a0727be 100644 --- a/project/SPT.Launcher/CustomControls/ModInfoCard.axaml +++ b/project/SPT.Launcher/CustomControls/ModInfoCard.axaml @@ -5,12 +5,10 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" xmlns:helpers="using:SPT.Launcher.Helpers" x:Class="SPT.Launcher.CustomControls.ModInfoCard"> - - + @@ -19,19 +17,19 @@ Orientation="Horizontal" Spacing="5" > - - - @@ -54,7 +52,7 @@ > @@ -66,7 +64,7 @@ /> - diff --git a/project/SPT.Launcher/CustomControls/ProfileCard.axaml b/project/SPT.Launcher/CustomControls/ProfileCard.axaml new file mode 100644 index 0000000..afb8815 --- /dev/null +++ b/project/SPT.Launcher/CustomControls/ProfileCard.axaml @@ -0,0 +1,61 @@ + + + + + + + + + + + diff --git a/project/SPT.Launcher/CustomControls/TotalModsCard.axaml b/project/SPT.Launcher/CustomControls/TotalModsCard.axaml new file mode 100644 index 0000000..e31b467 --- /dev/null +++ b/project/SPT.Launcher/CustomControls/TotalModsCard.axaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/project/SPT.Launcher/CustomControls/TotalModsCard.axaml.cs b/project/SPT.Launcher/CustomControls/TotalModsCard.axaml.cs new file mode 100644 index 0000000..5da6cf4 --- /dev/null +++ b/project/SPT.Launcher/CustomControls/TotalModsCard.axaml.cs @@ -0,0 +1,33 @@ +using System.Collections.ObjectModel; +using System.Windows.Input; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace SPT.Launcher.CustomControls; + +public partial class TotalModsCard : UserControl +{ + public TotalModsCard() + { + InitializeComponent(); + } + + public static readonly StyledProperty ActiveModsCountProperty = AvaloniaProperty.Register( + "ActiveModsCount"); + + public int ActiveModsCount + { + get => GetValue(ActiveModsCountProperty); + set => SetValue(ActiveModsCountProperty, value); + } + + public static readonly StyledProperty OpenModsInfoCommandProperty = AvaloniaProperty.Register( + "OpenModsInfoCommand"); + + public ICommand OpenModsInfoCommand + { + get => GetValue(OpenModsInfoCommandProperty); + set => SetValue(OpenModsInfoCommandProperty, value); + } +} \ No newline at end of file diff --git a/project/SPT.Launcher/Models/GameStarterFrontend.cs b/project/SPT.Launcher/Models/GameStarterFrontend.cs index 016347e..5d01217 100644 --- a/project/SPT.Launcher/Models/GameStarterFrontend.cs +++ b/project/SPT.Launcher/Models/GameStarterFrontend.cs @@ -7,6 +7,7 @@ using Avalonia.Controls.Notifications; using Splat; using System.Collections.Generic; using System.Threading.Tasks; +using DialogHostAvalonia; namespace SPT.Launcher.Models { @@ -30,7 +31,7 @@ namespace SPT.Launcher.Models var localeText = string.Format(LocalizationProvider.Instance.file_mismatch_dialog_message, serverVersion); - var result = await DialogHost.DialogHost.Show(new ConfirmationDialogViewModel(null, localeText, null, null, LauncherSettingsProvider.Instance.IsDevMode)); + var result = await DialogHost.Show(new ConfirmationDialogViewModel(null, localeText, null, null, LauncherSettingsProvider.Instance.IsDevMode)); if(result != null && result is bool confirmation && !confirmation) { diff --git a/project/SPT.Launcher/SPT.Launcher.csproj b/project/SPT.Launcher/SPT.Launcher.csproj index a32dfc4..6c941f6 100644 --- a/project/SPT.Launcher/SPT.Launcher.csproj +++ b/project/SPT.Launcher/SPT.Launcher.csproj @@ -22,12 +22,13 @@ - - + + - - + + + diff --git a/project/SPT.Launcher/ViewLocator.cs b/project/SPT.Launcher/ViewLocator.cs index 54efb46..7292b00 100644 --- a/project/SPT.Launcher/ViewLocator.cs +++ b/project/SPT.Launcher/ViewLocator.cs @@ -7,7 +7,7 @@ namespace SPT.Launcher { public class ViewLocator : IDataTemplate { - public IControl Build(object data) + public Control Build(object data) { var name = data.GetType().FullName!.Replace("ViewModel", "View"); var type = Type.GetType(name); diff --git a/project/SPT.Launcher/ViewModels/LoginViewModel.cs b/project/SPT.Launcher/ViewModels/LoginViewModel.cs index 49a033b..e9e16e7 100644 --- a/project/SPT.Launcher/ViewModels/LoginViewModel.cs +++ b/project/SPT.Launcher/ViewModels/LoginViewModel.cs @@ -146,8 +146,10 @@ namespace SPT.Launcher.ViewModels }); } - public void GetExistingProfiles() + public async Task GetExistingProfiles() { + await Task.Delay(200); + ServerProfileInfo[] existingProfiles = AccountManager.GetExistingProfiles(); if(existingProfiles != null) @@ -164,6 +166,8 @@ namespace SPT.Launcher.ViewModels ImageHelper sideImage = new ImageHelper() { Path = profileInfo.SideImage }; sideImage.Touch(); + + await Task.Delay(100); } } } diff --git a/project/SPT.Launcher/ViewModels/MainWindowViewModel.cs b/project/SPT.Launcher/ViewModels/MainWindowViewModel.cs index 6091479..2623452 100644 --- a/project/SPT.Launcher/ViewModels/MainWindowViewModel.cs +++ b/project/SPT.Launcher/ViewModels/MainWindowViewModel.cs @@ -9,7 +9,7 @@ using SPT.Launcher.Models.SPT; using SPT.Launcher.Helpers; using SPT.Launcher.ViewModels.Dialogs; using Avalonia.Threading; -using dialogHost = DialogHost.DialogHost; +using DialogHostAvalonia; namespace SPT.Launcher.ViewModels @@ -48,7 +48,7 @@ namespace SPT.Launcher.ViewModels LocalizationProvider.Instance.yes, LocalizationProvider.Instance.no); - var confirmCopySettings = await dialogHost.Show(viewModel); + var confirmCopySettings = await DialogHost.Show(viewModel); if (confirmCopySettings is bool and true) { diff --git a/project/SPT.Launcher/ViewModels/ProfileViewModel.cs b/project/SPT.Launcher/ViewModels/ProfileViewModel.cs index 2cd4c90..59e8c4a 100644 --- a/project/SPT.Launcher/ViewModels/ProfileViewModel.cs +++ b/project/SPT.Launcher/ViewModels/ProfileViewModel.cs @@ -10,6 +10,7 @@ using SPT.Launcher.ViewModels.Dialogs; using Avalonia.Threading; using System.Diagnostics; using System.IO; +using Avalonia.Controls.ApplicationLifetimes; using SPT.Launcher.Models.SPT; namespace SPT.Launcher.ViewModels @@ -17,8 +18,8 @@ namespace SPT.Launcher.ViewModels [RequireLoggedIn] public class ProfileViewModel : ViewModelBase { - public string CurrentUsername { get; set; } - + // public string CurrentUsername { get; set; } + private string _CurrentEdition; public string CurrentEdition { @@ -40,7 +41,7 @@ namespace SPT.Launcher.ViewModels set => this.RaiseAndSetIfChanged(ref _ProfileWipePending, value); } - public string CurrentID { get; set; } + public string CurrentId { get; set; } public ProfileInfo ProfileInfo { get; set; } = AccountManager.SelectedProfileInfo; @@ -48,9 +49,9 @@ namespace SPT.Launcher.ViewModels public ModInfoCollection ModInfoCollection { get; set; } = new ModInfoCollection(); - private GameStarter gameStarter = new GameStarter(new GameStarterFrontend()); + private readonly GameStarter _gameStarter = new GameStarter(new GameStarterFrontend()); - private ProcessMonitor monitor { get; set; } + private readonly ProcessMonitor _monitor; public ProfileViewModel(IScreen Host) : base(Host) { @@ -62,13 +63,13 @@ namespace SPT.Launcher.ViewModels SideImage.Touch(); } - monitor = new ProcessMonitor("EscapeFromTarkov", 1000, aliveCallback: GameAliveCallBack, exitCallback: GameExitCallback); + _monitor = new ProcessMonitor("EscapeFromTarkov", 1000, aliveCallback: GameAliveCallBack, exitCallback: GameExitCallback); - CurrentUsername = AccountManager.SelectedAccount.username; + // CurrentUsername = AccountManager.SelectedAccount.username; CurrentEdition = AccountManager.SelectedAccount.edition; - CurrentID = AccountManager.SelectedAccount.id; + CurrentId = AccountManager.SelectedAccount.id; } private async Task GameVersionCheck() @@ -154,11 +155,11 @@ namespace SPT.Launcher.ViewModels WipeProfileOnStart = false; } - GameStarterResult gameStartResult = await gameStarter.LaunchGame(ServerManager.SelectedServer, AccountManager.SelectedAccount, LauncherSettingsProvider.Instance.GamePath); + GameStarterResult gameStartResult = await _gameStarter.LaunchGame(ServerManager.SelectedServer, AccountManager.SelectedAccount, LauncherSettingsProvider.Instance.GamePath); if (gameStartResult.Succeeded) { - monitor.Start(); + _monitor.Start(); switch (LauncherSettingsProvider.Instance.LauncherStartGameAction) { @@ -221,9 +222,14 @@ namespace SPT.Launcher.ViewModels public async Task CopyCommand(object parameter) { - if (Application.Current.Clipboard != null && parameter != null && parameter is string text) + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop && parameter is string text) { - await Application.Current.Clipboard.SetTextAsync(text); + if (desktop?.MainWindow?.Clipboard == null) + { + return; + } + + await desktop.MainWindow.Clipboard.SetTextAsync(text); SendNotification("", $"{text} {LocalizationProvider.Instance.copied}", Avalonia.Controls.Notifications.NotificationType.Success); } } diff --git a/project/SPT.Launcher/ViewModels/ViewModelBase.cs b/project/SPT.Launcher/ViewModels/ViewModelBase.cs index 2064f27..ae658fd 100644 --- a/project/SPT.Launcher/ViewModels/ViewModelBase.cs +++ b/project/SPT.Launcher/ViewModels/ViewModelBase.cs @@ -8,7 +8,7 @@ using ReactiveUI; using Splat; using System; using System.Threading.Tasks; -using dialogHost = DialogHost.DialogHost; +using DialogHostAvalonia; namespace SPT.Launcher.ViewModels { @@ -162,7 +162,7 @@ namespace SPT.Launcher.ViewModels /// public async Task ShowDialog(object ViewModel) { - return await dialogHost.Show(ViewModel); + return await DialogHost.Show(ViewModel); } public ViewModelBase(IScreen Host) diff --git a/project/SPT.Launcher/Views/ConnectServerView.axaml b/project/SPT.Launcher/Views/ConnectServerView.axaml index c681149..ecfab7d 100644 --- a/project/SPT.Launcher/Views/ConnectServerView.axaml +++ b/project/SPT.Launcher/Views/ConnectServerView.axaml @@ -24,6 +24,7 @@ HorizontalAlignment="Center" IsVisible="{Binding connectModel.ConnectionFailed}" Command="{Binding RetryCommand}" + Classes="alt" /> diff --git a/project/SPT.Launcher/Views/Dialogs/ChangeEditionDialogView.axaml b/project/SPT.Launcher/Views/Dialogs/ChangeEditionDialogView.axaml index 99060c1..a81ecfa 100644 --- a/project/SPT.Launcher/Views/Dialogs/ChangeEditionDialogView.axaml +++ b/project/SPT.Launcher/Views/Dialogs/ChangeEditionDialogView.axaml @@ -3,11 +3,12 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:helpers="using:SPT.Launcher.Helpers" - xmlns:dialogHost="clr-namespace:DialogHost;assembly=DialogHost.Avalonia" + xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia" xmlns:s="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SPT.Launcher.Views.Dialogs.ChangeEditionDialogView" - Background="{StaticResource SPT_Background_Dark}"> + Background="{DynamicResource BackgroundBrush}" + > @@ -16,13 +17,13 @@ Foreground="IndianRed" /> - @@ -31,7 +32,7 @@ + - - - - - - - - - - - - - - - - - + + + diff --git a/project/SPT.Launcher/Views/MainWindow.axaml b/project/SPT.Launcher/Views/MainWindow.axaml index 329a40a..78ceac4 100644 --- a/project/SPT.Launcher/Views/MainWindow.axaml +++ b/project/SPT.Launcher/Views/MainWindow.axaml @@ -5,20 +5,19 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:cc="using:SPT.Launcher.CustomControls" xmlns:rxui="using:Avalonia.ReactiveUI" - xmlns:helpers="using:SPT.Launcher.Helpers" xmlns:cvt="using:SPT.Launcher.Converters" - xmlns:dialogHost="clr-namespace:DialogHost;assembly=DialogHost.Avalonia" + xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia" mc:Ignorable="d" d:DesignWidth="750" d:DesignHeight="450" x:Class="SPT.Launcher.Views.MainWindow" Icon="/Assets/spt-logo.ico" Title="SPT.Launcher" - MinHeight="450" MinWidth="800" - Height="450" Width="800" + MinHeight="450" MinWidth="760" + Height="450" Width="760" WindowStartupLocation="CenterScreen" ExtendClientAreaToDecorationsHint="True" ExtendClientAreaChromeHints="NoChrome" ExtendClientAreaTitleBarHeightHint="-1" - Background="{StaticResource SPT_Background_Light}"> + Background="{DynamicResource AltBackgroundBrush}"> @@ -39,7 +38,7 @@ MinButtonCommand="{Binding MinimizeCommand}" SettingsButtonCommand="{Binding GoToSettingsCommand}" Classes.versiontag="{Binding VersionInfo.HasTag}" - /> + /> - +