0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-12 17:10:44 -05:00

Merge pull request 'master' (#6) from SPT-AKI/Launcher:master into master

Reviewed-on: waffle.lord/Launcher#6
This commit is contained in:
IsWaffle 2023-09-30 18:55:25 +00:00
commit 5a13abf403
17 changed files with 128 additions and 38 deletions

View File

@ -19,7 +19,7 @@ git config --local user.email "USERNAME@SOMETHING.com"
## Requirements
- Escape From Tarkov 25837
- Escape From Tarkov 26215
- .NET 6 SDK
- Visual Studio Code

View File

@ -176,6 +176,7 @@ namespace Aki.Launcher.Helpers
englishLocale.server_mods = "Server Mods";
englishLocale.profile_mods = "Profile Mods";
englishLocale.author = "Author";
englishLocale.wipe_on_start = "Wipe profile on game start";
#endregion
Directory.CreateDirectory(LocalizationProvider.DefaultLocaleFolderPath);
@ -1605,6 +1606,22 @@ namespace Aki.Launcher.Helpers
#endregion
#region wipe_on_start
private string _wipe_on_start;
public string wipe_on_start
{
get => _wipe_on_start;
set
{
if (_wipe_on_start != value)
{
_wipe_on_start = value;
RaisePropertyChanged(nameof(wipe_on_start));
}
}
}
#endregion
#endregion
public event PropertyChangedEventHandler PropertyChanged;

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Autor",
"load_live_settings": "Wczytaj ustawienia EFT",
"load_live_settings_succeeded": "Ustawienia gry skopiowane z EFT",
"load_live_settings_failed": "Nie udało się skopiować ustawień EFT"
"load_live_settings_failed": "Nie udało się skopiować ustawień EFT",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Автор",
"load_live_settings": "Загрузить настройкий онлайн-версии",
"load_live_settings_succeeded": "Настройки игры скопированы из онлайн-версии",
"load_live_settings_failed": "Не удалось скопировать настройки онлайн-версии"
"load_live_settings_failed": "Не удалось скопировать настройки онлайн-версии",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -85,5 +85,6 @@
"author": "Author",
"load_live_settings": "Load Live Settings",
"load_live_settings_succeeded": "Game settings copied from live",
"load_live_settings_failed": "Failed to copy live settings"
"load_live_settings_failed": "Failed to copy live settings",
"wipe_on_start": "Wipe profile on game start"
}

View File

@ -8,6 +8,7 @@
<Button Content="Blah"/>
<TextBox Text="Some cool text here" Margin="5"/>
<TextBox Watermark="This is a watermark" Margin="5"/>
<CheckBox Content="This is a checkbox"/>
</StackPanel>
</Design.PreviewWith>
@ -297,6 +298,14 @@
<Setter Property="Foreground" Value="{StaticResource AKI_Foreground_Light}"/>
</Style>
<Style Selector="CheckBox /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{StaticResource AKI_Brush_DarkGrayBlue}"/>
</Style>
<Style Selector="CheckBox:pointerover /template/ Border#NormalRectangle">
<Setter Property="BorderBrush" Value="{StaticResource AKI_Brush_Yellow}"/>
</Style>
<Style Selector="CheckBox:pointerover /template/ ContentPresenter#ContentPresenter">
<Setter Property="TextBlock.Foreground" Value="{StaticResource AKI_Foreground_Light}" />
</Style>

View File

