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

Merge branch 'master' of https://dev.sp-tarkov.com/SPT/Launcher into 310-dev

This commit is contained in:
Dev 2024-07-13 09:20:20 +01:00
commit 831b2a0992
21 changed files with 200 additions and 68 deletions

View File

@ -217,7 +217,7 @@ namespace SPT.Launcher
{ {
var serverVersion = new SPTVersion(ServerManager.GetVersion()); var serverVersion = new SPTVersion(ServerManager.GetVersion());
var coreDllVersionInfo = FileVersionInfo.GetVersionInfo(Path.Combine($"{gamePath}/BepinEx/plugins/spt", "spt-core.dll")); var coreDllVersionInfo = FileVersionInfo.GetVersionInfo(Path.Join(gamePath, @"\BepinEx\plugins\spt", "spt-core.dll"));
var dllVersion = new SPTVersion(coreDllVersionInfo.FileVersion); var dllVersion = new SPTVersion(coreDllVersionInfo.FileVersion);
LogManager.Instance.Info($"[LaunchGame] spt-core.dll version: {dllVersion}"); LogManager.Instance.Info($"[LaunchGame] spt-core.dll version: {dllVersion}");
@ -300,7 +300,6 @@ namespace SPT.Launcher
foreach (var value in key.GetValueNames()) foreach (var value in key.GetValueNames())
{ {
key.DeleteValue(value); key.DeleteValue(value);
LogManager.Instance.Debug($"Removing reg key: {key.Name}");
} }
} }
catch (Exception ex) catch (Exception ex)
@ -352,7 +351,6 @@ namespace SPT.Launcher
{ {
file.IsReadOnly = false; file.IsReadOnly = false;
file.Delete(); file.Delete();
LogManager.Instance.Debug($" -> del file: {file.FullName}");
} }
// remove directory // remove directory

View File

@ -20,16 +20,16 @@ namespace SPT.Launcher.Controllers
private static LogManager _instance; private static LogManager _instance;
public static LogManager Instance => _instance ??= new LogManager(); public static LogManager Instance => _instance ??= new LogManager();
private readonly string _filePath; private readonly string _filePath;
private readonly string _logFile; public readonly string LogFile;
private LogManager() private LogManager()
{ {
_filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "user", "logs"); _filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "user", "logs");
_logFile = Path.Combine(_filePath, "launcher.log"); LogFile = Path.Combine(_filePath, "launcher.log");
if (File.Exists(_logFile)) if (File.Exists(LogFile))
{ {
File.Delete(_logFile); File.Delete(LogFile);
} }
Write($" ==== Launcher Started ===="); Write($" ==== Launcher Started ====");
@ -52,7 +52,7 @@ namespace SPT.Launcher.Controllers
Directory.CreateDirectory(_filePath); Directory.CreateDirectory(_filePath);
} }
File.AppendAllLines(_logFile, new[] { $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]{GetDevModeTag()}{text}" }); File.AppendAllLines(LogFile, new[] { $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]{GetDevModeTag()}{text}" });
} }
public void Debug(string text) => Write($"[Debug] {text}"); public void Debug(string text) => Write($"[Debug] {text}");

View File

@ -193,6 +193,8 @@ namespace SPT.Launcher.Helpers
englishLocale.dev_mode = "Developer Mode"; englishLocale.dev_mode = "Developer Mode";
englishLocale.failed_to_save_settings = "Failed to save settings"; englishLocale.failed_to_save_settings = "Failed to save settings";
englishLocale.register_failed_name_limit = "name cannot exceed 15 characters"; englishLocale.register_failed_name_limit = "name cannot exceed 15 characters";
englishLocale.copy_failed = "Failed to copy data to clipboard";
englishLocale.copy_logs_to_clipboard = "Copy logs to clipboard";
#endregion #endregion
Directory.CreateDirectory(LocalizationProvider.DefaultLocaleFolderPath); Directory.CreateDirectory(LocalizationProvider.DefaultLocaleFolderPath);
@ -229,6 +231,39 @@ namespace SPT.Launcher.Helpers
#region All Properties #region All Properties
#region
private string _copy_logs_to_clipboard;
public string copy_logs_to_clipboard
{
get => _copy_logs_to_clipboard;
set
{
if (_copy_logs_to_clipboard != value)
{
_copy_logs_to_clipboard = value;
RaisePropertyChanged(nameof(copy_logs_to_clipboard));
}
}
}
#endregion
#region copy_failed
private string _copy_failed;
public string copy_failed
{
get => _copy_failed;
set
{
if (_copy_failed != value)
{
_copy_failed = value;
RaisePropertyChanged(nameof(copy_failed));
}
}
}
#endregion
#region register_failed_name_limit #region register_failed_name_limit
private string _register_failed_name_limit; private string _register_failed_name_limit;

