dev #17

Merged
JacobTech merged 29 commits from dev into main 2024-04-11 15:50:14 -04:00
28 changed files with 648 additions and 1508 deletions
Showing only changes of commit 580d576e76 - Show all commits

View File

@ -1,590 +0,0 @@
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using JacobTechEncryption;
using Luski.GUI.MainScreen.Interfaces;
using Luski.GUI.MainScreen.UI;
using Luski.GUI.MainScreen.UI.PublicServers;
using Luski.GUI.StartPage.UI;
using Luski.net;
using Luski.net.Enums;
using Luski.net.Enums.Main;
using Luski.net.Interfaces;
using Luski.net.JsonTypes;
using Luski.net.Structures.Main;
using Luski.net.Structures.Public;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.Common;
using Window = GraphicsManager.Window;
namespace Luski.GUI.MainScreen;
public class MainScreen : Window
{
private static readonly NativeWindowSettings Settings = new()
{
Title = "Luski Login",
WindowBorder = WindowBorder.Fixed,
APIVersion = new Version(3, 2),
API = ContextAPI.OpenGL,
StartFocused = true,
Size = new Vector2i((int)(312 * Globals.Settings.Scale), (int)(545 * Globals.Settings.Scale)),
Icon = Globals.Icon,
SharedContext = null,
};
public TabControl? tc;
private FlowLayout? channelpicker, friends, friend_request;
private RoundedButton? FriendManagerBtn;
public Chat? chat;
Login login;
CreateAccount ca;
private static DebugProc DebugMessageDelegate = OnDebugMessage;
private static void OnDebugMessage(
DebugSource source, // Source of the debugging message.
DebugType type, // Type of the debugging message.
int id, // ID associated with the message.
DebugSeverity severity, // Severity of the message.
int length, // Length of the string in pMessage.
IntPtr pMessage, // Pointer to message string.
IntPtr pUserParam) // The pointer you gave to OpenGL, explained later.
{
// In order to access the string pointed to by pMessage, you can use Marshal
// class to copy its contents to a C# string without unsafe code. You can
// also use the new function Marshal.PtrToStringUTF8 since .NET Core 1.1.
string message = Marshal.PtrToStringAnsi(pMessage, length);
// The rest of the function is up to you to implement, however a debug output
// is always useful.
if (false)
{
switch (severity)
{
case DebugSeverity.DebugSeverityHigh:
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
Console.ResetColor();
break;
case DebugSeverity.DebugSeverityMedium:
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
Console.ResetColor();
break;
default:
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(message);
Console.ResetColor();
break;
}
}
}
public MainScreen() : base(Settings)
{
VSync = VSyncMode.On;
this.TryGetCurrentMonitorScale(out var h, out var v);
GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero);
GL.Enable(EnableCap.DebugOutput);
Globals.DefaultFontFamly = FontFamily.LoadFontFamily("Noto Sans").Result;
Globals.DefaultFont = FontInteraction.Load(Globals.DefaultFontFamly);
Globals.DefaultFont.PixelHeight = (uint)(20 * Globals.Settings.Scale);
Globals.DefaultFont.FontSize = FontSize.Regular;
Globals.TopTimeFont = Globals.DefaultFont.Clone();
Globals.TopTimeFont.PixelHeight = (uint)(12 * Globals.Settings.Scale);
Globals.TopTimeFont.FontSize = FontSize.Regular;
Globals.MessageFont = Globals.DefaultFont.Clone();
Globals.MessageFont.PixelHeight = (uint)(17 * Globals.Settings.Scale);
Globals.MessageFont.ExtraLinePixels = (uint)(5 * Globals.Settings.Scale);
Globals.MessageFont.FontSize = FontSize.Regular;
Globals.SmallTimeFont = Globals.DefaultFont.Clone();
Globals.LuskiTexture = TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Luski.png"));
CenterWindow(0);
if ((Globals.Luski.MainServer is not null && !Globals.Luski.MainServer.IsLogedIn) || !Globals.Luski.LoadedServers.Any(s => s.IsLogedIn))
{
Controls.Add(ca = new CreateAccount());
ca.Visible = false;
ca.ChangeToApp += LoginOnChangeToApp;
Controls.Add(login = new Login());
login.ChangeToApp += LoginOnChangeToApp;
login.ChangeToCa += LoginOnChangeToCa;
Thread t = new(_ =>
{
if (Globals.Luski.MainServer is not null)Globals.Luski.MainServer.EncryptionHandler.GenerateKeys();
});
t.Start();
}
WindowLoaded += OnWindowLoaded;
}
private Task OnWindowLoaded(Window arg)
{
if (Globals.UpdaterSettings.AutoUpdateCheck && new HttpClient().GetAsync($"https://www.jacobtech.com/Updater/GetProgramVersion?directory=Luski&branch={Globals.UpdaterSettings.Branch.ToString()}&selfcontained={Globals.UpdaterSettings.SelfContained.ToString().ToLower()}&platform={Globals.UpdaterSettings.Platform}").Result.Content.ReadAsStringAsync().Result != FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion)
{
var update = new UpdateWindow();
var result = update.ShowDialogue(this);
if (result == UpdateWindow.DialogueResult.Yes)
{
Globals.Download = true;
Close();
}
}
if ((Globals.Luski.MainServer is not null && Globals.Luski.MainServer.IsLogedIn) || Globals.Luski.LoadedServers.Any(s => s.IsLogedIn)) Invoke(() => LoginOnChangeToApp());
return Task.CompletedTask;
}
private Task LoginOnChangeToCa()
{
Title = "Create Account";
ca.Visible = true;
login.Visible = false;
return Task.CompletedTask;
}
public void AddGroup(MainSocketGroupChannel group)
{
Group friend = new(group);
friend.ClickCon += ChannelOnClickCon;
channelpicker!.Controls.Add(friend);
chans.Add(friend);
}
private readonly List<Friend> fr = new();
private List<IChannelPick> chans = new();
private Dictionary<long, int> FR_Index = new();
public void AddFriendRequest(MainSocketRemoteUser user)
{
FriendRequest frui = new(this, user);
FR_Index.Add(user.Id, friend_request!.Controls.Length);
friend_request.Controls.Add(frui);
}
public void RemoveFriendRequest(MainSocketRemoteUser user)
{
if (!FR_Index.ContainsKey(user.Id)) return;
friend_request!.Controls.Remove(friend_request!.Controls[FR_Index[user.Id]]);
}
public void AddFriend(MainSocketRemoteUser user)
{
Friend friend2 = new(user);
friend2.ClickCon += ChannelOnClickCon;
friends!.Controls.Add(friend2);
if (user.Channel is not null)
{
Friend friend = new(user);
friend.ClickCon += ChannelOnClickCon;
fr.Add(friend);
channelpicker!.Controls.Add(friend);
chans.Add(friend);
}
}
private CancellationTokenSource? channelCancellationToken = null;
private Task ChannelOnClickCon(IChannelPick arg)
{
try
{
BlockDraw = true;
Thread t = new(a => cc(a!));
t.Start(arg);
}
catch (Exception e)
{
Console.WriteLine(e);
}
return Task.CompletedTask;
}
private void cc(object argg)
{
try
{
IChannelPick arg = (IChannelPick)argg;
Invoke(new Action(() =>
{
chat!.UpdateTitle(arg);
}));
if (channelCancellationToken is not null)
{
channelCancellationToken.Cancel(false);
}
channelCancellationToken = new CancellationTokenSource();
//Globals.Luski.ChangeChannel(arg.Channel.Id, channelCancellationToken.Token).Wait();
Invoke(new Action(() =>
{
chat!.Clear();
}));
IReadOnlyList<MainSocketMessage> messages = arg.Channel.GetMessages(channelCancellationToken.Token, Globals.Settings.LoadPerChannel).Result;
foreach (MainSocketMessage message in messages.Reverse())
{
if (channelCancellationToken is null || channelCancellationToken.Token.IsCancellationRequested) return;
Invoke(new Action(() =>
{
chat!.AddMessage(TextureManager, message);
}));
}
if (channelCancellationToken is null || channelCancellationToken.Token.IsCancellationRequested) return;
channelCancellationToken = null;
Invoke(new Action(() =>
{
BlockDraw = false;
chat!.MessageFlow.ScrollToBottom();
DrawFrame();
}));
}
catch (Exception e)
{
if (e.Message.Contains("A task was canceled")) return;
Console.WriteLine(e);
}
}
public FlowLayout ser;
private UserControl? SerBox;
public PublicChat pc;
public async Task LoadPublicServer(PublicServer? Server)
{
if (Server is null) return;
BlockDraw = true;
try
{
#region Box Init
if (SerBox is null)
{
SerBox = new()
{
Location = new(ser.Size.X, 0),
Size = new(Size.X - ser.Size.X, Size.Y),
Anchor = ObjectAnchor.All,
BackgroundColor = new(20,20,20,255)
};
Controls.Add(SerBox);
SerBox.LoadToParent(this, this);
}
SerBox.Controls.Clear();
#endregion
#region Channel Selector Init
SocketChannel current_channel = await Server.User.GetSelectedChannel(CancellationToken.None);
Channel.SelectedTextures[0] = Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.al.png"));
Channel.SelectedTextures[1] = Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.ac.png"));
Channel.SelectedTextures[2] = Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.ar.png"));
List<SocketCategory> parents = new();
SocketCategory? cur = await current_channel.GetParent();
while (cur is not null)
{
parents.Add(cur);
cur = await cur.GetParent();
}
parents.Reverse();
ChannelSelector cs = new(parents[0])
{
BackgroundColor = new(34, 34, 34, 255),
Size = new((int)(307 * Globals.Settings.Scale), SerBox.Size.Y - 106),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
};
parents.RemoveAt(0);
SerBox.Controls.Add(cs);
cs.ForceDistanceUpdate(SerBox);
#endregion
#region Chat Init
pc = new()
{
Anchor = ObjectAnchor.All,
Location = new(cs.Size.X, 0),
Size = new(SerBox.Size.X - cs.Size.X, SerBox.Size.Y),
};
SerBox.Controls.Add(pc);
pc.LoadToParent(SerBox, this);
pc.ForceDistanceUpdate();
pc.MessageFlow.ForceDistanceUpdate(pc);
#endregion
#region Channel Selector Loader
_ = cs.Load(current_channel, parents);
#endregion
#region User Icon
Role[] ra = await Server.User.GetRoles();
Color c = ra[0].Color;
Color4 c4 = new(c.R, c.G, c.B, c.A);
Rectangle u=new Rectangle(TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Size = new((int)(46 * Globals.Settings.Scale)), Location = new((int)(4 * Globals.Settings.Scale), (int)(812 * Globals.Settings.Scale))};
u.Shader = Rectangle.DefaultAlphaTextureShader[Context];
u.Textures.Add(await Server.User.GetIcon());
SerBox.Controls.Add(u);
u.LoadToParent(SerBox, this);
u.ForceDistanceUpdate();
Label ul = new Label(Globals.DefaultFont)
{
Anchor = u.Anchor,
Text = Server.User.DisplayName,
Color = c4
};
ul.Location = new(u.Location.X + u.Size.X + (int)(5 * Globals.Settings.Scale),
(u.Location.Y + (u.Size.Y / 2) - (ul.PostiveTrueHeight / 2) - ul.Size.Y + ul.TrueHeight));
SerBox.Controls.Add(ul);
#endregion
}
catch (Exception e)
{
Console.WriteLine(e);
}
BlockDraw = false;
}
public async Task LoadMainServer(MainServer Server)
{
if (SerBox is null) SerBox = new()
{
Location = new(ser.Size.X, 0),
Size = new(Size.X - ser.Size.X, Size.Y),
Anchor = ObjectAnchor.All
};
Controls.Add(SerBox);
SerBox.ForceDistanceUpdate();
SerBox.Controls.Clear();
}
private async Task<Task> LoginOnChangeToApp()
{
Controls.Clear();
BlockDraw = true;
Title = "Luski";
Size = new((int)(1332 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale));
DateTime start = DateTime.Now;
CenterWindow(0);
DateTime start1 = DateTime.Now;
WindowBorder = WindowBorder.Resizable;
BackgroundColor = new Color4(34, 34, 34, 255);
Controls.Add(ser = new FlowLayout()
{
BackgroundColor = new(26, 26, 26, 255),
Size = new((int)(68 * Globals.Settings.Scale), (int)(868 * Globals.Settings.Scale)),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom,
});
// PublicServer? SelectedPublicServer;
DrawFrame();
if (Globals.Luski.MainServer is not null)
{
Texture uut =
TextureManager.AddTexture(Globals.Luski.MainServer.User.GetAvatar(CancellationToken.None).Result);
uut.Unit = TextureUnit.Texture1;
Label ul = new Label(Globals.DefaultFont)
{
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left,
Location = new(0, (int)(826 * Globals.Settings.Scale)), Text = Globals.Luski.MainServer.User.DisplayName
};
// ul.Location = new((int)(112 * Globals.Settings.Scale),
// (u.Location.Y + (u.Size.Y / 2) - (ul.PostiveTrueHeight / 2) - ul.Size.Y + ul.TrueHeight));
Controls.Add(ul);
Controls.Add(chat = new() { Location = new((int)(352 * Globals.Settings.Scale), 0) });
Controls.Add(tc = new(Globals.DefaultFont) // this is here to showcase my good friend TCLL
{
Location = chat.Location,
Size = chat.Size,
BackgroundColor = chat.BackgroundColor,
Anchor = ObjectAnchor.All,
Visible = false,
Border = (int)(10 * Globals.Settings.Scale),
TabSpace = (int)(5 * Globals.Settings.Scale),
});
tc.AddPage("Friends", friends = new FlowLayout()
{
BackgroundColor = new(45, 45, 45, 255)
});
tc.AddPage("Friend Request", friend_request = new FlowLayout()
{
BackgroundColor = new(45, 45, 45, 255)
});
tc.AddPage("Add Friend", new AddFriendPage(this));
ser.Controls.Add(new Rectangle(Globals.LuskiTexture)
{
Size = new((int)(52 * Globals.Settings.Scale)),
});
Controls.Add(channelpicker = new FlowLayout()
{
BackgroundColor = new(34, 34, 34, 255),
Size = new((int)(300 * Globals.Settings.Scale), (int)(800 * Globals.Settings.Scale)),
Location = new((int)(52 * Globals.Settings.Scale), 0),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
});
channelpicker.Controls.Add(FriendManagerBtn = new RoundedButton(Globals.DefaultFont)
{
Text = "Friends", Size = new((int)(52 * Globals.Settings.Scale)),
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan
});
FriendManagerBtn.Clicked += FriendManagerBtnOnClicked;
Console.WriteLine("Templates loaded in " + (DateTime.Now - start).TotalSeconds + " seconds");
MainSocketChannel sssss = Globals.Luski.MainServer.GetChannel<MainSocketChannel>(0, CancellationToken.None)
.Result;
_ = Globals.Luski.MainServer.User.Channels;
foreach (MainSocketGroupChannel ch in Globals.Luski.MainServer.User.Channels
.Where(s => s is MainSocketGroupChannel).Cast<MainSocketGroupChannel>())
{
AddGroup(ch);
}
foreach (MainSocketRemoteUser item in Globals.Luski.MainServer.User.Friends)
{
if (item.Channel is not null) AddFriend(item);
}
Console.WriteLine("Channels done in " + (DateTime.Now - start).TotalSeconds + " seconds");
MainSocketTextChannel chan = Globals.Luski.MainServer
.GetChannel<MainSocketTextChannel>(Globals.Luski.MainServer.User.SelectedChannel,
CancellationToken.None).Result;
chat.UpdateTitle(chans.First(s => s.Channel.Id == chan.Id));
chat.MessageFlow.BlockDraw = true;
try
{
IReadOnlyList<MainSocketMessage> messages =
chan.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel).Result;
Console.WriteLine("Messages done in " + (DateTime.Now - start).TotalSeconds + " seconds");
foreach (MainSocketMessage message in messages.Reverse())
{
chat.AddMessage(TextureManager, message);
}
chat.MessageFlow.ScrollToBottom();
}
catch (Exception e)
{
Console.WriteLine(e);
ChannelOnClickCon(chans.Where(s => s.Channel.Id == 0).First());
}
chat.MessageFlow.BlockDraw = false;
Console.WriteLine("Messages Fonts done in " + (DateTime.Now - start).TotalSeconds + " seconds");
foreach (MainSocketRemoteUser cufr in Globals.Luski.MainServer.User.FriendRequests)
{
AddFriendRequest(cufr);
}
Console.WriteLine("FR done in " + (DateTime.Now - start).TotalSeconds + " seconds");
BlockDraw = false;
DrawFrame();
Console.WriteLine("GUI done in " + (DateTime.Now - start1).TotalSeconds + " seconds");
}
foreach (PublicServer pser in Globals.Luski.LoadedServers)
{
ser.Controls.Add(new ServerIcon<PublicServer>(pser));
}
await (ser.Controls[0] as ServerIcon<PublicServer>)!.LoadServer();
MainShow += OnMainShow;
return Task.CompletedTask;
}
private Task OnMainShow()
{
if (Globals.Luski.MainServer is not null && Globals.Luski.MainServer.IsLogedIn)
{
Globals.Luski.MainServer.OnError += LuskiOnOnError;
Globals.Luski.MainServer.UserStatusUpdate += LuskiOnUserStatusUpdate;
Globals.Luski.MainServer.ReceivedFriendRequest += LuskiOnReceivedFriendRequest;
Globals.Luski.MainServer.FriendRequestResult += LuskiOnFriendRequestResult;
}
return Task.CompletedTask;
}
public event Func<Task>? MainShow;
private Task LuskiOnOnError(Exception arg)
{
Console.WriteLine(arg);
return Task.CompletedTask;
}
private Task LuskiOnFriendRequestResult(MainSocketRemoteUser arg1, bool arg2)
{
Console.WriteLine("new result");
Invoke(new Action(() =>
{
RemoveFriendRequest(arg1);
if (arg2) AddFriend(arg1);
}));
return Task.CompletedTask;
}
private Task LuskiOnReceivedFriendRequest(MainSocketRemoteUser arg)
{
Invoke(new Action(() =>
{
AddFriendRequest(arg);
}));
return Task.CompletedTask;
}
private Task LuskiOnUserStatusUpdate(IUser before, IUser After)
{
Console.WriteLine(before);
Console.WriteLine(After);
if (before is not MainSocketRemoteUser Before || Before.FriendStatus != FriendStatus.Friends || Before.Id == 0) return Task.CompletedTask;
Friend per = fr.Where(s => s.User.Id == before.Id).First()!;
Label stat = per.Status;
Invoke(new Action(() =>
{
per.rr.BackgroundColor = After.Status switch
{
UserStatus.Online => new(115, 255, 111, 255),
UserStatus.Idle => new(255, 229, 84, 255),
UserStatus.DoNotDisturb => new(255, 51, 79, 255),
UserStatus.Offline or UserStatus.Invisible or _ => Color4.LightGray
};
stat.Text = After.Status.ToString();
}));
return Task.CompletedTask;
}
private Task FriendManagerBtnOnClicked(IRenderObject arg)
{
if (chat!.Visible)
{
chat.Visible = false;
tc!.Visible = true;
}
else
{
chat.Visible = true;
tc!.Visible = false;
}
return Task.CompletedTask;
}
}

