Rendering Improvements
New subframes. Working on better-centered content.
This commit is contained in:
parent
0b2bfe1635
commit
dff9100cf0
@ -1,4 +1,4 @@
|
|||||||
using Luski.GUI.MainScreen.UI.PublicServers;
|
using Luski.GUI.MainScreen.UI.Generic;
|
||||||
using Luski.net.Structures.Public;
|
using Luski.net.Structures.Public;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.Interfaces;
|
namespace Luski.GUI.MainScreen.Interfaces;
|
||||||
|
285
Luski/GUI/MainScreen/UI/AddServerOverlayForm.cs
Normal file
285
Luski/GUI/MainScreen/UI/AddServerOverlayForm.cs
Normal file
@ -0,0 +1,285 @@
|
|||||||
|
using GraphicsManager.Enums;
|
||||||
|
using GraphicsManager.Interfaces;
|
||||||
|
using GraphicsManager.Objects;
|
||||||
|
using GraphicsManager.Objects.Core;
|
||||||
|
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
|
using Luski.GUI.MainScreen.UI.LuskiControls.ServerForms;
|
||||||
|
using OpenTK.Mathematics;
|
||||||
|
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||||
|
|
||||||
|
namespace Luski.GUI.MainScreen.UI;
|
||||||
|
|
||||||
|
public class AddServerOverlayForm : UserControl
|
||||||
|
{
|
||||||
|
private TextBox tb;
|
||||||
|
private CreateAccountUI caUI = new();
|
||||||
|
private DropDown<VersionDropButton> version;
|
||||||
|
private LoginUI lUI = new()
|
||||||
|
{
|
||||||
|
Visible = false
|
||||||
|
};
|
||||||
|
|
||||||
|
private UserControl btn;
|
||||||
|
|
||||||
|
private TextBox UsernameTB
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (lUI.Visible) return lUI.Username;
|
||||||
|
return caUI.Username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextBox PasswordTB
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (lUI.Visible) return lUI.Password;
|
||||||
|
return caUI.Password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddServerOverlayForm()
|
||||||
|
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
|
||||||
|
{
|
||||||
|
base.Size = new(350.ScaleInt(), 347.ScaleInt());
|
||||||
|
base.BackgroundColor = new(32, 32, 32, 255);
|
||||||
|
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||||
|
TextureDisplay = TextureDisplay.Center;
|
||||||
|
Label t;
|
||||||
|
Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f, Text = "Add Server", Color = Globals.DodgerBlue });
|
||||||
|
t.Location = new((base.Size.X / 2) - (t.Size.X / 2), t.Location.Y, 0);
|
||||||
|
|
||||||
|
Label? ll = new Label(Globals.DefaultFont)
|
||||||
|
{
|
||||||
|
Text = net.API.DefaultVersion,
|
||||||
|
Color = Color4.DarkGray,
|
||||||
|
IgnoreHover = true
|
||||||
|
};
|
||||||
|
Vector2i s =new((int)(ll.Size.X * 1.6f),27.ScaleInt());
|
||||||
|
ll = null;
|
||||||
|
|
||||||
|
Rectangle line = new Rectangle()
|
||||||
|
{
|
||||||
|
Size = new Vector2i(1.ScaleInt()),
|
||||||
|
BackgroundColor = Globals.DodgerBlue
|
||||||
|
};
|
||||||
|
|
||||||
|
int ten = 10.ScaleInt();
|
||||||
|
|
||||||
|
tb = new("BadTextbox.png")
|
||||||
|
{
|
||||||
|
Location = new(ten,50.ScaleInt(), 0),
|
||||||
|
Size = (base.Size.X - ten - ten - ten - s.X, s.Y),
|
||||||
|
WatermarkText = "Server Address",
|
||||||
|
TextLocation = TextLocation.LineCenter,
|
||||||
|
AllowMultiLine = false
|
||||||
|
};
|
||||||
|
tb.LetterPress += () =>
|
||||||
|
{
|
||||||
|
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||||
|
|
||||||
|
if (tb.Textures[0].handel != good.handel)
|
||||||
|
{
|
||||||
|
tb.Textures[0] = good;
|
||||||
|
if (UsernameTB.Textures[0].handel == good.handel &&
|
||||||
|
PasswordTB.Textures[0].handel == good.handel &&
|
||||||
|
(lUI.Visible || caUI.Avatar.Textures.Count > 1) &&
|
||||||
|
btn!.Textures[0].handel != good.handel &&
|
||||||
|
tb.Textures[0].handel == good.handel)
|
||||||
|
{
|
||||||
|
btn.Textures[0] = good;
|
||||||
|
}
|
||||||
|
Globals.ms.TryDraw();
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
};
|
||||||
|
tb.LetterRemoved += () =>
|
||||||
|
{
|
||||||
|
Texture bad = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||||
|
|
||||||
|
if (tb.Text.Length == 0 && tb.Textures[0].handel != bad.handel)
|
||||||
|
{
|
||||||
|
tb.Textures[0] = bad;
|
||||||
|
btn!.Textures[0] = bad;
|
||||||
|
Globals.ms.TryDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
};
|
||||||
|
tb.KeyPress += args =>
|
||||||
|
{
|
||||||
|
if (args.Key == Keys.Tab && !args.Shift)
|
||||||
|
{
|
||||||
|
UsernameTB.Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
};
|
||||||
|
|
||||||
|
Controls.Add(tb);
|
||||||
|
|
||||||
|
version = new DropDown<VersionDropButton>(Textures[0], line)
|
||||||
|
{
|
||||||
|
DropDownParentOverride = this,
|
||||||
|
Size = s,
|
||||||
|
BackgroundColor = new(255,20,20,255),
|
||||||
|
TextureDisplay = TextureDisplay.HorizontalCenter,
|
||||||
|
Shader = Shader,
|
||||||
|
Location = new(tb.Location.X + tb.Size.X + tb.Location.X, tb.Location.Y, 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (string v in Globals.Luski.SupportedVersions)
|
||||||
|
{
|
||||||
|
VersionDropButton option = new VersionDropButton(s, v)
|
||||||
|
{
|
||||||
|
LoadDisplay = () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Label ll2 = new Label(Globals.DefaultFont)
|
||||||
|
{
|
||||||
|
Text = v,
|
||||||
|
Color = Color4.DarkGray,
|
||||||
|
IgnoreHover = true,
|
||||||
|
|
||||||
|
};
|
||||||
|
ll2.Location = new((version.Size.X / 2) - (ll2.Size.X / 2),
|
||||||
|
((version.Size.Y - ll2.Size.Y) / 2)
|
||||||
|
, 0);
|
||||||
|
version.Controls.Add(ll2);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
version.AddOption(option);
|
||||||
|
if (v == net.API.DefaultVersion)
|
||||||
|
{
|
||||||
|
version.SetSelected(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
version.OpenStatusChanged += VersionOnOpenStatusChanged;
|
||||||
|
version.OptionSelected += VersionOnOptionSelected;
|
||||||
|
|
||||||
|
|
||||||
|
version.DropDownContainer.Textures.Add(Globals.ms.TextureManager.GetTextureResource("RoundedRectangleBottom.png"));
|
||||||
|
version.DropDownContainer.TextureDisplay = TextureDisplay.Center;
|
||||||
|
version.DropDownContainer.Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||||
|
version.DropDownContainer.BackgroundColor = version.BackgroundColor;
|
||||||
|
version.OpenStatusChanged += b =>
|
||||||
|
{
|
||||||
|
BlockDraw = true;
|
||||||
|
if (b)
|
||||||
|
{
|
||||||
|
version.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangleTop.png");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
version.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockDraw = false;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
btn = new(Globals.ms.TextureManager.GetTextureResource("BadTextbox.png"))
|
||||||
|
{
|
||||||
|
Location = new(tb.Location.X, tb.Location.Y + tb.Size.Y + tb.Location.X, 0),
|
||||||
|
Size = new(tb.Size.X, tb.Size.Y),
|
||||||
|
TextureDisplay = TextureDisplay.Center
|
||||||
|
};
|
||||||
|
Label sub = new(Globals.DefaultFont)
|
||||||
|
{
|
||||||
|
Text = "Submit",
|
||||||
|
IgnoreHover = true
|
||||||
|
};
|
||||||
|
sub.Location = new((btn.Size.X / 2) - (sub.Size.X / 2),
|
||||||
|
((btn.Size.Y - sub.Size.Y) / 2)
|
||||||
|
, 0);
|
||||||
|
sub.ForceDistanceUpdate(btn);
|
||||||
|
btn.Controls.Add(sub);
|
||||||
|
Controls.Add(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task VersionOnOpenStatusChanged(bool arg)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task VersionOnOptionSelected(VersionDropButton arg)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ParentResize()
|
||||||
|
{
|
||||||
|
BlockDraw = true;
|
||||||
|
for (int i = 0; i < Controls.Length; i++)
|
||||||
|
{
|
||||||
|
if (!Controls[i].Loaded) continue;
|
||||||
|
bool top = (Controls[i].Anchor & ObjectAnchor.Top) == ObjectAnchor.Top;
|
||||||
|
bool left = (Controls[i].Anchor & ObjectAnchor.Left) == ObjectAnchor.Left;
|
||||||
|
bool right = (Controls[i].Anchor & ObjectAnchor.Right) == ObjectAnchor.Right;
|
||||||
|
bool bottom = (Controls[i].Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
||||||
|
if (!top && !bottom) { Controls[i].Anchor |= ObjectAnchor.Top; top = true; }
|
||||||
|
if (!left && !right) { Controls[i].Anchor |= ObjectAnchor.Left; left = true; }
|
||||||
|
|
||||||
|
int lx, ly, sy, sx;
|
||||||
|
bool UpdateDistance = false;
|
||||||
|
if ((Controls[i].Anchor & ObjectAnchor.PreventWidthChange) == ObjectAnchor.PreventWidthChange)
|
||||||
|
{
|
||||||
|
UpdateDistance = true;
|
||||||
|
lx = Controls[i].Location.X + ((Size.X - Controls[i].Distance.X - Controls[i].Size.X - Controls[i].Location.X) / 2);
|
||||||
|
sx = Controls[i].Size.X;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lx = (left ? Controls[i].Location.X : Size.X - Controls[i].Distance.X - Controls[i].Size.X);
|
||||||
|
sx = (right ? Size.X - Controls[i].Distance.X - lx : Controls[i].Size.X);
|
||||||
|
}
|
||||||
|
if ((Controls[i].Anchor & ObjectAnchor.PreventHeightChange) == ObjectAnchor.PreventHeightChange)
|
||||||
|
{
|
||||||
|
UpdateDistance = true;
|
||||||
|
ly = Controls[i].Location.Y + ((Size.Y - Controls[i].Distance.Y - Controls[i].Size.Y - Controls[i].Location.Y) / 2);
|
||||||
|
sy = Controls[i].Size.Y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ly = (top ? Controls[i].Location.Y : Size.Y - Controls[i].Distance.Y - Controls[i].Size.Y);
|
||||||
|
sy = (bottom ? Size.Y - Controls[i].Distance.Y - ly : Controls[i].Size.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mooved = false;
|
||||||
|
Console.WriteLine(Controls[i].Location);
|
||||||
|
Console.WriteLine(Controls[i].Size);
|
||||||
|
Console.WriteLine("New X:{0} Y:{1} W:{2} H:{3}", lx, ly, sx, sy);
|
||||||
|
if (sx != Controls[i].Size.X || sy != Controls[i].Size.Y)
|
||||||
|
{
|
||||||
|
mooved = true;
|
||||||
|
Controls[i].SetSize(sx, sy);
|
||||||
|
}
|
||||||
|
if (lx != Controls[i].Location.X || ly != Controls[i].Location.Y)
|
||||||
|
{
|
||||||
|
mooved = true;
|
||||||
|
Controls[i].SetLocation(lx, ly);
|
||||||
|
}
|
||||||
|
if (UpdateDistance)
|
||||||
|
{
|
||||||
|
Controls[i].ForceDistanceUpdate(this);
|
||||||
|
}
|
||||||
|
Console.WriteLine(mooved);
|
||||||
|
if (Controls[i] is IParent parent)
|
||||||
|
{
|
||||||
|
Console.WriteLine(Controls[i]);
|
||||||
|
parent.ParentResize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Parent is not null) Parent.TryDraw();
|
||||||
|
BlockDraw = false;
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ using Rectangle = GraphicsManager.Objects.Rectangle;
|
|||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI;
|
namespace Luski.GUI.MainScreen.UI;
|
||||||
|
|
||||||
public class AddServerOverlay : UserControl, IServerOverlay
|
public class AddServerOverlayld : UserControl, IServerOverlay
|
||||||
{
|
{
|
||||||
private UserControl Form, btn;
|
private UserControl Form, btn;
|
||||||
private DropDown<VersionDropButton> version;
|
private DropDown<VersionDropButton> version;
|
||||||
@ -24,7 +24,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
|||||||
|
|
||||||
private Rectangle? rec;
|
private Rectangle? rec;
|
||||||
|
|
||||||
public AddServerOverlay()
|
public AddServerOverlayld()
|
||||||
{
|
{
|
||||||
base.Size = Globals.ms.ClientSize;
|
base.Size = Globals.ms.ClientSize;
|
||||||
base.BackgroundColor = new(0, 0, 0, 130);
|
base.BackgroundColor = new(0, 0, 0, 130);
|
||||||
@ -582,7 +582,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
|
|||||||
Globals.ServerList.Servers = l.ToArray();
|
Globals.ServerList.Servers = l.ToArray();
|
||||||
Globals.ServerList.SaveSettings(Path.Combine(Globals.LuskiPath, "Servers.json"), ServerListContext.Default.ServerList);
|
Globals.ServerList.SaveSettings(Path.Combine(Globals.LuskiPath, "Servers.json"), ServerListContext.Default.ServerList);
|
||||||
ServerIcon<PublicServer> ss = new ServerIcon<PublicServer>(ps);
|
ServerIcon<PublicServer> ss = new ServerIcon<PublicServer>(ps);
|
||||||
Globals.ms.ser.Controls.Insert(Globals.ms.ser.Controls.Length - 1, ss);
|
Globals.ms.ServerFlow.Controls.Insert(Globals.ms.ServerFlow.Controls.Length - 1, ss);
|
||||||
await ss.LoadServer();
|
await ss.LoadServer();
|
||||||
Globals.ms.Controls.Remove(this);
|
Globals.ms.Controls.Remove(this);
|
||||||
Globals.ms.TryDraw();
|
Globals.ms.TryDraw();
|
@ -5,10 +5,9 @@ using GraphicsManager.Objects.Core;
|
|||||||
using Luski.GUI.MainScreen.Interfaces;
|
using Luski.GUI.MainScreen.Interfaces;
|
||||||
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 OpenTK.Windowing.Common.Input;
|
using OpenTK.Windowing.Common.Input;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
namespace Luski.GUI.MainScreen.UI.Generic;
|
||||||
|
|
||||||
public class Category : UserControl, IChannelAdder
|
public class Category : UserControl, IChannelAdder
|
||||||
{
|
{
|
@ -3,14 +3,13 @@ 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.GUI.MainScreen.UI.LuskiControls;
|
||||||
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;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using OpenTK.Windowing.Common.Input;
|
using OpenTK.Windowing.Common.Input;
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
namespace Luski.GUI.MainScreen.UI.Generic;
|
||||||
|
|
||||||
public class Channel : UserControl
|
public class Channel : UserControl
|
||||||
{
|
{
|
||||||
@ -106,19 +105,19 @@ public class Channel : UserControl
|
|||||||
CS.Selected = this;
|
CS.Selected = this;
|
||||||
IReadOnlyList<SocketMessage> m;
|
IReadOnlyList<SocketMessage> m;
|
||||||
m = await CurrentChannel.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel);
|
m = await CurrentChannel.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel);
|
||||||
Globals.ms.pc.ClearChat();
|
Globals.ms.ChatBoxArea.ClearChat();
|
||||||
await Globals.ms.pc.LoadChannel(CurrentChannel);
|
await Globals.ms.ChatBoxArea.LoadChannel(CurrentChannel);
|
||||||
mm = Globals.ms.pc.AddMessages(m);
|
mm = Globals.ms.ChatBoxArea.AddMessages(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mm is not null)
|
if (mm is not null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Waiting");
|
Console.WriteLine("Waiting");
|
||||||
Task.WaitAll(mm);
|
Task.WaitAll(mm);
|
||||||
Globals.ms.pc.MessageFlow.ForceScrollUpdate();
|
Globals.ms.ChatBoxArea.MessageFlow.ForceScrollUpdate();
|
||||||
if (Globals.ms.pc.MessageFlow.Controls.Length > 1 && Globals.ms.pc.MessageFlow.Controls[Globals.ms.pc.MessageFlow.Controls.Length - 1].Location.Y + Globals.ms.pc.MessageFlow.Controls[Globals.ms.pc.MessageFlow.Controls.Length - 1].Size.Y > Globals.ms.pc.MessageFlow.Size.Y)
|
if (Globals.ms.ChatBoxArea.MessageFlow.Controls.Length > 1 && Globals.ms.ChatBoxArea.MessageFlow.Controls[Globals.ms.ChatBoxArea.MessageFlow.Controls.Length - 1].Location.Y + Globals.ms.ChatBoxArea.MessageFlow.Controls[Globals.ms.ChatBoxArea.MessageFlow.Controls.Length - 1].Size.Y > Globals.ms.ChatBoxArea.MessageFlow.Size.Y)
|
||||||
Globals.ms.pc.MessageFlow.ScrollToBottom();
|
Globals.ms.ChatBoxArea.MessageFlow.ScrollToBottom();
|
||||||
else Globals.ms.pc.MessageFlow.ScrollToTop();
|
else Globals.ms.ChatBoxArea.MessageFlow.ScrollToTop();
|
||||||
Console.WriteLine("Done");
|
Console.WriteLine("Done");
|
||||||
}
|
}
|
||||||
BlockDraw = false;
|
BlockDraw = false;
|
@ -1,32 +1,25 @@
|
|||||||
using System.Runtime.CompilerServices;
|
|
||||||
using GraphicsManager.Enums;
|
|
||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using Luski.GUI.MainScreen.Interfaces;
|
using Luski.GUI.MainScreen.Interfaces;
|
||||||
|
using Luski.GUI.MainScreen.UI.PublicServers;
|
||||||
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;
|
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
namespace Luski.GUI.MainScreen.UI.Generic;
|
||||||
|
|
||||||
public class ChannelSelector : FlowLayout, IChannelAdder
|
public class ChannelSelector : FlowLayout, IChannelAdder
|
||||||
{
|
{
|
||||||
public SocketCategory CurrentCategory { get; }
|
public SocketCategory CurrentCategory { get; private set; }
|
||||||
private readonly List<Category> cc = new();
|
private readonly List<Category> cc = new();
|
||||||
private readonly List<Channel> LoadedChannels = new();
|
private readonly List<Channel> LoadedChannels = new();
|
||||||
public Dictionary<long, IChannelAdder> ChannelAdders = new();
|
public Dictionary<long, IChannelAdder> ChannelAdders = new();
|
||||||
public Channel? Selected;
|
public Channel? Selected;
|
||||||
|
|
||||||
private ChannelSelector(SocketCategory Cat)
|
public async Task LoadSelectorRoot(SocketCategory Cat)
|
||||||
{
|
{
|
||||||
CurrentCategory = Cat;
|
CurrentCategory = Cat;
|
||||||
ChannelAdders.Add(Cat.ID, this);
|
ChannelAdders.Add(Cat.ID, this);
|
||||||
Cat.Server.MessageReceived += ServerOnMessageReceived;
|
Cat.Server.MessageReceived += ServerOnMessageReceived;
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task<ChannelSelector> MakeSelector(SocketCategory Cat)
|
|
||||||
{
|
|
||||||
ChannelSelector cs = new(Cat);
|
|
||||||
bool MakeChannels = await Cat.Server.User.HasAccessToCategory(Cat, ServerPermission.CreateChannels);
|
bool MakeChannels = await Cat.Server.User.HasAccessToCategory(Cat, ServerPermission.CreateChannels);
|
||||||
bool MakeRoles = await Cat.Server.User.HasPermissions(ServerPermission.ManageRoles);
|
bool MakeRoles = await Cat.Server.User.HasPermissions(ServerPermission.ManageRoles);
|
||||||
if (MakeChannels || MakeRoles)
|
if (MakeChannels || MakeRoles)
|
||||||
@ -35,17 +28,15 @@ public class ChannelSelector : FlowLayout, IChannelAdder
|
|||||||
if (MakeChannels)
|
if (MakeChannels)
|
||||||
{
|
{
|
||||||
Label l = lcm.AddLabel("Create Channel");
|
Label l = lcm.AddLabel("Create Channel");
|
||||||
l.Clicked += cs.LOnClicked;
|
l.Clicked += LOnClicked;
|
||||||
}
|
}
|
||||||
if (MakeRoles)
|
if (MakeRoles)
|
||||||
{
|
{
|
||||||
Label l = lcm.AddLabel("Create Role");
|
Label l = lcm.AddLabel("Create Role");
|
||||||
l.Clicked += cs.RLOnClicked;
|
l.Clicked += RLOnClicked;
|
||||||
}
|
}
|
||||||
cs.ContextMenu = lcm;
|
ContextMenu = lcm;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RLOnClicked(IRenderObject arg)
|
private async Task RLOnClicked(IRenderObject arg)
|
||||||
@ -63,8 +54,8 @@ public class ChannelSelector : FlowLayout, IChannelAdder
|
|||||||
private async Task ServerOnMessageReceived(SocketMessage arg)
|
private async Task ServerOnMessageReceived(SocketMessage arg)
|
||||||
{
|
{
|
||||||
if (Selected is null || arg.ChannelID != Selected.CurrentChannel.ID) return;
|
if (Selected is null || arg.ChannelID != Selected.CurrentChannel.ID) return;
|
||||||
bool u = Globals.ms.pc.MessageFlow.MaxScrollValue == Globals.ms.pc.MessageFlow.ScrollValue;
|
bool u = Globals.ms.ChatBoxArea.MessageFlow.MaxScrollValue == Globals.ms.ChatBoxArea.MessageFlow.ScrollValue;
|
||||||
await Globals.ms.pc.AddMessage(arg, u);
|
await Globals.ms.ChatBoxArea.AddMessage(arg, u);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
using GraphicsManager.Enums;
|
||||||
|
using GraphicsManager.Interfaces;
|
||||||
|
using GraphicsManager.Objects;
|
||||||
|
|
||||||
|
namespace Luski.GUI.MainScreen.UI.LuskiControls;
|
||||||
|
|
||||||
|
public class CenterFullScreenBase : UserControl
|
||||||
|
{
|
||||||
|
private IRenderObject centerobj;
|
||||||
|
public CenterFullScreenBase(IRenderObject obj, bool Streach = false)
|
||||||
|
{
|
||||||
|
centerobj = obj;
|
||||||
|
if (!Streach) obj.Anchor = ObjectAnchor.Prevent;
|
||||||
|
else obj.Anchor = ObjectAnchor.All;
|
||||||
|
Controls.Add(obj);
|
||||||
|
base.BackgroundColor = new(0, 0, 0, 130);
|
||||||
|
Anchor = ObjectAnchor.All;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void LoadToParent(IParent p, IWindow w)
|
||||||
|
{
|
||||||
|
base.SetSize(w.CS.X, w.CS.Y);
|
||||||
|
centerobj.SetLocation((w.CS.X - centerobj.Size.X)/2, (w.CS.Y - centerobj.Size.Y)/2);
|
||||||
|
centerobj.ForceDistanceUpdate(this);
|
||||||
|
base.LoadToParent(p, w);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
using GraphicsManager.Objects;
|
||||||
|
|
||||||
|
namespace Luski.GUI.MainScreen.UI.LuskiControls.ServerForms;
|
||||||
|
|
||||||
|
public class CreateAccountUI : UserControl
|
||||||
|
{
|
||||||
|
public Rectangle Avatar = new();
|
||||||
|
public TextBox Username = new(), Password = new(), DisplayName = new();
|
||||||
|
}
|
13
Luski/GUI/MainScreen/UI/LuskiControls/ServerForms/LoginUI.cs
Normal file
13
Luski/GUI/MainScreen/UI/LuskiControls/ServerForms/LoginUI.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using GraphicsManager.Objects;
|
||||||
|
|
||||||
|
namespace Luski.GUI.MainScreen.UI.LuskiControls.ServerForms;
|
||||||
|
|
||||||
|
public class LoginUI : UserControl
|
||||||
|
{
|
||||||
|
public TextBox Username = new(), Password = new();
|
||||||
|
|
||||||
|
public LoginUI()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -41,7 +41,13 @@ public class SettingsMenu : UserControl
|
|||||||
};
|
};
|
||||||
closebtn.MouseLeave += _ =>
|
closebtn.MouseLeave += _ =>
|
||||||
{
|
{
|
||||||
|
if (bl) BlockDraw = true;
|
||||||
closebtn.BackgroundColor = Color4.Gray;
|
closebtn.BackgroundColor = Color4.Gray;
|
||||||
|
if (bl)
|
||||||
|
{
|
||||||
|
BlockDraw = false;
|
||||||
|
bl = false;
|
||||||
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
closebtn.Clicked += ClosebtnOnClicked;
|
closebtn.Clicked += ClosebtnOnClicked;
|
||||||
@ -49,8 +55,11 @@ public class SettingsMenu : UserControl
|
|||||||
Controls.Add(closebtn);
|
Controls.Add(closebtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool bl;
|
||||||
|
|
||||||
private Task ClosebtnOnClicked(IRenderObject arg)
|
private Task ClosebtnOnClicked(IRenderObject arg)
|
||||||
{
|
{
|
||||||
|
bl = true;
|
||||||
Globals.ms.Controls.Remove(this, false);
|
Globals.ms.Controls.Remove(this, false);
|
||||||
Globals.ms.Title = BehindName;
|
Globals.ms.Title = BehindName;
|
||||||
Globals.ms.DrawFrame();
|
Globals.ms.DrawFrame();
|
||||||
|
@ -20,8 +20,8 @@ public class TextBox : UserControl
|
|||||||
|
|
||||||
public int CursorLocation { get; set; }
|
public int CursorLocation { get; set; }
|
||||||
|
|
||||||
public TextBox()
|
public TextBox(string defaul = "Textbox.png")
|
||||||
:base(Globals.ms.TextureManager.GetTextureResource("Textbox.png"))
|
:base(Globals.ms.TextureManager.GetTextureResource(defaul))
|
||||||
{
|
{
|
||||||
t = new(500);
|
t = new(500);
|
||||||
t.Elapsed += TOnElapsed;
|
t.Elapsed += TOnElapsed;
|
||||||
@ -44,8 +44,10 @@ public class TextBox : UserControl
|
|||||||
(int)_label.LineHeight ),
|
(int)_label.LineHeight ),
|
||||||
Location = _watermark.Location,
|
Location = _watermark.Location,
|
||||||
BackgroundColor = Color4.White,
|
BackgroundColor = Color4.White,
|
||||||
Visible = false
|
Visible = false,
|
||||||
|
IgnoreHover = true
|
||||||
};
|
};
|
||||||
|
IgnoreVisForChildren = true;
|
||||||
Controls.Add(Pointer);
|
Controls.Add(Pointer);
|
||||||
|
|
||||||
Controls.Add(_label);
|
Controls.Add(_label);
|
||||||
|
@ -6,6 +6,7 @@ using GraphicsManager.Interfaces;
|
|||||||
using GraphicsManager.Objects;
|
using GraphicsManager.Objects;
|
||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using Luski.GUI.MainScreen.UI;
|
using Luski.GUI.MainScreen.UI;
|
||||||
|
using Luski.GUI.MainScreen.UI.Generic;
|
||||||
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;
|
||||||
@ -36,7 +37,7 @@ public class MainScreenWindow : Window
|
|||||||
APIVersion = new Version(3, 2),
|
APIVersion = new Version(3, 2),
|
||||||
API = ContextAPI.OpenGL,
|
API = ContextAPI.OpenGL,
|
||||||
StartFocused = true,
|
StartFocused = true,
|
||||||
Size = new Vector2i(624, 1090),
|
ClientSize = new Vector2i(624, 1090),
|
||||||
Icon = Globals.Icon,
|
Icon = Globals.Icon,
|
||||||
SharedContext = null,
|
SharedContext = null,
|
||||||
};
|
};
|
||||||
@ -120,7 +121,6 @@ public class MainScreenWindow : Window
|
|||||||
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;
|
||||||
|
|
||||||
GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero);
|
GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero);
|
||||||
GL.Enable(EnableCap.DebugOutput);
|
GL.Enable(EnableCap.DebugOutput);
|
||||||
GLFW.SetErrorCallback(GLFW_Error);
|
GLFW.SetErrorCallback(GLFW_Error);
|
||||||
@ -150,7 +150,6 @@ public class MainScreenWindow : Window
|
|||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Globals.DefaultFont.PixelHeight = Globals.Settings.DefaultFontPX.ScaleFont();
|
Globals.DefaultFont.PixelHeight = Globals.Settings.DefaultFontPX.ScaleFont();
|
||||||
Globals.DefaultFont.FontSize = FontSize.Regular;
|
Globals.DefaultFont.FontSize = FontSize.Regular;
|
||||||
Globals.TopTimeFont = Globals.DefaultFont.Clone();
|
Globals.TopTimeFont = Globals.DefaultFont.Clone();
|
||||||
@ -175,10 +174,13 @@ public class MainScreenWindow : Window
|
|||||||
CenterWindow();
|
CenterWindow();
|
||||||
}
|
}
|
||||||
WindowLoaded += OnWindowLoaded;
|
WindowLoaded += OnWindowLoaded;
|
||||||
|
BlockDraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnWindowLoaded(Window arg)
|
private async Task OnWindowLoaded(Window arg)
|
||||||
{
|
{
|
||||||
|
BlockDraw = false;
|
||||||
|
Console.WriteLine("start");
|
||||||
if (Globals.UpdaterSettings.AutoUpdateCheck && new HttpClient()
|
if (Globals.UpdaterSettings.AutoUpdateCheck && new HttpClient()
|
||||||
.GetAsync(
|
.GetAsync(
|
||||||
$"https://www.jacobtech.com/Updater/GetProgramVersion?directory=Luski&branch=main&selfcontained={Globals.UpdaterSettings.SelfContained.ToString().ToLower()}&platform={Globals.UpdaterSettings.Platform}")
|
$"https://www.jacobtech.com/Updater/GetProgramVersion?directory=Luski&branch=main&selfcontained={Globals.UpdaterSettings.SelfContained.ToString().ToLower()}&platform={Globals.UpdaterSettings.Platform}")
|
||||||
@ -196,9 +198,10 @@ public class MainScreenWindow : Window
|
|||||||
await LoginOnChangeToApp();
|
await LoginOnChangeToApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlowLayout ser;
|
public FlowLayout ServerFlow;
|
||||||
private UserControl? SerBox;
|
private UserControl SerBox, ServerTitle;
|
||||||
public PublicChat pc;
|
public PublicChat ChatBoxArea;
|
||||||
|
public ChannelSelector ChannelSelector;
|
||||||
|
|
||||||
public async Task LoadPublicServer(PublicServer? Server)
|
public async Task LoadPublicServer(PublicServer? Server)
|
||||||
{
|
{
|
||||||
@ -211,38 +214,25 @@ public class MainScreenWindow : Window
|
|||||||
ServerLoginOverlay SLO = new(Server.Domain);
|
ServerLoginOverlay SLO = new(Server.Domain);
|
||||||
Controls.Add(SLO);
|
Controls.Add(SLO);
|
||||||
ForceUpdate();
|
ForceUpdate();
|
||||||
Globals.PrintParent(this);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BlockDraw = true;
|
BlockDraw = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#region Box Init
|
#region Control Removing
|
||||||
|
|
||||||
if (SerBox is null)
|
|
||||||
{
|
|
||||||
SerBox = new()
|
|
||||||
{
|
|
||||||
Location = new(ser.Size.X, 0, 0),
|
|
||||||
Size = new(Size.X - ser.Size.X, CS.Y),
|
|
||||||
Anchor = ObjectAnchor.All,
|
|
||||||
BackgroundColor = new(20, 20, 20, 255)
|
|
||||||
};
|
|
||||||
Controls.Add(SerBox);
|
|
||||||
SerBox.LoadToParent(this, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ServerTitle.Controls.Clear();
|
||||||
|
ChannelSelector.Controls.Clear();
|
||||||
|
SerBox.Controls.Remove(ServerTitle, false);
|
||||||
|
SerBox.Controls.Remove(ChannelSelector, false);
|
||||||
SerBox.Controls.Clear();
|
SerBox.Controls.Clear();
|
||||||
|
SerBox.Controls.Add(ServerTitle);
|
||||||
|
SerBox.Controls.Add(ChannelSelector);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Server Title
|
#region Server Title
|
||||||
|
|
||||||
UserControl ServerTitle = new()
|
|
||||||
{
|
|
||||||
Size = new(307.ScaleInt(), 46.ScaleInt()),
|
|
||||||
BackgroundColor = new(30, 30, 30, 255)
|
|
||||||
};
|
|
||||||
Label title = new(Globals.DefaultFont)
|
Label title = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Text = Server.Name,
|
Text = Server.Name,
|
||||||
@ -280,35 +270,29 @@ public class MainScreenWindow : Window
|
|||||||
}
|
}
|
||||||
|
|
||||||
parents.Reverse();
|
parents.Reverse();
|
||||||
ChannelSelector cs = await ChannelSelector.MakeSelector(parents[0]);
|
await ChannelSelector.LoadSelectorRoot(parents[0]);
|
||||||
cs.BackgroundColor = new(34, 34, 34, 255);
|
|
||||||
cs.Location = new(0, ServerTitle.Size.Y +2.ScaleInt(), 0);
|
|
||||||
cs.Size = new(ServerTitle.Size.X, SerBox.Size.Y - 54.ScaleInt() - cs.Location.Y);
|
|
||||||
cs.Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom;
|
|
||||||
|
|
||||||
parents.RemoveAt(0);
|
parents.RemoveAt(0);
|
||||||
SerBox.Controls.Add(cs);
|
|
||||||
cs.ForceDistanceUpdate(SerBox);
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Chat Init
|
#region Chat Init
|
||||||
|
|
||||||
pc = new()
|
ChatBoxArea = new()
|
||||||
{
|
{
|
||||||
Anchor = ObjectAnchor.All,
|
Anchor = ObjectAnchor.All,
|
||||||
Location = new(cs.Size.X, 0, 0),
|
Location = new(ChannelSelector.Size.X, 0, 0),
|
||||||
Size = new(SerBox.Size.X - cs.Size.X, SerBox.Size.Y),
|
Size = new(SerBox.Size.X - ChannelSelector.Size.X, SerBox.Size.Y),
|
||||||
};
|
};
|
||||||
SerBox.Controls.Add(pc);
|
SerBox.Controls.Add(ChatBoxArea);
|
||||||
pc.LoadToParent(SerBox, this);
|
ChatBoxArea.LoadToParent(SerBox, this);
|
||||||
pc.ForceDistanceUpdate();
|
ChatBoxArea.ForceDistanceUpdate();
|
||||||
pc.MessageFlow.ForceDistanceUpdate(pc);
|
ChatBoxArea.MessageFlow.ForceDistanceUpdate(ChatBoxArea);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Channel Selector Loader
|
#region Channel Selector Loader
|
||||||
|
|
||||||
_ = cs.Load(current_channel, parents);
|
_ = ChannelSelector.Load(current_channel, parents);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -316,7 +300,7 @@ public class MainScreenWindow : Window
|
|||||||
ServerProfile DefaultProfile = await Server.GetProfile(Server.User.ServerProfile, CancellationToken.None);
|
ServerProfile DefaultProfile = await Server.GetProfile(Server.User.ServerProfile, CancellationToken.None);
|
||||||
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, ChannelSelector.Location.Y + ChannelSelector.Size.Y + ii, 0);
|
||||||
u.Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left;
|
u.Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left;
|
||||||
SerBox.Controls.Add(u);
|
SerBox.Controls.Add(u);
|
||||||
u.LoadToParent(SerBox, this);
|
u.LoadToParent(SerBox, this);
|
||||||
@ -364,11 +348,12 @@ public class MainScreenWindow : Window
|
|||||||
SerBox.Controls.Add(ul);
|
SerBox.Controls.Add(ul);
|
||||||
Rectangle setting = new(TextureManager.GetTextureResource("settings.png"))
|
Rectangle setting = new(TextureManager.GetTextureResource("settings.png"))
|
||||||
{
|
{
|
||||||
Location = new(cs.Size.X - 40.ScaleInt(), cs.Location.Y + cs.Size.Y + 11.ScaleInt(),0),
|
Location = new(ChannelSelector.Size.X - 40.ScaleInt(), ChannelSelector.Location.Y + ChannelSelector.Size.Y + 11.ScaleInt(),0),
|
||||||
Size = new(32.ScaleInt()),
|
Size = new(32.ScaleInt()),
|
||||||
Shader = Rectangle.DefaultAlphaShader[Context],
|
Shader = Rectangle.DefaultAlphaShader[Context],
|
||||||
BackgroundColor = Color4.Gray,
|
BackgroundColor = Color4.Gray,
|
||||||
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left
|
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left,
|
||||||
|
BlendOverride = true
|
||||||
};
|
};
|
||||||
setting.MouseEnter += _ =>
|
setting.MouseEnter += _ =>
|
||||||
{
|
{
|
||||||
@ -431,7 +416,7 @@ public class MainScreenWindow : Window
|
|||||||
ProfileFlow.Size = new((int)arg.SizeAsFloat.X, ProfileFlow.Size.Y + con.Size.Y);
|
ProfileFlow.Size = new((int)arg.SizeAsFloat.X, ProfileFlow.Size.Y + con.Size.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileFlow.Location = new(ser.Size.X + 5.ScaleInt(),
|
ProfileFlow.Location = new(ServerFlow.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);
|
||||||
@ -449,10 +434,15 @@ public class MainScreenWindow : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GlobalSettingsMenu? gsm;
|
||||||
|
|
||||||
private Task SettingOnClicked(IRenderObject arg)
|
private Task SettingOnClicked(IRenderObject arg)
|
||||||
{
|
{
|
||||||
GlobalSettingsMenu sm = new();
|
if (gsm is null)
|
||||||
Controls.Add(sm);
|
{
|
||||||
|
gsm = new GlobalSettingsMenu();
|
||||||
|
}
|
||||||
|
Controls.Add(gsm);
|
||||||
Globals.ms.DrawFrame();
|
Globals.ms.DrawFrame();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
@ -462,8 +452,8 @@ public class MainScreenWindow : Window
|
|||||||
if (SerBox is null)
|
if (SerBox is null)
|
||||||
SerBox = new()
|
SerBox = new()
|
||||||
{
|
{
|
||||||
Location = new(ser.Size.X, 0, 0),
|
Location = new(ServerFlow.Size.X, 0, 0),
|
||||||
Size = new(Size.X - ser.Size.X, Size.Y),
|
Size = new(Size.X - ServerFlow.Size.X, Size.Y),
|
||||||
Anchor = ObjectAnchor.All
|
Anchor = ObjectAnchor.All
|
||||||
};
|
};
|
||||||
Controls.Add(SerBox);
|
Controls.Add(SerBox);
|
||||||
@ -471,10 +461,54 @@ public class MainScreenWindow : Window
|
|||||||
SerBox.Controls.Clear();
|
SerBox.Controls.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnKeyDown(KeyboardKeyEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnKeyDown(e);
|
||||||
|
if (e.Key == Keys.F9)
|
||||||
|
{
|
||||||
|
Globals.PrintParent(this);
|
||||||
|
}
|
||||||
|
else if (e.Key == Keys.F10)
|
||||||
|
{
|
||||||
|
CheckParent(this);
|
||||||
|
}
|
||||||
|
else if (e.Key == Keys.F12)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Update Time: " + UpdateAdverage);
|
||||||
|
Console.WriteLine("Draw Time: " + DrawAdverage);
|
||||||
|
Console.WriteLine("Total Time: " + TotalAdverage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void CheckParent(IParent p, IRenderObject c, int xx, Vector3i di)
|
||||||
|
{
|
||||||
|
if (p.IgnoreVisForChildren || p.Controls.Length <= 1 || xx >= p.Controls.Length || !c.Visible || c is ILabel) return;
|
||||||
|
for (int i = xx; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (!p.Controls[i].IsVisible ||
|
||||||
|
((p.Controls[i].Location.X + di.X >= c.Location.X && p.Controls[i].Location.X + p.Controls[i].Size.X + di.X - c.Size.X <= c.Location.X) &&
|
||||||
|
(p.Controls[i].Location.Y + di.Y >= c.Location.Y && p.Controls[i].Location.Y + p.Controls[i].Size.Y + di.X - c.Size.Y <= c.Location.Y)))
|
||||||
|
{
|
||||||
|
p.Controls[i].NotifiNotVisible();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p.Controls[i] is IParent pp) CheckParent(pp, c, pp.Controls.Length-1, di + p.Controls[i].Location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void CheckParent(IParent p)
|
||||||
|
{
|
||||||
|
for (int i = p.Controls.Length - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
CheckParent(p, p.Controls[i], i-1, new());
|
||||||
|
if (p.Controls[i] is IParent pp) CheckParent(pp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<Task> LoginOnChangeToApp()
|
private async Task<Task> LoginOnChangeToApp()
|
||||||
{
|
{
|
||||||
Controls.Clear();
|
Controls.Clear();
|
||||||
ForceUpdate();
|
//ForceUpdate();
|
||||||
BlockDraw = true;
|
BlockDraw = true;
|
||||||
Title = "Luski";
|
Title = "Luski";
|
||||||
unsafe
|
unsafe
|
||||||
@ -493,55 +527,162 @@ public class MainScreenWindow : Window
|
|||||||
WindowBorder = WindowBorder.Resizable;
|
WindowBorder = WindowBorder.Resizable;
|
||||||
BackgroundColor = new Color4(20, 20, 20, 255);
|
BackgroundColor = new Color4(20, 20, 20, 255);
|
||||||
|
|
||||||
Controls.Add(ser = new FlowLayout()
|
Controls.Add(ServerFlow = new FlowLayout()
|
||||||
{
|
{
|
||||||
BackgroundColor = new(26, 26, 26, 255),
|
BackgroundColor = new(26, 26, 26, 255),
|
||||||
Size = new(68.ScaleInt(), CS.Y),
|
Size = new(68.ScaleInt(), CS.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);
|
ServerFlow.ForceDistanceUpdate(this);
|
||||||
ser.LoadToParent(this,this);
|
ServerFlow.LoadToParent(this,this);
|
||||||
DrawFrame();
|
DrawFrame();
|
||||||
DateTime utcNow = DateTime.UtcNow;
|
|
||||||
|
SerBox = new()
|
||||||
|
{
|
||||||
|
Location = new(ServerFlow.Size.X, 0, 0),
|
||||||
|
Size = new(Size.X - ServerFlow.Size.X, CS.Y),
|
||||||
|
Anchor = ObjectAnchor.All,
|
||||||
|
BackgroundColor = new(20, 20, 20, 255)
|
||||||
|
};
|
||||||
|
Controls.Add(SerBox);
|
||||||
|
SerBox.LoadToParent(this, this);
|
||||||
|
|
||||||
|
ServerTitle = new()
|
||||||
|
{
|
||||||
|
Size = new(307.ScaleInt(), 46.ScaleInt()),
|
||||||
|
BackgroundColor = new(30, 30, 30, 255)
|
||||||
|
};
|
||||||
|
SerBox.Controls.Add(ServerTitle);
|
||||||
|
|
||||||
|
|
||||||
|
ChannelSelector = new()
|
||||||
|
{
|
||||||
|
BackgroundColor = new(34, 34, 34, 255),
|
||||||
|
Location = new(0, ServerTitle.Size.Y +2.ScaleInt(), 0),
|
||||||
|
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
|
||||||
|
};
|
||||||
|
ChannelSelector.Size = new(ServerTitle.Size.X, SerBox.Size.Y - 54.ScaleInt() - ChannelSelector.Location.Y);
|
||||||
|
SerBox.Controls.Add(ChannelSelector);
|
||||||
|
ChannelSelector.ForceDistanceUpdate(SerBox);
|
||||||
|
|
||||||
|
Console.WriteLine("Waiting");
|
||||||
Task.WhenAll(Globals.ServersLoading.ToArray()).Wait();
|
Task.WhenAll(Globals.ServersLoading.ToArray()).Wait();
|
||||||
|
Console.WriteLine("Done waiting");
|
||||||
foreach (PublicServer pser in Globals.Luski.LoadedServers)
|
foreach (PublicServer pser in Globals.Luski.LoadedServers)
|
||||||
{
|
{
|
||||||
ServerIcon<PublicServer> si = new ServerIcon<PublicServer>(pser);
|
ServerIcon<PublicServer> si = new ServerIcon<PublicServer>(pser);
|
||||||
ser.Controls.Add(si);
|
ServerFlow.Controls.Add(si);
|
||||||
si.LoadToParent(ser, this);
|
si.LoadToParent(ServerFlow, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (PublicServer pser in Globals.Luski.FailedServers)
|
foreach (PublicServer pser in Globals.Luski.FailedServers)
|
||||||
{
|
{
|
||||||
Console.WriteLine(pser.Name);
|
Console.WriteLine(pser.Name);
|
||||||
ServerIcon<PublicServer> si = new ServerIcon<PublicServer>(pser, true);
|
ServerIcon<PublicServer> si = new ServerIcon<PublicServer>(pser, true);
|
||||||
ser.Controls.Add(si);
|
ServerFlow.Controls.Add(si);
|
||||||
si.LoadToParent(ser, this);
|
si.LoadToParent(ServerFlow, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddServerIcon asi = new();
|
AddServerIcon asi = new();
|
||||||
asi.Clicked += AddButtonClicked;
|
asi.Clicked += AddButtonClicked;
|
||||||
ser.Controls.Add(asi);
|
ServerFlow.Controls.Add(asi);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ser.Controls.Length > 1) (ser.Controls[0] as ServerIcon<PublicServer>)!.LoadServer().Start();
|
if (ServerFlow.Controls.Length > 1) (ServerFlow.Controls[0] as ServerIcon<PublicServer>)!.LoadServer().Start();
|
||||||
DrawFrame();
|
DrawFrame();
|
||||||
MainShow += OnMainShow;
|
MainShow += OnMainShow;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void ForceUpdate()
|
||||||
|
{
|
||||||
|
DateTime dt = DateTime.Now;
|
||||||
|
BlockDraw = true;
|
||||||
|
for (int i = 0; i < Controls.Length; i++)
|
||||||
|
{
|
||||||
|
if (!Controls[i].Loaded) continue;
|
||||||
|
bool top = (Controls[i].Anchor & ObjectAnchor.Top) == ObjectAnchor.Top;
|
||||||
|
bool left = (Controls[i].Anchor & ObjectAnchor.Left) == ObjectAnchor.Left;
|
||||||
|
bool right = (Controls[i].Anchor & ObjectAnchor.Right) == ObjectAnchor.Right;
|
||||||
|
bool bottom = (Controls[i].Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
||||||
|
if (!top && !bottom) { Controls[i].Anchor |= ObjectAnchor.Top; top = true; }
|
||||||
|
if (!left && !right) { Controls[i].Anchor |= ObjectAnchor.Left; left = true; }
|
||||||
|
|
||||||
|
int lx, ly, sy, sx;
|
||||||
|
bool UpdateDistance = false;
|
||||||
|
if ((Controls[i].Anchor & ObjectAnchor.PreventWidthChange) == ObjectAnchor.PreventWidthChange)
|
||||||
|
{
|
||||||
|
UpdateDistance = true;
|
||||||
|
lx = Controls[i].Location.X + ((CS.X - Controls[i].Distance.X - Controls[i].Size.X - Controls[i].Location.X) / 2);
|
||||||
|
sx = Controls[i].Size.X;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lx = (left ? Controls[i].Location.X : CS.X - Controls[i].Distance.X - Controls[i].Size.X);
|
||||||
|
sx = (right ? CS.X - Controls[i].Distance.X - lx : Controls[i].Size.X);
|
||||||
|
}
|
||||||
|
if ((Controls[i].Anchor & ObjectAnchor.PreventHeightChange) == ObjectAnchor.PreventHeightChange)
|
||||||
|
{
|
||||||
|
UpdateDistance = true;
|
||||||
|
ly = Controls[i].Location.Y + ((CS.Y - Controls[i].Distance.Y - Controls[i].Size.Y - Controls[i].Location.Y) / 2);
|
||||||
|
sy = Controls[i].Size.Y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ly = (top ? Controls[i].Location.Y : CS.Y - Controls[i].Distance.Y - Controls[i].Size.Y);
|
||||||
|
sy = (bottom ? CS.Y - Controls[i].Distance.Y - ly : Controls[i].Size.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls[i].SetSize(sx, sy);
|
||||||
|
Controls[i].SetLocation(lx, ly);
|
||||||
|
if (UpdateDistance)
|
||||||
|
{
|
||||||
|
Controls[i].ForceDistanceUpdate(this);
|
||||||
|
}
|
||||||
|
if (Controls[i] is IParent parent)
|
||||||
|
{
|
||||||
|
parent.ParentResize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (UpdateAdverage is null) UpdateAdverage = DateTime.Now - dt;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateAdverage = new((UpdateAdverage.Value.Ticks + (DateTime.Now - dt).Ticks)/2);
|
||||||
|
}
|
||||||
|
DateTime dtt = DateTime.Now;
|
||||||
|
DrawFrame();
|
||||||
|
if (DrawAdverage is null || TotalAdverage is null)
|
||||||
|
{
|
||||||
|
DrawAdverage = DateTime.Now - dtt;
|
||||||
|
TotalAdverage = DateTime.Now - dt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawAdverage = new((DrawAdverage.Value.Ticks + (DateTime.Now - dtt).Ticks)/2);
|
||||||
|
TotalAdverage = new((TotalAdverage.Value.Ticks + (DateTime.Now - dt).Ticks)/2);
|
||||||
|
}
|
||||||
|
BlockDraw = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TimeSpan? UpdateAdverage, DrawAdverage, TotalAdverage;
|
||||||
|
|
||||||
|
|
||||||
private Task AddButtonClicked(IRenderObject arg)
|
private Task AddButtonClicked(IRenderObject arg)
|
||||||
{
|
{
|
||||||
AddServerOverlay aso = new();
|
CenterFullScreenBase aso = new(new AddServerOverlayForm())
|
||||||
|
{
|
||||||
|
AllowHoverFromBehind = false
|
||||||
|
};
|
||||||
|
//AddServerOverlayld aso = new();
|
||||||
aso.Clicked += AsoOnClicked;
|
aso.Clicked += AsoOnClicked;
|
||||||
Controls.Add(aso);
|
Controls.Add(aso);
|
||||||
|
|
||||||
TryDraw();
|
aso.LoadToParent(this, this);
|
||||||
OnResize(new(CS));
|
GL.Scissor(0,0, CS.X, CS.Y);
|
||||||
|
aso.Draw(0,0,0,0, CS.X, CS.Y);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -550,7 +691,8 @@ public class MainScreenWindow : Window
|
|||||||
{
|
{
|
||||||
Globals.ms.Controls.Remove(arg);
|
Globals.ms.Controls.Remove(arg);
|
||||||
Globals.ms.DrawFrame();
|
Globals.ms.DrawFrame();
|
||||||
AddServerOverlay aso = (arg as AddServerOverlay)!;
|
CenterFullScreenBase aso = (arg as CenterFullScreenBase)!;
|
||||||
|
//AddServerOverlayld aso = (arg as AddServerOverlayld)!;
|
||||||
aso.Clicked -= AsoOnClicked;
|
aso.Clicked -= AsoOnClicked;
|
||||||
aso.Clean();
|
aso.Clean();
|
||||||
aso = null!;
|
aso = null!;
|
||||||
|
@ -110,7 +110,7 @@ public static class Globals
|
|||||||
for (int i = 0; i < p.Controls.Length; i++)
|
for (int i = 0; i < p.Controls.Length; i++)
|
||||||
{
|
{
|
||||||
if (p.Controls[i].IgnoreHover) continue;
|
if (p.Controls[i].IgnoreHover) continue;
|
||||||
Console.WriteLine(sp + p.Controls[i] + ": " + p.Controls[i].Location + " " + (p.Controls[i].Location + l) + " "+ p.Controls[i].Size);
|
Console.WriteLine(sp + p.Controls[i] + ": " + p.Controls[i].IsVisible + " " + p.Controls[i].Location + " " + (p.Controls[i].Location + l) + " "+ p.Controls[i].Size);
|
||||||
if (p.Controls[i] is IParent pp) PrintP(index + 1, pp, l + pp.Position);
|
if (p.Controls[i] is IParent pp) PrintP(index + 1, pp, l + pp.Position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GraphicsManager" Version="1.1.0-alpha68" />
|
<PackageReference Include="GraphicsManager" Version="1.1.0-alpha98" />
|
||||||
<PackageReference Include="Luski.net" Version="2.0.1-alpha17" />
|
<PackageReference Include="Luski.net" Version="2.0.1-alpha18" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -50,6 +50,7 @@ try
|
|||||||
switch (server.Main)
|
switch (server.Main)
|
||||||
{
|
{
|
||||||
case false:
|
case false:
|
||||||
|
// if (server.Domain == "jt.luskiserver.jacobtech.com") continue;
|
||||||
Globals.ServersLoading.Add(Task.Run(async () =>
|
Globals.ServersLoading.Add(Task.Run(async () =>
|
||||||
{
|
{
|
||||||
return await Globals.Luski.TryGetPublicServer(out _, server.Domain, server.Version,
|
return await Globals.Luski.TryGetPublicServer(out _, server.Domain, server.Version,
|
||||||
@ -76,7 +77,7 @@ try
|
|||||||
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;
|
||||||
Globals.ms.DrawFrame();
|
//Globals.ms.DrawFrame();
|
||||||
pixels = Array.Empty<byte>();
|
pixels = Array.Empty<byte>();
|
||||||
Globals.ms.StartRender();
|
Globals.ms.StartRender();
|
||||||
Globals.ms.Dispose();
|
Globals.ms.Dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user