mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Alert user on failure to load settings/flags
This commit is contained in:
parent
cab047d7a9
commit
f1246e1a2d
@ -214,7 +214,6 @@ namespace Bloxstrap
|
|||||||
if (_installWebView2)
|
if (_installWebView2)
|
||||||
await InstallWebView2();
|
await InstallWebView2();
|
||||||
|
|
||||||
App.FastFlags.Save();
|
|
||||||
await ApplyModifications();
|
await ApplyModifications();
|
||||||
|
|
||||||
// TODO: move this to install/upgrade flow
|
// TODO: move this to install/upgrade flow
|
||||||
@ -224,7 +223,6 @@ namespace Bloxstrap
|
|||||||
CheckInstall();
|
CheckInstall();
|
||||||
|
|
||||||
// at this point we've finished updating our configs
|
// at this point we've finished updating our configs
|
||||||
App.Settings.Save();
|
|
||||||
App.State.Save();
|
App.State.Save();
|
||||||
|
|
||||||
await mutex.ReleaseAsync();
|
await mutex.ReleaseAsync();
|
||||||
@ -777,6 +775,8 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
public static void MigrateIntegrations()
|
public static void MigrateIntegrations()
|
||||||
{
|
{
|
||||||
|
// TODO: move this to the installer logic
|
||||||
|
|
||||||
// v2.2.0 - remove rbxfpsunlocker
|
// v2.2.0 - remove rbxfpsunlocker
|
||||||
string rbxfpsunlocker = Path.Combine(Paths.Integrations, "rbxfpsunlocker");
|
string rbxfpsunlocker = Path.Combine(Paths.Integrations, "rbxfpsunlocker");
|
||||||
|
|
||||||
|
@ -4,6 +4,10 @@ namespace Bloxstrap
|
|||||||
{
|
{
|
||||||
public class FastFlagManager : JsonManager<Dictionary<string, object>>
|
public class FastFlagManager : JsonManager<Dictionary<string, object>>
|
||||||
{
|
{
|
||||||
|
public override string ClassName => nameof(FastFlagManager);
|
||||||
|
|
||||||
|
public override string LOG_IDENT_CLASS => ClassName;
|
||||||
|
|
||||||
public override string FileLocation => Path.Combine(Paths.Modifications, "ClientSettings\\ClientAppSettings.json");
|
public override string FileLocation => Path.Combine(Paths.Modifications, "ClientSettings\\ClientAppSettings.json");
|
||||||
|
|
||||||
public bool Changed => !OriginalProp.SequenceEqual(Prop);
|
public bool Changed => !OriginalProp.SequenceEqual(Prop);
|
||||||
@ -238,9 +242,9 @@ namespace Bloxstrap
|
|||||||
OriginalProp = new(Prop);
|
OriginalProp = new(Prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Load()
|
public override void Load(bool alertFailure = true)
|
||||||
{
|
{
|
||||||
base.Load();
|
base.Load(alertFailure);
|
||||||
|
|
||||||
// clone the dictionary
|
// clone the dictionary
|
||||||
OriginalProp = new(Prop);
|
OriginalProp = new(Prop);
|
||||||
@ -249,6 +253,7 @@ namespace Bloxstrap
|
|||||||
if (GetPreset("Network.Log") != "7")
|
if (GetPreset("Network.Log") != "7")
|
||||||
SetPreset("Network.Log", "7");
|
SetPreset("Network.Log", "7");
|
||||||
|
|
||||||
|
// TODO - this should be moved to the installer update logic
|
||||||
string? val = GetPreset("UI.Menu.Style.EnableV4.1");
|
string? val = GetPreset("UI.Menu.Style.EnableV4.1");
|
||||||
if (GetPreset("UI.Menu.Style.EnableV4.2") != val)
|
if (GetPreset("UI.Menu.Style.EnableV4.2") != val)
|
||||||
SetPreset("UI.Menu.Style.EnableV4.2", val);
|
SetPreset("UI.Menu.Style.EnableV4.2", val);
|
||||||
|
@ -11,6 +11,8 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
public string InstallLocation = Path.Combine(Paths.LocalAppData, "Bloxstrap");
|
public string InstallLocation = Path.Combine(Paths.LocalAppData, "Bloxstrap");
|
||||||
|
|
||||||
|
public bool ExistingDataPresent => File.Exists(Path.Combine(InstallLocation, "Settings.json"));
|
||||||
|
|
||||||
public bool CreateDesktopShortcuts = true;
|
public bool CreateDesktopShortcuts = true;
|
||||||
|
|
||||||
public bool CreateStartMenuShortcuts = true;
|
public bool CreateStartMenuShortcuts = true;
|
||||||
@ -21,6 +23,10 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
public void DoInstall()
|
public void DoInstall()
|
||||||
{
|
{
|
||||||
|
const string LOG_IDENT = "Installer::DoInstall";
|
||||||
|
|
||||||
|
App.Logger.WriteLine(LOG_IDENT, "Beginning installation");
|
||||||
|
|
||||||
// should've been created earlier from the write test anyway
|
// should've been created earlier from the write test anyway
|
||||||
Directory.CreateDirectory(InstallLocation);
|
Directory.CreateDirectory(InstallLocation);
|
||||||
|
|
||||||
@ -69,9 +75,11 @@ namespace Bloxstrap
|
|||||||
Shortcut.Create(Paths.Application, "", StartMenuShortcut);
|
Shortcut.Create(Paths.Application, "", StartMenuShortcut);
|
||||||
|
|
||||||
// existing configuration persisting from an earlier install
|
// existing configuration persisting from an earlier install
|
||||||
App.Settings.Load();
|
App.Settings.Load(false);
|
||||||
App.State.Load();
|
App.State.Load(false);
|
||||||
App.FastFlags.Load();
|
App.FastFlags.Load(false);
|
||||||
|
|
||||||
|
App.Logger.WriteLine(LOG_IDENT, "Installation finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ValidateLocation()
|
private bool ValidateLocation()
|
||||||
|
@ -8,11 +8,13 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
public T Prop { get; set; } = new();
|
public T Prop { get; set; } = new();
|
||||||
|
|
||||||
public virtual string FileLocation => Path.Combine(Paths.Base, $"{typeof(T).Name}.json");
|
public virtual string ClassName => typeof(T).Name;
|
||||||
|
|
||||||
private string LOG_IDENT_CLASS => $"JsonManager<{typeof(T).Name}>";
|
public virtual string FileLocation => Path.Combine(Paths.Base, $"{ClassName}.json");
|
||||||
|
|
||||||
public virtual void Load()
|
public virtual string LOG_IDENT_CLASS => $"JsonManager<{ClassName}>";
|
||||||
|
|
||||||
|
public virtual void Load(bool alertFailure = true)
|
||||||
{
|
{
|
||||||
string LOG_IDENT = $"{LOG_IDENT_CLASS}::Load";
|
string LOG_IDENT = $"{LOG_IDENT_CLASS}::Load";
|
||||||
|
|
||||||
@ -32,7 +34,22 @@ namespace Bloxstrap
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine(LOG_IDENT, "Failed to load!");
|
App.Logger.WriteLine(LOG_IDENT, "Failed to load!");
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"{ex.Message}");
|
App.Logger.WriteException(LOG_IDENT, ex);
|
||||||
|
|
||||||
|
if (alertFailure)
|
||||||
|
{
|
||||||
|
string message = "";
|
||||||
|
|
||||||
|
if (ClassName == nameof(Settings))
|
||||||
|
message = Strings.JsonManager_SettingsLoadFailed;
|
||||||
|
else if (ClassName == nameof(FastFlagManager))
|
||||||
|
message = Strings.JsonManager_FastFlagsLoadFailed;
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(message))
|
||||||
|
Frontend.ShowMessageBox($"{message}\n\n{ex.GetType()}: {ex.Message}", System.Windows.MessageBoxImage.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
Bloxstrap/Resources/Strings.Designer.cs
generated
18
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -1495,6 +1495,24 @@ namespace Bloxstrap.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Your Fast Flags could not be loaded. They have been reset to the default configuration..
|
||||||
|
/// </summary>
|
||||||
|
public static string JsonManager_FastFlagsLoadFailed {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("JsonManager.FastFlagsLoadFailed", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Your Settings could not be loaded. They have been reset to the default configuration..
|
||||||
|
/// </summary>
|
||||||
|
public static string JsonManager_SettingsLoadFailed {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("JsonManager.SettingsLoadFailed", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Configure settings.
|
/// Looks up a localized string similar to Configure settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1162,4 +1162,10 @@ Are you sure you want to continue?</value>
|
|||||||
<data name="About.Supporters.Description" xml:space="preserve">
|
<data name="About.Supporters.Description" xml:space="preserve">
|
||||||
<value>These are the people currently supporting Bloxstrap through [Ko-fi]({0}). A massive thank you to everyone here!</value>
|
<value>These are the people currently supporting Bloxstrap through [Ko-fi]({0}). A massive thank you to everyone here!</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="JsonManager.SettingsLoadFailed" xml:space="preserve">
|
||||||
|
<value>Your Settings could not be loaded. They have been reset to the default configuration.</value>
|
||||||
|
</data>
|
||||||
|
<data name="JsonManager.FastFlagsLoadFailed" xml:space="preserve">
|
||||||
|
<value>Your Fast Flags could not be loaded. They have been reset to the default configuration.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -32,11 +32,11 @@ namespace Bloxstrap.UI.ViewModels.Installer
|
|||||||
}
|
}
|
||||||
|
|
||||||
installer.InstallLocation = value;
|
installer.InstallLocation = value;
|
||||||
CheckExistingData();
|
OnPropertyChanged(nameof(DataFoundMessageVisibility));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Visibility DataFoundMessageVisibility { get; set; } = Visibility.Collapsed;
|
public Visibility DataFoundMessageVisibility => installer.ExistingDataPresent ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
|
||||||
public string ErrorMessage => installer.InstallLocationError;
|
public string ErrorMessage => installer.InstallLocationError;
|
||||||
|
|
||||||
@ -61,7 +61,6 @@ namespace Bloxstrap.UI.ViewModels.Installer
|
|||||||
public InstallViewModel()
|
public InstallViewModel()
|
||||||
{
|
{
|
||||||
_originalInstallLocation = installer.InstallLocation;
|
_originalInstallLocation = installer.InstallLocation;
|
||||||
CheckExistingData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DoInstall()
|
public bool DoInstall()
|
||||||
@ -79,16 +78,6 @@ namespace Bloxstrap.UI.ViewModels.Installer
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckExistingData()
|
|
||||||
{
|
|
||||||
if (File.Exists(Path.Combine(InstallLocation, "Settings.json")))
|
|
||||||
DataFoundMessageVisibility = Visibility.Visible;
|
|
||||||
else
|
|
||||||
DataFoundMessageVisibility = Visibility.Collapsed;
|
|
||||||
|
|
||||||
OnPropertyChanged(nameof(DataFoundMessageVisibility));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BrowseInstallLocation()
|
private void BrowseInstallLocation()
|
||||||
{
|
{
|
||||||
using var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
using var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||||
|
Loading…
Reference in New Issue
Block a user