I did too much.

I was going to add a new munu to manage roles, but I got a bit carried away updating existing ones.
This commit is contained in:
JacobTech 2024-05-13 11:47:29 -04:00
parent baa7fc74e0
commit 42b612bbc2
39 changed files with 1752 additions and 722 deletions

View File

@ -35,7 +35,7 @@ public static class LuskiThemes
Description = "A light theme for the insane.",
GlobalServerTemplate = new()
{
SelectionColor = new("000000")
SelectionColor = new("00000000")
}
};

View File

@ -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;

View File

@ -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");
}

View File

@ -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;
}

View File

@ -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
}

View File

@ -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",

View File

@ -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)

View 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; }
}

View 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());
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;
};
}
}
}

View File

@ -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;
};
}
}

View File

@ -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);
}
}

View File

@ -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
}
}
}
}
}

View File

@ -0,0 +1,81 @@
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiSettings;
public class SettingsMenu : UserControl
{
private string BehindName;
public PageTab? Selected;
public FlowLayout fl;
private Appearance a;
public SettingsMenu()
{
base.BackgroundColor = new(34, 34, 34, 255);
base.Size = Globals.ms.ClientSize;
BehindName = Globals.ms.Title;
Globals.ms.Title = $"Settings - Luski";
fl = new()
{
BackgroundColor = new(20, 20, 20, 255),
Size = new(307.ScaleInt(), base.Size.Y),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
};
SettingsCategory AppSettings = new("App Settings", this);
SettingsCategory AdvancedSettings = new("Advanced Settings", this);
PageTab cb = AppSettings.AddPage(new General());
if (LuskiExperiments.Settings.Theme.IsEnabled()) _ = AppSettings.AddPage(a=new Appearance());
LuskiExperiments.Settings.Theme.EventToggled += b =>
{
if (b)
{
_ = AppSettings.AddPage(a=new Appearance());
Globals.ms.ForceUpdate(new(Globals.ms.CS));
}
else AppSettings.RemovePage(a!);
return Task.CompletedTask;
};
_ = AdvancedSettings.AddPage(new ExperimentSettings());
_ = AdvancedSettings.AddPage(new Updater());
fl.Controls.Add(AppSettings);
fl.Controls.Add(AdvancedSettings);
cb.ToggleSelected().Wait();
Anchor = ObjectAnchor.All;
Controls.Add(fl);
Rectangle closebtn = new(Globals.ms.TextureManager.GetTextureResource("close.png"))
{
Location = new(Globals.ms.ClientSize.X - 40.ScaleInt(), 8.ScaleInt(),0),
Size = new(32.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Gray,
Anchor = ObjectAnchor.Top | ObjectAnchor.Right
};
closebtn.MouseEnter += _ =>
{
closebtn.BackgroundColor = Color4.White;
return Task.CompletedTask;
};
closebtn.MouseLeave += _ =>
{
closebtn.BackgroundColor = Color4.Gray;
return Task.CompletedTask;
};
closebtn.Clicked += ClosebtnOnClicked;
closebtn.ForceDistanceUpdate(this);
Controls.Add(closebtn);
}
private Task ClosebtnOnClicked(IRenderObject arg)
{
Globals.ms.Controls.Remove(this);
Globals.ms.Title = BehindName;
Globals.ms.DrawFrame();
return Task.CompletedTask;
}
}

View File

@ -14,27 +14,45 @@ public class ChannelSelector : FlowLayout, IChannelAdder
public SocketCategory CurrentCategory { get; }
private readonly List<Category> cc = new();
private readonly List<Channel> LoadedChannels = new();
public Dictionary<long, IChannelAdder> ChannelAdders = new();
public Channel? Selected;
private ChannelSelector(SocketCategory Cat)
{
CurrentCategory = Cat;
ChannelAdders.Add(Cat.ID, this);
Cat.Server.MessageReceived += ServerOnMessageReceived;
}
public static async Task<ChannelSelector> MakeSelector(SocketCategory Cat)
{
ChannelSelector cs = new(Cat);
if (await Cat.Server.User.HasAccessToCategory(Cat, ServerPermission.CreateChannels))
bool MakeChannels = await Cat.Server.User.HasAccessToCategory(Cat, ServerPermission.CreateChannels);
bool MakeRoles = await Cat.Server.User.HasPermissions(ServerPermission.ManageRoles);
if (MakeChannels || MakeRoles)
{
LuskiContextMenu lcm = new();
Label l = lcm.AddLabel("Create Channel");
l.Clicked += cs.LOnClicked;
if (MakeChannels)
{
Label l = lcm.AddLabel("Create Channel");
l.Clicked += cs.LOnClicked;
}
if (MakeRoles)
{
Label l = lcm.AddLabel("Create Role");
l.Clicked += cs.RLOnClicked;
}
cs.ContextMenu = lcm;
}
return cs;
}
private async Task RLOnClicked(IRenderObject arg)
{
Globals.ms.Controls.Add(new AddChannel(this, CurrentCategory));
TryDraw();
}
private async Task LOnClicked(IRenderObject arg)
{

View File

@ -33,7 +33,7 @@ public class ChatMessage : UserControl
ServerProfile prof = await message.GetProfile(CancellationToken.None);
Color? c = await prof.GetColor();
if (c is null) c = await auth.GetColor();
Color4 c4 = new(c.R, c.G, c.B, c.A);
Color4 c4 = c.ToColor4();
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), prof, await prof.MakeRct(auth, new(40.ScaleInt())), c4);
}

View File

