Merge pull request 'I did too much.' (#20) from dev into main
Reviewed-on: #20
This commit is contained in:
commit
842282d2a8
@ -35,7 +35,7 @@ public static class LuskiThemes
|
||||
Description = "A light theme for the insane.",
|
||||
GlobalServerTemplate = new()
|
||||
{
|
||||
SelectionColor = new("000000")
|
||||
SelectionColor = new("00000000")
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,8 @@ public class Settings
|
||||
/// 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]
|
||||
[Description("Console Logs")]
|
||||
[Shared.GlobalAttributes.DisplayName("Console Logs")]
|
||||
[Description("The Log values for the console")]
|
||||
[JsonPropertyName("log")]
|
||||
public ConsoleLog Logs
|
||||
{
|
||||
@ -51,7 +52,8 @@ public class Settings
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[Description("Scale Fonts")]
|
||||
[Shared.GlobalAttributes.DisplayName("Scale Fonts")]
|
||||
[Description("Scales fonts using the scale property")]
|
||||
[JsonPropertyName("scale_fonts")]
|
||||
public bool ScaleFonts
|
||||
{
|
||||
@ -66,7 +68,7 @@ public class Settings
|
||||
{
|
||||
Globals.DefaultFont.PixelHeight = Globals.Settings.DefaultFontPX.ScaleFont();
|
||||
Globals.MessageFont.PixelHeight = Globals.Settings.MessageFontPX.ScaleFont();
|
||||
Globals.TopTimeFont.PixelHeight = Globals.Settings.TopTimeFonttPX.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();
|
||||
@ -83,7 +85,10 @@ public class Settings
|
||||
public uint DefaultFontPX { get; set; } = 20;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("top_time_font_px")]
|
||||
public uint TopTimeFonttPX { get; set; } = 12;
|
||||
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;
|
||||
@ -92,7 +97,8 @@ public class Settings
|
||||
public uint MessageFontLineSpacePX { get; set; } = 5;
|
||||
|
||||
[JsonInclude]
|
||||
[Description("24 Hour Time")]
|
||||
[Shared.GlobalAttributes.DisplayName("24 Hour Time")]
|
||||
[Description("shows time in the 24 hour format")]
|
||||
[JsonPropertyName("24hour_time")]
|
||||
public bool DayTime
|
||||
{
|
||||
@ -114,7 +120,6 @@ public class Settings
|
||||
[JsonIgnore]
|
||||
private bool _DayTime = false;
|
||||
public event Func<Task>? DayTimeChanged;
|
||||
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(Settings))]
|
||||
@ -123,7 +128,4 @@ public class Settings
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
|
||||
WriteIndented = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
|
||||
internal partial class SettingsContext : JsonSerializerContext
|
||||
{
|
||||
|
||||
}
|
||||
internal partial class SettingsContext : JsonSerializerContext;
|
@ -7,5 +7,5 @@ public class ServerThemeProperties
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("selection_color")]
|
||||
public Color SelectionColor { get; set; } = new("FFFFFF");
|
||||
public Color SelectionColor { get; set; } = new("FFFFFFFF");
|
||||
}
|
@ -7,7 +7,8 @@ namespace Luski.Classes;
|
||||
public class UpdaterSettings
|
||||
{
|
||||
[JsonInclude]
|
||||
[Description("Self Contained")]
|
||||
[Shared.GlobalAttributes.DisplayName("Self Contained")]
|
||||
[Description("This tells the updater to download the self contained version of the app.")]
|
||||
[JsonPropertyName("self_contained")]
|
||||
public bool SelfContained { get; set; } = false;
|
||||
|
||||
@ -20,16 +21,19 @@ public class UpdaterSettings
|
||||
public string Platform { get; set; } = "linux-x64";
|
||||
|
||||
[JsonInclude]
|
||||
[Description("Auto Launch")]
|
||||
[Shared.GlobalAttributes.DisplayName("Auto Launch")]
|
||||
[Description("Tells the updater to relaunch the app after the update is complete.")]
|
||||
[JsonPropertyName("auto_launch")]
|
||||
public bool AutoLaunch { get; set; } = true;
|
||||
[JsonInclude]
|
||||
[Description("Auto Update")]
|
||||
[Description("If the app can check for updates and an update is available, then the app will start the update process automatically.")]
|
||||
[Shared.GlobalAttributes.DisplayName("Auto Update")]
|
||||
[JsonPropertyName("auto_update")]
|
||||
public bool AutoUpdate { get; set; } = false;
|
||||
|
||||
[JsonInclude]
|
||||
[Description("Check For Updates")]
|
||||
[Description("This will allow the client to check for update during the launch process.")]
|
||||
[Shared.GlobalAttributes.DisplayName("Check For Updates")]
|
||||
[JsonPropertyName("update_check")]
|
||||
public bool AutoUpdateCheck { get; set; } = true;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using Luski.Shared.GlobalAttributes;
|
||||
|
||||
namespace Luski;
|
||||
|
||||
@ -6,16 +7,25 @@ namespace Luski;
|
||||
public enum ConsoleLog : long
|
||||
{
|
||||
None = 0,
|
||||
[Shared.GlobalAttributes.DisplayName("OpenGL Errors")]
|
||||
[Description("Show OpenGL Major Errors")]
|
||||
BigErrosForOpenGL = 1,
|
||||
[Shared.GlobalAttributes.DisplayName("OpenGL Medium Errors")]
|
||||
[Description("Show OpenGL Medium Errors")]
|
||||
MediumErrosForOpenGL = 2,
|
||||
[Shared.GlobalAttributes.DisplayName("OpenGL Small Errors")]
|
||||
[Description("Show OpenGL Small Errors")]
|
||||
LowErrosForOpenGL = 4,
|
||||
[Shared.GlobalAttributes.DisplayName("OpenGL Info")]
|
||||
[Description("Show OpenGL Info")]
|
||||
InfoForOpenGL = 8,
|
||||
[Description("Show Draw Frams")]
|
||||
[Shared.GlobalAttributes.DisplayName("Log Frames")]
|
||||
[Description("Shows draw fram message in the console")]
|
||||
DrawFrames = 16,
|
||||
[Shared.GlobalAttributes.DisplayName("Show Missing Charters")]
|
||||
[Description("Show Missing Charters")]
|
||||
ShowMissingChar = 32
|
||||
ShowMissingChar = 32,
|
||||
[Shared.GlobalAttributes.DisplayName("GLFW Errors")]
|
||||
[Description("Show GLFW Errors")]
|
||||
ShowErrorsForGLFW = 64
|
||||
}
|
@ -66,54 +66,50 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
AllowMultiLine = false
|
||||
};
|
||||
tb.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
tb.KeyPress += args =>
|
||||
tb.LetterPress += () =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete) && string.IsNullOrWhiteSpace(tb.Text))
|
||||
|
||||
if (tb.Textures[0].handel != good.handel)
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (tb.Textures[0].handel != t.handel)
|
||||
{
|
||||
tb.Textures[0] = t;
|
||||
if (t.handel == good.handel &&
|
||||
UserName!.Textures[0].handel == good.handel &&
|
||||
tb.Textures[0] = good;
|
||||
if (UserName!.Textures[0].handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel &&
|
||||
(rec is null || rec.Textures.Count > 1) &&
|
||||
btn!.Textures[0].handel != good.handel &&
|
||||
tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
if (Selected!.l.Text != "Login")
|
||||
{
|
||||
if (DisplayName!.Textures[0].handel == good.handel) btn.Textures[0] = good;
|
||||
}
|
||||
else btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel &&
|
||||
(UserName!.Textures[0].handel != good.handel ||
|
||||
Password!.Textures[0].handel != good.handel ||
|
||||
(rec is not null && rec!.Textures.Count == 1) ||
|
||||
btn!.Textures[0].handel == good.handel ||
|
||||
tb.Textures[0].handel != good.handel ||
|
||||
(DisplayName is not null && DisplayName.Textures[0].handel != good.handel)))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
tb.LetterRemoved += () =>
|
||||
{
|
||||
Texture bad = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
|
||||
if (tb.Text.Length == 0 && tb.Textures[0].handel != bad.handel)
|
||||
{
|
||||
tb.Textures[0] = bad;
|
||||
btn!.Textures[0] = bad;
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
tb.KeyPress += args =>
|
||||
{
|
||||
if (args.Key == Keys.Tab && !args.Shift)
|
||||
{
|
||||
UserName!.Focus();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
tb.Size = new(Form.Size.X - tb.Location.X - tb.Location.X - tb.Location.X - s.X, tb.Size.Y);
|
||||
|
||||
Form.Controls.Add(tb);
|
||||
|
||||
version = new DropDown<VersionDropButton>(Form.Textures[0], line)
|
||||
{
|
||||
DropDownParentOverride = Form,
|
||||
@ -190,7 +186,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
Location = new(tb.Location.X, tb.Location.Y + tb.Location.X + tb.Size.Y, 0),
|
||||
OnPageLoad = () =>
|
||||
{
|
||||
btn.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
btn!.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
page!.Controls.Add(UserName = new()
|
||||
{
|
||||
Location = new(0, 10.ScaleInt(), 0),
|
||||
@ -200,41 +196,47 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
AllowMultiLine = false
|
||||
});
|
||||
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
UserName.KeyPress += args =>
|
||||
UserName.LetterPress += () =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) && string.IsNullOrWhiteSpace(UserName.Text))
|
||||
|
||||
if (UserName.Textures[0].handel != good.handel)
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (UserName.Textures[0].handel != t.handel)
|
||||
{
|
||||
UserName.Textures[0] = t;
|
||||
if (t.handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel &&
|
||||
DisplayName!.Textures[0].handel == good.handel &&
|
||||
rec!.Textures.Count > 1 &&
|
||||
btn!.Textures[0].handel != good.handel &&
|
||||
tb.Textures[0].handel == good.handel)
|
||||
UserName.Textures[0] = good;
|
||||
if (Password!.Textures[0].handel == good.handel && DisplayName!.Textures[0].handel == good.handel && rec!.Textures.Count > 1 && btn!.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel &&
|
||||
(Password!.Textures[0].handel != good.handel ||
|
||||
DisplayName!.Textures[0].handel != good.handel ||
|
||||
rec!.Textures.Count == 1 ||
|
||||
btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
UserName.LetterRemoved += () =>
|
||||
{
|
||||
Texture bad = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
|
||||
if (UserName.Text.Length == 0 && UserName.Textures[0].handel != bad.handel)
|
||||
{
|
||||
UserName.Textures[0] = bad;
|
||||
btn.Textures[0] = bad;
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
UserName.KeyPress += args =>
|
||||
{
|
||||
if (args.Key == Keys.Tab)
|
||||
{
|
||||
if (args.Shift)
|
||||
{
|
||||
tb.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Password!.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
@ -249,36 +251,50 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
PasswordChar = '●'
|
||||
});
|
||||
Password.Textures[0] = UserName.Textures[0];
|
||||
Password.KeyPress += args =>
|
||||
Password.LetterPress += () =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) && string.IsNullOrWhiteSpace(Password.Text))
|
||||
|
||||
if (Password.Textures[0].handel != good.handel)
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (Password.Textures[0].handel != t.handel)
|
||||
{
|
||||
Password.Textures[0] = t;
|
||||
if (t.handel == good.handel && UserName!.Textures[0].handel == good.handel && DisplayName!.Textures[0].handel == good.handel && rec!.Textures.Count > 1 && btn!.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
Password.Textures[0] = good;
|
||||
if (UserName!.Textures[0].handel == good.handel && DisplayName!.Textures[0].handel == good.handel && rec!.Textures.Count > 1 && btn!.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel && (UserName!.Textures[0].handel != good.handel || DisplayName!.Textures[0].handel != good.handel || rec!.Textures.Count == 1 || btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
Password.LetterRemoved += () =>
|
||||
{
|
||||
Texture bad = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
|
||||
if (Password.Text.Length == 0 && Password.Textures[0].handel != bad.handel)
|
||||
{
|
||||
Password.Textures[0] = bad;
|
||||
btn.Textures[0] = bad;
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
Password.KeyPress += args =>
|
||||
{
|
||||
if (args.Key == Keys.Tab)
|
||||
{
|
||||
if (args.Shift)
|
||||
{
|
||||
UserName.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayName!.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
page.Controls.Add(rec = new(Globals.ms.TextureManager.GetAlphaCircle())
|
||||
{
|
||||
Size = new(50.ScaleInt()),
|
||||
@ -296,44 +312,47 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
TextLocation = TextLocation.LineCenter,
|
||||
AllowMultiLine = false
|
||||
});
|
||||
DisplayName.KeyPress += args =>
|
||||
DisplayName.LetterPress += () =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) &&
|
||||
string.IsNullOrWhiteSpace(UserName.Text))
|
||||
|
||||
if (DisplayName.Textures[0].handel != good.handel)
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (DisplayName.Textures[0].handel != t.handel)
|
||||
{
|
||||
DisplayName.Textures[0] = t;
|
||||
if (t.handel == good.handel && UserName!.Textures[0].handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel && rec!.Textures.Count > 1 &&
|
||||
btn!.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
DisplayName.Textures[0] = good;
|
||||
if (UserName!.Textures[0].handel == good.handel && Password!.Textures[0].handel == good.handel && rec!.Textures.Count > 1 && btn!.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel && (UserName!.Textures[0].handel != good.handel ||
|
||||
Password!.Textures[0].handel != good.handel ||
|
||||
rec!.Textures.Count == 1 ||
|
||||
btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
DisplayName.LetterRemoved += () =>
|
||||
{
|
||||
Texture bad = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
|
||||
if (DisplayName.Text.Length == 0 && DisplayName.Textures[0].handel != bad.handel)
|
||||
{
|
||||
DisplayName.Textures[0] = bad;
|
||||
btn.Textures[0] = bad;
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
DisplayName.KeyPress += args =>
|
||||
{
|
||||
if (args.Key == Keys.Tab && args.Shift)
|
||||
{
|
||||
Password.Focus();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
rec.FilesDroped += RecOnFilesDroped;
|
||||
DisplayName.Textures[0] = UserName.Textures[0];
|
||||
rec.ForceDistanceUpdate(page);
|
||||
tb.Focus();
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
};
|
||||
@ -359,42 +378,51 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
AllowMultiLine = false
|
||||
});
|
||||
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
UserName.KeyPress += args =>
|
||||
UserName.LetterPress += () =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) && string.IsNullOrWhiteSpace(UserName.Text))
|
||||
|
||||
if (UserName.Textures[0].handel != good.handel)
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (UserName.Textures[0].handel != t.handel)
|
||||
{
|
||||
UserName.Textures[0] = t;
|
||||
if (t.handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel &&
|
||||
btn!.Textures[0].handel != good.handel &&
|
||||
tb.Textures[0].handel == good.handel)
|
||||
UserName.Textures[0] = good;
|
||||
if (Password!.Textures[0].handel == good.handel && btn.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel &&
|
||||
(Password!.Textures[0].handel != good.handel ||
|
||||
btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
UserName.LetterRemoved += () =>
|
||||
{
|
||||
Texture bad = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
|
||||
if (UserName.Text.Length == 0 && UserName.Textures[0].handel != bad.handel)
|
||||
{
|
||||
UserName.Textures[0] = bad;
|
||||
btn.Textures[0] = bad;
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
UserName.KeyPress += args =>
|
||||
{
|
||||
if (args.Key == Keys.Tab)
|
||||
{
|
||||
if (args.Shift)
|
||||
{
|
||||
tb.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Password!.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
UserName.Size = UserName.Size;
|
||||
|
||||
page.Controls.Add(Password = new()
|
||||
{
|
||||
Location = new(0, UserName.Location.Y + UserName.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
|
||||
@ -405,39 +433,40 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
PasswordChar = '●'
|
||||
});
|
||||
Password.Textures[0] = UserName.Textures[0];
|
||||
Password.KeyPress += args =>
|
||||
Password.LetterPress += () =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) &&
|
||||
string.IsNullOrWhiteSpace(Password.Text))
|
||||
|
||||
if (Password.Textures[0].handel != good.handel)
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (Password.Textures[0].handel != t.handel)
|
||||
{
|
||||
Password.Textures[0] = t;
|
||||
if (t.handel == good.handel &&
|
||||
UserName!.Textures[0].handel == good.handel &&
|
||||
btn!.Textures[0].handel != good.handel &&
|
||||
tb.Textures[0].handel == good.handel)
|
||||
Password.Textures[0] = good;
|
||||
if (UserName.Textures[0].handel == good.handel && btn.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel &&
|
||||
(UserName!.Textures[0].handel != good.handel ||
|
||||
btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
Password.LetterRemoved += () =>
|
||||
{
|
||||
Texture bad = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
|
||||
if (Password.Text.Length == 0 && Password.Textures[0].handel != bad.handel)
|
||||
{
|
||||
Password.Textures[0] = bad;
|
||||
btn.Textures[0] = bad;
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
Password.KeyPress += args =>
|
||||
{
|
||||
if (args.Key == Keys.Tab && args.Shift)
|
||||
{
|
||||
UserName.Focus();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
@ -445,6 +474,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
Password.ForceDistanceUpdate(page);
|
||||
DisplayName = null!;
|
||||
rec = null!;
|
||||
tb.Focus();
|
||||
Globals.ms.ForceUpdate(new(Globals.ms.CS));
|
||||
TryDraw();
|
||||
}
|
||||
@ -467,8 +497,6 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
BackgroundColor = Form.BackgroundColor
|
||||
};
|
||||
page.Size = new(Form.Size.X - tb.Location.X - tb.Location.X, Form.Size.Y - tb.Location.X - page.Location.Y - ca.Size.Y - tb.Location.X);
|
||||
Console.Write(page.Size.Y - tb.Location.X - tb.Location.X - (50*2*3));
|
||||
Console.WriteLine(page.Size);
|
||||
Form.Controls.Add(page);
|
||||
|
||||
btn = new(Globals.ms.TextureManager.GetTextureResource("BadTextbox.png"))
|
||||
@ -478,6 +506,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
||||
TextureDisplay = TextureDisplay.Center
|
||||
};
|
||||
_ = ca.ToggleSelected();
|
||||
tb.Focus();
|
||||
Label sub = new(Globals.DefaultFont)
|
||||
{
|
||||
Text = "Submit",
|
||||
|
@ -18,7 +18,7 @@ public class TextBox : UserControl
|
||||
private Rectangle Pointer;
|
||||
private Timer t;
|
||||
|
||||
public int CursorLocation { get; set; } = 0;
|
||||
public int CursorLocation { get; set; }
|
||||
|
||||
public TextBox()
|
||||
:base(Globals.ms.TextureManager.GetTextureResource("Textbox.png"))
|
||||
@ -54,13 +54,15 @@ public class TextBox : UserControl
|
||||
|
||||
private void TOnElapsed(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
Globals.ms.Invoke(new Action(() =>
|
||||
Globals.ms.Invoke(() =>
|
||||
{
|
||||
Pointer.Visible = !Pointer.Visible;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
public event Func<KeyboardKeyEventArgs, Task>? KeyPress;
|
||||
public event Func<Task>? LetterPress;
|
||||
public event Func<Task>? LetterRemoved;
|
||||
|
||||
public override void UnFocus()
|
||||
{
|
||||
@ -90,24 +92,30 @@ public class TextBox : UserControl
|
||||
{
|
||||
if (Loaded) return;
|
||||
window.MouseDown += Window_MouseDown;
|
||||
window.KeyDown += Window_KeyDown;
|
||||
window.TextInput += WindowOnTextInput;
|
||||
if (!window.Context.IsCurrent) window.Context.MakeCurrent();
|
||||
base.LoadToParent(parent, window);
|
||||
Pointer.Location = _watermark.Location;
|
||||
}
|
||||
|
||||
private void WindowOnTextInput(TextInputEventArgs obj)
|
||||
|
||||
public override void SendClipEvent(string ClipString)
|
||||
{
|
||||
base.SendClipEvent(ClipString);
|
||||
if (!use) return;
|
||||
Text = Text.Insert((int)CursorLocation, obj.AsString);
|
||||
CursorLocation += obj.AsString.Length;
|
||||
var f = _label.GetCharLocation((int)CursorLocation);
|
||||
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
||||
Pointer.Visible = true;
|
||||
try
|
||||
{
|
||||
Text = Text.Insert(CursorLocation, ClipString);
|
||||
CursorLocation += ClipString.Length;
|
||||
Vector2i f = _label.GetCharLocation(CursorLocation);
|
||||
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
||||
Pointer.Visible = true;
|
||||
if (LetterPress is not null) LetterPress.Invoke().Wait();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public char? PasswordChar { get => _label.PasswordChar; set => _label.PasswordChar = value; }
|
||||
|
||||
private TextLocation tl = TextLocation.TopLeft;
|
||||
@ -259,57 +267,56 @@ public class TextBox : UserControl
|
||||
|
||||
public event Func<Task>? OnNewLine;
|
||||
public event Func<Task>? OnRemoveLine;
|
||||
|
||||
private void Window_KeyDown(KeyboardKeyEventArgs obj)
|
||||
|
||||
public override void SendKeyEvent(KeyboardKeyEventArgs KeyArgs)
|
||||
{
|
||||
base.SendKeyEvent(KeyArgs);
|
||||
if (!use) return;
|
||||
if (obj.Key == Keys.Left)
|
||||
if (KeyArgs.Key == Keys.Left && CursorLocation != 0)
|
||||
{
|
||||
CursorLocation--;
|
||||
var f = _label.GetCharLocation((int)CursorLocation);
|
||||
var f = _label.GetCharLocation(CursorLocation);
|
||||
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
||||
Pointer.Visible = true;
|
||||
}
|
||||
if (obj.Key == Keys.Right)
|
||||
if (KeyArgs.Key == Keys.Right && CursorLocation != Text.Length)
|
||||
{
|
||||
if (CursorLocation != Text.Length)
|
||||
{
|
||||
CursorLocation++;
|
||||
var f = _label.GetCharLocation((int)CursorLocation);
|
||||
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
||||
Pointer.Visible = true;
|
||||
}
|
||||
|
||||
CursorLocation++;
|
||||
var f = _label.GetCharLocation(CursorLocation);
|
||||
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
||||
Pointer.Visible = true;
|
||||
}
|
||||
if (obj.Key == Keys.CapsLock || obj.Key == Keys.Menu || obj.Key == Keys.LeftSuper || obj.Key == Keys.RightSuper || obj.Key == Keys.End || obj.Key == Keys.Home || obj.Key == Keys.PageDown || obj.Key == Keys.PageUp || obj.Key == Keys.Insert || obj.Key == Keys.Up || obj.Key == Keys.Down || obj.Key == Keys.Left || obj.Key == Keys.Right) return;
|
||||
if (obj.Key == Keys.Backspace)
|
||||
if (KeyArgs.Key == Keys.CapsLock || KeyArgs.Key == Keys.Menu || KeyArgs.Key == Keys.LeftSuper || KeyArgs.Key == Keys.RightSuper || KeyArgs.Key == Keys.End || KeyArgs.Key == Keys.Home || KeyArgs.Key == Keys.PageDown || KeyArgs.Key == Keys.PageUp || KeyArgs.Key == Keys.Insert || KeyArgs.Key == Keys.Up || KeyArgs.Key == Keys.Down || KeyArgs.Key == Keys.Left || KeyArgs.Key == Keys.Right) return;
|
||||
if (KeyArgs.Key == Keys.Backspace)
|
||||
{
|
||||
if (!(Text.Length > 0)) return;
|
||||
if (Text[CursorLocation- 1] == '\n')
|
||||
{
|
||||
Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight);
|
||||
if (OnRemoveLine is not null) OnRemoveLine.Invoke();
|
||||
if (OnRemoveLine is not null) OnRemoveLine.Invoke().Wait();
|
||||
}
|
||||
CursorLocation--;
|
||||
Text = Text.Remove(CursorLocation, 1);
|
||||
if (LetterRemoved is not null) LetterRemoved.Invoke().Wait();
|
||||
var f = _label.GetCharLocation(CursorLocation);
|
||||
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
||||
Pointer.Visible = true;
|
||||
}
|
||||
if (obj.Key == Keys.Delete)
|
||||
if (KeyArgs.Key == Keys.Delete)
|
||||
{
|
||||
if (CursorLocation == Text.Length) return;
|
||||
if (Text[CursorLocation] == '\n')
|
||||
{
|
||||
Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight);
|
||||
if (OnRemoveLine is not null) OnRemoveLine.Invoke();
|
||||
if (OnRemoveLine is not null) OnRemoveLine.Invoke().Wait();
|
||||
}
|
||||
Text = Text.Remove(CursorLocation, 1);
|
||||
if (LetterRemoved is not null) LetterRemoved.Invoke().Wait();
|
||||
}
|
||||
|
||||
if (obj.Key == Keys.Enter)
|
||||
if (KeyArgs.Key == Keys.Enter)
|
||||
{
|
||||
if (AllowMultiLine && obj.Shift)
|
||||
if (AllowMultiLine && KeyArgs.Shift)
|
||||
{
|
||||
BlockDraw = true;
|
||||
Size = new(Size.X, Size.Y + (int)_label.Font.PixelHeight);
|
||||
@ -323,12 +330,23 @@ public class TextBox : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (obj.Key == Keys.V && obj.Control && Window is not null) Text += Window.ClipboardString;
|
||||
if (KeyPress is not null) _ = KeyPress.Invoke(obj);
|
||||
}
|
||||
|
||||
|
||||
if (KeyArgs.Key == Keys.V && KeyArgs.Control && Window is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Text += Window.ClipboardString;
|
||||
if (LetterPress is not null) LetterPress.Invoke().Wait();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
if (KeyPress is not null) _ = KeyPress.Invoke(KeyArgs);
|
||||
}
|
||||
|
||||
private void Window_MouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if (MouseInside && e.Button == MouseButton.Button1)
|
||||
|
12
Luski/GUI/MainScreen/UI/LuskiSettings/Core/ISettingsPage.cs
Normal file
12
Luski/GUI/MainScreen/UI/LuskiSettings/Core/ISettingsPage.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||
|
||||
public interface ISettingsPage : IRenderObject
|
||||
{
|
||||
public string PageName { get; set; }
|
||||
public FontInteraction TitleFont { get; set; }
|
||||
public Color4 BackgroundColor { get; set; }
|
||||
}
|
38
Luski/GUI/MainScreen/UI/LuskiSettings/Core/PageFlow.cs
Normal file
38
Luski/GUI/MainScreen/UI/LuskiSettings/Core/PageFlow.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||
|
||||
public class PageFlow : FlowLayout, ISettingsPage
|
||||
{
|
||||
public string PageName
|
||||
{
|
||||
get
|
||||
{
|
||||
return pn;
|
||||
}
|
||||
set
|
||||
{
|
||||
pn = value;
|
||||
TitleLable.Text = $" \n{value}\n ";
|
||||
}
|
||||
}
|
||||
public FontInteraction TitleFont { get; set; }
|
||||
|
||||
public Label TitleLable;
|
||||
private string pn = "Blank Page";
|
||||
|
||||
public PageFlow()
|
||||
{
|
||||
TitleFont = Globals.DefaultFont.Clone();
|
||||
TitleFont.FontSize = FontSize.Bold;
|
||||
TitleFont.PixelHeight = (uint)(TitleFont.PixelHeight * 1.4f);
|
||||
Controls.Add(TitleLable = new Label(TitleFont)
|
||||
{
|
||||
Text = $" \nBlank Page\n "
|
||||
});
|
||||
base.Visible = false;
|
||||
base.Size = new(945.ScaleInt(), 896.ScaleInt());
|
||||
}
|
||||
}
|
@ -4,16 +4,16 @@ using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.SettingsPanel;
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||
|
||||
public class CategoryButton : UserControl
|
||||
public class PageTab : UserControl
|
||||
{
|
||||
public static Texture? seltec = null;
|
||||
private SettingsMenu SM;
|
||||
private Label l;
|
||||
public required Action OnPageLoad;
|
||||
public required IRenderObject Page;
|
||||
|
||||
public CategoryButton(string Text, SettingsMenu SM)
|
||||
public PageTab(string Text, SettingsMenu SM)
|
||||
:base(seltec)
|
||||
{
|
||||
this.SM = SM;
|
||||
@ -30,7 +30,7 @@ public class CategoryButton : UserControl
|
||||
((base.Size.Y - l.Size.Y) / 2)
|
||||
, 0);
|
||||
Controls.Add(l);
|
||||
BackgroundColor = new(0, 0, 0, 0);
|
||||
base.BackgroundColor = new(0, 0, 0, 0);
|
||||
Clicked += OnClicked;
|
||||
MouseEnter += o =>
|
||||
{
|
||||
@ -79,10 +79,10 @@ public class CategoryButton : UserControl
|
||||
l.Color = f;
|
||||
if (Selected)
|
||||
{
|
||||
if (SM.Selected is not null) SM.Selected.Page.Visible = false;
|
||||
SM.Selected = this;
|
||||
Globals.ms.Title = $"Settings | {l.Text} - Luski";
|
||||
SM.page.Controls.Clear();
|
||||
OnPageLoad.Invoke();
|
||||
Page.Visible = true;
|
||||
}
|
||||
|
||||
BlockDraw = false;
|
@ -0,0 +1,80 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||
|
||||
public class SettingsCategory : UserControl
|
||||
{
|
||||
private Label Top;
|
||||
private static FontInteraction? fi;
|
||||
private Rectangle line;
|
||||
public string Name
|
||||
{
|
||||
get => Top.Text;
|
||||
}
|
||||
|
||||
private SettingsMenu ss;
|
||||
|
||||
public SettingsCategory(string Name, SettingsMenu SS)
|
||||
{
|
||||
ss = SS;
|
||||
if (fi is null)
|
||||
{
|
||||
fi = Globals.DefaultFont.Clone();
|
||||
fi.FontSize = FontSize.Bold;
|
||||
}
|
||||
Top = new(fi)
|
||||
{
|
||||
Location = new(5.ScaleInt(), 5.ScaleInt(), 0),
|
||||
Text = Name
|
||||
};
|
||||
base.BackgroundColor = new(255, 255, 255, 0);
|
||||
base.Size = new(307.ScaleInt(), 20.ScaleInt() + Top.Size.Y);
|
||||
Top.Location = new((base.Size.X - Top.Size.X) / 2, Top.Location.Y, 0);
|
||||
line = new()
|
||||
{
|
||||
Size = new(base.Size.X, 1.ScaleInt()),
|
||||
BackgroundColor = Color4.Gray,
|
||||
Location = new(0, base.Size.Y - 1.ScaleInt(), 0)
|
||||
};
|
||||
line.ForceDistanceUpdate(this);
|
||||
Controls.Add(line);
|
||||
Controls.Add(Top);
|
||||
}
|
||||
|
||||
public PageTab AddPage<TPage>(TPage Page) where TPage : ISettingsPage
|
||||
{
|
||||
Page.Location = new(ss.fl.Size.X + 40.ScaleInt(), 0, 0);
|
||||
Page.Size = new(Globals.ms.CS.X - ss.fl.Size.X - 80.ScaleInt(), Globals.ms.CS.Y);
|
||||
Page.AllowHoverFromBehind = true;
|
||||
Page.Anchor = ObjectAnchor.All;
|
||||
Page.BackgroundColor = ss.BackgroundColor;
|
||||
ss.Controls.Add(Page);
|
||||
if (Page is PageFlow pbf) pbf.HScrollPixels = Globals.Settings.PerScrollPixels;
|
||||
PageTab cb = new(Page.PageName, ss)
|
||||
{
|
||||
Page = Page
|
||||
};
|
||||
Controls.Add(cb);
|
||||
int f = 5.ScaleInt();
|
||||
cb.Location = new (line.Location.X + f, line.Location.Y - f, 0);
|
||||
line.Location = new(line.Location.X, line.Location.Y + cb.Size.Y + f, 0);
|
||||
Size = new(Size.X, Size.Y + cb.Size.Y + f);
|
||||
Page.Tag = cb;
|
||||
return cb;
|
||||
}
|
||||
|
||||
public void RemovePage<TPage>(TPage Page) where TPage : ISettingsPage
|
||||
{
|
||||
if (Page.Tag is PageTab cb)
|
||||
{
|
||||
int f = 5.ScaleInt();
|
||||
line.Location = new(line.Location.X, line.Location.Y - cb.Size.Y - f, 0);
|
||||
Size = new(Size.X, Size.Y - cb.Size.Y - f);
|
||||
Controls.Remove(cb);
|
||||
}
|
||||
ss.Controls.Remove(Page);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using GraphicsManager.Objects;
|
||||
using Luski.Classes;
|
||||
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||
using Luski.GUI.MainScreen.UI.SettingsPanel;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
|
||||
|
||||
public class ExperimentSettings : PageFlow
|
||||
{
|
||||
public ExperimentSettings()
|
||||
{
|
||||
base.Size = new(500.ScaleInt());
|
||||
PageName = "Experiments";
|
||||
ExperimentGUI? g = null;
|
||||
foreach (ExperimentInfo exp in Globals.Experiments)
|
||||
{
|
||||
g = new(exp);
|
||||
Controls.Add(g);
|
||||
}
|
||||
|
||||
if (g is not null)
|
||||
{
|
||||
g.line.WindowLoaded += _ =>
|
||||
{
|
||||
ParentResize(new(Globals.ms.ClientSize));
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using System.Reflection;
|
||||
using GraphicsManager.Enums;
|
||||
using Luski.Classes;
|
||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
|
||||
|
||||
public class Updater : PageFlow
|
||||
{
|
||||
public Updater()
|
||||
{
|
||||
PageName = "Updater Config";
|
||||
TextBox t;
|
||||
Controls.Add(t =new TextBox()
|
||||
{
|
||||
Text = Globals.UpdaterSettings.Updater!,
|
||||
WatermarkText = "Updater File",
|
||||
TextureDisplay = TextureDisplay.Center,
|
||||
Size = new(base.Size.X, 34.ScaleInt()),
|
||||
TextLocation = TextLocation.LineCenter,
|
||||
AllowMultiLine = false
|
||||
});
|
||||
foreach (PropertyInfo prop in typeof(UpdaterSettings).GetProperties())
|
||||
{
|
||||
object PropVal = prop.GetValue(Globals.UpdaterSettings)!;
|
||||
Type PropType = prop.PropertyType;
|
||||
|
||||
if (PropType.IsEnum)
|
||||
{
|
||||
IEnumerable<Enum> values = Enum.GetValues(PropType).Cast<Enum>();
|
||||
foreach (var val in values)
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals.AddBool(this, PropType, val, ((Enum)PropVal).HasFlag(val), bb =>
|
||||
{
|
||||
long va = Convert.ToInt64(val);
|
||||
long v = Convert.ToInt64(PropVal);
|
||||
if (bb)
|
||||
{
|
||||
object e = Enum.Parse(PropType, (v + va).ToString());
|
||||
PropVal = e;
|
||||
prop.SetValue(Globals.Settings, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
var e = Enum.Parse(PropType, (v - va).ToString());
|
||||
PropVal = e;
|
||||
prop.SetValue(Globals.UpdaterSettings, e);
|
||||
}
|
||||
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PropType.FullName == typeof(bool).FullName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals.AddBool(this, prop, (bool)PropVal, b =>
|
||||
{
|
||||
prop.SetValue(Globals.UpdaterSettings, b);
|
||||
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.ForceDistanceUpdate(this);
|
||||
t.KeyPress += _ =>
|
||||
{
|
||||
Globals.UpdaterSettings.Updater = t.Text;
|
||||
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
WindowLoaded += _ =>
|
||||
{
|
||||
Globals.ms.ForceUpdate(new(Globals.ms.CS));
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Objects;
|
||||
using Luski.Classes;
|
||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||
using Luski.GUI.MainScreen.UI.SettingsPanel;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
|
||||
|
||||
public class Appearance : PageFlow
|
||||
{
|
||||
private DropDown<ThemeDropButton> ThemeDrop;
|
||||
|
||||
public Appearance()
|
||||
{
|
||||
PageName = "Appearance";
|
||||
ThemeDropButton LightDD;
|
||||
ThemeDrop = new(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"),new Rectangle()
|
||||
{
|
||||
Size = new(base.Size.X - 2, 1.ScaleInt()),
|
||||
BackgroundColor = Color4.Gray,
|
||||
Location = new(1, base.Size.Y - 1.ScaleInt(), 0),
|
||||
Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Bottom
|
||||
}, LightDD = new(LuskiThemes.Light)
|
||||
{
|
||||
LoadDisplay = () =>
|
||||
{
|
||||
Label ll = new Label(Globals.DefaultFont)
|
||||
{
|
||||
Text = LuskiThemes.Light.Name,
|
||||
Color = Color4.DarkGray,
|
||||
IgnoreHover = true
|
||||
};
|
||||
ll.Location = new(10.ScaleInt(),
|
||||
((ThemeDrop.Size.Y - ll.Size.Y) / 2)
|
||||
, 0);
|
||||
ThemeDrop.Controls.Add(ll);
|
||||
},
|
||||
Size = new(297.ScaleInt(), 40.ScaleInt()),
|
||||
})
|
||||
{
|
||||
DropDownParentOverride = Globals.ms,
|
||||
Size = new(40.ScaleInt()),
|
||||
Location = new(5.ScaleInt(), 5.ScaleInt(), 0),
|
||||
BackgroundColor = new(40, 40, 40, 255),
|
||||
Anchor = ObjectAnchor.Right | ObjectAnchor.Left,};
|
||||
foreach (ThemeStart themeStart in LuskiThemes.LuskiThemeList)
|
||||
{
|
||||
if (themeStart.Name == LuskiThemes.Light.Name) continue;
|
||||
ThemeDropButton tdb;
|
||||
ThemeDrop.AddOption(tdb = new(themeStart)
|
||||
{
|
||||
LoadDisplay = () =>
|
||||
{
|
||||
Label ll = new Label(Globals.DefaultFont)
|
||||
{
|
||||
Text = themeStart.Name,
|
||||
Color = Color4.DarkGray,
|
||||
IgnoreHover = true
|
||||
};
|
||||
ll.Location = new(10.ScaleInt(),
|
||||
((ThemeDrop.Size.Y - ll.Size.Y) / 2)
|
||||
, 0);
|
||||
ThemeDrop.Controls.Add(ll);
|
||||
},
|
||||
Size = new(297.ScaleInt(), 40.ScaleInt()),
|
||||
});
|
||||
if (themeStart.Name == Globals.Settings.Theme) ThemeDrop.SetSelected(tdb);
|
||||
}
|
||||
ThemeDrop.DropDownContainer.Textures.Add(Globals.ms.TextureManager.GetTextureResource("RoundedRectangleBottom.png"));
|
||||
ThemeDrop.DropDownContainer.TextureDisplay = TextureDisplay.Center;
|
||||
ThemeDrop.DropDownContainer.Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||
ThemeDrop.DropDownContainer.BackgroundColor = ThemeDrop.BackgroundColor;
|
||||
Rectangle line = new()
|
||||
{
|
||||
Size = new(base.Size.X - 2, 1.ScaleInt()),
|
||||
BackgroundColor = Color4.Gray,
|
||||
Location = new(1, base.Size.Y - 1.ScaleInt(), 0),
|
||||
Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Bottom
|
||||
};
|
||||
ThemeDrop.OpenStatusChanged += b =>
|
||||
{
|
||||
BlockDraw = true;
|
||||
Size = new(base.Size.X, base.Size.Y + ( b ? ThemeDrop.DropDownContainer.Size.Y : -1 * ThemeDrop.DropDownContainer.Size.Y));
|
||||
line!.Location = new(line.Location.X,
|
||||
line.Location.Y + (b ? ThemeDrop.DropDownContainer.Size.Y : -1 * ThemeDrop.DropDownContainer.Size.Y), 0);
|
||||
if (b)
|
||||
{
|
||||
ThemeDrop.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangleTop.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
ThemeDrop.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png");
|
||||
}
|
||||
|
||||
BlockDraw = false;
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
Controls.Add(ThemeDrop);
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
using System.Reflection;
|
||||
using Luski.Classes;
|
||||
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
|
||||
|
||||
public class General : PageFlow
|
||||
{
|
||||
public General()
|
||||
{
|
||||
PageName = "General";
|
||||
foreach (PropertyInfo prop in typeof(Settings).GetProperties())
|
||||
{
|
||||
object PropVal = prop.GetValue(Globals.Settings)!;
|
||||
Type PropType = prop.PropertyType;
|
||||
if (PropType.IsEnum)
|
||||
{
|
||||
IEnumerable<Enum> values = Enum.GetValues(PropType).Cast<Enum>();
|
||||
foreach (var val in values)
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals.AddBool(this, PropType, val, ((Enum)PropVal).HasFlag(val), bb =>
|
||||
{
|
||||
long va = Convert.ToInt64(val);
|
||||
long v = Convert.ToInt64(PropVal);
|
||||
if (bb)
|
||||
{
|
||||
object e = Enum.Parse(PropType, (v + va).ToString());
|
||||
PropVal = e;
|
||||
prop.SetValue(Globals.Settings, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
var e = Enum.Parse(PropType, (v - va).ToString());
|
||||
PropVal = e;
|
||||
prop.SetValue(Globals.Settings, e);
|
||||
}
|
||||
Globals.Settings.SaveSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PropType.FullName == typeof(bool).FullName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals.AddBool(this, prop, (bool)PropVal, b =>
|
||||
{
|
||||
prop.SetValue(Globals.Settings, b);
|
||||
Globals.Settings.SaveSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|