View File

@ -1,45 +0,0 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using Luski.net.Structures.Main;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.GraphicsLibraryFramework;
namespace Luski.GUI.MainScreen.UI;
public class AddFriendPage : FlowLayout
{
private MainScreen Screen;
private Textbox Input;
public AddFriendPage(MainScreen Parent)
{
this.Screen = Parent;
Size = new((int)(200 * Globals.Settings.Scale), (int)(48 * Globals.Settings.Scale));
BackgroundColor = new(45,45,45,255);
Controls.Add(Input = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right, Location = new((int)(7.5 * Globals.Settings.Scale)), Size = new((int)(185 * Globals.Settings.Scale),(int)(20 * Globals.Settings.Scale)), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan });
Input.KeyPress += InputOnKeyPress;
}
private Task InputOnKeyPress(KeyboardKeyEventArgs arg)
{
if (Input.BorderColor == Color4.Red) Input.BorderColor = Color4.DarkCyan;
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter) return Task.CompletedTask;
if (!long.TryParse(Input.Text, out long code))
{
Input.BorderColor = Color4.Red;
return Task.CompletedTask;
}
// MainSocketRemoteUser? result = Globals.Luski.MainServer.SendFriendRequest(code, CancellationToken.None).Result;
//if (result is null) Input.BorderColor = Color4.Red;
// else
// {
// if (result.Channel is null)
// Screen.AddFriendRequest(result);
// else
// Screen.AddFriend(result);
//}
return Task.CompletedTask;
}
}

View File

@ -0,0 +1,29 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI;
public class AddServerIcon : UserControl
{
public Rectangle Button;
public AddServerIcon()
{
Button = new(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.add.png")))
{
Location = new((int)(18 * Globals.Settings.Scale), (int)(8 * Globals.Settings.Scale), 0),
Size = new((int)(32 * Globals.Settings.Scale)),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.White
};
Controls.Add(Button);
BackgroundColor = new(26, 26, 26, 255);
base.Size = new((int)(68 * Globals.Settings.Scale), (int)(48 * Globals.Settings.Scale));
}
}

View File

@ -0,0 +1,15 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
namespace Luski.GUI.MainScreen.UI;
public class AddServerOverlay : UserControl
{
public AddServerOverlay()
{
base.Size = Globals.ms.Size;
BackgroundColor = new(0, 0, 0, 130);
Anchor = ObjectAnchor.All;
}
}

View File

@ -1,147 +0,0 @@
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.Interfaces;
using Luski.net;
using Luski.net.Enums;
using Luski.net.Enums.Main;
using Luski.net.JsonTypes;
using Luski.net.Structures.Main;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.GraphicsLibraryFramework;
namespace Luski.GUI.MainScreen.UI;
public class Chat : UserControl
{
public FlowLayout MessageFlow;
private Label title, desc;
private Textbox tb;
private MainSocketTextChannel? Channel;
public Chat()
{
UserControl titlecon;
Size = new((int)(980 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale));
BackgroundColor = new(50, 50, 50, 255);
Anchor = ObjectAnchor.All;
Controls.Add(MessageFlow = new()
{
Size = new(Size.X, (int)(761 * Globals.Settings.Scale)),
Location = new(0, (int)(52 * Globals.Settings.Scale)),
BackgroundColor = new(40,40,40,255),
Anchor = ObjectAnchor.All,
HScrollPixels = Globals.Settings.PerScrollPixels
});
Controls.Add(titlecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right, Size = new((int)(980 * Globals.Settings.Scale), (int)(52 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
{
//Location = new(
// (int)((26 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale),
// (int)((26 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight/2.0)))
});
titlecon.Controls.Add(desc = new Label(Globals.DefaultFont){ Color = new(161,161,161,255), Location = new(title.Location.X + title.Size.X + 5, title.Location.Y)});
Controls.Add(tb = new Textbox(Globals.DefaultFont, Globals.DefaultFont)
{
InsideColor = new(28, 28, 28, 255),
BorderColor = Color4.DarkCyan,
Location = new((int)(10 * Globals.Settings.Scale), (int)(824 * Globals.Settings.Scale)),
Size = new((int)(960 * Globals.Settings.Scale), (int)(34 * Globals.Settings.Scale)),
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right
});
tb.KeyPress += TbOnKeyPress;
Globals.Luski.MainServer.MessageReceived += LuskiOnMessageReceived;
}
private Task TbOnKeyPress(KeyboardKeyEventArgs arg)
{
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter) return Task.CompletedTask;
Thread t = new(() => Thr());
t.Start();
return Task.CompletedTask;
}
private void Thr()
{
//Globals.Luski.MainServer.SendMessage(tb.Text, Channel!.Id, CancellationToken.None);
Window!.Invoke(() => { tb.Text = string.Empty; });
}
private Task LuskiOnMessageReceived(MainSocketMessage arg)
{
if (Channel!.Id != arg.ChannelID) return Task.CompletedTask;
IRenderObject? reff = null;
if (MessageFlow.Controls.Length > 0) reff = MessageFlow.Controls[MessageFlow.Controls.Length - 1];
AddMessage(Window!.TextureManager, arg);
if (reff is null || (reff.Location.Y + reff.Size.Y <= MessageFlow.Size.Y && reff.Location.X >= 0)) Window.Invoke(() => { MessageFlow.ScrollToBottom();});
return Task.CompletedTask;
}
public void Clear()
{
MessageFlow.Controls.Clear();
lastm = null;
lastUser = null;
}
public void UpdateTitle(IChannelPick channelPick)
{
if (Channel is not null && Channel!.Id == channelPick.Channel.Id) return;
Channel = channelPick.Channel;
title.Text = channelPick.Channel.Title;
//tb.WatermarkFont = Globals.DefaultFont;
if (channelPick.Channel.Type == ChannelType.DM)
title.Text = (channelPick.Channel as MainSocketDMChannel)!.User.DisplayName;
tb.WatermarkText = "Message " + title.Text;
if (channelPick.Channel.Description is not null)
{
desc.Visible = true;
desc.Text = channelPick.Channel.Description;
desc.Location = new(title.Location.X + title.Size.X + 5, title.Location.Y);
}
else
{
desc.Visible = false;
}
}
private MainSocketMessage? lastm;
private long? lastUser;
private ChatMessage? LastChatMessage;
public void AddMessage(TextureManager m, MainSocketMessage Message)
{
bool hasbeentenmin = false;
if (lastm is not null)
hasbeentenmin =
new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(lastm.Id >> 22).ToLocalTime().AddMinutes(10) <
new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(Message.Id >> 22).ToLocalTime();
lastm = Message;
if (lastUser is null || lastUser != Message.AuthorID || hasbeentenmin)
{
if (Window is null || !Globals.ms.InvokeRequired)
{
MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(m, Message));
}
else
Globals.ms.Invoke(() =>
{
MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(m, Message));
Window.DrawFrame();
});
}
else
{
if (Window is null || !Globals.ms.InvokeRequired)
{
LastChatMessage!.AddMessage(Message);
}
else
Globals.ms.Invoke(() => { LastChatMessage!.AddMessage(Message); Window!.DrawFrame(); });
}
lastUser = Message.AuthorID;
}
}

