This commit is contained in:
JacobTech 2023-11-18 12:33:05 -05:00
parent a6fc28e2ab
commit 580d576e76
28 changed files with 648 additions and 1508 deletions

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)