diff --git a/project/SPT.Launcher.Base/Controllers/AccountManager.cs b/project/SPT.Launcher.Base/Controllers/AccountManager.cs
index 4b759fc..3e5a154 100644
--- a/project/SPT.Launcher.Base/Controllers/AccountManager.cs
+++ b/project/SPT.Launcher.Base/Controllers/AccountManager.cs
@@ -289,6 +289,7 @@ namespace SPT.Launcher
}
SelectedAccount.edition = edition;
+ SelectedAccount.wipe = true;
LogManager.Instance.Info($"Account Wiped: {data.username} -> {edition}");
return AccountStatus.OK;
}
diff --git a/project/SPT.Launcher.Base/Controllers/GameStarter.cs b/project/SPT.Launcher.Base/Controllers/GameStarter.cs
index 2dcf1a2..bcd0bcf 100644
--- a/project/SPT.Launcher.Base/Controllers/GameStarter.cs
+++ b/project/SPT.Launcher.Base/Controllers/GameStarter.cs
@@ -21,6 +21,7 @@ using SPT.Launcher.Controllers;
using SPT.Launcher.Interfaces;
using System.Runtime.InteropServices;
using SPT.Launcher.Models.SPT;
+using Newtonsoft.Json.Linq;
namespace SPT.Launcher
{
@@ -90,7 +91,7 @@ namespace SPT.Launcher
if (account.wipe)
{
LogManager.Instance.Info("[LaunchGame] Wipe profile requested");
- RemoveRegistryKeys();
+ RemoveProfileRegistryKeys(account.id);
CleanTempFiles();
}
@@ -288,27 +289,24 @@ namespace SPT.Launcher
}
///
- /// Remove the registry keys
+ /// Remove the SPT JSON-based registry keys associated with the given profile ID
///
- /// returns true if the keys were removed. returns false if an exception occured
- public bool RemoveRegistryKeys()
+ public void RemoveProfileRegistryKeys(string profileId)
{
- try
- {
- var key = Registry.CurrentUser.OpenSubKey(registrySettings, true);
+ var registryFile = new FileInfo(Path.Combine(Environment.CurrentDirectory, "user\\sptRegistry\\registry.json"));
- foreach (var value in key.GetValueNames())
- {
- key.DeleteValue(value);
- }
- }
- catch (Exception ex)
+ if (!registryFile.Exists)
{
- LogManager.Instance.Exception(ex);
- return false;
+ return;
}
- return true;
+ JObject registryData = JObject.Parse(File.ReadAllText(registryFile.FullName));
+
+ // Find any property that has a key containing the profileId, and remove it
+ var propsToRemove = registryData.Properties().Where(prop => prop.Name.Contains(profileId, StringComparison.CurrentCultureIgnoreCase)).ToList();
+ propsToRemove.ForEach(prop => prop.Remove());
+
+ File.WriteAllText(registryFile.FullName, registryData.ToString());
}
///
diff --git a/project/SPT.Launcher/ViewModels/SettingsViewModel.cs b/project/SPT.Launcher/ViewModels/SettingsViewModel.cs
index 928bb49..b31eea6 100644
--- a/project/SPT.Launcher/ViewModels/SettingsViewModel.cs
+++ b/project/SPT.Launcher/ViewModels/SettingsViewModel.cs
@@ -151,23 +151,6 @@ namespace SPT.Launcher.ViewModels
}
}
- public void RemoveRegistryKeysCommand()
- {
- LogManager.Instance.Info("[Settings] Removing registry keys ...");
- bool regKeysRemoved = gameStarter.RemoveRegistryKeys();
-
- if (regKeysRemoved)
- {
- LogManager.Instance.Info("[Settings] Registry keys removed");
- SendNotification("", LocalizationProvider.Instance.remove_registry_keys_succeeded, Avalonia.Controls.Notifications.NotificationType.Success);
- }
- else
- {
- LogManager.Instance.Info("[Settings] Registry keys failed to remove");
- SendNotification("", LocalizationProvider.Instance.remove_registry_keys_failed, Avalonia.Controls.Notifications.NotificationType.Error);
- }
- }
-
public async Task ResetGameSettingsCommand()
{
LogManager.Instance.Info("[Settings] Reseting game settings ...");
diff --git a/project/SPT.Launcher/Views/SettingsView.axaml b/project/SPT.Launcher/Views/SettingsView.axaml
index a8fe6cc..0cde6ce 100644
--- a/project/SPT.Launcher/Views/SettingsView.axaml
+++ b/project/SPT.Launcher/Views/SettingsView.axaml
@@ -16,10 +16,6 @@
Opacity=".7"
/>
-