View File

@ -1,202 +0,0 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net;
using Luski.net.Enums;
using Luski.net.Enums.Main;
using Luski.net.Interfaces;
using Luski.net.JsonTypes;
using Luski.net.Structures.Main;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI;
public class ChatMessage : UserControl
{
readonly int padding = 2;
private static Font TimeFont;// = Font.MakeFontFromSystem(13);
private MainSocketMessage Msg { get; }
private Label label2, lastm;
private static Dictionary<MainSocketRemoteUser, ContextMenu> Menues = new();
private static Dictionary<MainSocketRemoteUser, List<ChatMessage>> Messages = new();
public ChatMessage(TextureManager tm, MainSocketMessage message)
{
Label label1;
Size = new((int)(723.5 * Globals.Settings.Scale), (int)(37 * Globals.Settings.Scale));
BackgroundColor = new(40, 40, 40, 255);
Msg = message;
IUser user = message.GetAuthor(CancellationToken.None).Result;
Anchor = ObjectAnchor.Left | ObjectAnchor.Right;
Controls.Add(label1 = new Label(Globals.DefaultFont) { Location = new((int)(54 * Globals.Settings.Scale), (int)(6 * Globals.Settings.Scale)), Text = user.DisplayName});
DateTime time = new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(Msg.Id >> 22).ToLocalTime();
string timestr;
if (time.Date == DateTime.Now.ToLocalTime().Date)
{
timestr = $"Today at {time.ToShortTimeString()}";
}
else if (time.Date == DateTime.Now.ToLocalTime().AddDays(-1).Date)
{
timestr = $"Yesterday at {time.ToShortTimeString()}";
}
else
{
timestr = $"{time:M/dd/yyyy h:mm tt}";
}
Controls.Add(new Label(Globals.DefaultFont) { Scale = 0.8f, Location = new(label1.Location.X + label1.Size.X + 4, label1.Location.Y), Text = timestr});
Rectangle r = new Rectangle(tm.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Location = new((int)(10 * Globals.Settings.Scale), (int)(2 * Globals.Settings.Scale)), Size = new((int)(38 * Globals.Settings.Scale)) };
Texture tex = tm.AddTexture(user.GetAvatar(CancellationToken.None).Result);
tex.Unit = TextureUnit.Texture1;
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
r.Textures.Add(tex);
Controls.Add(r);
Controls.Add(label2 = new Label(Globals.DefaultFont) { Location = new(label1.Location.X, (int)(label1.Location.Y + label1.Font.PixelHeight + (5 * Globals.Settings.Scale))), Text = message.Context});
lastm = label2;
if (Msg.Files != null && Msg.Files.Length > 0)
{
int row = 1;
int filesonrow = 0;
for (int i = 0; i < Msg.Files.Length; i++)
{
int lx = (padding * filesonrow) + lastm.Location.X + (333 * (filesonrow + 1));
if (lx > Size.X)
{
row++;
filesonrow = 0;
lx = (padding * filesonrow) + lastm.Location.X + (333 * (filesonrow + 1));
}
filesonrow++;
Controls.Add(new ContentEmbed(Msg.Files[i], Msg.ChannelID)
{
Location = new(lx - 333, lastm.Location.Y + 2 + lastm.Size.Y +(padding * row) + (66 * (row - 1)))
});
}
}
if (user is MainSocketRemoteUser u && u.FriendStatus == FriendStatus.NotFriends)
{
Tag = u;
if (!Menues.ContainsKey(u))
{
ContextMenu m = new((int)(150 * Globals.Settings.Scale));
RoundedButton d;
m.Items.Add(d = new RoundedButton(Globals.DefaultFont)
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(25 * Globals.Settings.Scale)), Text = "Add Friend"
});
d.Tag = this;
Menues.Add(u,m);
Messages.Add(u, new());
d.Clicked += DOnClicked;
}
Messages[u].Add(this);
this.ContextMenu = Menues[u];
}
Size = new(Size.X, Controls[Controls.Length - 1].Location.Y + Controls[Controls.Length - 1].Size.Y + padding + 10);
}
private Task DOnClicked(IRenderObject arg)
{
if (arg.Tag is ChatMessage u && u.Tag is MainSocketRemoteUser uu)
{
foreach (ChatMessage cm in Messages[uu])
{
cm.ContextMenu!.IsVisible = false;
cm.ContextMenu!.Close();
cm.ContextMenu = null;
}
Messages.Remove(uu);
Menues.Remove(uu);
// MainSocketRemoteUser result = Globals.Luski.MainServer
// .SendFriendRequest(long.Parse(uu.friend_codes.First()), CancellationToken.None).Result;
// if (result.Channel is null)
// Globals.ms.AddFriendRequest(result);
// else
// Globals.ms.AddFriend(result);
}
return Task.CompletedTask;
}
public void AddMessage(MainSocketMessage msg)
{
Label newLabel = new(Globals.DefaultFont)
{
Text = msg.Context,
Tag = msg,
Location = new(label2.Location.X, Size.Y)
};
newLabel.MouseEnter += NewLabel_MouseEnter;
newLabel.MouseLeave += NewLabel_MouseLeave;
Controls.Add(newLabel);
if (msg.Files is not null && msg.Files.Length > 0)
{
int row = 1;
int filesonrow = 0;
for (int i = 0; i < msg.Files.Length; i++)
{
int lx = (padding * filesonrow) + lastm.Location.X + (333 * (filesonrow + 1));
if (lx > Size.X)
{
row++;
filesonrow = 0;
lx = (padding * filesonrow) + lastm.Location.X + (333 * (filesonrow + 1));
}
filesonrow++;
Controls.Add(new ContentEmbed(msg.Files[i], Msg.ChannelID)
{
Location = new(lx - 333, lastm.Location.Y + 2 + lastm.Size.Y +(padding * row) + (66 * (row - 1)))
});
}
}
Size = new(Size.X, Controls[Controls.Length - 1].Location.Y + Controls[Controls.Length - 1].Size.Y + padding + 10);
}
readonly List<Label> Labels = new();
private Task NewLabel_MouseLeave(IRenderObject sender)
{
if (sender is not Label label) return Task.CompletedTask;
if (label.Tag is not MainSocketMessage Message) return Task.CompletedTask;
DateTime time = new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(Message.Id >> 22).ToLocalTime();
string b = time.ToString("h:mm tt");
Label[] l = Labels.Where(s => s.Text == b).ToArray();
if (l.Any())
{
Controls.Remove(l.First());
Labels.Remove(l.First());
}
Window!.DrawFrame();
return Task.CompletedTask;
}
private Task NewLabel_MouseEnter(IRenderObject sender)
{
if (sender is not Label label) return Task.CompletedTask;
if (label.Tag is not MainSocketMessage Message) return Task.CompletedTask;
DateTime time = new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(Message.Id >> 22).ToLocalTime();
Label m = new(Globals.DefaultFont)
{
Text = time.ToString("h:mm tt"),
Location = new((int)(7.5 * Globals.Settings.Scale), label.Location.Y - 13 + (int)label.Font.PixelHeight),
};
Controls.Add(m);
Labels.Add(m);
Window!.DrawFrame();
return Task.CompletedTask;
}
}

View File

@ -1,49 +0,0 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using File = Luski.net.Structures.File;
namespace Luski.GUI.MainScreen.UI;
public class ContentEmbed : UserControl
{
readonly File file;
long channel;
public ContentEmbed(File file, long channel)
{
Label fileNameLabel, fileSizeLabel;
this.channel = channel;
this.file = file;
string fst = "";
ulong size = file.Size;
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";
Size = new(333, 66);
BackgroundColor = new(40, 40, 40, 255);
Controls.Add(fileSizeLabel = new Label(Globals.DefaultFont) {Text = fst, Location = new(64, 39)});
Controls.Add(fileNameLabel = new Label(Globals.DefaultFont) { Color = new(102/(float)255,227/(float)255,170/(float)255, 1), Text = file.Name, Location = new(64, 6)});
fileNameLabel.Clicked += FileNameLabelOnClicked;
Stream tempp = Tools.GetResourceStream(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Download.png");
Controls.Add(new Rectangle(Globals.ms.TextureManager.AddTexture(tempp)) { Location = new(8, 6), Size = new(50, 50)});
int temp = fileNameLabel.Size.X + fileNameLabel.Location.X;
int temp2 = fileSizeLabel.Size.X + fileSizeLabel.Location.X;
if (temp >= temp2) Size = new(temp + 4, Size.Y);
else Size = new(temp2 + 4, Size.Y);
}
private Task FileNameLabelOnClicked(IRenderObject arg)
{
string dir = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Downloads", "LuskiDownloads");
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
Thread t = new(() => file.DownloadBytes(Path.Join(dir, file.Name), channel, CancellationToken.None));
t.Start();
return Task.CompletedTask;
}
}

View File

@ -1,114 +0,0 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.Interfaces;
using Luski.GUI.Windows;
using Luski.net;
using Luski.net.Enums;
using Luski.net.JsonTypes;
using Luski.net.Structures.Main;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.GraphicsLibraryFramework;
namespace Luski.GUI.MainScreen.UI;
public class Friend : UserControl, IChannelPick
{
public MainSocketRemoteUser User;
public MainSocketTextChannel Channel
{
get
{
return User.Channel!;
}
}
public Rectangle r, rr;
public Label Username, Status;
public Friend(MainSocketRemoteUser person)
{
User = person;
Size = new((int)(240 * Globals.Settings.Scale), (int)(62* Globals.Settings.Scale));
BackgroundColor = new(34, 34, 34, 255);
Controls.Add(Username = new Label(Globals.DefaultFont) { Text = person.DisplayName, Location = new((int)(58 * Globals.Settings.Scale),(int)(14 * Globals.Settings.Scale))});
Controls.Add(Status = new Label(Globals.DefaultFont) { Scale = 0.8f, Text = person.Status.ToString(), Location = new((int)(58 * Globals.Settings.Scale),(int)(34* Globals.Settings.Scale))});
Controls.Add(this.rr=new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
Size = new ((int)(42 * Globals.Settings.Scale))
});
Username.Location = new(Username.Location.X,
(this.rr.Location.Y + (this.rr.Size.Y / 2) - ((Username.TrueHeight + 5 + Status.TrueHeight) / 2) -
(Username.Size.Y - (Username.TrueHeight)))
);
Status.Location = new(Username.Location.X, (int)(Username.Location.Y + Username.Font.PixelHeight + 5 - (Status.Size.Y - Status.TrueHeight)));
this.rr.BackgroundColor = person.Status switch
{
UserStatus.Online => new(115, 255, 111, 255),
UserStatus.Idle => new(255, 229, 84, 255),
UserStatus.DoNotDisturb => new(255, 51, 79, 255),
UserStatus.Offline or UserStatus.Invisible or _ => Color4.LightGray
};
r = new Rectangle(this.rr.Textures.First()) { Location = new(this.rr.Location.X + 4,this.rr.Location.Y + 4), Size = new(this.rr.Size.X - 8)};
Texture t = Globals.ms.TextureManager.AddTexture(person.GetAvatar(CancellationToken.None).Result);
t.Unit = TextureUnit.Texture1;
r.Textures.Add(t);
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
Controls.Add(r);
this.Clicked += AllOnClicked;
ContextMenu = new((int)(196 * Globals.Settings.Scale));
RoundedButton rrr, rr2;
ContextMenu.Items.Add(rrr=new(Globals.DefaultFont)
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(32 * Globals.Settings.Scale)), Text = "Export Keys"
});
ContextMenu.Items.Add(rr2=new(Globals.DefaultFont)
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(32 * Globals.Settings.Scale)), Text = "Open In New Window"
});
rr2.Clicked += Rr2OnClicked;
rrr.Clicked += RrOnClicked;
}
private Task Rr2OnClicked(IRenderObject arg)
{
GLFW.WindowHint(WindowHintBool.Decorated, false);
ChatWindow w = new(this);
//w.WindowBorder = WindowBorder.Resizable;
// ContextMenu!.HideContext(Window!);
//Window!.DrawFrame();
w.StartRender();
//w.IsEventDriven = true;
//Window.Windows.Add(w);
//w.StartRenderAsync();
//w.StartRender();
//ContextMenu!.HideContext(Window!);
return Task.CompletedTask;
}
private Task RrOnClicked(IRenderObject arg)
{
_ = User.Channel!.SendKeysToUsers(CancellationToken.None);
ContextMenu!.HideContext(Window!);
return Task.CompletedTask;
}
private Task AllOnClicked(IRenderObject arg)
{
if (ClickCon is not null) _ = ClickCon.Invoke(this);
return Task.CompletedTask;
}
public event Func<IChannelPick, Task>? ClickCon;
}

