From 2dee38084e3ce52dcb0e663b4e4b700308591e80 Mon Sep 17 00:00:00 2001 From: JacobTech Date: Tue, 27 Aug 2024 10:55:36 -0400 Subject: [PATCH] Categories And Scissor The scissor code should now properly cut all controls from going past the parent. --- Luski/ConsoleLog.cs | 7 +++++ .../UI/LuskiControls/AdvancedGradientLabel.cs | 2 +- .../MainScreen/UI/LuskiControls/LuskiLabel.cs | 2 +- .../Pages/Server/Roles/ServerRoleOptions.cs | 26 ++++++++++++++++--- Luski/Globals.cs | 3 ++- Luski/Luski.csproj | 4 +-- 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Luski/ConsoleLog.cs b/Luski/ConsoleLog.cs index 7fe4f2d..917502f 100644 --- a/Luski/ConsoleLog.cs +++ b/Luski/ConsoleLog.cs @@ -9,23 +9,30 @@ public enum ConsoleLog : long None = 0, [Shared.GlobalAttributes.DisplayName("OpenGL Errors")] [Description("Show OpenGL Major Errors")] + [Category("Rendering")] BigErrosForOpenGL = 1, [Shared.GlobalAttributes.DisplayName("OpenGL Medium Errors")] [Description("Show OpenGL Medium Errors")] + [Category("Rendering")] MediumErrosForOpenGL = 2, [Shared.GlobalAttributes.DisplayName("OpenGL Small Errors")] [Description("Show OpenGL Small Errors")] + [Category("Rendering")] LowErrosForOpenGL = 4, [Shared.GlobalAttributes.DisplayName("OpenGL Info")] [Description("Show OpenGL Info")] + [Category("Rendering")] InfoForOpenGL = 8, [Shared.GlobalAttributes.DisplayName("Log Frames")] [Description("Shows draw fram message in the console")] + [Category("Rendering")] DrawFrames = 16, [Shared.GlobalAttributes.DisplayName("Show Missing Charters")] [Description("Show Missing Charters")] + [Category("Rendering")] ShowMissingChar = 32, [Shared.GlobalAttributes.DisplayName("GLFW Errors")] [Description("Show GLFW Errors")] + [Category("Rendering")] ShowErrorsForGLFW = 64 } \ No newline at end of file diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/AdvancedGradientLabel.cs b/Luski/GUI/MainScreen/UI/LuskiControls/AdvancedGradientLabel.cs index de3fd99..348011e 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/AdvancedGradientLabel.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/AdvancedGradientLabel.cs @@ -48,7 +48,7 @@ public class AdvancedGradientLabel : LabelBase base.LoadToParent(window, win); } - public override void Draw(int x, int y, int ww, int hh) + public override void Draw(int x, int y, int sx, int sy, int sw, int sh) { if (Visible && Loaded && this.Font is not null && Colors.Length > 1) { diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/LuskiLabel.cs b/Luski/GUI/MainScreen/UI/LuskiControls/LuskiLabel.cs index c6f6a18..20699a9 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/LuskiLabel.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/LuskiLabel.cs @@ -550,7 +550,7 @@ public class LuskiLabel : LabelBase private List Links = new(); - public override void Draw(int x, int y, int ww, int hh) + public override void Draw(int x, int y, int sx, int sy, int sw, int sh) { if (Visible && Loaded) { diff --git a/Luski/GUI/MainScreen/UI/PublicServers/ServerSettings/Pages/Server/Roles/ServerRoleOptions.cs b/Luski/GUI/MainScreen/UI/PublicServers/ServerSettings/Pages/Server/Roles/ServerRoleOptions.cs index 6bfd847..643b36f 100644 --- a/Luski/GUI/MainScreen/UI/PublicServers/ServerSettings/Pages/Server/Roles/ServerRoleOptions.cs +++ b/Luski/GUI/MainScreen/UI/PublicServers/ServerSettings/Pages/Server/Roles/ServerRoleOptions.cs @@ -143,6 +143,7 @@ public class ServerRoleOptions : UserControl NeedMax.Clear(); Type PropType = typeof(ServerPermission); IEnumerable values = Enum.GetValues(PropType).Cast(); + Dictionary Cats = new(); foreach (var val in values) { try @@ -150,10 +151,27 @@ public class ServerRoleOptions : UserControl MemberInfo? enumValueMemberInfo = Globals.GetMemberInfo(PropType, val); string description = Globals.GetAttribute(enumValueMemberInfo!, val).Description; string Name = Globals.GetAttribute(enumValueMemberInfo!, val).DisplayName; + string cat = Globals.GetAttribute(enumValueMemberInfo!, val).Category; + if (cat.ToLower() == "internal") continue; + + if (!Cats.ContainsKey(cat)) + { + UserControl c = new UserControl() + { + BackgroundColor = Page.BackgroundColor, + Size = new(Page.Size.X, 50.ScaleInt()) + }; + Label tmp = new(Globals.DefaultFont) + { + Text = cat + " Permissions" + }; + tmp.SetLocation(2.ScaleInt(), (int)((c.Size.Y - tmp.Font.PixelHeight)/2)); + c.Controls.Add(tmp); + Page.Controls.Add(c); + Cats.Add(cat, c); + } - - if (Name.ToLower() == "view this") continue; - Globals.AddBool(Page, Name, description + " in the server.", r.ServerPermissions.HasFlag(val), _ => + UserControl tc = Globals.AddBool(Cats[cat], Name, description + " in the server.", r.ServerPermissions.HasFlag(val), _ => { TempPermissions ^= val; if (TempPermissions != r.ServerPermissions) @@ -165,6 +183,8 @@ public class ServerRoleOptions : UserControl Warning.Visible = false; } }, NeedMax); + tc.SetLocation(tc.Location.X, Cats[cat].Size.Y); + Cats[cat].SetSize(Cats[cat].Size.X, Cats[cat].Size.Y + tc.Size.Y); } catch diff --git a/Luski/Globals.cs b/Luski/Globals.cs index c566f63..aa83890 100644 --- a/Luski/Globals.cs +++ b/Luski/Globals.cs @@ -260,7 +260,7 @@ public static class Globals public static API Luski { get; } = new(); public static MainScreenWindow ms; - public static void AddBool(IParent parent, string Name, string description, bool s, Action a, List