diff --git a/Luski/GUI/MainScreen.cs b/Luski/GUI/MainScreen.cs new file mode 100644 index 0000000..09db009 --- /dev/null +++ b/Luski/GUI/MainScreen.cs @@ -0,0 +1,47 @@ +using System.ComponentModel; +using System.Reflection; +using GraphicsManager; +using GraphicsManager.Enums; +using GraphicsManager.Interfaces; +using GraphicsManager.Objects; +using GraphicsManager.Objects.Core; +using Luski.GUI.StartPage.UI; +using Luski.net; +using OpenTK.Graphics.OpenGL4; +using OpenTK.Mathematics; +using OpenTK.Windowing.Desktop; +using OpenTK.Windowing.Common; + +namespace Luski.GUI.MainScreen; + +public class MainScreen : Window +{ + private static readonly NativeWindowSettings Settings = new() + { + Title = "Luski Login", + WindowBorder = WindowBorder.Fixed, + APIVersion = new Version(3, 2), + StartFocused = true, + Size = new OpenTK.Mathematics.Vector2i(481, 838), + }; + + public MainScreen() : base(Settings) + { + Login login; + Controls.Add(login = new Login()); + login.ChangeToApp += LoginOnChangeToApp; + } + + private Task LoginOnChangeToApp() + { + Controls.Clear(); + Title = "Luski"; + Size = new(2048, 1334); + WindowBorder = WindowBorder.Resizable; + BackgroundColor = new Color4(34, 34, 34, 255); + Controls.Add(new Rectangle(new Texture(Globals.Luski.CurrentUser.GetAvatar().Result)) { Size = new(70, 70), Location = new(14 + 132, 16 + 62 + 1170)}); + Controls.Add(new Label(){Location = new(132 + 92, 39 + 62+1170), Text = Globals.Luski.CurrentUser.Username}); + DrawFrame(); + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/Luski/GUI/StartPage/StartPage.cs b/Luski/GUI/StartPage/StartPage.cs deleted file mode 100644 index 69c98b1..0000000 --- a/Luski/GUI/StartPage/StartPage.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using GraphicsManager; -using OpenTK.Windowing.Desktop; -using OpenTK.Windowing.Common; - -namespace Luski.GUI.StartPage; - -public class StartPage : Window -{ - private static readonly NativeWindowSettings Settings = new() - { - Title = "Luski StartPage", - WindowBorder = WindowBorder.Fixed, - APIVersion = new Version(3, 2), - StartFocused = true, - Size = new OpenTK.Mathematics.Vector2i(481, 838), - }; - - public StartPage() : base(Settings) - { - Controls.Add(new UI.Login()); - } -} \ No newline at end of file diff --git a/Luski/GUI/StartPage/UI/Login.cs b/Luski/GUI/StartPage/UI/Login.cs index b681f4b..45d90ac 100644 --- a/Luski/GUI/StartPage/UI/Login.cs +++ b/Luski/GUI/StartPage/UI/Login.cs @@ -1,22 +1,44 @@ using System.Reflection; using GraphicsManager; +using GraphicsManager.Interfaces; using GraphicsManager.Objects; using GraphicsManager.Objects.Core; +using Luski.net; +using Luski.net.Enums; using OpenTK.Mathematics; namespace Luski.GUI.StartPage.UI; public class Login : UserControl { + private RoundedButton button; + private Textbox Password, Email; + public event Func ChangeToApp; public Login() { Size = new(481, 838); Controls.Add(new Rectangle(new Texture(Tools.GetResourceBytes(Assembly.GetExecutingAssembly(), "Luski.Resources.Textures.Luski.png"))) { Location = new(103,8), Size = new(276, 289)}); Controls.Add(new Label() { Location = new(173,305), Text = "Luski", Color = new(0.9529f, 0.46666f, 0.203921569f, 1f) }); Controls.Add(new Label() { Location = new(34,395), Text = "Email"}); - Controls.Add(new Textbox() { Location = new(41,431), Size = new(401,41), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan }); + Controls.Add(Email =new Textbox() { Location = new(41,431), Size = new(401,41), InsideColor = new(28,28,28,255), BorderColor = Color4.DarkCyan }); Controls.Add(new Label() { Location = new(34,521), Text = "Password" }); - Controls.Add(new Textbox() { Location = new(41,562), Size = new(401, 41), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan }); + Controls.Add(Password = new Textbox() { Location = new(41,562), Size = new(401, 41), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan }); Controls.Add(new Label() { Location = new(36,664), Text = "Create Account" }); + Controls.Add(button = new() { Text = "Login", Location = new(41, 700), Size = new(401, 71), InsideColor = new(28, 28, 28, 255), BorderColor = Color4.DarkCyan }); + button.Clicked += ButtonOnClicked; + } + + private Task ButtonOnClicked(IRenderObject arg) + { + try + { + Globals.Luski = Server.Login(Email.Text, Password.Text, Branch.Dev).Result; + ChangeToApp.Invoke(); + } + catch (Exception e) + { + Console.WriteLine(e); + } + return Task.CompletedTask; } } diff --git a/Luski/Globals.cs b/Luski/Globals.cs new file mode 100644 index 0000000..8d09cba --- /dev/null +++ b/Luski/Globals.cs @@ -0,0 +1,8 @@ +using Luski.net; + +namespace Luski; + +public class Globals +{ + public static Server Luski = null; +} \ No newline at end of file diff --git a/Luski/Luski.csproj b/Luski/Luski.csproj index 53433aa..266f365 100644 --- a/Luski/Luski.csproj +++ b/Luski/Luski.csproj @@ -8,7 +8,7 @@ - + diff --git a/Luski/Program.cs b/Luski/Program.cs index a2706af..9cc6ef8 100644 --- a/Luski/Program.cs +++ b/Luski/Program.cs @@ -1,5 +1,5 @@ -using Luski.GUI.StartPage; +using Luski.GUI.MainScreen; -var t = new StartPage(); +MainScreen t = new MainScreen(); t.StartRender(); t.Dispose(); \ No newline at end of file