dev #17
@ -1,5 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using GraphicsManager;
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
@ -12,6 +14,7 @@ using Luski.net;
|
||||
using Luski.net.Enums;
|
||||
using Luski.net.Interfaces;
|
||||
using Luski.net.JsonTypes;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using OpenTK.Windowing.Common;
|
||||
@ -28,7 +31,8 @@ public class MainScreen : Window
|
||||
APIVersion = new Version(3, 2),
|
||||
StartFocused = true,
|
||||
Size = new Vector2i((int)(240.5 * Globals.Settings.Scale), (int)(419 * Globals.Settings.Scale)),
|
||||
Icon = Globals.Icon
|
||||
Icon = Globals.Icon,
|
||||
SharedContext = null
|
||||
};
|
||||
|
||||
private TabControl tc;
|
||||
@ -37,10 +41,50 @@ public class MainScreen : Window
|
||||
public Chat? chat;
|
||||
Login login;
|
||||
CreateAccount ca;
|
||||
private static DebugProc DebugMessageDelegate = OnDebugMessage;
|
||||
private static void OnDebugMessage(
|
||||
DebugSource source, // Source of the debugging message.
|
||||
DebugType type, // Type of the debugging message.
|
||||
int id, // ID associated with the message.
|
||||
DebugSeverity severity, // Severity of the message.
|
||||
int length, // Length of the string in pMessage.
|
||||
IntPtr pMessage, // Pointer to message string.
|
||||
IntPtr pUserParam) // The pointer you gave to OpenGL, explained later.
|
||||
{
|
||||
// In order to access the string pointed to by pMessage, you can use Marshal
|
||||
// class to copy its contents to a C# string without unsafe code. You can
|
||||
// also use the new function Marshal.PtrToStringUTF8 since .NET Core 1.1.
|
||||
string message = Marshal.PtrToStringAnsi(pMessage, length);
|
||||
|
||||
// The rest of the function is up to you to implement, however a debug output
|
||||
// is always useful.
|
||||
|
||||
return;
|
||||
switch (severity)
|
||||
{
|
||||
case DebugSeverity.DebugSeverityHigh:
|
||||
Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
|
||||
Console.ResetColor();
|
||||
break;
|
||||
case DebugSeverity.DebugSeverityMedium:
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message);
|
||||
Console.ResetColor();
|
||||
break;
|
||||
default:
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine(message);
|
||||
Console.ResetColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public MainScreen() : base(Settings)
|
||||
{
|
||||
VSync = VSyncMode.On;
|
||||
GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero);
|
||||
GL.Enable(EnableCap.DebugOutput);
|
||||
Globals.DefaultFont =
|
||||
Font.MakeEmbeddedFont("Luski.Resources.Fonts.OpenSans-Regular.ttf", Assembly.GetExecutingAssembly());
|
||||
Globals.DefaultFont.PixelHeight = (uint)(12 * Globals.Settings.Scale);
|
||||
@ -53,6 +97,7 @@ public class MainScreen : Window
|
||||
ca.Visible = false;
|
||||
ca.ChangeToApp += LoginOnChangeToApp;
|
||||
Controls.Add(login = new Login());
|
||||
|
||||
login.ChangeToApp += LoginOnChangeToApp;
|
||||
login.ChangeToCa += LoginOnChangeToCa;
|
||||
|
||||
@ -62,9 +107,17 @@ public class MainScreen : Window
|
||||
|
||||
});
|
||||
t.Start();
|
||||
WindowLoaded += OnWindowLoaded;
|
||||
WindowLoaded += OnWindowLoadedd;
|
||||
}
|
||||
|
||||
private Task OnWindowLoadedd(Window arg)
|
||||
{
|
||||
Console.WriteLine(login.r.Location.Y);
|
||||
Console.WriteLine(login.r.ScissorLocation.Y);
|
||||
Console.WriteLine(login.r.Location.X);
|
||||
Console.WriteLine(login.r.ScissorLocation.X);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private Task OnWindowLoaded(Window arg)
|
||||
{
|
||||
if (Globals.UpdaterSettings.AutoUpdateCheck && new HttpClient().GetAsync($"https://www.jacobtech.com/Updater/GetProgramVersion?directory=Luski&branch={Globals.UpdaterSettings.Branch}&selfcontained={Globals.UpdaterSettings.SelfContained.ToString().ToLower()}&platform={Globals.UpdaterSettings.Platform}").Result.Content.ReadAsStringAsync().Result != FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion)
|
||||
@ -168,13 +221,13 @@ public class MainScreen : Window
|
||||
|
||||
foreach (SocketMessage message in messages.Reverse())
|
||||
{
|
||||
if (channelCancellationToken.Token.IsCancellationRequested) return;
|
||||
if (channelCancellationToken is null || channelCancellationToken.Token.IsCancellationRequested) return;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
chat!.AddMessage(message);
|
||||
chat!.AddMessage(TextureManager, message);
|
||||
}));
|
||||
}
|
||||
if (channelCancellationToken.Token.IsCancellationRequested) return;
|
||||
if (channelCancellationToken is null || channelCancellationToken.Token.IsCancellationRequested) return;
|
||||
channelCancellationToken = null;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
@ -211,10 +264,10 @@ public class MainScreen : Window
|
||||
DateTime start1 = DateTime.Now;
|
||||
WindowBorder = WindowBorder.Resizable;
|
||||
BackgroundColor = new Color4(34, 34, 34, 255);
|
||||
Controls.Add(new Rectangle(TextureManager.AddTexture(Globals.Luski.CurrentUser.GetAvatar(CancellationToken.None).Result)) { Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Size = new((int)(35 * Globals.Settings.Scale)), Location = new((int)(47 * Globals.Settings.Scale), (int)(624 * Globals.Settings.Scale))});
|
||||
Controls.Add(new Rectangle(TextureManager.AddTexture(Globals.Luski.CurrentUser.GetAvatar(CancellationToken.None).Result, true)) { Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Size = new((int)(35 * Globals.Settings.Scale)), Location = new((int)(47 * Globals.Settings.Scale), (int)(624 * Globals.Settings.Scale))});
|
||||
Controls.Add(new Label(){ Font = Globals.DefaultFont, Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left, Location = new((int)(86 * Globals.Settings.Scale), (int)(635.5 * Globals.Settings.Scale)), Text = Globals.Luski.CurrentUser.Username});
|
||||
FlowLayout ser;
|
||||
Controls.Add(chat = new(this) {Location = new((int)(270 * Globals.Settings.Scale),0)});
|
||||
Controls.Add(chat = new() {Location = new((int)(270 * Globals.Settings.Scale),0)});
|
||||
Controls.Add(ser = new FlowLayout()
|
||||
{
|
||||
BackgroundColor = new(26, 26, 26, 255),
|
||||
@ -246,7 +299,6 @@ public class MainScreen : Window
|
||||
{
|
||||
Size = new((int)(40 * Globals.Settings.Scale)),
|
||||
});
|
||||
|
||||
Controls.Add(channelpicker = new FlowLayout()
|
||||
{
|
||||
BackgroundColor = new(34,34,34,255),
|
||||
@ -269,13 +321,14 @@ public class MainScreen : Window
|
||||
|
||||
SocketTextChannel chan = Globals.Luski.GetChannel<SocketTextChannel>(Globals.Luski.CurrentUser.SelectedChannel, CancellationToken.None).Result;
|
||||
chat.UpdateTitle(chans.First(s => s.Channel.Id == chan.Id));
|
||||
chat.MessageFlow.BlockDraw = true;
|
||||
try
|
||||
{
|
||||
IReadOnlyList<SocketMessage> messages = chan.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel).Result;
|
||||
Console.WriteLine("Messages done in " + (DateTime.Now - start).TotalSeconds + " seconds");
|
||||
foreach (SocketMessage message in messages.Reverse())
|
||||
{
|
||||
chat.AddMessage(message);
|
||||
chat.AddMessage(TextureManager, message);
|
||||
}
|
||||
chat.MessageFlow.ScrollToBottom();
|
||||
}
|
||||
@ -284,7 +337,8 @@ public class MainScreen : Window
|
||||
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 (SocketRemoteUser cufr in Globals.Luski.CurrentUser.FriendRequests)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using Luski.GUI.MainScreen.Interfaces;
|
||||
using Luski.net;
|
||||
using Luski.net.Enums;
|
||||
@ -14,13 +15,12 @@ namespace Luski.GUI.MainScreen.UI;
|
||||
public class Chat : UserControl
|
||||
{
|
||||
public FlowLayout MessageFlow;
|
||||
private UserControl titlecon, typecon;
|
||||
private UserControl titlecon;//, typecon;
|
||||
private Label title, desc;
|
||||
private Textbox tb;
|
||||
private SocketTextChannel? Channel = null;
|
||||
public Chat(MainScreen screen)
|
||||
public Chat()
|
||||
{
|
||||
screen.MainShow += ScreenOnMainShow;
|
||||
Size = new((int)(754 * Globals.Settings.Scale), (int)(667 * Globals.Settings.Scale));
|
||||
BackgroundColor = new(50, 50, 50, 255);
|
||||
Anchor = ObjectAnchor.All;
|
||||
@ -33,7 +33,7 @@ public class Chat : UserControl
|
||||
HScrollPixels = Globals.Settings.PerScrollPixels
|
||||
});
|
||||
Controls.Add(titlecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right, Size = new((int)(754 * Globals.Settings.Scale), (int)(40 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
|
||||
Controls.Add(typecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Bottom | ObjectAnchor.Right, Location = new(0, (int)(626 * Globals.Settings.Scale)), Size = new((int)(754 * Globals.Settings.Scale), (int)(41 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
|
||||
//Controls.Add(typecon = new UserControl(){Anchor = ObjectAnchor.Left | ObjectAnchor.Bottom | ObjectAnchor.Right, Location = new(0, (int)(626 * Globals.Settings.Scale)), Size = new((int)(754 * Globals.Settings.Scale), (int)(41 * Globals.Settings.Scale)), BackgroundColor = BackgroundColor});
|
||||
titlecon.Controls.Add(title = new Label()
|
||||
{
|
||||
Font = Globals.DefaultFont, Location = new(
|
||||
@ -41,22 +41,18 @@ public class Chat : UserControl
|
||||
(int)((20 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight / 2)))
|
||||
});
|
||||
titlecon.Controls.Add(desc = new Label(){ Font = Globals.DefaultFont, Color = new(161,161,161,255), Location = new(title.Location.X + title.Size.X + 5, title.Location.Y)});
|
||||
typecon.Controls.Add(tb = new Textbox()
|
||||
//typecon.Controls.Add();
|
||||
Controls.Add(tb = new Textbox()
|
||||
{
|
||||
Font = Globals.DefaultFont,
|
||||
InsideColor = new(28, 28, 28, 255),
|
||||
BorderColor = Color4.DarkCyan,
|
||||
Location = new((int)(7.5 * Globals.Settings.Scale)),
|
||||
Location = new((int)(7.5 * Globals.Settings.Scale), (int)(633.5 * Globals.Settings.Scale)),
|
||||
Size = new((int)(739 * Globals.Settings.Scale), (int)(26 * Globals.Settings.Scale)),
|
||||
Anchor = ObjectAnchor.All
|
||||
});
|
||||
tb.KeyPress += TbOnKeyPress;
|
||||
}
|
||||
|
||||
private Task ScreenOnMainShow()
|
||||
{
|
||||
Globals.Luski.MessageReceived += LuskiOnMessageReceived;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task TbOnKeyPress(KeyboardKeyEventArgs arg)
|
||||
@ -78,7 +74,7 @@ public class Chat : UserControl
|
||||
if (Channel!.Id != arg.ChannelID) return Task.CompletedTask;
|
||||
IRenderObject? reff = null;
|
||||
if (MessageFlow.Controls.Length > 0) reff = MessageFlow.Controls[MessageFlow.Controls.Length - 1];
|
||||
AddMessage(arg);
|
||||
AddMessage(Window!.TextureManager, arg);
|
||||
if (reff is null || (reff.Location.Y + reff.Size.Y <= MessageFlow.Size.Y && reff.Location.X >= 0)) Window.Invoke(new Action(() => { MessageFlow.ScrollToBottom();}));
|
||||
|
||||
return Task.CompletedTask;
|
||||
@ -116,7 +112,7 @@ public class Chat : UserControl
|
||||
private long? lastUser = null;
|
||||
private ChatMessage? LastChatMessage = null;
|
||||
|
||||
public void AddMessage(SocketMessage Message)
|
||||
public void AddMessage(TextureManager m, SocketMessage Message)
|
||||
{
|
||||
bool hasbeentenmin = false;
|
||||
if (lastm is not null)
|
||||
@ -126,17 +122,21 @@ public class Chat : UserControl
|
||||
lastm = Message;
|
||||
if (lastUser is null || lastUser != Message.AuthorID || hasbeentenmin)
|
||||
{
|
||||
if (Window is null || !Window.InvokeRequired)
|
||||
MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(Message));
|
||||
if (Window is null || !Globals.ms.InvokeRequired)
|
||||
{
|
||||
MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(m, Message));
|
||||
}
|
||||
else
|
||||
Window!.Invoke(new Action(() => { MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(Message)); Window.DrawFrame(); }));
|
||||
Globals.ms!.Invoke(new Action(() => { MessageFlow.Controls.Add(LastChatMessage = new ChatMessage(m ,Message)); Window.DrawFrame(); }));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Window is null || !Window.InvokeRequired)
|
||||
if (Window is null || !Globals.ms.InvokeRequired)
|
||||
{
|
||||
LastChatMessage!.AddMessage(Message);
|
||||
}
|
||||
else
|
||||
Window!.Invoke(new Action(() => { LastChatMessage!.AddMessage(Message); Window!.DrawFrame(); }));
|
||||
Globals.ms!.Invoke(new Action(() => { LastChatMessage!.AddMessage(Message); Window!.DrawFrame(); }));
|
||||
}
|
||||
|
||||
lastUser = Message.AuthorID;
|
||||
|
@ -20,7 +20,7 @@ public class ChatMessage : UserControl
|
||||
private static Dictionary<SocketRemoteUser, ContextMenu> Menues = new();
|
||||
private static Dictionary<SocketRemoteUser, List<ChatMessage>> Messages = new();
|
||||
|
||||
public ChatMessage(SocketMessage message)
|
||||
public ChatMessage(TextureManager tm, SocketMessage message)
|
||||
{
|
||||
Size = new((int)(723.5 * Globals.Settings.Scale), (int)(37 * Globals.Settings.Scale));
|
||||
|
||||
@ -48,7 +48,7 @@ public class ChatMessage : UserControl
|
||||
timestr = $"{time:M/dd/yyyy h:mm tt}";
|
||||
}
|
||||
Controls.Add(new Label() { Font = Globals.DefaultFont, Location = new(label1.Location.X + label1.Size.X + 4, (int)(4.5 * Globals.Settings.Scale)), Text = timestr});
|
||||
Controls.Add(new Rectangle(Globals.ms.TextureManager.AddTexture(user.GetAvatar(CancellationToken.None).Result)) { Location = new((int)(7.5 * Globals.Settings.Scale), (int)(1.5 * Globals.Settings.Scale)), Size = new((int)(29 * Globals.Settings.Scale)) });
|
||||
Controls.Add(new Rectangle(tm.AddTexture(user.GetAvatar(CancellationToken.None).Result, true)) { Location = new((int)(7.5 * Globals.Settings.Scale), (int)(1.5 * Globals.Settings.Scale)), Size = new((int)(29 * Globals.Settings.Scale)) });
|
||||
Controls.Add(label2 = new Label() { Font = Globals.DefaultFont, Location = new((int)(41.5 * Globals.Settings.Scale), (int)(20 * Globals.Settings.Scale)), Text = message.Context});
|
||||
lastm = label2;
|
||||
if (Msg.Files != null && Msg.Files.Length > 0)
|
||||
|
@ -1,9 +1,16 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using Luski.GUI.MainScreen.Interfaces;
|
||||
using Luski.GUI.Windows;
|
||||
using Luski.net.JsonTypes;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
using Window = GraphicsManager.Window;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI;
|
||||
|
||||
@ -25,20 +32,45 @@ public class Friend : UserControl, IChannelPick
|
||||
User = person;
|
||||
Size = new((int)(185 * Globals.Settings.Scale), (int)(48* Globals.Settings.Scale));
|
||||
BackgroundColor = new(34, 34, 34, 255);
|
||||
Controls.Add( r = new Rectangle(Globals.ms.TextureManager.AddTexture(person.GetAvatar(CancellationToken.None).Result)) { Location = new((int)(7.5 * Globals.Settings.Scale),(int)(8.5 * Globals.Settings.Scale)), Size = new((int)(29* Globals.Settings.Scale))});
|
||||
Controls.Add( r = new Rectangle(Globals.ms.TextureManager.AddTexture(person.GetAvatar(CancellationToken.None).Result, true)) { Location = new((int)(7.5 * Globals.Settings.Scale),(int)(8.5 * Globals.Settings.Scale)), Size = new((int)(29* Globals.Settings.Scale))});
|
||||
Controls.Add(Username = new Label() { Font = Globals.DefaultFont, Text = person.Username, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(10 * Globals.Settings.Scale))});
|
||||
Controls.Add(Status = new Label() { Font = Globals.DefaultFont, Text = person.Status.ToString(), Location = new((int)(38.5 * Globals.Settings.Scale),(int)(24 * Globals.Settings.Scale))});
|
||||
this.Clicked += AllOnClicked;
|
||||
ContextMenu = new((int)(150 * Globals.Settings.Scale));
|
||||
RoundedButton rr;
|
||||
RoundedButton rr, rr2;
|
||||
ContextMenu.Items.Add(rr=new()
|
||||
{
|
||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
||||
Size = new((int)(25 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Export Keys"
|
||||
});
|
||||
ContextMenu.Items.Add(rr2=new()
|
||||
{
|
||||
InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan,
|
||||
Size = new((int)(25 * Globals.Settings.Scale)), Font = Globals.DefaultFont, Text = "Open In New Window"
|
||||
});
|
||||
rr2.Clicked += Rr2OnClicked;
|
||||
rr.Clicked += RrOnClicked;
|
||||
}
|
||||
|
||||
private Task Rr2OnClicked(IRenderObject arg)
|
||||
{
|
||||
GLFW.WindowHint(WindowHintBool.Decorated, false);
|
||||
ChatWindow w = new(this);
|
||||
|
||||
//w.WindowBorder = WindowBorder.Resizable;
|
||||
// ContextMenu!.HideContext(Window!);
|
||||
//Window!.DrawFrame();
|
||||
w.StartRender();
|
||||
//w.IsEventDriven = true;
|
||||
//Window.Windows.Add(w);
|
||||
//w.StartRenderAsync();
|
||||
//w.StartRender();
|
||||
//ContextMenu!.HideContext(Window!);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Task RrOnClicked(IRenderObject arg)
|
||||
{
|
||||
_ = User.Channel!.SendKeysToUsers(CancellationToken.None);
|
||||
|
@ -20,7 +20,7 @@ public class FriendRequest : UserControl
|
||||
this.Screen = Parent;
|
||||
Size = new((int)(200 * Globals.Settings.Scale), (int)(48* Globals.Settings.Scale));
|
||||
BackgroundColor = new(34, 34, 34, 255);
|
||||
Controls.Add(new Rectangle(Globals.ms.TextureManager.AddTexture(User.GetAvatar(CancellationToken.None).Result)) { 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))});
|
||||
Controls.Add(new Label() { Font = Globals.DefaultFont, Text = User.Username, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(10 * Globals.Settings.Scale))});
|
||||
Controls.Add(new Label() { Font = Globals.DefaultFont, Text = User.FriendStatus.ToString(), Location = new((int)(38.5 * Globals.Settings.Scale),(int)(24 * Globals.Settings.Scale))});
|
||||
if (User.FriendStatus == FriendStatus.PendingIn)
|
||||
|
@ -18,7 +18,7 @@ public class Group : UserControl, IChannelPick
|
||||
Channel = chan;
|
||||
Size = new((int)(185 * Globals.Settings.Scale), (int)(48* Globals.Settings.Scale));
|
||||
BackgroundColor = new(34, 34, 34, 255);
|
||||
Controls.Add( r = new Rectangle(Globals.ms.TextureManager.AddTexture(chan.GetPicture(CancellationToken.None).Result)) { Location = new((int)(7.5 * Globals.Settings.Scale),(int)(8.5 * Globals.Settings.Scale)), Size = new((int)(29* Globals.Settings.Scale))});
|
||||
Controls.Add( r = new Rectangle(Globals.ms.TextureManager.AddTexture(chan.GetPicture(CancellationToken.None).Result, true)) { Location = new((int)(7.5 * Globals.Settings.Scale),(int)(8.5 * Globals.Settings.Scale)), Size = new((int)(29* Globals.Settings.Scale))});
|
||||
Controls.Add(Username = new Label() { Font = Globals.DefaultFont, Text = chan.Title, Location = new((int)(38.5 * Globals.Settings.Scale),(int)(10 * Globals.Settings.Scale))});
|
||||
string sl = "Online";
|
||||
if (chan.Id != 0)
|
||||
|
@ -46,10 +46,12 @@ public class CreateAccount : UserControl
|
||||
private Task RecOnFilesDroped(string[] arg)
|
||||
{
|
||||
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;
|
||||
Controls.Remove(rec);
|
||||
|
||||
pfp = arg[0];
|
||||
rec = new(Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]))){ Location = new(350, 585), Size = new(100) };
|
||||
Controls.Add(rec);
|
||||
if (rec.Texture is null)
|
||||
{Controls.Remove(rec);rec = new(Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]), true)){ Location = new(350, 585), Size = new(100) };Controls.Add(rec);}
|
||||
else rec.Texture = Globals.ms.TextureManager.AddTexture(File.ReadAllBytes(arg[0]), true);
|
||||
|
||||
Window!.DrawFrame();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
using SixLabors.ImageSharp.Drawing.Processing;
|
||||
|
||||
namespace Luski.GUI.StartPage.UI;
|
||||
|
||||
@ -15,10 +16,11 @@ public class Login : UserControl
|
||||
private Label ca;
|
||||
public event Func<Task>? ChangeToApp;
|
||||
public event Func<Task>? ChangeToCa;
|
||||
public Rectangle r;
|
||||
public Login()
|
||||
{
|
||||
Size = new((int)(240.5*Globals.Settings.Scale), (int)(419*Globals.Settings.Scale));
|
||||
Controls.Add(new Rectangle(Globals.LuskiTexture) { Location = new((int)(51.5 * Globals.Settings.Scale), (int)(4 * Globals.Settings.Scale)), Size = new((int)(138*Globals.Settings.Scale), (int)(144.5*Globals.Settings.Scale))});
|
||||
Controls.Add(r=new Rectangle(Globals.LuskiTexture) { Location = new((int)(51.5 * Globals.Settings.Scale), (int)(4 * Globals.Settings.Scale)), Size = new((int)(138*Globals.Settings.Scale), (int)(144.5*Globals.Settings.Scale))});
|
||||
Label t;
|
||||
Controls.Add(t=new Label() { Scale = 1.6f, Font = Globals.DefaultFont, Location = new((int)(85*Globals.Settings.Scale),(int)(153*Globals.Settings.Scale)), Text = "Luski", Color = new(243, 119, 53, 255) });
|
||||
t.Location = new((Size.X / 2) - (t.Size.X / 2), t.Location.Y);
|
||||
|
@ -16,8 +16,9 @@ public class UpdateWindow : Window
|
||||
WindowBorder = WindowBorder.Fixed,
|
||||
APIVersion = new Version(3, 2),
|
||||
StartFocused = true,
|
||||
Size = new OpenTK.Mathematics.Vector2i(481, 838),
|
||||
Icon = Globals.Icon
|
||||
Size = new Vector2i(481, 838),
|
||||
Icon = Globals.Icon,
|
||||
SharedContext = null
|
||||
};
|
||||
|
||||
public enum DialogueResult
|
||||
|
44
Luski/GUI/Windows/ChatWindow.cs
Normal file
44
Luski/GUI/Windows/ChatWindow.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using GraphicsManager;
|
||||
using GraphicsManager.Enums;
|
||||
using Luski.GUI.MainScreen.Interfaces;
|
||||
using Luski.GUI.MainScreen.UI;
|
||||
using Luski.net.JsonTypes;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
|
||||
namespace Luski.GUI.Windows;
|
||||
|
||||
|
||||
public class ChatWindow : Window
|
||||
{
|
||||
private static readonly NativeWindowSettings Settings = new()
|
||||
{
|
||||
Title = "Channel",
|
||||
WindowBorder = WindowBorder.Resizable,
|
||||
APIVersion = new Version(3, 2),
|
||||
StartFocused = true,
|
||||
Size = new OpenTK.Mathematics.Vector2i((int)(754 * Globals.Settings.Scale), (int)(667 * Globals.Settings.Scale)),
|
||||
Icon = Globals.Icon,
|
||||
SharedContext = null
|
||||
};
|
||||
|
||||
public ChatWindow(IChannelPick pick) : base(Settings)
|
||||
{
|
||||
Chat c;
|
||||
WindowBorder = WindowBorder.Resizable;
|
||||
Controls.Add(c= new Chat()
|
||||
{
|
||||
Location = new(0),
|
||||
Size = new(Size.X, Size.Y),
|
||||
Anchor = ObjectAnchor.All
|
||||
});
|
||||
c.UpdateTitle(pick);
|
||||
IReadOnlyList<SocketMessage> messages = pick.Channel.GetMessages(CancellationToken.None, Globals.Settings.LoadPerChannel).Result;
|
||||
|
||||
foreach (SocketMessage message in messages.Reverse())
|
||||
{
|
||||
c!.AddMessage(TextureManager, message);
|
||||
}
|
||||
c!.MessageFlow.ScrollToBottom();
|
||||
}
|
||||
}
|
@ -13,6 +13,25 @@ namespace Luski;
|
||||
|
||||
public class Globals
|
||||
{
|
||||
public record Snowflake
|
||||
{
|
||||
public Snowflake(long ID)
|
||||
{
|
||||
this.ID = ID;
|
||||
Increment = (ushort)((ID << 52) >> 52);
|
||||
Worker_ID = (ushort)((ID << 47) >> 59);
|
||||
Server_ID = (ushort)((ID << 42) >> 59);
|
||||
Timestamp = ID >> 22;
|
||||
}
|
||||
|
||||
public long ID { get; }
|
||||
public long Timestamp { get; }
|
||||
public ushort Worker_ID { get; }
|
||||
public ushort Server_ID { get; }
|
||||
public ushort Increment { get; }
|
||||
|
||||
private static ushort i = 0;
|
||||
}
|
||||
public static bool Download { get; set; } = false;
|
||||
public static Server Luski { get; set; } = null!;
|
||||
public static MainScreen ms;
|
||||
|
@ -15,7 +15,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GraphicsManager" Version="1.0.4-alpha03" />
|
||||
<PackageReference Include="GraphicsManager" Version="1.0.5-alpha08" />
|
||||
<PackageReference Include="Luski.net" Version="1.1.2-beta05" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -8,9 +8,17 @@ using Luski.net;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Console.WriteLine(new Globals.Snowflake(6080823133885445424));
|
||||
bool f = false;
|
||||
bool t = true;
|
||||
byte bf = Convert.ToByte(f);
|
||||
byte bt = Convert.ToByte(t);
|
||||
Console.WriteLine("{0} converted to {1}.", f, bf);
|
||||
Console.WriteLine("{0} converted to {1}.", t, bt);
|
||||
Globals.Settings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
|
||||
Globals.UpdaterSettings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
|
||||
|
||||
@ -20,20 +28,10 @@ try
|
||||
resource_stream?.CopyTo(ms);
|
||||
var Logo = SixLabors.ImageSharp.Image.Load<Rgba32>(ms.ToArray());
|
||||
|
||||
var pixels = new List<byte>(4 * Logo.Width * Logo.Height);
|
||||
|
||||
for (int y = 0; y < Logo.Height; y++)
|
||||
{
|
||||
var row = Logo.GetPixelRowSpan(y);
|
||||
|
||||
for (int x = 0; x < Logo.Width; x++)
|
||||
{
|
||||
pixels.Add(row[x].R);
|
||||
pixels.Add(row[x].G);
|
||||
pixels.Add(row[x].B);
|
||||
pixels.Add(row[x].A);
|
||||
}
|
||||
}
|
||||
//List<byte> pixels = new List<byte>(4 * Logo.Width * Logo.Height);
|
||||
Span<byte> pixels = new byte[4 * Logo.Width * Logo.Height].AsSpan();
|
||||
Logo.CopyPixelDataTo(pixels);
|
||||
|
||||
Globals.Icon = new WindowIcon(new Image(Logo.Width, Logo.Height, pixels.ToArray()));
|
||||
Globals.ms = new MainScreen();
|
||||
Globals.ms.StartRender();
|
||||
|
Loading…
Reference in New Issue
Block a user