View File

@ -38,7 +38,7 @@ namespace SPT.Launcher.Models.SPT
string[] splitVersion = SPTVersion.Split('.'); string[] splitVersion = SPTVersion.Split('.');
if (splitVersion.Length == 3) if (splitVersion.Length >= 3)
{ {
int.TryParse(splitVersion[0], out Major); int.TryParse(splitVersion[0], out Major);
int.TryParse(splitVersion[1], out Minor); int.TryParse(splitVersion[1], out Minor);

View File

@ -6,7 +6,8 @@
xmlns:cvt="using:SPT.Launcher.Converters" xmlns:cvt="using:SPT.Launcher.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPT.Launcher.CustomControls.DetailedProfileCard" x:Class="SPT.Launcher.CustomControls.DetailedProfileCard"
MinWidth="250" MinHeight="250" MinWidth="250" MinHeight="300"
MaxWidth="250" MaxHeight="300"
PointerEntered="InputElement_OnPointerEntered" PointerEntered="InputElement_OnPointerEntered"
PointerExited="InputElement_OnPointerExited" PointerExited="InputElement_OnPointerExited"
PointerPressed="InputElement_OnPointerPressed" PointerPressed="InputElement_OnPointerPressed"
@ -26,22 +27,26 @@
</Transitions> </Transitions>
</Border.Transitions> </Border.Transitions>
<Grid RowDefinitions="Auto, Auto, *, Auto, Auto" ColumnDefinitions="Auto, *, Auto" Margin="10"> <Grid RowDefinitions="30, Auto, *, 20, Auto" ColumnDefinitions="Auto, *, Auto" Margin="10">
<!-- SPT version --> <!-- SPT version -->
<Label x:Name="SptVersion" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" <Viewbox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Stretch="Uniform">
<Label x:Name="SptVersion"
Background="Transparent" HorizontalAlignment="Center" Background="Transparent" HorizontalAlignment="Center"
ToolTip.Tip="{Binding $parent[UserControl].ProfileInfo.MismatchMessage}" ToolTip.Tip="{Binding $parent[UserControl].ProfileInfo.MismatchMessage}"
Classes.versionMismatch="{Binding $parent[UserControl].ProfileInfo.VersionMismatch}" Classes.versionMismatch="{Binding $parent[UserControl].ProfileInfo.VersionMismatch}"
> >
<StackPanel Orientation="Horizontal"> <TextBlock>
<TextBlock Text="{Binding $parent[UserControl].ProfileInfo.SPT.version}" <Run Text="{Binding $parent[UserControl].ProfileInfo.SPT.version}"
/> />
<InlineUIContainer>
<Path Data="{StaticResource Alert}" Fill="{Binding ElementName=SptVersion, Path=Foreground}" <Path Data="{StaticResource Alert}" Fill="{Binding ElementName=SptVersion, Path=Foreground}"
Margin="10 0" Margin="10 0"
IsVisible="{Binding $parent[UserControl].ProfileInfo.VersionMismatch}" IsVisible="{Binding $parent[UserControl].ProfileInfo.VersionMismatch}"
/> />
</StackPanel> </InlineUIContainer>
</TextBlock>
</Label> </Label>
</Viewbox>
<!-- Side image --> <!-- Side image -->
<Image Grid.Row="1" Grid.Column="0" <Image Grid.Row="1" Grid.Column="0"
@ -89,21 +94,16 @@
</StackPanel> </StackPanel>
<!-- remaining xp --> <!-- remaining xp -->
<StackPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" <Viewbox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" Stretch="Uniform" IsVisible="{Binding $parent[UserControl].ProfileInfo.HasData}">
HorizontalAlignment="Center" <TextBlock>
Orientation="Horizontal" <Run Text="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=next_level_in}"/>
IsVisible="{Binding $parent[UserControl].ProfileInfo.HasData}" <Run Text="{Binding $parent[UserControl].ProfileInfo.RemainingExp}" Foreground="{DynamicResource AccentBrush}"/>
> <Run>xp</Run>
<Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=next_level_in}"/> </TextBlock>
<Label Content="{Binding $parent[UserControl].ProfileInfo.RemainingExp}" </Viewbox>
FontWeight="SemiBold"
Classes="acc"
/>
<Label Content="xp"/>
</StackPanel>
<!-- xp progress --> <!-- xp progress -->
<ProgressBar Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3" <ProgressBar Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" Margin="0 10"
Value="{Binding $parent[UserControl].ProfileInfo.XPLevelProgress}" Value="{Binding $parent[UserControl].ProfileInfo.XPLevelProgress}"
IsVisible="{Binding $parent[UserControl].ProfileInfo.HasData}" IsVisible="{Binding $parent[UserControl].ProfileInfo.HasData}"
/> />

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Tryb Dewelopera", "dev_mode": "Tryb Dewelopera",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -97,5 +97,7 @@
"dev_mode": "Developer Mode", "dev_mode": "Developer Mode",
"failed_to_save_settings": "Failed to save settings", "failed_to_save_settings": "Failed to save settings",
"core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT", "core_dll_file_version_mismatch": "Your BepinEx/plugins/spt/spt-core.dll file version doesn't match what was expected and is unable to start. Try reinstalling SPT",
"register_failed_name_limit": "name cannot exceed 15 characters" "register_failed_name_limit": "name cannot exceed 15 characters",
"copy_failed": "Failed to copy data to clipboard",
"copy_logs_to_clipboard": "Copy logs to clipboard"
} }