@ -34,6 +34,20 @@ namespace Aki.Launcher.ViewModels
set => this.RaiseAndSetIfChanged(ref _ModsListIsVisible, value);
}
private bool _WipeProfileOnStart;
public bool WipeProfileOnStart
{
get => _WipeProfileOnStart;
set => this.RaiseAndSetIfChanged(ref _WipeProfileOnStart, value);
}
private bool _ProfileWipePending;
public bool ProfileWipePending
{
get => _ProfileWipePending;
set => this.RaiseAndSetIfChanged(ref _ProfileWipePending, value);
}
public string CurrentID { get; set; }
public ProfileInfo ProfileInfo { get; set; } = AccountManager.SelectedProfileInfo;
@ -144,6 +158,19 @@ namespace Aki.Launcher.ViewModels
LauncherSettingsProvider.Instance.GameRunning = true;
if (WipeProfileOnStart)
{
var wipeStatus = await WipeProfile(AccountManager.SelectedAccount.edition);
if (wipeStatus != AccountStatus.OK)
{
LauncherSettingsProvider.Instance.GameRunning = false;
return;
}
WipeProfileOnStart = false;
}
GameStarterResult gameStartResult = await gameStarter.LaunchGame(ServerManager.SelectedServer, AccountManager.SelectedAccount, LauncherSettingsProvider.Instance.GamePath);
if (gameStartResult.Succeeded)
@ -171,33 +198,41 @@ namespace Aki.Launcher.ViewModels
}
}
private async Task<AccountStatus> WipeProfile(string edition)
{
AccountStatus status = await AccountManager.WipeAsync(edition);
switch (status)
{
case AccountStatus.OK:
{
ProfileWipePending = true;
CurrentEdition = AccountManager.SelectedAccount.edition;
SendNotification("", LocalizationProvider.Instance.account_updated);
break;
}
case AccountStatus.NoConnection:
{
NavigateTo(new ConnectServerViewModel(HostScreen));
break;
}
default:
{
SendNotification("", LocalizationProvider.Instance.edit_account_update_error);
break;
}
}
return status;
}
public async Task ChangeEditionCommand()
{
var result = await ShowDialog(new ChangeEditionDialogViewModel(null));
if(result != null && result is AkiEdition edition)
{
AccountStatus status = await AccountManager.WipeAsync(edition.Name);
switch (status)
{
case AccountStatus.OK:
{
CurrentEdition = AccountManager.SelectedAccount.edition;
SendNotification("", LocalizationProvider.Instance.account_updated);
break;
}
case AccountStatus.NoConnection:
{
NavigateTo(new ConnectServerViewModel(HostScreen));
break;
}
default:
{
SendNotification("", LocalizationProvider.Instance.edit_account_update_error);
break;
}
}
await WipeProfile(edition.Name);
}
}
@ -285,6 +320,7 @@ namespace Aki.Launcher.ViewModels
case LauncherAction.MinimizeAction:
{
ChangeWindowState(Avalonia.Controls.WindowState.Normal);
ProfileWipePending = false;
break;
}

View File

@ -19,13 +19,13 @@
<Border Grid.Row="1" Grid.Column="1" CornerRadius="5"
BorderBrush="{StaticResource AKI_Background_Dark}"
BorderThickness="5">
<Grid RowDefinitions="10,AUTO,AUTO,AUTO,10" ColumnDefinitions="10,AUTO,*,10"
<Grid RowDefinitions="10,AUTO,AUTO,AUTO,AUTO,10" ColumnDefinitions="10,AUTO,*,10"
Background="{StaticResource AKI_Background_Dark}"
>
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1">
<Label Content="{Binding CurrentUsername}" Margin="5 0"/>
<!--Grid.Row="1" Grid.Column="4"-->
<!-- profile name and version -->
<Label x:Name="akiVersion"
Background="Transparent"
ToolTip.Tip="{Binding ProfileInfo.MismatchMessage}"
@ -40,20 +40,37 @@
</StackPanel>
</Label>
</StackPanel>
<!-- delete profile button -->
<Button HorizontalAlignment="Right" Grid.Row="1" Grid.Column="2"
Classes="icon"
Command="{Binding RemoveProfileCommand}"
IsEnabled="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=!GameRunning}"
>
<Path Data="{StaticResource Delete}" Fill="IndianRed"/>
</Button>
<!-- profile id button -->
<Button Content="{Binding CurrentID}" Classes="link"
Grid.Row="2" Grid.Column="1"
Command="{Binding CopyCommand}"
CommandParameter="{Binding CurrentID}"/>
CommandParameter="{Binding CurrentID}"
/>
<!-- profile edition button -->
<Button Content="{Binding CurrentEdition}" Classes="link"
Grid.Row="3" Grid.Column="1"
Command="{Binding ChangeEditionCommand}"/>
Command="{Binding ChangeEditionCommand}"
IsEnabled="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=!GameRunning}"
/>
<!-- wipe profile checkbox -->
<CheckBox Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=wipe_on_start}"
Grid.Row="4" Grid.Column="1"
IsChecked="{Binding WipeProfileOnStart}"
IsEnabled="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=!GameRunning}"
IsVisible="{Binding !ProfileWipePending}"
/>
</Grid>
</Border>