View File

@ -1,73 +0,0 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net;
using Luski.net.Enums;
using Luski.net.Enums.Main;
using Luski.net.JsonTypes;
using Luski.net.Structures.Main;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI;
public class FriendRequest : UserControl
{
private MainScreen Screen;
public MainSocketRemoteUser User;
public Rectangle? Accept, Reject;
public FriendRequest(MainScreen Parent, MainSocketRemoteUser User)
{
this.User = User;
this.Screen = Parent;
Size = new((int)(868 * Globals.Settings.Scale), (int)(62* Globals.Settings.Scale));
BackgroundColor = new(34, 34, 34, 255);
// Controls.Add(new Rectangle(Globals.ms.TextureManager.AddTexture(User.GetAvatar(CancellationToken.None).Result, true)) { Location = new((int)(7.5 * Globals.Settings.Scale),(int)(8.5 * Globals.Settings.Scale)), Size = new((int)(29 * Globals.Settings.Scale))});
Rectangle rr;
Controls.Add(rr=new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
Size = new ((int)(42 * Globals.Settings.Scale))
});
rr.BackgroundColor = BackgroundColor;
Texture t = Globals.ms.TextureManager.AddTexture(User.GetAvatar(CancellationToken.None).Result);
t.Unit = TextureUnit.Texture1;
rr.Textures.Add(t);
rr.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
Controls.Add(new Label(Globals.DefaultFont) { Text = User.DisplayName, Location = new((int)(50 * Globals.Settings.Scale),(int)(14 * Globals.Settings.Scale))});
Controls.Add(new Label(Globals.DefaultFont) { Text = User.FriendStatus.ToString(), Location = new((int)(50 * Globals.Settings.Scale),(int)(32 * Globals.Settings.Scale))});
if (User.FriendStatus == FriendStatus.PendingIn)
{
Controls.Add(Accept = new Rectangle()
{
Anchor = ObjectAnchor.Top | ObjectAnchor.Right, BackgroundColor = Color4.Green, Location = new((int)(166 * Globals.Settings.Scale), (int)(12 * Globals.Settings.Scale)),
Size = new((int)(28 * Globals.Settings.Scale))
});
Controls.Add(Reject = new Rectangle()
{
Anchor = ObjectAnchor.Top | ObjectAnchor.Right, BackgroundColor = Color4.Red, Location = new((int)(212 * Globals.Settings.Scale), Accept.Location.Y),
Size = Accept.Size
});
Accept.Clicked += AcceptOnClicked;
Reject.Clicked += RejectOnClicked;
}
}
private Task RejectOnClicked(IRenderObject arg)
{
//_ = Globals.Luski.SendFriendResult(User.Id, false, CancellationToken.None).Result;
Screen.RemoveFriendRequest(User);
return Task.CompletedTask;
}
private Task AcceptOnClicked(IRenderObject arg)
{
//Screen.AddFriend(Globals.Luski.SendFriendResult(User.Id, true, CancellationToken.None).Result);
Screen.RemoveFriendRequest(User);
return Task.CompletedTask;
}
}

View File

@ -0,0 +1,30 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
namespace Luski.GUI.MainScreen.UI;
public class FullScreenMedia : UserControl
{
public Rectangle IMG;
public FullScreenMedia(Texture t)
{
base.Size = Globals.ms.Size;
IMG = new(t)
{
Size = t.RawSize!.Value,
Location = new((base.Size.X - t.RawSize!.Value.X) / 2, (base.Size.Y - t.RawSize!.Value.Y) / 2, 0),
Anchor = ObjectAnchor.All
};
BackgroundColor = new(0, 0, 0, 130);
Controls.Add(IMG);
IMG.ForceDistanceUpdate(this);
Anchor = ObjectAnchor.All;
}
public static FullScreenMedia GetDisplay(Texture t)
{
return new FullScreenMedia(t);
}
}

View File

@ -1,75 +0,0 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.Interfaces;
using Luski.net.Structures.Main;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI;
public class Group : UserControl, IChannelPick
{
public MainSocketTextChannel Channel { get; set; }
// private string members = "";
public Group(MainSocketGroupChannel chan)
{
Label Status, Username;
Rectangle r, rr;
Channel = chan;
Size = new((int)(240 * Globals.Settings.Scale), (int)(62* Globals.Settings.Scale));
BackgroundColor = new(34, 34, 34, 255);
Controls.Add(rr=new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
Size = new ((int)(42 * Globals.Settings.Scale)),
BackgroundColor = new(64, 220, 64, 255)
});
r = new Rectangle(rr.Textures.First()) { Location = new(rr.Location.X + 4,rr.Location.Y + 4), Size = new(rr.Size.X - 8)};
Controls.Add(rr);
Texture tex = Globals.ms.TextureManager.AddTexture(chan.GetPicture(CancellationToken.None).Result);
tex.Unit = TextureUnit.Texture1;
r.Textures.Add(tex);
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
Controls.Add(r);
Controls.Add(Username = new Label(Globals.DefaultFont) { Text = chan.Title});
string sl = "Online";
if (chan.Id != 0)
{
sl = chan.Members.Count + " Members";
}
Controls.Add(Status = new Label(Globals.DefaultFont) { Scale = 0.7f, Text = sl, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(24 * Globals.Settings.Scale))});
this.Clicked += AllOnClicked;
Username.Location = new((int)(58 * Globals.Settings.Scale),
(rr.Location.Y + (rr.Size.Y / 2) - ((Username.TrueHeight + 5 + Status.TrueHeight) / 2) -
(Username.Size.Y - (Username.TrueHeight)))
);
Status.Location = new(Username.Location.X, (int)(Username.Location.Y + Username.Font.PixelHeight + 5 - (Status.Size.Y - Status.TrueHeight)));
if (chan.Id == 0) return;
ContextMenu = new((int)(150 * Globals.Settings.Scale));
RoundedButton rrr;
ContextMenu.Items.Add(rrr=new(Globals.DefaultFont)
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(25 * Globals.Settings.Scale)), Text = "Export Keys"
});
rrr.Clicked += RrOnClicked;
}
private Task RrOnClicked(IRenderObject arg)
{
_ = Channel.SendKeysToUsers(CancellationToken.None);
ContextMenu!.HideContext(Window!);
return Task.CompletedTask;
}
private Task AllOnClicked(IRenderObject arg)
{
if (ClickCon is not null) _ = ClickCon.Invoke(this);
return Task.CompletedTask;
}
public event Func<IChannelPick, Task>? ClickCon;
}

View File

@ -31,7 +31,8 @@ public class Category : UserControl, IChannelAdder
c.tmp = new() c.tmp = new()
{ {
Size = c.Size, Size = c.Size,
Anchor = ObjectAnchor.Top | ObjectAnchor.Left Anchor = ObjectAnchor.Top | ObjectAnchor.Left,
IgnoreHover = true
}; };
c.tmp.Clicked += c.TmpOnClicked; c.tmp.Clicked += c.TmpOnClicked;
c.tmp.HoverMouse = MouseCursor.Hand; c.tmp.HoverMouse = MouseCursor.Hand;
@ -41,22 +42,24 @@ public class Category : UserControl, IChannelAdder
Text = ">", Text = ">",
Location = new((int)(5*Globals.Settings.Scale)), Location = new((int)(5*Globals.Settings.Scale)),
Color = cat.Color.ToColor4(), Color = cat.Color.ToColor4(),
DIR = new(1,0) 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, Text = cat.Name,
Color = c.ee.Color Color = c.ee.Color,
IgnoreHover = true
}); });
c.Clicked += c.AllOnClicked; c.Clicked += c.AllOnClicked;
c.Name.Location = new((int)(26 * Globals.Settings.Scale), ((c.Size.Y/2) - (c.Name.TrueHeight/ 2) - (c.Name.Size.Y - c.Name.TrueHeight))); c.Name.Location = new((int)(26 * Globals.Settings.Scale), ((c.Size.Y/2) - (c.Name.TrueHeight/ 2) - (c.Name.Size.Y - c.Name.TrueHeight)), 0);
c.Members = new() c.Members = new()
{ {
Anchor = ObjectAnchor.All, Anchor = ObjectAnchor.All,
Location = new((int)(20 * Globals.Settings.Scale), c.Size.Y) Location = new((int)(20 * Globals.Settings.Scale), c.Size.Y, 0),
IgnoreHover = true
}; };
c.ee.Location = new(c.ee.Location.X, c.Name.Location.Y); c.ee.Location = new(c.ee.Location.X, c.Name.Location.Y, 0);
c.Members.Size = new(c.Size.X - c.Members.Location.X, 0); c.Members.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);
@ -117,12 +120,12 @@ public class Category : UserControl, IChannelAdder
if (value) if (value)
{ {
ee.DIR = new(0,1); ee.DIR = new(0,1);
ee.Location = new(ee.Location.X, (ee.Location.Y - ee.PostiveTrueHeight)); ee.Location = new(ee.Location.X, (ee.Location.Y - ee.PostiveTrueHeight), 0);
} }
else else
{ {
ee.DIR = new(1,0); ee.DIR = new(1,0);
ee.Location = new(ee.Location.X, (ee.Location.Y + ee.PostiveTrueHeight)); ee.Location = new(ee.Location.X, (ee.Location.Y + ee.PostiveTrueHeight), 0);
} }
e = value; e = value;
} }

View File

@ -11,68 +11,29 @@ namespace Luski.GUI.MainScreen.UI.PublicServers;
public class Channel : UserControl public class Channel : UserControl
{ {
private Rectangle SelectedRct, SelectedRctL, SelectedRctR; //private Rectangle SelectedRct, SelectedRctL, SelectedRctR;
private ChannelSelector CS; private ChannelSelector CS;
public readonly static Texture[] SelectedTextures = new Texture[] {null!, null!, null!}; //public readonly static Texture[] SelectedTextures = new Texture[] {null!, null!, null!};
public static Texture? seltec = null;
public SocketChannel CurrentChannel { get; set; } public SocketChannel CurrentChannel { get; set; }
public new Color4 BackgroundColor
{
get => base.BackgroundColor;
set
{
if (!Selected)
{
SelectedRct.BackgroundColor = value;
SelectedRctL.BackgroundColor = value;
SelectedRctR.BackgroundColor = value;
}
base.BackgroundColor = value;
}
}
private Channel(Stream UserIcon, ChannelSelector cs, SocketChannel chan) private Channel(Stream UserIcon, ChannelSelector cs, SocketChannel chan)
:base(seltec)
{ {
CS = cs; CS = cs;
CurrentChannel = chan; CurrentChannel = chan;
Size = new((int)(307 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale)); Size = new((int)(307 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale));
#region Selected Texture
SelectedRct = new(SelectedTextures[1])
{
Location = new(Size.Y, 0),
Size = new(Size.X - (Size.Y * 2), Size.Y),
Anchor = ObjectAnchor.All,
BackgroundColor = BackgroundColor,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
Visible = true
};
Controls.Add(SelectedRct);
SelectedRctL = new(SelectedTextures[0])
{
Location = new(0),
Size = new(Size.Y),
Anchor = ObjectAnchor.Left,
BackgroundColor = SelectedRct.BackgroundColor,
Shader = SelectedRct.Shader,
Visible = true
};
Controls.Add(SelectedRctL);
SelectedRctR = new(SelectedTextures[2])
{
Location = new(Size.X - Size.Y, 0),
Size = SelectedRctL.Size,
Anchor = ObjectAnchor.Right,
BackgroundColor = SelectedRct.BackgroundColor,
Shader = SelectedRct.Shader,
Visible = true
};
Controls.Add(SelectedRctR);
#endregion
TextureDisplay = TextureDisplay.HorizontalCenter;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
int i = (int)(4 * Globals.Settings.Scale);
r = new Rectangle(Globals.ms.TextureManager.GetAlphaCircle()) r = new Rectangle(Globals.ms.TextureManager.GetAlphaCircle())
{ {
Location = new((int)(4 * Globals.Settings.Scale)), Location = new(i,i,0),
Size = new ((int)(32 * Globals.Settings.Scale)) Size = new ((int)(32 * Globals.Settings.Scale)),
IgnoreHover = true
}; };
Texture tex; Texture tex;
tex = Globals.ms.TextureManager.AddTexture(UserIcon); tex = Globals.ms.TextureManager.AddTexture(UserIcon);
@ -85,27 +46,15 @@ public class Channel : UserControl
ChannelName = new Label(Globals.DefaultFont) ChannelName = new Label(Globals.DefaultFont)
{ {
Text = chan.Name, Text = chan.Name,
Color = chan.Color.ToColor4() Color = chan.Color.ToColor4(),
IgnoreHover = true
}; };
Controls.Add(ChannelName); Controls.Add(ChannelName);
Clicked += AllOnClicked; Clicked += AllOnClicked;
ChannelName.Location = new((int)(40 * Globals.Settings.Scale), ChannelName.Location = new((int)(40 * Globals.Settings.Scale),
(Size.Y / 2) - ((int)ChannelName.Font.PixelHeight) + (ChannelName.PostiveTrueHeight / 2) (Size.Y / 2) - ((int)ChannelName.Font.PixelHeight) + (ChannelName.PostiveTrueHeight / 2)
); , 0);
ContextMenu = new((int)(150 * Globals.Settings.Scale)); ContextMenu = new((int)(150 * Globals.Settings.Scale));
RoundedButton ExportKeysButton, EdditChannelButton;
ContextMenu.Items.Add(ExportKeysButton=new(Globals.DefaultFont)
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(25 * Globals.Settings.Scale)), Text = "Export Keys"
});
ContextMenu.Items.Add(EdditChannelButton=new(Globals.DefaultFont)
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(25 * Globals.Settings.Scale)), Text = "Edit Channel"
});
EdditChannelButton.Clicked += EditChannelButtonOnClicked;
ExportKeysButton.Clicked += ExportKeysButtonOnClicked;
HoverMouse = MouseCursor.Hand; HoverMouse = MouseCursor.Hand;
} }
@ -118,7 +67,7 @@ public class Channel : UserControl
Color4 bc = new(141,151,165,51); Color4 bc = new(141,151,165,51);
if (Selected) if (Selected)
{ {
bc = BackgroundColor; bc = CS.BackgroundColor;
} }
BlockDraw = true; BlockDraw = true;
@ -128,9 +77,10 @@ public class Channel : UserControl
{ {
await CS.Selected.ToggleSelected(); await CS.Selected.ToggleSelected();
} }
BackgroundColor = bc;
if (Selected) if (Selected)
{ {
CS.Selected = this; CS.Selected = this;
IReadOnlyList<SocketMessage> m; IReadOnlyList<SocketMessage> m;
m = await CurrentChannel.GetMessages(CancellationToken.None, 200); m = await CurrentChannel.GetMessages(CancellationToken.None, 200);
@ -140,10 +90,7 @@ public class Channel : UserControl
_ = Globals.ms.pc.AddMessages(m); _ = Globals.ms.pc.AddMessages(m);
if (m.Count > 0)Globals.ms.pc.MessageFlow.ScrollToBottom(); if (m.Count > 0)Globals.ms.pc.MessageFlow.ScrollToBottom();
} }
SelectedRct.BackgroundColor = bc;
SelectedRctL.BackgroundColor = bc;
BlockDraw = false; BlockDraw = false;
SelectedRctR.BackgroundColor = bc;
TryDraw(); TryDraw();
} }
catch (Exception e) catch (Exception e)