View File

@ -18,8 +18,6 @@ namespace SPT.Launcher.ViewModels
[RequireLoggedIn] [RequireLoggedIn]
public class ProfileViewModel : ViewModelBase public class ProfileViewModel : ViewModelBase
{ {
// public string CurrentUsername { get; set; }
private string _CurrentEdition; private string _CurrentEdition;
public string CurrentEdition public string CurrentEdition
{ {
@ -65,8 +63,6 @@ namespace SPT.Launcher.ViewModels
_monitor = new ProcessMonitor("EscapeFromTarkov", 1000, aliveCallback: GameAliveCallBack, exitCallback: GameExitCallback); _monitor = new ProcessMonitor("EscapeFromTarkov", 1000, aliveCallback: GameAliveCallBack, exitCallback: GameExitCallback);
// CurrentUsername = AccountManager.SelectedAccount.username;
CurrentEdition = AccountManager.SelectedAccount.edition; CurrentEdition = AccountManager.SelectedAccount.edition;
CurrentId = AccountManager.SelectedAccount.id; CurrentId = AccountManager.SelectedAccount.id;

View File

@ -7,11 +7,15 @@ using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using ReactiveUI; using ReactiveUI;
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using Avalonia.Input;
using Avalonia.Platform.Storage;
namespace SPT.Launcher.ViewModels namespace SPT.Launcher.ViewModels
{ {
@ -34,6 +38,64 @@ namespace SPT.Launcher.ViewModels
LauncherSettingsProvider.Instance.SaveSettings(); LauncherSettingsProvider.Instance.SaveSettings();
} }
public async Task CopyLogsToClipboard()
{
LogManager.Instance.Info("[Settings] Copying logs to clipboard ...");
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
if (desktop.MainWindow?.Clipboard == null)
{
LogManager.Instance.Error("[Settings] Failed to get clipboard");
return;
}
var traceLogs = Directory.GetFiles(Path.Join(LauncherSettingsProvider.Instance.GamePath, "Logs"), $"{DateTime.Now:yyyy.MM.dd}_* traces.log", SearchOption.AllDirectories);
var traceLog = traceLogs.Length > 0 ? traceLogs[0] : "";
var filesToCopy = new string[]
{
Path.Join(LauncherSettingsProvider.Instance.GamePath, @"\user\logs", $"server-{DateTime.Now:yyyy-MM-dd}.log"),
traceLog,
Path.Join(LauncherSettingsProvider.Instance.GamePath, @"BepInEx\LogOutput.log"),
Path.Join(LauncherSettingsProvider.Instance.GamePath, @"\user\profiles", $"{AccountManager.SelectedAccount.id}.json"),
LogManager.Instance.LogFile,
};
List<IStorageFile> files = new List<IStorageFile>();
foreach (var logPath in filesToCopy)
{
var file = await desktop.MainWindow.StorageProvider.TryGetFileFromPathAsync(logPath);
if (file != null)
{
LogManager.Instance.Debug($"file to copy :: {logPath}");
files.Add(file);
continue;
}
LogManager.Instance.Warning($"failed to get file to copy :: {logPath}");
}
if (files.Count == 0)
{
LogManager.Instance.Warning("[Settings] Failed to copy log files");
SendNotification("", LocalizationProvider.Instance.copy_failed);
}
var data = new DataObject();
data.Set(DataFormats.Files, files.ToArray());
await desktop.MainWindow.Clipboard.SetDataObjectAsync(data);
LogManager.Instance.Info($"[Settings] {files.Count} log/s copied to clipboard");
SendNotification("", $"{files.Count} {LocalizationProvider.Instance.copied}");
}
}
public void GoBackCommand() public void GoBackCommand()
{ {
if (Application.Current?.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktop) if (Application.Current?.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktop)
@ -53,40 +115,47 @@ namespace SPT.Launcher.ViewModels
public void CleanTempFilesCommand() public void CleanTempFilesCommand()
{ {
LogManager.Instance.Info("[Settings] Clearing temp files ...");
bool filesCleared = gameStarter.CleanTempFiles(); bool filesCleared = gameStarter.CleanTempFiles();
if (filesCleared) if (filesCleared)
{ {
LogManager.Instance.Info("[Settings] Temp files cleared");
SendNotification("", LocalizationProvider.Instance.clean_temp_files_succeeded, NotificationType.Success); SendNotification("", LocalizationProvider.Instance.clean_temp_files_succeeded, NotificationType.Success);
} }
else else
{ {
LogManager.Instance.Info("[Settings] Temp files failed to clear");
SendNotification("", LocalizationProvider.Instance.clean_temp_files_failed, NotificationType.Error); SendNotification("", LocalizationProvider.Instance.clean_temp_files_failed, NotificationType.Error);
} }
} }
public void RemoveRegistryKeysCommand() public void RemoveRegistryKeysCommand()
{ {
LogManager.Instance.Info("[Settings] Removing registry keys ...");
bool regKeysRemoved = gameStarter.RemoveRegistryKeys(); bool regKeysRemoved = gameStarter.RemoveRegistryKeys();
if (regKeysRemoved) if (regKeysRemoved)
{ {
LogManager.Instance.Info("[Settings] Registry keys removed");
SendNotification("", LocalizationProvider.Instance.remove_registry_keys_succeeded, Avalonia.Controls.Notifications.NotificationType.Success); SendNotification("", LocalizationProvider.Instance.remove_registry_keys_succeeded, Avalonia.Controls.Notifications.NotificationType.Success);
} }
else else
{ {
LogManager.Instance.Info("[Settings] Registry keys failed to remove");
SendNotification("", LocalizationProvider.Instance.remove_registry_keys_failed, Avalonia.Controls.Notifications.NotificationType.Error); SendNotification("", LocalizationProvider.Instance.remove_registry_keys_failed, Avalonia.Controls.Notifications.NotificationType.Error);
} }
} }
public async Task ResetGameSettingsCommand() public async Task ResetGameSettingsCommand()
{ {
LogManager.Instance.Info("[Settings] Reseting game settings ...");
string EFTSettingsFolder = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Battlestate Games", "Escape from Tarkov", "Settings"); string EFTSettingsFolder = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Battlestate Games", "Escape from Tarkov", "Settings");
string SPTSettingsFolder = Path.Join(LauncherSettingsProvider.Instance.GamePath, "user", "sptsettings"); string SPTSettingsFolder = Path.Join(LauncherSettingsProvider.Instance.GamePath, "user", "sptsettings");
if (!Directory.Exists(EFTSettingsFolder)) if (!Directory.Exists(EFTSettingsFolder))
{ {
LogManager.Instance.Warning($"EFT settings folder not found, can't reset :: Path: {EFTSettingsFolder}"); LogManager.Instance.Warning($"[Settings] EFT settings folder not found, can't reset :: Path: {EFTSettingsFolder}");
SendNotification("", LocalizationProvider.Instance.load_live_settings_failed, Avalonia.Controls.Notifications.NotificationType.Error); SendNotification("", LocalizationProvider.Instance.load_live_settings_failed, Avalonia.Controls.Notifications.NotificationType.Error);
return; return;
} }
@ -112,12 +181,14 @@ namespace SPT.Launcher.ViewModels
SendNotification("", LocalizationProvider.Instance.load_live_settings_failed, Avalonia.Controls.Notifications.NotificationType.Error); SendNotification("", LocalizationProvider.Instance.load_live_settings_failed, Avalonia.Controls.Notifications.NotificationType.Error);
return; return;
} }
LogManager.Instance.Info("[Settings] Game settings reset to live settings");
SendNotification("", LocalizationProvider.Instance.load_live_settings_succeeded, Avalonia.Controls.Notifications.NotificationType.Success); SendNotification("", LocalizationProvider.Instance.load_live_settings_succeeded, Avalonia.Controls.Notifications.NotificationType.Success);
} }
public async Task ClearGameSettingsCommand() public async Task ClearGameSettingsCommand()
{ {
LogManager.Instance.Info("[Settings] Clearing game settings ...");
var SPTSettingsDir = new DirectoryInfo(Path.Join(LauncherSettingsProvider.Instance.GamePath, "user", "sptsettings")); var SPTSettingsDir = new DirectoryInfo(Path.Join(LauncherSettingsProvider.Instance.GamePath, "user", "sptsettings"));
try try
@ -132,7 +203,8 @@ namespace SPT.Launcher.ViewModels
SendNotification("", LocalizationProvider.Instance.clear_game_settings_failed, Avalonia.Controls.Notifications.NotificationType.Error); SendNotification("", LocalizationProvider.Instance.clear_game_settings_failed, Avalonia.Controls.Notifications.NotificationType.Error);
return; return;
} }
LogManager.Instance.Info("[Settings] Game settings cleared");
SendNotification("", LocalizationProvider.Instance.clear_game_settings_succeeded, Avalonia.Controls.Notifications.NotificationType.Success); SendNotification("", LocalizationProvider.Instance.clear_game_settings_succeeded, Avalonia.Controls.Notifications.NotificationType.Success);
} }
@ -148,18 +220,22 @@ namespace SPT.Launcher.ViewModels
public async Task SelectGameFolderCommand() public async Task SelectGameFolderCommand()
{ {
OpenFolderDialog dialog = new OpenFolderDialog(); if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
dialog.Directory = Assembly.GetExecutingAssembly().Location;
if (Application.Current?.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktop)
{ {
string? result = await dialog.ShowAsync(desktop.MainWindow); var startPath = await desktop.MainWindow.StorageProvider.TryGetFolderFromPathAsync(Assembly.GetExecutingAssembly().Location);
if (result != null) var dir = await desktop.MainWindow.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions()
{ {
LauncherSettingsProvider.Instance.GamePath = result; Title = "Select your SPT folder",
SuggestedStartLocation = startPath
});
if (dir == null || dir.Count == 0)
{
return;
} }
LauncherSettingsProvider.Instance.GamePath = dir[0].Path.LocalPath;
} }
} }
} }

