mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-20 09:31:29 -07:00
- Features - Added integration with rbxfpsunlocker - Added support for user-applicable mods - Added ability to disable auto-update checking - Misc - Removed Bloxstrap branding from Discord Rich Presence - Mod presets for old death sound and mouse cursor are now statically stored as base64 strings, eliminating reliance on the website and the old cursors still existing - Bugfixes - Fixed vista bootstrapper style not hiding properly and improper behavior when closed - Fixed forms not being brought to the front when shown - Code - Reconsolidated Bootstrapper to a single file, using regions instead of partials
95 lines
2.7 KiB
C#
95 lines
2.7 KiB
C#
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Text.Json;
|
|
|
|
using Bloxstrap.Enums;
|
|
|
|
namespace Bloxstrap
|
|
{
|
|
public class SettingsFormat
|
|
{
|
|
public string VersionGuid { get; set; }
|
|
|
|
public bool CheckForUpdates { get; set; } = true;
|
|
|
|
public BootstrapperStyle BootstrapperStyle { get; set; } = BootstrapperStyle.ProgressDialog;
|
|
public BootstrapperIcon BootstrapperIcon { get; set; } = BootstrapperIcon.IconBloxstrap;
|
|
|
|
public bool UseDiscordRichPresence { get; set; } = true;
|
|
public bool HideRPCButtons { get; set; } = false;
|
|
public bool RFUEnabled { get; set; } = false;
|
|
public bool RFUAutoclose { get; set; } = false;
|
|
|
|
public bool UseOldDeathSound { get; set; } = true;
|
|
public bool UseOldMouseCursor { get; set; } = false;
|
|
}
|
|
|
|
public class SettingsManager
|
|
{
|
|
public SettingsFormat Settings = new();
|
|
public bool ShouldSave = false;
|
|
private bool IsSaving = false;
|
|
|
|
private string _saveLocation;
|
|
public string SaveLocation
|
|
{
|
|
get => _saveLocation;
|
|
|
|
set
|
|
{
|
|
if (!String.IsNullOrEmpty(_saveLocation))
|
|
return;
|
|
|
|
_saveLocation = value;
|
|
|
|
string settingsJson = "";
|
|
|
|
if (File.Exists(_saveLocation))
|
|
settingsJson = File.ReadAllText(_saveLocation);
|
|
|
|
Debug.WriteLine(settingsJson);
|
|
|
|
try
|
|
{
|
|
Settings = JsonSerializer.Deserialize<SettingsFormat>(settingsJson);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine($"Failed to fetch settings! Reverting to defaults... ({ex.Message})");
|
|
// Settings = new();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
if (IsSaving)
|
|
{
|
|
// sometimes Save() is called at the same time from both Main() and Exit(),
|
|
// so this is here to avoid the program exiting before saving
|
|
|
|
Thread.Sleep(1000);
|
|
return;
|
|
}
|
|
|
|
IsSaving = true;
|
|
|
|
Debug.WriteLine("Attempting to save...");
|
|
|
|
string SettingsJson = JsonSerializer.Serialize(Settings, new JsonSerializerOptions { WriteIndented = true });
|
|
Debug.WriteLine(SettingsJson);
|
|
|
|
if (!ShouldSave)
|
|
{
|
|
Debug.WriteLine("ShouldSave set to false, not saving...");
|
|
return;
|
|
}
|
|
|
|
// save settings
|
|
File.WriteAllText(SaveLocation, SettingsJson);
|
|
|
|
IsSaving = false;
|
|
}
|
|
}
|
|
}
|