Compare commits
No commits in common. "76ec58a595ab0104fad25182ab2334613662e588" and "842282d2a87974852917d413a433c6099754074e" have entirely different histories.
76ec58a595
...
842282d2a8
@ -75,7 +75,7 @@ public class Settings
|
|||||||
Label._characters[Globals.ms.Context][Globals.TopTimeFont].Clear();
|
Label._characters[Globals.ms.Context][Globals.TopTimeFont].Clear();
|
||||||
Label._characters[Globals.ms.Context][Globals.SmallTimeFont].Clear();
|
Label._characters[Globals.ms.Context][Globals.SmallTimeFont].Clear();
|
||||||
|
|
||||||
Globals.ms.ForceUpdate();
|
Globals.ms.ForceUpdate(new(Globals.ms.ClientSize));
|
||||||
Globals.ms.DrawFrame();
|
Globals.ms.DrawFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ public class Settings
|
|||||||
|
|
||||||
[JsonInclude]
|
[JsonInclude]
|
||||||
[Shared.GlobalAttributes.DisplayName("24 Hour Time")]
|
[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")]
|
[JsonPropertyName("24hour_time")]
|
||||||
public bool DayTime
|
public bool DayTime
|
||||||
{
|
{
|
||||||
@ -113,32 +113,12 @@ 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]
|
[JsonIgnore]
|
||||||
private bool _ScaleFonts = true;
|
private bool _ScaleFonts = true;
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
private ConsoleLog _Logs = (ConsoleLog)(-25);
|
private ConsoleLog _Logs = (ConsoleLog)(-25);
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
private bool _DayTime = false;
|
private bool _DayTime = false;
|
||||||
[JsonIgnore]
|
|
||||||
private bool _MemoryFonts= false;
|
|
||||||
public event Func<Task>? DayTimeChanged;
|
public event Func<Task>? DayTimeChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,30 +9,23 @@ public enum ConsoleLog : long
|
|||||||
None = 0,
|
None = 0,
|
||||||
[Shared.GlobalAttributes.DisplayName("OpenGL Errors")]
|
[Shared.GlobalAttributes.DisplayName("OpenGL Errors")]
|
||||||
[Description("Show OpenGL Major Errors")]
|
[Description("Show OpenGL Major Errors")]
|
||||||
[Category("Rendering")]
|
|
||||||
BigErrosForOpenGL = 1,
|
BigErrosForOpenGL = 1,
|
||||||
[Shared.GlobalAttributes.DisplayName("OpenGL Medium Errors")]
|
[Shared.GlobalAttributes.DisplayName("OpenGL Medium Errors")]
|
||||||
[Description("Show OpenGL Medium Errors")]
|
[Description("Show OpenGL Medium Errors")]
|
||||||
[Category("Rendering")]
|
|
||||||
MediumErrosForOpenGL = 2,
|
MediumErrosForOpenGL = 2,
|
||||||
[Shared.GlobalAttributes.DisplayName("OpenGL Small Errors")]
|
[Shared.GlobalAttributes.DisplayName("OpenGL Small Errors")]
|
||||||
[Description("Show OpenGL Small Errors")]
|
[Description("Show OpenGL Small Errors")]
|
||||||
[Category("Rendering")]
|
|
||||||
LowErrosForOpenGL = 4,
|
LowErrosForOpenGL = 4,
|
||||||
[Shared.GlobalAttributes.DisplayName("OpenGL Info")]
|
[Shared.GlobalAttributes.DisplayName("OpenGL Info")]
|
||||||
[Description("Show OpenGL Info")]
|
[Description("Show OpenGL Info")]
|
||||||
[Category("Rendering")]
|
|
||||||
InfoForOpenGL = 8,
|
InfoForOpenGL = 8,
|
||||||
[Shared.GlobalAttributes.DisplayName("Log Frames")]
|
[Shared.GlobalAttributes.DisplayName("Log Frames")]
|
||||||
[Description("Shows draw fram message in the console")]
|
[Description("Shows draw fram message in the console")]
|
||||||
[Category("Rendering")]
|
|
||||||
DrawFrames = 16,
|
DrawFrames = 16,
|
||||||
[Shared.GlobalAttributes.DisplayName("Show Missing Charters")]
|
[Shared.GlobalAttributes.DisplayName("Show Missing Charters")]
|
||||||
[Description("Show Missing Charters")]
|
[Description("Show Missing Charters")]
|
||||||
[Category("Rendering")]
|
|
||||||
ShowMissingChar = 32,
|
ShowMissingChar = 32,
|
||||||
[Shared.GlobalAttributes.DisplayName("GLFW Errors")]
|
[Shared.GlobalAttributes.DisplayName("GLFW Errors")]
|
||||||
[Description("Show GLFW Errors")]
|
[Description("Show GLFW Errors")]
|
||||||
[Category("Rendering")]
|
|
||||||
ShowErrorsForGLFW = 64
|
ShowErrorsForGLFW = 64
|
||||||
}
|
}
|
@ -1,8 +0,0 @@
|
|||||||
namespace Luski.Enums;
|
|
||||||
|
|
||||||
public enum FontCode : byte
|
|
||||||
{
|
|
||||||
Size,
|
|
||||||
Italics,
|
|
||||||
Height
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace Luski.Enums;
|
|
||||||
|
|
||||||
public enum GradType : byte
|
|
||||||
{
|
|
||||||
Block,
|
|
||||||
Line
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace Luski.Enums;
|
|
||||||
|
|
||||||
public enum TextCode
|
|
||||||
{
|
|
||||||
Rainbow,
|
|
||||||
Gradient,
|
|
||||||
Color,
|
|
||||||
Font,
|
|
||||||
url
|
|
||||||
}
|
|
@ -17,7 +17,7 @@ public class AccountButton : UserControl
|
|||||||
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
|
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
|
||||||
{
|
{
|
||||||
this.SM = SM;
|
this.SM = SM;
|
||||||
base.SetSize(297.ScaleInt(), 40.ScaleInt());
|
base.Size = new(297.ScaleInt(), 40.ScaleInt());
|
||||||
TextureDisplay = TextureDisplay.HorizontalCenter;
|
TextureDisplay = TextureDisplay.HorizontalCenter;
|
||||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||||
l = new Label(Globals.DefaultFont)
|
l = new Label(Globals.DefaultFont)
|
||||||
@ -26,8 +26,9 @@ public class AccountButton : UserControl
|
|||||||
Color = Color4.Gray,
|
Color = Color4.Gray,
|
||||||
IgnoreHover = true,
|
IgnoreHover = true,
|
||||||
};
|
};
|
||||||
l.SetLocation((base.Size.X / 2) - (l.Size.X / 2),
|
l.Location = new((base.Size.X / 2) - (l.Size.X / 2),
|
||||||
((base.Size.Y - l.Size.Y) / 2));
|
((base.Size.Y - l.Size.Y) / 2)
|
||||||
|
, 0);
|
||||||
Controls.Add(l);
|
Controls.Add(l);
|
||||||
base.BackgroundColor = new(0, 0, 0, 0);
|
base.BackgroundColor = new(0, 0, 0, 0);
|
||||||
Clicked += OnClicked;
|
Clicked += OnClicked;
|
||||||
@ -81,7 +82,7 @@ public class AccountButton : UserControl
|
|||||||
SM.Selected = this;
|
SM.Selected = this;
|
||||||
SM.page.Controls.Clear();
|
SM.page.Controls.Clear();
|
||||||
OnPageLoad.Invoke();
|
OnPageLoad.Invoke();
|
||||||
Globals.ms.ForceUpdate();
|
Globals.ms.ForceUpdate(new(Globals.ms.CS));
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockDraw = false;
|
BlockDraw = false;
|
||||||
|
@ -18,6 +18,6 @@ public class AddServerIcon : UserControl
|
|||||||
};
|
};
|
||||||
Controls.Add(Button);
|
Controls.Add(Button);
|
||||||
base.BackgroundColor = new(26, 26, 26, 255);
|
base.BackgroundColor = new(26, 26, 26, 255);
|
||||||
base.SetSize(68.ScaleInt(), 48.ScaleInt());
|
base.Size = new(68.ScaleInt(), 48.ScaleInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -108,7 +108,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
|
|
||||||
tb.SetSize(Form.Size.X - tb.Location.X - tb.Location.X - tb.Location.X - s.X, tb.Size.Y);
|
tb.Size = new(Form.Size.X - tb.Location.X - tb.Location.X - tb.Location.X - s.X, tb.Size.Y);
|
||||||
Form.Controls.Add(tb);
|
Form.Controls.Add(tb);
|
||||||
version = new DropDown<VersionDropButton>(Form.Textures[0], line)
|
version = new DropDown<VersionDropButton>(Form.Textures[0], line)
|
||||||
{
|
{
|
||||||
@ -475,7 +475,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
|||||||
DisplayName = null!;
|
DisplayName = null!;
|
||||||
rec = null!;
|
rec = null!;
|
||||||
tb.Focus();
|
tb.Focus();
|
||||||
Globals.ms.ForceUpdate();
|
Globals.ms.ForceUpdate(new(Globals.ms.CS));
|
||||||
TryDraw();
|
TryDraw();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -600,7 +600,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
|||||||
|
|
||||||
private string pfp = "";
|
private string pfp = "";
|
||||||
|
|
||||||
private Task RecOnFilesDroped(IRenderObject obj, string[] arg)
|
private Task RecOnFilesDroped(string[] arg)
|
||||||
{
|
{
|
||||||
Console.WriteLine(arg[0]);
|
Console.WriteLine(arg[0]);
|
||||||
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;
|
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;
|
||||||
|
@ -1,131 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,741 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,6 @@
|
|||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using GraphicsManager.Objects.Core;
|
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using Luski.Shared.PublicServers.V1.Enums;
|
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiControls;
|
namespace Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
@ -11,7 +9,7 @@ public class ProfileView : UserControl
|
|||||||
{
|
{
|
||||||
public SocketUser User { get; set; }
|
public SocketUser User { get; set; }
|
||||||
|
|
||||||
private ProfileView(IRenderObject user, SocketUser u, ServerProfile p, Role r, Color[] c, ColorType ct)
|
private ProfileView(IRenderObject user, SocketUser u, ServerProfile p, Role r, Color? c = null)
|
||||||
{
|
{
|
||||||
this.User = u;
|
this.User = u;
|
||||||
base.Size = new(244.ScaleInt(), 44.ScaleInt());
|
base.Size = new(244.ScaleInt(), 44.ScaleInt());
|
||||||
@ -19,27 +17,14 @@ public class ProfileView : UserControl
|
|||||||
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
|
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
|
||||||
user.ForceDistanceUpdate(this);
|
user.ForceDistanceUpdate(this);
|
||||||
user.IgnoreHover = true;
|
user.IgnoreHover = true;
|
||||||
|
Color4 col = r.Color.ToColor4();
|
||||||
LabelBase uname;
|
if (c is not null) col = c.ToColor4();
|
||||||
if (ct == ColorType.Full)
|
Label uname = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
uname = new Label(Globals.DefaultFont)
|
Text = p.DisplayName,
|
||||||
{
|
Color = col,
|
||||||
Text = p.DisplayName,
|
IgnoreHover = true
|
||||||
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(),
|
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
|
||||||
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
|
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
|
||||||
Controls.Add(uname);
|
Controls.Add(uname);
|
||||||
@ -48,16 +33,7 @@ public class ProfileView : UserControl
|
|||||||
|
|
||||||
public static async Task<ProfileView> Make(SocketUser u, ServerProfile p, Role r)
|
public static async Task<ProfileView> Make(SocketUser u, ServerProfile p, Role r)
|
||||||
{
|
{
|
||||||
ColorType ct = await u.GetColorType();
|
ProfileView m = new(await p.MakeRct(u, new(32.ScaleInt())), u, p, r);
|
||||||
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;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -323,10 +323,6 @@ public class TextBox : UserControl
|
|||||||
if (OnNewLine is not null) OnNewLine.Invoke().Wait();
|
if (OnNewLine is not null) OnNewLine.Invoke().Wait();
|
||||||
BlockDraw = false;
|
BlockDraw = false;
|
||||||
Text += '\n';
|
Text += '\n';
|
||||||
CursorLocation++;
|
|
||||||
var f = _label.GetCharLocation(CursorLocation);
|
|
||||||
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
|
||||||
Pointer.Visible = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -338,10 +334,9 @@ public class TextBox : UserControl
|
|||||||
|
|
||||||
if (KeyArgs.Key == Keys.V && KeyArgs.Control && Window is not null)
|
if (KeyArgs.Key == Keys.V && KeyArgs.Control && Window is not null)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SendClipEvent(Window.ClipboardString);
|
Text += Window.ClipboardString;
|
||||||
if (LetterPress is not null) LetterPress.Invoke().Wait();
|
if (LetterPress is not null) LetterPress.Invoke().Wait();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -9,7 +9,7 @@ public class ToggleSwitch : UserControl
|
|||||||
public ToggleSwitch()
|
public ToggleSwitch()
|
||||||
:base(Globals.ms.TextureManager.GetTextureResource("Toggle.png"))
|
:base(Globals.ms.TextureManager.GetTextureResource("Toggle.png"))
|
||||||
{
|
{
|
||||||
base.SetSize(40.ScaleInt(), 24.ScaleInt());
|
base.Size = new(40.ScaleInt(), 24.ScaleInt());
|
||||||
base.BackgroundColor = OffBackgroundColor;
|
base.BackgroundColor = OffBackgroundColor;
|
||||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||||
Clicked += o =>
|
Clicked += o =>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using GraphicsManager.Objects.Core;
|
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using Luski.Shared.PublicServers.V1.Enums;
|
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiControls;
|
namespace Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
@ -18,37 +16,15 @@ public class UserView : UserControl
|
|||||||
base.BackgroundColor = new(34, 34, 34, 255);
|
base.BackgroundColor = new(34, 34, 34, 255);
|
||||||
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
|
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
|
||||||
user.ForceDistanceUpdate(this);
|
user.ForceDistanceUpdate(this);
|
||||||
if (r.ColorType == ColorType.Full)
|
Label uname = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Label uname = new(Globals.DefaultFont)
|
Text = p.DisplayName,
|
||||||
{
|
Color = r.Color.ToColor4()
|
||||||
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(),
|
||||||
if (offline) uname.Color = new(uname.Color.R, uname.Color.G, uname.Color.B, uname.Color.A * 0.6f);
|
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
|
||||||
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
|
Controls.Add(uname);
|
||||||
(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);
|
Controls.Add(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ using GraphicsManager.Interfaces;
|
|||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||||
|
|
||||||
public interface ISettingsPage : IRenderObject
|
public interface ISettingsPage : IRenderObject
|
||||||
{
|
{
|
@ -2,7 +2,7 @@ using GraphicsManager.Enums;
|
|||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||||
|
|
||||||
public class PageFlow : FlowLayout, ISettingsPage
|
public class PageFlow : FlowLayout, ISettingsPage
|
||||||
{
|
{
|
@ -4,7 +4,7 @@ using GraphicsManager.Objects;
|
|||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||||
|
|
||||||
public class PageTab : UserControl
|
public class PageTab : UserControl
|
||||||
{
|
{
|
@ -3,9 +3,9 @@ using GraphicsManager.Objects;
|
|||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||||
|
|
||||||
public class SettingsCategory<TSettingsMenu> : UserControl where TSettingsMenu : SettingsMenu
|
public class SettingsCategory : UserControl
|
||||||
{
|
{
|
||||||
private Label Top;
|
private Label Top;
|
||||||
private static FontInteraction? fi;
|
private static FontInteraction? fi;
|
||||||
@ -15,9 +15,9 @@ public class SettingsCategory<TSettingsMenu> : UserControl where TSettingsMenu :
|
|||||||
get => Top.Text;
|
get => Top.Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TSettingsMenu ss;
|
private SettingsMenu ss;
|
||||||
|
|
||||||
public SettingsCategory(string Name, TSettingsMenu SS)
|
public SettingsCategory(string Name, SettingsMenu SS)
|
||||||
{
|
{
|
||||||
ss = SS;
|
ss = SS;
|
||||||
if (fi is null)
|
if (fi is null)
|
@ -1,37 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
|
using GraphicsManager.Objects;
|
||||||
using Luski.Classes;
|
using Luski.Classes;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||||
using Luski.GUI.MainScreen.UI.SettingsPanel;
|
using Luski.GUI.MainScreen.UI.SettingsPanel;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
|
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
|
||||||
@ -21,7 +22,7 @@ public class ExperimentSettings : PageFlow
|
|||||||
{
|
{
|
||||||
g.line.WindowLoaded += _ =>
|
g.line.WindowLoaded += _ =>
|
||||||
{
|
{
|
||||||
ParentResize();
|
ParentResize(new(Globals.ms.ClientSize));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ using System.Reflection;
|
|||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using Luski.Classes;
|
using Luski.Classes;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
|
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public class Updater : PageFlow
|
|||||||
};
|
};
|
||||||
WindowLoaded += _ =>
|
WindowLoaded += _ =>
|
||||||
{
|
{
|
||||||
Globals.ms.ForceUpdate();
|
Globals.ms.ForceUpdate(new(Globals.ms.CS));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ using GraphicsManager.Enums;
|
|||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using Luski.Classes;
|
using Luski.Classes;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||||
using Luski.GUI.MainScreen.UI.SettingsPanel;
|
using Luski.GUI.MainScreen.UI.SettingsPanel;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Luski.Classes;
|
using Luski.Classes;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
using Luski.GUI.MainScreen.UI.LuskiSettings.Core;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
|
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
|
||||||
|
|
||||||
|
81
Luski/GUI/MainScreen/UI/LuskiSettings/SettingsMenu.cs
Normal file
81
Luski/GUI/MainScreen/UI/LuskiSettings/SettingsMenu.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,8 @@
|
|||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using GraphicsManager.Objects.Core;
|
|
||||||
using Luski.GUI.MainScreen.Interfaces;
|
using Luski.GUI.MainScreen.Interfaces;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using Luski.Shared.PublicServers.V1.Enums;
|
|
||||||
using OpenTK.Windowing.Common.Input;
|
using OpenTK.Windowing.Common.Input;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
||||||
@ -16,12 +13,12 @@ public class Category : UserControl, IChannelAdder
|
|||||||
public SocketCategory CurrentCategory { get; set; }
|
public SocketCategory CurrentCategory { get; set; }
|
||||||
private List<Category> cc = new();
|
private List<Category> cc = new();
|
||||||
private List<Channel> cl = new();
|
private List<Channel> cl = new();
|
||||||
private LabelBase ee;
|
private Label ee;
|
||||||
private ChannelSelector CS;
|
private ChannelSelector CS;
|
||||||
|
|
||||||
public event Func<int, Task>? AddY;
|
public event Func<int, Task>? AddY;
|
||||||
|
|
||||||
private LabelBase Name;
|
private Label Name;
|
||||||
public UserControl tmp;
|
public UserControl tmp;
|
||||||
|
|
||||||
public static Task<Category> MakeCat(SocketCategory cat, ChannelSelector cs)
|
public static Task<Category> MakeCat(SocketCategory cat, ChannelSelector cs)
|
||||||
@ -30,7 +27,7 @@ public class Category : UserControl, IChannelAdder
|
|||||||
c.CurrentCategory = cat;
|
c.CurrentCategory = cat;
|
||||||
c.CS = cs;
|
c.CS = cs;
|
||||||
c.Anchor = ObjectAnchor.All;
|
c.Anchor = ObjectAnchor.All;
|
||||||
c.SetSize(307.ScaleInt(), 40.ScaleInt());
|
c.Size = new(307.ScaleInt(), 40.ScaleInt());
|
||||||
c.tmp = new()
|
c.tmp = new()
|
||||||
{
|
{
|
||||||
Size = c.Size,
|
Size = c.Size,
|
||||||
@ -40,41 +37,20 @@ public class Category : UserControl, IChannelAdder
|
|||||||
c.tmp.Clicked += c.TmpOnClicked;
|
c.tmp.Clicked += c.TmpOnClicked;
|
||||||
c.tmp.HoverMouse = MouseCursor.Hand;
|
c.tmp.HoverMouse = MouseCursor.Hand;
|
||||||
c.Controls.Add(c.tmp);
|
c.Controls.Add(c.tmp);
|
||||||
if (cat.ColorType == ColorType.Full)
|
c.tmp.Controls.Add(c.ee = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
c.tmp.Controls.Add(c.ee = new Label(Globals.DefaultFont)
|
Text = ">",
|
||||||
{
|
Location = new(5.ScaleInt()),
|
||||||
Text = ">",
|
Color = cat.Color.ToColor4(),
|
||||||
Location = new(5.ScaleInt()),
|
DIR = new(1,0),
|
||||||
Color = cat.Colors[0].ToColor4(),
|
IgnoreHover = true
|
||||||
DIR = new(1,0),
|
});
|
||||||
IgnoreHover = true
|
c.tmp.Controls.Add(c.Name = new Label(Globals.DefaultFont)
|
||||||
});
|
|
||||||
c.tmp.Controls.Add(c.Name = new Label(Globals.DefaultFont)
|
|
||||||
{
|
|
||||||
Text = cat.Name,
|
|
||||||
Color = cat.Colors[0].ToColor4(),
|
|
||||||
IgnoreHover = true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
c.tmp.Controls.Add(c.ee = new AdvancedGradientLabel(Globals.DefaultFont)
|
Text = cat.Name,
|
||||||
{
|
Color = c.ee.Color,
|
||||||
Text = ">",
|
IgnoreHover = true
|
||||||
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.Clicked += c.AllOnClicked;
|
||||||
c.Name.Location = new(26.ScaleInt(), (((c.Size.Y - c.Name.Size.Y)/2)), 0);
|
c.Name.Location = new(26.ScaleInt(), (((c.Size.Y - c.Name.Size.Y)/2)), 0);
|
||||||
c.Members = new()
|
c.Members = new()
|
||||||
@ -84,7 +60,7 @@ public class Category : UserControl, IChannelAdder
|
|||||||
IgnoreHover = true
|
IgnoreHover = true
|
||||||
};
|
};
|
||||||
c.ee.Location = new(c.ee.Location.X, c.Name.Location.Y, 0);
|
c.ee.Location = new(c.ee.Location.X, c.Name.Location.Y, 0);
|
||||||
c.Members.SetSize(c.Size.X - c.Members.Location.X, 0);
|
c.Members.Size = new(c.Size.X - c.Members.Location.X, 0);
|
||||||
c.Controls.Add(c.Members);
|
c.Controls.Add(c.Members);
|
||||||
c.Members.ForceDistanceUpdate(c);
|
c.Members.ForceDistanceUpdate(c);
|
||||||
c.tmp.HoverMouse = MouseCursor.Hand;
|
c.tmp.HoverMouse = MouseCursor.Hand;
|
||||||
|
@ -2,7 +2,6 @@ using GraphicsManager.Enums;
|
|||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
|
||||||
using Luski.net.Enums;
|
using Luski.net.Enums;
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using Luski.Shared.PublicServers.V1.Enums;
|
using Luski.Shared.PublicServers.V1.Enums;
|
||||||
@ -41,26 +40,12 @@ public class Channel : UserControl
|
|||||||
r.Textures.Add(tex);
|
r.Textures.Add(tex);
|
||||||
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
||||||
Controls.Add(r);
|
Controls.Add(r);
|
||||||
|
ChannelName = new Label(Globals.DefaultFont)
|
||||||
if (chan.ColorType == ColorType.Full)
|
|
||||||
{
|
{
|
||||||
ChannelName = new Label(Globals.DefaultFont)
|
Text = chan.Name,
|
||||||
{
|
Color = chan.Color.ToColor4(),
|
||||||
Text = chan.Name,
|
IgnoreHover = true
|
||||||
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);
|
Controls.Add(ChannelName);
|
||||||
Clicked += AllOnClicked;
|
Clicked += AllOnClicked;
|
||||||
ChannelName.Location = new(40.ScaleInt(),
|
ChannelName.Location = new(40.ScaleInt(),
|
||||||
@ -80,24 +65,12 @@ public class Channel : UserControl
|
|||||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||||
int i = 4.ScaleInt();
|
int i = 4.ScaleInt();
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
if (chan.ColorType == ColorType.Full)
|
ChannelName = new Label(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
ChannelName = new Label(Globals.DefaultFont)
|
Text = chan.Name,
|
||||||
{
|
Color = chan.Color.ToColor4(),
|
||||||
Text = chan.Name,
|
IgnoreHover = true
|
||||||
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);
|
Controls.Add(ChannelName);
|
||||||
Clicked += AllOnClicked;
|
Clicked += AllOnClicked;
|
||||||
ChannelName.Location = new(i,
|
ChannelName.Location = new(i,
|
||||||
@ -155,7 +128,7 @@ public class Channel : UserControl
|
|||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public LabelBase ChannelName;
|
public Label ChannelName;
|
||||||
public Rectangle r;
|
public Rectangle r;
|
||||||
|
|
||||||
public static async Task<Channel> MakeChannel(SocketChannel chan, ChannelSelector cs)
|
public static async Task<Channel> MakeChannel(SocketChannel chan, ChannelSelector cs)
|
||||||
|
@ -2,11 +2,8 @@ using System.Diagnostics;
|
|||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using GraphicsManager.Objects.Core;
|
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
|
||||||
using Luski.net.Structures.Main;
|
using Luski.net.Structures.Main;
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using Luski.Shared.PublicServers.V1.Enums;
|
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using OpenTK.Windowing.Common.Input;
|
using OpenTK.Windowing.Common.Input;
|
||||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||||
@ -23,7 +20,7 @@ public class ChatMessage : UserControl
|
|||||||
|
|
||||||
private IRenderObject LastObject;
|
private IRenderObject LastObject;
|
||||||
public List<IRenderObject> MessageObjs = new();
|
public List<IRenderObject> MessageObjs = new();
|
||||||
private LabelBase FirstL;
|
private Label FirstL;
|
||||||
|
|
||||||
public readonly double HorPadding = 12.ScaleDouble(),
|
public readonly double HorPadding = 12.ScaleDouble(),
|
||||||
VerticalPadding = 0.ScaleDouble();
|
VerticalPadding = 0.ScaleDouble();
|
||||||
@ -34,23 +31,18 @@ public class ChatMessage : UserControl
|
|||||||
{
|
{
|
||||||
SocketUser auth = (SocketUser)(await message.GetAuthor(CancellationToken.None));
|
SocketUser auth = (SocketUser)(await message.GetAuthor(CancellationToken.None));
|
||||||
ServerProfile prof = await message.GetProfile(CancellationToken.None);
|
ServerProfile prof = await message.GetProfile(CancellationToken.None);
|
||||||
Color[]? c = await prof.GetColors();
|
Color? c = await prof.GetColor();
|
||||||
ColorType? ct = await prof.GetColorType();
|
if (c is null) c = await auth.GetColor();
|
||||||
if (c is null)
|
Color4 c4 = c.ToColor4();
|
||||||
{
|
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), prof, await prof.MakeRct(auth, new(40.ScaleInt())), c4);
|
||||||
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, ColorType ct, Color4[] UserNameColor)
|
private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, ServerProfile Author, IRenderObject UserIcon, Color4 UserNameColor)
|
||||||
{
|
{
|
||||||
pc = p;
|
pc = p;
|
||||||
LabelBase label1;
|
Label label1;
|
||||||
base.SetSize(723.5.ScaleInt(), 37.ScaleInt());
|
base.Size = new(723.5.ScaleInt(), 37.ScaleInt());
|
||||||
ch = chan;
|
ch = chan;
|
||||||
base.BackgroundColor = new(40, 40, 40, 255);
|
base.BackgroundColor = new(40, 40, 40, 255);
|
||||||
Msg = message;
|
Msg = message;
|
||||||
@ -92,8 +84,7 @@ public class ChatMessage : UserControl
|
|||||||
|
|
||||||
UserIcon.Location = new(10.ScaleInt(), 2.ScaleInt(), 0);
|
UserIcon.Location = new(10.ScaleInt(), 2.ScaleInt(), 0);
|
||||||
Controls.Add(UserIcon);
|
Controls.Add(UserIcon);
|
||||||
if (ct == ColorType.Full) Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor[0], Text = Author.DisplayName });
|
Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor, Text = Author.DisplayName });
|
||||||
else Controls.Add(label1 = new AdvancedGradientLabel(Globals.DefaultFont) { Colors = UserNameColor, Text = Author.DisplayName });
|
|
||||||
label1.Location = new(
|
label1.Location = new(
|
||||||
54.ScaleInt(),
|
54.ScaleInt(),
|
||||||
UserIcon.Location.Y,
|
UserIcon.Location.Y,
|
||||||
@ -118,10 +109,6 @@ public class ChatMessage : UserControl
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
l.ContextMenu = lcm;
|
l.ContextMenu = lcm;
|
||||||
if (Msg.Context == "test message with picture")
|
|
||||||
{
|
|
||||||
//Console.WriteLine(Msg.FileIDs.Length);
|
|
||||||
}
|
|
||||||
MessageObjs.Add(l);
|
MessageObjs.Add(l);
|
||||||
}
|
}
|
||||||
Globals.Settings.DayTimeChanged += () =>
|
Globals.Settings.DayTimeChanged += () =>
|
||||||
@ -191,7 +178,7 @@ public class ChatMessage : UserControl
|
|||||||
public async Task AddMessage(SocketMessage msg)
|
public async Task AddMessage(SocketMessage msg)
|
||||||
{
|
{
|
||||||
BlockDraw = true;
|
BlockDraw = true;
|
||||||
LuskiLabel newLabel;
|
Label newLabel;
|
||||||
if (!string.IsNullOrWhiteSpace(msg.Context))
|
if (!string.IsNullOrWhiteSpace(msg.Context))
|
||||||
{
|
{
|
||||||
newLabel = new(Globals.MessageFont)
|
newLabel = new(Globals.MessageFont)
|
||||||
@ -212,7 +199,7 @@ public class ChatMessage : UserControl
|
|||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
newLabel.HoverMouse = MouseCursor.Hand;
|
newLabel.HoverMouse = MouseCursor.Hand;
|
||||||
newLabel.DefaultColor = Color4.Aqua;
|
newLabel.Color = Color4.Aqua;
|
||||||
newLabel.Clicked += NewLabelOnClicked;
|
newLabel.Clicked += NewLabelOnClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,8 @@ public class ContentEmbed : UserControl
|
|||||||
else if (size < 1000000000)
|
else if (size < 1000000000)
|
||||||
fst = Math.Round(size / (double)1000000, 2) + " MB";
|
fst = Math.Round(size / (double)1000000, 2) + " MB";
|
||||||
else if (size < 1000000000000) fst = Math.Round(size / (double)1000000000, 2) + " GB";
|
else if (size < 1000000000000) fst = Math.Round(size / (double)1000000000, 2) + " GB";
|
||||||
base.SetSize(333.ScaleInt(), 66.ScaleInt());
|
base.Size = new(333, 66);
|
||||||
base.BackgroundColor = new(40, 40, 40, 255);
|
BackgroundColor = new(40, 40, 40, 255);
|
||||||
Controls.Add(fileSizeLabel = new Label(Globals.DefaultFont) { Text = fst, Location = new(64, 39, 0) });
|
Controls.Add(fileSizeLabel = new Label(Globals.DefaultFont) { Text = fst, Location = new(64, 39, 0) });
|
||||||
Controls.Add(fileNameLabel = new Label(Globals.DefaultFont)
|
Controls.Add(fileNameLabel = new Label(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ using GraphicsManager;
|
|||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using GraphicsManager.Objects.Core;
|
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using Luski.Shared.PublicServers.V1.Enums;
|
using Luski.Shared.PublicServers.V1.Enums;
|
||||||
@ -20,7 +19,7 @@ public class PublicChat : UserControl
|
|||||||
{
|
{
|
||||||
|
|
||||||
public FlowLayout MessageFlow;
|
public FlowLayout MessageFlow;
|
||||||
private LabelBase title, desc;
|
private Label title, desc;
|
||||||
private TextBox tb;
|
private TextBox tb;
|
||||||
private SocketChannel? Channel;
|
private SocketChannel? Channel;
|
||||||
UserControl titlecon;
|
UserControl titlecon;
|
||||||
@ -30,7 +29,8 @@ public class PublicChat : UserControl
|
|||||||
|
|
||||||
public PublicChat()
|
public PublicChat()
|
||||||
{
|
{
|
||||||
base.SetSize(980.ScaleInt(), 866.ScaleInt());
|
|
||||||
|
base.Size = new(980.ScaleInt(), 866.ScaleInt());
|
||||||
base.BackgroundColor = new(40,40,40,255);
|
base.BackgroundColor = new(40,40,40,255);
|
||||||
Anchor = ObjectAnchor.All;
|
Anchor = ObjectAnchor.All;
|
||||||
Controls.Add(MessageFlow = new()
|
Controls.Add(MessageFlow = new()
|
||||||
@ -102,21 +102,8 @@ public class PublicChat : UserControl
|
|||||||
tb.ForceDistanceUpdate(this);
|
tb.ForceDistanceUpdate(this);
|
||||||
//tb.KeyPress += TbOnKeyPress;
|
//tb.KeyPress += TbOnKeyPress;
|
||||||
//Globals.Luski.MainServer.MessageReceived += LuskiOnMessageReceived;
|
//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 bool ssss = false;
|
||||||
|
|
||||||
private Task OnSizeChanged(IRenderObject arg)
|
private Task OnSizeChanged(IRenderObject arg)
|
||||||
@ -151,7 +138,7 @@ public class PublicChat : UserControl
|
|||||||
|
|
||||||
if (cm.Size.Y != ny)
|
if (cm.Size.Y != ny)
|
||||||
{
|
{
|
||||||
cm.SetSize(Size.X, ny);
|
cm.Size = new(Size.X, ny);
|
||||||
MessageFlow.ReportSizeUpdate(cm);
|
MessageFlow.ReportSizeUpdate(cm);
|
||||||
}
|
}
|
||||||
ssss = false;
|
ssss = false;
|
||||||
@ -182,11 +169,12 @@ public class PublicChat : UserControl
|
|||||||
|
|
||||||
private async Task TbOnKeyPress(KeyboardKeyEventArgs arg)
|
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)
|
if (arg.Key == Keys.Enter && !arg.Shift)
|
||||||
{
|
{
|
||||||
var file = await Channel!.Server.UploadFile("/home/jacob/Pictures/Points.png");
|
|
||||||
Console.WriteLine(file.ID);
|
await Channel!.SendMessage(tb.Text, FakeProfile: Globals.ServerProfile);
|
||||||
await Channel!.SendMessage(tb.Text, Profile: Globals.ServerProfile, files: file);
|
|
||||||
tb.Text = string.Empty;
|
tb.Text = string.Empty;
|
||||||
tb.CursorLocation = 0;
|
tb.CursorLocation = 0;
|
||||||
}
|
}
|
||||||
@ -196,7 +184,7 @@ public class PublicChat : UserControl
|
|||||||
{
|
{
|
||||||
BlockDraw = true;
|
BlockDraw = true;
|
||||||
tb.Location = new(tb.Location.X, tb.Location.Y + (int)tb.Font.PixelHeight, 0);
|
tb.Location = new(tb.Location.X, tb.Location.Y + (int)tb.Font.PixelHeight, 0);
|
||||||
MessageFlow.SetSize(MessageFlow.Size.X, MessageFlow.Size.Y + (int)tb.Font.PixelHeight);
|
MessageFlow.Size = new(MessageFlow.Size.X, MessageFlow.Size.Y + (int)tb.Font.PixelHeight);
|
||||||
BlockDraw = false;
|
BlockDraw = false;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
@ -375,46 +363,6 @@ public class PublicChat : UserControl
|
|||||||
public ChatMessage? LastChatMessageIndex;
|
public ChatMessage? LastChatMessageIndex;
|
||||||
private bool loadingm = false;
|
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)
|
public async Task LoadChannel(SocketChannel channel)
|
||||||
{
|
{
|
||||||
Channel = channel;
|
Channel = channel;
|
||||||
@ -426,31 +374,6 @@ public class PublicChat : UserControl
|
|||||||
memberflow.Controls.Clear();
|
memberflow.Controls.Clear();
|
||||||
await UserConOnClicked(UserCon!);
|
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;
|
title.Text = channel.Name;
|
||||||
var five = 5.ScaleInt();
|
var five = 5.ScaleInt();
|
||||||
title.Location = new(five + five,
|
title.Location = new(five + five,
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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; }
|
||||||
|
}
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ using Luski.net.Structures.Public;
|
|||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
|
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
|
||||||
|
|
||||||
public class RoleIcon : UserControl
|
public class RoleIcon : UserControl
|
||||||
{
|
{
|
||||||
@ -19,14 +19,13 @@ public class RoleIcon : UserControl
|
|||||||
TextureDisplay = TextureDisplay.HorizontalCenter;
|
TextureDisplay = TextureDisplay.HorizontalCenter;
|
||||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||||
base.Size = new(sri.RoleFlow.Size.X, 50.ScaleInt());
|
base.Size = new(sri.RoleFlow.Size.X, 50.ScaleInt());
|
||||||
//TODO what?
|
|
||||||
Rectangle Color = new(Globals.ms.TextureManager.GetAlphaCircle())
|
Rectangle Color = new(Globals.ms.TextureManager.GetAlphaCircle())
|
||||||
{
|
{
|
||||||
Size = new(12.ScaleInt()),
|
Size = new(12.ScaleInt()),
|
||||||
Location = new(4.ScaleInt(), 19.ScaleInt(), 0),
|
Location = new(4.ScaleInt(), 19.ScaleInt(), 0),
|
||||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||||
IgnoreHover = true,
|
IgnoreHover = true,
|
||||||
BackgroundColor = role.Colors[0].ToColor4()
|
BackgroundColor = role.Color.ToColor4()
|
||||||
};
|
};
|
||||||
Label name = new(Globals.ServerRoleFont)
|
Label name = new(Globals.ServerRoleFont)
|
||||||
{
|
{
|
@ -2,7 +2,7 @@ using GraphicsManager.Enums;
|
|||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings;
|
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
|
||||||
|
|
||||||
public class SaveWarning : UserControl
|
public class SaveWarning : UserControl
|
||||||
{
|
{
|
@ -4,7 +4,7 @@ using Luski.net;
|
|||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
|
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
|
||||||
|
|
||||||
public class ServerRoleInteraction : UserControl
|
public class ServerRoleInteraction : UserControl
|
||||||
{
|
{
|
||||||
@ -12,7 +12,7 @@ public class ServerRoleInteraction : UserControl
|
|||||||
public RoleIcon Selected;
|
public RoleIcon Selected;
|
||||||
public ServerRoleOptions SRO;
|
public ServerRoleOptions SRO;
|
||||||
|
|
||||||
public ServerRoleInteraction(PublicServer server, Roles srp)
|
public ServerRoleInteraction(PublicServer server, ServerRolePage srp)
|
||||||
{
|
{
|
||||||
Task<Role[]> task = Task.Run(() => server.GetRoles());
|
Task<Role[]> task = Task.Run(() => server.GetRoles());
|
||||||
task.Wait();
|
task.Wait();
|
@ -3,12 +3,14 @@ using System.Reflection;
|
|||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
|
using Luski.Classes;
|
||||||
|
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using Luski.Shared.PublicServers.V1.Enums;
|
using Luski.Shared.PublicServers.V1.Enums;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using DisplayNameAttribute = Luski.Shared.GlobalAttributes.DisplayNameAttribute;
|
using DisplayNameAttribute = Luski.Shared.GlobalAttributes.DisplayNameAttribute;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
|
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
|
||||||
|
|
||||||
public class ServerRoleOptions : UserControl
|
public class ServerRoleOptions : UserControl
|
||||||
{
|
{
|
||||||
@ -143,7 +145,6 @@ public class ServerRoleOptions : UserControl
|
|||||||
NeedMax.Clear();
|
NeedMax.Clear();
|
||||||
Type PropType = typeof(ServerPermission);
|
Type PropType = typeof(ServerPermission);
|
||||||
IEnumerable<ServerPermission> values = Enum.GetValues(PropType).Cast<ServerPermission>();
|
IEnumerable<ServerPermission> values = Enum.GetValues(PropType).Cast<ServerPermission>();
|
||||||
Dictionary<string, UserControl> Cats = new();
|
|
||||||
foreach (var val in values)
|
foreach (var val in values)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -151,27 +152,10 @@ public class ServerRoleOptions : UserControl
|
|||||||
MemberInfo? enumValueMemberInfo = Globals.GetMemberInfo(PropType, val);
|
MemberInfo? enumValueMemberInfo = Globals.GetMemberInfo(PropType, val);
|
||||||
string description = Globals.GetAttribute<DescriptionAttribute, ServerPermission>(enumValueMemberInfo!, val).Description;
|
string description = Globals.GetAttribute<DescriptionAttribute, ServerPermission>(enumValueMemberInfo!, val).Description;
|
||||||
string Name = Globals.GetAttribute<DisplayNameAttribute, ServerPermission>(enumValueMemberInfo!, val).DisplayName;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserControl tc = Globals.AddBool(Cats[cat], Name, description + " in the server.", r.ServerPermissions.HasFlag(val), _ =>
|
|
||||||
|
if (Name.ToLower() == "view this") continue;
|
||||||
|
Globals.AddBool(Page, Name, description + " in the server.", r.ServerPermissions.HasFlag(val), _ =>
|
||||||
{
|
{
|
||||||
TempPermissions ^= val;
|
TempPermissions ^= val;
|
||||||
if (TempPermissions != r.ServerPermissions)
|
if (TempPermissions != r.ServerPermissions)
|
||||||
@ -183,8 +167,6 @@ public class ServerRoleOptions : UserControl
|
|||||||
Warning.Visible = false;
|
Warning.Visible = false;
|
||||||
}
|
}
|
||||||
}, NeedMax);
|
}, 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
|
catch
|
||||||
@ -229,17 +211,6 @@ public class ServerRoleOptions : UserControl
|
|||||||
SelectedLine.Size = new(ManageMembers.Size.X, Line.Size.Y);
|
SelectedLine.Size = new(ManageMembers.Size.X, Line.Size.Y);
|
||||||
SelectedLine.Location = new(ManageMembers.Location.X, Line.Location.Y, Line.Location.Z);
|
SelectedLine.Location = new(ManageMembers.Location.X, Line.Location.Y, Line.Location.Z);
|
||||||
Page.Controls.Clear();
|
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;
|
BlockDraw = false;
|
||||||
TryDraw();
|
TryDraw();
|
||||||
}
|
}
|
@ -1,15 +1,14 @@
|
|||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
|
||||||
using Luski.net;
|
using Luski.net;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
|
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
|
||||||
|
|
||||||
public class Roles : PageFlow
|
public class ServerRolePage : PageBaseControl
|
||||||
{
|
{
|
||||||
private ServerRoleInteraction Page;
|
private ServerRoleInteraction Page;
|
||||||
|
|
||||||
public Roles(PublicServer ps)
|
public ServerRolePage(PublicServer ps)
|
||||||
{
|
{
|
||||||
PageName = "Roles";
|
PageName = "Roles";
|
||||||
Page = new(ps, this)
|
Page = new(ps, this)
|
||||||
@ -18,7 +17,7 @@ public class Roles : PageFlow
|
|||||||
Anchor = ObjectAnchor.All
|
Anchor = ObjectAnchor.All
|
||||||
};
|
};
|
||||||
Controls.Add(Page);
|
Controls.Add(Page);
|
||||||
Globals.ms.ForceUpdate();
|
Globals.ms.ForceUpdate(new(Globals.ms.CS));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Color4 BackgroundColor
|
public override Color4 BackgroundColor
|
@ -1,29 +1,39 @@
|
|||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
|
using Luski.GUI.MainScreen.UI.PublicServers.ServerSettingPages;
|
||||||
|
using Luski.net;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase;
|
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
||||||
|
|
||||||
public class SettingsMenu : UserControl
|
public class ServerSettings : UserControl
|
||||||
{
|
{
|
||||||
private string BehindName;
|
private string BehindName;
|
||||||
public PageTab? Selected;
|
public ServerSettingPageTab? Selected;
|
||||||
public FlowLayout fl;
|
public FlowLayout fl;
|
||||||
|
|
||||||
public SettingsMenu(string Name)
|
public ServerSettings(PublicServer ps)
|
||||||
{
|
{
|
||||||
base.BackgroundColor = new(34, 34, 34, 255);
|
base.BackgroundColor = new(34, 34, 34, 255);
|
||||||
base.Size = Globals.ms.ClientSize;
|
base.Size = Globals.ms.ClientSize;
|
||||||
BehindName = Globals.ms.Title;
|
BehindName = Globals.ms.Title;
|
||||||
Globals.ms.Title = Name;
|
Globals.ms.Title = $"Server Settings - Luski";
|
||||||
fl = new()
|
fl = new()
|
||||||
{
|
{
|
||||||
BackgroundColor = new(20, 20, 20, 255),
|
BackgroundColor = new(20, 20, 20, 255),
|
||||||
Size = new(307.ScaleInt(), base.Size.Y),
|
Size = new(307.ScaleInt(), base.Size.Y),
|
||||||
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
|
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;
|
Anchor = ObjectAnchor.All;
|
||||||
Controls.Add(fl);
|
Controls.Add(fl);
|
||||||
Rectangle closebtn = new(Globals.ms.TextureManager.GetTextureResource("close.png"))
|
Rectangle closebtn = new(Globals.ms.TextureManager.GetTextureResource("close.png"))
|
@ -1,27 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -94,7 +94,7 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
|
|||||||
Controls.Add(r);
|
Controls.Add(r);
|
||||||
base.BackgroundColor = new(26, 26, 26, 255);
|
base.BackgroundColor = new(26, 26, 26, 255);
|
||||||
this.Clicked += OnClicked;
|
this.Clicked += OnClicked;
|
||||||
base.SetSize(68.ScaleInt(), 48.ScaleInt());
|
base.Size = new(68.ScaleInt(), 48.ScaleInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnClicked(IRenderObject arg)
|
private async Task OnClicked(IRenderObject arg)
|
||||||
|
@ -338,7 +338,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
|
|||||||
DisplayName.Textures[0] = UserName.Textures[0];
|
DisplayName.Textures[0] = UserName.Textures[0];
|
||||||
rec.ForceDistanceUpdate(page);
|
rec.ForceDistanceUpdate(page);
|
||||||
Globals.ms.TryDraw();
|
Globals.ms.TryDraw();
|
||||||
Globals.ms.ForceUpdate();
|
Globals.ms.ForceUpdate(new(Size));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ca.Size = new((Form.Size.X - tb.Location.X - tb.Location.X - (tb.Location.X / 2)) / 2, ca.Size.Y);
|
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.Controls.Remove(this);
|
||||||
Globals.ms.ForceUpdate();
|
Globals.ms.ForceUpdate(new(Size));
|
||||||
Globals.ms.TryDraw();
|
Globals.ms.TryDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,7 +556,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
|
|||||||
|
|
||||||
private string pfp = "";
|
private string pfp = "";
|
||||||
|
|
||||||
private Task RecOnFilesDroped(IRenderObject obj, string[] arg)
|
private Task RecOnFilesDroped(string[] arg)
|
||||||
{
|
{
|
||||||
Console.WriteLine(arg[0]);
|
Console.WriteLine(arg[0]);
|
||||||
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;
|
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;
|
||||||
|
@ -9,7 +9,6 @@ using Luski.GUI.MainScreen.UI;
|
|||||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
using Luski.GUI.MainScreen.UI.LuskiSettings;
|
using Luski.GUI.MainScreen.UI.LuskiSettings;
|
||||||
using Luski.GUI.MainScreen.UI.PublicServers;
|
using Luski.GUI.MainScreen.UI.PublicServers;
|
||||||
using Luski.GUI.MainScreen.UI.PublicServers.ServerSettings;
|
|
||||||
using Luski.net;
|
using Luski.net;
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
using Luski.Shared.PublicServers.V1.Enums;
|
using Luski.Shared.PublicServers.V1.Enums;
|
||||||
@ -44,7 +43,7 @@ public class MainScreenWindow : Window
|
|||||||
public TabControl? tc;
|
public TabControl? tc;
|
||||||
private FlowLayout? channelpicker, friends, friend_request;
|
private FlowLayout? channelpicker, friends, friend_request;
|
||||||
private RoundedButton? FriendManagerBtn;
|
private RoundedButton? FriendManagerBtn;
|
||||||
public static DebugProc DebugMessageDelegate = OnDebugMessage;
|
private static DebugProc DebugMessageDelegate = OnDebugMessage;
|
||||||
private static GLFWCallbacks.ErrorCallback GLFW_Error = OnGLFW_Error;
|
private static GLFWCallbacks.ErrorCallback GLFW_Error = OnGLFW_Error;
|
||||||
|
|
||||||
private static void OnGLFW_Error(ErrorCode e, string d)
|
private static void OnGLFW_Error(ErrorCode e, string d)
|
||||||
@ -107,16 +106,12 @@ public class MainScreenWindow : Window
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MainScreenWindow() : base(Settings)
|
public MainScreenWindow() : base(Settings)
|
||||||
{
|
{
|
||||||
Globals.ms = this;
|
Globals.ms = this;
|
||||||
SetWindowSize(new(1332.ScaleInt(), 866.ScaleInt()));
|
Size = 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;
|
ShowMissingChar = true;
|
||||||
LogFrames = ((Globals.Settings.Logs & ConsoleLog.DrawFrames) == ConsoleLog.DrawFrames);
|
LogFrames = ((Globals.Settings.Logs & ConsoleLog.DrawFrames) == ConsoleLog.DrawFrames);
|
||||||
VSync = VSyncMode.On;
|
VSync = VSyncMode.On;
|
||||||
@ -210,7 +205,7 @@ public class MainScreenWindow : Window
|
|||||||
{
|
{
|
||||||
ServerLoginOverlay SLO = new(Server.Domain);
|
ServerLoginOverlay SLO = new(Server.Domain);
|
||||||
Controls.Add(SLO);
|
Controls.Add(SLO);
|
||||||
ForceUpdate();
|
ForceUpdate(new(ClientSize));
|
||||||
Globals.PrintParent(this);
|
Globals.PrintParent(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -224,7 +219,7 @@ public class MainScreenWindow : Window
|
|||||||
SerBox = new()
|
SerBox = new()
|
||||||
{
|
{
|
||||||
Location = new(ser.Size.X, 0, 0),
|
Location = new(ser.Size.X, 0, 0),
|
||||||
Size = new(Size.X - ser.Size.X, CS.Y),
|
Size = new(Size.X - ser.Size.X, ClientSize.Y),
|
||||||
Anchor = ObjectAnchor.All,
|
Anchor = ObjectAnchor.All,
|
||||||
BackgroundColor = new(20, 20, 20, 255)
|
BackgroundColor = new(20, 20, 20, 255)
|
||||||
};
|
};
|
||||||
@ -250,12 +245,12 @@ public class MainScreenWindow : Window
|
|||||||
};
|
};
|
||||||
if (await Server.User.HasPermissions(ServerPermission.ManageRoles))
|
if (await Server.User.HasPermissions(ServerPermission.ManageRoles))
|
||||||
{
|
{
|
||||||
ServerTitle.Clicked += _ =>
|
ServerTitle.Clicked += o =>
|
||||||
{
|
{
|
||||||
PublicServerSettingsMenu sm = new(Server);
|
ServerSettings sm = new(Server);
|
||||||
Controls.Add(sm);
|
Controls.Add(sm);
|
||||||
Globals.ms.DrawFrame();
|
Globals.ms.DrawFrame();
|
||||||
Globals.ms.ForceUpdate();
|
Globals.ms.ForceUpdate(new(Globals.ms.CS));
|
||||||
Globals.ms.DrawFrame();
|
Globals.ms.DrawFrame();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
@ -313,16 +308,10 @@ public class MainScreenWindow : Window
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region User Icon
|
#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);
|
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()));
|
IRenderObject u = await DefaultProfile.MakeRct(Server.User, new(46.ScaleInt()));
|
||||||
int ii = 4.ScaleInt();
|
int ii = 4.ScaleInt();
|
||||||
u.Location = new(ii, cs.Location.Y + cs.Size.Y + ii, 0);
|
u.Location = new(ii, cs.Location.Y + cs.Size.Y + ii, 0);
|
||||||
@ -330,25 +319,12 @@ public class MainScreenWindow : Window
|
|||||||
SerBox.Controls.Add(u);
|
SerBox.Controls.Add(u);
|
||||||
u.LoadToParent(SerBox, this);
|
u.LoadToParent(SerBox, this);
|
||||||
u.ForceDistanceUpdate();
|
u.ForceDistanceUpdate();
|
||||||
LabelBase ul;
|
Label ul = new Label(Globals.DefaultFont)
|
||||||
if (ct == ColorType.Full)
|
|
||||||
{
|
{
|
||||||
ul = new Label(Globals.DefaultFont)
|
Anchor = u.Anchor,
|
||||||
{
|
Text = DefaultProfile.DisplayName,
|
||||||
Anchor = u.Anchor,
|
Color = c4
|
||||||
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(),
|
ul.Location = new(u.Location.X + u.Size.X + 5.ScaleInt(),
|
||||||
(u.Location.Y + ((u.Size.Y - ul.Size.Y) / 2)), 0);
|
(u.Location.Y + ((u.Size.Y - ul.Size.Y) / 2)), 0);
|
||||||
@ -357,7 +333,7 @@ public class MainScreenWindow : Window
|
|||||||
Size = new(20.ScaleInt()),
|
Size = new(20.ScaleInt()),
|
||||||
Shader = Rectangle.DefaultAlphaShader[Context],
|
Shader = Rectangle.DefaultAlphaShader[Context],
|
||||||
BackgroundColor = Color4.Gray,
|
BackgroundColor = Color4.Gray,
|
||||||
Tag = new Tuple<SocketAppUser, IRenderObject, LabelBase>(Server.User, u, ul),
|
Tag = new Tuple<SocketAppUser, IRenderObject, Label>(Server.User, u, ul),
|
||||||
Anchor = u.Anchor
|
Anchor = u.Anchor
|
||||||
};
|
};
|
||||||
Expand.Clicked += ExpandOnClicked;
|
Expand.Clicked += ExpandOnClicked;
|
||||||
@ -384,12 +360,12 @@ public class MainScreenWindow : Window
|
|||||||
BackgroundColor = Color4.Gray,
|
BackgroundColor = Color4.Gray,
|
||||||
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left
|
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left
|
||||||
};
|
};
|
||||||
setting.MouseEnter += _ =>
|
setting.MouseEnter += o =>
|
||||||
{
|
{
|
||||||
setting.BackgroundColor = Color4.White;
|
setting.BackgroundColor = Color4.White;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
setting.MouseLeave += _ =>
|
setting.MouseLeave += o =>
|
||||||
{
|
{
|
||||||
setting.BackgroundColor = Color4.Gray;
|
setting.BackgroundColor = Color4.Gray;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@ -397,7 +373,7 @@ public class MainScreenWindow : Window
|
|||||||
setting.Clicked += SettingOnClicked;
|
setting.Clicked += SettingOnClicked;
|
||||||
setting.ForceDistanceUpdate(SerBox);
|
setting.ForceDistanceUpdate(SerBox);
|
||||||
SerBox.Controls.Add(setting);
|
SerBox.Controls.Add(setting);
|
||||||
ForceUpdate();
|
ForceUpdate(new (Size));
|
||||||
TryDraw();
|
TryDraw();
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -409,63 +385,56 @@ public class MainScreenWindow : Window
|
|||||||
BlockDraw = false;
|
BlockDraw = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlowLayout? ProfileFlow;
|
private FlowLayout? ProfileFlow = null;
|
||||||
|
|
||||||
private async Task ExpandOnClicked(IRenderObject arg)
|
private async Task ExpandOnClicked(IRenderObject arg)
|
||||||
{
|
{
|
||||||
try
|
if (ProfileFlow is null)
|
||||||
{
|
{
|
||||||
if (ProfileFlow is null)
|
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))
|
||||||
{
|
{
|
||||||
ProfileFlow = new();
|
ProfileView con = await ProfileView.Make(s.Item1, prof, role);
|
||||||
Tuple<SocketAppUser, IRenderObject, LabelBase> s = (Tuple<SocketAppUser, IRenderObject, LabelBase>)arg.Tag!;
|
con.Clicked += async o =>
|
||||||
var role = (await s.Item1.GetRoles())[0];
|
|
||||||
foreach (ServerProfile prof in await s.Item1.GetProfiles(CancellationToken.None))
|
|
||||||
{
|
{
|
||||||
ProfileView con = await ProfileView.Make(s.Item1, prof, role);
|
IRenderObject iro = await prof.MakeRct(s.Item1, s.Item2.Size);
|
||||||
con.Clicked += async _ =>
|
iro.Location = s.Item2.Location;
|
||||||
{
|
iro.Distance = s.Item2.Distance;
|
||||||
IRenderObject iro = await prof.MakeRct(s.Item1, s.Item2.Size);
|
iro.Anchor = s.Item2.Anchor;
|
||||||
iro.Location = s.Item2.Location;
|
int oldx = s.Item3.Size.X;
|
||||||
iro.Distance = s.Item2.Distance;
|
s.Item2.Parent!.Controls.Add(iro);
|
||||||
iro.Anchor = s.Item2.Anchor;
|
s.Item2.Parent!.Controls.Remove(s.Item2);
|
||||||
int oldx = s.Item3.Size.X;
|
s.Item3.Text = prof.DisplayName;
|
||||||
s.Item2.Parent!.Controls.Add(iro);
|
Controls.Remove(ProfileFlow);
|
||||||
s.Item2.Parent!.Controls.Remove(s.Item2);
|
ProfileFlow = null;
|
||||||
s.Item3.Text = prof.DisplayName;
|
arg.Location = new(arg.Location.X - oldx + s.Item3.Size.X, arg.Location.Y, arg.Location.Z);
|
||||||
Controls.Remove(ProfileFlow);
|
arg.ForceDistanceUpdate(arg.Parent!);
|
||||||
ProfileFlow = null;
|
Globals.ServerProfile = prof;
|
||||||
arg.Location = new(arg.Location.X - oldx + s.Item3.Size.X, arg.Location.Y, arg.Location.Z);
|
arg.Tag = new Tuple<SocketAppUser, IRenderObject, Label>(s.Item1, iro, s.Item3);
|
||||||
arg.ForceDistanceUpdate(arg.Parent!);
|
TryDraw();
|
||||||
Globals.ServerProfile = prof;
|
};
|
||||||
arg.Tag = new Tuple<SocketAppUser, IRenderObject, LabelBase>(s.Item1, iro, s.Item3);
|
ProfileFlow.Controls.Add(con);
|
||||||
TryDraw();
|
ProfileFlow.Size = new((int)arg.SizeAsFloat.X, ProfileFlow.Size.Y + con.Size.Y);
|
||||||
};
|
}
|
||||||
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(),
|
ProfileFlow.Location = new(ser.Size.X + 5.ScaleInt(),
|
||||||
CS.Y - 54.ScaleInt() - ProfileFlow.Size.Y,
|
CS.Y - 54.ScaleInt() - ProfileFlow.Size.Y,
|
||||||
0);
|
0);
|
||||||
Controls.Add(ProfileFlow);
|
Controls.Add(ProfileFlow);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Controls.Remove(ProfileFlow);
|
|
||||||
ProfileFlow = null;
|
|
||||||
}
|
|
||||||
DrawFrame();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
Controls.Remove(ProfileFlow);
|
||||||
|
ProfileFlow = null;
|
||||||
}
|
}
|
||||||
|
DrawFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task SettingOnClicked(IRenderObject arg)
|
private Task SettingOnClicked(IRenderObject arg)
|
||||||
{
|
{
|
||||||
GlobalSettingsMenu sm = new();
|
SettingsMenu sm = new();
|
||||||
Controls.Add(sm);
|
Controls.Add(sm);
|
||||||
Globals.ms.DrawFrame();
|
Globals.ms.DrawFrame();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@ -488,7 +457,7 @@ public class MainScreenWindow : Window
|
|||||||
private async Task<Task> LoginOnChangeToApp()
|
private async Task<Task> LoginOnChangeToApp()
|
||||||
{
|
{
|
||||||
Controls.Clear();
|
Controls.Clear();
|
||||||
ForceUpdate();
|
ForceUpdate(new(ClientSize));
|
||||||
BlockDraw = true;
|
BlockDraw = true;
|
||||||
Title = "Luski";
|
Title = "Luski";
|
||||||
unsafe
|
unsafe
|
||||||
@ -510,11 +479,10 @@ public class MainScreenWindow : Window
|
|||||||
Controls.Add(ser = new FlowLayout()
|
Controls.Add(ser = new FlowLayout()
|
||||||
{
|
{
|
||||||
BackgroundColor = new(26, 26, 26, 255),
|
BackgroundColor = new(26, 26, 26, 255),
|
||||||
Size = new(68.ScaleInt(), CS.Y),
|
Size = new(68.ScaleInt(), ClientSize.Y),
|
||||||
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom,
|
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom,
|
||||||
Location = new(0,0,0)
|
Location = new(0,0,0)
|
||||||
});
|
});
|
||||||
ser.ForceDistanceUpdate(this);
|
|
||||||
ser.LoadToParent(this,this);
|
ser.LoadToParent(this,this);
|
||||||
DrawFrame();
|
DrawFrame();
|
||||||
DateTime utcNow = DateTime.UtcNow;
|
DateTime utcNow = DateTime.UtcNow;
|
||||||
@ -547,6 +515,11 @@ public class MainScreenWindow : Window
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnResize(ResizeEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnResize(e);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private Task AddButtonClicked(IRenderObject arg)
|
private Task AddButtonClicked(IRenderObject arg)
|
||||||
{
|
{
|
||||||
|
105
Luski/Globals.cs
105
Luski/Globals.cs
@ -2,7 +2,6 @@ using System.CodeDom.Compiler;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization.Metadata;
|
using System.Text.Json.Serialization.Metadata;
|
||||||
using GraphicsManager;
|
using GraphicsManager;
|
||||||
@ -201,19 +200,11 @@ public static class Globals
|
|||||||
|
|
||||||
public static Texture GetTextureResource(this TextureManager tm, string File)
|
public static Texture GetTextureResource(this TextureManager tm, string File)
|
||||||
{
|
{
|
||||||
try
|
if (!TextureResources.ContainsKey(tm)) TextureResources.Add(tm, new());
|
||||||
{
|
if (TextureResources[tm].TryGetValue(File, out Texture? t)) return t;
|
||||||
if (!TextureResources.ContainsKey(tm)) TextureResources.Add(tm, new());
|
t = tm.AddTexture(GetResource($"Textures.{File}"));
|
||||||
if (TextureResources[tm].TryGetValue(File, out Texture? t)) return t;
|
TextureResources[tm].Add(File,t);
|
||||||
t = tm.AddTexture(GetResource($"Textures.{File}"));
|
return t;
|
||||||
TextureResources[tm].Add(File,t);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream GetResource(string File)
|
public static Stream GetResource(string File)
|
||||||
@ -260,7 +251,7 @@ public static class Globals
|
|||||||
public static API Luski { get; } = new();
|
public static API Luski { get; } = new();
|
||||||
public static MainScreenWindow ms;
|
public static MainScreenWindow ms;
|
||||||
|
|
||||||
public static UserControl AddBool(IParent parent, string Name, string description, bool s, Action<bool> a, List<Label>? List = null)
|
public static void AddBool(IParent parent, string Name, string description, bool s, Action<bool> a, List<Label>? List = null)
|
||||||
{
|
{
|
||||||
ToggleSwitch ts = new()
|
ToggleSwitch ts = new()
|
||||||
{
|
{
|
||||||
@ -298,7 +289,7 @@ public static class Globals
|
|||||||
};
|
};
|
||||||
l.Tag = TempLine;
|
l.Tag = TempLine;
|
||||||
TempLine.Size = new(parent.Size.X - space - space, 2.ScaleInt());
|
TempLine.Size = new(parent.Size.X - space - space, 2.ScaleInt());
|
||||||
tc.SetSize(parent.Size.X, TempLine.Location.Y + TempLine.Size.Y);
|
tc.Size = new(parent.Size.X, TempLine.Location.Y + TempLine.Size.Y);
|
||||||
TempLine.ForceDistanceUpdate(tc);
|
TempLine.ForceDistanceUpdate(tc);
|
||||||
tc.Controls.Add(TempLine);
|
tc.Controls.Add(TempLine);
|
||||||
//ts.ForceDistanceUpdate(tc);
|
//ts.ForceDistanceUpdate(tc);
|
||||||
@ -309,7 +300,6 @@ public static class Globals
|
|||||||
};
|
};
|
||||||
tc.ForceDistanceUpdate(parent);
|
tc.ForceDistanceUpdate(parent);
|
||||||
parent.Controls.Add(tc);
|
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
|
public static void AddBool<TEnum>(IParent parent, Type t, TEnum e, bool s, Action<bool> a, List<Label>? List = null) where TEnum : Enum
|
||||||
@ -369,35 +359,6 @@ public static class Globals
|
|||||||
return new(col.R, col.G, col.B, col.A);
|
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)
|
public static Color4 ToColor4(this Color? col)
|
||||||
{
|
{
|
||||||
return new(col!.Value.R, col.Value.G, col.Value.B, col.Value.A);
|
return new(col!.Value.R, col.Value.G, col.Value.B, col.Value.A);
|
||||||
@ -415,7 +376,6 @@ public static class Globals
|
|||||||
|
|
||||||
public static Dictionary<long, Texture> UserTextureMap = new();
|
public static Dictionary<long, Texture> UserTextureMap = new();
|
||||||
public static Dictionary<long, Texture> ProfileTextureMap = new();
|
public static Dictionary<long, Texture> ProfileTextureMap = new();
|
||||||
public static readonly Dictionary<IGLFWGraphicsContext, Shader> GradientShader = new Dictionary<IGLFWGraphicsContext, Shader>();
|
|
||||||
|
|
||||||
public static ServerProfile? ServerProfile = null;
|
public static ServerProfile? ServerProfile = null;
|
||||||
|
|
||||||
@ -427,44 +387,18 @@ public static class Globals
|
|||||||
UserControl r = new(t);
|
UserControl r = new(t);
|
||||||
r.Size = Size;
|
r.Size = Size;
|
||||||
r.Shader = Rectangle.DefaultAlphaShader[ms.Context];
|
r.Shader = Rectangle.DefaultAlphaShader[ms.Context];
|
||||||
ColorType ct = await User.GetColorType();
|
Color c = await User.GetColor();
|
||||||
Color[] c = await User.GetColors();
|
|
||||||
ColorType? cct = await Profile.GetColorType();
|
|
||||||
Color[]? cc = await Profile.GetColors();
|
|
||||||
if (cc is not null)
|
|
||||||
{
|
|
||||||
c = cc;
|
|
||||||
ct = cct!.Value;
|
|
||||||
}
|
|
||||||
r.BackgroundColor = new(25, 25, 25, 255);
|
r.BackgroundColor = new(25, 25, 25, 255);
|
||||||
if (ct == ColorType.Full)
|
Label l = new(DefaultFont)
|
||||||
{
|
{
|
||||||
Label l = new(DefaultFont)
|
Color = c.ToColor4()
|
||||||
{
|
};
|
||||||
Color = c[0].ToColor4()
|
l.Text = Profile.DisplayName[0].ToString();
|
||||||
};
|
var y = l.GetSizeOfChar(0);
|
||||||
l.Text = Profile.DisplayName[0].ToString();
|
l.Location = new((r.Size.X - l.Size.X)/2,
|
||||||
Vector2i y = l.GetSizeOfChar(0),
|
(int)(r.Size.Y - (l.Font.PixelHeight - y.Y) - (r.Size.Y / 2) - (y.Y/2)),
|
||||||
yy = l.GetBearingOfChar(0);
|
0);
|
||||||
l.Location = new((r.Size.X - l.Size.X)/2,
|
r.Controls.Add(l);
|
||||||
(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;
|
return r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -492,10 +426,9 @@ public static class Globals
|
|||||||
IgnoreHover = true,
|
IgnoreHover = true,
|
||||||
Text = Server.Name[0].ToString()
|
Text = Server.Name[0].ToString()
|
||||||
};
|
};
|
||||||
Vector2i y = l.GetSizeOfChar(0),
|
var y = l.GetSizeOfChar(0);
|
||||||
yy = l.GetBearingOfChar(0);
|
|
||||||
l.Location = new((r.Size.X - l.Size.X)/2,
|
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)),
|
(int)(r.Size.Y - (l.Font.PixelHeight - y.Y) - (r.Size.Y / 2) - (y.Y/2)),
|
||||||
0);
|
0);
|
||||||
r.Controls.Add(l);
|
r.Controls.Add(l);
|
||||||
return r;
|
return r;
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GraphicsManager" Version="1.1.0-alpha50" />
|
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha83" />
|
||||||
<PackageReference Include="Luski.net" Version="2.0.1-alpha15" />
|
<PackageReference Include="Luski.net" Version="2.0.1-alpha04" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -31,8 +31,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="GUI\MainScreen\UI\PublicServers\ServerSettings\Pages\Moderation\" />
|
|
||||||
<Folder Include="GUI\MainScreen\UI\PublicServers\ServerSettings\Pages\UserManagement\" />
|
|
||||||
<Folder Include="GUI\Windows\" />
|
<Folder Include="GUI\Windows\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Luski;
|
using Luski;
|
||||||
using Luski.Classes;
|
using Luski.Classes;
|
||||||
using Luski.GUI;
|
using Luski.GUI;
|
||||||
using OpenTK.Mathematics;
|
|
||||||
using OpenTK.Windowing.Common.Input;
|
using OpenTK.Windowing.Common.Input;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
@ -10,23 +9,6 @@ using Image = OpenTK.Windowing.Common.Input.Image;
|
|||||||
|
|
||||||
try
|
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);
|
Globals.Settings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
|
||||||
foreach (ExperimentInfo le in LuskiExperiments.LuskiExperimentsList)
|
foreach (ExperimentInfo le in LuskiExperiments.LuskiExperimentsList)
|
||||||
{
|
{
|
||||||
@ -90,16 +72,6 @@ try
|
|||||||
Globals.Icon = new WindowIcon(new Image(Logo.Width, Logo.Height, pixels));
|
Globals.Icon = new WindowIcon(new Image(Logo.Width, Logo.Height, pixels));
|
||||||
|
|
||||||
Logo.Dispose();
|
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;
|
MainScreenWindow.Settings.Icon = Globals.Icon;
|
||||||
Globals.ms = new MainScreenWindow();
|
Globals.ms = new MainScreenWindow();
|
||||||
Globals.ms.CustomF11 = false;
|
Globals.ms.CustomF11 = false;
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
#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);
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user