View File

@ -13,7 +13,7 @@
ProfileInfo="{Binding ProfileInfo}" ProfileInfo="{Binding ProfileInfo}"
CurrentEdition="{Binding CurrentEdition}" CurrentEdition="{Binding CurrentEdition}"
CurrentId="{Binding CurrentId}" CurrentId="{Binding CurrentId}"
WipeProfileOnStart="{Binding WipeProfileOnStart}" WipeProfileOnStart="{Binding WipeProfileOnStart, Mode=TwoWay}"
ProfileWipePending="{Binding ProfileWipePending}" ProfileWipePending="{Binding ProfileWipePending}"
CopyCommand="{Binding CopyCommand}" CopyCommand="{Binding CopyCommand}"
ChangeEditionCommand="{Binding ChangeEditionCommand}" ChangeEditionCommand="{Binding ChangeEditionCommand}"

View File

@ -12,29 +12,29 @@
<!-- Backdrop --> <!-- Backdrop -->
<Rectangle Fill="{DynamicResource BackgroundBrush}" <Rectangle Fill="{DynamicResource BackgroundBrush}"
Grid.RowSpan="7" Grid.ColumnSpan="5" Grid.RowSpan="8" Grid.ColumnSpan="5"
Opacity=".7" Opacity=".7"
/> />
<WrapPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Orientation="Horizontal"> <WrapPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Orientation="Horizontal">
<Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=remove_registry_keys}" <Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=remove_registry_keys}"
Command="{Binding RemoveRegistryKeysCommand}" Command="{Binding RemoveRegistryKeysCommand}"
Classes="outlined" Classes="outlined" Margin="0 0 10 5"
Margin="0 0 10 5"
/> />
<Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=load_live_settings}" <Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=load_live_settings}"
Command="{Binding ResetGameSettingsCommand}" Command="{Binding ResetGameSettingsCommand}"
Classes="outlined" Classes="outlined" Margin="0 0 10 5"
Margin="0 0 10 5"
/> />
<Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=clear_game_settings}" <Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=clear_game_settings}"
Command="{Binding ClearGameSettingsCommand}" Command="{Binding ClearGameSettingsCommand}"
Classes="outlined" Classes="outlined" Margin="0 0 10 5"
Margin="0 0 10 5"
/> />
<Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=clean_temp_files}" <Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=clean_temp_files}"
Command="{Binding CleanTempFilesCommand}" Command="{Binding CleanTempFilesCommand}"
Classes="outlined" Classes="outlined" Margin="0 0 10 5"
Margin="0 0 10 5" />
<Button Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=copy_logs_to_clipboard}"
Command="{Binding CopyLogsToClipboard}"
Classes="outlined" Margin="0 0 10 5"
/> />
</WrapPanel> </WrapPanel>
@ -68,9 +68,11 @@
<!-- Game Path --> <!-- Game Path -->
<StackPanel Grid.Row="5" Grid.Column="1" Margin="0 10 10 10" IsEnabled="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=IsDevMode}"> <StackPanel Grid.Row="5" Grid.Column="1" Margin="0 10 10 10" IsEnabled="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=IsDevMode}">
<Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=game_path}"/> <Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=game_path}"
/>
<TextBox Watermark="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=game_path}" <TextBox Watermark="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=game_path}"
Text="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=GamePath}" Text="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=GamePath}"
VerticalContentAlignment="Center"
/> />
</StackPanel> </StackPanel>
@ -101,6 +103,7 @@
<Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=url}"/> <Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=url}"/>
<TextBox Watermark="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=url}" <TextBox Watermark="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=url}"
Text="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=Server.Url}" Text="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=Server.Url}"
VerticalContentAlignment="Center"
/> />
</StackPanel> </StackPanel>