Merge pull request 'dev' (#21) from dev into main

Reviewed-on: #21
This commit is contained in:
JacobTech 2024-08-27 11:00:45 -04:00
commit 76ec58a595
53 changed files with 1783 additions and 543 deletions

View File

@ -75,7 +75,7 @@ public class Settings
Label._characters[Globals.ms.Context][Globals.TopTimeFont].Clear();
Label._characters[Globals.ms.Context][Globals.SmallTimeFont].Clear();
Globals.ms.ForceUpdate(new(Globals.ms.ClientSize));
Globals.ms.ForceUpdate();
Globals.ms.DrawFrame();
}
}
@ -98,7 +98,7 @@ public class Settings
[JsonInclude]
[Shared.GlobalAttributes.DisplayName("24 Hour Time")]
[Description("shows time in the 24 hour format")]
[Description("Shows time in the 24 hour format")]
[JsonPropertyName("24hour_time")]
public bool DayTime
{
@ -113,12 +113,32 @@ public class Settings
}
}
[JsonInclude]
[Shared.GlobalAttributes.DisplayName("Memory Fonts")]
[Description("Stores fonts in memory for faster load times")]
[JsonPropertyName("memory_fonts")]
public bool StoreFontsInMemory
{
get
{
return _MemoryFonts;
}
set
{
_MemoryFonts = value;
//GraphicsManager.Objects.Core.FontFamily.MemoryFont = value;
//if (DayTimeChanged is not null) DayTimeChanged.Invoke();
}
}
[JsonIgnore]
private bool _ScaleFonts = true;
[JsonIgnore]
private ConsoleLog _Logs = (ConsoleLog)(-25);
[JsonIgnore]
private bool _DayTime = false;
[JsonIgnore]
private bool _MemoryFonts= false;
public event Func<Task>? DayTimeChanged;
}

View File

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

8
Luski/Enums/FontCode.cs Normal file
View File

@ -0,0 +1,8 @@
namespace Luski.Enums;
public enum FontCode : byte
{
Size,
Italics,
Height
}

7
Luski/Enums/GradType.cs Normal file
View File

@ -0,0 +1,7 @@
namespace Luski.Enums;
public enum GradType : byte
{
Block,
Line
}

10
Luski/Enums/TextCode.cs Normal file
View File

@ -0,0 +1,10 @@
namespace Luski.Enums;
public enum TextCode
{
Rainbow,
Gradient,
Color,
Font,
url
}

View File

@ -17,7 +17,7 @@ public class AccountButton : UserControl
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{
this.SM = SM;
base.Size = new(297.ScaleInt(), 40.ScaleInt());
base.SetSize(297.ScaleInt(), 40.ScaleInt());
TextureDisplay = TextureDisplay.HorizontalCenter;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
l = new Label(Globals.DefaultFont)
@ -26,9 +26,8 @@ public class AccountButton : UserControl
Color = Color4.Gray,
IgnoreHover = true,
};
l.Location = new((base.Size.X / 2) - (l.Size.X / 2),
((base.Size.Y - l.Size.Y) / 2)
, 0);
l.SetLocation((base.Size.X / 2) - (l.Size.X / 2),
((base.Size.Y - l.Size.Y) / 2));
Controls.Add(l);
base.BackgroundColor = new(0, 0, 0, 0);
Clicked += OnClicked;
@ -82,7 +81,7 @@ public class AccountButton : UserControl
SM.Selected = this;
SM.page.Controls.Clear();
OnPageLoad.Invoke();
Globals.ms.ForceUpdate(new(Globals.ms.CS));
Globals.ms.ForceUpdate();
}
BlockDraw = false;

View File

@ -18,6 +18,6 @@ public class AddServerIcon : UserControl
};
Controls.Add(Button);
base.BackgroundColor = new(26, 26, 26, 255);
base.Size = new(68.ScaleInt(), 48.ScaleInt());
base.SetSize(68.ScaleInt(), 48.ScaleInt());
}
}

View File

@ -108,7 +108,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
return Task.CompletedTask;
};
tb.Size = new(Form.Size.X - tb.Location.X - tb.Location.X - tb.Location.X - s.X, tb.Size.Y);
tb.SetSize(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)
{
@ -475,7 +475,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
DisplayName = null!;
rec = null!;
tb.Focus();
Globals.ms.ForceUpdate(new(Globals.ms.CS));
Globals.ms.ForceUpdate();
TryDraw();
}
};
@ -600,7 +600,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
private string pfp = "";
private Task RecOnFilesDroped(string[] arg)
private Task RecOnFilesDroped(IRenderObject obj, string[] arg)
{
Console.WriteLine(arg[0]);
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;

View File

@ -0,0 +1,131 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects.Core;
using GraphicsManager.Structs;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class AdvancedGradientLabel : LabelBase
{
public AdvancedGradientLabel(FontInteraction fi) : base(fi) { }
public Color4[] Colors { get; set; } = new[]
{
new Color4(255, 255, 255, 255),
new Color4(255, 255, 255, 255)
};
protected virtual (Color4,Color4) getcols(int charter)
{
Vector2i cl = GetCharLocation(charter);
Vector2i cs = GetSizeOfChar(charter);
return new(getcol(cl.X), getcol(cl.X + cs.X));
}
protected virtual Color4 getcol(int pos)
{
float travel = (float)Size.X/(Colors.Length - 1);
int i = 1;
while (travel * i < pos)
{
i++;
}
i--;
float t = Math.Clamp((pos-(travel*i))/travel, 0, 1);
Color4 LeftColor = Colors[i], RightColor = Colors[i + 1];
float r = LeftColor.R + (RightColor.R - LeftColor.R) * t;
float g = LeftColor.G + (RightColor.G - LeftColor.G) * t;
float b = LeftColor.B + (RightColor.B - LeftColor.B) * t;
float a = LeftColor.A + (RightColor.A - LeftColor.A) * t;
return new Color4(r, g, b, a);
}
public override void LoadToParent(IParent window, IWindow win)
{
if (Loaded) return;
if (Shader is null) Shader = Globals.GradientShader[win.Context];
base.LoadToParent(window, win);
}
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)
{
if (!Window!.Context.IsCurrent) Window.Context.MakeCurrent();
Shader.Use();
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
GL.BlendFunc(0, BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
Shader.SetMatrixF4("projection", Window.WindowSizeMatrix);
GL.BindVertexArray(VAO);
float angle_rad = (float)Math.Atan2(DIR.Y, DIR.X);
Matrix4 rotateM = Matrix4.CreateRotationZ(angle_rad);
Matrix4 transOriginM = Matrix4.CreateTranslation(new Vector3(loc_.X + Parent!.IntToWindow(0), loc_.Y + (Font.PixelHeight * Scale) + Parent!.IntToWindow(0, true), 0f));
float char_x = 0.0f;
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
GL.ActiveTexture((Shader.GetUniformLocation("u_texture") switch
{
0 => TextureUnit.Texture0,
1 => TextureUnit.Texture1,
2 => TextureUnit.Texture2,
3 => TextureUnit.Texture3,
4 => TextureUnit.Texture4,
5 => TextureUnit.Texture5,
6 => TextureUnit.Texture6,
7 => TextureUnit.Texture7,
8 => TextureUnit.Texture8,
9 => TextureUnit.Texture9,
}));
float hhh = 0f;
for (int i = 0; i < text_Calculated.Length; i++)
{
var col = getcols(i);
GL.Uniform4(Shader.GetUniformLocation("textColor"), col.Item1);
GL.Uniform4(Shader.GetUniformLocation("rightColor"), col.Item2);
char c;
if (PasswordChar is null)
c = text_Calculated[i];
else
c = PasswordChar.Value;
bool n = (c == '\n');
if (!_characters[Window!.Context][Font].ContainsKey(c) && !n)
{
_ = Texture.TextureForChar(Window!.Context, Font, c, Shader);
}
if (n)
{
hhh += LineHeight;
hhh += Font.ExtraLinePixels;
char_x = 0f;
}
else
{
if (!_characters[Window!.Context][Font].ContainsKey(c)) continue;
Character ch = _characters[Window!.Context][Font][c];
float w = ch.Size.X * Scale;
float h = ch.Size.Y * Scale;
float xrel = char_x + ch.Bearing.X * Scale;
float yrel = (ch.Size.Y - ch.Bearing.Y) * Scale;
yrel += hhh;
char_x += (ch.Advance >> 6) * Scale;
Matrix4 scaleM = Matrix4.CreateScale(new Vector3(w, h, 1.0f));
Matrix4 transRelM = Matrix4.CreateTranslation(new Vector3(xrel, yrel, 0.0f));
Matrix4 modelM = scaleM * transRelM * rotateM * transOriginM;
GL.UniformMatrix4(Shader.GetUniformLocation("model"), false, ref modelM);
ch.Texture.Use();
GL.DrawArrays(PrimitiveType.Triangles, 0, 6);
}
}
}
}
}

View File

@ -0,0 +1,34 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using GraphicsManager.Structs;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class BasicGradientLabel : AdvancedGradientLabel
{
public BasicGradientLabel(FontInteraction fi) : base(fi) { }
public Color4 LeftColor
{
get => Colors[0];
set => Colors[0] = value;
}
public Color4 RightColor
{
get => Colors[1];
set => Colors[1] = value;
}
protected override Color4 getcol(int pos)
{
float t = Math.Clamp(pos/(float)Size.X, 0, 1);
float r = LeftColor.R + (RightColor.R - LeftColor.R) * t;
float g = LeftColor.G + (RightColor.G - LeftColor.G) * t;
float b = LeftColor.B + (RightColor.B - LeftColor.B) * t;
float a = LeftColor.A + (RightColor.A - LeftColor.A) * t;
return new Color4(r, g, b, a);
}
}

View File

