mirror of
https://github.com/sp-tarkov/launcher.git
synced 2025-02-12 17:10:44 -05:00
add wipe profile on start checkbox
This commit is contained in:
parent
3efb90b3cb
commit
0b65346512
@ -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>
|
||||
|
@ -34,6 +34,13 @@ namespace Aki.Launcher.ViewModels
|
||||
set => this.RaiseAndSetIfChanged(ref _ModsListIsVisible, value);
|
||||
}
|
||||
|
||||
private bool _WipeProfileOnStart;
|
||||
public bool WipeProfileOnStart
|
||||
{
|
||||
get => _WipeProfileOnStart;
|
||||
set => this.RaiseAndSetIfChanged(ref _WipeProfileOnStart, value);
|
||||
}
|
||||
|
||||
public string CurrentID { get; set; }
|
||||
|
||||
public ProfileInfo ProfileInfo { get; set; } = AccountManager.SelectedProfileInfo;
|
||||
@ -144,6 +151,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 +191,40 @@ namespace Aki.Launcher.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<AccountStatus> WipeProfile(string edition)
|
||||
{
|
||||
AccountStatus status = await AccountManager.WipeAsync(edition);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,36 @@
|
||||
</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"
|
||||
/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user