View File

@ -1,3 +1,4 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects; using GraphicsManager.Objects;
using Luski.GUI.MainScreen.Interfaces; using Luski.GUI.MainScreen.Interfaces;
using Luski.net.Structures.Public; using Luski.net.Structures.Public;

View File

@ -21,6 +21,8 @@ public class ChatMessage : UserControl
private SocketMessage Msg { get; } private SocketMessage Msg { get; }
private SocketChannel ch { get; } private SocketChannel ch { get; }
public PublicChat pc;
private IRenderObject LastObject; private IRenderObject LastObject;
private Label FirstL; private Label FirstL;
@ -30,18 +32,19 @@ public class ChatMessage : UserControl
private static Dictionary<MainSocketRemoteUser, ContextMenu> Menues = new(); private static Dictionary<MainSocketRemoteUser, ContextMenu> Menues = new();
private static Dictionary<MainSocketRemoteUser, List<ChatMessage>> Messages = new(); private static Dictionary<MainSocketRemoteUser, List<ChatMessage>> Messages = new();
public static async Task<ChatMessage> MakeChatMessage(SocketMessage message) public static async Task<ChatMessage> MakeChatMessage(PublicChat p, SocketMessage message)
{ {
IUser auth = await message.GetAuthor(CancellationToken.None); IUser auth = await message.GetAuthor(CancellationToken.None);
Role[] ra = await ((SocketUser)auth).GetRoles(); Role[] ra = await ((SocketUser)auth).GetRoles();
Color c = ra[0].Color; Color c = ra[0].Color;
Color4 c4 = new(c.R, c.G, c.B, c.A); Color4 c4 = new(c.R, c.G, c.B, c.A);
return new ChatMessage(message, await message.GetParent(CancellationToken.None), auth, await auth.GetIcon(), c4); return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), auth, await auth.GetIcon(), c4);
} }
private ChatMessage(SocketMessage message, SocketChannel chan, IUser Author, Texture UserIcon, Color4 UserNameColor) private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, IUser Author, Texture UserIcon, Color4 UserNameColor)
{ {
pc = p;
Label label1; Label label1;
Size = new((int)(723.5 * Globals.Settings.Scale), (int)(37 * Globals.Settings.Scale)); Size = new((int)(723.5 * Globals.Settings.Scale), (int)(37 * Globals.Settings.Scale));
ch = chan; ch = chan;
@ -65,7 +68,7 @@ public class ChatMessage : UserControl
} }
Rectangle r = new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), Rectangle r = new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Location = new((int)(10 * Globals.Settings.Scale), (int)(2 * Globals.Settings.Scale)), Size = new((int)(38 * Globals.Settings.Scale)) }; "Luski.Resources.Textures.Status.png"))) { Location = new((int)(10 * Globals.Settings.Scale), (int)(2 * Globals.Settings.Scale), 0), Size = new((int)(38 * Globals.Settings.Scale)) };
//UserIcon.Unit = TextureUnit.Texture1; //UserIcon.Unit = TextureUnit.Texture1;
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context]; r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
r.Textures.Add(UserIcon); r.Textures.Add(UserIcon);
@ -73,14 +76,14 @@ public class ChatMessage : UserControl
Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor, Text = Author.DisplayName }); Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor, Text = Author.DisplayName });
label1.Location = new( label1.Location = new(
(int)(54 * Globals.Settings.Scale), (int)(54 * Globals.Settings.Scale),
(int)(r.Location.Y + (r.Size.Y / 2) - (label1.Font.CurrentFont.Fonts[0].Size.Metrics.NominalHeight / 2) - label1.Size.Y + label1.Font.PixelHeight)); (int)(r.Location.Y + (r.Size.Y / 2) - (label1.Font.CurrentFont.Fonts[0].Size.Metrics.NominalHeight / 2) - label1.Size.Y + label1.Font.PixelHeight), 0);
LastObject = label1; LastObject = label1;
FirstL = label1; FirstL = label1;
Controls.Add(new Label(Globals.TopTimeFont) { Location = new(label1.Location.X + label1.Size.X + (int)(8 * Globals.Settings.Scale), (int)(label1.Location.Y + label1.Font.PixelHeight - Globals.TopTimeFont.PixelHeight)), Text = timestr}); Controls.Add(new Label(Globals.TopTimeFont) { Location = new(label1.Location.X + label1.Size.X + (int)(8 * Globals.Settings.Scale), (int)(label1.Location.Y + label1.Font.PixelHeight - Globals.TopTimeFont.PixelHeight), 0), Text = timestr});
if (!string.IsNullOrWhiteSpace(Msg.Context)) if (!string.IsNullOrWhiteSpace(Msg.Context))
{ {
Label l; Label l;
Controls.Add(l = new Label(Globals.MessageFont) { Location = new(LastObject.Location.X, (int)(LastObject.Location.Y + (LastObject as Label)!.Size.Y + VerticalPadding)), Text = message.Context}); Controls.Add(l = new Label(Globals.MessageFont) { Location = new(LastObject.Location.X, (int)(LastObject.Location.Y + (LastObject as Label)!.Size.Y + VerticalPadding), 0), Text = message.Context});
LastObject = l; LastObject = l;
} }
@ -100,7 +103,7 @@ public class ChatMessage : UserControl
filesonrow++; filesonrow++;
IRenderObject cem = ContentEmbed.GetEmbed(this, Msg.Files[i], Msg.ChannelID).Result; IRenderObject cem = ContentEmbed.GetEmbed(this, Msg.Files[i], Msg.ChannelID).Result;
cem.Location = new((int)(lx - 333), (int)(LastObject.Location.Y + 2 + LastObject.Size.Y + (HorPadding * row) + (66 * (row - 1)))); cem.Location = new((int)(lx - 333), (int)(LastObject.Location.Y + 2 + LastObject.Size.Y + (HorPadding * row) + (66 * (row - 1))), 0);
LastObject = cem; LastObject = cem;
//lo = cem.Location; //lo = cem.Location;
// si = cem.Size; // si = cem.Size;
@ -124,11 +127,11 @@ public class ChatMessage : UserControl
}; };
if (LastObject is Label l) if (LastObject is Label l)
{ {
newLabel.Location = new(FirstL.Location.X, (int)(l.Location.Y + l.Size.Y + VerticalPadding)); newLabel.Location = new(FirstL.Location.X, (int)(l.Location.Y + l.Size.Y + VerticalPadding), 0);
} }
else else
{ {
newLabel.Location = new(FirstL.Location.X, Size.Y); newLabel.Location = new(FirstL.Location.X, Size.Y, 0);
} }
bool result = Uri.TryCreate(newLabel.Text, UriKind.Absolute, out Uri? uriResult) bool result = Uri.TryCreate(newLabel.Text, UriKind.Absolute, out Uri? uriResult)
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
@ -161,7 +164,7 @@ public class ChatMessage : UserControl
filesonrow++; filesonrow++;
IRenderObject cem = await ContentEmbed.GetEmbed(this, msg.Files[i], msg.ChannelID); IRenderObject cem = await ContentEmbed.GetEmbed(this, msg.Files[i], msg.ChannelID);
cem.Location = new((int)(lx - 333), (int)(LastObject.Location.Y + 2 + LastObject.Size.Y + (HorPadding * row) + (66 * (row - 1)))); cem.Location = new((int)(lx - 333), (int)(LastObject.Location.Y + 2 + LastObject.Size.Y + (HorPadding * row) + (66 * (row - 1))), 0);
LastObject = cem; LastObject = cem;
Controls.Add(cem); Controls.Add(cem);
} }
@ -215,7 +218,7 @@ public class ChatMessage : UserControl
Label m = new(Globals.DefaultFont) Label m = new(Globals.DefaultFont)
{ {
Text = time.ToString("h:mm tt"), Text = time.ToString("h:mm tt"),
Location = new((int)(7.5 * Globals.Settings.Scale), label.Location.Y - 13 + (int)label.Font.PixelHeight), Location = new((int)(7.5 * Globals.Settings.Scale), label.Location.Y - 13 + (int)label.Font.PixelHeight, 0),
}; };
Controls.Add(m); Controls.Add(m);

View File