@ -0,0 +1,88 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class CompressedFlow : UserControl
{
public CompressedFlow()
{
Controls.ControlAfterAdded += ControlsOnControlAdded;
Controls.ControlRemoved += ControlsOnControlRemoved;
SizeChanged += OnSizeChanged;
Padding = new(5.ScaleInt());
ChildPadding = new(Padding.X);
}
public event Func<IRenderObject, Task>? SizeUpdateNotIgnored;
public Vector4i Padding { get; set; }
public Vector2i ChildPadding { get; set; }
private bool IgnoreNextSizeChange;
private Task OnSizeChanged(IRenderObject arg)
{
if (IgnoreNextSizeChange)
{
IgnoreNextSizeChange = false;
return Task.CompletedTask;
}
UpdateControlesFromIndex(0);
return Task.CompletedTask;
}
private Task ControlsOnControlRemoved()
{
UpdateControlesFromIndex(0);
return Task.CompletedTask;
}
private Task ControlsOnControlAdded(int arg1, IRenderObject arg2)
{
if (arg1 != 0)
{
if (arg1 + 1 < Controls.Length)arg2.Location = Controls[arg1 + 1].Location;
}
else
{
arg2.Location = new(Padding.X, Padding.Y, 0);
}
UpdateControlesFromIndex(arg1);
return Task.CompletedTask;
}
private void UpdateControlesFromIndex(int index)
{
if (Controls.Length == 0)
{
IgnoreNextSizeChange = true;
Size = new(Size.X, 0);
if (SizeUpdateNotIgnored is not null) _ = SizeUpdateNotIgnored.Invoke(this);
return;
}
if (index == 0) index++;
for (int i = index; i < Controls.Length; i++)
{
if (Controls[i-1].Location.X + Controls[i-1].Size.X + Padding.Z + Controls[i].Size.X + ChildPadding.X > Size.X)
{
Controls[i].Location = new(Padding.X,
Controls[i - 1].Location.Y + Controls[i - 1].Size.Y + ChildPadding.Y, 0);
}
else
{
Controls[i].Location = new(ChildPadding.X + Controls[i - 1].Location.X + Controls[i - 1].Size.X,
Controls[i - 1].Location.Y, 0);
}
}
if (Controls[Controls.Length - 1].Location.Y + Controls[Controls.Length - 1].Size.Y + Padding.W != Size.Y)
{
IgnoreNextSizeChange = true;
Size = new(Size.X,
Controls[Controls.Length - 1].Location.Y + Controls[Controls.Length - 1].Size.Y + Padding.W);
if (SizeUpdateNotIgnored is not null) _ = SizeUpdateNotIgnored.Invoke(this);
}
}
}

View File

@ -0,0 +1,64 @@
using GraphicsManager.Objects;
using Luski.net;
using Luski.net.Structures.Public;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class FileUpload : UserControl
{
public long? FileID;
private PublicServer? PublicServer;
private MainServer? MainServer;
private string Path = "";
public SocketFile? PublicSF;
private void INIT(string FilePath)
{
Path = FilePath;
FileInfo FI = new(FilePath);
string fst = "";
ulong size = (ulong)FI.Length;
if (size < 1000)
fst = size + " bytes";
else if (size < 1000000)
fst = Math.Round(size / (double)1000, 2) + " KB";
else if (size < 1000000000)
fst = Math.Round(size / (double)1000000, 2) + " MB";
else if (size < 1000000000000) fst = Math.Round(size / (double)1000000000, 2) + " GB";
Label fileNameLabel, fileSizeLabel;
base.Size = new(333.ScaleInt(), 66.ScaleInt());
base.BackgroundColor = new(40, 40, 40, 255);
Controls.Add(fileSizeLabel = new Label(Globals.DefaultFont) { Text = fst, Location = new(64, 39, 0) });
Controls.Add(fileNameLabel = new Label(Globals.DefaultFont)
{
Color = new(102 / (float)255, 227 / (float)255, 170 / (float)255, 1), Text = FI.Name,
Location = new(64, 6, 0)
});
if (fileSizeLabel.Size.X > fileNameLabel.Size.X)
base.Size = new(fileSizeLabel.Location.X + fileSizeLabel.Size.X + 5.ScaleInt(), base.Size.Y);
else
base.Size = new(fileNameLabel.Location.X + fileNameLabel.Size.X + 5.ScaleInt(), base.Size.Y);
}
public FileUpload(PublicServer ps, string FilePath)
{
INIT(FilePath);
PublicServer = ps;
}
public FileUpload(MainServer ms, string FilePath)
{
INIT(FilePath);
MainServer = ms;
}
public async Task StartUpload()
{
if (FileID is not null) return;
if (PublicServer is not null)
{
PublicSF = await PublicServer.UploadFile(Path);
return;
}
}
}

View File

