Luski/Luski/Classes/Settings.cs
JacobTech ab73abc7c7 Menu Mayhem & Rendering Revelations 🎨
Killed it! The new menus and rendering won't crash... probably.
2024-08-22 11:14:33 -04:00

151 lines
4.9 KiB
C#

using System.ComponentModel;
using System.Text.Json.Serialization;
using GraphicsManager.Objects;
namespace Luski.Classes;
public class Settings
{
[JsonInclude]
[JsonPropertyName("scale")]
public double? Scale { get; set; } = null;
[JsonInclude]
[JsonPropertyName("perscrollpixels")]
public uint PerScrollPixels { get; set; } = 20;
[JsonInclude]
[JsonPropertyName("multithreadpercent")]
public uint MultiThreadPercent { get; set; } = 50;
[JsonInclude]
[JsonPropertyName("loadperchannel")]
public int LoadPerChannel { get; set; } = 50;
[JsonInclude]
[JsonPropertyName("theme")]
public string Theme { get; set; } = "Dark";
[JsonInclude]
[JsonPropertyName("experiments")]
public List<ExperimentJson> Experiments { get; set; } = Array.Empty<ExperimentJson>().ToList();
[JsonInclude]
[JsonPropertyName("default_display")]
public int Display { get; set; } = 0;
/// <summary>
/// Sets the log value for the console. Default value of -25 to enable all logs by default except for DrawFrames and InfoOpenGL even if new ones are added.
/// </summary>
[JsonInclude]
[Shared.GlobalAttributes.DisplayName("Console Logs")]
[Description("The Log values for the console")]
[JsonPropertyName("log")]
public ConsoleLog Logs
{
get
{
return _Logs;
}
set
{
_Logs = value;
if (Globals.ms is not null)
{
Globals.ms.LogFrames = (_Logs & ConsoleLog.DrawFrames) == ConsoleLog.DrawFrames;
Globals.ms.ShowMissingChar = (_Logs & ConsoleLog.ShowMissingChar) == ConsoleLog.ShowMissingChar;
}
}
}
[JsonInclude]
[Shared.GlobalAttributes.DisplayName("Scale Fonts")]
[Description("Scales fonts using the scale property")]
[JsonPropertyName("scale_fonts")]
public bool ScaleFonts
{
get
{
return _ScaleFonts;
}
set
{
_ScaleFonts = value;
if (Globals.ms is not null)
{
Globals.DefaultFont.PixelHeight = Globals.Settings.DefaultFontPX.ScaleFont();
Globals.MessageFont.PixelHeight = Globals.Settings.MessageFontPX.ScaleFont();
Globals.TopTimeFont.PixelHeight = Globals.Settings.TopTimeFontPX.ScaleFont();
Globals.SmallTimeFont.PixelHeight = ((uint)11).ScaleFont();
Label._characters[Globals.ms.Context][Globals.DefaultFont].Clear();
Label._characters[Globals.ms.Context][Globals.MessageFont].Clear();
Label._characters[Globals.ms.Context][Globals.TopTimeFont].Clear();
Label._characters[Globals.ms.Context][Globals.SmallTimeFont].Clear();
Globals.ms.ForceUpdate();
Globals.ms.DrawFrame();
}
}
}
[JsonInclude]
[JsonPropertyName("default_font_px")]
public uint DefaultFontPX { get; set; } = 20;
[JsonInclude]
[JsonPropertyName("top_time_font_px")]
public uint TopTimeFontPX { get; set; } = 12;
[JsonInclude]
[JsonPropertyName("role_settings_font_px")]
public uint RoleSettingsFontPX { get; set; } = 14;
[JsonInclude]
[JsonPropertyName("message_font_px")]
public uint MessageFontPX { get; set; } = 17;
[JsonInclude]
[JsonPropertyName("message_font_line_space_px")]
public uint MessageFontLineSpacePX { get; set; } = 5;
[JsonInclude]
[Shared.GlobalAttributes.DisplayName("24 Hour Time")]
[Description("Shows time in the 24 hour format")]
[JsonPropertyName("24hour_time")]
public bool DayTime
{
get
{
return _DayTime;
}
set
{
_DayTime = value;
if (DayTimeChanged is not null) DayTimeChanged.Invoke();
}
}
[JsonInclude]
[Shared.GlobalAttributes.DisplayName("Memory Fonts")]
[Description("Stores fonts in memory for faster load times")]
[JsonPropertyName("memory_fonts")]
public bool StoreFontsInMemory
{
get
{
return _MemoryFonts;
}
set
{
_MemoryFonts = value;
//GraphicsManager.Objects.Core.FontFamily.MemoryFont = value;
//if (DayTimeChanged is not null) DayTimeChanged.Invoke();
}
}
[JsonIgnore]
private bool _ScaleFonts = true;
[JsonIgnore]
private ConsoleLog _Logs = (ConsoleLog)(-25);
[JsonIgnore]
private bool _DayTime = false;
[JsonIgnore]
private bool _MemoryFonts= false;
public event Func<Task>? DayTimeChanged;
}
[JsonSerializable(typeof(Settings))]
[JsonSourceGenerationOptions(
GenerationMode = JsonSourceGenerationMode.Default,
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = true,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
internal partial class SettingsContext : JsonSerializerContext;