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")]
|
[JsonPropertyName("scale")]
|
||||||
public double Scale { get; set; } = 1;
|
public double Scale { get; set; } = 1;
|
||||||
[JsonInclude]
|
[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")]
|
[JsonPropertyName("perscrollpixels")]
|
||||||
public uint PerScrollPixels { get; set; } = 20;
|
public uint PerScrollPixels { get; set; } = 20;
|
||||||
[JsonInclude]
|
[JsonInclude]
|
||||||
|
@ -9,6 +9,7 @@ using GraphicsManager.Objects.Core;
|
|||||||
using JacobTechEncryption;
|
using JacobTechEncryption;
|
||||||
using Luski.GUI.MainScreen.Interfaces;
|
using Luski.GUI.MainScreen.Interfaces;
|
||||||
using Luski.GUI.MainScreen.UI;
|
using Luski.GUI.MainScreen.UI;
|
||||||
|
using Luski.GUI.MainScreen.UI.PublicServers;
|
||||||
using Luski.GUI.StartPage.UI;
|
using Luski.GUI.StartPage.UI;
|
||||||
using Luski.net;
|
using Luski.net;
|
||||||
using Luski.net.Enums;
|
using Luski.net.Enums;
|
||||||
@ -16,6 +17,7 @@ using Luski.net.Enums.Main;
|
|||||||
using Luski.net.Interfaces;
|
using Luski.net.Interfaces;
|
||||||
using Luski.net.JsonTypes;
|
using Luski.net.JsonTypes;
|
||||||
using Luski.net.Structures.Main;
|
using Luski.net.Structures.Main;
|
||||||
|
using Luski.net.Structures.Public;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using OpenTK.Windowing.Desktop;
|
using OpenTK.Windowing.Desktop;
|
||||||
@ -35,7 +37,7 @@ public class MainScreen : Window
|
|||||||
StartFocused = true,
|
StartFocused = true,
|
||||||
Size = new Vector2i((int)(312 * Globals.Settings.Scale), (int)(545 * Globals.Settings.Scale)),
|
Size = new Vector2i((int)(312 * Globals.Settings.Scale), (int)(545 * Globals.Settings.Scale)),
|
||||||
Icon = Globals.Icon,
|
Icon = Globals.Icon,
|
||||||
SharedContext = null
|
SharedContext = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
public TabControl? tc;
|
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
|
// The rest of the function is up to you to implement, however a debug output
|
||||||
// is always useful.
|
// is always useful.
|
||||||
|
|
||||||
switch (severity)
|
if (false)
|
||||||
{
|
{
|
||||||
case DebugSeverity.DebugSeverityHigh:
|
switch (severity)
|
||||||
Console.ForegroundColor = ConsoleColor.DarkRed;
|
{
|
||||||
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
|
case DebugSeverity.DebugSeverityHigh:
|
||||||
Console.ResetColor();
|
Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||||
break;
|
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
|
||||||
case DebugSeverity.DebugSeverityMedium:
|
Console.ResetColor();
|
||||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
break;
|
||||||
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
|
case DebugSeverity.DebugSeverityMedium:
|
||||||
Console.ResetColor();
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
break;
|
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
|
||||||
default:
|
Console.ResetColor();
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
break;
|
||||||
Console.WriteLine(message);
|
default:
|
||||||
Console.ResetColor();
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
break;
|
Console.WriteLine(message);
|
||||||
|
Console.ResetColor();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainScreen() : base(Settings)
|
public MainScreen() : base(Settings)
|
||||||
{
|
{
|
||||||
VSync = VSyncMode.On;
|
VSync = VSyncMode.On;
|
||||||
|
this.TryGetCurrentMonitorScale(out var h, out var v);
|
||||||
GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero);
|
GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero);
|
||||||
GL.Enable(EnableCap.DebugOutput);
|
GL.Enable(EnableCap.DebugOutput);
|
||||||
Globals.DefaultFont =
|
Globals.DefaultFontFamly = FontFamily.LoadFontFamily("Noto Sans").Result;
|
||||||
Font.MakeEmbeddedFont("Luski.Resources.Fonts.OpenSans-Regular.ttf", Assembly.GetExecutingAssembly());
|
Globals.DefaultFont = FontInteraction.Load(Globals.DefaultFontFamly);
|
||||||
//Globals.DefaultFont = Font.MakeFontFromFile(@"C:\Users\techn\Downloads\tahoma.ttf");
|
|
||||||
Globals.DefaultFont.PixelHeight = (uint)(20 * Globals.Settings.Scale);
|
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"));
|
"Luski.Resources.Textures.Luski.png"));
|
||||||
CenterWindow(0);
|
CenterWindow(0);
|
||||||
Controls.Add(ca = new CreateAccount());
|
if ((Globals.Luski.MainServer is not null && !Globals.Luski.MainServer.IsLogedIn) || !Globals.Luski.LoadedServers.Any(s => s.IsLogedIn))
|
||||||
ca.Visible = false;
|
|
||||||
ca.ChangeToApp += LoginOnChangeToApp;
|
|
||||||
Controls.Add(login = new Login());
|
|
||||||
|
|
||||||
login.ChangeToApp += LoginOnChangeToApp;
|
|
||||||
login.ChangeToCa += LoginOnChangeToCa;
|
|
||||||
|
|
||||||
Thread t = new(_ =>
|
|
||||||
{
|
{
|
||||||
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;
|
WindowLoaded += OnWindowLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +140,9 @@ public class MainScreen : Window
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((Globals.Luski.MainServer is not null && Globals.Luski.MainServer.IsLogedIn) || Globals.Luski.LoadedServers.Any(s => s.IsLogedIn)) Invoke(() => LoginOnChangeToApp());
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,133 +255,274 @@ public class MainScreen : Window
|
|||||||
Console.WriteLine(e);
|
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();
|
Controls.Clear();
|
||||||
BlockDraw = true;
|
BlockDraw = true;
|
||||||
Title = "Luski";
|
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));
|
Size = new((int)(1332 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale));
|
||||||
DateTime start = DateTime.Now;
|
DateTime start = DateTime.Now;
|
||||||
CenterWindow(0);
|
CenterWindow(0);
|
||||||
DateTime start1 = DateTime.Now;
|
DateTime start1 = DateTime.Now;
|
||||||
WindowBorder = WindowBorder.Resizable;
|
WindowBorder = WindowBorder.Resizable;
|
||||||
BackgroundColor = new Color4(34, 34, 34, 255);
|
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()
|
Controls.Add(ser = new FlowLayout()
|
||||||
{
|
{
|
||||||
BackgroundColor = new(26, 26, 26, 255),
|
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,
|
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,
|
Texture uut =
|
||||||
Size = chat.Size,
|
TextureManager.AddTexture(Globals.Luski.MainServer.User.GetAvatar(CancellationToken.None).Result);
|
||||||
BackgroundColor = chat.BackgroundColor,
|
uut.Unit = TextureUnit.Texture1;
|
||||||
Anchor = ObjectAnchor.All,
|
// u.Shader = Rectangle.DefaultAlphaTextureShader[Context];
|
||||||
Visible = false,
|
//u.Textures.Add(uut);
|
||||||
TitleFont = Globals.DefaultFont,
|
//Controls.Add(u);
|
||||||
Border = (int)( 10 * Globals.Settings.Scale),
|
Label ul = new Label(Globals.DefaultFont)
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
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();
|
|
||||||
}
|
foreach (MainSocketRemoteUser item in Globals.Luski.MainServer.User.Friends)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
if (item.Channel is not null) AddFriend(item);
|
||||||
Console.WriteLine(e);
|
}
|
||||||
ChannelOnClickCon(chans.Where(s => s.Channel.Id == 0).First());
|
|
||||||
|
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;
|
foreach (PublicServer pser in Globals.Luski.LoadedServers)
|
||||||
|
|
||||||
Console.WriteLine("Messages Fonts done in " + (DateTime.Now - start).TotalSeconds + " seconds");
|
|
||||||
foreach (MainSocketRemoteUser cufr in Globals.Luski.MainServer.User.FriendRequests)
|
|
||||||
{
|
{
|
||||||
AddFriendRequest(cufr);
|
ser.Controls.Add(new ServerIcon<PublicServer>(pser));
|
||||||
}
|
}
|
||||||
Console.WriteLine("FR done in " + (DateTime.Now - start).TotalSeconds + " seconds");
|
|
||||||
BlockDraw = false;
|
await (ser.Controls[0] as ServerIcon<PublicServer>)!.LoadServer();
|
||||||
DrawFrame();
|
|
||||||
Console.WriteLine("GUI done in " + (DateTime.Now - start1).TotalSeconds + " seconds");
|
|
||||||
MainShow += OnMainShow;
|
MainShow += OnMainShow;
|
||||||
MainShow.Invoke();
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task OnMainShow()
|
private Task OnMainShow()
|
||||||
{
|
{
|
||||||
Globals.Luski.MainServer.OnError += LuskiOnOnError;
|
if (Globals.Luski.MainServer is not null && Globals.Luski.MainServer.IsLogedIn)
|
||||||
Globals.Luski.MainServer.UserStatusUpdate += LuskiOnUserStatusUpdate;
|
{
|
||||||
Globals.Luski.MainServer.ReceivedFriendRequest += LuskiOnReceivedFriendRequest;
|
Globals.Luski.MainServer.OnError += LuskiOnOnError;
|
||||||
Globals.Luski.MainServer.FriendRequestResult += LuskiOnFriendRequestResult;
|
Globals.Luski.MainServer.UserStatusUpdate += LuskiOnUserStatusUpdate;
|
||||||
|
Globals.Luski.MainServer.ReceivedFriendRequest += LuskiOnReceivedFriendRequest;
|
||||||
|
Globals.Luski.MainServer.FriendRequestResult += LuskiOnFriendRequestResult;
|
||||||
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
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;
|
this.Screen = Parent;
|
||||||
Size = new((int)(200 * Globals.Settings.Scale), (int)(48 * Globals.Settings.Scale));
|
Size = new((int)(200 * Globals.Settings.Scale), (int)(48 * Globals.Settings.Scale));
|
||||||
BackgroundColor = new(45,45,45,255);
|
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;
|
Input.KeyPress += InputOnKeyPress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,16 +35,15 @@ public class Chat : UserControl
|
|||||||
HScrollPixels = Globals.Settings.PerScrollPixels
|
HScrollPixels = Globals.Settings.PerScrollPixels
|
||||||
});
|
});
|
||||||
Controls.Add(titlecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right, Size = new((int)(980 * Globals.Settings.Scale), (int)(52 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
|
Controls.Add(titlecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right, Size = new((int)(980 * Globals.Settings.Scale), (int)(52 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
|
||||||
titlecon.Controls.Add(title = new Label()
|
titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Font = Globals.DefaultFont, Location = new(
|
//Location = new(
|
||||||
(int)((26 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale),
|
// (int)((26 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale),
|
||||||
(int)((26 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight/2.0)))
|
// (int)((26 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight/2.0)))
|
||||||
});
|
});
|
||||||
titlecon.Controls.Add(desc = new Label(){ Font = Globals.DefaultFont, Color = new(161,161,161,255), Location = new(title.Location.X + title.Size.X + 5, title.Location.Y)});
|
titlecon.Controls.Add(desc = new Label(Globals.DefaultFont){ Color = new(161,161,161,255), Location = new(title.Location.X + title.Size.X + 5, title.Location.Y)});
|
||||||
Controls.Add(tb = new Textbox()
|
Controls.Add(tb = new Textbox(Globals.DefaultFont, Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Font = Globals.DefaultFont,
|
|
||||||
InsideColor = new(28, 28, 28, 255),
|
InsideColor = new(28, 28, 28, 255),
|
||||||
BorderColor = Color4.DarkCyan,
|
BorderColor = Color4.DarkCyan,
|
||||||
Location = new((int)(10 * Globals.Settings.Scale), (int)(824 * Globals.Settings.Scale)),
|
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;
|
if (Channel is not null && Channel!.Id == channelPick.Channel.Id) return;
|
||||||
Channel = channelPick.Channel;
|
Channel = channelPick.Channel;
|
||||||
title.Text = channelPick.Channel.Title;
|
title.Text = channelPick.Channel.Title;
|
||||||
tb.WatermarkFont = Globals.DefaultFont;
|
//tb.WatermarkFont = Globals.DefaultFont;
|
||||||
if (channelPick.Channel.Type == ChannelType.DM)
|
if (channelPick.Channel.Type == ChannelType.DM)
|
||||||
title.Text = (channelPick.Channel as MainSocketDMChannel)!.User.DisplayName;
|
title.Text = (channelPick.Channel as MainSocketDMChannel)!.User.DisplayName;
|
||||||
tb.WatermarkText = "Message " + title.Text;
|
tb.WatermarkText = "Message " + title.Text;
|
||||||
|
@ -18,7 +18,7 @@ namespace Luski.GUI.MainScreen.UI;
|
|||||||
public class ChatMessage : UserControl
|
public class ChatMessage : UserControl
|
||||||
{
|
{
|
||||||
readonly int padding = 2;
|
readonly int padding = 2;
|
||||||
private static Font TimeFont = Font.MakeFontFromSystem(13);
|
private static Font TimeFont;// = Font.MakeFontFromSystem(13);
|
||||||
private MainSocketMessage Msg { get; }
|
private MainSocketMessage Msg { get; }
|
||||||
private Label label2, lastm;
|
private Label label2, lastm;
|
||||||
private static Dictionary<MainSocketRemoteUser, ContextMenu> Menues = new();
|
private static Dictionary<MainSocketRemoteUser, ContextMenu> Menues = new();
|
||||||
@ -34,7 +34,7 @@ public class ChatMessage : UserControl
|
|||||||
IUser user = message.GetAuthor(CancellationToken.None).Result;
|
IUser user = message.GetAuthor(CancellationToken.None).Result;
|
||||||
Anchor = ObjectAnchor.Left | ObjectAnchor.Right;
|
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}";
|
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});
|
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.GetResourceBytes(Assembly.GetExecutingAssembly(),
|
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)) };
|
"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);
|
Texture tex = tm.AddTexture(user.GetAvatar(CancellationToken.None).Result);
|
||||||
tex.Unit = TextureUnit.Texture1;
|
tex.Unit = TextureUnit.Texture1;
|
||||||
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
||||||
r.Textures.Add(tex);
|
r.Textures.Add(tex);
|
||||||
Controls.Add(r);
|
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;
|
lastm = label2;
|
||||||
if (Msg.Files != null && Msg.Files.Length > 0)
|
if (Msg.Files != null && Msg.Files.Length > 0)
|
||||||
{
|
{
|
||||||
@ -91,10 +91,10 @@ public class ChatMessage : UserControl
|
|||||||
{
|
{
|
||||||
ContextMenu m = new((int)(150 * Globals.Settings.Scale));
|
ContextMenu m = new((int)(150 * Globals.Settings.Scale));
|
||||||
RoundedButton d;
|
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,
|
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;
|
d.Tag = this;
|
||||||
Menues.Add(u,m);
|
Menues.Add(u,m);
|
||||||
@ -133,9 +133,8 @@ public class ChatMessage : UserControl
|
|||||||
|
|
||||||
public void AddMessage(MainSocketMessage msg)
|
public void AddMessage(MainSocketMessage msg)
|
||||||
{
|
{
|
||||||
Label newLabel = new()
|
Label newLabel = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Font = Globals.DefaultFont,
|
|
||||||
Text = msg.Context,
|
Text = msg.Context,
|
||||||
Tag = msg,
|
Tag = msg,
|
||||||
Location = new(label2.Location.X, Size.Y)
|
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 (sender is not Label label) return Task.CompletedTask;
|
||||||
if (label.Tag is not MainSocketMessage 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();
|
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"),
|
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);
|
Controls.Add(m);
|
||||||
|
@ -27,10 +27,10 @@ public class ContentEmbed : UserControl
|
|||||||
else if (size < 1000000000000) fst = Math.Round(size / (double)1000000000, 2) + " GB";
|
else if (size < 1000000000000) fst = Math.Round(size / (double)1000000000, 2) + " GB";
|
||||||
Size = new(333, 66);
|
Size = new(333, 66);
|
||||||
BackgroundColor = new(40, 40, 40, 255);
|
BackgroundColor = new(40, 40, 40, 255);
|
||||||
Controls.Add(fileSizeLabel = new Label() {Text = fst, Location = new(64, 39)});
|
Controls.Add(fileSizeLabel = new Label(Globals.DefaultFont) {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(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;
|
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)});
|
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 temp = fileNameLabel.Size.X + fileNameLabel.Location.X;
|
||||||
int temp2 = fileSizeLabel.Size.X + fileSizeLabel.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));
|
Size = new((int)(240 * Globals.Settings.Scale), (int)(62* Globals.Settings.Scale));
|
||||||
BackgroundColor = new(34, 34, 34, 255);
|
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(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() { Scale = 0.8f, Font = Globals.DefaultFont, Text = person.Status.ToString(), Location = new((int)(58 * Globals.Settings.Scale),(int)(34* 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],
|
"Luski.Resources.Textures.Status.png"))) { Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||||
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
|
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
|
||||||
Size = new ((int)(42 * Globals.Settings.Scale))
|
Size = new ((int)(42 * Globals.Settings.Scale))
|
||||||
@ -64,15 +64,15 @@ public class Friend : UserControl, IChannelPick
|
|||||||
this.Clicked += AllOnClicked;
|
this.Clicked += AllOnClicked;
|
||||||
ContextMenu = new((int)(196 * Globals.Settings.Scale));
|
ContextMenu = new((int)(196 * Globals.Settings.Scale));
|
||||||
RoundedButton rrr, rr2;
|
RoundedButton rrr, rr2;
|
||||||
ContextMenu.Items.Add(rrr=new()
|
ContextMenu.Items.Add(rrr=new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
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,
|
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;
|
rr2.Clicked += Rr2OnClicked;
|
||||||
rrr.Clicked += RrOnClicked;
|
rrr.Clicked += RrOnClicked;
|
||||||
|
@ -28,7 +28,7 @@ public class FriendRequest : UserControl
|
|||||||
BackgroundColor = new(34, 34, 34, 255);
|
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 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;
|
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],
|
"Luski.Resources.Textures.Status.png"))) { Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||||
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
|
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
|
||||||
Size = new ((int)(42 * Globals.Settings.Scale))
|
Size = new ((int)(42 * Globals.Settings.Scale))
|
||||||
@ -38,8 +38,8 @@ public class FriendRequest : UserControl
|
|||||||
t.Unit = TextureUnit.Texture1;
|
t.Unit = TextureUnit.Texture1;
|
||||||
rr.Textures.Add(t);
|
rr.Textures.Add(t);
|
||||||
rr.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
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(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.FriendStatus.ToString(), Location = new((int)(50 * Globals.Settings.Scale),(int)(32 * Globals.Settings.Scale))});
|
||||||
if (User.FriendStatus == FriendStatus.PendingIn)
|
if (User.FriendStatus == FriendStatus.PendingIn)
|
||||||
{
|
{
|
||||||
Controls.Add(Accept = new Rectangle()
|
Controls.Add(Accept = new Rectangle()
|
||||||
|
@ -21,7 +21,7 @@ public class Group : UserControl, IChannelPick
|
|||||||
Channel = chan;
|
Channel = chan;
|
||||||
Size = new((int)(240 * Globals.Settings.Scale), (int)(62* Globals.Settings.Scale));
|
Size = new((int)(240 * Globals.Settings.Scale), (int)(62* Globals.Settings.Scale));
|
||||||
BackgroundColor = new(34, 34, 34, 255);
|
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],
|
"Luski.Resources.Textures.Status.png"))) { Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||||
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
|
Location = new((int)(10 * Globals.Settings.Scale), (int)(10 * Globals.Settings.Scale)),
|
||||||
Size = new ((int)(42 * Globals.Settings.Scale)),
|
Size = new ((int)(42 * Globals.Settings.Scale)),
|
||||||
@ -34,13 +34,13 @@ public class Group : UserControl, IChannelPick
|
|||||||
r.Textures.Add(tex);
|
r.Textures.Add(tex);
|
||||||
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
||||||
Controls.Add(r);
|
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";
|
string sl = "Online";
|
||||||
if (chan.Id != 0)
|
if (chan.Id != 0)
|
||||||
{
|
{
|
||||||
sl = chan.Members.Count + " Members";
|
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;
|
this.Clicked += AllOnClicked;
|
||||||
Username.Location = new((int)(58 * Globals.Settings.Scale),
|
Username.Location = new((int)(58 * Globals.Settings.Scale),
|
||||||
(rr.Location.Y + (rr.Size.Y / 2) - ((Username.TrueHeight + 5 + Status.TrueHeight) / 2) -
|
(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;
|
if (chan.Id == 0) return;
|
||||||
ContextMenu = new((int)(150 * Globals.Settings.Scale));
|
ContextMenu = new((int)(150 * Globals.Settings.Scale));
|
||||||
RoundedButton rrr;
|
RoundedButton rrr;
|
||||||
ContextMenu.Items.Add(rrr=new()
|
ContextMenu.Items.Add(rrr=new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
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;
|
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;
|
||||||
|
}
|
104
Luski/GUI/MainScreen/UI/PublicServers/ChannelSelector.cs
Normal file
104
Luski/GUI/MainScreen/UI/PublicServers/ChannelSelector.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using GraphicsManager.Objects;
|
||||||
|
using Luski.GUI.MainScreen.Interfaces;
|
||||||
|
using Luski.net.Structures.Public;
|
||||||
|
using OpenTK.Mathematics;
|
||||||
|
|
||||||
|
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
||||||
|
|
||||||
|
public class ChannelSelector : FlowLayout, IChannelAdder
|
||||||
|
{
|
||||||
|
public SocketCategory CurrentCategory { get; }
|
||||||
|
private readonly List<Category> cc = new();
|
||||||
|
private readonly List<Channel> LoadedChannels = new();
|
||||||
|
public Channel? Selected;
|
||||||
|
|
||||||
|
public ChannelSelector(SocketCategory Cat)
|
||||||
|
{
|
||||||
|
CurrentCategory = Cat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Load(SocketChannel currentchannel, List<SocketCategory> parents)
|
||||||
|
{
|
||||||
|
IChannelAdder b = this;
|
||||||
|
SocketChannel[] chanspp = await b.CurrentCategory.GetChannels();
|
||||||
|
foreach (SocketChannel v in chanspp)
|
||||||
|
{
|
||||||
|
Channel f = await b.AddChannel(v);
|
||||||
|
if (v.ID == currentchannel.ID)
|
||||||
|
{
|
||||||
|
await f.ToggleSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SocketCategory[] cats = await b.CurrentCategory.GetCategories();
|
||||||
|
foreach (SocketCategory v in cats)
|
||||||
|
{
|
||||||
|
await b.AddCategory(v);
|
||||||
|
Globals.ms.DrawFrame();
|
||||||
|
}
|
||||||
|
foreach (SocketCategory par in parents)
|
||||||
|
{
|
||||||
|
b.Extended = true;
|
||||||
|
b = await b.AddCategory(par);
|
||||||
|
Globals.ms.DrawFrame();
|
||||||
|
chanspp = await par.GetChannels();
|
||||||
|
foreach (SocketChannel v in chanspp)
|
||||||
|
{
|
||||||
|
Channel f = await b.AddChannel(v);
|
||||||
|
if (v.ID == currentchannel.ID)
|
||||||
|
{
|
||||||
|
await f.ToggleSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cats = await par.GetCategories();
|
||||||
|
foreach (SocketCategory v in cats)
|
||||||
|
{
|
||||||
|
await b.AddCategory(v);
|
||||||
|
Globals.ms.DrawFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Channel> AddChannel(SocketChannel chan)
|
||||||
|
{
|
||||||
|
Channel[] tc = LoadedChannels.Where(s => s.CurrentChannel.ID == chan.ID).ToArray();
|
||||||
|
if (tc.Length > 0)
|
||||||
|
{
|
||||||
|
Channel cat23 = tc[0];
|
||||||
|
if (!Controls.Contains(cat23))
|
||||||
|
{
|
||||||
|
Controls.Add(cat23);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cat23;
|
||||||
|
}
|
||||||
|
Channel cat2 = await Channel.MakeChannel(chan, this);
|
||||||
|
LoadedChannels.Add(cat2);
|
||||||
|
cat2.BackgroundColor = BackgroundColor;
|
||||||
|
Controls.Add(cat2);
|
||||||
|
return cat2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Extended { get; set; } = true;
|
||||||
|
|
||||||
|
public async Task<Category> AddCategory(SocketCategory Cat, DateTime? dt = null)
|
||||||
|
{
|
||||||
|
Category[] tc = cc.Where(s => s.CurrentCategory.ID == Cat.ID).ToArray();
|
||||||
|
if (tc.Length > 0)
|
||||||
|
{
|
||||||
|
Category cat23 = tc[0];
|
||||||
|
if (!Controls.Contains(cat23))
|
||||||
|
{
|
||||||
|
Controls.Add(cat23);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cat23;
|
||||||
|
}
|
||||||
|
Category cat = await Category.MakeCat(Cat, this);
|
||||||
|
cc.Add(cat);
|
||||||
|
cat.BackgroundColor = BackgroundColor;
|
||||||
|
cat.tmp.BackgroundColor = BackgroundColor;
|
||||||
|
cat.Members.BackgroundColor = BackgroundColor;
|
||||||
|
Controls.Add(cat);
|
||||||
|
return cat;
|
||||||
|
}
|
||||||
|
}
|
224
Luski/GUI/MainScreen/UI/PublicServers/ChatMessage.cs
Normal file
224
Luski/GUI/MainScreen/UI/PublicServers/ChatMessage.cs
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using GraphicsManager;
|
||||||
|
using GraphicsManager.Enums;
|
||||||
|
using GraphicsManager.Interfaces;
|
||||||
|
using GraphicsManager.Objects;
|
||||||
|
using GraphicsManager.Objects.Core;
|
||||||
|
using Luski.net.Interfaces;
|
||||||
|
using Luski.net.Structures.Main;
|
||||||
|
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 ChatMessage : UserControl
|
||||||
|
{
|
||||||
|
//readonly int padding = 10;
|
||||||
|
private static Font TimeFont;// = Font.MakeFontFromSystem(13);
|
||||||
|
private SocketMessage Msg { get; }
|
||||||
|
private SocketChannel ch { get; }
|
||||||
|
|
||||||
|
private IRenderObject LastObject;
|
||||||
|
private Label FirstL;
|
||||||
|
|
||||||
|
private readonly double HorPadding = (12 * Globals.Settings.Scale),
|
||||||
|
VerticalPadding = (12 * Globals.Settings.Scale);
|
||||||
|
|
||||||
|
private static Dictionary<MainSocketRemoteUser, ContextMenu> Menues = new();
|
||||||
|
private static Dictionary<MainSocketRemoteUser, List<ChatMessage>> Messages = new();
|
||||||
|
|
||||||
|
public static async Task<ChatMessage> MakeChatMessage(SocketMessage message)
|
||||||
|
{
|
||||||
|
IUser auth = await message.GetAuthor(CancellationToken.None);
|
||||||
|
Role[] ra = await ((SocketUser)auth).GetRoles();
|
||||||
|
Color c = ra[0].Color;
|
||||||
|
Color4 c4 = new(c.R, c.G, c.B, c.A);
|
||||||
|
return new ChatMessage(message, await message.GetParent(CancellationToken.None), auth, await auth.GetIcon(), c4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ChatMessage(SocketMessage message, SocketChannel chan, IUser Author, Texture UserIcon, Color4 UserNameColor)
|
||||||
|
{
|
||||||
|
Label label1;
|
||||||
|
Size = new((int)(723.5 * Globals.Settings.Scale), (int)(37 * Globals.Settings.Scale));
|
||||||
|
ch = chan;
|
||||||
|
BackgroundColor = new(40, 40, 40, 255);
|
||||||
|
Msg = message;
|
||||||
|
Anchor = ObjectAnchor.Left | ObjectAnchor.Right;
|
||||||
|
|
||||||
|
DateTime time = chan.Epoch.AddMilliseconds(Msg.ID >> 20).ToLocalTime();
|
||||||
|
string timestr;
|
||||||
|
if (time.Date == DateTime.Now.ToLocalTime().Date)
|
||||||
|
{
|
||||||
|
timestr = $"Today at {time.ToShortTimeString()}";
|
||||||
|
}
|
||||||
|
else if (time.Date == DateTime.Now.ToLocalTime().AddDays(-1).Date)
|
||||||
|
{
|
||||||
|
timestr = $"Yesterday at {time.ToShortTimeString()}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timestr = $"{time:M/dd/yyyy h:mm tt}";
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle r = new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
|
||||||
|
"Luski.Resources.Textures.Status.png"))) { Location = new((int)(10 * Globals.Settings.Scale), (int)(2 * Globals.Settings.Scale)), Size = new((int)(38 * Globals.Settings.Scale)) };
|
||||||
|
//UserIcon.Unit = TextureUnit.Texture1;
|
||||||
|
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
||||||
|
r.Textures.Add(UserIcon);
|
||||||
|
Controls.Add(r);
|
||||||
|
Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor, Text = Author.DisplayName });
|
||||||
|
label1.Location = new(
|
||||||
|
(int)(54 * Globals.Settings.Scale),
|
||||||
|
(int)(r.Location.Y + (r.Size.Y / 2) - (label1.Font.CurrentFont.Fonts[0].Size.Metrics.NominalHeight / 2) - label1.Size.Y + label1.Font.PixelHeight));
|
||||||
|
LastObject = label1;
|
||||||
|
FirstL = label1;
|
||||||
|
Controls.Add(new Label(Globals.TopTimeFont) { Location = new(label1.Location.X + label1.Size.X + (int)(8 * Globals.Settings.Scale), (int)(label1.Location.Y + label1.Font.PixelHeight - Globals.TopTimeFont.PixelHeight)), Text = timestr});
|
||||||
|
if (!string.IsNullOrWhiteSpace(Msg.Context))
|
||||||
|
{
|
||||||
|
Label l;
|
||||||
|
Controls.Add(l = new Label(Globals.MessageFont) { Location = new(LastObject.Location.X, (int)(LastObject.Location.Y + (LastObject as Label)!.Size.Y + VerticalPadding)), Text = message.Context});
|
||||||
|
LastObject = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Msg.Files.Count > 0)
|
||||||
|
{
|
||||||
|
int row = 1;
|
||||||
|
int filesonrow = 0;
|
||||||
|
for (int i = 0; i < Msg.Files.Count; i++)
|
||||||
|
{
|
||||||
|
double lx = (HorPadding * filesonrow) + LastObject.Location.X + (333 * (filesonrow + 1));
|
||||||
|
if (lx > Size.X)
|
||||||
|
{
|
||||||
|
row++;
|
||||||
|
filesonrow = 0;
|
||||||
|
lx = (HorPadding * filesonrow) + LastObject.Location.X + (333 * (filesonrow + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
filesonrow++;
|
||||||
|
IRenderObject cem = ContentEmbed.GetEmbed(this, Msg.Files[i], Msg.ChannelID).Result;
|
||||||
|
cem.Location = new((int)(lx - 333), (int)(LastObject.Location.Y + 2 + LastObject.Size.Y + (HorPadding * row) + (66 * (row - 1))));
|
||||||
|
LastObject = cem;
|
||||||
|
//lo = cem.Location;
|
||||||
|
// si = cem.Size;
|
||||||
|
Controls.Add(cem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LastObject is Label ll) Size = new(Size.X, (int)(ll.Location.Y + ll.Size.Y + VerticalPadding));
|
||||||
|
else Size = new(Size.X ,(int)(LastObject.Location.Y + LastObject.Size.Y + VerticalPadding));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddMessage(SocketMessage msg)
|
||||||
|
{
|
||||||
|
Label newLabel;
|
||||||
|
if (!string.IsNullOrWhiteSpace(msg.Context))
|
||||||
|
{
|
||||||
|
newLabel = new(Globals.MessageFont)
|
||||||
|
{
|
||||||
|
Text = msg.Context,
|
||||||
|
Tag = msg
|
||||||
|
};
|
||||||
|
if (LastObject is Label l)
|
||||||
|
{
|
||||||
|
newLabel.Location = new(FirstL.Location.X, (int)(l.Location.Y + l.Size.Y + VerticalPadding));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newLabel.Location = new(FirstL.Location.X, Size.Y);
|
||||||
|
}
|
||||||
|
bool result = Uri.TryCreate(newLabel.Text, UriKind.Absolute, out Uri? uriResult)
|
||||||
|
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
newLabel.HoverMouse = MouseCursor.Hand;
|
||||||
|
newLabel.Color = Color4.Aqua;
|
||||||
|
newLabel.Clicked += NewLabelOnClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
newLabel.MouseEnter += NewLabel_MouseEnter;
|
||||||
|
newLabel.MouseLeave += NewLabel_MouseLeave;
|
||||||
|
Controls.Add(newLabel);
|
||||||
|
LastObject = newLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.Files.Count > 0)
|
||||||
|
{
|
||||||
|
int row = 1;
|
||||||
|
int filesonrow = 0;
|
||||||
|
for (int i = 0; i < msg.Files.Count; i++)
|
||||||
|
{
|
||||||
|
double lx = (HorPadding * filesonrow) + LastObject.Location.X + (333 * (filesonrow + 1));
|
||||||
|
if (lx > Size.X)
|
||||||
|
{
|
||||||
|
row++;
|
||||||
|
filesonrow = 0;
|
||||||
|
lx = (HorPadding * filesonrow) + LastObject.Location.X + (333 * (filesonrow + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
filesonrow++;
|
||||||
|
IRenderObject cem = await ContentEmbed.GetEmbed(this, msg.Files[i], msg.ChannelID);
|
||||||
|
cem.Location = new((int)(lx - 333), (int)(LastObject.Location.Y + 2 + LastObject.Size.Y + (HorPadding * row) + (66 * (row - 1))));
|
||||||
|
LastObject = cem;
|
||||||
|
Controls.Add(cem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (LastObject is Label ll) Size = new(Size.X, (int)(ll.Location.Y + ll.Size.Y + VerticalPadding));
|
||||||
|
else Size = new(Size.X ,(int)(LastObject.Location.Y + LastObject.Size.Y + VerticalPadding));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task NewLabelOnClicked(IRenderObject arg)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Label m = (arg as Label)!;
|
||||||
|
if (OperatingSystem.IsWindows())
|
||||||
|
Process.Start(m.Text);
|
||||||
|
else if (OperatingSystem.IsLinux())
|
||||||
|
if (m.Tag is string s) Process.Start("xdg-open",s);
|
||||||
|
else Process.Start("xdg-open", m.Text);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly List<Label> Labels = new();
|
||||||
|
private Task NewLabel_MouseLeave(IRenderObject sender)
|
||||||
|
{
|
||||||
|
if (sender is not Label label) return Task.CompletedTask;
|
||||||
|
if (label.Tag is not MainSocketMessage Message) return Task.CompletedTask;
|
||||||
|
DateTime time = new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(Message.Id >> 22).ToLocalTime();
|
||||||
|
string b = time.ToString("h:mm tt");
|
||||||
|
Label[] l = Labels.Where(s => s.Text == b).ToArray();
|
||||||
|
if (l.Any())
|
||||||
|
{
|
||||||
|
Controls.Remove(l.First());
|
||||||
|
Labels.Remove(l.First());
|
||||||
|
}
|
||||||
|
Window!.DrawFrame();
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task NewLabel_MouseEnter(IRenderObject sender)
|
||||||
|
{
|
||||||
|
if (sender is not Label label) return Task.CompletedTask;
|
||||||
|
if (label.Tag is not MainSocketMessage Message) return Task.CompletedTask;
|
||||||
|
DateTime time = new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(Message.Id >> 22).ToLocalTime();
|
||||||
|
Label m = new(Globals.DefaultFont)
|
||||||
|
{
|
||||||
|
Text = time.ToString("h:mm tt"),
|
||||||
|
Location = new((int)(7.5 * Globals.Settings.Scale), label.Location.Y - 13 + (int)label.Font.PixelHeight),
|
||||||
|
};
|
||||||
|
|
||||||
|
Controls.Add(m);
|
||||||
|
Labels.Add(m);
|
||||||
|
Window!.DrawFrame();
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
117
Luski/GUI/MainScreen/UI/PublicServers/ContentEmbed.cs
Normal file
117
Luski/GUI/MainScreen/UI/PublicServers/ContentEmbed.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using GraphicsManager;
|
||||||
|
using GraphicsManager.Interfaces;
|
||||||
|
using GraphicsManager.Objects;
|
||||||
|
using GraphicsManager.Objects.Core;
|
||||||
|
using Luski.net.Structures.Public;
|
||||||
|
using OpenTK.Windowing.Common.Input;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using File = Luski.net.Structures.File;
|
||||||
|
using Rectangle = GraphicsManager.Objects.Rectangle;
|
||||||
|
|
||||||
|
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
||||||
|
|
||||||
|
public class ContentEmbed : UserControl
|
||||||
|
{
|
||||||
|
readonly SocketFile file;
|
||||||
|
public static Texture? t = null;
|
||||||
|
public static Texture? DownloadIcon = null;
|
||||||
|
long channel;
|
||||||
|
private static bool isopen;
|
||||||
|
public static async Task<IRenderObject> GetEmbed(ChatMessage m, SocketFile file, long channel)
|
||||||
|
{
|
||||||
|
if (file.Name.ToLower().EndsWith(".png") || file.Name.ToLower().EndsWith(".jpg"))
|
||||||
|
{
|
||||||
|
Stream data = await file.GetCache(CancellationToken.None);
|
||||||
|
Texture t = Globals.ms.TextureManager.AddTexture(data);
|
||||||
|
data.Dispose();
|
||||||
|
Rectangle r;
|
||||||
|
double s = (Globals.Settings.Scale * 322);
|
||||||
|
double scale = s / t.RawSize!.Value.X;
|
||||||
|
m.Controls.Add(r = new Rectangle(t)
|
||||||
|
{
|
||||||
|
Size = new((int)s, (int)(scale * t.RawSize.Value.Y)),
|
||||||
|
Shader = Texture.TextureShader[Globals.ms.Context],
|
||||||
|
HoverMouse = MouseCursor.Hand
|
||||||
|
});
|
||||||
|
r.Clicked += ROnClicked;
|
||||||
|
t.RawSize = null;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ContentEmbed c;
|
||||||
|
m.Controls.Add(c = new ContentEmbed(file, channel));
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Task ROnClicked(IRenderObject arg)
|
||||||
|
{
|
||||||
|
if (isopen) return Task.CompletedTask;
|
||||||
|
isopen = !isopen;
|
||||||
|
Rectangle r;
|
||||||
|
Image<Rgba32> Logo = SixLabors.ImageSharp.Image.Load<Rgba32>(System.IO.File.OpenRead("/home/jacob/Pictures/Logo.png"));
|
||||||
|
Logo.DangerousTryGetSinglePixelMemory(out Memory<Rgba32> m);
|
||||||
|
byte[] pixels = new byte[4 * Logo.Width * Logo.Height];
|
||||||
|
Logo.CopyPixelDataTo(pixels);
|
||||||
|
Globals.ms.Controls.Add(r=new Rectangle()
|
||||||
|
{
|
||||||
|
Size = Globals.ms.Size,
|
||||||
|
BackgroundColor = new(0,0,0,150),
|
||||||
|
HoverMouse = new(0,0, Logo.Width, Logo.Height, pixels)
|
||||||
|
});
|
||||||
|
Globals.ms.CurrentTop = r;
|
||||||
|
Globals.ms.DrawFrame();
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContentEmbed(SocketFile file, long channel)
|
||||||
|
{
|
||||||
|
Label fileNameLabel, fileSizeLabel;
|
||||||
|
this.channel = channel;
|
||||||
|
this.file = file;
|
||||||
|
string fst = "";
|
||||||
|
ulong size = (ulong)file.Size;
|
||||||
|
if (size < 1000)
|
||||||
|
fst = size + " bytes";
|
||||||
|
else if (size < 1000000)
|
||||||
|
fst = Math.Round(size / (double)1000, 2) + " KB";
|
||||||
|
else if (size < 1000000000)
|
||||||
|
fst = Math.Round(size / (double)1000000, 2) + " MB";
|
||||||
|
else if (size < 1000000000000) fst = Math.Round(size / (double)1000000000, 2) + " GB";
|
||||||
|
Size = new(333, 66);
|
||||||
|
BackgroundColor = new(40, 40, 40, 255);
|
||||||
|
Controls.Add(fileSizeLabel = new Label(Globals.DefaultFont) { Text = fst, Location = new(64, 39) });
|
||||||
|
Controls.Add(fileNameLabel = new Label(Globals.DefaultFont)
|
||||||
|
{
|
||||||
|
Color = new(102 / (float)255, 227 / (float)255, 170 / (float)255, 1), Text = file.Name,
|
||||||
|
Location = new(64, 6)
|
||||||
|
});
|
||||||
|
fileNameLabel.Clicked += FileNameLabelOnClicked;
|
||||||
|
if (DownloadIcon is null)
|
||||||
|
{
|
||||||
|
Stream tempp =
|
||||||
|
Tools.GetResourceStream(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Download.png");
|
||||||
|
DownloadIcon = Globals.ms.TextureManager.AddTexture(tempp);
|
||||||
|
tempp.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Controls.Add(new Rectangle(DownloadIcon)
|
||||||
|
{ Location = new(8, 6), Size = new(50, 50) });
|
||||||
|
int temp = fileNameLabel.Size.X + fileNameLabel.Location.X;
|
||||||
|
int temp2 = fileSizeLabel.Size.X + fileSizeLabel.Location.X;
|
||||||
|
//if (temp >= temp2) Size = new(temp + 4, Size.Y);
|
||||||
|
//else Size = new(temp2 + 4, Size.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task FileNameLabelOnClicked(IRenderObject arg)
|
||||||
|
{
|
||||||
|
string dir = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Downloads", "LuskiDownloads");
|
||||||
|
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
|
||||||
|
//Thread t = new(() => file.DownloadBytes(Path.Join(dir, file.Name), channel, CancellationToken.None));
|
||||||
|
//t.Start();
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
126
Luski/GUI/MainScreen/UI/PublicServers/PublicChat.cs
Normal file
126
Luski/GUI/MainScreen/UI/PublicServers/PublicChat.cs
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
using GraphicsManager.Enums;
|
||||||
|
using GraphicsManager.Objects;
|
||||||
|
using Luski.net.Structures.Public;
|
||||||
|
using OpenTK.Mathematics;
|
||||||
|
using OpenTK.Windowing.Common.Input;
|
||||||
|
|
||||||
|
namespace Luski.GUI.MainScreen.UI.PublicServers;
|
||||||
|
|
||||||
|
public class PublicChat : UserControl
|
||||||
|
{
|
||||||
|
|
||||||
|
public FlowLayout MessageFlow;
|
||||||
|
private Label title, desc;
|
||||||
|
private Textbox tb;
|
||||||
|
private SocketChannel? Channel;
|
||||||
|
|
||||||
|
public PublicChat()
|
||||||
|
{
|
||||||
|
UserControl titlecon;
|
||||||
|
Size = new((int)(980 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale));
|
||||||
|
BackgroundColor = new(50, 50, 50, 255);
|
||||||
|
Anchor = ObjectAnchor.All;
|
||||||
|
Controls.Add(MessageFlow = new()
|
||||||
|
{
|
||||||
|
Size = new(Size.X, (int)(761 * Globals.Settings.Scale)),
|
||||||
|
Location = new(0, (int)(52 * Globals.Settings.Scale)),
|
||||||
|
BackgroundColor = new(40,40,40,255),
|
||||||
|
Anchor = ObjectAnchor.All,
|
||||||
|
HScrollPixels = Globals.Settings.PerScrollPixels
|
||||||
|
});
|
||||||
|
Controls.Add(titlecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right, Size = new((int)(980 * Globals.Settings.Scale), (int)(52 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
|
||||||
|
titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
|
||||||
|
{
|
||||||
|
//Location = new(
|
||||||
|
// (int)((26 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale),
|
||||||
|
// (int)((26 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight/2.0)))
|
||||||
|
});
|
||||||
|
titlecon.Controls.Add(desc = new Label(Globals.DefaultFont){ Color = new(161,161,161,255), Location = new(title.Location.X + title.Size.X + 5, title.Location.Y)});
|
||||||
|
Controls.Add(tb = new Textbox(Globals.DefaultFont, Globals.DefaultFont)
|
||||||
|
{
|
||||||
|
InsideColor = new(28, 28, 28, 255),
|
||||||
|
BorderColor = Color4.DarkCyan,
|
||||||
|
Location = new((int)(10 * Globals.Settings.Scale), (int)(824 * Globals.Settings.Scale)),
|
||||||
|
Size = new((int)(960 * Globals.Settings.Scale), (int)(34 * Globals.Settings.Scale)),
|
||||||
|
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
|
||||||
|
HoverMouse = MouseCursor.IBeam
|
||||||
|
});
|
||||||
|
//tb.KeyPress += TbOnKeyPress;
|
||||||
|
//Globals.Luski.MainServer.MessageReceived += LuskiOnMessageReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SocketMessage? lastm;
|
||||||
|
private long? lastUser;
|
||||||
|
private ChatMessage? LastChatMessage;
|
||||||
|
|
||||||
|
public async Task LoadChannel(SocketChannel channel)
|
||||||
|
{
|
||||||
|
Channel = channel;
|
||||||
|
title.Text = channel.Name;
|
||||||
|
desc.Text = channel.Description;
|
||||||
|
this.tb.WatermarkText = $"Message {channel.Name}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearChat()
|
||||||
|
{
|
||||||
|
MessageFlow.Controls.Clear();
|
||||||
|
lastm = null;
|
||||||
|
lastUser = null;
|
||||||
|
LastChatMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddMessages(IEnumerable<SocketMessage> messages, bool reverse = true)
|
||||||
|
{
|
||||||
|
if (reverse)
|
||||||
|
{
|
||||||
|
foreach (SocketMessage message in messages.Reverse())
|
||||||
|
{
|
||||||
|
await AddMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (SocketMessage message in messages)
|
||||||
|
{
|
||||||
|
await AddMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddMessage(SocketMessage Message)
|
||||||
|
{
|
||||||
|
bool hasbeentenmin = false;
|
||||||
|
if (lastm is not null)
|
||||||
|
hasbeentenmin =
|
||||||
|
new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(lastm.ID >> 22).ToLocalTime().AddMinutes(10) <
|
||||||
|
new DateTime(2022, 1, 1, 0, 0, 0, 0).AddMilliseconds(Message.ID >> 22).ToLocalTime();
|
||||||
|
lastm = Message;
|
||||||
|
if (lastUser is null || lastUser != Message.AuthorID || hasbeentenmin)
|
||||||
|
{
|
||||||
|
if (Window is null || !Globals.ms.InvokeRequired)
|
||||||
|
{
|
||||||
|
MessageFlow.Controls.Add(LastChatMessage = await ChatMessage.MakeChatMessage(Message));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LastChatMessage = await ChatMessage.MakeChatMessage(Message);
|
||||||
|
Globals.ms.Invoke(() =>
|
||||||
|
{
|
||||||
|
MessageFlow.Controls.Add(LastChatMessage);
|
||||||
|
Window.DrawFrame();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Window is null || !Globals.ms.InvokeRequired)
|
||||||
|
{
|
||||||
|
await LastChatMessage!.AddMessage(Message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Globals.ms.Invoke(() => { LastChatMessage!.AddMessage(Message); Window!.DrawFrame(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
lastUser = Message.AuthorID;
|
||||||
|
}
|
||||||
|
}
|
86
Luski/GUI/MainScreen/UI/ServerIcon.cs
Normal file
86
Luski/GUI/MainScreen/UI/ServerIcon.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using GraphicsManager;
|
||||||
|
using GraphicsManager.Interfaces;
|
||||||
|
using GraphicsManager.Objects;
|
||||||
|
using GraphicsManager.Objects.Core;
|
||||||
|
using Luski.net;
|
||||||
|
using OpenTK.Graphics.OpenGL4;
|
||||||
|
|
||||||
|
namespace Luski.GUI.MainScreen.UI;
|
||||||
|
|
||||||
|
public class ServerIcon<TServer> : UserControl where TServer : Server
|
||||||
|
{
|
||||||
|
private Rectangle SelectedRect;
|
||||||
|
private static ServerIcon<MainServer>? ser1;
|
||||||
|
private static ServerIcon<PublicServer>? ser2;
|
||||||
|
|
||||||
|
public async Task LoadServer()
|
||||||
|
{
|
||||||
|
if (ser1 is not null)
|
||||||
|
{
|
||||||
|
ser1.SelectedRect.BackgroundColor = new(26, 26, 26, 255);
|
||||||
|
ser1 = null;
|
||||||
|
}
|
||||||
|
if (ser2 is not null)
|
||||||
|
{
|
||||||
|
ser2.SelectedRect.BackgroundColor = new(26, 26, 26, 255);
|
||||||
|
ser2 = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedRect.BackgroundColor = new(255, 255, 255, 255);
|
||||||
|
Globals.UserTextureMap.Clear();
|
||||||
|
if (typeof(TServer).FullName == typeof(PublicServer).FullName)
|
||||||
|
{
|
||||||
|
ser2 = this as ServerIcon<PublicServer>;
|
||||||
|
await Globals.ms.LoadPublicServer(ser2!.Server);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ser1 = this as ServerIcon<MainServer>;
|
||||||
|
await Globals.ms.LoadMainServer(ser1!.Server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerIcon(TServer Server)
|
||||||
|
{
|
||||||
|
Rectangle r = new(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
|
||||||
|
"Luski.Resources.Textures.rc.png")))
|
||||||
|
{
|
||||||
|
Location = new((int)(18 * Globals.Settings.Scale), (int)(8 * Globals.Settings.Scale)),
|
||||||
|
Size = new((int)(32 * Globals.Settings.Scale)),
|
||||||
|
Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context]
|
||||||
|
};
|
||||||
|
Rectangle rr = new(r.Textures[0])
|
||||||
|
{
|
||||||
|
Location = new((int)(17 * Globals.Settings.Scale), (int)(7 * Globals.Settings.Scale)),
|
||||||
|
Size = new((int)(34 * Globals.Settings.Scale)),
|
||||||
|
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||||
|
BackgroundColor = new(26, 26, 26, 255)
|
||||||
|
};
|
||||||
|
SelectedRect = new(r.Textures[0])
|
||||||
|
{
|
||||||
|
Location = new((int)(14 * Globals.Settings.Scale), (int)(4 * Globals.Settings.Scale)),
|
||||||
|
Size = new((int)(40 * Globals.Settings.Scale)),
|
||||||
|
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||||
|
BackgroundColor = new(26, 26, 26, 255)
|
||||||
|
};
|
||||||
|
this.Server = Server;
|
||||||
|
Texture t = Globals.ms.TextureManager.AddTexture(Server.GetAvatar(CancellationToken.None).Result);
|
||||||
|
t.Unit = TextureUnit.Texture1;
|
||||||
|
r.Textures.Add(t);
|
||||||
|
Controls.Add(SelectedRect);
|
||||||
|
Controls.Add(rr);
|
||||||
|
Controls.Add(r);
|
||||||
|
BackgroundColor = new(26, 26, 26, 255);
|
||||||
|
this.Clicked += OnClicked;
|
||||||
|
Size = new((int)(68 * Globals.Settings.Scale), (int)(48 * Globals.Settings.Scale));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task OnClicked(IRenderObject arg)
|
||||||
|
{
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TServer Server { get; }
|
||||||
|
}
|
@ -27,13 +27,13 @@ public class CreateAccount : UserControl
|
|||||||
Rectangle tt;
|
Rectangle tt;
|
||||||
Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))});
|
Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))});
|
||||||
Label t;
|
Label t;
|
||||||
Controls.Add(t=new Label() { 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) });
|
Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f * (float)Globals.Settings.Scale, Location = new((int)(199*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) });
|
||||||
t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y);
|
t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y);
|
||||||
tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y);
|
tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y);
|
||||||
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(UsernameTextbox = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Username", Location = new((int)(27 * Globals.Settings.Scale),(int)(280 * Globals.Settings.Scale)), Size = new((int)(261 * Globals.Settings.Scale),(int)(27 * Globals.Settings.Scale)), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan });
|
||||||
Controls.Add(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(Password = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Password", PasswordChar = '●', Location = new(UsernameTextbox.Location.X,(int)(346 * Globals.Settings.Scale)), Size = new(UsernameTextbox.Size.X, UsernameTextbox.Location.X), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||||
Controls.Add(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(DisplaynameTextBox = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Displayname", Location = new(UsernameTextbox.Location.X,(int)(400 * Globals.Settings.Scale)), Size = new((int)(196 * Globals.Settings.Scale), UsernameTextbox.Location.X), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||||
Controls.Add(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(button = new(Globals.DefaultFont) { Text = "Create Account", Location = new(UsernameTextbox.Location.X, (int)(456 * Globals.Settings.Scale)), Size = new(UsernameTextbox.Size.X, (int)(46 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||||
Controls.Add(rec = new Rectangle(){ Location = new((int)(228 * Globals.Settings.Scale), (int)(384 * Globals.Settings.Scale)), Size = new((int)(50 * Globals.Settings.Scale)), BackgroundColor = Color4.Red});
|
Controls.Add(rec = new Rectangle(){ Location = new((int)(228 * Globals.Settings.Scale), (int)(384 * Globals.Settings.Scale)), Size = new((int)(50 * Globals.Settings.Scale)), BackgroundColor = Color4.Red});
|
||||||
Password.KeyPress += PasswordOnKeyPress;
|
Password.KeyPress += PasswordOnKeyPress;
|
||||||
UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress;
|
UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress;
|
||||||
@ -59,9 +59,9 @@ public class CreateAccount : UserControl
|
|||||||
{
|
{
|
||||||
Controls.Remove(rec);
|
Controls.Remove(rec);
|
||||||
Vector2i oldl = rec.Location, olds = rec.Size;
|
Vector2i oldl = rec.Location, olds = rec.Size;
|
||||||
rec = new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceBytes(Assembly.GetExecutingAssembly(),
|
rec = new Rectangle(Globals.ms.TextureManager.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
|
||||||
"Luski.Resources.Textures.Status.png"))) { Location = oldl, Size = olds };
|
"Luski.Resources.Textures.Status.png"))) { Location = oldl, Size = olds };
|
||||||
Texture tex = Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]));
|
Texture tex = Globals.ms.TextureManager.AddTexture(File.OpenRead(arg[0]));
|
||||||
tex.Unit = TextureUnit.Texture1;
|
tex.Unit = TextureUnit.Texture1;
|
||||||
rec.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
rec.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
||||||
rec.Textures.Add(tex);
|
rec.Textures.Add(tex);
|
||||||
@ -70,7 +70,7 @@ public class CreateAccount : UserControl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rec.Textures[1] = Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]));
|
rec.Textures[1] = Globals.ms.TextureManager.AddTexture(File.OpenRead(arg[0]));
|
||||||
rec.Textures[1].Unit = TextureUnit.Texture1;
|
rec.Textures[1].Unit = TextureUnit.Texture1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ public class Login : UserControl
|
|||||||
Rectangle tt;
|
Rectangle tt;
|
||||||
Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))});
|
Controls.Add(tt=new Rectangle(Globals.LuskiTexture) { Size = new((int)(179*Globals.Settings.Scale), (int)(189*Globals.Settings.Scale))});
|
||||||
Label t;
|
Label t;
|
||||||
Controls.Add(t=new Label() { Scale = 1.6f, Font = Globals.DefaultFont, Location = new((int)(199*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) });
|
Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f, Location = new((int)(199*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) });
|
||||||
t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y);
|
t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y);
|
||||||
tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y);
|
tt.Location = new((Size.X / 2) - (tt.Size.X / 2), tt.Location.Y);
|
||||||
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(UsernameTextbox = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Username", Location = new((int)(27*Globals.Settings.Scale),(int)(280 * Globals.Settings.Scale)), Size = new((int)(261 * Globals.Settings.Scale),(int)(27 * Globals.Settings.Scale)), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan });
|
||||||
Controls.Add(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(Password = new Textbox(Globals.DefaultFont, Globals.DefaultFont) { TextLocation = TextLocation.TrueCenterLeft, WatermarkText = "Password", PasswordChar = '●', Location = new(UsernameTextbox.Location.X,(int)(365 * Globals.Settings.Scale)), Size = UsernameTextbox.Size, InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||||
Controls.Add(ca = new Label() { Font = Globals.DefaultFont, Location = new(UsernameTextbox.Location.X,(int)(419 * Globals.Settings.Scale)), Text = "Create Account" });
|
Controls.Add(ca = new Label(Globals.DefaultFont) { Location = new(UsernameTextbox.Location.X,(int)(419 * Globals.Settings.Scale)), 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 });
|
Controls.Add(button = new(Globals.DefaultFont) {Text = "Login", Location = new(UsernameTextbox.Location.X, (int)(455 * Globals.Settings.Scale)), Size = new(UsernameTextbox.Size.X,(int)(46 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan });
|
||||||
Password.KeyPress += PasswordOnKeyPress;
|
Password.KeyPress += PasswordOnKeyPress;
|
||||||
UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress;
|
UsernameTextbox.KeyPress += UsernameTextboxOnKeyPress;
|
||||||
button.Clicked += ButtonOnClicked;
|
button.Clicked += ButtonOnClicked;
|
||||||
|
@ -33,20 +33,20 @@ public class UpdateWindow : Window
|
|||||||
public UpdateWindow() : base(Settings)
|
public UpdateWindow() : base(Settings)
|
||||||
{
|
{
|
||||||
Label t;
|
Label t;
|
||||||
Controls.Add(t = new Label() { Font = Globals.DefaultFont, Scale = 1.2f, Location = new((int)(17.5*Globals.Settings.Scale)), Text = "Luski has detected that your\nclient is on an older version\nfor your branch."});
|
Controls.Add(t = new Label(Globals.DefaultFont) { Scale = 1.2f, Location = new((int)(17.5*Globals.Settings.Scale)), Text = "Luski has detected that your\nclient is on an older version\nfor your branch."});
|
||||||
if (!Globals.Empty(Globals.UpdaterSettings.Updater))
|
if (!Globals.Empty(Globals.UpdaterSettings.Updater))
|
||||||
{
|
{
|
||||||
t.Text += "\n\nWould you like to update?";
|
t.Text += "\n\nWould you like to update?";
|
||||||
Controls.Add(yes = new()
|
Controls.Add(yes = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Font = Globals.DefaultFont, Text = "Yes",
|
Text = "Yes",
|
||||||
Location = new(t.Location.X, t.Location.Y + t.Size.Y + (int)(t.Scale * t.Font.PixelHeight)),
|
Location = new(t.Location.X, t.Location.Y + t.Size.Y + (int)(t.Scale * t.Font.PixelHeight)),
|
||||||
Size = new(t.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255),
|
Size = new(t.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255),
|
||||||
BorderColor = Color4.DarkCyan
|
BorderColor = Color4.DarkCyan
|
||||||
});
|
});
|
||||||
Controls.Add(no = new()
|
Controls.Add(no = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Font = Globals.DefaultFont, Text = "No", Location = new(t.Location.X, yes.Location.Y + yes.Size.Y + 20),
|
Text = "No", Location = new(t.Location.X, yes.Location.Y + yes.Size.Y + 20),
|
||||||
Size = new(yes.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255),
|
Size = new(yes.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255),
|
||||||
BorderColor = Color4.DarkCyan
|
BorderColor = Color4.DarkCyan
|
||||||
});
|
});
|
||||||
@ -57,9 +57,9 @@ public class UpdateWindow : Window
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
t.Text += "\n\nNo updater path was set\nSet a path for auto updates";
|
t.Text += "\n\nNo updater path was set\nSet a path for auto updates";
|
||||||
Controls.Add(no = new()
|
Controls.Add(no = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Font = Globals.DefaultFont, Text = "Ok",
|
Text = "Ok",
|
||||||
Location = new(t.Location.X, t.Location.Y + t.Size.Y + (int)(t.Scale * t.Font.PixelHeight)),
|
Location = new(t.Location.X, t.Location.Y + t.Size.Y + (int)(t.Scale * t.Font.PixelHeight)),
|
||||||
Size = new(t.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255),
|
Size = new(t.Size.X, (int)(35.5 * Globals.Settings.Scale)), InsideColor = new(28, 28, 28, 255),
|
||||||
BorderColor = Color4.DarkCyan
|
BorderColor = Color4.DarkCyan
|
||||||
|
@ -1,23 +1,83 @@
|
|||||||
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization.Metadata;
|
using System.Text.Json.Serialization.Metadata;
|
||||||
|
using GraphicsManager;
|
||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using Luski.Clesses;
|
using Luski.Clesses;
|
||||||
using Luski.GUI.MainScreen;
|
using Luski.GUI.MainScreen;
|
||||||
using Luski.net;
|
using Luski.net;
|
||||||
|
using Luski.net.Interfaces;
|
||||||
|
using Luski.net.Structures.Public;
|
||||||
|
using OpenTK.Graphics.OpenGL4;
|
||||||
|
using OpenTK.Mathematics;
|
||||||
using OpenTK.Windowing.Common.Input;
|
using OpenTK.Windowing.Common.Input;
|
||||||
|
|
||||||
namespace Luski;
|
namespace Luski;
|
||||||
|
|
||||||
public class Globals
|
public static class Globals
|
||||||
{
|
{
|
||||||
#pragma warning disable CS8618
|
#pragma warning disable CS8618
|
||||||
public static bool Download { get; set; } = false;
|
public static bool Download { get; set; } = false;
|
||||||
public static API Luski { get; } = new();
|
public static API Luski { get; } = new();
|
||||||
public static MainScreen ms;
|
public static MainScreen ms;
|
||||||
|
private static Texture? gac;
|
||||||
|
|
||||||
|
public static Color4 ToColor4(this Color col)
|
||||||
|
{
|
||||||
|
return new(col.R, col.G, col.B, col.A);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Texture GetAlphaCircle(this TextureManager tm)
|
||||||
|
{
|
||||||
|
if (gac is null)
|
||||||
|
{
|
||||||
|
gac = tm.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
|
||||||
|
"Luski.Resources.Textures.Status.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return gac;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dictionary<long, Texture> UserTextureMap = new();
|
||||||
|
|
||||||
|
public static async Task<Texture> GetIcon(this SocketUser User)
|
||||||
|
{
|
||||||
|
if (UserTextureMap.TryGetValue(User.Id, out Texture? t)) return t;
|
||||||
|
Stream UserStream = await User.GetAvatar(CancellationToken.None);
|
||||||
|
t = Globals.ms.TextureManager.AddTexture(UserStream);
|
||||||
|
UserTextureMap.Add(User.Id, t);
|
||||||
|
UserStream.Dispose();
|
||||||
|
t.Unit = TextureUnit.Texture1;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<Texture> GetIcon(this IUser User)
|
||||||
|
{
|
||||||
|
if (UserTextureMap.TryGetValue(User.Id, out Texture? t)) return t;
|
||||||
|
Stream UserStream = await User.GetAvatar(CancellationToken.None);
|
||||||
|
t = Globals.ms.TextureManager.AddTexture(UserStream);
|
||||||
|
UserTextureMap.Add(User.Id, t);
|
||||||
|
UserStream.Dispose();
|
||||||
|
t.Unit = TextureUnit.Texture1;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
public static Settings Settings { get; set; }
|
public static Settings Settings { get; set; }
|
||||||
|
|
||||||
public static Font DefaultFont { get; set; }
|
public static FontFamily DefaultFontFamly { get; set; }
|
||||||
|
public static FontInteraction DefaultFont { get; set; }
|
||||||
|
public static FontInteraction TopTimeFont { get; set; }
|
||||||
|
public static FontInteraction MessageFont { get; set; }
|
||||||
|
public static FontInteraction SmallTimeFont { get; set; }
|
||||||
|
|
||||||
|
public static PublicServer? GetCurentPublicServer()
|
||||||
|
{
|
||||||
|
if (Luski.LoadedServers.Count > 0)
|
||||||
|
return Luski.LoadedServers[0];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static UpdaterSettings UpdaterSettings { get; set; }
|
public static UpdaterSettings UpdaterSettings { get; set; }
|
||||||
|
|
||||||
public static Texture LuskiTexture;
|
public static Texture LuskiTexture;
|
||||||
|
8
Luski/Interfaces/IThemeObject.cs
Normal file
8
Luski/Interfaces/IThemeObject.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
using GraphicsManager.Interfaces;
|
||||||
|
|
||||||
|
namespace Luski.Interfaces;
|
||||||
|
|
||||||
|
public interface IThemeObject
|
||||||
|
{
|
||||||
|
public IRenderObject MakeObject(params object[] param);
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<FileVersion>1.1.0.1</FileVersion>
|
<FileVersion>1.1.0.1</FileVersion>
|
||||||
@ -19,14 +19,15 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GraphicsManager" Version="1.0.5-alpha74" />
|
<PackageReference Include="GraphicsManager" Version="1.0.6-alpha89" />
|
||||||
<PackageReference Include="Luski.net" Version="1.1.3-alpha25" />
|
<PackageReference Include="Luski.net" Version="2.0.0-alpha12" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources/**"></EmbeddedResource>
|
<EmbeddedResource Include="Resources/**"></EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ApplicationIcon>Luski.ico</ApplicationIcon>
|
<ApplicationIcon>Luski.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -1,32 +1,57 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using GraphicsManager;
|
||||||
using Luski;
|
using Luski;
|
||||||
using Luski.Clesses;
|
using Luski.Clesses;
|
||||||
using Luski.GUI.MainScreen;
|
using Luski.GUI.MainScreen;
|
||||||
|
using Luski.net;
|
||||||
using OpenTK.Windowing.Common.Input;
|
using OpenTK.Windowing.Common.Input;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
using Image = OpenTK.Windowing.Common.Input.Image;
|
using Image = OpenTK.Windowing.Common.Input.Image;
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Globals.Settings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
|
Globals.Settings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
|
||||||
_ = Globals.Luski.GetMainServer(Globals.Settings.Domain, Globals.Settings.Version);
|
ServerList serverlist = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Servers.json"), ServerListContext.Default.ServerList);
|
||||||
_ = Globals.Luski.GetPublicServer("TCLL.Luski.JacobTech.com", Globals.Settings.Version);
|
List<Task<PublicServer>> bbb = new();
|
||||||
Console.WriteLine("Conecting to main server '{0}' using API {1}", Globals.Luski.MainServer.Domain, Globals.Luski.MainServer.ApiVersion);
|
if (serverlist.Server.Length > 0)
|
||||||
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);
|
foreach (ServerInfo server in serverlist.Server)
|
||||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
{
|
||||||
Stream? resource_stream = assembly.GetManifestResourceStream($"Luski.Resources.Textures.Luski.png");
|
switch (server.Main)
|
||||||
MemoryStream ms = new();
|
{
|
||||||
resource_stream?.CopyTo(ms);
|
case false:
|
||||||
var Logo = SixLabors.ImageSharp.Image.Load<Rgba32>(ms.ToArray());
|
bbb.Add(Globals.Luski.GetPublicServer(server.Domain, server.Version, server.Secure));
|
||||||
|
break;
|
||||||
|
case true:
|
||||||
|
Globals.Luski.GetMainServer(server.Domain, server.Version);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Span<byte> pixels = new byte[4 * Logo.Width * Logo.Height].AsSpan();
|
//var ttttt = GraphicsManager.Tools.GetFamilyList("fc-list ':' family");
|
||||||
|
//var ffff = GraphicsManager.Tools.GetFontList($"fc-list ':'family='{ttttt[new Random().Next(0, ttttt.Length)]}' file");
|
||||||
|
|
||||||
|
Globals.UpdaterSettings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
|
||||||
|
//Globals.Luski.LoadedServers.First().CreateAccount("JacobTech", "JacobGuin12173*", "JacobTech", "/home/jacob/Pictures/Logo.png", CancellationToken.None);
|
||||||
|
Task.WaitAll(bbb.ToArray());
|
||||||
|
if (!Globals.Luski.LoadedServers.First().IsLogedIn)
|
||||||
|
_ = Globals.Luski.LoadedServers.First().Login("JacobTech", "JacobGuin12173*", CancellationToken.None).Result;
|
||||||
|
Image<Rgba32> Logo = SixLabors.ImageSharp.Image.Load<Rgba32>(Tools.GetResourceStream(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Luski.png"));
|
||||||
|
Logo.DangerousTryGetSinglePixelMemory(out Memory<Rgba32> m);
|
||||||
|
byte[] pixels = new byte[4 * Logo.Width * Logo.Height];
|
||||||
Logo.CopyPixelDataTo(pixels);
|
Logo.CopyPixelDataTo(pixels);
|
||||||
|
|
||||||
Globals.Icon = new WindowIcon(new Image(Logo.Width, Logo.Height, pixels.ToArray()));
|
Globals.Icon = new WindowIcon(new Image(Logo.Width, Logo.Height, pixels));
|
||||||
|
|
||||||
|
Logo.Dispose();
|
||||||
Globals.ms = new MainScreen();
|
Globals.ms = new MainScreen();
|
||||||
|
Globals.ms.CustomF11 = false;
|
||||||
|
Globals.ms.DrawFrame();
|
||||||
|
Globals.ms.Cursor = new MouseCursor(0, 0, Logo.Width, Logo.Height, pixels);
|
||||||
|
pixels = Array.Empty<byte>();
|
||||||
Globals.ms.StartRender();
|
Globals.ms.StartRender();
|
||||||
Globals.ms.Dispose();
|
Globals.ms.Dispose();
|
||||||
}
|
}
|
||||||
|
BIN
Luski/Resources/Textures/ac.png
Normal file
BIN
Luski/Resources/Textures/ac.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 406 B |
BIN
Luski/Resources/Textures/al.png
Normal file
BIN
Luski/Resources/Textures/al.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 943 B |
BIN
Luski/Resources/Textures/ar.png
Normal file
BIN
Luski/Resources/Textures/ar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 845 B |
BIN
Luski/Resources/Textures/rc.png
Normal file
BIN
Luski/Resources/Textures/rc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
242
Luski/Temp.cs
Normal file
242
Luski/Temp.cs
Normal file
@ -0,0 +1,242 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace Luski;
|
||||||
|
|
||||||
|
public class Temp
|
||||||
|
{
|
||||||
|
internal static string pw = "bobbob";
|
||||||
|
|
||||||
|
public static class File
|
||||||
|
{
|
||||||
|
internal static void SetOfflineKey(string key)
|
||||||
|
{
|
||||||
|
MakeFile("Server.GetKeyFilePath", pw);
|
||||||
|
LuskiDataFile? fileLayout = JsonSerializer.Deserialize<LuskiDataFile>(FileString("Server.GetKeyFilePath", pw));
|
||||||
|
fileLayout.OfflineKey = key;
|
||||||
|
fileLayout.Save("Server.GetKeyFilePath", pw);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
internal static string? GetOfflineKey()
|
||||||
|
{
|
||||||
|
MakeFile("/home/jacob/.config/JacobTech/Luski/Dev/win-x64/Data/1/keys.lsk", pw);
|
||||||
|
LuskiDataFile? fileLayout = JsonSerializer.Deserialize<LuskiDataFile>(FileString("Server.GetKeyFilePath", pw));
|
||||||
|
return fileLayout?.OfflineKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LuskiDataFile GetFile()
|
||||||
|
{
|
||||||
|
MakeFile("/home/jacob/.config/JacobTech/Luski/Dev/win-x64/Data/2/keys.lsk", pw);
|
||||||
|
return JsonSerializer.Deserialize<LuskiDataFile>(FileString("/home/jacob/.config/JacobTech/Luski/Dev/win-x64/Data/2/keys.lsk", pw))!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string FileString(string path, string password)
|
||||||
|
{
|
||||||
|
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
|
||||||
|
byte[] salt = new byte[100];
|
||||||
|
FileStream fsCrypt = new(path, FileMode.Open);
|
||||||
|
fsCrypt.Read(salt, 0, salt.Length);
|
||||||
|
RijndaelManaged AES = new()
|
||||||
|
{
|
||||||
|
KeySize = 256,
|
||||||
|
BlockSize = 128
|
||||||
|
};
|
||||||
|
Rfc2898DeriveBytes key = new(passwordBytes, salt, 50000);
|
||||||
|
AES.Key = key.GetBytes(AES.KeySize / 8);
|
||||||
|
AES.IV = key.GetBytes(AES.BlockSize / 8);
|
||||||
|
AES.Padding = PaddingMode.PKCS7;
|
||||||
|
AES.Mode = CipherMode.CFB;
|
||||||
|
CryptoStream cs = new(fsCrypt, AES.CreateDecryptor(), CryptoStreamMode.Read);
|
||||||
|
MemoryStream fsOut = new();
|
||||||
|
int read;
|
||||||
|
byte[] buffer = new byte[1048576];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while ((read = cs.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
fsOut.Write(buffer, 0, read);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (CryptographicException ex_CryptographicException)
|
||||||
|
{
|
||||||
|
Console.WriteLine("CryptographicException error: " + ex_CryptographicException.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error: " + ex.Message);
|
||||||
|
}
|
||||||
|
fsOut.Seek(0, SeekOrigin.Begin);
|
||||||
|
using BinaryReader reader = new(fsOut);
|
||||||
|
byte[] by = reader.ReadBytes((int)fsOut.Length);
|
||||||
|
fsOut.Close();
|
||||||
|
fsCrypt.Close();
|
||||||
|
return Encoding.UTF8.GetString(by);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Channels
|
||||||
|
{
|
||||||
|
private static string GetKey(long channel)
|
||||||
|
{
|
||||||
|
LuskiDataFile? fileLayout;
|
||||||
|
IEnumerable<ChannelLayout>? lis;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
#pragma warning disable CS8603 // Possible null reference return.
|
||||||
|
// if (channel == 0) return myPrivateKey;
|
||||||
|
#pragma warning restore CS8603 // Possible null reference return.
|
||||||
|
MakeFile("Server.GetKeyFilePath", pw);
|
||||||
|
fileLayout = JsonSerializer.Deserialize<LuskiDataFile>(FileString("Server.GetKeyFilePath", pw));
|
||||||
|
lis = fileLayout?.channels?.Where(s => s.id == channel);
|
||||||
|
if (lis?.Count() > 0)
|
||||||
|
{
|
||||||
|
return lis.First().key;
|
||||||
|
}
|
||||||
|
throw new Exception("You dont have a key for that channel");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
fileLayout = null;
|
||||||
|
lis = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string GetKeyBranch(long channel)
|
||||||
|
{
|
||||||
|
LuskiDataFile? fileLayout;
|
||||||
|
IEnumerable<ChannelLayout>? lis;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
#pragma warning disable CS8603 // Possible null reference return.
|
||||||
|
// if (channel == 0) return myPrivateKey;
|
||||||
|
#pragma warning restore CS8603 // Possible null reference return.
|
||||||
|
MakeFile("Server.GetKeyFilePathBr(branch.ToString())", pw);
|
||||||
|
fileLayout = JsonSerializer.Deserialize<LuskiDataFile>(FileString("", pw));
|
||||||
|
lis = fileLayout?.channels?.Where(s => s.id == channel);
|
||||||
|
if (lis?.Count() > 0)
|
||||||
|
{
|
||||||
|
return lis.First().key;
|
||||||
|
}
|
||||||
|
throw new Exception("You dont have a key for that channel");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
fileLayout = null;
|
||||||
|
lis = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddKey(long channel, string key)
|
||||||
|
{
|
||||||
|
MakeFile("Server.GetKeyFilePath", pw);
|
||||||
|
LuskiDataFile? fileLayout = JsonSerializer.Deserialize<LuskiDataFile>(FileString("Server.GetKeyFilePath", pw));
|
||||||
|
fileLayout?.Addchannelkey(channel, key);
|
||||||
|
fileLayout?.Save("Server.GetKeyFilePath", pw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void MakeFile(string dir, string password)
|
||||||
|
{
|
||||||
|
if (!System.IO.File.Exists(dir))
|
||||||
|
{
|
||||||
|
LuskiDataFile? l = JsonSerializer.Deserialize<LuskiDataFile>("{\"channels\":[]}");
|
||||||
|
l?.Save(dir, password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LuskiDataFile
|
||||||
|
{
|
||||||
|
public static LuskiDataFile GetDataFile(string path, string password)
|
||||||
|
{
|
||||||
|
MakeFile(path, password);
|
||||||
|
return JsonSerializer.Deserialize<LuskiDataFile>(FileString(path, password));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static LuskiDataFile GetDefualtDataFile()
|
||||||
|
{
|
||||||
|
return GetDataFile("Server.GetKeyFilePath", pw);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelLayout[]? channels { get; set; } = default!;
|
||||||
|
|
||||||
|
public string? OfflineKey { get; set; } = default!;
|
||||||
|
|
||||||
|
public void Save(string file, string password)
|
||||||
|
{
|
||||||
|
byte[] salt = new byte[100];
|
||||||
|
RandomNumberGenerator? provider = RandomNumberGenerator.Create();
|
||||||
|
provider.GetBytes(salt);
|
||||||
|
FileStream fsCrypt = new(file, FileMode.Create);
|
||||||
|
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
|
||||||
|
RijndaelManaged AES = new()
|
||||||
|
{
|
||||||
|
KeySize = 256,
|
||||||
|
BlockSize = 128,
|
||||||
|
Padding = PaddingMode.PKCS7
|
||||||
|
};
|
||||||
|
Rfc2898DeriveBytes key = new(passwordBytes, salt, 50000);
|
||||||
|
AES.Key = key.GetBytes(AES.KeySize / 8);
|
||||||
|
AES.IV = key.GetBytes(AES.BlockSize / 8);
|
||||||
|
AES.Mode = CipherMode.CFB;
|
||||||
|
fsCrypt.Write(salt, 0, salt.Length);
|
||||||
|
CryptoStream cs = new(fsCrypt, AES.CreateEncryptor(), CryptoStreamMode.Write);
|
||||||
|
string tempp = JsonSerializer.Serialize(this);
|
||||||
|
MemoryStream fsIn = new(Encoding.UTF8.GetBytes(tempp));
|
||||||
|
byte[] buffer = new byte[1048576];
|
||||||
|
int read;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while ((read = fsIn.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
cs.Write(buffer, 0, read);
|
||||||
|
}
|
||||||
|
fsIn.Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error: " + ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
cs.Close();
|
||||||
|
fsCrypt.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Addchannelkey(long chan, string Key)
|
||||||
|
{
|
||||||
|
List<ChannelLayout>? chans = channels?.ToList();
|
||||||
|
if (chans is null) chans = new();
|
||||||
|
if (!(chans?.Where(s => s.id == chan).Count() > 0))
|
||||||
|
{
|
||||||
|
ChannelLayout l = new()
|
||||||
|
{
|
||||||
|
id = chan,
|
||||||
|
key = Key
|
||||||
|
};
|
||||||
|
chans?.Add(l);
|
||||||
|
channels = chans?.ToArray();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chans.Remove(chans.Where(s => s.id == chan).First());
|
||||||
|
ChannelLayout l = new()
|
||||||
|
{
|
||||||
|
id = chan,
|
||||||
|
key = Key
|
||||||
|
};
|
||||||
|
chans?.Add(l);
|
||||||
|
channels = chans?.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ChannelLayout
|
||||||
|
{
|
||||||
|
public long id { get; set; } = default!;
|
||||||
|
public string key { get; set; } = default!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user