@ -0,0 +1,741 @@
using System.Diagnostics;
using System.Text;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using GraphicsManager.Structs;
using Luski.Enums;
using Luski.net.Structures.Public;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common.Input;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class LuskiLabel : LabelBase
{
public LuskiLabel() : this(Globals.DefaultFont) { }
public LuskiLabel(FontInteraction fi) : base(fi) { }
public Color4 DefaultColor { get; set; } = Color4.White;
public override void LoadToParent(IParent window, IWindow win)
{
if (Loaded) return;
if (Shader is null) Shader = Globals.GradientShader[win.Context];
base.LoadToParent(window, win);
}
protected virtual (Color4,Color4) getGradcols(int Start, int charter, int End, int StartLine, int Line, int EndLine, GradType GT, Color4[] Colors)
{
Vector2i cl = GetCharLocation(charter);
Vector2i cs = GetSizeOfChar(charter);
Vector2i cls = GetCharLocation(Start);
Vector2i cle = GetCharLocation(End);
Vector2i cse = GetSizeOfChar(End);
if (GT == GradType.Line && StartLine != EndLine)
{
for (int i = StartLine; i < EndLine; i++)
{
Vector2i dis = new(MaxLineSizes[i].Item1.X, 0);
if (i == StartLine) dis -= new Vector2i(cls.X, 0);
cle += dis;
if (i < Line) cl += dis;
}
}
else if (GT == GradType.Block && StartLine != EndLine)
{
cls = new(0, cl.Y);
int longest = MaxLineSizes[StartLine].Item1.X;
for (int i = StartLine+1; i <= EndLine; i++)
{
if (MaxLineSizes[i].Item1.X > longest) longest = MaxLineSizes[i].Item1.X;
}
cse = new(0);
cle = new(longest, cle.X);
}
return new(getGradcol(cls.X, cl.X, cle.X + cse.X, Colors), getGradcol(cls.X, cl.X + cs.X, cle.X + cse.X, Colors));
}
protected virtual Color4 getGradcol(int Start, int pos, int End, Color4[] Colors)
{
pos -= Start;
End -= Start;
float travel = (float)End/(Colors.Length - 1);
int i = 1;
while (travel * i < pos)
{
i++;
}
i--;
float t = Math.Clamp((pos-(travel*i))/travel, 0, 1);
Color4 LeftColor, RightColor;
try
{
LeftColor = Colors[i];
RightColor = Colors[i + 1];
}
catch (Exception e)
{
LeftColor = Color4.DarkRed;
RightColor = Color4.DarkRed;
}
float r = LeftColor.R + (RightColor.R - LeftColor.R) * t;
float g = LeftColor.G + (RightColor.G - LeftColor.G) * t;
float b = LeftColor.B + (RightColor.B - LeftColor.B) * t;
float a = LeftColor.A + (RightColor.A - LeftColor.A) * t;
return new Color4(r, g, b, a);
}
List<Tuple<TextCode, int, int, object?>> Commands = new();
public string PlainText { get; protected set; } = string.Empty;
private List<(Vector2i, FontInteraction)> MaxLineSizes = new();
public override string Text
{
get => base.Text;
set
{
if (value is null) value = string.Empty;
text = value;
text_Calculated = string.Empty;
PlainText = string.Empty;
MaxLineSizes.Clear();
float max_x = 0, lines = 1, char_x = 0F;
int len = Text.Length;
bool use_slash = true, usebrac = true;
List<int> Rainbow_End = new();
List<int> Gradient_End = new();
List<int> Color_End = new();
List<int> Font_Starts = new();
List<int> Link_Starts = new();
Commands.Clear();
List<(GradType, int)> RainGrad = new();
List<(Color4[], GradType, int)> Grad = new();
List<Color4> ccccc = new();
List<bool> Itilacs = new();
List<FontSize> Fonts = new();
List<uint> Sizes = new();
List<string> Links = new();
FontInteraction Current = Font;
FontInteraction? Largest = null;
int LastFontEnd = 0;
StringBuilder sb = new();
uint lh = 0;
float lw = 0;
uint max_lh = 0;
for (int i = 0; i < len; i++)
{
char c;
if (PasswordChar is null)
c = Text[i];
else
c = PasswordChar.Value;
bool n = (c == '\n');
if (Text[i] == '\\' && use_slash)
{
if (i + 1 < len)
{
char tm = Text[i + 1];
if (tm == '\\')
{
use_slash = false;
continue;
}
if (tm == '[')
{
usebrac = false;
continue;
}
}
}
try
{
if (usebrac && Text[i] == '[')
{
int brack = Text.IndexOf(']', i);
string com = Text[(i + 1)..(brack )].Replace("\" ", "\"");
while (com.Contains(" "))
{
com = com.Replace(" ", " ");
}
string[] args = com.Split('=', '"', ' ');
FontInteraction tmp;
if (args[0][0] != '/')
{
switch (args[0])
{
case "rainbow":
Rainbow_End.Add(sb.Length);
GradType rgt = GradType.Line;
for (int j = 1; j < args.Length-2; j+=3)
{
switch (args[j])
{
case "type":
rgt = (GradType)byte.Parse(args[j + 2]);
break;
}
}
RainGrad.Add(new(rgt, (int)lines-1));
i = brack;
continue;
case "gradient":
List<Color> cols = new();
Gradient_End.Add(sb.Length);
GradType gt = GradType.Line;
for (int j = 1; j < args.Length-2; j+=3)
{
Console.WriteLine(args[j]);
switch (args[j])
{
case "colors":
for (int w = 0; w < args[j+2].Length - 7; w+=8)
{
cols.Add(new(args[j+2][w..(w+8)]));
}
break;
case "type":
gt = (GradType)byte.Parse(args[j + 2]);
break;
}
}
Grad.Add(new(cols.ToArray().ToColor4Array(), gt, (int)lines-1));
i = brack;
continue;
case "color":
i = brack;
Color_End.Add(sb.Length);
Color col = new(args[2].Replace("#", ""));
ccccc.Add(col.ToColor4());
i = brack;
continue;
case "fontsize":
FontSize fs = (FontSize)int.Parse(args[2]);
tmp = Current.Clone();
tmp.FontSize = fs;
if (Fonts.Count != 0 || Itilacs.Count != 0 || Sizes.Count != 0)
{
int pos = Font_Starts.Count - 1;
int last_Start = Font_Starts[pos];
int end = sb.Length - 1;
if (end != -1 && last_Start != end)
Commands.Add(new(TextCode.Font, last_Start, end, Current));
Font_Starts.RemoveAt(pos);
}
Fonts.Add(fs);
Font_Starts.Add(sb.Length);
Current = tmp;
i = brack;
continue;
case "px":
uint ph = uint.Parse(args[2]);
tmp = Current.Clone();
tmp.PixelHeight = ph;
if (Fonts.Count != 0 || Itilacs.Count != 0 || Sizes.Count != 0)
{
int pos = Font_Starts.Count - 1;
int last_Start = Font_Starts[pos];
int end = sb.Length - 1;
if (end != -1 && last_Start != end)
Commands.Add(new(TextCode.Font, last_Start, end, Current));
Font_Starts.RemoveAt(pos);
}
i = brack;
Sizes.Add(ph);
Font_Starts.Add(sb.Length);
Current = tmp;
i = brack;
continue;
case "url":
Link_Starts.Add(i);
Links.Add(args[2]);
i = brack;
continue;
case "i":
tmp = Current.Clone();
tmp.Italic = true;
if (Fonts.Count != 0 || Itilacs.Count != 0 || Sizes.Count != 0)
{
int pos = Font_Starts.Count - 1;
int last_Start = Font_Starts[pos];
int end = sb.Length - 1;
if (end != -1 && last_Start != end)
Commands.Add(new(TextCode.Font, last_Start, end, Current));
Font_Starts.RemoveAt(pos);
}
Itilacs.Add(true);
Font_Starts.Add(sb.Length);
Current = tmp;
i = brack;
continue;
}
}
else
{
if (com == "/rainbow")
{
if (Rainbow_End.Count == 0)
{
i = brack;
continue;
}
(GradType, int) cc = RainGrad[RainGrad.Count - 1];
Commands.Add(new(TextCode.Rainbow, Rainbow_End[Rainbow_End.Count-1], sb.Length-1, new Tuple<GradType, int, int>(cc.Item1, cc.Item2, (int)lines-1)));
Rainbow_End.RemoveAt(Rainbow_End.Count-1);
i = brack;
continue;
}
if (com == "/gradient")
{
if (Gradient_End.Count == 0)
{
i = brack;
continue;
}
var cc = Grad[Grad.Count - 1];
Commands.Add(new(TextCode.Gradient, Gradient_End[Gradient_End.Count-1], sb.Length-1, new Tuple<Color4[], GradType, int, int>(cc.Item1, cc.Item2, cc.Item3, (int)lines-1)));
Gradient_End.RemoveAt(Gradient_End.Count-1);
Grad.RemoveAt(Grad.Count-1);
i = brack;
continue;
}
if (com == "/color")
{
if (ccccc.Count == 0)
{
i = brack;
continue;
}
Commands.Add(new(TextCode.Color, Color_End[Color_End.Count-1], sb.Length-1, ccccc[ccccc.Count-1]));
Color_End.RemoveAt(Color_End.Count-1);
ccccc.RemoveAt(ccccc.Count-1);
i = brack;
continue;
}
if (com == "/url")
{
Commands.Add(new(TextCode.url, Link_Starts[Link_Starts.Count-1], sb.Length-1, Links[Links.Count-1]));
Link_Starts.RemoveAt(Link_Starts.Count-1);
Links.RemoveAt(Links.Count-1);
i = brack;
continue;
}
if (com == "/fontsize" || com == "/i" || com == "/px")
{
int pos = Font_Starts.Count - 1;
if (pos == -1)
{
i = brack;
continue;
}
if (pos >= 0)
{
int last_Start = Font_Starts[pos];
Font_Starts.RemoveAt(pos);
if (LastFontEnd != sb.Length - 1)
{
LastFontEnd = sb.Length - 1;
Commands.Add(new(TextCode.Font, last_Start, LastFontEnd, Current));
}
}
}
if (com == "/fontsize")
{
Fonts.RemoveAt(Fonts.Count - 1);
if (Fonts.Count != 0)
{
Current = Current.Clone();
Current.FontSize = Fonts[Fonts.Count - 1];
Font_Starts.Add(sb.Length-1);
}
else
{
if (Sizes.Count == 0 && Itilacs.Count == 0)
Current = Font;
else
{
Current = Current.Clone();
Current.FontSize = Font.FontSize;
Font_Starts.Add(sb.Length-1);
}
}
i = brack;
continue;
}
if (com == "/i")
{
Itilacs.RemoveAt(Itilacs.Count - 1);
if (Itilacs.Count != 0)
{
Current = Current.Clone();
Current.Italic = Itilacs[Itilacs.Count - 1];
Font_Starts.Add(sb.Length-1);
}
else
{
if (Sizes.Count == 0 && Fonts.Count == 0)
Current = Font;
else
{
Current = Current.Clone();
Current.Italic = Font.Italic;
Font_Starts.Add(sb.Length-1);
}
}
i = brack;
continue;
}
if (com == "/px")
{
if (Sizes.Count == 0)
{
i = brack;
continue;
}
Sizes.RemoveAt(Sizes.Count - 1);
if (Sizes.Count != 0)
{
Current = Current.Clone();
Current.PixelHeight = Sizes[Sizes.Count - 1];
Font_Starts.Add(sb.Length-1);
}
else
{
if (Itilacs.Count == 0 && Fonts.Count == 0)
Current = Font;
else
{
Current = Current.Clone();
Current.PixelHeight = Font.PixelHeight;
Font_Starts.Add(sb.Length-1);
}
}
i = brack;
continue;
}
}
}
}
catch (Exception e)
{
Console.WriteLine(value);
Console.WriteLine(e);
//ignore
}
use_slash = true;
usebrac = true;
if (Largest is null || Current.PixelHeight > Largest.PixelHeight)
{
lh = Current.PixelHeight;
Largest = Current;
}
if (n)
{
lines++;
char_x = 0f;
max_lh += lh;
MaxLineSizes.Add(new(new((int)lw,(int)lh), Largest));
max_lh += (uint) ((double) lh * ((double) Largest.CurrentFonts[0].Face.Height / (double) Largest.CurrentFonts[0].Face.UnitsPerEM) * (double) this.Scale);
Largest = null;
lw = 0;
lh = 0;
sb.Append(c);
}
else
{
Character ch;
if (Window is not null) ch = Texture.GetChar(Font, c, Window.Context);
else ch = Texture.GetChar(Font, c);
if (MaxSize is not null && i > 0 && text[i-1] == ' ')
{
int addc = 0;
float word_char_x = char_x;
while (true)
{
if (addc + i == Text.Length) break;
if (text[addc + i] == ' ') break;
Character ch2;
if (Window is not null) ch2 = Texture.GetChar(Font, text[addc + i], Window.Context);
else ch2 = Texture.GetChar(Font, c);
word_char_x += (ch2.Advance >> 6) * Scale;
if (word_char_x > MaxSize.Value.X)
{
char_x = 0f;
lines++;
sb.Append('\n');
break;
}
addc++;
}
}
sb.Append(c);
float w = ch.Size.X * Scale;
float xrel = char_x + ch.Bearing.X * Scale;
char_x += (ch.Advance >> 6) * Scale;
if ((xrel + w) >= max_x) max_x = (xrel + w);
if ((xrel + w) >= lw) lw = (xrel + w);
}
}
MaxLineSizes.Add(new(new((int)lw,(int)lh), Largest));
max_lh += (uint) ((double) lh * ((double) Largest.CurrentFonts[0].Face.Height / (double) Largest.CurrentFonts[0].Face.UnitsPerEM) * (double) this.Scale);
Largest = null;
PlainText = sb.ToString();
text_Calculated = sb.ToString();
Commands.Sort((x, y) => x.Item2.CompareTo(y.Item2));
Size = new((int)max_x, (int)(max_lh) + (int)(lines * Font.ExtraLinePixels));
if (Loaded)
{
if (Window is not null && Window.CanControleUpdate)
{
if (!Window.Context.IsCurrent)
{
try
{
Window.Context.MakeCurrent();
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
if (Window.Context.IsCurrent)
{
Parent!.TryDraw();
}
}
}
}
}
public static Color4[] Rainbow = new[]
{
Color4.Red,
new(255,154,0,255),
new(208, 222, 33, 255),
new(79, 220, 74, 255),
new(63, 218, 216, 255),
new(47, 201, 226, 255),
new(28, 127, 238, 255),
new(95, 21, 242, 255),
new(186, 12, 248, 255),
new(251, 7, 217, 255)
};
public static Color4 LinkColor = Color4.Cyan;
private List<SubHitBox> Links = new();
public override void Draw(int x, int y, int sx, int sy, int sw, int sh)
{
if (Visible && Loaded)
{
if (!Window!.Context.IsCurrent) Window.Context.MakeCurrent();
Shader.Use();
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
GL.BlendFunc(0, BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
Shader.SetMatrixF4("projection", Window.WindowSizeMatrix);
GL.BindVertexArray(VAO);
float angle_rad = (float)Math.Atan2(DIR.Y, DIR.X);
Matrix4 rotateM = Matrix4.CreateRotationZ(angle_rad);
Matrix4 transOriginM = Matrix4.CreateTranslation(new Vector3(loc_.X + Parent!.IntToWindow(0), loc_.Y + (MaxLineSizes[0].Item1.Y * Scale) + Parent!.IntToWindow(0, true), 0f));
float char_x = 0.0f;
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
float hhh = 0;
int NextCommand = 0;
List<int> Active_Grads = new();
List<int> Active_Fonts = new();
List<Vector2i> Active_Links = new();
Dictionary<int, FontSize> Olds = new();
int line = 0;
int count = 0;
for (int i = 0; i < text_Calculated.Length; i++)
{
FontInteraction charfont = Font;
while (Commands.Count != 0 && NextCommand < Commands.Count && i == Commands[NextCommand].Item2)
{
switch (Commands[NextCommand].Item1)
{
case TextCode.Gradient or TextCode.Rainbow or TextCode.Color:
Active_Grads.Add(NextCommand);
break;
case TextCode.Font:
Active_Fonts.Add(NextCommand);
break;
case TextCode.url:
Active_Grads.Add(NextCommand);
Active_Links.Add(new((int)char_x, (int)hhh));
break;
}
NextCommand++;
}
if (Active_Fonts.Count != 0)
{
int g = Active_Fonts[Active_Fonts.Count - 1];
Tuple<TextCode, int, int ,object?> com = Commands[g];
if (com.Item1 == TextCode.Font)
{
charfont = (FontInteraction)com.Item4!;
}
if (com.Item3 <= i)
{
Active_Fonts.RemoveAt(Active_Fonts.Count-1);
}
}
if (Active_Grads.Count != 0)
{
Tuple<TextCode, int, int ,object?> com = Commands[Active_Grads[Active_Grads.Count - 1]];
(Color4, Color4) col;
if (com.Item1 == TextCode.Rainbow)
{
Tuple<GradType, int, int> item4 = (Tuple<GradType, int, int>)com.Item4!;
col = getGradcols(com.Item2, i, com.Item3, 0,line, item4.Item3, item4.Item1, Rainbow);
}
else if (com.Item1 == TextCode.Color)
{
col = new((Color4)com.Item4!, (Color4)com.Item4!);
}
else if (com.Item1 == TextCode.url)
{
col = new(LinkColor, LinkColor);
}
else
{
Tuple<Color4[], GradType, int, int> item4 = (Tuple<Color4[], GradType, int, int>)com.Item4!;
col = getGradcols(com.Item2, i, com.Item3, item4.Item3, line, item4.Item4, item4.Item2, item4.Item1);
}
GL.Uniform4(Shader.GetUniformLocation("textColor"), col.Item1);
GL.Uniform4(Shader.GetUniformLocation("rightColor"), col.Item2);
if (com.Item3 == i)
{
if (com.Item1 == TextCode.url)
{
int index = Active_Links.Count - 1;
Vector2i now = new((int)char_x, (int)hhh);
Vector2i lc = Active_Links[index];
Vector2i sz = new(now.X - Active_Links[Active_Links.Count - 1].X,
MaxLineSizes[line].Item1.Y);
if (Links.Count <= index || Links[index].Location != Active_Links[index] || Links[index].Size != sz)
{
if (Links.Count > count)Links.RemoveAt(count);
SubHitBox hb = new()
{
Location = lc,
Size = sz,
HoverMouse = MouseCursor.Hand
};
hb.Clicked += _ =>
{
try
{
if (OperatingSystem.IsWindows())
Process.Start((string)com.Item4!);
else if (OperatingSystem.IsLinux())
{
Process.Start("xdg-open", (string)com.Item4!);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
return Task.CompletedTask;
};
Links.Insert(count, hb);
SubHitBoxes.Add(hb);
count++;
}
Active_Links.RemoveAt(Active_Links.Count-1);
}
Active_Grads.RemoveAt(Active_Grads.Count-1);
}
}
else
{
GL.Uniform4(Shader.GetUniformLocation("textColor"), DefaultColor);
GL.Uniform4(Shader.GetUniformLocation("rightColor"), DefaultColor);
}
char c;
if (PasswordChar is null)
c = text_Calculated[i];
else
c = PasswordChar.Value;
bool n = (c == '\n');
if ((!_characters[Window!.Context].ContainsKey(charfont) || !_characters[Window!.Context][charfont].ContainsKey(c) ) && !n)
{
_ = Texture.TextureForChar(Window!.Context, charfont, c, Shader);
}
if (n)
{
hhh += ((float)MaxLineSizes[line].Item1.Y *
((float)MaxLineSizes[line].Item2.CurrentFonts[0].Face.Height /
(float)MaxLineSizes[line].Item2.CurrentFonts[0].Face.UnitsPerEM) * (float)this.Scale);
hhh += Font.ExtraLinePixels;
char_x = 0f;
line++;
}
else
{
if (!_characters[Window!.Context][charfont].ContainsKey(c)) continue;
Character ch = _characters[Window!.Context][charfont][c];
float w = ch.Size.X * Scale;
float h = ch.Size.Y * Scale;
float xrel = char_x + ch.Bearing.X * Scale;
float yrel = (ch.Size.Y - ch.Bearing.Y) * Scale;
yrel += hhh;
char_x += (ch.Advance >> 6) * Scale;
Matrix4 scaleM = Matrix4.CreateScale(new Vector3(w, h, 1.0f));
Matrix4 transRelM = Matrix4.CreateTranslation(new Vector3(xrel, yrel, 0.0f));
Matrix4 modelM = scaleM * transRelM * rotateM * transOriginM;
GL.UniformMatrix4(Shader.GetUniformLocation("model"), false, ref modelM);
ch.Texture.Use();
GL.DrawArrays(PrimitiveType.Triangles, 0, 6);
}
}
}
}
}

View File

@ -1,6 +1,8 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
@ -9,7 +11,7 @@ public class ProfileView : UserControl
{
public SocketUser User { get; set; }
private ProfileView(IRenderObject user, SocketUser u, ServerProfile p, Role r, Color? c = null)
private ProfileView(IRenderObject user, SocketUser u, ServerProfile p, Role r, Color[] c, ColorType ct)
{
this.User = u;
base.Size = new(244.ScaleInt(), 44.ScaleInt());
@ -17,14 +19,27 @@ public class ProfileView : UserControl
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
user.ForceDistanceUpdate(this);
user.IgnoreHover = true;
Color4 col = r.Color.ToColor4();
if (c is not null) col = c.ToColor4();
Label uname = new(Globals.DefaultFont)
LabelBase uname;
if (ct == ColorType.Full)
{
Text = p.DisplayName,
Color = col,
IgnoreHover = true
};
uname = new Label(Globals.DefaultFont)
{
Text = p.DisplayName,
Color = c[0].ToColor4(),
IgnoreHover = true
};
}
else
{
uname = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = p.DisplayName,
Colors = c.ToColor4Array(),
IgnoreHover = true
};
}
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
@ -33,7 +48,16 @@ public class ProfileView : UserControl
public static async Task<ProfileView> Make(SocketUser u, ServerProfile p, Role r)
{
ProfileView m = new(await p.MakeRct(u, new(32.ScaleInt())), u, p, r);
ColorType ct = await u.GetColorType();
Color[] c = await u.GetColors();
ColorType? cct = await p.GetColorType();
Color[]? cc = await p.GetColors();
if (cc is not null)
{
c = cc;
ct = cct!.Value;
}
ProfileView m = new(await p.MakeRct(u, new(32.ScaleInt())), u, p, r, c, ct);
return m;
}
}

View File

@ -2,7 +2,7 @@ using GraphicsManager.Interfaces;
using GraphicsManager.Objects.Core;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
public interface ISettingsPage : IRenderObject
{

View File

@ -2,7 +2,7 @@ using GraphicsManager.Enums;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
public class PageFlow : FlowLayout, ISettingsPage
{

View File

@ -4,7 +4,7 @@ using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
public class PageTab : UserControl
{

View File

@ -3,9 +3,9 @@ using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
public class SettingsCategory : UserControl
public class SettingsCategory<TSettingsMenu> : UserControl where TSettingsMenu : SettingsMenu
{
private Label Top;
private static FontInteraction? fi;
@ -15,9 +15,9 @@ public class SettingsCategory : UserControl
get => Top.Text;
}
private SettingsMenu ss;
private TSettingsMenu ss;
public SettingsCategory(string Name, SettingsMenu SS)
public SettingsCategory(string Name, TSettingsMenu SS)
{
ss = SS;
if (fi is null)

View File

@ -1,39 +1,29 @@
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
using Luski.net;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers;
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase;
public class ServerSettings : UserControl
public class SettingsMenu : UserControl
{
private string BehindName;
public ServerSettingPageTab? Selected;
public PageTab? Selected;
public FlowLayout fl;
public ServerSettings(PublicServer ps)
public SettingsMenu(string Name)
{
base.BackgroundColor = new(34, 34, 34, 255);
base.Size = Globals.ms.ClientSize;
BehindName = Globals.ms.Title;
Globals.ms.Title = $"Server Settings - Luski";
Globals.ms.Title = Name;
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"))

View File

@ -323,6 +323,10 @@ public class TextBox : UserControl
if (OnNewLine is not null) OnNewLine.Invoke().Wait();
BlockDraw = false;
Text += '\n';
CursorLocation++;
var f = _label.GetCharLocation(CursorLocation);
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
Pointer.Visible = true;
}
else
{
@ -334,9 +338,10 @@ public class TextBox : UserControl
if (KeyArgs.Key == Keys.V && KeyArgs.Control && Window is not null)
{
try
{
Text += Window.ClipboardString;
SendClipEvent(Window.ClipboardString);
if (LetterPress is not null) LetterPress.Invoke().Wait();
}
catch

View File

@ -9,7 +9,7 @@ public class ToggleSwitch : UserControl
public ToggleSwitch()
:base(Globals.ms.TextureManager.GetTextureResource("Toggle.png"))
{
base.Size = new(40.ScaleInt(), 24.ScaleInt());
base.SetSize(40.ScaleInt(), 24.ScaleInt());
base.BackgroundColor = OffBackgroundColor;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
Clicked += o =>

View File

@ -1,6 +1,8 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
@ -16,15 +18,37 @@ public class UserView : UserControl
base.BackgroundColor = new(34, 34, 34, 255);
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
user.ForceDistanceUpdate(this);
Label uname = new(Globals.DefaultFont)
if (r.ColorType == ColorType.Full)
{
Text = p.DisplayName,
Color = r.Color.ToColor4()
};
if (offline) uname.Color = new(uname.Color.R, uname.Color.G, uname.Color.B, uname.Color.A * 0.6f);
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
Label uname = new(Globals.DefaultFont)
{
Text = p.DisplayName,
Color = r.Colors[0].ToColor4()
};
if (offline) uname.Color = new(uname.Color.R, uname.Color.G, uname.Color.B, uname.Color.A * 0.6f);
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
}
else
{
AdvancedGradientLabel uname = new(Globals.DefaultFont)
{
Text = p.DisplayName,
Colors = r.Colors.ToColor4Array()
};
if (offline)
{
for (int i = 0; i < uname.Colors.Length; i++)
{
uname.Colors[i] = new(uname.Colors[i].R, uname.Colors[i].G, uname.Colors[i].B,
uname.Colors[i].A * 0.6f);
}
}
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
}
Controls.Add(user);
}

View File

@ -0,0 +1,37 @@
using GraphicsManager.Enums;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
namespace Luski.GUI.MainScreen.UI.LuskiSettings;
public class GlobalSettingsMenu : SettingsMenu
{
private Appearance a;
public GlobalSettingsMenu()
:base("Settings - Luski")
{
SettingsCategory<GlobalSettingsMenu> AppSettings = new("App Settings", this);
SettingsCategory<GlobalSettingsMenu> 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();
}
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;
}
}

View File

@ -1,6 +1,5 @@
using GraphicsManager.Objects;
using Luski.Classes;
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
using Luski.GUI.MainScreen.UI.SettingsPanel;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
@ -22,7 +21,7 @@ public class ExperimentSettings : PageFlow
{
g.line.WindowLoaded += _ =>
{
ParentResize(new(Globals.ms.ClientSize));
ParentResize();
return Task.CompletedTask;
};
}

View File

@ -2,7 +2,7 @@ using System.Reflection;
using GraphicsManager.Enums;
using Luski.Classes;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
@ -84,7 +84,7 @@ public class Updater : PageFlow
};
WindowLoaded += _ =>
{
Globals.ms.ForceUpdate(new(Globals.ms.CS));
Globals.ms.ForceUpdate();
return Task.CompletedTask;
};
}

View File

@ -2,7 +2,7 @@ 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.LuskiControls.SettingsMenuBase.Core;
using Luski.GUI.MainScreen.UI.SettingsPanel;
using OpenTK.Mathematics;

View File

@ -1,6 +1,6 @@
using System.Reflection;
using Luski.Classes;
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;

View File

@ -1,81 +0,0 @@
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

@ -1,8 +1,11 @@
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.Interfaces;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Windowing.Common.Input;
namespace Luski.GUI.MainScreen.UI.PublicServers;
@ -13,12 +16,12 @@ public class Category : UserControl, IChannelAdder
public SocketCategory CurrentCategory { get; set; }
private List<Category> cc = new();
private List<Channel> cl = new();
private Label ee;
private LabelBase ee;
private ChannelSelector CS;
public event Func<int, Task>? AddY;
private Label Name;
private LabelBase Name;
public UserControl tmp;
public static Task<Category> MakeCat(SocketCategory cat, ChannelSelector cs)
@ -27,7 +30,7 @@ public class Category : UserControl, IChannelAdder
c.CurrentCategory = cat;
c.CS = cs;
c.Anchor = ObjectAnchor.All;
c.Size = new(307.ScaleInt(), 40.ScaleInt());
c.SetSize(307.ScaleInt(), 40.ScaleInt());
c.tmp = new()
{
Size = c.Size,
@ -37,20 +40,41 @@ public class Category : UserControl, IChannelAdder
c.tmp.Clicked += c.TmpOnClicked;
c.tmp.HoverMouse = MouseCursor.Hand;
c.Controls.Add(c.tmp);
c.tmp.Controls.Add(c.ee = new(Globals.DefaultFont)
if (cat.ColorType == ColorType.Full)
{
Text = ">",
Location = new(5.ScaleInt()),
Color = cat.Color.ToColor4(),
DIR = new(1,0),
IgnoreHover = true
});
c.tmp.Controls.Add(c.Name = new Label(Globals.DefaultFont)
c.tmp.Controls.Add(c.ee = new Label(Globals.DefaultFont)
{
Text = ">",
Location = new(5.ScaleInt()),
Color = cat.Colors[0].ToColor4(),
DIR = new(1,0),
IgnoreHover = true
});
c.tmp.Controls.Add(c.Name = new Label(Globals.DefaultFont)
{
Text = cat.Name,
Color = cat.Colors[0].ToColor4(),
IgnoreHover = true
});
}
else
{
Text = cat.Name,
Color = c.ee.Color,
IgnoreHover = true
});
c.tmp.Controls.Add(c.ee = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = ">",
Location = new(5.ScaleInt()),
Colors = cat.Colors.ToColor4Array(),
DIR = new(1,0),
IgnoreHover = true
});
c.tmp.Controls.Add(c.Name = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = cat.Name,
Colors = cat.Colors.ToColor4Array(),
IgnoreHover = true
});
}
c.Clicked += c.AllOnClicked;
c.Name.Location = new(26.ScaleInt(), (((c.Size.Y - c.Name.Size.Y)/2)), 0);
c.Members = new()
@ -60,7 +84,7 @@ public class Category : UserControl, IChannelAdder
IgnoreHover = true
};
c.ee.Location = new(c.ee.Location.X, c.Name.Location.Y, 0);
c.Members.Size = new(c.Size.X - c.Members.Location.X, 0);
c.Members.SetSize(c.Size.X - c.Members.Location.X, 0);
c.Controls.Add(c.Members);
c.Members.ForceDistanceUpdate(c);
c.tmp.HoverMouse = MouseCursor.Hand;

View File

@ -2,6 +2,7 @@ using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net.Enums;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
@ -40,12 +41,26 @@ public class Channel : UserControl
r.Textures.Add(tex);
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
Controls.Add(r);
ChannelName = new Label(Globals.DefaultFont)
if (chan.ColorType == ColorType.Full)
{
Text = chan.Name,
Color = chan.Color.ToColor4(),
IgnoreHover = true
};
ChannelName = new Label(Globals.DefaultFont)
{
Text = chan.Name,
Color = chan.Colors[0].ToColor4(),
IgnoreHover = true
};
}
else
{
ChannelName = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = chan.Name,
Colors = chan.Colors.ToColor4Array(),
IgnoreHover = true
};
}
Controls.Add(ChannelName);
Clicked += AllOnClicked;
ChannelName.Location = new(40.ScaleInt(),
@ -65,12 +80,24 @@ public class Channel : UserControl
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
int i = 4.ScaleInt();
GC.Collect();
ChannelName = new Label(Globals.DefaultFont)
if (chan.ColorType == ColorType.Full)
{
Text = chan.Name,
Color = chan.Color.ToColor4(),
IgnoreHover = true
};
ChannelName = new Label(Globals.DefaultFont)
{
Text = chan.Name,
Color = chan.Colors[0].ToColor4(),
IgnoreHover = true
};
}
else
{
ChannelName = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = chan.Name,
Colors = chan.Colors.ToColor4Array(),
IgnoreHover = true
};
}
Controls.Add(ChannelName);
Clicked += AllOnClicked;
ChannelName.Location = new(i,
@ -128,7 +155,7 @@ public class Channel : UserControl
Console.WriteLine(e);
}
}
public Label ChannelName;
public LabelBase ChannelName;
public Rectangle r;
public static async Task<Channel> MakeChannel(SocketChannel chan, ChannelSelector cs)

