dev #17

Merged
JacobTech merged 29 commits from dev into main 2024-04-11 15:50:14 -04:00
13 changed files with 253 additions and 181 deletions
Showing only changes of commit ac830c6578 - Show all commits

View File

@ -1,5 +1,4 @@
using System.Diagnostics;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using GraphicsManager;
@ -29,13 +28,14 @@ public class MainScreen : Window
Title = "Luski Login",
WindowBorder = WindowBorder.Fixed,
APIVersion = new Version(3, 2),
API = ContextAPI.OpenGL,
StartFocused = true,
Size = new Vector2i((int)(240.5 * Globals.Settings.Scale), (int)(419 * Globals.Settings.Scale)),
Size = new Vector2i((int)(312 * Globals.Settings.Scale), (int)(545 * Globals.Settings.Scale)),
Icon = Globals.Icon,
SharedContext = null
};
private TabControl tc;
public TabControl? tc;
private FlowLayout? channelpicker, friends, friend_request;
private RoundedButton? FriendManagerBtn;
public Chat? chat;
@ -59,7 +59,6 @@ public class MainScreen : Window
// The rest of the function is up to you to implement, however a debug output
// is always useful.
return;
switch (severity)
{
case DebugSeverity.DebugSeverityHigh:
@ -87,11 +86,10 @@ return;
GL.Enable(EnableCap.DebugOutput);
Globals.DefaultFont =
Font.MakeEmbeddedFont("Luski.Resources.Fonts.OpenSans-Regular.ttf", Assembly.GetExecutingAssembly());
Globals.DefaultFont.PixelHeight = (uint)(12 * Globals.Settings.Scale);
//Font.MakeFontFromSystem((uint)(12 * Globals.Settings.Scale));
//Globals.DefaultFont = Font.MakeFontFromFile(@"C:\Users\techn\Downloads\tahoma.ttf");
Globals.DefaultFont.PixelHeight = (uint)(20 * Globals.Settings.Scale);
Globals.LuskiTexture = TextureManager.AddTexture(Tools.GetResourceBytes(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Luski.png"));
CenterWindow(0);
Controls.Add(ca = new CreateAccount());
ca.Visible = false;
@ -112,10 +110,6 @@ return;
private Task OnWindowLoadedd(Window arg)
{
Console.WriteLine(login.r.Location.Y);
Console.WriteLine(login.r.ScissorLocation.Y);
Console.WriteLine(login.r.Location.X);
Console.WriteLine(login.r.ScissorLocation.X);
return Task.CompletedTask;
}
private Task OnWindowLoaded(Window arg)
@ -170,7 +164,7 @@ return;
{
Friend friend2 = new(user);
friend2.ClickCon += ChannelOnClickCon;
friends.Controls.Add(friend2);
friends!.Controls.Add(friend2);
if (user.Channel is not null)
{
Friend friend = new(user);
@ -182,18 +176,20 @@ return;
}
private CancellationTokenSource? channelCancellationToken = null;
private async Task ChannelOnClickCon(IChannelPick arg)
private Task ChannelOnClickCon(IChannelPick arg)
{
try
{
BlockDraw = true;
Thread t = new(a => cc(a));
Thread t = new(a => cc(a!));
t.Start(arg);
}
catch (Exception e)
{
Console.WriteLine(e);
}
return Task.CompletedTask;
}
private void cc(object argg)
@ -205,10 +201,8 @@ return;
{
chat!.UpdateTitle(arg);
}));
Console.WriteLine("Checking token");
if (channelCancellationToken is not null)
{
Console.WriteLine("Cancling token");
channelCancellationToken.Cancel(false);
}
channelCancellationToken = new CancellationTokenSource();
@ -258,20 +252,29 @@ return;
//Clip
// Console.WriteLine(Public);
Globals.Luski.SetMultiThreadPercent(Globals.Settings.MultiThreadPercent);
Size = new((int)(1024 * Globals.Settings.Scale), (int)(667 * Globals.Settings.Scale));
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(new Rectangle(TextureManager.AddTexture(Globals.Luski.CurrentUser.GetAvatar(CancellationToken.None).Result, true)) { Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Size = new((int)(35 * Globals.Settings.Scale)), Location = new((int)(47 * Globals.Settings.Scale), (int)(624 * Globals.Settings.Scale))});
Controls.Add(new Label(){ Font = Globals.DefaultFont, Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Location = new((int)(86 * Globals.Settings.Scale), (int)(635.5 * Globals.Settings.Scale)), Text = Globals.Luski.CurrentUser.Username});
Rectangle u=new Rectangle(TextureManager.AddTexture(Tools.GetResourceBytes(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Size = new((int)(46 * Globals.Settings.Scale)), Location = new((int)(62 * Globals.Settings.Scale), (int)(812 * Globals.Settings.Scale))};
Texture uut = TextureManager.AddTexture(Globals.Luski.CurrentUser.GetAvatar(CancellationToken.None).Result);
uut.Unit = TextureUnit.Texture1;
u.Shader = Rectangle.DefaultAlphaTextureShader[Context];
u.Textures.Add(uut);
Controls.Add(u);
Label ul = new Label(){ Font = Globals.DefaultFont, Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Location = new(0, (int)(826 * Globals.Settings.Scale)), Text = Globals.Luski.CurrentUser.Username};
FlowLayout ser;
Controls.Add(chat = new() {Location = new((int)(270 * Globals.Settings.Scale),0)});
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(ser = new FlowLayout()
{
BackgroundColor = new(26, 26, 26, 255),
Size = new((int)(40 * Globals.Settings.Scale),(int)(667 * Globals.Settings.Scale)),
Size = new((int)(52 * Globals.Settings.Scale),(int)(868 * Globals.Settings.Scale)),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom,
});
@ -297,16 +300,16 @@ return;
tc.AddPage("Add Friend", new AddFriendPage(this));
ser.Controls.Add(new Rectangle(Globals.LuskiTexture)
{
Size = new((int)(40 * Globals.Settings.Scale)),
Size = new((int)(52 * Globals.Settings.Scale)),
});
Controls.Add(channelpicker = new FlowLayout()
{
BackgroundColor = new(34,34,34,255),
Size = new((int)(230 * Globals.Settings.Scale), (int)(616 * Globals.Settings.Scale)),
Location = new((int)(40 * Globals.Settings.Scale), 0),
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() { Font = Globals.DefaultFont, Text = "Friends", Size = new((int)(40* Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan});
channelpicker.Controls.Add(FriendManagerBtn = new RoundedButton() { Font = 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");
foreach (SocketGroupChannel ch in Globals.Luski.CurrentUser.Channels.Where(s => s is SocketGroupChannel).Cast<SocketGroupChannel>())
@ -363,7 +366,7 @@ return;
return Task.CompletedTask;
}
public event Func<Task> MainShow;
public event Func<Task>? MainShow;
private Task LuskiOnOnError(Exception arg)
{
@ -396,9 +399,17 @@ return;
Console.WriteLine(before);
Console.WriteLine(After);
if (before is not SocketRemoteUser Before || Before.FriendStatus != FriendStatus.Friends || Before.Id == 0) return Task.CompletedTask;
Label stat = fr.Where(s => s.User.Id == before.Id).First()!.Status;
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;
@ -406,15 +417,15 @@ return;
private Task FriendManagerBtnOnClicked(IRenderObject arg)
{
if (chat.Visible)
if (chat!.Visible)
{
chat.Visible = false;
tc.Visible = true;
tc!.Visible = true;
}
else
{
chat.Visible = true;
tc.Visible = false;
tc!.Visible = false;
}
return Task.CompletedTask;
}

View File

@ -3,7 +3,6 @@ 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.JsonTypes;
using OpenTK.Mathematics;
@ -15,40 +14,38 @@ namespace Luski.GUI.MainScreen.UI;
public class Chat : UserControl
{
public FlowLayout MessageFlow;
private UserControl titlecon;//, typecon;
private Label title, desc;
private Textbox tb;
private SocketTextChannel? Channel = null;
private SocketTextChannel? Channel;
public Chat()
{
Size = new((int)(754 * Globals.Settings.Scale), (int)(667 * Globals.Settings.Scale));
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((int)(754 * Globals.Settings.Scale), (int)(586 * Globals.Settings.Scale)),
Location = new(0, (int)(40 * Globals.Settings.Scale)),
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)(754 * Globals.Settings.Scale), (int)(40 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
//Controls.Add(typecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Bottom | ObjectAnchor.Right, Location = new(0, (int)(626 * Globals.Settings.Scale)), Size = new((int)(754 * Globals.Settings.Scale), (int)(41 * 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.Controls.Add(title = new Label()
{
Font = Globals.DefaultFont, Location = new(
(int)((20 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale),
(int)((20 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight / 2)))
(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(){ Font = Globals.DefaultFont, Color = new(161,161,161,255), Location = new(title.Location.X + title.Size.X + 5, title.Location.Y)});
//typecon.Controls.Add();
Controls.Add(tb = new Textbox()
{
Font = Globals.DefaultFont,
InsideColor = new(28, 28, 28, 255),
BorderColor = Color4.DarkCyan,
Location = new((int)(7.5 * Globals.Settings.Scale), (int)(633.5 * Globals.Settings.Scale)),
Size = new((int)(739 * Globals.Settings.Scale), (int)(26 * Globals.Settings.Scale)),
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.All
});
tb.KeyPress += TbOnKeyPress;
@ -66,7 +63,7 @@ public class Chat : UserControl
private void Thr()
{
Globals.Luski.SendMessage(tb.Text, Channel!.Id, CancellationToken.None);
Window!.Invoke(new Action(() => { tb.Text = string.Empty; }));
Window!.Invoke(() => { tb.Text = string.Empty; });
}
private Task LuskiOnMessageReceived(SocketMessage arg)
@ -75,7 +72,7 @@ public class Chat : UserControl
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(new Action(() => { MessageFlow.ScrollToBottom();}));
if (reff is null || (reff.Location.Y + reff.Size.Y <= MessageFlow.Size.Y && reff.Location.X >= 0)) Window.Invoke(() => { MessageFlow.ScrollToBottom();});
return Task.CompletedTask;
}
@ -108,9 +105,9 @@ public class Chat : UserControl
}
}
private SocketMessage? lastm = null;
private long? lastUser = null;
private ChatMessage? LastChatMessage = null;
private SocketMessage? lastm;
private long? lastUser;
private ChatMessage? LastChatMessage;
public void AddMessage(TextureManager m, SocketMessage Message)
{
@ -127,7 +124,11 @@ public class Chat : UserControl
MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(m, Message));
}
else
Globals.ms!.Invoke(new Action(() => { MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(m ,Message)); Window.DrawFrame(); }));
Globals.ms.Invoke(() =>
{
MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(m, Message));
Window.DrawFrame();
});
}
else
{
@ -136,7 +137,7 @@ public class Chat : UserControl
LastChatMessage!.AddMessage(Message);
}
else
Globals.ms!.Invoke(new Action(() => { LastChatMessage!.AddMessage(Message); Window!.DrawFrame(); }));
Globals.ms.Invoke(() => { LastChatMessage!.AddMessage(Message); Window!.DrawFrame(); });
}
lastUser = Message.AuthorID;

View File

@ -1,3 +1,4 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
@ -6,8 +7,8 @@ using GraphicsManager.Objects.Core;
using Luski.net.Enums;
using Luski.net.Interfaces;
using Luski.net.JsonTypes;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using File = Luski.net.JsonTypes.File;
namespace Luski.GUI.MainScreen.UI;
@ -16,12 +17,13 @@ public class ChatMessage : UserControl
readonly int padding = 2;
private static Font TimeFont = Font.MakeFontFromSystem(13);
private SocketMessage Msg { get; }
private Label label1, label2, lastm;
private Label label2, lastm;
private static Dictionary<SocketRemoteUser, ContextMenu> Menues = new();
private static Dictionary<SocketRemoteUser, List<ChatMessage>> Messages = new();
public ChatMessage(TextureManager tm, SocketMessage message)
{
Label label1;
Size = new((int)(723.5 * Globals.Settings.Scale), (int)(37 * Globals.Settings.Scale));
BackgroundColor = new(40, 40, 40, 255);
@ -29,7 +31,7 @@ public class ChatMessage : UserControl
IUser user = message.GetAuthor(CancellationToken.None).Result;
Anchor = ObjectAnchor.Left | ObjectAnchor.Right;
Controls.Add(label1 = new Label() { Font = Globals.DefaultFont, Location = new((int)(42 * Globals.Settings.Scale), (int)(4.5 * Globals.Settings.Scale)), Text = user.Username});
Controls.Add(label1 = new Label() { Font = Globals.DefaultFont, Location = new((int)(54 * Globals.Settings.Scale), (int)(6 * Globals.Settings.Scale)), Text = user.Username});
@ -47,9 +49,15 @@ public class ChatMessage : UserControl
{
timestr = $"{time:M/dd/yyyy h:mm tt}";
}
Controls.Add(new Label() { Font = Globals.DefaultFont, Location = new(label1.Location.X + label1.Size.X + 4, (int)(4.5 * Globals.Settings.Scale)), Text = timestr});
Controls.Add(new Rectangle(tm.AddTexture(user.GetAvatar(CancellationToken.None).Result, true)) { Location = new((int)(7.5 * Globals.Settings.Scale), (int)(1.5 * Globals.Settings.Scale)), Size = new((int)(29 * Globals.Settings.Scale)) });
Controls.Add(label2 = new Label() { Font = Globals.DefaultFont, Location = new((int)(41.5 * Globals.Settings.Scale), (int)(20 * Globals.Settings.Scale)), Text = message.Context});
Controls.Add(new Label() { Scale = 0.8f, Font = Globals.DefaultFont, Location = new(label1.Location.X + label1.Size.X + 4, label1.Location.Y), Text = timestr});
Rectangle r = new Rectangle(tm.AddTexture(Tools.GetResourceBytes(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() { Font = 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)
{
@ -109,7 +117,8 @@ public class ChatMessage : UserControl
Messages.Remove(uu);
Menues.Remove(uu);
SocketRemoteUser? result = Globals.Luski.SendFriendRequest(long.Parse(uu.friend_codes.First()), CancellationToken.None).Result;
SocketRemoteUser result = Globals.Luski
.SendFriendRequest(long.Parse(uu.friend_codes.First()), CancellationToken.None).Result;
if (result.Channel is null)
Globals.ms.AddFriendRequest(result);
else
@ -132,11 +141,11 @@ public class ChatMessage : UserControl
newLabel.MouseEnter += NewLabel_MouseEnter;
newLabel.MouseLeave += NewLabel_MouseLeave;
Controls.Add(newLabel);
if (msg.Files != null && msg.Files.Length > 0)
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++)
for (int i = 0; i < msg.Files.Length; i++)
{
int lx = (padding * filesonrow) + lastm.Location.X + (333 * (filesonrow + 1));
if (lx > Size.X)
@ -147,7 +156,7 @@ public class ChatMessage : UserControl
}
filesonrow++;
Controls.Add(new ContentEmbed(Msg.Files[i], Msg.ChannelID)
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)))
});
@ -162,8 +171,8 @@ public class ChatMessage : UserControl
if (label.Tag is not SocketMessage 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");
IEnumerable<Label>? l = Labels.Where(s => s.Text == b);
if (l is not null && l.Any())
Label[] l = Labels.Where(s => s.Text == b).ToArray();
if (l.Any())
{
Controls.Remove(l.First());
Labels.Remove(l.First());

View File

@ -2,7 +2,6 @@ using System.Reflection;
using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using File = Luski.net.JsonTypes.File;
namespace Luski.GUI.MainScreen.UI;
@ -11,28 +10,21 @@ public class ContentEmbed : UserControl
{
readonly File file;
long channel;
private Label fileNameLabel, fileSizeLabel;
private Rectangle downloadButton;
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((double)size / (double)1000, 2) + " KB";
} else if (size < 1000000000)
{
fst = Math.Round((double)size / (double)1000000, 2) + " MB";
} else if (size < 1000000000000)
{
fst = Math.Round((double)size / (double)1000000000, 2) + " GB";
}
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() {Text = fst, Location = new(64, 39)});
@ -41,7 +33,7 @@ public class ContentEmbed : UserControl
byte[] tempp = Tools.GetResourceBytes(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; ;
int temp2 = fileSizeLabel.Size.X + fileSizeLabel.Location.X;
if (temp >= temp2) Size = new(temp + 4, Size.Y);
else Size = new(temp2 + 4, Size.Y);
}

View File

@ -1,16 +1,15 @@
using GraphicsManager.Enums;
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.Enums;
using Luski.net.JsonTypes;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;
using Window = GraphicsManager.Window;
namespace Luski.GUI.MainScreen.UI;
@ -22,34 +21,59 @@ public class Friend : UserControl, IChannelPick
{
get
{
return User.Channel;
return User.Channel!;
}
}
private Rectangle r;
public Rectangle r, rr;
public Label Username, Status;
public Friend(SocketRemoteUser person)
{
User = person;
Size = new((int)(185 * Globals.Settings.Scale), (int)(48* Globals.Settings.Scale));
Size = new((int)(240 * Globals.Settings.Scale), (int)(62* Globals.Settings.Scale));
BackgroundColor = new(34, 34, 34, 255);
Controls.Add( r = new Rectangle(Globals.ms.TextureManager.AddTexture(person.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))});
Controls.Add(Username = new Label() { Font = Globals.DefaultFont, Text = person.Username, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(10 * Globals.Settings.Scale))});
Controls.Add(Status = new Label() { Font = Globals.DefaultFont, Text = person.Status.ToString(), Location = new((int)(38.5 * Globals.Settings.Scale),(int)(24 * Globals.Settings.Scale))});
Controls.Add(Username = new Label() { Font = Globals.DefaultFont, Text = person.Username, Location = new((int)(58 * Globals.Settings.Scale),(int)(14 * Globals.Settings.Scale))});
Controls.Add(Status = new Label() { Scale = 0.8f, Font = Globals.DefaultFont, 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.GetResourceBytes(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)(150 * Globals.Settings.Scale));
RoundedButton rr, rr2;
ContextMenu.Items.Add(rr=new()
ContextMenu = new((int)(196 * Globals.Settings.Scale));
RoundedButton rrr, rr2;
ContextMenu.Items.Add(rrr=new()
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(25 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Export Keys"
Size = new((int)(32 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Export Keys"
});
ContextMenu.Items.Add(rr2=new()
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(25 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Open In New Window"
Size = new((int)(32 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Open In New Window"
});
rr2.Clicked += Rr2OnClicked;
rr.Clicked += RrOnClicked;
rrr.Clicked += RrOnClicked;
}
private Task Rr2OnClicked(IRenderObject arg)

View File

@ -1,9 +1,12 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net.Enums;
using Luski.net.JsonTypes;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI;
@ -12,28 +15,39 @@ public class FriendRequest : UserControl
{
private MainScreen Screen;
public SocketRemoteUser User;
public Rectangle Accept, Reject;
public Rectangle? Accept, Reject;
public FriendRequest(MainScreen Parent, SocketRemoteUser User)
{
this.User = User;
this.Screen = Parent;
Size = new((int)(200 * Globals.Settings.Scale), (int)(48* Globals.Settings.Scale));
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))});
Controls.Add(new Label() { Font = Globals.DefaultFont, Text = User.Username, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(10 * Globals.Settings.Scale))});
Controls.Add(new Label() { Font = Globals.DefaultFont, Text = User.FriendStatus.ToString(), Location = new((int)(38.5 * Globals.Settings.Scale),(int)(24 * Globals.Settings.Scale))});
// 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.GetResourceBytes(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() { Font = Globals.DefaultFont, Text = User.Username, Location = new((int)(50 * Globals.Settings.Scale),(int)(14 * Globals.Settings.Scale))});
Controls.Add(new Label() { Font = 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)(127 * Globals.Settings.Scale), (int)(8.5 * Globals.Settings.Scale)),
Size = new((int)(29 * Globals.Settings.Scale))
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)(163.5 * Globals.Settings.Scale), (int)(8.5 * Globals.Settings.Scale)),
Size = new((int)(29 * Globals.Settings.Scale))
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;

View File

@ -1,8 +1,11 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net.JsonTypes;
using Luski.GUI.MainScreen.Interfaces;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI;
@ -10,32 +13,49 @@ namespace Luski.GUI.MainScreen.UI;
public class Group : UserControl, IChannelPick
{
public SocketTextChannel Channel { get; set; }
private string members = "";
private Rectangle r;
private Label Username, Status;
// private string members = "";
public Group(SocketGroupChannel chan)
{
Label Status, Username;
Rectangle r, rr;
Channel = chan;
Size = new((int)(185 * Globals.Settings.Scale), (int)(48* Globals.Settings.Scale));
Size = new((int)(240 * Globals.Settings.Scale), (int)(62* Globals.Settings.Scale));
BackgroundColor = new(34, 34, 34, 255);
Controls.Add( r = new Rectangle(Globals.ms.TextureManager.AddTexture(chan.GetPicture(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))});
Controls.Add(Username = new Label() { Font = Globals.DefaultFont, Text = chan.Title, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(10 * Globals.Settings.Scale))});
Controls.Add(rr=new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceBytes(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() { Font = Globals.DefaultFont, Text = chan.Title});
string sl = "Online";
if (chan.Id != 0)
{
sl = chan.Members.Count + " Members";
}
Controls.Add(Status = new Label() { Font = Globals.DefaultFont, Text = sl, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(24 * Globals.Settings.Scale))});
Controls.Add(Status = new Label() { Scale = 0.7f, Font = Globals.DefaultFont, 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 rr;
ContextMenu.Items.Add(rr=new()
RoundedButton rrr;
ContextMenu.Items.Add(rrr=new()
{
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
Size = new((int)(25 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Export Keys"
});
rr.Clicked += RrOnClicked;
rrr.Clicked += RrOnClicked;
}
private Task RrOnClicked(IRenderObject arg)
@ -51,5 +71,5 @@ public class Group : UserControl, IChannelPick
return Task.CompletedTask;
}
public event Func<IChannelPick, Task> ClickCon;
public event Func<IChannelPick, Task>? ClickCon;
}

View File

@ -1,6 +1,11 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.GraphicsLibraryFramework;
@ -12,22 +17,24 @@ public class CreateAccount : UserControl
private RoundedButton button;
private Textbox Password, Email, Username;
private Rectangle rec;
private string pfp = null;
private string? pfp;
public event Func<Task> ChangeToApp;
public event Func<Task>? ChangeToApp;
public CreateAccount()
{
Size = new((int)(240.5*Globals.Settings.Scale), (int)(419*Globals.Settings.Scale));
Controls.Add(new Rectangle(Globals.LuskiTexture) { Location = new((int)(51.5 * Globals.Settings.Scale), (int)(4 * Globals.Settings.Scale)), Size = new((int)(138*Globals.Settings.Scale), (int)(144.5*Globals.Settings.Scale))});
Size = new((int)(312 * Globals.Settings.Scale), (int)(545 * Globals.Settings.Scale));
Rectangle tt;
Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))});
Label t;
Controls.Add(t=new Label() { Scale = 1.6f, Font = Globals.DefaultFont, Location = new((int)(85*Globals.Settings.Scale),(int)(153*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) });
Controls.Add(t=new Label() { Scale = 1.6f * (float)Globals.Settings.Scale, Font = Globals.DefaultFont, 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);
Controls.Add(Email = new Textbox() { WatermarkFont = Globals.DefaultFont, WatermarkText = "Email", Font = Globals.DefaultFont, Location = new((int)(20.5 * Globals.Settings.Scale),(int)(215.5 * Globals.Settings.Scale)), Size = new((int)(200.5 * Globals.Settings.Scale),(int)(20.5 * Globals.Settings.Scale)), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan });
Controls.Add(Password = new Textbox() { WatermarkFont = Globals.DefaultFont, WatermarkText = "Password", Font = Globals.DefaultFont, PasswordChar = '●', Location = new(Email.Location.X,(int)(265.5 * Globals.Settings.Scale)), Size = new(Email.Size.X, Email.Location.X), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Controls.Add(Username = new Textbox() { WatermarkFont = Globals.DefaultFont, WatermarkText = "Username", Font = Globals.DefaultFont, Location = new(Email.Location.X,(int)(308 * Globals.Settings.Scale)), Size = new((int)(150 * Globals.Settings.Scale), Email.Location.X), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Controls.Add(button = new() { Font = Globals.DefaultFont, Text = "Create Account", Location = new(Email.Location.X, (int)(350 * Globals.Settings.Scale)), Size = new((int)(200.5 * Globals.Settings.Scale), (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Controls.Add(rec = new Rectangle(){ Location = new((int)(175 * Globals.Settings.Scale), (int)(292.5 * Globals.Settings.Scale)), Size = new((int)(50 * Globals.Settings.Scale)), BackgroundColor = Color4.Red});
tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y);
Controls.Add(Email = new Textbox() { TextLocation = TextLocation.TrueCenterLeft, WatermarkFont = Globals.DefaultFont, WatermarkText = "Email", Font = Globals.DefaultFont, 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(Password = new Textbox() { TextLocation = TextLocation.TrueCenterLeft, WatermarkFont = Globals.DefaultFont, WatermarkText = "Password", Font = Globals.DefaultFont, PasswordChar = '●', Location = new(Email.Location.X,(int)(346 * Globals.Settings.Scale)), Size = new(Email.Size.X, Email.Location.X), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Controls.Add(Username = new Textbox() { TextLocation = TextLocation.TrueCenterLeft, WatermarkFont = Globals.DefaultFont, WatermarkText = "Username", Font = Globals.DefaultFont, Location = new(Email.Location.X,(int)(400 * Globals.Settings.Scale)), Size = new((int)(196 * Globals.Settings.Scale), Email.Location.X), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Controls.Add(button = new() { Font = Globals.DefaultFont, Text = "Create Account", Location = new(Email.Location.X, (int)(456 * Globals.Settings.Scale)), Size = new(Email.Size.X, (int)(46 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
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});
Password.KeyPress += PasswordOnKeyPress;
Email.KeyPress += EmailOnKeyPress;
button.Clicked += ButtonOnClicked;
@ -48,9 +55,24 @@ public class CreateAccount : UserControl
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;
pfp = arg[0];
if (rec.Texture is null)
{Controls.Remove(rec);rec = new(Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]), true)){ Location = new(350, 585), Size = new(100) };Controls.Add(rec);}
else rec.Texture = Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]), true);
if (!rec.Textures.Any())
{
Controls.Remove(rec);
Vector2i oldl = rec.Location, olds = rec.Size;
rec = new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceBytes(Assembly.GetExecutingAssembly(),
"Luski.Resources.Textures.Status.png"))) { Location = oldl, Size = olds };
Texture tex = Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]));
tex.Unit = TextureUnit.Texture1;
rec.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
rec.Textures.Add(tex);
Controls.Add(rec);
//rec = new(Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]), true)){ Location = new(350, 585), Size = new(100) };Controls.Add(rec);
}
else
{
rec.Textures[1] = Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]));
rec.Textures[1].Unit = TextureUnit.Texture1;
}
Window!.DrawFrame();
return Task.CompletedTask;
@ -86,11 +108,11 @@ public class CreateAccount : UserControl
Email.Text,
Password.Text,
Username.Text,
pfp
pfp!
};
if (arr.Any(s => string.IsNullOrEmpty(s))) return Task.CompletedTask;
Globals.Luski = Server.CreateAccount(Email.Text, Password.Text, Username.Text, pfp, CancellationToken.None, Globals.UpdaterSettings.Branch);
ChangeToApp.Invoke();
Globals.Luski = Server.CreateAccount(Email.Text, Password.Text, Username.Text, pfp!, CancellationToken.None, Globals.UpdaterSettings.Branch);
ChangeToApp!.Invoke();
}
catch (Exception e)
{

View File

@ -1,11 +1,10 @@
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.net;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;
using SixLabors.ImageSharp.Drawing.Processing;
namespace Luski.GUI.StartPage.UI;
@ -16,18 +15,19 @@ public class Login : UserControl
private Label ca;
public event Func<Task>? ChangeToApp;
public event Func<Task>? ChangeToCa;
public Rectangle r;
public Login()
{
Size = new((int)(240.5*Globals.Settings.Scale), (int)(419*Globals.Settings.Scale));
Controls.Add(r=new Rectangle(Globals.LuskiTexture) { Location = new((int)(51.5 * Globals.Settings.Scale), (int)(4 * Globals.Settings.Scale)), Size = new((int)(138*Globals.Settings.Scale), (int)(144.5*Globals.Settings.Scale))});
Size = new((int)(312 * Globals.Settings.Scale), (int)(545 * Globals.Settings.Scale));
Rectangle tt;
Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))});
Label t;
Controls.Add(t=new Label() { Scale = 1.6f, Font = Globals.DefaultFont, Location = new((int)(85*Globals.Settings.Scale),(int)(153*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) });
Controls.Add(t=new Label() { Scale = 1.6f * (float)Globals.Settings.Scale, Font = Globals.DefaultFont, 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);
Controls.Add(Email = new Textbox() { WatermarkFont = Globals.DefaultFont, WatermarkText = "Email", Font = Globals.DefaultFont, Location = new((int)(20.5*Globals.Settings.Scale),(int)(215.5 * Globals.Settings.Scale)), Size = new((int)(200.5 * Globals.Settings.Scale),(int)(20.5 * Globals.Settings.Scale)), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan });
Controls.Add(Password = new Textbox() { WatermarkFont = Globals.DefaultFont, WatermarkText = "Password", Font = Globals.DefaultFont, PasswordChar = '●', Location = new((int)(20.5*Globals.Settings.Scale),(int)(281 * Globals.Settings.Scale)), Size = new((int)(200.5 * Globals.Settings.Scale), (int)(20.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Controls.Add(ca = new Label() { Font = Globals.DefaultFont, Location = new((int)(20.5*Globals.Settings.Scale),(int)(332 * Globals.Settings.Scale)), Text = "Create Account" });
Controls.Add(button = new() { Font = Globals.DefaultFont, Text = "Login", Location = new((int)(20.5*Globals.Settings.Scale), (int)(350 * Globals.Settings.Scale)), Size = new((int)(200.5 * Globals.Settings.Scale), (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y);
Controls.Add(Email = new Textbox() { TextLocation = TextLocation.TrueCenterLeft, WatermarkFont = Globals.DefaultFont, WatermarkText = "Email", Font = Globals.DefaultFont, 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(Password = new Textbox() { TextLocation = TextLocation.TrueCenterLeft, WatermarkFont = Globals.DefaultFont, WatermarkText = "Password", Font = Globals.DefaultFont, PasswordChar = '●', Location = new(Email.Location.X,(int)(365 * Globals.Settings.Scale)), Size = Email.Size, InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Controls.Add(ca = new Label() { Font = Globals.DefaultFont, Location = new(Email.Location.X,(int)(419 * Globals.Settings.Scale)), Text = "Create Account" });
Controls.Add(button = new() { Font = Globals.DefaultFont, Text = "Login", Location = new(Email.Location.X, (int)(455 * Globals.Settings.Scale)), Size = new(Email.Size.X,(int)(46 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Password.KeyPress += PasswordOnKeyPress;
Email.KeyPress += EmailOnKeyPress;
button.Clicked += ButtonOnClicked;
@ -71,7 +71,15 @@ public class Login : UserControl
}
catch (Exception e)
{
Console.WriteLine(e);
if (e.Message.Contains("Invaled Login"))
{
BlockDraw = true;
Password.BorderColor = Color4.DarkRed;
Email.BorderColor = Color4.DarkRed;
BlockDraw = false;
TryDraw();
}
else Console.WriteLine(e);
}
return Task.CompletedTask;
}

View File

@ -9,7 +9,7 @@ namespace Luski.GUI;
public class UpdateWindow : Window
{
private RoundedButton yes, no;
private RoundedButton? yes, no;
private static readonly NativeWindowSettings Settings = new()
{
Title = "Update Available",

View File

@ -1,40 +1,20 @@
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using GraphicsManager;
using GraphicsManager.Objects.Core;
using Luski.Clesses;
using Luski.GUI.MainScreen;
using Luski.net;
using Luski.net.Enums;
using OpenTK.Windowing.Common.Input;
namespace Luski;
public class Globals
{
public record Snowflake
{
public Snowflake(long ID)
{
this.ID = ID;
Increment = (ushort)((ID << 52) >> 52);
Worker_ID = (ushort)((ID << 47) >> 59);
Server_ID = (ushort)((ID << 42) >> 59);
Timestamp = ID >> 22;
}
public long ID { get; }
public long Timestamp { get; }
public ushort Worker_ID { get; }
public ushort Server_ID { get; }
public ushort Increment { get; }
private static ushort i = 0;
}
#pragma warning disable CS8618
public static bool Download { get; set; } = false;
public static Server Luski { get; set; } = null!;
public static MainScreen ms;
public static Settings Settings { get; set; }
public static Font DefaultFont { get; set; }
@ -48,23 +28,19 @@ public class Globals
if (!File.Exists(path))
{
@out = new();
Console.WriteLine("Overiding 1");
File.WriteAllText(path, JsonSerializer.Serialize(@out, TypeInfo));
}
try
{
@out = JsonSerializer.Deserialize(File.ReadAllText(path), TypeInfo);
Console.WriteLine("Found");
if (@out is null)
{
Console.WriteLine("Overiding 2");
@out = new();
}
}
catch
{
Console.WriteLine("Overiding 3");
@out = new();
}
File.WriteAllText(path, JsonSerializer.Serialize(@out, TypeInfo));
@ -102,3 +78,4 @@ public class Globals
return (string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str));
}
}
#pragma warning restore CS8618

View File

@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<FileVersion>1.0.1.2</FileVersion>
<FileVersion>1.1.0.0</FileVersion>
<Company>JacobTech, LLC</Company>
</PropertyGroup>
@ -14,8 +14,12 @@
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<NoWarn>1701;1702;IL2121;MSB3246</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.5-alpha08" />
<PackageReference Include="GraphicsManager" Version="1.0.5-alpha74" />
<PackageReference Include="Luski.net" Version="1.1.2-beta05" />
</ItemGroup>

View File

@ -1,27 +1,17 @@
using System.Diagnostics;
using System.Reflection;
using System.Security.Cryptography;
using Luski;
using Luski.Clesses;
using Luski.GUI.MainScreen;
using Luski.net;
using OpenTK.Windowing.Common.Input;
using SixLabors.ImageSharp.PixelFormats;
using Image = OpenTK.Windowing.Common.Input.Image;
try
{
Console.WriteLine(new Globals.Snowflake(6080823133885445424));
bool f = false;
bool t = true;
byte bf = Convert.ToByte(f);
byte bt = Convert.ToByte(t);
Console.WriteLine("{0} converted to {1}.", f, bf);
Console.WriteLine("{0} converted to {1}.", t, bt);
Globals.Settings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
Globals.UpdaterSettings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
Assembly assembly = Assembly.GetExecutingAssembly();
Stream? resource_stream = assembly.GetManifestResourceStream($"Luski.Resources.Textures.Luski.png");
MemoryStream ms = new();