@ -42,10 +42,10 @@ public class PublicChat : UserControl
HScrollPixels = Globals.Settings.PerScrollPixels,
});
MessageFlow.FlowUpdate += MessageFlowOnFlowUpdate;
if (LuskiExperiments.GUI.MessageLiveSize.IsEnabled()) MessageFlow.SizeChanged += OnSizeChanged;
LuskiExperiments.GUI.MessageLiveSize.EventToggled += MessageLiveSizeOnEventToggled;
if (LuskiExperiments.GUI.LiveLabelSize.IsEnabled()) MessageFlow.SizeChanged += OnSizeChanged;
LuskiExperiments.GUI.LiveLabelSize.EventToggled += LiveLabelSizeOnEventToggled;
Task MessageLiveSizeOnEventToggled(bool arg)
Task LiveLabelSizeOnEventToggled(bool arg)
{
if (arg) MessageFlow.SizeChanged += OnSizeChanged;
else MessageFlow.SizeChanged -= OnSizeChanged;

View File

@ -1,11 +1,13 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
using Luski.GUI.MainScreen.UI.SettingsPanel;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.SettingsPanel;
namespace Luski.GUI.MainScreen.UI.PublicServers;
public class Category : UserControl
public class ServerSettingCategory : UserControl
{
private Label Top;
private static FontInteraction? fi;
@ -15,8 +17,11 @@ public class Category : UserControl
get => Top.Text;
}
public Category(string Name)
private ServerSettings ss;
public ServerSettingCategory(string Name, ServerSettings SS)
{
ss = SS;
if (fi is null)
{
fi = Globals.DefaultFont.Clone();
@ -27,7 +32,7 @@ public class Category : UserControl
Location = new(5.ScaleInt(), 5.ScaleInt(), 0),
Text = Name
};
BackgroundColor = new(255, 255, 255, 0);
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()
@ -40,26 +45,23 @@ public class Category : UserControl
Controls.Add(line);
Controls.Add(Top);
}
public void AddButton(CategoryButton cb)
public ServerSettingPageTab AddPage<TPage>(TPage Page) where TPage : IPageBase
{
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;
if (Page is PageBaseFlow pbf) pbf.HScrollPixels = Globals.Settings.PerScrollPixels;
ServerSettingPageTab 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);
}
public void RemoveButton(CategoryButton cb)
{
int f = 5.ScaleInt();
line.Location = new(line.Location.X, line.Location.Y - cb.Size.Y - f, 0);
Controls.Remove(cb);
Size = new(Size.X, Size.Y - cb.Size.Y + f);
for (int i = 0; i < Controls.Length; i++)
{
ReportSizeUpdate(Controls[i]);
}
TryDraw();
return cb;
}
}

View File

