Public Servers.
Added a bunch of controls to use in public servers.
This commit is contained in:
parent
d8657d103d
commit
c178ec62cf
19
Luski/Clesses/ServerInfo.cs
Normal file
19
Luski/Clesses/ServerInfo.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Luski.Clesses;
|
||||
|
||||
public class ServerInfo
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("domain")]
|
||||
public string Domain { get; set; } = default!;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; } = "v1";
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("is_main")]
|
||||
public bool Main { get; set; } = false;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("is_secure")]
|
||||
public bool Secure { get; set; } = true;
|
||||
}
|
30
Luski/Clesses/ServerList.cs
Normal file
30
Luski/Clesses/ServerList.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Luski.Clesses;
|
||||
|
||||
public class ServerList
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("servers")]
|
||||
public ServerInfo[] Server { get; set; } = new []
|
||||
{
|
||||
new ServerInfo()
|
||||
{
|
||||
Domain = "10.100.0.10:5287",
|
||||
Version = "v1",
|
||||
Main = false,
|
||||
Secure = false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(ServerList))]
|
||||
[JsonSourceGenerationOptions(
|
||||
GenerationMode = JsonSourceGenerationMode.Default,
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
|
||||
WriteIndented = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
|
||||
internal partial class ServerListContext : JsonSerializerContext
|
||||
{
|
||||
|
||||
}
|
@ -8,12 +8,6 @@ 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]
|
||||
|
@ -9,6 +9,7 @@ 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;
|
||||
@ -16,6 +17,7 @@ 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;
|
||||
@ -35,7 +37,7 @@ public class MainScreen : Window
|
||||
StartFocused = true,
|
||||
Size = new Vector2i((int)(312 * Globals.Settings.Scale), (int)(545 * Globals.Settings.Scale)),
|
||||
Icon = Globals.Icon,
|
||||
SharedContext = null
|
||||
SharedContext = null,
|
||||
};
|
||||
|
||||
public TabControl? tc;
|
||||
@ -61,53 +63,68 @@ public class MainScreen : Window
|
||||
|
||||
// The rest of the function is up to you to implement, however a debug output
|
||||
// is always useful.
|
||||
|
||||
switch (severity)
|
||||
|
||||
if (false)
|
||||
{
|
||||
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;
|
||||
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.DefaultFont =
|
||||
Font.MakeEmbeddedFont("Luski.Resources.Fonts.OpenSans-Regular.ttf", Assembly.GetExecutingAssembly());
|
||||
//Globals.DefaultFont = Font.MakeFontFromFile(@"C:\Users\techn\Downloads\tahoma.ttf");
|
||||
Globals.DefaultFontFamly = FontFamily.LoadFontFamily("Noto Sans").Result;
|
||||
Globals.DefaultFont = FontInteraction.Load(Globals.DefaultFontFamly);
|
||||
Globals.DefaultFont.PixelHeight = (uint)(20 * Globals.Settings.Scale);
|
||||
Globals.LuskiTexture = TextureManager.AddTexture(Tools.GetResourceBytes(Assembly.GetExecutingAssembly(),
|
||||
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);
|
||||
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.IsLogedIn) || !Globals.Luski.LoadedServers.Any(s => s.IsLogedIn))
|
||||
{
|
||||
Globals.Luski.MainServer.EncryptionHandler.GenerateKeys();
|
||||
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();
|
||||
});
|
||||
t.Start();
|
||||
|
||||
}
|
||||
WindowLoaded += OnWindowLoaded;
|
||||
}
|
||||
|
||||
@ -123,6 +140,9 @@ public class MainScreen : Window
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
if ((Globals.Luski.MainServer is not null && Globals.Luski.MainServer.IsLogedIn) || Globals.Luski.LoadedServers.Any(s => s.IsLogedIn)) Invoke(() => LoginOnChangeToApp());
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@ -235,133 +255,274 @@ public class MainScreen : Window
|
||||
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 = Color4.DarkRed
|
||||
};
|
||||
Controls.Add(SerBox);
|
||||
SerBox.LoadToParent(this, this);
|
||||
}
|
||||
|
||||
SerBox.Controls.Clear();
|
||||
#endregion
|
||||
|
||||
#region Channel Selector Init
|
||||
SocketChannel currentchannel = await Server.User.GetSelectedChannel(CancellationToken.None);
|
||||
List<SocketCategory> parents = new();
|
||||
SocketCategory? cur = await currentchannel.GetParent();
|
||||
while (cur is not null)
|
||||
{
|
||||
parents.Add(cur);
|
||||
cur = await cur.GetParent();
|
||||
}
|
||||
|
||||
private Task LoginOnChangeToApp()
|
||||
parents.Reverse();
|
||||
ChannelSelector cs = new(parents[0])
|
||||
{
|
||||
BackgroundColor = new(34, 34, 34, 255),
|
||||
Size = new((int)(307 * Globals.Settings.Scale), SerBox.Size.Y - 150),
|
||||
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
|
||||
};
|
||||
parents.RemoveAt(0);
|
||||
SerBox.Controls.Add(cs);
|
||||
cs.LoadToParent(SerBox, this);
|
||||
cs.ForceDistanceUpdate();
|
||||
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"));
|
||||
#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(currentchannel, 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";
|
||||
// string Public, Private;
|
||||
// using (RSACryptoServiceProvider cryptoServiceProvider = new RSACryptoServiceProvider(Encryption.NewKeySize))
|
||||
//{
|
||||
// Private = cryptoServiceProvider.ToXmlString(true);
|
||||
// Public = cryptoServiceProvider.ToXmlString(false);
|
||||
//}
|
||||
// Luski.net.Encryption.File.Channels.AddKey(69, Private);
|
||||
//Clip
|
||||
// Console.WriteLine(Public);
|
||||
//Globals.Luski.SetMultiThreadPercent(Globals.Settings.MultiThreadPercent);
|
||||
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);
|
||||
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.MainServer.User.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.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));
|
||||
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)(52 * Globals.Settings.Scale),(int)(868 * Globals.Settings.Scale)),
|
||||
Size = new((int)(68 * Globals.Settings.Scale), (int)(868 * Globals.Settings.Scale)),
|
||||
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom,
|
||||
|
||||
|
||||
});
|
||||
Controls.Add(tc = new()// this is here to showcase my good friend TCLL
|
||||
// PublicServer? SelectedPublicServer;
|
||||
DrawFrame();
|
||||
if (Globals.Luski.MainServer is not null)
|
||||
{
|
||||
Location = chat.Location,
|
||||
Size = chat.Size,
|
||||
BackgroundColor = chat.BackgroundColor,
|
||||
Anchor = ObjectAnchor.All,
|
||||
Visible = false,
|
||||
TitleFont = Globals.DefaultFont,
|
||||
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() { 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 (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())
|
||||
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);
|
||||
Label ul = new Label(Globals.DefaultFont)
|
||||
{
|
||||
chat.AddMessage(TextureManager, message);
|
||||
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);
|
||||
}
|
||||
chat.MessageFlow.ScrollToBottom();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
ChannelOnClickCon(chans.Where(s => s.Channel.Id == 0).First());
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
chat.MessageFlow.BlockDraw = false;
|
||||
|
||||
Console.WriteLine("Messages Fonts done in " + (DateTime.Now - start).TotalSeconds + " seconds");
|
||||
foreach (MainSocketRemoteUser cufr in Globals.Luski.MainServer.User.FriendRequests)
|
||||
foreach (PublicServer pser in Globals.Luski.LoadedServers)
|
||||
{
|
||||
AddFriendRequest(cufr);
|
||||
ser.Controls.Add(new ServerIcon<PublicServer>(pser));
|
||||
}
|
||||
Console.WriteLine("FR done in " + (DateTime.Now - start).TotalSeconds + " seconds");
|
||||
BlockDraw = false;
|
||||
DrawFrame();
|
||||
Console.WriteLine("GUI done in " + (DateTime.Now - start1).TotalSeconds + " seconds");
|
||||
|
||||
await (ser.Controls[0] as ServerIcon<PublicServer>)!.LoadServer();
|
||||
|
||||
MainShow += OnMainShow;
|
||||
MainShow.Invoke();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task OnMainShow()
|
||||
{
|
||||
Globals.Luski.MainServer.OnError += LuskiOnOnError;
|
||||
Globals.Luski.MainServer.UserStatusUpdate += LuskiOnUserStatusUpdate;
|
||||
Globals.Luski.MainServer.ReceivedFriendRequest += LuskiOnReceivedFriendRequest;
|
||||
Globals.Luski.MainServer.FriendRequestResult += LuskiOnFriendRequestResult;
|
||||
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;
|
||||
}
|
||||
|
||||
|
12
Luski/GUI/MainScreen/Interfaces/IChannelAdder.cs
Normal file
12
Luski/GUI/MainScreen/Interfaces/IChannelAdder.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Luski.GUI.MainScreen.UI.PublicServers;
|
||||
using Luski.net.Structures.Public;
|
||||
|
||||
namespace Luski.GUI.MainScreen.Interfaces;
|
||||
|
||||
public interface IChannelAdder
|
||||
{
|
||||
public bool Extended { get; set; }
|
||||
public SocketCategory CurrentCategory { get; }
|
||||
public Task<Channel> AddChannel(SocketChannel chan);
|
||||
public Task<Category> AddCategory(SocketCategory Cat, DateTime? dt = null);
|
||||
}
|
@ -17,7 +17,7 @@ public class AddFriendPage : FlowLayout
|
||||
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() { 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 });
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -35,16 +35,15 @@ public class Chat : UserControl
|
||||
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()
|
||||
titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
|
||||
{
|
||||
Font = Globals.DefaultFont, Location = new(
|
||||
(int)((26 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale),
|
||||
(int)((26 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight/2.0)))
|
||||
//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(){ Font = 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()
|
||||
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)
|
||||
{
|
||||
Font = Globals.DefaultFont,
|
||||
InsideColor = new(28, 28, 28, 255),
|
||||
BorderColor = Color4.DarkCyan,
|
||||
Location = new((int)(10 * Globals.Settings.Scale), (int)(824 * Globals.Settings.Scale)),
|
||||
@ -92,7 +91,7 @@ public class Chat : UserControl
|
||||
if (Channel is not null && Channel!.Id == channelPick.Channel.Id) return;
|
||||
Channel = channelPick.Channel;
|
||||
title.Text = channelPick.Channel.Title;
|
||||
tb.WatermarkFont = Globals.DefaultFont;
|
||||
//tb.WatermarkFont = Globals.DefaultFont;
|
||||
if (channelPick.Channel.Type == ChannelType.DM)
|
||||
title.Text = (channelPick.Channel as MainSocketDMChannel)!.User.DisplayName;
|
||||
tb.WatermarkText = "Message " + title.Text;
|
||||
|
@ -18,7 +18,7 @@ namespace Luski.GUI.MainScreen.UI;
|
||||
public class ChatMessage : UserControl
|
||||
{
|
||||
readonly int padding = 2;
|
||||
private static Font TimeFont = Font.MakeFontFromSystem(13);
|
||||
private static Font TimeFont;// = Font.MakeFontFromSystem(13);
|
||||
private MainSocketMessage Msg { get; }
|
||||
private Label label2, lastm;
|
||||
private static Dictionary<MainSocketRemoteUser, ContextMenu> Menues = new();
|
||||
@ -34,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.DisplayName});
|
||||
Controls.Add(label1 = new Label(Globals.DefaultFont) { Location = new((int)(54 * Globals.Settings.Scale), (int)(6 * Globals.Settings.Scale)), Text = user.DisplayName});
|
||||
|
||||
|
||||
|
||||
@ -52,15 +52,15 @@ public class ChatMessage : UserControl
|
||||
{
|
||||
timestr = $"{time:M/dd/yyyy h:mm tt}";
|
||||
}
|
||||
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(),
|
||||
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() { Font = Globals.DefaultFont, Location = new(label1.Location.X, (int)(label1.Location.Y + label1.Font.PixelHeight + (5 * Globals.Settings.Scale))), Text = message.Context});
|
||||
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)
|
||||
{
|
||||
@ -91,10 +91,10 @@ public class ChatMessage : UserControl
|
||||
{
|
||||
ContextMenu m = new((int)(150 * Globals.Settings.Scale));
|
||||
RoundedButton d;
|
||||
m.Items.Add(d = new RoundedButton()
|
||||
m.Items.Add(d = new RoundedButton(Globals.DefaultFont)
|
||||
{
|
||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
||||
Size = new((int)(25 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Add Friend"
|
||||
Size = new((int)(25 * Globals.Settings.Scale)), Text = "Add Friend"
|
||||
});
|
||||
d.Tag = this;
|
||||
Menues.Add(u,m);
|
||||
@ -133,9 +133,8 @@ public class ChatMessage : UserControl
|
||||
|
||||
public void AddMessage(MainSocketMessage msg)
|
||||
{
|
||||
Label newLabel = new()
|
||||
Label newLabel = new(Globals.DefaultFont)
|
||||
{
|
||||
Font = Globals.DefaultFont,
|
||||
Text = msg.Context,
|
||||
Tag = msg,
|
||||
Location = new(label2.Location.X, Size.Y)
|
||||
@ -189,11 +188,10 @@ public class ChatMessage : UserControl
|
||||
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()
|
||||
Label m = new(Globals.DefaultFont)
|
||||
{
|
||||
Font = TimeFont,
|
||||
Text = time.ToString("h:mm tt"),
|
||||
Location = new((int)(7.5 * Globals.Settings.Scale), label.Location.Y - (int)TimeFont.PixelHeight + (int)label.Font.PixelHeight),
|
||||
Location = new((int)(7.5 * Globals.Settings.Scale), label.Location.Y - 13 + (int)label.Font.PixelHeight),
|
||||
};
|
||||
|
||||
Controls.Add(m);
|
||||
|
@ -27,10 +27,10 @@ public class ContentEmbed : UserControl
|
||||
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)});
|
||||
Controls.Add(fileNameLabel = new Label() { Color = new(102/(float)255,227/(float)255,170/(float)255, 1), Text = file.Name, Location = new(64, 6)});
|
||||
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;
|
||||
byte[] tempp = Tools.GetResourceBytes(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Download.png");
|
||||
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;
|
||||
|
@ -34,11 +34,11 @@ public class Friend : UserControl, IChannelPick
|
||||
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.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))});
|
||||
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.GetResourceBytes(Assembly.GetExecutingAssembly(),
|
||||
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))
|
||||
@ -64,15 +64,15 @@ public class Friend : UserControl, IChannelPick
|
||||
this.Clicked += AllOnClicked;
|
||||
ContextMenu = new((int)(196 * Globals.Settings.Scale));
|
||||
RoundedButton rrr, rr2;
|
||||
ContextMenu.Items.Add(rrr=new()
|
||||
ContextMenu.Items.Add(rrr=new(Globals.DefaultFont)
|
||||
{
|
||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
||||
Size = new((int)(32 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Export Keys"
|
||||
Size = new((int)(32 * Globals.Settings.Scale)), Text = "Export Keys"
|
||||
});
|
||||
ContextMenu.Items.Add(rr2=new()
|
||||
ContextMenu.Items.Add(rr2=new(Globals.DefaultFont)
|
||||
{
|
||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
||||
Size = new((int)(32 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Open In New Window"
|
||||
Size = new((int)(32 * Globals.Settings.Scale)), Text = "Open In New Window"
|
||||
});
|
||||
rr2.Clicked += Rr2OnClicked;
|
||||
rrr.Clicked += RrOnClicked;
|
||||
|
@ -28,7 +28,7 @@ public class FriendRequest : UserControl
|
||||
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.GetResourceBytes(Assembly.GetExecutingAssembly(),
|
||||
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))
|
||||
@ -38,8 +38,8 @@ public class FriendRequest : UserControl
|
||||
t.Unit = TextureUnit.Texture1;
|
||||
rr.Textures.Add(t);
|
||||
rr.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
||||
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))});
|
||||
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()
|
||||
|
@ -21,7 +21,7 @@ public class Group : UserControl, IChannelPick
|
||||
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.GetResourceBytes(Assembly.GetExecutingAssembly(),
|
||||
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)),
|
||||
@ -34,13 +34,13 @@ public class Group : UserControl, IChannelPick
|
||||
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});
|
||||
Controls.Add(Username = new Label(Globals.DefaultFont) { Text = chan.Title});
|
||||
string sl = "Online";
|
||||
if (chan.Id != 0)
|
||||
{
|
||||
sl = chan.Members.Count + " Members";
|
||||
}
|
||||
Controls.Add(Status = new Label() { Scale = 0.7f, Font = Globals.DefaultFont, Text = sl, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(24 * Globals.Settings.Scale))});
|
||||
Controls.Add(Status = new Label(Globals.DefaultFont) { Scale = 0.7f, Text = sl, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(24 * Globals.Settings.Scale))});
|
||||
this.Clicked += AllOnClicked;
|
||||
Username.Location = new((int)(58 * Globals.Settings.Scale),
|
||||
(rr.Location.Y + (rr.Size.Y / 2) - ((Username.TrueHeight + 5 + Status.TrueHeight) / 2) -
|
||||
@ -50,10 +50,10 @@ public class Group : UserControl, IChannelPick
|
||||
if (chan.Id == 0) return;
|
||||
ContextMenu = new((int)(150 * Globals.Settings.Scale));
|
||||
RoundedButton rrr;
|
||||
ContextMenu.Items.Add(rrr=new()
|
||||
ContextMenu.Items.Add(rrr=new(Globals.DefaultFont)
|
||||
{
|
||||
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)(25 * Globals.Settings.Scale)), Text = "Export Keys"
|
||||
});
|
||||
rrr.Clicked += RrOnClicked;
|
||||
}
|
||||
|
203
Luski/GUI/MainScreen/UI/PublicServers/Category.cs
Normal file
203
Luski/GUI/MainScreen/UI/PublicServers/Category.cs
Normal file
@ -0,0 +1,203 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using Luski.GUI.MainScreen.Interfaces;
|
||||
using Luski.net.Structures.Public;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
||||
|
||||
public class Category : UserControl, IChannelAdder
|
||||
{
|
||||
public FlowLayout Members;
|
||||
public SocketCategory CurrentCategory { get; set; }
|
||||
private List<Category> cc = new();
|
||||
private List<Channel> cl = new();
|
||||
private Label ee;
|
||||
private ChannelSelector CS;
|
||||
|
||||
public event Func<int, Task>? AddY;
|
||||
|
||||
private Label Name;
|
||||
public UserControl tmp;
|
||||
|
||||
public static Task<Category> MakeCat(SocketCategory cat, ChannelSelector cs)
|
||||
{
|
||||
Category c = new();
|
||||
c.CurrentCategory = cat;
|
||||
c.CS = cs;
|
||||
c.Anchor = ObjectAnchor.All;
|
||||
c.Size = new((int)(307 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale));
|
||||
c.tmp = new()
|
||||
{
|
||||
Size = c.Size,
|
||||
Anchor = ObjectAnchor.Top | ObjectAnchor.Left
|
||||
};
|
||||
c.tmp.Clicked += c.TmpOnClicked;
|
||||
c.tmp.HoverMouse = MouseCursor.Hand;
|
||||
c.Controls.Add(c.tmp);
|
||||
c.tmp.Controls.Add(c.ee = new(Globals.DefaultFont)
|
||||
{
|
||||
Text = ">",
|
||||
Location = new((int)(5*Globals.Settings.Scale)),
|
||||
Color = cat.Color.ToColor4(),
|
||||
DIR = new(1,0)
|
||||
});
|
||||
c.tmp.Controls.Add(c.Name = new Label(Globals.DefaultFont)
|
||||
{
|
||||
Text = cat.Name,
|
||||
Color = c.ee.Color
|
||||
|
||||
});
|
||||
c.Clicked += c.AllOnClicked;
|
||||
c.Name.Location = new((int)(26 * Globals.Settings.Scale), ((c.Size.Y/2) - (c.Name.TrueHeight/ 2) - (c.Name.Size.Y - c.Name.TrueHeight)));
|
||||
c.Members = new()
|
||||
{
|
||||
Anchor = ObjectAnchor.All,
|
||||
Location = new((int)(20 * Globals.Settings.Scale), c.Size.Y)
|
||||
};
|
||||
c.ee.Location = new(c.ee.Location.X, c.Name.Location.Y);
|
||||
c.Members.Size = new(c.Size.X - c.Members.Location.X, 0);
|
||||
c.Controls.Add(c.Members);
|
||||
c.Members.ForceDistanceUpdate(c);
|
||||
c.tmp.HoverMouse = MouseCursor.Hand;
|
||||
return Task.FromResult(c);
|
||||
}
|
||||
|
||||
private Category()
|
||||
{
|
||||
}
|
||||
private async Task TmpOnClicked(IRenderObject arg)
|
||||
{
|
||||
BlockDraw = true;
|
||||
if (!Extended)
|
||||
{
|
||||
DateTime dt = DateTime.UtcNow;
|
||||
SocketChannel[] Channels = await CurrentCategory.GetChannels();
|
||||
Console.WriteLine(DateTime.UtcNow - dt);
|
||||
foreach (SocketChannel v in Channels)
|
||||
{
|
||||
Channel c = await AddChannel(v);
|
||||
c.LoadToParent(Members, Window!);
|
||||
_ = CatOnAddY(c.Size.Y);
|
||||
}
|
||||
Console.WriteLine(DateTime.UtcNow - dt);
|
||||
|
||||
SocketCategory[] cats = await CurrentCategory.GetCategories();
|
||||
Console.WriteLine(DateTime.UtcNow - dt);
|
||||
foreach (SocketCategory v in cats)
|
||||
{
|
||||
var c = await AddCategory(v, dt);
|
||||
c.LoadToParent(Members, Window!);
|
||||
_ = CatOnAddY(c.Size.Y);
|
||||
}
|
||||
Console.WriteLine(DateTime.UtcNow - dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AddY is not null) await AddY.Invoke(-Members.Size.Y);
|
||||
this.Size = new(this.Size.X, this.Size.Y -Members.Size.Y);
|
||||
Members.Size = new(Members.Size.X, 0);
|
||||
//Members.Controls.Clear(false);
|
||||
}
|
||||
|
||||
BlockDraw = false;
|
||||
|
||||
Extended = !Extended;
|
||||
|
||||
Window!.ForceUpdate(new(Window.Size));
|
||||
}
|
||||
|
||||
private bool e;
|
||||
public bool Extended
|
||||
{
|
||||
get => e;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
ee.DIR = new(0,1);
|
||||
ee.Location = new(ee.Location.X, (ee.Location.Y - ee.PostiveTrueHeight));
|
||||
}
|
||||
else
|
||||
{
|
||||
ee.DIR = new(1,0);
|
||||
ee.Location = new(ee.Location.X, (ee.Location.Y + ee.PostiveTrueHeight));
|
||||
}
|
||||
e = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Task AllOnClicked(IRenderObject arg)
|
||||
{
|
||||
if (ClickCon is not null) _ = ClickCon.Invoke(this);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public event Func<Category, Task>? ClickCon;
|
||||
|
||||
public async Task<Category> AddCategory(SocketCategory Cat, DateTime? dt = null)
|
||||
{
|
||||
if (dt is not null) Console.WriteLine("c: {0}",DateTime.UtcNow - dt);
|
||||
Category[] tc = cc.Where(s => s.CurrentCategory.ID == Cat.ID).ToArray();
|
||||
if (dt is not null) Console.WriteLine("c: {0}",DateTime.UtcNow - dt);
|
||||
if (tc.Length > 0)
|
||||
{
|
||||
if (dt is not null) Console.WriteLine("c: {0}",DateTime.UtcNow - dt);
|
||||
var cat2 = tc[0];
|
||||
if (!Members.Controls.Contains(cat2))
|
||||
{
|
||||
if (dt is not null) Console.WriteLine("c: {0}",DateTime.UtcNow - dt);
|
||||
Members.Controls.Add(cat2);
|
||||
if (dt is not null) Console.WriteLine("c: {0}",DateTime.UtcNow - dt);
|
||||
//Size = new(Size.X, Size.Y + cat2.Size.Y);
|
||||
_ = CatOnAddY(cat2.Size.Y);
|
||||
if (dt is not null) Console.WriteLine("c: {0}",DateTime.UtcNow - dt);
|
||||
if (AddY is not null) _ = AddY.Invoke(cat2.Size.Y);
|
||||
if (dt is not null) Console.WriteLine("c: {0}",DateTime.UtcNow - dt);
|
||||
}
|
||||
|
||||
return cat2;
|
||||
}
|
||||
var cat = await Category.MakeCat(Cat, CS);
|
||||
cc.Add(cat);
|
||||
Members.Controls.Add(cat);
|
||||
cat.Size = new(this.Size.X, cat.Size.Y);
|
||||
cat.Members.BackgroundColor = BackgroundColor;
|
||||
cat.BackgroundColor = BackgroundColor;
|
||||
cat.tmp.BackgroundColor = BackgroundColor;
|
||||
Size = new(Size.X, Size.Y + cat.Size.Y);
|
||||
cat.AddY += CatOnAddY;
|
||||
if (AddY is not null) await AddY.Invoke(cat.Size.Y);
|
||||
return cat;
|
||||
}
|
||||
|
||||
private async Task CatOnAddY(int arg)
|
||||
{
|
||||
this.Size = new(Size.X, Size.Y + arg);
|
||||
}
|
||||
|
||||
public async Task<Channel> AddChannel(SocketChannel chan)
|
||||
{
|
||||
Channel[] tc = cl.Where(s => s.CurrentChannel.ID == chan.ID).ToArray();
|
||||
if (tc.Length > 0)
|
||||
{
|
||||
Channel cat2 = tc[0];
|
||||
if (!Members.Controls.Contains(cat2))
|
||||
{
|
||||
Members.Controls.Add(cat2);
|
||||
Size = new(Size.X, Size.Y + cat2.Size.Y);
|
||||
if (AddY is not null) _ = AddY.Invoke(cat2.Size.Y);
|
||||
}
|
||||
|
||||
return cat2;
|
||||
}
|
||||
Channel cat = await Channel.MakeChannel(chan, CS);
|
||||
cl.Add(cat);
|
||||
cat.BackgroundColor = BackgroundColor;
|
||||
Size = new(Size.X, Size.Y + cat.Size.Y);
|
||||
Members.Controls.Add(cat);
|
||||
if (AddY is not null) await AddY.Invoke(cat.Size.Y);
|
||||
return cat;
|
||||
}
|
||||
}
|
183
Luski/GUI/MainScreen/UI/PublicServers/Channel.cs
Normal file
183
Luski/GUI/MainScreen/UI/PublicServers/Channel.cs
Normal file
@ -0,0 +1,183 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using Luski.net.Structures.Public;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
||||
|
||||
public class Channel : UserControl
|
||||
{
|
||||
private Rectangle SelectedRct, SelectedRctL, SelectedRctR;
|
||||
private ChannelSelector CS;
|
||||
public readonly static Texture[] SelectedTextures = new Texture[] {null!, null!, null!};
|
||||
|
||||
public SocketChannel CurrentChannel { get; set; }
|
||||
public new Color4 BackgroundColor
|
||||
{
|
||||
get => base.BackgroundColor;
|
||||
set
|
||||
{
|
||||
if (!Selected)
|
||||
{
|
||||
SelectedRct.BackgroundColor = value;
|
||||
SelectedRctL.BackgroundColor = value;
|
||||
SelectedRctR.BackgroundColor = value;
|
||||
}
|
||||
base.BackgroundColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Channel(Stream UserIcon, ChannelSelector cs, SocketChannel chan)
|
||||
{
|
||||
CS = cs;
|
||||
CurrentChannel = chan;
|
||||
Size = new((int)(307 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale));
|
||||
#region Selected Texture
|
||||
SelectedRct = new(SelectedTextures[1])
|
||||
{
|
||||
Location = new(Size.Y, 0),
|
||||
Size = new(Size.X - (Size.Y * 2), Size.Y),
|
||||
Anchor = ObjectAnchor.All,
|
||||
BackgroundColor = BackgroundColor,
|
||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||
Visible = true
|
||||
};
|
||||
Controls.Add(SelectedRct);
|
||||
SelectedRctL = new(SelectedTextures[0])
|
||||
{
|
||||
Location = new(0),
|
||||
Size = new(Size.Y),
|
||||
Anchor = ObjectAnchor.Left,
|
||||
BackgroundColor = SelectedRct.BackgroundColor,
|
||||
Shader = SelectedRct.Shader,
|
||||
Visible = true
|
||||
};
|
||||
Controls.Add(SelectedRctL);
|
||||
SelectedRctR = new(SelectedTextures[2])
|
||||
{
|
||||
Location = new(Size.X - Size.Y, 0),
|
||||
Size = SelectedRctL.Size,
|
||||
Anchor = ObjectAnchor.Right,
|
||||
BackgroundColor = SelectedRct.BackgroundColor,
|
||||
Shader = SelectedRct.Shader,
|
||||
Visible = true
|
||||
};
|
||||
Controls.Add(SelectedRctR);
|
||||
#endregion
|
||||
|
||||
r = new Rectangle(Globals.ms.TextureManager.GetAlphaCircle())
|
||||
{
|
||||
Location = new((int)(4 * Globals.Settings.Scale)),
|
||||
Size = new ((int)(32 * Globals.Settings.Scale))
|
||||
};
|
||||
Texture tex;
|
||||
tex = Globals.ms.TextureManager.AddTexture(UserIcon);
|
||||
GC.Collect();
|
||||
UserIcon.Dispose();
|
||||
tex.Unit = TextureUnit.Texture1;
|
||||
r.Textures.Add(tex);
|
||||
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
||||
Controls.Add(r);
|
||||
ChannelName = new Label(Globals.DefaultFont)
|
||||
{
|
||||
Text = chan.Name,
|
||||
Color = chan.Color.ToColor4()
|
||||
};
|
||||
Controls.Add(ChannelName);
|
||||
Clicked += AllOnClicked;
|
||||
ChannelName.Location = new((int)(40 * Globals.Settings.Scale),
|
||||
(Size.Y / 2) - ((int)ChannelName.Font.PixelHeight) + (ChannelName.PostiveTrueHeight / 2)
|
||||
);
|
||||
ContextMenu = new((int)(150 * Globals.Settings.Scale));
|
||||
RoundedButton ExportKeysButton, EdditChannelButton;
|
||||
ContextMenu.Items.Add(ExportKeysButton=new(Globals.DefaultFont)
|
||||
{
|
||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
||||
Size = new((int)(25 * Globals.Settings.Scale)), Text = "Export Keys"
|
||||
});
|
||||
ContextMenu.Items.Add(EdditChannelButton=new(Globals.DefaultFont)
|
||||
{
|
||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
||||
Size = new((int)(25 * Globals.Settings.Scale)), Text = "Edit Channel"
|
||||
});
|
||||
EdditChannelButton.Clicked += EditChannelButtonOnClicked;
|
||||
ExportKeysButton.Clicked += ExportKeysButtonOnClicked;
|
||||
HoverMouse = MouseCursor.Hand;
|
||||
}
|
||||
|
||||
public bool Selected { get; private set; }
|
||||
|
||||
public async Task ToggleSelected()
|
||||
{
|
||||
try
|
||||
{
|
||||
Color4 bc = new(141,151,165,51);
|
||||
if (Selected)
|
||||
{
|
||||
bc = BackgroundColor;
|
||||
}
|
||||
|
||||
BlockDraw = true;
|
||||
Selected = !Selected;
|
||||
|
||||
if (CS.Selected is not null && CS.Selected != this)
|
||||
{
|
||||
await CS.Selected.ToggleSelected();
|
||||
}
|
||||
|
||||
if (Selected)
|
||||
{
|
||||
CS.Selected = this;
|
||||
IReadOnlyList<SocketMessage> m;
|
||||
m = await CurrentChannel.GetMessages(CancellationToken.None, 200);
|
||||
//m = Array.Empty<SocketMessage>();
|
||||
Globals.ms.pc.ClearChat();
|
||||
await Globals.ms.pc.LoadChannel(CurrentChannel);
|
||||
_ = Globals.ms.pc.AddMessages(m);
|
||||
if (m.Count > 0)Globals.ms.pc.MessageFlow.ScrollToBottom();
|
||||
}
|
||||
SelectedRct.BackgroundColor = bc;
|
||||
SelectedRctL.BackgroundColor = bc;
|
||||
BlockDraw = false;
|
||||
SelectedRctR.BackgroundColor = bc;
|
||||
TryDraw();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
public Label ChannelName;
|
||||
public Rectangle r;
|
||||
|
||||
public static async Task<Channel> MakeChannel(SocketChannel chan, ChannelSelector cs)
|
||||
{
|
||||
Channel c = new(await chan.GetPicture(CancellationToken.None), cs, chan);
|
||||
return c;
|
||||
}
|
||||
|
||||
private Task EditChannelButtonOnClicked(IRenderObject arg)
|
||||
{
|
||||
arg.ContextMenu!.HideContext(Window!);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task ExportKeysButtonOnClicked(IRenderObject arg)
|
||||
{
|
||||
//_ = CurrentChannel.SendKeysToUsers(CancellationToken.None);
|
||||
ContextMenu!.HideContext(Window!);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task AllOnClicked(IRenderObject arg)
|
||||
{
|
||||
if (!Selected) await ToggleSelected();
|
||||
//if (ClickCon is not null) _ = ClickCon.Invoke(this);
|
||||
}
|
||||
|
||||
//public event Func<Channel, Task>? ClickCon;
|
||||
}
|