View File

@ -2,8 +2,11 @@ using System.Diagnostics;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net.Structures.Main;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common.Input;
using OpenTK.Windowing.GraphicsLibraryFramework;
@ -20,7 +23,7 @@ public class ChatMessage : UserControl
private IRenderObject LastObject;
public List<IRenderObject> MessageObjs = new();
private Label FirstL;
private LabelBase FirstL;
public readonly double HorPadding = 12.ScaleDouble(),
VerticalPadding = 0.ScaleDouble();
@ -31,18 +34,23 @@ public class ChatMessage : UserControl
{
SocketUser auth = (SocketUser)(await message.GetAuthor(CancellationToken.None));
ServerProfile prof = await message.GetProfile(CancellationToken.None);
Color? c = await prof.GetColor();
if (c is null) c = await auth.GetColor();
Color4 c4 = c.ToColor4();
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), prof, await prof.MakeRct(auth, new(40.ScaleInt())), c4);
Color[]? c = await prof.GetColors();
ColorType? ct = await prof.GetColorType();
if (c is null)
{
c = await auth.GetColors();
ct = await auth.GetColorType();
}
Color4[] c4 = (ct!.Value == ColorType.Full ? new Color4[]{c[0].ToColor4()} : new Color4[]{c[0].ToColor4(), c[1].ToColor4()});
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), prof, await prof.MakeRct(auth, new(40.ScaleInt())), ct.Value, c4);
}
private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, ServerProfile Author, IRenderObject UserIcon, Color4 UserNameColor)
private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, ServerProfile Author, IRenderObject UserIcon, ColorType ct, Color4[] UserNameColor)
{
pc = p;
Label label1;
base.Size = new(723.5.ScaleInt(), 37.ScaleInt());
LabelBase label1;
base.SetSize(723.5.ScaleInt(), 37.ScaleInt());
ch = chan;
base.BackgroundColor = new(40, 40, 40, 255);
Msg = message;
@ -84,7 +92,8 @@ public class ChatMessage : UserControl
UserIcon.Location = new(10.ScaleInt(), 2.ScaleInt(), 0);
Controls.Add(UserIcon);
Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor, Text = Author.DisplayName });
if (ct == ColorType.Full) Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor[0], Text = Author.DisplayName });
else Controls.Add(label1 = new AdvancedGradientLabel(Globals.DefaultFont) { Colors = UserNameColor, Text = Author.DisplayName });
label1.Location = new(
54.ScaleInt(),
UserIcon.Location.Y,
@ -109,6 +118,10 @@ public class ChatMessage : UserControl
};
}
l.ContextMenu = lcm;
if (Msg.Context == "test message with picture")
{
//Console.WriteLine(Msg.FileIDs.Length);
}
MessageObjs.Add(l);
}
Globals.Settings.DayTimeChanged += () =>
@ -178,7 +191,7 @@ public class ChatMessage : UserControl
public async Task AddMessage(SocketMessage msg)
{
BlockDraw = true;
Label newLabel;
LuskiLabel newLabel;
if (!string.IsNullOrWhiteSpace(msg.Context))
{
newLabel = new(Globals.MessageFont)
@ -199,7 +212,7 @@ public class ChatMessage : UserControl
if (result)
{
newLabel.HoverMouse = MouseCursor.Hand;
newLabel.Color = Color4.Aqua;
newLabel.DefaultColor = Color4.Aqua;
newLabel.Clicked += NewLabelOnClicked;
}

View File

@ -93,8 +93,8 @@ public class ContentEmbed : UserControl
else if (size < 1000000000)
fst = Math.Round(size / (double)1000000, 2) + " MB";
else if (size < 1000000000000) fst = Math.Round(size / (double)1000000000, 2) + " GB";
base.Size = new(333, 66);
BackgroundColor = new(40, 40, 40, 255);
base.SetSize(333.ScaleInt(), 66.ScaleInt());
base.BackgroundColor = new(40, 40, 40, 255);
Controls.Add(fileSizeLabel = new Label(Globals.DefaultFont) { Text = fst, Location = new(64, 39, 0) });
Controls.Add(fileNameLabel = new Label(Globals.DefaultFont)
{

View File

@ -3,6 +3,7 @@ using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
@ -19,7 +20,7 @@ public class PublicChat : UserControl
{
public FlowLayout MessageFlow;
private Label title, desc;
private LabelBase title, desc;
private TextBox tb;
private SocketChannel? Channel;
UserControl titlecon;
@ -29,8 +30,7 @@ public class PublicChat : UserControl
public PublicChat()
{
base.Size = new(980.ScaleInt(), 866.ScaleInt());
base.SetSize(980.ScaleInt(), 866.ScaleInt());
base.BackgroundColor = new(40,40,40,255);
Anchor = ObjectAnchor.All;
Controls.Add(MessageFlow = new()
@ -102,8 +102,21 @@ public class PublicChat : UserControl
tb.ForceDistanceUpdate(this);
//tb.KeyPress += TbOnKeyPress;
//Globals.Luski.MainServer.MessageReceived += LuskiOnMessageReceived;
FilesDroped += OnFilesDroped;
tb.FilesDroped += OnFilesDroped;
MessageFlow.FilesDroped += OnFilesDroped;
FileFlow = new()
{
BackgroundColor = base.BackgroundColor,
Size = new(MessageFlow.Size.X, 0),
Location = new(MessageFlow.Location.X, MessageFlow.Location.Y + MessageFlow.Size.Y, 0),
Anchor = ObjectAnchor.Left | ObjectAnchor.Bottom | ObjectAnchor.Right
};
Controls.Add(FileFlow);
}
private bool ssss = false;
private Task OnSizeChanged(IRenderObject arg)
@ -138,7 +151,7 @@ public class PublicChat : UserControl
if (cm.Size.Y != ny)
{
cm.Size = new(Size.X, ny);
cm.SetSize(Size.X, ny);
MessageFlow.ReportSizeUpdate(cm);
}
ssss = false;
@ -169,12 +182,11 @@ public class PublicChat : UserControl
private async Task TbOnKeyPress(KeyboardKeyEventArgs arg)
{
//var t = Matrix4.Identity * Matrix4.CreateScale(2 / (float)Size.X, 2 / (float)Size.Y, 1) * Matrix4.CreateTranslation(-1.0f, -1.0f, 0.0f);
//var tt = Matrix4.CreateOrthographicOffCenter(0.0f, Size.X, 0.0f, Size.Y, 1, -1);
if (arg.Key == Keys.Enter && !arg.Shift)
{
await Channel!.SendMessage(tb.Text, FakeProfile: Globals.ServerProfile);
var file = await Channel!.Server.UploadFile("/home/jacob/Pictures/Points.png");
Console.WriteLine(file.ID);
await Channel!.SendMessage(tb.Text, Profile: Globals.ServerProfile, files: file);
tb.Text = string.Empty;
tb.CursorLocation = 0;
}
@ -184,7 +196,7 @@ public class PublicChat : UserControl
{
BlockDraw = true;
tb.Location = new(tb.Location.X, tb.Location.Y + (int)tb.Font.PixelHeight, 0);
MessageFlow.Size = new(MessageFlow.Size.X, MessageFlow.Size.Y + (int)tb.Font.PixelHeight);
MessageFlow.SetSize(MessageFlow.Size.X, MessageFlow.Size.Y + (int)tb.Font.PixelHeight);
BlockDraw = false;
return Task.CompletedTask;
}
@ -363,6 +375,46 @@ public class PublicChat : UserControl
public ChatMessage? LastChatMessageIndex;
private bool loadingm = false;
private List<FileUpload> FilesToUpload = new();
private CompressedFlow FileFlow;
private Task OnFilesDroped(IRenderObject arg1, string[] arg2)
{
int last = arg2.Length - 1;
BlockDraw = true;
for (int i = 0; i < last; i++)
{
AddFile(arg2[i], false);
}
BlockDraw = false;
AddFile(arg2[last]);
return Task.CompletedTask;
}
public void AddFile(string FilePath, bool ReloadUI = true)
{
FileFlow.SizeUpdateNotIgnored += CFOnSizeChanged;
FileUpload FU = new(Channel!.Server, FilePath);
FileFlow.Controls.Add(FU);
FU.BackgroundColor = Color4.Red;
if (ReloadUI) TryDraw();
}
private int OldSize = 0;
private Task CFOnSizeChanged(IRenderObject arg)
{
Console.WriteLine(arg.Size);
FileFlow.BackgroundColor = Color4.Green;
arg.Location = new(arg.Location.X, arg.Location.Y + OldSize - arg.Size.Y, 0);
OldSize = arg.Size.Y;
return Task.CompletedTask;
}
public void RemoveFile(FileUpload FU)
{
}
public async Task LoadChannel(SocketChannel channel)
{
Channel = channel;
@ -374,6 +426,31 @@ public class PublicChat : UserControl
memberflow.Controls.Clear();
await UserConOnClicked(UserCon!);
}
if (channel.ColorType == ColorType.Full)
{
titlecon.Controls.Remove(title, false);
if (title is not Label) title = new Label(title.Font)
{
Location = title.Location
};
((Label)title).Color = channel.Colors[0].ToColor4();
titlecon.Controls.Add(title);
}
else
{
if (title is not AdvancedGradientLabel)
{
titlecon.Controls.Remove(title, false);
title = new AdvancedGradientLabel(title.Font)
{
Location = title.Location
};
titlecon.Controls.Add(title);
}
((AdvancedGradientLabel)title).Colors = channel.Colors.ToColor4Array();
}
title.Text = channel.Name;
var five = 5.ScaleInt();
title.Location = new(five + five,

View File

@ -1,67 +0,0 @@
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.PublicServers;
public class ServerSettingCategory : UserControl
{
private Label Top;
private static FontInteraction? fi;
private Rectangle line;
public string Name
{
get => Top.Text;
}
private ServerSettings ss;
public ServerSettingCategory(string Name, ServerSettings 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 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);
return cb;
}
}

View File

@ -1,96 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,38 +0,0 @@
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

@ -1,38 +0,0 @@
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

@ -4,7 +4,7 @@ using Luski.net.Structures.Public;
using OpenTK.Mathematics;
using SixLabors.ImageSharp.Processing;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
public class RoleIcon : UserControl
{
@ -19,13 +19,14 @@ public class RoleIcon : UserControl
TextureDisplay = TextureDisplay.HorizontalCenter;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
base.Size = new(sri.RoleFlow.Size.X, 50.ScaleInt());
//TODO what?
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()
BackgroundColor = role.Colors[0].ToColor4()
};
Label name = new(Globals.ServerRoleFont)
{

View File

@ -0,0 +1,27 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.net.Structures.Public;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
public class RoleMember : UserControl
{
public RoleMember(ServerProfile p, SocketUser u)
{
base.Size = new(500.ScaleInt(), 40.ScaleInt());
Task<IRenderObject> icon = p.MakeRct(u, new(24.ScaleInt()));
icon.Wait();
int val = 8.ScaleInt();
icon.Result.Location = new(val, val, 0);
Controls.Add(icon.Result);
Label dn = new(Globals.DefaultFont)
{
Text = p.DisplayName
};
Controls.Add(dn);
dn.Location = new(icon.Result.Location.X + icon.Result.Size.X + 5.ScaleInt(),
icon.Result.Location.Y + ((icon.Result.Size.Y - dn.Size.Y) / 2), 0);
}
}

View File

@ -1,14 +1,15 @@
using GraphicsManager.Enums;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
using Luski.net;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
public class ServerRolePage : PageBaseControl
public class Roles : PageFlow
{
private ServerRoleInteraction Page;
public ServerRolePage(PublicServer ps)
public Roles(PublicServer ps)
{
PageName = "Roles";
Page = new(ps, this)
@ -17,7 +18,7 @@ public class ServerRolePage : PageBaseControl
Anchor = ObjectAnchor.All
};
Controls.Add(Page);
Globals.ms.ForceUpdate(new(Globals.ms.CS));
Globals.ms.ForceUpdate();
}
public override Color4 BackgroundColor

View File

@ -4,7 +4,7 @@ using Luski.net;
using Luski.net.Structures.Public;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
public class ServerRoleInteraction : UserControl
{
@ -12,7 +12,7 @@ public class ServerRoleInteraction : UserControl
public RoleIcon Selected;
public ServerRoleOptions SRO;
public ServerRoleInteraction(PublicServer server, ServerRolePage srp)
public ServerRoleInteraction(PublicServer server, Roles srp)
{
Task<Role[]> task = Task.Run(() => server.GetRoles());
task.Wait();

View File

@ -3,14 +3,12 @@ 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;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
public class ServerRoleOptions : UserControl
{
@ -145,6 +143,7 @@ public class ServerRoleOptions : UserControl
NeedMax.Clear();
Type PropType = typeof(ServerPermission);
IEnumerable<ServerPermission> values = Enum.GetValues(PropType).Cast<ServerPermission>();
Dictionary<string, UserControl> Cats = new();
foreach (var val in values)
{
try
@ -152,10 +151,27 @@ public class ServerRoleOptions : UserControl
MemberInfo? enumValueMemberInfo = Globals.GetMemberInfo(PropType, val);
string description = Globals.GetAttribute<DescriptionAttribute, ServerPermission>(enumValueMemberInfo!, val).Description;
string Name = Globals.GetAttribute<DisplayNameAttribute, ServerPermission>(enumValueMemberInfo!, val).DisplayName;
string cat = Globals.GetAttribute<CategoryAttribute, ServerPermission>(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)
@ -167,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
@ -211,6 +229,17 @@ public class ServerRoleOptions : UserControl
SelectedLine.Size = new(ManageMembers.Size.X, Line.Size.Y);
SelectedLine.Location = new(ManageMembers.Location.X, Line.Location.Y, Line.Location.Z);
Page.Controls.Clear();
var m = r.GetMembers();
m.Wait();
foreach (var meber in m.Result)
{
var p = meber.Server.GetProfile(meber.ServerProfile, CancellationToken.None);
p.Wait();
Page.Controls.Add(new RoleMember(p.Result, meber)
{
BackgroundColor = Page.BackgroundColor
});
}
BlockDraw = false;
TryDraw();
}

View File

@ -0,0 +1,25 @@
using GraphicsManager.Enums;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
using Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
using Luski.net;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings;
public class PublicServerSettingsMenu : SettingsMenu
{
public PublicServerSettingsMenu(PublicServer ps) : base("Server Settings - Luski")
{
SettingsCategory<PublicServerSettingsMenu> ServerCat = new(ps.Name, this);
Roles srp;
PageTab cb = ServerCat.AddPage(srp = new(ps)
{
BackgroundColor = base.BackgroundColor
});
Controls.Add(srp);
fl.Controls.Add(ServerCat);
cb.ToggleSelected().Wait();
Anchor = ObjectAnchor.All;
Controls.Add(fl);
}
}

View File

@ -2,7 +2,7 @@ using GraphicsManager.Enums;
using GraphicsManager.Objects;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings;
public class SaveWarning : UserControl
{

View File

@ -94,7 +94,7 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
Controls.Add(r);
base.BackgroundColor = new(26, 26, 26, 255);
this.Clicked += OnClicked;
base.Size = new(68.ScaleInt(), 48.ScaleInt());
base.SetSize(68.ScaleInt(), 48.ScaleInt());
}
private async Task OnClicked(IRenderObject arg)

View File

@ -338,7 +338,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
DisplayName.Textures[0] = UserName.Textures[0];
rec.ForceDistanceUpdate(page);
Globals.ms.TryDraw();
Globals.ms.ForceUpdate(new(Size));
Globals.ms.ForceUpdate();
}
};
ca.Size = new((Form.Size.X - tb.Location.X - tb.Location.X - (tb.Location.X / 2)) / 2, ca.Size.Y);
@ -540,7 +540,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
}
Globals.ms.Controls.Remove(this);
Globals.ms.ForceUpdate(new(Size));
Globals.ms.ForceUpdate();
Globals.ms.TryDraw();
}
@ -556,7 +556,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
private string pfp = "";
private Task RecOnFilesDroped(string[] arg)
private Task RecOnFilesDroped(IRenderObject obj, string[] arg)
{
Console.WriteLine(arg[0]);
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;

View File

@ -9,6 +9,7 @@ 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.GUI.MainScreen.UI.PublicServers.ServerSettings;
using Luski.net;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
@ -43,7 +44,7 @@ public class MainScreenWindow : Window
public TabControl? tc;
private FlowLayout? channelpicker, friends, friend_request;
private RoundedButton? FriendManagerBtn;
private static DebugProc DebugMessageDelegate = OnDebugMessage;
public static DebugProc DebugMessageDelegate = OnDebugMessage;
private static GLFWCallbacks.ErrorCallback GLFW_Error = OnGLFW_Error;
private static void OnGLFW_Error(ErrorCode e, string d)
@ -106,12 +107,16 @@ public class MainScreenWindow : Window
break;
}
}
public MainScreenWindow() : base(Settings)
{
Globals.ms = this;
Size = new(1332.ScaleInt(), 866.ScaleInt());
SetWindowSize(new(1332.ScaleInt(), 866.ScaleInt()));
Shader s = new Shader("Luski.Resources.Shaders.LeftToRightLabel", Embeded: true, Assembly: Assembly.GetExecutingAssembly());
s.Use();
s.SetInt("u_texture", s.GetUniformLocation("u_texture"));
Globals.GradientShader.Add(Context, s);
ClientSize = CS;
ShowMissingChar = true;
LogFrames = ((Globals.Settings.Logs & ConsoleLog.DrawFrames) == ConsoleLog.DrawFrames);
VSync = VSyncMode.On;
@ -205,7 +210,7 @@ public class MainScreenWindow : Window
{
ServerLoginOverlay SLO = new(Server.Domain);
Controls.Add(SLO);
ForceUpdate(new(ClientSize));
ForceUpdate();
Globals.PrintParent(this);
return;
}
@ -219,7 +224,7 @@ public class MainScreenWindow : Window
SerBox = new()
{
Location = new(ser.Size.X, 0, 0),
Size = new(Size.X - ser.Size.X, ClientSize.Y),
Size = new(Size.X - ser.Size.X, CS.Y),
Anchor = ObjectAnchor.All,
BackgroundColor = new(20, 20, 20, 255)
};
@ -245,12 +250,12 @@ public class MainScreenWindow : Window
};
if (await Server.User.HasPermissions(ServerPermission.ManageRoles))
{
ServerTitle.Clicked += o =>
ServerTitle.Clicked += _ =>
{
ServerSettings sm = new(Server);
PublicServerSettingsMenu sm = new(Server);
Controls.Add(sm);
Globals.ms.DrawFrame();
Globals.ms.ForceUpdate(new(Globals.ms.CS));
Globals.ms.ForceUpdate();
Globals.ms.DrawFrame();
return Task.CompletedTask;
};
@ -308,10 +313,16 @@ public class MainScreenWindow : Window
#endregion
#region User Icon
Role[] ra = await Server.User.GetRoles();
Color c = ra[0].Color;
Color4 c4 = new(c.R, c.G, c.B, c.A);
ServerProfile DefaultProfile = await Server.GetProfile(Server.User.ServerProfile, CancellationToken.None);
ColorType ct = await Server.User.GetColorType();
Color[] c = await Server.User.GetColors();
ColorType? cct = await DefaultProfile.GetColorType();
Color[]? cc = await DefaultProfile.GetColors();
if (cc is not null)
{
c = cc;
ct = cct!.Value;
}
IRenderObject u = await DefaultProfile.MakeRct(Server.User, new(46.ScaleInt()));
int ii = 4.ScaleInt();
u.Location = new(ii, cs.Location.Y + cs.Size.Y + ii, 0);
@ -319,12 +330,25 @@ public class MainScreenWindow : Window
SerBox.Controls.Add(u);
u.LoadToParent(SerBox, this);
u.ForceDistanceUpdate();
Label ul = new Label(Globals.DefaultFont)
LabelBase ul;
if (ct == ColorType.Full)
{
Anchor = u.Anchor,
Text = DefaultProfile.DisplayName,
Color = c4
};
ul = new Label(Globals.DefaultFont)
{
Anchor = u.Anchor,
Text = DefaultProfile.DisplayName,
Color = c[0].ToColor4()
};
}
else
{
ul = new AdvancedGradientLabel(Globals.DefaultFont)
{
Anchor = u.Anchor,
Text = DefaultProfile.DisplayName,
Colors = c.ToColor4Array()
};
}
ul.Location = new(u.Location.X + u.Size.X + 5.ScaleInt(),
(u.Location.Y + ((u.Size.Y - ul.Size.Y) / 2)), 0);
@ -333,7 +357,7 @@ public class MainScreenWindow : Window
Size = new(20.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Context],
BackgroundColor = Color4.Gray,
Tag = new Tuple<SocketAppUser, IRenderObject, Label>(Server.User, u, ul),
Tag = new Tuple<SocketAppUser, IRenderObject, LabelBase>(Server.User, u, ul),
Anchor = u.Anchor
};
Expand.Clicked += ExpandOnClicked;
@ -360,12 +384,12 @@ public class MainScreenWindow : Window
BackgroundColor = Color4.Gray,
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left
};
setting.MouseEnter += o =>
setting.MouseEnter += _ =>
{
setting.BackgroundColor = Color4.White;
return Task.CompletedTask;
};
setting.MouseLeave += o =>
setting.MouseLeave += _ =>
{
setting.BackgroundColor = Color4.Gray;
return Task.CompletedTask;
@ -373,7 +397,7 @@ public class MainScreenWindow : Window
setting.Clicked += SettingOnClicked;
setting.ForceDistanceUpdate(SerBox);
SerBox.Controls.Add(setting);
ForceUpdate(new (Size));
ForceUpdate();
TryDraw();
#endregion
}
@ -385,56 +409,63 @@ public class MainScreenWindow : Window
BlockDraw = false;
}
private FlowLayout? ProfileFlow = null;
private FlowLayout? ProfileFlow;
private async Task ExpandOnClicked(IRenderObject arg)
{
if (ProfileFlow is null)
try
{
ProfileFlow = new();
Tuple<SocketAppUser, IRenderObject, Label> s = (Tuple<SocketAppUser, IRenderObject, Label>)arg.Tag!;
var role = (await s.Item1.GetRoles())[0];
foreach (var prof in await s.Item1.GetProfiles(CancellationToken.None))
if (ProfileFlow is null)
{
ProfileView con = await ProfileView.Make(s.Item1, prof, role);
con.Clicked += async o =>
ProfileFlow = new();
Tuple<SocketAppUser, IRenderObject, LabelBase> s = (Tuple<SocketAppUser, IRenderObject, LabelBase>)arg.Tag!;
var role = (await s.Item1.GetRoles())[0];
foreach (ServerProfile prof in await s.Item1.GetProfiles(CancellationToken.None))
{
IRenderObject iro = await prof.MakeRct(s.Item1, s.Item2.Size);
iro.Location = s.Item2.Location;
iro.Distance = s.Item2.Distance;
iro.Anchor = s.Item2.Anchor;
int oldx = s.Item3.Size.X;
s.Item2.Parent!.Controls.Add(iro);
s.Item2.Parent!.Controls.Remove(s.Item2);
s.Item3.Text = prof.DisplayName;
Controls.Remove(ProfileFlow);
ProfileFlow = null;
arg.Location = new(arg.Location.X - oldx + s.Item3.Size.X, arg.Location.Y, arg.Location.Z);
arg.ForceDistanceUpdate(arg.Parent!);
Globals.ServerProfile = prof;
arg.Tag = new Tuple<SocketAppUser, IRenderObject, Label>(s.Item1, iro, s.Item3);
TryDraw();
};
ProfileFlow.Controls.Add(con);
ProfileFlow.Size = new((int)arg.SizeAsFloat.X, ProfileFlow.Size.Y + con.Size.Y);
}
ProfileView con = await ProfileView.Make(s.Item1, prof, role);
con.Clicked += async _ =>
{
IRenderObject iro = await prof.MakeRct(s.Item1, s.Item2.Size);
iro.Location = s.Item2.Location;
iro.Distance = s.Item2.Distance;
iro.Anchor = s.Item2.Anchor;
int oldx = s.Item3.Size.X;
s.Item2.Parent!.Controls.Add(iro);
s.Item2.Parent!.Controls.Remove(s.Item2);
s.Item3.Text = prof.DisplayName;
Controls.Remove(ProfileFlow);
ProfileFlow = null;
arg.Location = new(arg.Location.X - oldx + s.Item3.Size.X, arg.Location.Y, arg.Location.Z);
arg.ForceDistanceUpdate(arg.Parent!);
Globals.ServerProfile = prof;
arg.Tag = new Tuple<SocketAppUser, IRenderObject, LabelBase>(s.Item1, iro, s.Item3);
TryDraw();
};
ProfileFlow.Controls.Add(con);
ProfileFlow.Size = new((int)arg.SizeAsFloat.X, ProfileFlow.Size.Y + con.Size.Y);
}
ProfileFlow.Location = new(ser.Size.X + 5.ScaleInt(),
CS.Y - 54.ScaleInt() - ProfileFlow.Size.Y,
0);
Controls.Add(ProfileFlow);
ProfileFlow.Location = new(ser.Size.X + 5.ScaleInt(),
CS.Y - 54.ScaleInt() - ProfileFlow.Size.Y,
0);
Controls.Add(ProfileFlow);
}
else
{
Controls.Remove(ProfileFlow);
ProfileFlow = null;
}
DrawFrame();
}
else
catch (Exception e)
{
Controls.Remove(ProfileFlow);
ProfileFlow = null;
Console.WriteLine(e);
}
DrawFrame();
}
private Task SettingOnClicked(IRenderObject arg)
{
SettingsMenu sm = new();
GlobalSettingsMenu sm = new();
Controls.Add(sm);
Globals.ms.DrawFrame();
return Task.CompletedTask;
@ -457,7 +488,7 @@ public class MainScreenWindow : Window
private async Task<Task> LoginOnChangeToApp()
{
Controls.Clear();
ForceUpdate(new(ClientSize));
ForceUpdate();
BlockDraw = true;
Title = "Luski";
unsafe
@ -479,10 +510,11 @@ public class MainScreenWindow : Window
Controls.Add(ser = new FlowLayout()
{
BackgroundColor = new(26, 26, 26, 255),
Size = new(68.ScaleInt(), ClientSize.Y),
Size = new(68.ScaleInt(), CS.Y),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom,
Location = new(0,0,0)
});
ser.ForceDistanceUpdate(this);
ser.LoadToParent(this,this);
DrawFrame();
DateTime utcNow = DateTime.UtcNow;
@ -515,11 +547,6 @@ public class MainScreenWindow : Window
return Task.CompletedTask;
}
protected override void OnResize(ResizeEventArgs e)
{
base.OnResize(e);
}
private Task AddButtonClicked(IRenderObject arg)
{

View File

@ -2,6 +2,7 @@ using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using GraphicsManager;
@ -200,11 +201,19 @@ public static class Globals
public static Texture GetTextureResource(this TextureManager tm, string File)
{
if (!TextureResources.ContainsKey(tm)) TextureResources.Add(tm, new());
if (TextureResources[tm].TryGetValue(File, out Texture? t)) return t;
t = tm.AddTexture(GetResource($"Textures.{File}"));
TextureResources[tm].Add(File,t);
return t;
try
{
if (!TextureResources.ContainsKey(tm)) TextureResources.Add(tm, new());
if (TextureResources[tm].TryGetValue(File, out Texture? t)) return t;
t = tm.AddTexture(GetResource($"Textures.{File}"));
TextureResources[tm].Add(File,t);
return t;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public static Stream GetResource(string File)
@ -251,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<bool> a, List<Label>? List = null)
public static UserControl AddBool(IParent parent, string Name, string description, bool s, Action<bool> a, List<Label>? List = null)
{
ToggleSwitch ts = new()
{
@ -289,7 +298,7 @@ public static class Globals
};
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);
tc.SetSize(parent.Size.X, TempLine.Location.Y + TempLine.Size.Y);
TempLine.ForceDistanceUpdate(tc);
tc.Controls.Add(TempLine);
//ts.ForceDistanceUpdate(tc);
@ -300,6 +309,7 @@ public static class Globals
};
tc.ForceDistanceUpdate(parent);
parent.Controls.Add(tc);
return tc;
}
public static void AddBool<TEnum>(IParent parent, Type t, TEnum e, bool s, Action<bool> a, List<Label>? List = null) where TEnum : Enum
@ -359,6 +369,35 @@ public static class Globals
return new(col.R, col.G, col.B, col.A);
}
public static Color4[] ToColor4Array(this Color[] col)
{
List<Color4> cols = new();
foreach (Color c in col)
{
cols.Add(new(c.R, c.G, c.B, c.A));
}
return cols.ToArray();
}
public static string ToDB(this Color[] col)
{
StringBuilder sb = new();
foreach (Color c in col)
{
sb.Append(Convert.ToHexString(new byte[] { c.R, c.G, c.B, c.A }));
}
return sb.ToString();
}
public static string ToDB(this Color4[] col)
{
StringBuilder sb = new();
foreach (Color4 c in col)
{
sb.Append(Convert.ToHexString(new byte[] { (byte)(c.R * byte.MaxValue), (byte)(c.G * byte.MaxValue), (byte)(c.B * byte.MaxValue), (byte)(c.A * byte.MaxValue) }));
}
return sb.ToString();
}
public static Color4 ToColor4(this Color? col)
{
return new(col!.Value.R, col.Value.G, col.Value.B, col.Value.A);
@ -376,6 +415,7 @@ public static class Globals
public static Dictionary<long, Texture> UserTextureMap = new();
public static Dictionary<long, Texture> ProfileTextureMap = new();
public static readonly Dictionary<IGLFWGraphicsContext, Shader> GradientShader = new Dictionary<IGLFWGraphicsContext, Shader>();
public static ServerProfile? ServerProfile = null;
@ -387,18 +427,44 @@ public static class Globals
UserControl r = new(t);
r.Size = Size;
r.Shader = Rectangle.DefaultAlphaShader[ms.Context];
Color c = await User.GetColor();
r.BackgroundColor = new(25, 25, 25, 255);
Label l = new(DefaultFont)
ColorType ct = await User.GetColorType();
Color[] c = await User.GetColors();
ColorType? cct = await Profile.GetColorType();
Color[]? cc = await Profile.GetColors();
if (cc is not null)
{
Color = c.ToColor4()
};
l.Text = Profile.DisplayName[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)),
0);
r.Controls.Add(l);
c = cc;
ct = cct!.Value;
}
r.BackgroundColor = new(25, 25, 25, 255);
if (ct == ColorType.Full)
{
Label l = new(DefaultFont)
{
Color = c[0].ToColor4()
};
l.Text = Profile.DisplayName[0].ToString();
Vector2i y = l.GetSizeOfChar(0),
yy = l.GetBearingOfChar(0);
l.Location = new((r.Size.X - l.Size.X)/2,
(int)(r.Size.Y - l.Font.PixelHeight + yy.Y - (r.Size.Y / 2) - (y.Y/2)),
0);
r.Controls.Add(l);
}
else
{
AdvancedGradientLabel l = new(DefaultFont)
{
Colors = c.ToColor4Array()
};
l.Text = Profile.DisplayName[0].ToString();
Vector2i y = l.GetSizeOfChar(0),
yy = l.GetBearingOfChar(0);
l.Location = new((r.Size.X - l.Size.X)/2,
(int)(r.Size.Y - l.Font.PixelHeight + yy.Y - (r.Size.Y / 2) - (y.Y/2)),
0);
r.Controls.Add(l);
}
return r;
}
else
@ -426,9 +492,10 @@ public static class Globals
IgnoreHover = true,
Text = Server.Name[0].ToString()
};
var y = l.GetSizeOfChar(0);
Vector2i y = l.GetSizeOfChar(0),
yy = l.GetBearingOfChar(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)),
(int)(r.Size.Y - l.Font.PixelHeight + yy.Y - (r.Size.Y / 2) - (y.Y/2)),
0);
r.Controls.Add(l);
return r;

