dev #17

Merged
JacobTech merged 29 commits from dev into main 2024-04-11 15:50:14 -04:00
17 changed files with 128 additions and 117 deletions
Showing only changes of commit d8657d103d - Show all commits

View File

@ -8,6 +8,12 @@ public class Settings
[JsonPropertyName("scale")]
public double Scale { get; set; } = 1;
[JsonInclude]
[JsonPropertyName("api_domain")]
public string Domain { get; set; } = "api.beta.luski.jacobtech.com";
[JsonInclude]
[JsonPropertyName("api_v")]
public string Version { get; set; } = "v1";
[JsonInclude]
[JsonPropertyName("perscrollpixels")]
public uint PerScrollPixels { get; set; } = 20;
[JsonInclude]

View File

@ -15,7 +15,7 @@ public class UpdaterSettings
[JsonInclude]
[JsonPropertyName("branch")]
public Branch Branch { get; set; } = Branch.Beta;
public string Branch { get; set; } = "beta";
[JsonInclude]
[JsonPropertyName("platform")]

View File

@ -6,13 +6,16 @@ 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.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 OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Desktop;
@ -101,8 +104,8 @@ public class MainScreen : Window
Thread t = new(_ =>
{
Encryption.GenerateKeys();
Globals.Luski.MainServer.EncryptionHandler.GenerateKeys();
});
t.Start();
WindowLoaded += OnWindowLoaded;
@ -131,7 +134,7 @@ public class MainScreen : Window
return Task.CompletedTask;
}
public void AddGroup(SocketGroupChannel group)
public void AddGroup(MainSocketGroupChannel group)
{
Group friend = new(group);
friend.ClickCon += ChannelOnClickCon;
@ -143,20 +146,20 @@ public class MainScreen : Window
private List<IChannelPick> chans = new();
private Dictionary<long, int> FR_Index = new();
public void AddFriendRequest(SocketRemoteUser user)
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(SocketRemoteUser user)
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(SocketRemoteUser user)
public void AddFriend(MainSocketRemoteUser user)
{
Friend friend2 = new(user);
friend2.ClickCon += ChannelOnClickCon;
@ -202,16 +205,14 @@ public class MainScreen : Window
channelCancellationToken.Cancel(false);
}
channelCancellationToken = new CancellationTokenSource();
Globals.Luski.ChangeChannel(arg.Channel.Id, channelCancellationToken.Token, Globals.Luski.CurrentUser.Servers.First()).Wait();
//Globals.Luski.ChangeChannel(arg.Channel.Id, channelCancellationToken.Token).Wait();
Invoke(new Action(() =>
{
chat!.Clear();
}));
IReadOnlyList<SocketMessage> messages = arg.Channel.GetMessages(channelCancellationToken.Token, Globals.Settings.LoadPerChannel).Result;
IReadOnlyList<MainSocketMessage> messages = arg.Channel.GetMessages(channelCancellationToken.Token, Globals.Settings.LoadPerChannel).Result;
foreach (SocketMessage message in messages.Reverse())
foreach (MainSocketMessage message in messages.Reverse())
{
if (channelCancellationToken is null || channelCancellationToken.Token.IsCancellationRequested) return;
Invoke(new Action(() =>
@ -249,7 +250,7 @@ public class MainScreen : Window
// Luski.net.Encryption.File.Channels.AddKey(69, Private);
//Clip
// Console.WriteLine(Public);
Globals.Luski.SetMultiThreadPercent(Globals.Settings.MultiThreadPercent);
//Globals.Luski.SetMultiThreadPercent(Globals.Settings.MultiThreadPercent);
Size = new((int)(1332 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale));
DateTime start = DateTime.Now;
CenterWindow(0);
@ -258,18 +259,12 @@ public class MainScreen : Window
BackgroundColor = new Color4(34, 34, 34, 255);
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, Globals.Luski.CurrentUser.Servers.First()).Result);
Texture uut = TextureManager.AddTexture(Globals.Luski.MainServer.User.GetAvatar(CancellationToken.None).Result);
uut.Unit = TextureUnit.Texture1;
u.Shader = Rectangle.DefaultAlphaTextureShader[Context];
u.Textures.Add(uut);
Controls.Add(u);
Globals.Luski.CurrentUser.AddServer(SocketServer.GetServer("TCLL.LuskiServers.JacobTech.com"));
foreach (SocketServer Server in Globals.Luski.CurrentUser.Servers)
{
Console.WriteLine("Loading Server: {0}", Server.Domain);
//add server to UI
}
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};
Label ul = new Label(){ Font = Globals.DefaultFont, Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Location = new(0, (int)(826 * Globals.Settings.Scale)), Text = Globals.Luski.MainServer.User.DisplayName };
FlowLayout ser;
ul.Location = new((int)(112 * Globals.Settings.Scale),
(u.Location.Y + (u.Size.Y/2) - (ul.PostiveTrueHeight/2) - ul.Size.Y + ul.TrueHeight));
@ -316,24 +311,24 @@ public class MainScreen : Window
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>())
foreach (MainSocketGroupChannel ch in Globals.Luski.MainServer.User.Channels.Where(s => s is MainSocketGroupChannel).Cast<MainSocketGroupChannel>())
{
AddGroup(ch);
}
foreach (SocketRemoteUser item in Globals.Luski.CurrentUser.Friends)
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");
SocketTextChannel chan = Globals.Luski.GetChannel<SocketTextChannel>(Globals.Luski.CurrentUser.SelectedChannel, CancellationToken.None, Globals.Luski.CurrentUser.Servers.First()).Result;
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<SocketMessage> messages = chan.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel).Result;
IReadOnlyList<MainSocketMessage> messages = chan.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel).Result;
Console.WriteLine("Messages done in " + (DateTime.Now - start).TotalSeconds + " seconds");
foreach (SocketMessage message in messages.Reverse())
foreach (MainSocketMessage message in messages.Reverse())
{
chat.AddMessage(TextureManager, message);
}
@ -348,7 +343,7 @@ public class MainScreen : Window
chat.MessageFlow.BlockDraw = false;
Console.WriteLine("Messages Fonts done in " + (DateTime.Now - start).TotalSeconds + " seconds");
foreach (SocketRemoteUser cufr in Globals.Luski.CurrentUser.FriendRequests)
foreach (MainSocketRemoteUser cufr in Globals.Luski.MainServer.User.FriendRequests)
{
AddFriendRequest(cufr);
}
@ -363,10 +358,10 @@ public class MainScreen : Window
private Task OnMainShow()
{
Globals.Luski.OnError += LuskiOnOnError;
Globals.Luski.UserStatusUpdate += LuskiOnUserStatusUpdate;
Globals.Luski.ReceivedFriendRequest += LuskiOnReceivedFriendRequest;
Globals.Luski.FriendRequestResult += LuskiOnFriendRequestResult;
Globals.Luski.MainServer.OnError += LuskiOnOnError;
Globals.Luski.MainServer.UserStatusUpdate += LuskiOnUserStatusUpdate;
Globals.Luski.MainServer.ReceivedFriendRequest += LuskiOnReceivedFriendRequest;
Globals.Luski.MainServer.FriendRequestResult += LuskiOnFriendRequestResult;
return Task.CompletedTask;
}
@ -378,7 +373,7 @@ public class MainScreen : Window
return Task.CompletedTask;
}
private Task LuskiOnFriendRequestResult(SocketRemoteUser arg1, bool arg2)
private Task LuskiOnFriendRequestResult(MainSocketRemoteUser arg1, bool arg2)
{
Console.WriteLine("new result");
Invoke(new Action(() =>
@ -389,7 +384,7 @@ public class MainScreen : Window
return Task.CompletedTask;
}
private Task LuskiOnReceivedFriendRequest(SocketRemoteUser arg)
private Task LuskiOnReceivedFriendRequest(MainSocketRemoteUser arg)
{
Invoke(new Action(() =>
{
@ -402,7 +397,7 @@ public class MainScreen : Window
{
Console.WriteLine(before);
Console.WriteLine(After);
if (before is not SocketRemoteUser Before || Before.FriendStatus != FriendStatus.Friends || Before.Id == 0) return Task.CompletedTask;
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(() =>

View File

@ -1,8 +1,8 @@
using Luski.net.JsonTypes;
using Luski.net.Structures.Main;
namespace Luski.GUI.MainScreen.Interfaces;
public interface IChannelPick
{
public SocketTextChannel Channel { get; }
public MainSocketTextChannel Channel { get; }
}

View File

@ -1,6 +1,6 @@
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using Luski.net.JsonTypes;
using Luski.net.Structures.Main;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.GraphicsLibraryFramework;
@ -31,15 +31,15 @@ public class AddFriendPage : FlowLayout
Input.BorderColor = Color4.Red;
return Task.CompletedTask;
}
SocketRemoteUser? result = Globals.Luski.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);
}
// 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

@ -5,7 +5,9 @@ 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;
@ -17,7 +19,7 @@ public class Chat : UserControl
public FlowLayout MessageFlow;
private Label title, desc;
private Textbox tb;
private SocketTextChannel? Channel;
private MainSocketTextChannel? Channel;
public Chat()
{
UserControl titlecon;
@ -50,7 +52,7 @@ public class Chat : UserControl
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right
});
tb.KeyPress += TbOnKeyPress;
Globals.Luski.MessageReceived += LuskiOnMessageReceived;
Globals.Luski.MainServer.MessageReceived += LuskiOnMessageReceived;
}
private Task TbOnKeyPress(KeyboardKeyEventArgs arg)
@ -63,11 +65,11 @@ public class Chat : UserControl
private void Thr()
{
Globals.Luski.SendMessage(tb.Text, Channel!.Id, Globals.Luski.CurrentUser.Servers.First(), CancellationToken.None);
//Globals.Luski.MainServer.SendMessage(tb.Text, Channel!.Id, CancellationToken.None);
Window!.Invoke(() => { tb.Text = string.Empty; });
}
private Task LuskiOnMessageReceived(SocketMessage arg)
private Task LuskiOnMessageReceived(MainSocketMessage arg)
{
if (Channel!.Id != arg.ChannelID) return Task.CompletedTask;
IRenderObject? reff = null;
@ -92,7 +94,7 @@ public class Chat : UserControl
title.Text = channelPick.Channel.Title;
tb.WatermarkFont = Globals.DefaultFont;
if (channelPick.Channel.Type == ChannelType.DM)
title.Text = (channelPick.Channel as SocketDMChannel)!.User.Username;
title.Text = (channelPick.Channel as MainSocketDMChannel)!.User.DisplayName;
tb.WatermarkText = "Message " + title.Text;
if (channelPick.Channel.Description is not null)
{
@ -106,11 +108,11 @@ public class Chat : UserControl
}
}
private SocketMessage? lastm;
private MainSocketMessage? lastm;
private long? lastUser;
private ChatMessage? LastChatMessage;
public void AddMessage(TextureManager m, SocketMessage Message)
public void AddMessage(TextureManager m, MainSocketMessage Message)
{
bool hasbeentenmin = false;
if (lastm is not null)

View File

@ -6,8 +6,10 @@ 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;
@ -17,12 +19,12 @@ public class ChatMessage : UserControl
{
readonly int padding = 2;
private static Font TimeFont = Font.MakeFontFromSystem(13);
private SocketMessage Msg { get; }
private MainSocketMessage Msg { get; }
private Label label2, lastm;
private static Dictionary<SocketRemoteUser, ContextMenu> Menues = new();
private static Dictionary<SocketRemoteUser, List<ChatMessage>> Messages = new();
private static Dictionary<MainSocketRemoteUser, ContextMenu> Menues = new();
private static Dictionary<MainSocketRemoteUser, List<ChatMessage>> Messages = new();
public ChatMessage(TextureManager tm, SocketMessage message)
public ChatMessage(TextureManager tm, MainSocketMessage message)
{
Label label1;
Size = new((int)(723.5 * Globals.Settings.Scale), (int)(37 * Globals.Settings.Scale));
@ -32,7 +34,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)(54 * Globals.Settings.Scale), (int)(6 * 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.DisplayName});
@ -53,7 +55,7 @@ public class ChatMessage : UserControl
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, Globals.Luski.CurrentUser.Servers.First()).Result);
Texture tex = tm.AddTexture(user.GetAvatar(CancellationToken.None).Result);
tex.Unit = TextureUnit.Texture1;
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
r.Textures.Add(tex);
@ -82,7 +84,7 @@ public class ChatMessage : UserControl
}
}
if (user is SocketRemoteUser u && u.FriendStatus == FriendStatus.NotFriends)
if (user is MainSocketRemoteUser u && u.FriendStatus == FriendStatus.NotFriends)
{
Tag = u;
if (!Menues.ContainsKey(u))
@ -107,7 +109,7 @@ public class ChatMessage : UserControl
private Task DOnClicked(IRenderObject arg)
{
if (arg.Tag is ChatMessage u && u.Tag is SocketRemoteUser uu)
if (arg.Tag is ChatMessage u && u.Tag is MainSocketRemoteUser uu)
{
foreach (ChatMessage cm in Messages[uu])
{
@ -118,18 +120,18 @@ public class ChatMessage : UserControl
Messages.Remove(uu);
Menues.Remove(uu);
SocketRemoteUser result = Globals.Luski
.SendFriendRequest(long.Parse(uu.friend_codes.First()), CancellationToken.None).Result;
if (result.Channel is null)
Globals.ms.AddFriendRequest(result);
else
Globals.ms.AddFriend(result);
// 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(SocketMessage msg)
public void AddMessage(MainSocketMessage msg)
{
Label newLabel = new()
{
@ -169,7 +171,7 @@ public class ChatMessage : UserControl
private Task NewLabel_MouseLeave(IRenderObject sender)
{
if (sender is not Label label) return Task.CompletedTask;
if (label.Tag is not SocketMessage Message) 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();
@ -185,7 +187,7 @@ public class ChatMessage : UserControl
private Task NewLabel_MouseEnter(IRenderObject sender)
{
if (sender is not Label label) return Task.CompletedTask;
if (label.Tag is not SocketMessage Message) 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()
{

View File

@ -2,7 +2,7 @@ using System.Reflection;
using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using File = Luski.net.JsonTypes.File;
using File = Luski.net.Structures.File;
namespace Luski.GUI.MainScreen.UI;

View File

@ -8,6 +8,7 @@ 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;
@ -16,9 +17,9 @@ namespace Luski.GUI.MainScreen.UI;
public class Friend : UserControl, IChannelPick
{
public SocketRemoteUser User;
public MainSocketRemoteUser User;
public SocketTextChannel Channel
public MainSocketTextChannel Channel
{
get
{
@ -27,13 +28,13 @@ public class Friend : UserControl, IChannelPick
}
public Rectangle r, rr;
public Label Username, Status;
public Friend(SocketRemoteUser person)
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() { Font = Globals.DefaultFont, Text = person.Username, Location = new((int)(58 * Globals.Settings.Scale),(int)(14 * Globals.Settings.Scale))});
Controls.Add(Username = new Label() { Font = Globals.DefaultFont, Text = person.DisplayName, 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))});
@ -55,7 +56,7 @@ public class Friend : UserControl, IChannelPick
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, Globals.Luski.CurrentUser.Servers.First()).Result);
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];

View File

@ -6,7 +6,9 @@ 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;
@ -15,10 +17,10 @@ namespace Luski.GUI.MainScreen.UI;
public class FriendRequest : UserControl
{
private MainScreen Screen;
public SocketRemoteUser User;
public MainSocketRemoteUser User;
public Rectangle? Accept, Reject;
public FriendRequest(MainScreen Parent, SocketRemoteUser User)
public FriendRequest(MainScreen Parent, MainSocketRemoteUser User)
{
this.User = User;
this.Screen = Parent;
@ -32,11 +34,11 @@ public class FriendRequest : UserControl
Size = new ((int)(42 * Globals.Settings.Scale))
});
rr.BackgroundColor = BackgroundColor;
Texture t = Globals.ms.TextureManager.AddTexture(User.GetAvatar(CancellationToken.None, Globals.Luski.CurrentUser.Servers.First()).Result);
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.DisplayName, 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)
{
@ -57,14 +59,14 @@ public class FriendRequest : UserControl
private Task RejectOnClicked(IRenderObject arg)
{
_ = Globals.Luski.SendFriendResult(User.Id, false, CancellationToken.None).Result;
//_ = 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.AddFriend(Globals.Luski.SendFriendResult(User.Id, true, CancellationToken.None).Result);
Screen.RemoveFriendRequest(User);
return Task.CompletedTask;
}

View File

@ -3,8 +3,8 @@ using GraphicsManager;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net.JsonTypes;
using Luski.GUI.MainScreen.Interfaces;
using Luski.net.Structures.Main;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
@ -12,9 +12,9 @@ namespace Luski.GUI.MainScreen.UI;
public class Group : UserControl, IChannelPick
{
public SocketTextChannel Channel { get; set; }
public MainSocketTextChannel Channel { get; set; }
// private string members = "";
public Group(SocketGroupChannel chan)
public Group(MainSocketGroupChannel chan)
{
Label Status, Username;
Rectangle r, rr;

View File

@ -15,7 +15,7 @@ namespace Luski.GUI.StartPage.UI;
public class CreateAccount : UserControl
{
private RoundedButton button;
private Textbox Password, Email, Username;
private Textbox Password, UsernameTextbox, DisplaynameTextBox;
private Rectangle rec;
private string? pfp;
@ -30,23 +30,23 @@ public class CreateAccount : UserControl
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);
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(UsernameTextbox = new Textbox() { TextLocation = TextLocation.TrueCenterLeft, WatermarkFont = Globals.DefaultFont, WatermarkText = "Username", 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(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(DisplaynameTextBox = new Textbox() { TextLocation = TextLocation.TrueCenterLeft, WatermarkFont = Globals.DefaultFont, WatermarkText = "Displayname", Font = Globals.DefaultFont, 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(button = new() { Font = 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(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;
UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress;
button.Clicked += ButtonOnClicked;
Username.KeyPress += UsernameOnKeyPress;
DisplaynameTextBox.KeyPress += DisplaynameTextBoxOnKeyPress;
rec.FilesDroped += RecOnFilesDroped;
}
private Task UsernameOnKeyPress(KeyboardKeyEventArgs arg)
private Task DisplaynameTextBoxOnKeyPress(KeyboardKeyEventArgs arg)
{
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter && arg.Key != Keys.Tab) return Task.CompletedTask;
if (arg.Key == Keys.Tab && arg.Shift) { Password.Focus(); return Task.CompletedTask; }
if (arg.Key == Keys.Enter || arg.Key == Keys.KeyPadEnter) ButtonOnClicked(Username);
if (arg.Key == Keys.Enter || arg.Key == Keys.KeyPadEnter) ButtonOnClicked(DisplaynameTextBox);
return Task.CompletedTask;
}
@ -79,7 +79,7 @@ public class CreateAccount : UserControl
}
private bool tab;
private Task EmailOnKeyPress(KeyboardKeyEventArgs arg)
private Task UsernameTextboxOnKeyPress(KeyboardKeyEventArgs arg)
{
if (arg.Key != Keys.Tab) return Task.CompletedTask;
if (arg.Key == Keys.Tab){ Password.Focus(); tab = true;}
@ -94,8 +94,8 @@ public class CreateAccount : UserControl
return Task.CompletedTask;
};
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter && arg.Key != Keys.Tab) return Task.CompletedTask;
if (arg.Key == Keys.Tab && arg.Shift) { Email.Focus(); return Task.CompletedTask; }
if (arg.Key == Keys.Tab ){ Username.Focus(); return Task.CompletedTask; }
if (arg.Key == Keys.Tab && arg.Shift) { UsernameTextbox.Focus(); return Task.CompletedTask; }
if (arg.Key == Keys.Tab ){ DisplaynameTextBox.Focus(); return Task.CompletedTask; }
return Task.CompletedTask;
}
@ -105,13 +105,13 @@ public class CreateAccount : UserControl
{
string[] arr = new string[]
{
Email.Text,
UsernameTextbox.Text,
Password.Text,
Username.Text,
DisplaynameTextBox.Text,
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);
Globals.Luski.MainServer.CreateAccount(UsernameTextbox.Text, Password.Text, DisplaynameTextBox.Text, pfp!, CancellationToken.None);
ChangeToApp!.Invoke();
}
catch (Exception e)

View File

@ -11,7 +11,7 @@ namespace Luski.GUI.StartPage.UI;
public class Login : UserControl
{
private RoundedButton button;
private Textbox Password, Email;
private Textbox Password, UsernameTextbox;
private Label ca;
public event Func<Task>? ChangeToApp;
public event Func<Task>? ChangeToCa;
@ -24,12 +24,12 @@ public class Login : UserControl
Controls.Add(t=new Label() { Scale = 1.6f, 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);
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 });
Controls.Add(UsernameTextbox = new Textbox() { TextLocation = TextLocation.TrueCenterLeft, WatermarkFont = Globals.DefaultFont, WatermarkText = "Username", 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(UsernameTextbox.Location.X,(int)(365 * Globals.Settings.Scale)), Size = UsernameTextbox.Size, InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
Controls.Add(ca = new Label() { Font = Globals.DefaultFont, Location = new(UsernameTextbox.Location.X,(int)(419 * Globals.Settings.Scale)), Text = "Create Account" });
Controls.Add(button = new() { Font = 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 });
Password.KeyPress += PasswordOnKeyPress;
Email.KeyPress += EmailOnKeyPress;
UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress;
button.Clicked += ButtonOnClicked;
ca.Clicked += CaOnClicked;
this.WindowLoaded += OnWindowLoaded;
@ -37,7 +37,7 @@ public class Login : UserControl
private Task OnWindowLoaded(IRenderObject arg)
{
Email.Focus();
UsernameTextbox.Focus();
return Task.CompletedTask;
}
@ -47,7 +47,7 @@ public class Login : UserControl
return Task.CompletedTask;
}
private Task EmailOnKeyPress(KeyboardKeyEventArgs arg)
private Task UsernameTextboxOnKeyPress(KeyboardKeyEventArgs arg)
{
if (arg.Key != Keys.Tab) return Task.CompletedTask;
Password.Focus();
@ -57,7 +57,7 @@ public class Login : UserControl
private Task PasswordOnKeyPress(KeyboardKeyEventArgs arg)
{
if (arg.Key != Keys.Enter && arg.Key != Keys.KeyPadEnter && arg.Key != Keys.Tab) return Task.CompletedTask;
if (arg.Key == Keys.Tab && arg.Shift) Email.Focus();
if (arg.Key == Keys.Tab && arg.Shift) UsernameTextbox.Focus();
if (arg.Key != Keys.Tab ) ButtonOnClicked(Password);
return Task.CompletedTask;
}
@ -66,7 +66,7 @@ public class Login : UserControl
{
try
{
Globals.Luski = Server.Login(Email.Text, Password.Text, CancellationToken.None, Globals.UpdaterSettings.Branch).Result;
Globals.Luski.MainServer.Login(UsernameTextbox.Text, Password.Text, CancellationToken.None);
ChangeToApp!.Invoke();
}
catch (Exception e)
@ -75,7 +75,7 @@ public class Login : UserControl
{
BlockDraw = true;
Password.BorderColor = Color4.DarkRed;
Email.BorderColor = Color4.DarkRed;
UsernameTextbox.BorderColor = Color4.DarkRed;
BlockDraw = false;
TryDraw();
}

View File

@ -2,7 +2,7 @@ using GraphicsManager;
using GraphicsManager.Enums;
using Luski.GUI.MainScreen.Interfaces;
using Luski.GUI.MainScreen.UI;
using Luski.net.JsonTypes;
using Luski.net.Structures.Main;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
@ -33,9 +33,9 @@ public class ChatWindow : Window
Anchor = ObjectAnchor.All
});
c.UpdateTitle(pick);
IReadOnlyList<SocketMessage> messages = pick.Channel.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel).Result;
IReadOnlyList<MainSocketMessage> messages = pick.Channel.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel).Result;
foreach (SocketMessage message in messages.Reverse())
foreach (MainSocketMessage message in messages.Reverse())
{
c!.AddMessage(TextureManager, message);
}

View File

@ -12,7 +12,7 @@ public class Globals
{
#pragma warning disable CS8618
public static bool Download { get; set; } = false;
public static Server Luski { get; set; } = null!;
public static API Luski { get; } = new();
public static MainScreen ms;
public static Settings Settings { get; set; }

View File

@ -20,7 +20,7 @@
<ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.5-alpha74" />
<PackageReference Include="Luski.net" Version="1.1.3-alpha23" />
<PackageReference Include="Luski.net" Version="1.1.3-alpha25" />
</ItemGroup>
<ItemGroup>

View File

@ -11,6 +11,10 @@ using Image = OpenTK.Windowing.Common.Input.Image;
try
{
Globals.Settings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
_ = Globals.Luski.GetMainServer(Globals.Settings.Domain, Globals.Settings.Version);
_ = Globals.Luski.GetPublicServer("TCLL.Luski.JacobTech.com", Globals.Settings.Version);
Console.WriteLine("Conecting to main server '{0}' using API {1}", Globals.Luski.MainServer.Domain, Globals.Luski.MainServer.ApiVersion);
Console.WriteLine("Conecting to public server '{0}' using API {1}", Globals.Luski.LoadedServers.First().Domain, Globals.Luski.LoadedServers.First().ApiVersion);
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");
@ -18,7 +22,6 @@ try
resource_stream?.CopyTo(ms);
var Logo = SixLabors.ImageSharp.Image.Load<Rgba32>(ms.ToArray());
//List<byte> pixels = new List<byte>(4 * Logo.Width * Logo.Height);
Span<byte> pixels = new byte[4 * Logo.Width * Logo.Height].AsSpan();
Logo.CopyPixelDataTo(pixels);