@ -0,0 +1,96 @@
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers;
public class ServerSettingPageTab : UserControl
{
public static Texture? seltec = null;
private ServerSettings SM;
private Label l;
public required IRenderObject Page;
public ServerSettingPageTab(string Text, ServerSettings SM)
:base(seltec)
{
this.SM = SM;
base.Size = new(297.ScaleInt(), 40.ScaleInt());
TextureDisplay = TextureDisplay.HorizontalCenter;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
l = new Label(Globals.DefaultFont)
{
Text = Text,
Color = Color4.Gray,
IgnoreHover = true
};
l.Location = new(5.ScaleInt(),
((base.Size.Y - l.Size.Y) / 2)
, 0);
Controls.Add(l);
base.BackgroundColor = new(0, 0, 0, 0);
Clicked += OnClicked;
MouseEnter += o =>
{
if (!Selected)
{
BackgroundColor = new(141, 151, 165, 30);
}
return Task.CompletedTask;
};
MouseLeave += o =>
{
if (!Selected)
{
BackgroundColor = new(0,0,0,0);
}
return Task.CompletedTask;
};
}
private async Task OnClicked(IRenderObject arg)
{
if (!Selected) await ToggleSelected();
}
public bool Selected { get; private set; }
public async Task ToggleSelected()
{
try
{
Color4 bc = new(141,151,165,51), f= Color4.White;
if (Selected)
{
bc = new (0,0,0,0);
f = Color4.Gray;
}
BlockDraw = true;
Selected = !Selected;
if (SM.Selected is not null && SM.Selected != this)
{
await SM.Selected.ToggleSelected();
}
BackgroundColor = bc;
l.Color = f;
if (Selected)
{
if (SM.Selected is not null) SM.Selected.Page.Visible = false;
SM.Selected = this;
Globals.ms.Title = $"Server Settings | {l.Text} - Luski";
Page.Visible = true;
}
BlockDraw = false;
TryDraw();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}

View File

@ -0,0 +1,10 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects.Core;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
public interface IPageBase : IRenderObject
{
public string PageName { get; set; }
public FontInteraction TitleFont { get; set; }
}

View File

@ -0,0 +1,38 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
public class PageBaseControl : UserControl, IPageBase
{
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 PageBaseControl()
{
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((16+231+48+508).ScaleInt());
}
}

View File

@ -0,0 +1,38 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
public class PageBaseFlow : FlowLayout, IPageBase
{
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 PageBaseFlow()
{
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((16+231+48+508).ScaleInt());
}
}

View File

@ -0,0 +1,73 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using Luski.net.Structures.Public;
using OpenTK.Mathematics;
using SixLabors.ImageSharp.Processing;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
public class RoleIcon : UserControl
{
private ServerRoleInteraction SRI;
private Role ThisRole;
public RoleIcon(Role role, ServerRoleInteraction sri)
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{
SRI = sri;
ThisRole = role;
base.BackgroundColor = new (0,0,0,0);
TextureDisplay = TextureDisplay.HorizontalCenter;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
base.Size = new(sri.RoleFlow.Size.X, 50.ScaleInt());
Rectangle Color = new(Globals.ms.TextureManager.GetAlphaCircle())
{
Size = new(12.ScaleInt()),
Location = new(4.ScaleInt(), 19.ScaleInt(), 0),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
IgnoreHover = true,
BackgroundColor = role.Color.ToColor4()
};
Label name = new(Globals.ServerRoleFont)
{
Text = role.DisplayName,
IgnoreHover = true
};
name.Location = new(Color.Location.X + Color.Size.X + 4.ScaleInt(),
(Color.Location.Y + ((Color.Size.Y - name.Size.Y) / 2)), 0);
Controls.Add(name);
Controls.Add(Color);
Clicked += _ =>
{
if (sri.Selected != this)
{
sri.Selected.SetSelected(false);
sri.Selected = this;
SetSelected(true);
}
return Task.CompletedTask;
};
MouseEnter += _ =>
{
BackgroundColor = new(141, 151, 165, 30);
return Task.CompletedTask;
};
MouseLeave += _ =>
{
BackgroundColor = sri.Selected == this ? new(141, 151, 165, 51) : new(0, 0, 0, 0);
return Task.CompletedTask;
};
}
public void SetSelected(bool value)
{
if (value)
{
BackgroundColor = new(141, 151, 165, 51);
SRI.SRO.LoadRole(ThisRole);
}
else
{
BackgroundColor = new(0, 0, 0, 0);
}
}
}

View File

@ -0,0 +1,56 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
public class SaveWarning : UserControl
{
public event Func<Task>? SaveClicked;
public SaveWarning()
{
Label warning = new(Globals.DefaultFont)
{
Text = "Careful — you have unsaved changes!",
IgnoreHover = true
};
Label savetext = new(Globals.DefaultFont)
{
Text = "Save Changes",
IgnoreHover = true
};
Controls.Add(warning);
base.Size = new(700.ScaleInt(), 52.ScaleInt());
int space = 10.ScaleInt();
UserControl uc = new()
{
BackgroundColor = new(36, 128, 70, 255),
Size = new(140.ScaleInt(), 32.ScaleInt()),
Anchor = ObjectAnchor.Right | ObjectAnchor.Top | ObjectAnchor.Bottom
};
savetext.Location = new((uc.Size.X - savetext.Size.X) / 2, ((uc.Size.Y - savetext.Size.Y) / 2), 0);
uc.MouseEnter += _ =>
{
uc.BackgroundColor = new(26, 99, 52, 255);
return Task.CompletedTask;
};
uc.MouseLeave += _ =>
{
uc.BackgroundColor = new(36, 128, 70, 255);
return Task.CompletedTask;
};
uc.Clicked += _ =>
{
if (SaveClicked is not null) return SaveClicked.Invoke();
return Task.CompletedTask;
};
uc.Location = new(base.Size.X - space - uc.Size.X, space, 0);
warning.Location = new(space, savetext.Location.Y + uc.Location.Y, 0);
uc.Controls.Add(savetext);
uc.ForceDistanceUpdate(this);
Controls.Add(uc);
Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Top;
base.BackgroundColor = new(17, 18, 20, 255);
}
}

View File

@ -0,0 +1,83 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using Luski.net;
using Luski.net.Structures.Public;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
public class ServerRoleInteraction : UserControl
{
public FlowLayout RoleFlow;
public RoleIcon Selected;
public ServerRoleOptions SRO;
public ServerRoleInteraction(PublicServer server, ServerRolePage srp)
{
Task<Role[]> task = Task.Run(() => server.GetRoles());
task.Wait();
Role[] roles_pre = task.Result;
var roles = roles_pre.OrderByDescending(s => s.Index);
base.Size = new(srp.Size.X, srp.Size.Y - srp.TitleLable.Size.Y);
RoleFlow = new()
{
Size = new(247.ScaleInt(), base.Size.Y)
};
Rectangle hline = new()
{
Location = new(RoleFlow.Size.X, 0, 0),
Size = new(1.ScaleInt(), base.Size.Y),
Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Bottom,
BackgroundColor = Color4.White
};
hline.ForceDistanceUpdate(this);
Controls.Add(hline);
SRO = new()
{
//BackgroundColor = base.BackgroundColor,
Size = new(srp.Size.X - RoleFlow.Size.X, base.Size.Y),
Location = new(RoleFlow.Size.X + hline.Size.X, 0, 0),
Anchor = ObjectAnchor.All
};
SRO.ForceDistanceUpdate(this);
Controls.Add(SRO);
foreach (var role in roles)
{
Selected = new RoleIcon(role, this);
RoleFlow.Controls.Add(Selected);
Selected.ForceDistanceUpdate(RoleFlow);
}
Selected!.SetSelected(true);
var space = 10.ScaleInt();
Controls.Add(RoleFlow);
Warning = new()
{
Visible = false
};
Warning.Size = new(base.Size.X - space - space, Warning.Size.Y);
Warning.Location = new(space, base.Size.Y - Warning.Size.Y - space, 0);
Warning.ForceDistanceUpdate(this);
Controls.Add(Warning);
SRO.Init(Warning);
SRO.ForceDistanceUpdate(this);
}
public SaveWarning Warning;
public override Color4 BackgroundColor
{
get
{
return base.BackgroundColor;
}
set
{
base.BackgroundColor = value;
RoleFlow.BackgroundColor = value;
SRO.BackgroundColor = value;
Selected.SetSelected(true);
}
}
}

View File

@ -0,0 +1,227 @@
using System.ComponentModel;
using System.Reflection;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.Classes;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Mathematics;
using DisplayNameAttribute = Luski.Shared.GlobalAttributes.DisplayNameAttribute;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
public class ServerRoleOptions : UserControl
{
public FlowLayout Page = new();
private Label Display = new(Globals.DefaultFont) { Text = "Display" }, Permissions = new(Globals.DefaultFont) { Text = "Permissions" }, ManageMembers = new(Globals.DefaultFont);
private Rectangle Line = new() {BackgroundColor = new(63,65,71,255)}, SelectedLine = new();
private SaveWarning Warning;
public delegate void LoadCurrent();
private LoadCurrent? CurrentPageToLoad = null;
public void Init(SaveWarning sw)
{
Warning = sw;
Controls.Add(Display);
Controls.Add(Permissions);
Controls.Add(ManageMembers);
Controls.Add(Line);
Controls.Add(SelectedLine);
Controls.Add(Page);
Page.BackgroundColor = new(0, 0, 0, 0);
base.BackgroundColor = new(0, 0, 0, 0);
int space = 20.ScaleInt();
Display.Location = new(space, 0, 0);
Permissions.Location = new(Display.Location.X + Display.Size.X + space, Permissions.Location.Y,
Permissions.Location.Z);
ManageMembers.Location = new(Permissions.Location.X + Permissions.Size.X + space, ManageMembers.Location.Y,
ManageMembers.Location.Z);
Line.Location = new(space, Display.Size.Y, 0);
Line.Size = new(Size.X - space - space, 2.ScaleInt());
Line.Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Top;
Line.ForceDistanceUpdate(this);
SelectedLine.Location = new(Display.Location.X, Line.Location.Y, Line.Location.Z);
SelectedLine.BackgroundColor = Globals.DodgerBlue;
SelectedLine.Size = new(Display.Size.X, Line.Size.Y);
Display.Clicked += _ =>
{
if (SelectedLine.Location.X == Display.Location.X) return Task.CompletedTask;
LoadDisplay();
return Task.CompletedTask;
};
Permissions.Clicked += _ =>
{
if (SelectedLine.Location.X == Permissions.Location.X) return Task.CompletedTask;
LoadPermissions();
return Task.CompletedTask;
};
ManageMembers.Clicked += _ =>
{
if (SelectedLine.Location.X == ManageMembers.Location.X) return Task.CompletedTask;
LoadMembers();
return Task.CompletedTask;
};
Page.Size = new(Line.Size.X, base.Size.Y - Line.Location.Y - Line.Size.Y);
Page.Location = new(Line.Location.X, Line.Size.Y + Line.Location.Y, 0);
Page.HScrollPixels = (uint)30.ScaleInt();
Page.Anchor = ObjectAnchor.All;
Page.ForceDistanceUpdate(this);
if (LuskiExperiments.GUI.LiveLabelSize.IsEnabled())
Page.SizeChanged += PageOnSizeChanged;
LuskiExperiments.GUI.LiveLabelSize.EventToggled += b =>
{
if (b) Page.SizeChanged += PageOnSizeChanged;
else Page.SizeChanged -= PageOnSizeChanged;
return Task.CompletedTask;
};
}
private Task PageOnSizeChanged(IRenderObject arg)
{
foreach (Label l in NeedMax)
{
Vector2i oldsize = l.Size;
l.MaxSize = Page.Size;
Vector2i diff = oldsize - l.Size;
if (l.Parent is UserControl uc)
{
uc.Size = new(uc.Size.X, uc.Size.Y - diff.Y);
}
if (l.Tag is Rectangle line)
{
line.Location = new(line.Location.X, line.Location.Y - diff.Y, 0);
}
}
return Task.CompletedTask;
}
private List<Label> NeedMax = new();
private void AddSpace()
{
int space = Warning.Parent!.Size.Y - Warning.Location.Y - Warning.Size.Y;
Page.Controls.Add(new Rectangle()
{
BackgroundColor = new(0,0,0,0),
Size = new(Warning.Size.Y + space + space)
});
}
public void LoadDisplay()
{
if (CurrentPageToLoad != LoadDisplay)
{
Page.ScrollToTop();
}
CurrentPageToLoad = LoadDisplay;
SelectedLine.Size = new(Display.Size.X, Line.Size.Y);
SelectedLine.Location = new(Display.Location.X, Line.Location.Y, Line.Location.Z);
Page.Controls.Clear();
TryDraw();
}
private ServerPermission TempPermissions = ServerPermission.None;
public void LoadPermissions()
{
uint? scrval = null;
if (CurrentPageToLoad != LoadPermissions)
{
scrval = Page.ScrollValue;
Page.ScrollToTop();
}
CurrentPageToLoad = LoadPermissions;
SelectedLine.Size = new(Permissions.Size.X, Line.Size.Y);
SelectedLine.Location = new(Permissions.Location.X, Line.Location.Y, Line.Location.Z);
RemoveSaveEvents();
BlockDraw = true;
Page.Controls.Clear();
TempPermissions = r.ServerPermissions;
NeedMax.Clear();
Type PropType = typeof(ServerPermission);
IEnumerable<ServerPermission> values = Enum.GetValues(PropType).Cast<ServerPermission>();
foreach (var val in values)
{
try
{
MemberInfo? enumValueMemberInfo = Globals.GetMemberInfo(PropType, val);
string description = Globals.GetAttribute<DescriptionAttribute, ServerPermission>(enumValueMemberInfo!, val).Description;
string Name = Globals.GetAttribute<DisplayNameAttribute, ServerPermission>(enumValueMemberInfo!, val).DisplayName;
if (Name.ToLower() == "view this") continue;
Globals.AddBool(Page, Name, description + " in the server.", r.ServerPermissions.HasFlag(val), _ =>
{
TempPermissions ^= val;
if (TempPermissions != r.ServerPermissions)
{
Warning.Visible = true;
}
else
{
Warning.Visible = false;
}
}, NeedMax);
}
catch
{
//ignore
}
}
AddSpace();
Warning.SaveClicked += PermissionSave;
if (scrval is not null)
{
Page.ScrollValue = scrval.Value;
}
BlockDraw = false;
TryDraw();
}
private async Task PermissionSave()
{
r = await r.Server.EditRole(r, Permissions: TempPermissions);
Window!.Invoke(() =>
{
Warning.Visible = false;
Window!.TryDraw();
});
TempPermissions = r.ServerPermissions;
}
public void RemoveSaveEvents()
{
Warning.SaveClicked -= PermissionSave;
}
public void LoadMembers()
{
if (CurrentPageToLoad != LoadMembers)
{
Page.ScrollToTop();
}
CurrentPageToLoad = LoadMembers;
BlockDraw = true;
SelectedLine.Size = new(ManageMembers.Size.X, Line.Size.Y);
SelectedLine.Location = new(ManageMembers.Location.X, Line.Location.Y, Line.Location.Z);
Page.Controls.Clear();
BlockDraw = false;
TryDraw();
}
private Role r;
public void LoadRole(Role role)
{
r = role;
ManageMembers.Text = $"Manage Members ({role.MembersListID.Length})";
if (CurrentPageToLoad is not null) CurrentPageToLoad();
//LoadPermissions();
}
}

View File

@ -0,0 +1,35 @@
using GraphicsManager.Enums;
using Luski.net;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
public class ServerRolePage : PageBaseControl
{
private ServerRoleInteraction Page;
public ServerRolePage(PublicServer ps)
{
PageName = "Roles";
Page = new(ps, this)
{
Location = new(0, TitleLable.Size.Y, 0),
Anchor = ObjectAnchor.All
};
Controls.Add(Page);
Globals.ms.ForceUpdate(new(Globals.ms.CS));
}
public override Color4 BackgroundColor
{
get
{
return base.BackgroundColor;
}
set
{
base.BackgroundColor = value;
Page.BackgroundColor = value;
}
}
}

View File

@ -0,0 +1,69 @@
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
using Luski.net;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers;
public class ServerSettings : UserControl
{
private string BehindName;
public ServerSettingPageTab? Selected;
public FlowLayout fl;
public ServerSettings(PublicServer ps)
{
base.BackgroundColor = new(34, 34, 34, 255);
base.Size = Globals.ms.ClientSize;
BehindName = Globals.ms.Title;
Globals.ms.Title = $"Server Settings - Luski";
fl = new()
{
BackgroundColor = new(20, 20, 20, 255),
Size = new(307.ScaleInt(), base.Size.Y),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
};
ServerSettingCategory ssc = new(ps.Name, this);
ServerRolePage srp;
ServerSettingPageTab cb = ssc.AddPage(srp = new(ps)
{
BackgroundColor = base.BackgroundColor
});
Controls.Add(srp);
fl.Controls.Add(ssc);
cb.ToggleSelected().Wait();
Anchor = ObjectAnchor.All;
Controls.Add(fl);
Rectangle closebtn = new(Globals.ms.TextureManager.GetTextureResource("close.png"))
{
Location = new(Globals.ms.ClientSize.X - 40.ScaleInt(), 8.ScaleInt(),0),
Size = new(32.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Gray,
Anchor = ObjectAnchor.Top | ObjectAnchor.Right
};
closebtn.MouseEnter += _ =>
{
closebtn.BackgroundColor = Color4.White;
return Task.CompletedTask;
};
closebtn.MouseLeave += _ =>
{
closebtn.BackgroundColor = Color4.Gray;
return Task.CompletedTask;
};
closebtn.Clicked += ClosebtnOnClicked;
closebtn.ForceDistanceUpdate(this);
Controls.Add(closebtn);
}
private Task ClosebtnOnClicked(IRenderObject arg)
{
Globals.ms.Controls.Remove(this);
Globals.ms.Title = BehindName;
Globals.ms.DrawFrame();
return Task.CompletedTask;
}
}

View File

@ -1,452 +0,0 @@
using System.ComponentModel;
using System.Reflection;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.Classes;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.GUI.MainScreen.UI.SettingsPanel;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI;
public class SettingsMenu : UserControl
{
private string BehindName;
public FlowLayout page;
public CategoryButton? Selected, apper;
private FlowLayout fl;
private Category? AppSettings;
private FontInteraction f;
private DropDown<ThemeDropButton> ThemeDrop;
public SettingsMenu()
{
LuskiExperiments.Settings.Theme.EventToggled += ThemeOnEventToggled;
BehindName = Globals.ms.Title;
Globals.ms.Title = "Settings - Luski";
base.BackgroundColor = new(34, 34, 34, 255);
base.Size = Globals.ms.ClientSize;
Anchor = ObjectAnchor.All;
if (CategoryButton.seltec is null)
{
CategoryButton.seltec = Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png");
}
fl = new()
{
BackgroundColor = new(20, 20, 20, 255),
Size = new(307.ScaleInt(), base.Size.Y),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
};
f = Globals.DefaultFont.Clone();
f.FontSize = FontSize.Bold;
f.PixelHeight = (uint)(f.PixelHeight * 1.4f);
AppSettings = new("APP SETTINGS");
CategoryButton cb3 = new("General", this)
{
OnPageLoad = () =>
{
page!.Controls.Add(new Label(f)
{
Text = " \nGeneral\n "
});
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
{
MemberInfo[] memberInfos =
PropType.GetMember(val.ToString());
MemberInfo? enumValueMemberInfo = memberInfos.FirstOrDefault(m =>
m.DeclaringType == PropType);
object[] valueAttributes =
enumValueMemberInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (valueAttributes.Length == 0) continue;
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, ((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
{
object[] valueAttributes =
prop.GetCustomAttributes(typeof(DescriptionAttribute), false);
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, (bool)PropVal, b =>
{
prop.SetValue(Globals.Settings, b);
Globals.Settings.SaveSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
});
}
catch
{
// ignored
}
}
}
}
};
AppSettings.AddButton(cb3);
fl.Controls.Add(AppSettings);
if (LuskiExperiments.Settings.Theme.IsEnabled())
{
Label Top = new(Globals.DefaultFont)
{
Location = new(5.ScaleInt(), 5.ScaleInt(), 0),
Text = LuskiThemes.Dark.Name
};
CategoryButton cb2 = new("Appearance", this)
{
OnPageLoad = () =>
{
page!.Controls.Add(new Label(f)
{
Text = " \nAppearance\n "
});
ThemeDropButton LightDD;
ThemeDrop = new(CategoryButton.seltec!,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(Top.Location.X, Top.Location.Y, 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] = CategoryButton.seltec!;
}
BlockDraw = false;
return Task.CompletedTask;
};
page!.Controls.Add(ThemeDrop);
}
};
AppSettings.AddButton(cb2);
fl.Controls.Insert(0, AppSettings);
fl.ScrollToBottom();
}
page = new()
{
BackgroundColor = this.BackgroundColor,
Location = new(fl.Size.X + 40.ScaleInt(), 0, 0),
Size = new(Globals.ms.ClientSize.X - fl.Size.X - 80.ScaleInt(), Globals.ms.Size.Y),
AllowHoverFromBehind = true,
Anchor = ObjectAnchor.All,
HScrollPixels = Globals.Settings.PerScrollPixels
};
Controls.Add(page);
void AddBool(string Name, bool s, Action<bool> a)
{
ToggleSwitch ts = new()
{
Value = s
};
UserControl tc = new()
{
Size = ts.Size,
BackgroundColor = page.BackgroundColor
};
Label l;
tc.Controls.Add(l =new Label(Globals.DefaultFont)
{
Text = Name + ": "
});
tc.Size = l.Size;
tc.Controls.Add(ts);
ts.Location = new(l.Size.X + 10.ScaleInt(), 0, 0);
ts.ValueChanged += @switch =>
{
a.Invoke(@switch .Value);
return Task.CompletedTask;
};
page.Controls.Add(tc);
}
page.ForceDistanceUpdate(this);
Category As = new("ADVANCED SETTINGS");
CategoryButton cb = new("Experiments", this)
{
OnPageLoad = () =>
{
page!.Controls.Add(new Label(f)
{
Text = " \nExperiments\n "
});
ExperimentGUI? g = null;
foreach (ExperimentInfo exp in Globals.Experiments)
{
g = new(exp);
page.Controls.Add(g);
}
if (g is not null)
{
g.line.WindowLoaded += _ =>
{
page.ParentResize(new(Globals.ms.ClientSize));
return Task.CompletedTask;
};
}
}
};
CategoryButton us = new("Updater Config", this)
{
OnPageLoad = () =>
{
page!.Controls.Add(new Label(f)
{
Text = " \nUpdater Config\n "
});
TextBox t;
page!.Controls.Add(t =new TextBox()
{
Text = Globals.UpdaterSettings.Updater!,
WatermarkText = "Updater File",
TextureDisplay = TextureDisplay.Center,
Size = new(page.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
{
MemberInfo[] memberInfos =
PropType.GetMember(val.ToString());
MemberInfo? enumValueMemberInfo = memberInfos.FirstOrDefault(m =>
m.DeclaringType == PropType);
object[] valueAttributes =
enumValueMemberInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (valueAttributes.Length == 0) continue;
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, ((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
{
object[] valueAttributes =
prop.GetCustomAttributes(typeof(DescriptionAttribute), false);
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, (bool)PropVal, b =>
{
prop.SetValue(Globals.UpdaterSettings, b);
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
});
}
catch
{
// ignored
}
}
}
t.ForceDistanceUpdate(page);
t.KeyPress += args =>
{
Globals.UpdaterSettings.Updater = t.Text;
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
return Task.CompletedTask;
};
TryDraw();
Globals.ms.ForceUpdate(new(Globals.ms.CS));
}
};
As.AddButton(cb);
As.AddButton(us);
fl.Controls.Add(As);
fl.ForceDistanceUpdate(this);
_ = cb3.ToggleSelected();
Rectangle closebtn = new(Globals.ms.TextureManager.GetTextureResource("close.png"))
{
Location = new(Globals.ms.ClientSize.X - 40.ScaleInt(), 8.ScaleInt(),0),
Size = new(32.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Gray,
Anchor = ObjectAnchor.Top | ObjectAnchor.Right
};
closebtn.MouseEnter += _ =>
{
closebtn.BackgroundColor = Color4.White;
return Task.CompletedTask;
};
closebtn.MouseLeave += _ =>
{
closebtn.BackgroundColor = Color4.Gray;
return Task.CompletedTask;
};
closebtn.Clicked += ClosebtnOnClicked;
closebtn.ForceDistanceUpdate(this);
Controls.Add(closebtn);
Controls.Add(fl);
}
private Task ThemeOnEventToggled(bool arg)
{
if (arg)
{
apper = new("Appearance", this)
{
OnPageLoad = () =>
{
page.Controls.Add(new Label(f)
{
Text = " \nAppearance\n "
});
}
};
AppSettings!.AddButton(apper);
fl.ScrollToBottom();
}
else
{
AppSettings!.RemoveButton(apper);
}
return Task.CompletedTask;
}
private Task ClosebtnOnClicked(IRenderObject arg)
{
Globals.ms.Controls.Remove(this);
Globals.ms.Title = BehindName;
Globals.ms.DrawFrame();
return Task.CompletedTask;
}
}

View File

@ -14,7 +14,7 @@ public class ExperimentDropButton : DropDownOption
public ExperimentSelectorInfo ESI;
public ExperimentDropButton(ExperimentSelectorInfo esi)
:base(CategoryButton.seltec!)
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{
ESI = esi;
base.Size = new(297.ScaleInt(), 40.ScaleInt());
@ -40,7 +40,7 @@ public class ExperimentDropButton : DropDownOption
, 0);
Controls.Add(d);
Controls.Add(l);
BackgroundColor = new(0, 0, 0, 0);
base.BackgroundColor = new(0, 0, 0, 0);
MouseEnter += o =>
{
BackgroundColor = new(141, 151, 165, 30);

View File

@ -48,7 +48,7 @@ public class ExperimentGUI : UserControl
Color = Color4.Gray
};
Controls.Add(n);
BackgroundColor = new(255, 255, 255, 0);
base.BackgroundColor = new(255, 255, 255, 0);
ExperimentDropButton Disabled = new(DisabledESI)
{
LoadDisplay = () =>
@ -66,13 +66,13 @@ public class ExperimentGUI : UserControl
},
Size = new(297.ScaleInt(), 40.ScaleInt())
};
dd = new(CategoryButton.seltec!, new Rectangle()
dd = new(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"), new Rectangle()
{
Size = new(1.ScaleInt()),
BackgroundColor = Color4.Gray
BackgroundColor = Color4.Gray,
}, Disabled)
{
Size = new(40.ScaleInt()),
Size = new(base.Size.X, 40.ScaleInt()),
Location = new(Top.Location.X, n.Location.Y + n.Size.Y + Top.Location.Y, 0),
BackgroundColor = new(40, 40, 40, 255),
Anchor = ObjectAnchor.Right | ObjectAnchor.Left,
@ -94,7 +94,7 @@ public class ExperimentGUI : UserControl
}
else
{
dd.Textures[0] = CategoryButton.seltec!;
dd.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png");
}
BlockDraw = false;
@ -144,8 +144,9 @@ public class ExperimentGUI : UserControl
line.ForceDistanceUpdate(this);
Controls.Add(line);
Controls.Add(Top);
//base.BackgroundColor = new((byte)new Random().Next(255),(byte)new Random().Next(255),(byte)new Random().Next(255),(byte)new Random().Next(255));
}
private Task DdOnOptionSelected(ExperimentDropButton arg)
{
if (arg.ESI == DisabledESI)

View File

@ -14,7 +14,7 @@ public class ThemeDropButton : DropDownOption
public ThemeStart ESI;
public ThemeDropButton(ThemeStart esi)
:base(CategoryButton.seltec!)
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{
ESI = esi;
base.Size = new(297.ScaleInt(), 40.ScaleInt());

View File

@ -2,16 +2,16 @@ using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using GraphicsManager.Enums;
using GraphicsManager.Globals;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.UI;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.GUI.MainScreen.UI.LuskiSettings;
using Luski.GUI.MainScreen.UI.PublicServers;
using Luski.net;
using Luski.net.Structures.Public;
using OpenTK.Graphics.GL;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
@ -21,6 +21,7 @@ using DebugProc = OpenTK.Graphics.OpenGL4.DebugProc;
using DebugSeverity = OpenTK.Graphics.OpenGL4.DebugSeverity;
using DebugSource = OpenTK.Graphics.OpenGL4.DebugSource;
using DebugType = OpenTK.Graphics.OpenGL4.DebugType;
using ErrorCode = OpenTK.Windowing.GraphicsLibraryFramework.ErrorCode;
using Window = GraphicsManager.Window;
namespace Luski.GUI;
@ -43,6 +44,15 @@ public class MainScreenWindow : Window
private FlowLayout? channelpicker, friends, friend_request;
private RoundedButton? FriendManagerBtn;
private static DebugProc DebugMessageDelegate = OnDebugMessage;
private static GLFWCallbacks.ErrorCallback GLFW_Error = OnGLFW_Error;
private static void OnGLFW_Error(ErrorCode e, string d)
{
if ((Globals.Settings.Logs & ConsoleLog.ShowErrorsForGLFW) != ConsoleLog.ShowErrorsForGLFW) return;
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[GLFW Error:{0}] {1}", e, d);
Console.ResetColor();
}
private static void OnDebugMessage(
DebugSource source, // Source of the debugging message.
@ -53,13 +63,14 @@ public class MainScreenWindow : Window
IntPtr pMessage, // Pointer to message string.
IntPtr pUserParam) // The pointer you gave to OpenGL, explained later.
{
string message = Marshal.PtrToStringAnsi(pMessage, length);
string message = string.Empty;
switch (severity)
{
case DebugSeverity.DebugSeverityHigh:
if ((Globals.Settings.Logs & ConsoleLog.BigErrosForOpenGL) == ConsoleLog.BigErrosForOpenGL)
{
message = Marshal.PtrToStringAnsi(pMessage, length);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
Console.ResetColor();
@ -69,6 +80,7 @@ public class MainScreenWindow : Window
case DebugSeverity.DebugSeverityMedium:
if ((Globals.Settings.Logs & ConsoleLog.MediumErrosForOpenGL) == ConsoleLog.MediumErrosForOpenGL)
{
message = Marshal.PtrToStringAnsi(pMessage, length);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
Console.ResetColor();
@ -77,6 +89,7 @@ public class MainScreenWindow : Window
case DebugSeverity.DebugSeverityLow:
if ((Globals.Settings.Logs & ConsoleLog.LowErrosForOpenGL) == ConsoleLog.LowErrosForOpenGL)
{
message = Marshal.PtrToStringAnsi(pMessage, length);
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
Console.ResetColor();
@ -85,6 +98,7 @@ public class MainScreenWindow : Window
default:
if ((Globals.Settings.Logs & ConsoleLog.InfoForOpenGL) == ConsoleLog.InfoForOpenGL)
{
message = Marshal.PtrToStringAnsi(pMessage, length);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(message);
Console.ResetColor();
@ -104,6 +118,7 @@ public class MainScreenWindow : Window
GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero);
GL.Enable(EnableCap.DebugOutput);
GLFW.SetErrorCallback(GLFW_Error);
try
{
Globals.DefaultFontFamly = FontFamily.LoadFontFamily(Globals.GetResource("Fonts.OpenSans.zip"), "OpenSans");
@ -134,8 +149,11 @@ public class MainScreenWindow : Window
Globals.DefaultFont.PixelHeight = Globals.Settings.DefaultFontPX.ScaleFont();
Globals.DefaultFont.FontSize = FontSize.Regular;
Globals.TopTimeFont = Globals.DefaultFont.Clone();
Globals.TopTimeFont.PixelHeight = Globals.Settings.TopTimeFonttPX.ScaleFont();
Globals.TopTimeFont.PixelHeight = Globals.Settings.TopTimeFontPX.ScaleFont();
Globals.TopTimeFont.FontSize = FontSize.Regular;
Globals.ServerRoleFont = Globals.DefaultFont.Clone();
Globals.ServerRoleFont.PixelHeight = Globals.Settings.RoleSettingsFontPX.ScaleFont();
Globals.ServerRoleFont.FontSize = FontSize.Regular;
Globals.MessageFont = Globals.DefaultFont.Clone();
Globals.MessageFont.PixelHeight = Globals.Settings.MessageFontPX.ScaleFont();
Globals.MessageFont.ExtraLinePixels = Globals.Settings.MessageFontLineSpacePX.ScaleFont();
@ -211,6 +229,38 @@ public class MainScreenWindow : Window
SerBox.Controls.Clear();
#endregion
#region Server Title
UserControl ServerTitle = new()
{
Size = new(307.ScaleInt(), 46.ScaleInt()),
BackgroundColor = new(30, 30, 30, 255)
};
Label title = new(Globals.DefaultFont)
{
Text = Server.Name,
IgnoreHover = true
};
if (await Server.User.HasPermissions(ServerPermission.ManageRoles))
{
ServerTitle.Clicked += o =>
{
ServerSettings sm = new(Server);
Controls.Add(sm);
Globals.ms.DrawFrame();
Globals.ms.ForceUpdate(new(Globals.ms.CS));
Globals.ms.DrawFrame();
return Task.CompletedTask;
};
title.Color = Color4.Green;
}
title.Location = new(5.ScaleInt(), (int)((ServerTitle.Size.Y - title.LineHeight) / 2), 0);
ServerTitle.Controls.Add(title);
ServerTitle.ForceDistanceUpdate(SerBox);
SerBox.Controls.Add(ServerTitle);
#endregion
#region Channel Selector Init
@ -227,7 +277,8 @@ public class MainScreenWindow : Window
parents.Reverse();
ChannelSelector cs = await ChannelSelector.MakeSelector(parents[0]);
cs.BackgroundColor = new(34, 34, 34, 255);
cs.Size = new(307.ScaleInt(), SerBox.Size.Y - 54.ScaleInt());
cs.Location = new(0, ServerTitle.Size.Y +2.ScaleInt(), 0);
cs.Size = new(ServerTitle.Size.X, SerBox.Size.Y - 54.ScaleInt() - cs.Location.Y);
cs.Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom;
parents.RemoveAt(0);
@ -263,7 +314,7 @@ public class MainScreenWindow : Window
ServerProfile DefaultProfile = await Server.GetProfile(Server.User.ServerProfile, CancellationToken.None);
IRenderObject u = await DefaultProfile.MakeRct(Server.User, new(46.ScaleInt()));
int ii = 4.ScaleInt();
u.Location = new(ii, cs.Size.Y + ii, 0);
u.Location = new(ii, cs.Location.Y + cs.Size.Y + ii, 0);
u.Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left;
SerBox.Controls.Add(u);
u.LoadToParent(SerBox, this);
@ -303,7 +354,7 @@ public class MainScreenWindow : Window
SerBox.Controls.Add(ul);
Rectangle setting = new(TextureManager.GetTextureResource("settings.png"))
{
Location = new(cs.Size.X - 40.ScaleInt(), cs.Size.Y + 11.ScaleInt(),0),
Location = new(cs.Size.X - 40.ScaleInt(), cs.Location.Y + cs.Size.Y + 11.ScaleInt(),0),
Size = new(32.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Context],
BackgroundColor = Color4.Gray,
@ -406,6 +457,7 @@ public class MainScreenWindow : Window
private async Task<Task> LoginOnChangeToApp()
{
Controls.Clear();
ForceUpdate(new(ClientSize));
BlockDraw = true;
Title = "Luski";
unsafe

View File

@ -1,15 +1,18 @@
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.Classes;
using Luski.Classes.ThemeSub;
using Luski.GUI;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net;
using Luski.net.Enums;
using Luski.net.Interfaces;
@ -176,7 +179,7 @@ public static class Globals
ExperimentInfo[] experimentInfos = found as ExperimentInfo[] ?? found.ToArray();
if (experimentInfos.Count() > 0)
{
if (!EnabledExperiments.Contains(EI)) EnabledExperiments.Add(experimentInfos[0]);
if (!EnabledExperiments.Contains(experimentInfos[0])) EnabledExperiments.Add(experimentInfos[0]);
experimentInfos[0].Selected = experiment.Selected;
}
else
@ -247,12 +250,120 @@ public static class Globals
public static bool Download { get; set; } = false;
public static API Luski { get; } = new();
public static MainScreenWindow ms;
public static void AddBool(IParent parent, string Name, string description, bool s, Action<bool> a, List<Label>? List = null)
{
ToggleSwitch ts = new()
{
Value = s,
Anchor = ObjectAnchor.Top | ObjectAnchor.Right
};
UserControl tc = new()
{
BackgroundColor = new(0,0,0,0)
};
Label l, ll;
int space = 5.ScaleInt();
tc.Controls.Add(ll =new Label(Globals.DefaultFont)
{
Location = new(0, space + space, 0),
Text = Name
});
tc.Controls.Add(l =new Label(Globals.DefaultFont)
{
Location = new(ll.Location.X, ll.Size.Y + space, 0),
Color = Color4.Gray,
MaxSize = parent.Size,
Text = description
});
if (List is not null) List.Add(l);
tc.Size = l.Size;
tc.Controls.Add(ts);
ts.Location = new(parent.Size.X - ts.Size.X - 5.ScaleInt(), ll.Location.Y, 0);
Rectangle TempLine = new()
{
Location = new(0, l.Location.Y + l.Size.Y + space, 0),
BackgroundColor = Color4.White,
Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Top
};
l.Tag = TempLine;
TempLine.Size = new(parent.Size.X - space - space, 2.ScaleInt());
tc.Size = new(parent.Size.X, TempLine.Location.Y + TempLine.Size.Y);
TempLine.ForceDistanceUpdate(tc);
tc.Controls.Add(TempLine);
//ts.ForceDistanceUpdate(tc);
ts.ValueChanged += @switch =>
{
a.Invoke(@switch.Value);
return Task.CompletedTask;
};
tc.ForceDistanceUpdate(parent);
parent.Controls.Add(tc);
}
public static void AddBool<TEnum>(IParent parent, Type t, TEnum e, bool s, Action<bool> a, List<Label>? List = null) where TEnum : Enum
{
MemberInfo? enumValueMemberInfo = GetMemberInfo(t, e);
object[] valueAttributes =
enumValueMemberInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (valueAttributes.Length == 0) return;
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
object[] namevalueAttributes =
enumValueMemberInfo.GetCustomAttributes(typeof(Luski.Shared.GlobalAttributes.DisplayNameAttribute), false);
if (namevalueAttributes.Length == 0) return;
string Name = ((Luski.Shared.GlobalAttributes.DisplayNameAttribute)namevalueAttributes[0]).DisplayName;
AddBool(parent, Name, description,s,a,List);
}
public static void AddBool(IParent parent, PropertyInfo t, bool s, Action<bool> a, List<Label>? List = null)
{
object[] valueAttributes =
t.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (valueAttributes.Length == 0) return;
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
object[] namevalueAttributes =
t.GetCustomAttributes(typeof(Luski.Shared.GlobalAttributes.DisplayNameAttribute), false);
if (namevalueAttributes.Length == 0) return;
string Name = ((Luski.Shared.GlobalAttributes.DisplayNameAttribute)namevalueAttributes[0]).DisplayName;
AddBool(parent, Name, description,s,a,List);
}
public static TAttribute GetAttribute<TAttribute, TEnum>(Type t, TEnum e) where TAttribute : Attribute where TEnum : Enum
{
MemberInfo? enumValueMemberInfo = GetMemberInfo(t, e);
object[] valueAttributes =
enumValueMemberInfo!.GetCustomAttributes(typeof(TAttribute), false);
return (TAttribute)valueAttributes[0];
}
public static TAttribute GetAttribute<TAttribute, TEnum>(MemberInfo enumValueMemberInfo, TEnum e) where TAttribute : Attribute where TEnum : Enum
{
object[] valueAttributes =
enumValueMemberInfo.GetCustomAttributes(typeof(TAttribute), false);
return (TAttribute)valueAttributes[0];
}
public static MemberInfo? GetMemberInfo<TEnum>(Type t, TEnum e) where TEnum : Enum
{
MemberInfo[] memberInfos =
t.GetMember(e.ToString());
MemberInfo? enumValueMemberInfo = memberInfos.FirstOrDefault(m =>
m.DeclaringType == t);
return enumValueMemberInfo;
}
public static Color4 ToColor4(this Color col)
{
return new(col.R, col.G, col.B, col.A);
}
public static Color4 ToColor4(this Color? col)
{
return new(col!.Value.R, col.Value.G, col.Value.B, col.Value.A);
}
public static Color ToColor(this Color4 col)
{
return new((byte)(col.R*byte.MaxValue), (byte)(col.G*byte.MaxValue), (byte)(col.B*byte.MaxValue), (byte)(col.A*byte.MaxValue));
@ -311,9 +422,10 @@ public static class Globals
r.BackgroundColor = new(25, 25, 25, 255);
Label l = new(DefaultFont)
{
Color = new(255,255,255,255)
Color = new(255,255,255,255),
IgnoreHover = true,
Text = Server.Name[0].ToString()
};
l.Text = Server.Name[0].ToString();
var y = l.GetSizeOfChar(0);
l.Location = new((r.Size.X - l.Size.X)/2,
(int)(r.Size.Y - (l.Font.PixelHeight - y.Y) - (r.Size.Y / 2) - (y.Y/2)),
@ -355,6 +467,7 @@ public static class Globals
public static FontFamily DefaultFontFamly { get; set; }
public static FontInteraction DefaultFont { get; set; }
public static FontInteraction ServerRoleFont { get; set; }
public static FontInteraction TopTimeFont { get; set; }
public static FontInteraction MessageFont { get; set; }
public static FontInteraction SmallTimeFont { get; set; }

View File

@ -7,6 +7,7 @@
<Nullable>enable</Nullable>
<FileVersion>0.0.0.1</FileVersion>
<Company>JacobTech, LLC</Company>
<ApplicationIcon>Luski.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
@ -21,18 +22,25 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha72" />
<PackageReference Include="Luski.net" Version="2.0.0-alpha98" />
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha83" />
<PackageReference Include="Luski.net" Version="2.0.1-alpha04" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources/**"></EmbeddedResource>
<EmbeddedResource Include="Resources/**" />
</ItemGroup>
<ItemGroup>
<Folder Include="GUI\Windows\" />
</ItemGroup>
<ItemGroup>
<None Remove="Luski.ico" />
<Resource Include="Luski.ico">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<PropertyGroup>
<ApplicationIcon>Luski.ico</ApplicationIcon>

View File

@ -10,11 +10,11 @@ public static class LuskiExperiments
Parents.ThemeEdit,
new()
{
DisplayName = "Proper Message Label Size",
DisplayName = "Proper Label Size",
Name = "2024_04_label_size",
Options = new()
{
GUI.MessageLiveSize
GUI.LiveLabelSize
}
}
};
@ -69,10 +69,10 @@ public static class LuskiExperiments
public static class GUI
{
public static readonly ExperimentSelectorInfo MessageLiveSize = new()
public static readonly ExperimentSelectorInfo LiveLabelSize = new()
{
Name = "Proper Label Size",
Description = "Live updates messages to be the right length during resize.", RequiresRestart = false
Description = "Live updates labels to be the right length during resize.", RequiresRestart = false
};
}
}

View File

@ -72,6 +72,7 @@ try
Globals.Icon = new WindowIcon(new Image(Logo.Width, Logo.Height, pixels));
Logo.Dispose();
MainScreenWindow.Settings.Icon = Globals.Icon;
Globals.ms = new MainScreenWindow();
Globals.ms.CustomF11 = false;
Globals.ms.DrawFrame();