New GUI layout to resolve #3

This commit is contained in:
JacobTech 2023-01-02 20:39:35 -05:00
parent 46fdd869da
commit f7e557344d
6 changed files with 82 additions and 28 deletions

47
Luski/GUI/MainScreen.cs Normal file
View File

@ -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;
}
}

View File

@ -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());
}
}

View File

@ -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<Task> 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;
}
}

8
Luski/Globals.cs Normal file
View File

@ -0,0 +1,8 @@
using Luski.net;
namespace Luski;
public class Globals
{
public static Server Luski = null;
}

View File

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.0-alpha9" />
<PackageReference Include="GraphicsManager" Version="1.0.0-alpha995" />
<PackageReference Include="Luski.net" Version="1.1.0-alpha" />
</ItemGroup>

View File

@ -1,5 +1,5 @@
using Luski.GUI.StartPage;
using Luski.GUI.MainScreen;
var t = new StartPage();
MainScreen t = new MainScreen();
t.StartRender();
t.Dispose();