View File

@ -22,8 +22,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha83" />
<PackageReference Include="Luski.net" Version="2.0.1-alpha04" />
<PackageReference Include="GraphicsManager" Version="1.1.0-alpha50" />
<PackageReference Include="Luski.net" Version="2.0.1-alpha15" />
</ItemGroup>
<ItemGroup>
@ -31,6 +31,8 @@
</ItemGroup>
<ItemGroup>
<Folder Include="GUI\MainScreen\UI\PublicServers\ServerSettings\Pages\Moderation\" />
<Folder Include="GUI\MainScreen\UI\PublicServers\ServerSettings\Pages\UserManagement\" />
<Folder Include="GUI\Windows\" />
</ItemGroup>

View File

@ -2,6 +2,7 @@
using Luski;
using Luski.Classes;
using Luski.GUI;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common.Input;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
@ -9,6 +10,23 @@ using Image = OpenTK.Windowing.Common.Input.Image;
try
{
unsafe
{
int * a1;
int * a2;
int b1;
b1 = 20;
a1 = &b1;
a2 = a1;
*a1 = 25;
Console.WriteLine(*a2);
}
Globals.Settings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
foreach (ExperimentInfo le in LuskiExperiments.LuskiExperimentsList)
{
@ -72,6 +90,16 @@ try
Globals.Icon = new WindowIcon(new Image(Logo.Width, Logo.Height, pixels));
Logo.Dispose();
Console.WriteLine(new Color4[]{
Color4.Red,
Color4.Orange,
Color4.Yellow,
Color4.Green,
Color4.Blue,
Color4.Indigo,
Color4.Violet,
}.ToDB());
MainScreenWindow.Settings.Icon = Globals.Icon;
Globals.ms = new MainScreenWindow();
Globals.ms.CustomF11 = false;

View File

@ -0,0 +1,19 @@
#version 330
in vec2 vUV;
uniform sampler2D u_texture;
uniform vec4 textColor;
uniform vec4 rightColor;
out vec4 fragColor;
void main()
{
vec2 uv = vUV.xy;
float text = texture(u_texture, uv).r;
vec4 gradientColor = mix(textColor, rightColor, uv.x);
fragColor = vec4(gradientColor.rgb, gradientColor.a*text);
}

View File

@ -0,0 +1,15 @@
#version 330
layout (location = 0) in vec2 in_pos;
layout (location = 1) in vec2 in_uv;
out vec2 vUV;
uniform mat4 model;
uniform mat4 projection;
void main()
{
vUV = in_uv.xy;
gl_Position = projection * model * vec4(in_pos.xy, 0.0, 1.0);
}