@ -5,9 +5,6 @@ using GraphicsManager.Objects;
using GraphicsManager.Objects.Core; using GraphicsManager.Objects.Core;
using Luski.net.Structures.Public; using Luski.net.Structures.Public;
using OpenTK.Windowing.Common.Input; using OpenTK.Windowing.Common.Input;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using File = Luski.net.Structures.File;
using Rectangle = GraphicsManager.Objects.Rectangle; using Rectangle = GraphicsManager.Objects.Rectangle;
namespace Luski.GUI.MainScreen.UI.PublicServers; namespace Luski.GUI.MainScreen.UI.PublicServers;
@ -21,6 +18,7 @@ public class ContentEmbed : UserControl
private static bool isopen; private static bool isopen;
public static async Task<IRenderObject> GetEmbed(ChatMessage m, SocketFile file, long channel) public static async Task<IRenderObject> GetEmbed(ChatMessage m, SocketFile file, long channel)
{ {
if (file.Name.ToLower().EndsWith(".png") || file.Name.ToLower().EndsWith(".jpg")) if (file.Name.ToLower().EndsWith(".png") || file.Name.ToLower().EndsWith(".jpg"))
{ {
Stream data = await file.GetCache(CancellationToken.None); Stream data = await file.GetCache(CancellationToken.None);
@ -33,10 +31,10 @@ public class ContentEmbed : UserControl
{ {
Size = new((int)s, (int)(scale * t.RawSize.Value.Y)), Size = new((int)s, (int)(scale * t.RawSize.Value.Y)),
Shader = Texture.TextureShader[Globals.ms.Context], Shader = Texture.TextureShader[Globals.ms.Context],
HoverMouse = MouseCursor.Hand HoverMouse = MouseCursor.Hand,
Tag = m.pc
}); });
r.Clicked += ROnClicked; r.Clicked += ROnClicked;
t.RawSize = null;
return r; return r;
} }
else else
@ -50,23 +48,37 @@ public class ContentEmbed : UserControl
private static Task ROnClicked(IRenderObject arg) private static Task ROnClicked(IRenderObject arg)
{ {
if (isopen) return Task.CompletedTask; if (isopen) return Task.CompletedTask;
isopen = !isopen; isopen = true;
Rectangle r; FullScreenMedia r;
Image<Rgba32> Logo = SixLabors.ImageSharp.Image.Load<Rgba32>(System.IO.File.OpenRead("/home/jacob/Pictures/Logo.png"));
Logo.DangerousTryGetSinglePixelMemory(out Memory<Rgba32> m); Globals.ms.Controls.Add(r = FullScreenMedia.GetDisplay(((Rectangle)arg).Textures[0]));
byte[] pixels = new byte[4 * Logo.Width * Logo.Height]; if (arg.Tag is PublicChat pc)
Logo.CopyPixelDataTo(pixels);
Globals.ms.Controls.Add(r=new Rectangle()
{ {
Size = Globals.ms.Size, pc.MessageFlow.AllowHoverFromBehind = false;
BackgroundColor = new(0,0,0,150), r.Tag = pc;
HoverMouse = new(0,0, Logo.Width, Logo.Height, pixels) }
});
Globals.ms.CurrentTop = r; r.Clicked += RrOnClicked;
Globals.ms.DrawFrame(); Globals.ms.DrawFrame();
return Task.CompletedTask; return Task.CompletedTask;
} }
private static Task RrOnClicked(IRenderObject arg)
{
isopen = false;
Globals.ms.Controls.Remove(arg);
Globals.ms.DrawFrame();
FullScreenMedia fsm = (arg as FullScreenMedia)!;
fsm.Clicked -= RrOnClicked;
if (fsm.Tag is PublicChat pc)
{
pc.MessageFlow.AllowHoverFromBehind = true;
}
fsm.Clean();
fsm = null!;
return Task.CompletedTask;
}
public ContentEmbed(SocketFile file, long channel) public ContentEmbed(SocketFile file, long channel)
{ {
Label fileNameLabel, fileSizeLabel; Label fileNameLabel, fileSizeLabel;
@ -81,13 +93,13 @@ 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";
Size = new(333, 66); base.Size = new(333, 66);
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) }); 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)
{ {
Color = new(102 / (float)255, 227 / (float)255, 170 / (float)255, 1), Text = file.Name, Color = new(102 / (float)255, 227 / (float)255, 170 / (float)255, 1), Text = file.Name,
Location = new(64, 6) Location = new(64, 6, 0)
}); });
fileNameLabel.Clicked += FileNameLabelOnClicked; fileNameLabel.Clicked += FileNameLabelOnClicked;
if (DownloadIcon is null) if (DownloadIcon is null)
@ -99,7 +111,7 @@ public class ContentEmbed : UserControl
} }
Controls.Add(new Rectangle(DownloadIcon) Controls.Add(new Rectangle(DownloadIcon)
{ Location = new(8, 6), Size = new(50, 50) }); { Location = new(8, 6, 0), Size = new(50, 50) });
int temp = fileNameLabel.Size.X + fileNameLabel.Location.X; int temp = fileNameLabel.Size.X + fileNameLabel.Location.X;
int temp2 = fileSizeLabel.Size.X + fileSizeLabel.Location.X; int temp2 = fileSizeLabel.Size.X + fileSizeLabel.Location.X;
//if (temp >= temp2) Size = new(temp + 4, Size.Y); //if (temp >= temp2) Size = new(temp + 4, Size.Y);

View File

@ -11,31 +11,38 @@ public class PublicChat : UserControl
public FlowLayout MessageFlow; public FlowLayout MessageFlow;
private Label title, desc; private Label title, desc;
private Textbox tb; //private Textbox tb;
private SocketChannel? Channel; private SocketChannel? Channel;
public PublicChat() public PublicChat()
{ {
UserControl titlecon; UserControl titlecon;
Size = new((int)(980 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale)); base.Size = new((int)(980 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale));
BackgroundColor = new(50, 50, 50, 255); BackgroundColor = new(50, 50, 50, 255);
Anchor = ObjectAnchor.All; Anchor = ObjectAnchor.All;
Controls.Add(MessageFlow = new() Controls.Add(MessageFlow = new()
{ {
Size = new(Size.X, (int)(761 * Globals.Settings.Scale)), Size = new(base.Size.X, (int)(761 * Globals.Settings.Scale)),
Location = new(0, (int)(52 * Globals.Settings.Scale)), Location = new(0, (int)(52 * Globals.Settings.Scale), 0),
BackgroundColor = new(40,40,40,255), BackgroundColor = new(40,40,40,255),
Anchor = ObjectAnchor.All, Anchor = ObjectAnchor.All,
HScrollPixels = Globals.Settings.PerScrollPixels HScrollPixels = Globals.Settings.PerScrollPixels,
}); });
Controls.Add(titlecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right, Size = new((int)(980 * Globals.Settings.Scale), (int)(52 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor}); Controls.Add(titlecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right, Size = new((int)(980 * Globals.Settings.Scale), (int)(52 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
titlecon.ForceDistanceUpdate(this);
titlecon.Controls.Add(title = new Label(Globals.DefaultFont) titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
{ {
//Location = new( //Location = new(
// (int)((26 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale), // (int)((26 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale),
// (int)((26 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight/2.0))) // (int)((26 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight/2.0)))
}); });
titlecon.Controls.Add(desc = new Label(Globals.DefaultFont){ Color = new(161,161,161,255), Location = new(title.Location.X + title.Size.X + 5, title.Location.Y)}); titlecon.Controls.Add(desc = new Label(Globals.DefaultFont)
{
Color = new(161,161,161,255),
Location = new(title.Location.X + title.Size.X + 5, title.Location.Y, 0)
});
/*
Controls.Add(tb = new Textbox(Globals.DefaultFont, Globals.DefaultFont) Controls.Add(tb = new Textbox(Globals.DefaultFont, Globals.DefaultFont)
{ {
InsideColor = new(28, 28, 28, 255), InsideColor = new(28, 28, 28, 255),
@ -44,7 +51,7 @@ public class PublicChat : UserControl
Size = new((int)(960 * Globals.Settings.Scale), (int)(34 * Globals.Settings.Scale)), Size = new((int)(960 * Globals.Settings.Scale), (int)(34 * Globals.Settings.Scale)),
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right, Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
HoverMouse = MouseCursor.IBeam HoverMouse = MouseCursor.IBeam
}); });*/
//tb.KeyPress += TbOnKeyPress; //tb.KeyPress += TbOnKeyPress;
//Globals.Luski.MainServer.MessageReceived += LuskiOnMessageReceived; //Globals.Luski.MainServer.MessageReceived += LuskiOnMessageReceived;
} }
@ -58,7 +65,12 @@ public class PublicChat : UserControl
Channel = channel; Channel = channel;
title.Text = channel.Name; title.Text = channel.Name;
desc.Text = channel.Description; desc.Text = channel.Description;
this.tb.WatermarkText = $"Message {channel.Name}"; desc.Location = new((int)(title.Location.X + title.Size.X + (5 * Globals.Settings.Scale)), desc.Location.Y, 0);
if (Window is not null)
{
Window.Title = $"{channel.Name} | {channel.Server.Name} - Luski";
}
//this.tb.WatermarkText = $"Message {channel.Name}";
} }
public void ClearChat() public void ClearChat()
@ -99,11 +111,11 @@ public class PublicChat : UserControl
{ {
if (Window is null || !Globals.ms.InvokeRequired) if (Window is null || !Globals.ms.InvokeRequired)
{ {
MessageFlow.Controls.Add(LastChatMessage = await ChatMessage.MakeChatMessage(Message)); MessageFlow.Controls.Add(LastChatMessage = await ChatMessage.MakeChatMessage(this, Message));
} }
else else
{ {
LastChatMessage = await ChatMessage.MakeChatMessage(Message); LastChatMessage = await ChatMessage.MakeChatMessage(this, Message);
Globals.ms.Invoke(() => Globals.ms.Invoke(() =>
{ {
MessageFlow.Controls.Add(LastChatMessage); MessageFlow.Controls.Add(LastChatMessage);

View File

@ -46,23 +46,26 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
Rectangle r = new(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), Rectangle r = new(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.rc.png"))) "Luski.Resources.Textures.rc.png")))
{ {
Location = new((int)(18 * Globals.Settings.Scale), (int)(8 * Globals.Settings.Scale)), Location = new((int)(18 * Globals.Settings.Scale), (int)(8 * Globals.Settings.Scale), 0),
Size = new((int)(32 * Globals.Settings.Scale)), Size = new((int)(32 * Globals.Settings.Scale)),
Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context] Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context],
IgnoreHover = true
}; };
Rectangle rr = new(r.Textures[0]) Rectangle rr = new(r.Textures[0])
{ {
Location = new((int)(17 * Globals.Settings.Scale), (int)(7 * Globals.Settings.Scale)), Location = new((int)(17 * Globals.Settings.Scale), (int)(7 * Globals.Settings.Scale), 0),
Size = new((int)(34 * Globals.Settings.Scale)), Size = new((int)(34 * Globals.Settings.Scale)),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context], Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = new(26, 26, 26, 255) BackgroundColor = new(26, 26, 26, 255),
IgnoreHover = true
}; };
SelectedRect = new(r.Textures[0]) SelectedRect = new(r.Textures[0])
{ {
Location = new((int)(14 * Globals.Settings.Scale), (int)(4 * Globals.Settings.Scale)), Location = new((int)(14 * Globals.Settings.Scale), (int)(4 * Globals.Settings.Scale), 0),
Size = new((int)(40 * Globals.Settings.Scale)), Size = new((int)(40 * Globals.Settings.Scale)),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context], Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = new(26, 26, 26, 255) BackgroundColor = new(26, 26, 26, 255),
IgnoreHover = true
}; };
this.Server = Server; this.Server = Server;
Texture t = Globals.ms.TextureManager.AddTexture(Server.GetAvatar(CancellationToken.None).Result); Texture t = Globals.ms.TextureManager.AddTexture(Server.GetAvatar(CancellationToken.None).Result);

View File

@ -0,0 +1,362 @@
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.UI;
using Luski.GUI.MainScreen.UI.PublicServers;
using Luski.GUI.StartPage.UI;
using Luski.net;
using Luski.net.Structures.Public;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using Window = GraphicsManager.Window;
namespace Luski.GUI;
public class MainScreenWindow : Window
{
private static readonly NativeWindowSettings Settings = new()
{
Title = "Luski Login",
WindowBorder = WindowBorder.Fixed,
APIVersion = new Version(3, 2),
API = ContextAPI.OpenGL,
StartFocused = true,
Size = new Vector2i((int)(312 * Globals.Settings.Scale), (int)(545 * Globals.Settings.Scale)),
Icon = Globals.Icon,
SharedContext = null,
};
public TabControl? tc;
private FlowLayout? channelpicker, friends, friend_request;
private RoundedButton? FriendManagerBtn;
Login login;
CreateAccount ca;
private static DebugProc DebugMessageDelegate = OnDebugMessage;
private static void OnDebugMessage(
DebugSource source, // Source of the debugging message.
DebugType type, // Type of the debugging message.
int id, // ID associated with the message.
DebugSeverity severity, // Severity of the message.
int length, // Length of the string in pMessage.
IntPtr pMessage, // Pointer to message string.
IntPtr pUserParam) // The pointer you gave to OpenGL, explained later.
{
// In order to access the string pointed to by pMessage, you can use Marshal
// class to copy its contents to a C# string without unsafe code. You can
// also use the new function Marshal.PtrToStringUTF8 since .NET Core 1.1.
string message = Marshal.PtrToStringAnsi(pMessage, length);
// The rest of the function is up to you to implement, however a debug output
// is always useful.
if (false)
{
switch (severity)
{
case DebugSeverity.DebugSeverityHigh:
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
Console.ResetColor();
break;
case DebugSeverity.DebugSeverityMedium:
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
Console.ResetColor();
break;
default:
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(message);
Console.ResetColor();
break;
}
}
}
public MainScreenWindow() : base(Settings)
{
VSync = VSyncMode.On;
this.TryGetCurrentMonitorScale(out var h, out var v);
GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero);
GL.Enable(EnableCap.DebugOutput);
Globals.DefaultFontFamly = FontFamily.LoadFontFamily("Noto Sans").Result;
Globals.DefaultFont = FontInteraction.Load(Globals.DefaultFontFamly);
Globals.DefaultFont.PixelHeight = (uint)(20 * Globals.Settings.Scale);
Globals.DefaultFont.FontSize = FontSize.Regular;
Globals.TopTimeFont = Globals.DefaultFont.Clone();
Globals.TopTimeFont.PixelHeight = (uint)(12 * Globals.Settings.Scale);
Globals.TopTimeFont.FontSize = FontSize.Regular;
Globals.MessageFont = Globals.DefaultFont.Clone();
Globals.MessageFont.PixelHeight = (uint)(17 * Globals.Settings.Scale);
Globals.MessageFont.ExtraLinePixels = (uint)(5 * Globals.Settings.Scale);
Globals.MessageFont.FontSize = FontSize.Regular;
Globals.SmallTimeFont = Globals.DefaultFont.Clone();
Globals.LuskiTexture = TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Luski.png"));
CenterWindow(0);
if ((Globals.Luski.MainServer is not null && !Globals.Luski.MainServer.IsLogedIn) ||
!Globals.Luski.LoadedServers.Any(s => s.IsLogedIn))
{
Controls.Add(ca = new CreateAccount());
ca.Visible = false;
ca.ChangeToApp += LoginOnChangeToApp;
Controls.Add(login = new Login());
login.ChangeToApp += LoginOnChangeToApp;
login.ChangeToCa += LoginOnChangeToCa;
Thread t = new(_ =>
{
if (Globals.Luski.MainServer is not null) Globals.Luski.MainServer.EncryptionHandler.GenerateKeys();
});
t.Start();
}
WindowLoaded += OnWindowLoaded;
}
private Task OnWindowLoaded(Window arg)
{
if (Globals.UpdaterSettings.AutoUpdateCheck && new HttpClient()
.GetAsync(
$"https://www.jacobtech.com/Updater/GetProgramVersion?directory=Luski&branch={Globals.UpdaterSettings.Branch.ToString()}&selfcontained={Globals.UpdaterSettings.SelfContained.ToString().ToLower()}&platform={Globals.UpdaterSettings.Platform}")
.Result.Content.ReadAsStringAsync().Result !=
FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion)
{
var update = new UpdateWindow();
var result = update.ShowDialogue(this);
if (result == UpdateWindow.DialogueResult.Yes)
{
Globals.Download = true;
Close();
}
}
if ((Globals.Luski.MainServer is not null && Globals.Luski.MainServer.IsLogedIn) ||
Globals.Luski.LoadedServers.Any(s => s.IsLogedIn)) Invoke(() => LoginOnChangeToApp());
return Task.CompletedTask;
}
private Task LoginOnChangeToCa()
{
Title = "Create Account";
ca.Visible = true;
login.Visible = false;
return Task.CompletedTask;
}
public FlowLayout ser;
private UserControl? SerBox;
public PublicChat pc;
public async Task LoadPublicServer(PublicServer? Server)
{
GL.Enable(EnableCap.DepthTest);
GL.DepthFunc(DepthFunction.Always);
if (Server is null) return;
BlockDraw = true;
try
{
#region Box Init
if (SerBox is null)
{
SerBox = new()
{
Location = new(ser.Size.X, 0, 0),
Size = new(Size.X - ser.Size.X, Size.Y),
Anchor = ObjectAnchor.All,
BackgroundColor = new(20, 20, 20, 255)
};
Controls.Add(SerBox);
SerBox.LoadToParent(this, this);
}
SerBox.Controls.Clear();
#endregion
#region Channel Selector Init
SocketChannel current_channel = await Server.User.GetSelectedChannel(CancellationToken.None);
Channel.seltec = Globals.ms.TextureManager.AddTexture(
Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.RoundedRectangle.png"));
List<SocketCategory> parents = new();
SocketCategory? cur = await current_channel.GetParent();
while (cur is not null)
{
parents.Add(cur);
cur = await cur.GetParent();
}
parents.Reverse();
ChannelSelector cs = new(parents[0])
{
BackgroundColor = new(34, 34, 34, 255),
Size = new((int)(307 * Globals.Settings.Scale), SerBox.Size.Y - 106),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
};
parents.RemoveAt(0);
SerBox.Controls.Add(cs);
cs.ForceDistanceUpdate(SerBox);
#endregion
#region Chat Init
pc = new()
{
Anchor = ObjectAnchor.All,
Location = new(cs.Size.X, 0, 0),
Size = new(SerBox.Size.X - cs.Size.X, SerBox.Size.Y),
};
SerBox.Controls.Add(pc);
pc.LoadToParent(SerBox, this);
pc.ForceDistanceUpdate();
pc.MessageFlow.ForceDistanceUpdate(pc);
#endregion
#region Channel Selector Loader
_ = cs.Load(current_channel, parents);
#endregion
#region User Icon
Role[] ra = await Server.User.GetRoles();
Color c = ra[0].Color;
Color4 c4 = new(c.R, c.G, c.B, c.A);
Rectangle u = new Rectangle(TextureManager.AddTexture(Tools.GetResourceStream(
Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png")))
{
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Size = new((int)(46 * Globals.Settings.Scale)),
Location = new((int)(4 * Globals.Settings.Scale), (int)(812 * Globals.Settings.Scale), 0)
};
u.Shader = Rectangle.DefaultAlphaTextureShader[Context];
u.Textures.Add(await Server.User.GetIcon());
SerBox.Controls.Add(u);
u.LoadToParent(SerBox, this);
u.ForceDistanceUpdate();
Label ul = new Label(Globals.DefaultFont)
{
Anchor = u.Anchor,
Text = Server.User.DisplayName,
Color = c4
};
ul.Location = new(u.Location.X + u.Size.X + (int)(5 * Globals.Settings.Scale),
(u.Location.Y + (u.Size.Y / 2) - (ul.PostiveTrueHeight / 2) - ul.Size.Y + ul.TrueHeight), 0);
SerBox.Controls.Add(ul);
#endregion
}
catch (Exception e)
{
Console.WriteLine(e);
}
BlockDraw = false;
}
public async Task LoadMainServer(MainServer Server)
{
if (SerBox is null)
SerBox = new()
{
Location = new(ser.Size.X, 0, 0),
Size = new(Size.X - ser.Size.X, Size.Y),
Anchor = ObjectAnchor.All
};
Controls.Add(SerBox);
SerBox.ForceDistanceUpdate();
SerBox.Controls.Clear();
}
private async Task<Task> LoginOnChangeToApp()
{
Controls.Clear();
BlockDraw = true;
Title = "Luski";
Size = new((int)(1332 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale));
DateTime start = DateTime.Now;
CenterWindow(0);
DateTime start1 = DateTime.Now;
WindowBorder = WindowBorder.Resizable;
BackgroundColor = new Color4(34, 34, 34, 255);
Controls.Add(ser = new FlowLayout()
{
BackgroundColor = new(26, 26, 26, 255),
Size = new((int)(68 * Globals.Settings.Scale), (int)(868 * Globals.Settings.Scale)),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom,
Location = new(0,0,0)
});
DrawFrame();
foreach (PublicServer pser in Globals.Luski.LoadedServers)
{
ser.Controls.Add(new ServerIcon<PublicServer>(pser));
}
AddServerIcon asi = new();
asi.Button.Clicked += AddButtonClicked;
ser.Controls.Add(asi);
await (ser.Controls[0] as ServerIcon<PublicServer>)!.LoadServer();
MainShow += OnMainShow;
return Task.CompletedTask;
}
private Task AddButtonClicked(IRenderObject arg)
{
AddServerOverlay aso = new();
aso.Clicked += AsoOnClicked;
Controls.Add(aso);
TryDraw();
return Task.CompletedTask;
}
private Task AsoOnClicked(IRenderObject arg)
{
Globals.ms.Controls.Remove(arg);
Globals.ms.DrawFrame();
AddServerOverlay aso = (arg as AddServerOverlay)!;
aso.Clicked -= AsoOnClicked;
aso.Clean();
aso = null!;
return Task.CompletedTask;
}
private Task OnMainShow()
{
if (Globals.Luski.MainServer is not null && Globals.Luski.MainServer.IsLogedIn)
{
Globals.Luski.MainServer.OnError += LuskiOnOnError;
}
return Task.CompletedTask;
}
public event Func<Task>? MainShow;
private Task LuskiOnOnError(Exception arg)
{
Console.WriteLine(arg);
return Task.CompletedTask;
}
}

View File

@ -15,7 +15,7 @@ namespace Luski.GUI.StartPage.UI;
public class CreateAccount : UserControl public class CreateAccount : UserControl
{ {
private RoundedButton button; private RoundedButton button;
private Textbox Password, UsernameTextbox, DisplaynameTextBox; private TexturedTextBox Password, UsernameTextbox, DisplaynameTextBox;
private Rectangle rec; private Rectangle rec;
private string? pfp; private string? pfp;
@ -28,13 +28,13 @@ public class CreateAccount : UserControl
Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))}); Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))});
Label t; Label t;
Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f * (float)Globals.Settings.Scale, Location = new((int)(199*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) }); Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f * (float)Globals.Settings.Scale, Location = new((int)(199*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) });
t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y); t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y, 0);
tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y); tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y, 0);
Controls.Add(UsernameTextbox = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Username", Location = new((int)(27 * Globals.Settings.Scale),(int)(280 * Globals.Settings.Scale)), Size = new((int)(261 * Globals.Settings.Scale),(int)(27 * Globals.Settings.Scale)), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan }); Controls.Add(UsernameTextbox = new(Globals.LuskiTexture, Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Username", Location = new((int)(27 * Globals.Settings.Scale),(int)(280 * Globals.Settings.Scale), 0), Size = new((int)(261 * Globals.Settings.Scale),(int)(27 * Globals.Settings.Scale)),});
Controls.Add(Password = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Password", PasswordChar = '●', Location = new(UsernameTextbox.Location.X,(int)(346 * Globals.Settings.Scale)), Size = new(UsernameTextbox.Size.X, UsernameTextbox.Location.X), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan }); Controls.Add(Password = new(Globals.LuskiTexture, Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Password", PasswordChar = '●', Location = new(UsernameTextbox.Location.X,(int)(346 * Globals.Settings.Scale), 0), Size = new(UsernameTextbox.Size.X, UsernameTextbox.Location.X), });
Controls.Add(DisplaynameTextBox = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Displayname", Location = new(UsernameTextbox.Location.X,(int)(400 * Globals.Settings.Scale)), Size = new((int)(196 * Globals.Settings.Scale), UsernameTextbox.Location.X), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan }); Controls.Add(DisplaynameTextBox = new(Globals.LuskiTexture, Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Displayname", Location = new(UsernameTextbox.Location.X,(int)(400 * Globals.Settings.Scale), 0), Size = new((int)(196 * Globals.Settings.Scale), UsernameTextbox.Location.X), });
Controls.Add(button = new(Globals.DefaultFont) { Text = "Create Account", Location = new(UsernameTextbox.Location.X, (int)(456 * Globals.Settings.Scale)), Size = new(UsernameTextbox.Size.X, (int)(46 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan }); Controls.Add(button = new(Globals.LuskiTexture, Globals.DefaultFont) { Text = "Create Account", Location = new(UsernameTextbox.Location.X, (int)(456 * Globals.Settings.Scale), 0), Size = new(UsernameTextbox.Size.X, (int)(46 * Globals.Settings.Scale)),});
Controls.Add(rec = new Rectangle(){ Location = new((int)(228 * Globals.Settings.Scale), (int)(384 * Globals.Settings.Scale)), Size = new((int)(50 * Globals.Settings.Scale)), BackgroundColor = Color4.Red}); Controls.Add(rec = new Rectangle(){ Location = new((int)(228 * Globals.Settings.Scale), (int)(384 * Globals.Settings.Scale), 0), Size = new((int)(50 * Globals.Settings.Scale)), BackgroundColor = Color4.Red});
Password.KeyPress += PasswordOnKeyPress; Password.KeyPress += PasswordOnKeyPress;
UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress; UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress;
button.Clicked += ButtonOnClicked; button.Clicked += ButtonOnClicked;
@ -58,7 +58,8 @@ public class CreateAccount : UserControl
if (!rec.Textures.Any()) if (!rec.Textures.Any())
{ {
Controls.Remove(rec); Controls.Remove(rec);
Vector2i oldl = rec.Location, olds = rec.Size; Vector3i oldl = rec.Location;
Vector2i olds = rec.Size;
rec = new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), rec = new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Location = oldl, Size = olds }; "Luski.Resources.Textures.Status.png"))) { Location = oldl, Size = olds };
Texture tex = Globals.ms.TextureManager.AddTexture(File.OpenRead(arg[0])); Texture tex = Globals.ms.TextureManager.AddTexture(File.OpenRead(arg[0]));

View File

@ -11,7 +11,7 @@ namespace Luski.GUI.StartPage.UI;
public class Login : UserControl public class Login : UserControl
{ {
private RoundedButton button; private RoundedButton button;
private Textbox Password, UsernameTextbox; private TexturedTextBox Password, UsernameTextbox;
private Label ca; private Label ca;
public event Func<Task>? ChangeToApp; public event Func<Task>? ChangeToApp;
public event Func<Task>? ChangeToCa; public event Func<Task>? ChangeToCa;
@ -22,12 +22,12 @@ public class Login : UserControl
Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))}); Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))});
Label t; Label t;
Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f, Location = new((int)(199*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) }); Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f, Location = new((int)(199*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) });
t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y); t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y, 0);
tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y); tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y, 0);
Controls.Add(UsernameTextbox = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Username", Location = new((int)(27*Globals.Settings.Scale),(int)(280 * Globals.Settings.Scale)), Size = new((int)(261 * Globals.Settings.Scale),(int)(27 * Globals.Settings.Scale)), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan }); Controls.Add(UsernameTextbox = new(Globals.LuskiTexture, Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Username", Location = new((int)(27*Globals.Settings.Scale),(int)(280 * Globals.Settings.Scale), 0), Size = new((int)(261 * Globals.Settings.Scale),(int)(27 * Globals.Settings.Scale))});
Controls.Add(Password = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Password", PasswordChar = '●', Location = new(UsernameTextbox.Location.X,(int)(365 * Globals.Settings.Scale)), Size = UsernameTextbox.Size, InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan }); Controls.Add(Password = new(Globals.LuskiTexture, Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Password", PasswordChar = '●', Location = new(UsernameTextbox.Location.X,(int)(365 * Globals.Settings.Scale), 0), Size = UsernameTextbox.Size, });
Controls.Add(ca = new Label(Globals.DefaultFont) { Location = new(UsernameTextbox.Location.X,(int)(419 * Globals.Settings.Scale)), Text = "Create Account" }); Controls.Add(ca = new Label(Globals.DefaultFont) { Location = new(UsernameTextbox.Location.X,(int)(419 * Globals.Settings.Scale), 0), Text = "Create Account" });
Controls.Add(button = new(Globals.DefaultFont) {Text = "Login", Location = new(UsernameTextbox.Location.X, (int)(455 * Globals.Settings.Scale)), Size = new(UsernameTextbox.Size.X,(int)(46 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan }); Controls.Add(button = new(Globals.LuskiTexture, Globals.DefaultFont) {Text = "Login", Location = new(UsernameTextbox.Location.X, (int)(455 * Globals.Settings.Scale), 0), Size = new(UsernameTextbox.Size.X,(int)(46 * Globals.Settings.Scale)),});
Password.KeyPress += PasswordOnKeyPress; Password.KeyPress += PasswordOnKeyPress;
UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress; UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress;
button.Clicked += ButtonOnClicked; button.Clicked += ButtonOnClicked;
@ -74,8 +74,6 @@ public class Login : UserControl
if (e.Message.Contains("Invaled Login")) if (e.Message.Contains("Invaled Login"))
{ {
BlockDraw = true; BlockDraw = true;
Password.BorderColor = Color4.DarkRed;
UsernameTextbox.BorderColor = Color4.DarkRed;
BlockDraw = false; BlockDraw = false;
TryDraw(); TryDraw();
} }

View File

@ -37,18 +37,16 @@ public class UpdateWindow : Window
if (!Globals.Empty(Globals.UpdaterSettings.Updater)) if (!Globals.Empty(Globals.UpdaterSettings.Updater))
{ {
t.Text += "\n\nWould you like to update?"; t.Text += "\n\nWould you like to update?";
Controls.Add(yes = new(Globals.DefaultFont) Controls.Add(yes = new(Globals.LuskiTexture, Globals.DefaultFont)
{ {
Text = "Yes", Text = "Yes",
Location = new(t.Location.X, t.Location.Y + t.Size.Y + (int)(t.Scale * t.Font.PixelHeight)), Location = new(t.Location.X, t.Location.Y + t.Size.Y + (int)(t.Scale * t.Font.PixelHeight), 0),
Size = new(t.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), Size = new(t.Size.X, (int)(35.5 * Globals.Settings.Scale))
BorderColor = Color4.DarkCyan
}); });
Controls.Add(no = new(Globals.DefaultFont) Controls.Add(no = new(Globals.LuskiTexture, Globals.DefaultFont)
{ {
Text = "No", Location = new(t.Location.X, yes.Location.Y + yes.Size.Y + 20), Text = "No", Location = new(t.Location.X, yes.Location.Y + yes.Size.Y + 20, 0),
Size = new(yes.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), Size = new(yes.Size.X, (int)(35.5 * Globals.Settings.Scale))
BorderColor = Color4.DarkCyan
}); });
Size = new(t.Location.X + t.Location.X + t.Size.X, no.Location.Y + no.Size.Y + t.Location.X); Size = new(t.Location.X + t.Location.X + t.Size.X, no.Location.Y + no.Size.Y + t.Location.X);
yes.Clicked += YesOnClicked; yes.Clicked += YesOnClicked;
@ -57,12 +55,11 @@ public class UpdateWindow : Window
else else
{ {
t.Text += "\n\nNo updater path was set\nSet a path for auto updates"; t.Text += "\n\nNo updater path was set\nSet a path for auto updates";
Controls.Add(no = new(Globals.DefaultFont) Controls.Add(no = new(Globals.LuskiTexture, Globals.DefaultFont)
{ {
Text = "Ok", Text = "Ok",
Location = new(t.Location.X, t.Location.Y + t.Size.Y + (int)(t.Scale * t.Font.PixelHeight)), Location = new(t.Location.X, t.Location.Y + t.Size.Y + (int)(t.Scale * t.Font.PixelHeight), 0),
Size = new(t.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), Size = new(t.Size.X, (int)(35.5 * Globals.Settings.Scale)),
BorderColor = Color4.DarkCyan
}); });
Size = new(t.Location.X + t.Location.X + t.Size.X, no.Location.Y + no.Size.Y + t.Location.X); Size = new(t.Location.X + t.Location.X + t.Size.X, no.Location.Y + no.Size.Y + t.Location.X);
no.Clicked += NoOnClicked; no.Clicked += NoOnClicked;

View File

@ -1,44 +0,0 @@
using GraphicsManager;
using GraphicsManager.Enums;
using Luski.GUI.MainScreen.Interfaces;
using Luski.GUI.MainScreen.UI;
using Luski.net.Structures.Main;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
namespace Luski.GUI.Windows;
public class ChatWindow : Window
{
private static readonly NativeWindowSettings Settings = new()
{
Title = "Channel",
WindowBorder = WindowBorder.Resizable,
APIVersion = new Version(3, 2),
StartFocused = true,
Size = new OpenTK.Mathematics.Vector2i((int)(754 * Globals.Settings.Scale), (int)(667 * Globals.Settings.Scale)),
Icon = Globals.Icon,
SharedContext = null
};
public ChatWindow(IChannelPick pick) : base(Settings)
{
Chat c;
WindowBorder = WindowBorder.Resizable;
Controls.Add(c= new Chat()
{
Location = new(0),
Size = new(Size.X, Size.Y),
Anchor = ObjectAnchor.All
});
c.UpdateTitle(pick);
IReadOnlyList<MainSocketMessage> messages = pick.Channel.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel).Result;
foreach (MainSocketMessage message in messages.Reverse())
{
c!.AddMessage(TextureManager, message);
}
c!.MessageFlow.ScrollToBottom();
}
}

View File

@ -2,9 +2,10 @@ using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization.Metadata; using System.Text.Json.Serialization.Metadata;
using GraphicsManager; using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects.Core; using GraphicsManager.Objects.Core;
using Luski.Clesses; using Luski.Clesses;
using Luski.GUI.MainScreen; using Luski.GUI;
using Luski.net; using Luski.net;
using Luski.net.Interfaces; using Luski.net.Interfaces;
using Luski.net.Structures.Public; using Luski.net.Structures.Public;
@ -17,9 +18,45 @@ namespace Luski;
public static class Globals public static class Globals
{ {
#pragma warning disable CS8618 #pragma warning disable CS8618
public static Dictionary<Window, List<IRenderObject>> AllowedBehindObjects = new();
public static void AddBehindObject(this Window w, IRenderObject obj)
{
if (!AllowedBehindObjects.ContainsKey(w)) AllowedBehindObjects.Add(w, new());
if (AllowedBehindObjects[w].Count > 0)
{
obj.AllowHoverFromBehind = AllowedBehindObjects[w][0].AllowHoverFromBehind;
}
w.Controls.Add(obj);
AllowedBehindObjects[w].Add(obj);
}
public static void ToggleBehindObjects(this Window w)
{
if (!AllowedBehindObjects.ContainsKey(w)) AllowedBehindObjects.Add(w, new());
if (AllowedBehindObjects[w].Count > 0)
{
bool new_val = !AllowedBehindObjects[w][0].AllowHoverFromBehind;
foreach (IRenderObject v in AllowedBehindObjects[w])
{
v.AllowHoverFromBehind = new_val;
}
}
}
public static void RemoveBehindObject(this Window w, IRenderObject obj, bool purge = true)
{
if (!AllowedBehindObjects.ContainsKey(w)) AllowedBehindObjects.Add(w, new());
AllowedBehindObjects[w].Remove(obj);
w.Controls.Remove(obj, purge);
obj.Clean();
obj = null!;
}
public static bool Download { get; set; } = false; public static bool Download { get; set; } = false;
public static API Luski { get; } = new(); public static API Luski { get; } = new();
public static MainScreen ms; public static MainScreenWindow ms;
private static Texture? gac; private static Texture? gac;
public static Color4 ToColor4(this Color col) public static Color4 ToColor4(this Color col)

View File

@ -19,14 +19,18 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.6-alpha89" /> <PackageReference Include="GraphicsManager" Version="1.0.7-alpha40" />
<PackageReference Include="Luski.net" Version="2.0.0-alpha23" /> <PackageReference Include="Luski.net" Version="2.0.0-alpha25" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources/**"></EmbeddedResource> <EmbeddedResource Include="Resources/**"></EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="GUI\Windows\" />
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>Luski.ico</ApplicationIcon> <ApplicationIcon>Luski.ico</ApplicationIcon>

View File

@ -3,18 +3,43 @@ using System.Reflection;
using GraphicsManager; using GraphicsManager;
using Luski; using Luski;
using Luski.Clesses; using Luski.Clesses;
using Luski.GUI.MainScreen; using Luski.GUI;
using Luski.net; using OpenTK.Graphics.OpenGL;
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;
using Image = OpenTK.Windowing.Common.Input.Image; using Image = OpenTK.Windowing.Common.Input.Image;
using Rectangle = GraphicsManager.Objects.Rectangle;
try try
{ {
/*Window w = new();
Rectangle r, rr;
w.Size = new(1000);
r = new()
{
Location = new(250,250,0),
Size = new(500),
BackgroundColor = Color4.Green
};
GL.Enable(EnableCap.DepthTest);
// GL.DepthFunc(DepthFunction.Notequal);
rr = new()
{
Location = new(500,500,-1),
Size = new(500),
BackgroundColor = Color4.Blue
};
w.Controls.Add(rr);
w.Controls.Add(r);
w.StartRender();*/
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);
ServerList serverlist = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Servers.json"), ServerListContext.Default.ServerList); ServerList serverlist = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Servers.json"), ServerListContext.Default.ServerList);
List<Task<PublicServer>> bbb = new(); List<Task<bool>> bbb = new();
if (serverlist.Server.Length > 0) if (serverlist.Server.Length > 0)
{ {
foreach (ServerInfo server in serverlist.Server) foreach (ServerInfo server in serverlist.Server)
@ -22,7 +47,7 @@ try
switch (server.Main) switch (server.Main)
{ {
case false: case false:
bbb.Add(Globals.Luski.GetPublicServer(server.Domain, server.Version, server.Secure)); bbb.Add(Globals.Luski.TryGetPublicServer(out _,server.Domain, server.Version, server.Secure));
break; break;
case true: case true:
Globals.Luski.GetMainServer(server.Domain, server.Version); Globals.Luski.GetMainServer(server.Domain, server.Version);
@ -37,7 +62,7 @@ try
Globals.UpdaterSettings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings); Globals.UpdaterSettings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
//Globals.Luski.LoadedServers.First().CreateAccount("JacobTech", "JacobGuin12173*", "JacobTech", "/home/jacob/Pictures/Logo.png", CancellationToken.None); //Globals.Luski.LoadedServers.First().CreateAccount("JacobTech", "JacobGuin12173*", "JacobTech", "/home/jacob/Pictures/Logo.png", CancellationToken.None);
Task.WaitAll(bbb.ToArray()); Task.WaitAll(bbb.ToArray());
if (!Globals.Luski.LoadedServers.First().IsLogedIn) if (!Globals.Luski.IsAnyServerLoggedin)
_ = Globals.Luski.LoadedServers.First().Login("JacobTech", "JacobGuin12173*", CancellationToken.None).Result; _ = Globals.Luski.LoadedServers.First().Login("JacobTech", "JacobGuin12173*", CancellationToken.None).Result;
Image<Rgba32> Logo = SixLabors.ImageSharp.Image.Load<Rgba32>(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Luski.png")); Image<Rgba32> Logo = SixLabors.ImageSharp.Image.Load<Rgba32>(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Luski.png"));
Logo.DangerousTryGetSinglePixelMemory(out Memory<Rgba32> m); Logo.DangerousTryGetSinglePixelMemory(out Memory<Rgba32> m);
@ -47,7 +72,7 @@ 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();
Globals.ms = new MainScreen(); Globals.ms = new MainScreenWindow();
Globals.ms.CustomF11 = false; Globals.ms.CustomF11 = false;
Globals.ms.DrawFrame(); Globals.ms.DrawFrame();
//Globals.ms.Cursor = new MouseCursor(0, 0, Logo.Width, Logo.Height, pixels); //Globals.ms.Cursor = new MouseCursor(0, 0, Logo.Width, Logo.Height, pixels);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B