commit
f7abb6e993
14
.gitignore
vendored
14
.gitignore
vendored
@ -77,3 +77,17 @@ fabric.properties
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
|
16
Luski.sln
Normal file
16
Luski.sln
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Luski", "Luski\Luski.csproj", "{02A83482-752B-4EB8-A952-51961D6EE684}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{02A83482-752B-4EB8-A952-51961D6EE684}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{02A83482-752B-4EB8-A952-51961D6EE684}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{02A83482-752B-4EB8-A952-51961D6EE684}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{02A83482-752B-4EB8-A952-51961D6EE684}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
9
Luski/Classes/ExperimentInfo.cs
Normal file
9
Luski/Classes/ExperimentInfo.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Luski.Classes;
|
||||
|
||||
public class ExperimentInfo
|
||||
{
|
||||
public string DisplayName { get; set; } = default!;
|
||||
public string Name { get; set; } = default!;
|
||||
public List<ExperimentSelectorInfo> Options { get; set; } = default!;
|
||||
public int? Selected { get; set; } = null;
|
||||
}
|
13
Luski/Classes/ExperimentJson.cs
Normal file
13
Luski/Classes/ExperimentJson.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Luski.Classes;
|
||||
|
||||
public class ExperimentJson
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = default!;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("selected")]
|
||||
public int Selected { get; set; } = default!;
|
||||
}
|
14
Luski/Classes/ExperimentSelectorInfo.cs
Normal file
14
Luski/Classes/ExperimentSelectorInfo.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Luski.Classes;
|
||||
|
||||
public class ExperimentSelectorInfo
|
||||
{
|
||||
public event Func<bool,Task>? EventToggled;
|
||||
public string Name { get; set; } = default!;
|
||||
public string Description { get; set; } = default!;
|
||||
public bool RequiresRestart { get; set; } = false;
|
||||
|
||||
internal void SendTog(bool b)
|
||||
{
|
||||
if (EventToggled is not null) EventToggled.Invoke(b);
|
||||
}
|
||||
}
|
48
Luski/Classes/LuskiThemes.cs
Normal file
48
Luski/Classes/LuskiThemes.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace Luski.Classes;
|
||||
|
||||
public static class LuskiThemes
|
||||
{
|
||||
public static void LoadThemeFromDir(string dir)
|
||||
{
|
||||
ThemeStart ts = Globals.GetSettings(Path.Combine(dir, "theme.json"), ThemeStartContext.Default.ThemeStart);
|
||||
LuskiThemes.LuskiThemeList.Add(ts);
|
||||
}
|
||||
|
||||
public static void LoadThemeFromZip(string ZIP)
|
||||
{
|
||||
ZipArchive zf = ZipFile.OpenRead(ZIP);
|
||||
ZipArchiveEntry? json = zf.GetEntry("theme.json");
|
||||
ThemeStart ts = Globals.GetSettings(json?.Open()!, ThemeStartContext.Default.ThemeStart);
|
||||
LuskiThemes.LuskiThemeList.Add(ts);
|
||||
}
|
||||
|
||||
|
||||
public readonly static ThemeStart Dark = new()
|
||||
{
|
||||
Name = "Dark",
|
||||
Description = "A dark theme but still a bit lit."
|
||||
};
|
||||
public static ThemeStart Amoled = new()
|
||||
{
|
||||
Name = "Amoled",
|
||||
Description = "A dark theme that is truly dark."
|
||||
};
|
||||
public static ThemeStart Light = new()
|
||||
{
|
||||
Name = "Light",
|
||||
Description = "A light theme for the insane.",
|
||||
GlobalServerTemplate = new()
|
||||
{
|
||||
SelectionColor = new("000000")
|
||||
}
|
||||
};
|
||||
|
||||
public static List<ThemeStart> LuskiThemeList = new()
|
||||
{
|
||||
Light,
|
||||
Dark,
|
||||
Amoled
|
||||
};
|
||||
}
|
25
Luski/Classes/ServerInfo.cs
Normal file
25
Luski/Classes/ServerInfo.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Luski.Classes;
|
||||
|
||||
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;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("pre_encrypt")]
|
||||
public bool PreGenEncryption { get; set; } = true;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("show_server_messages")]
|
||||
public bool ShowMessage { get; set; } = false;
|
||||
}
|
21
Luski/Classes/ServerList.cs
Normal file
21
Luski/Classes/ServerList.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Luski.Classes;
|
||||
|
||||
public class ServerList
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("servers")]
|
||||
public ServerInfo[] Servers { get; set; } = Array.Empty<ServerInfo>();
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(ServerList))]
|
||||
[JsonSourceGenerationOptions(
|
||||
GenerationMode = JsonSourceGenerationMode.Default,
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
|
||||
WriteIndented = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
|
||||
internal partial class ServerListContext : JsonSerializerContext
|
||||
{
|
||||
|
||||
}
|
129
Luski/Classes/Settings.cs
Normal file
129
Luski/Classes/Settings.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using GraphicsManager.Objects;
|
||||
|
||||
namespace Luski.Classes;
|
||||
|
||||
public class Settings
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("scale")]
|
||||
public double? Scale { get; set; } = null;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("perscrollpixels")]
|
||||
public uint PerScrollPixels { get; set; } = 20;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("multithreadpercent")]
|
||||
public uint MultiThreadPercent { get; set; } = 50;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("loadperchannel")]
|
||||
public int LoadPerChannel { get; set; } = 50;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("theme")]
|
||||
public string Theme { get; set; } = "Dark";
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("experiments")]
|
||||
public List<ExperimentJson> Experiments { get; set; } = Array.Empty<ExperimentJson>().ToList();
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("default_display")]
|
||||
public int Display { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Sets the log value for the console. Default value of -25 to enable all logs by default except for DrawFrames and InfoOpenGL even if new ones are added.
|
||||
/// </summary>
|
||||
[JsonInclude]
|
||||
[Description("Console Logs")]
|
||||
[JsonPropertyName("log")]
|
||||
public ConsoleLog Logs
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Logs;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Logs = value;
|
||||
if (Globals.ms is not null)
|
||||
{
|
||||
Globals.ms.LogFrames = (_Logs & ConsoleLog.DrawFrames) == ConsoleLog.DrawFrames;
|
||||
Globals.ms.ShowMissingChar = (_Logs & ConsoleLog.ShowMissingChar) == ConsoleLog.ShowMissingChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[Description("Scale Fonts")]
|
||||
[JsonPropertyName("scale_fonts")]
|
||||
public bool ScaleFonts
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ScaleFonts;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ScaleFonts = value;
|
||||
if (Globals.ms is not null)
|
||||
{
|
||||
Globals.DefaultFont.PixelHeight = Globals.Settings.DefaultFontPX.ScaleFont();
|
||||
Globals.MessageFont.PixelHeight = Globals.Settings.MessageFontPX.ScaleFont();
|
||||
Globals.TopTimeFont.PixelHeight = Globals.Settings.TopTimeFonttPX.ScaleFont();
|
||||
Globals.SmallTimeFont.PixelHeight = ((uint)11).ScaleFont();
|
||||
Label._characters[Globals.ms.Context][Globals.DefaultFont].Clear();
|
||||
Label._characters[Globals.ms.Context][Globals.MessageFont].Clear();
|
||||
Label._characters[Globals.ms.Context][Globals.TopTimeFont].Clear();
|
||||
Label._characters[Globals.ms.Context][Globals.SmallTimeFont].Clear();
|
||||
|
||||
Globals.ms.ForceUpdate(new(Globals.ms.ClientSize));
|
||||
Globals.ms.DrawFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("default_font_px")]
|
||||
public uint DefaultFontPX { get; set; } = 20;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("top_time_font_px")]
|
||||
public uint TopTimeFonttPX { get; set; } = 12;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("message_font_px")]
|
||||
public uint MessageFontPX { get; set; } = 17;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("message_font_line_space_px")]
|
||||
public uint MessageFontLineSpacePX { get; set; } = 5;
|
||||
|
||||
[JsonInclude]
|
||||
[Description("24 Hour Time")]
|
||||
[JsonPropertyName("24hour_time")]
|
||||
public bool DayTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _DayTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
_DayTime = value;
|
||||
if (DayTimeChanged is not null) DayTimeChanged.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
private bool _ScaleFonts = true;
|
||||
[JsonIgnore]
|
||||
private ConsoleLog _Logs = (ConsoleLog)(-25);
|
||||
[JsonIgnore]
|
||||
private bool _DayTime = false;
|
||||
public event Func<Task>? DayTimeChanged;
|
||||
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(Settings))]
|
||||
[JsonSourceGenerationOptions(
|
||||
GenerationMode = JsonSourceGenerationMode.Default,
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
|
||||
WriteIndented = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
|
||||
internal partial class SettingsContext : JsonSerializerContext
|
||||
{
|
||||
|
||||
}
|
32
Luski/Classes/ThemeStart.cs
Normal file
32
Luski/Classes/ThemeStart.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Luski.Classes.ThemeSub;
|
||||
|
||||
namespace Luski.Classes;
|
||||
|
||||
public class ThemeStart
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = default!;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("description")]
|
||||
public string Description { get; set; } = default!;
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("global_server_template")]
|
||||
public ServerThemeProperties GlobalServerTemplate { get; set; } = new();
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("server_overrides")]
|
||||
public ServerTheme[] ServerOverrides { get; set; } = Array.Empty<ServerTheme>();
|
||||
}
|
||||
|
||||
|
||||
[JsonSerializable(typeof(ThemeStart))]
|
||||
[JsonSourceGenerationOptions(
|
||||
GenerationMode = JsonSourceGenerationMode.Default,
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
|
||||
WriteIndented = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
|
||||
internal partial class ThemeStartContext : JsonSerializerContext
|
||||
{
|
||||
|
||||
}
|
14
Luski/Classes/ThemeSub/ServerTheme.cs
Normal file
14
Luski/Classes/ThemeSub/ServerTheme.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Luski.Classes.ThemeSub;
|
||||
|
||||
public class ServerTheme
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("address")]
|
||||
public string Address { get; set; } = default!;
|
||||
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("properties")]
|
||||
public ServerThemeProperties Properties { get; set; } = new();
|
||||
}
|
11
Luski/Classes/ThemeSub/ServerThemeProperties.cs
Normal file
11
Luski/Classes/ThemeSub/ServerThemeProperties.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Luski.net.Structures.Public;
|
||||
|
||||
namespace Luski.Classes.ThemeSub;
|
||||
|
||||
public class ServerThemeProperties
|
||||
{
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("selection_color")]
|
||||
public Color SelectionColor { get; set; } = new("FFFFFF");
|
||||
}
|
46
Luski/Classes/UpdaterSettings.cs
Normal file
46
Luski/Classes/UpdaterSettings.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using Luski.net.Enums;
|
||||
|
||||
namespace Luski.Classes;
|
||||
|
||||
public class UpdaterSettings
|
||||
{
|
||||
[JsonInclude]
|
||||
[Description("Self Contained")]
|
||||
[JsonPropertyName("self_contained")]
|
||||
public bool SelfContained { get; set; } = false;
|
||||
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("updater")]
|
||||
public string? Updater { get; set; } = null;
|
||||
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("platform")]
|
||||
public string Platform { get; set; } = "linux-x64";
|
||||
|
||||
[JsonInclude]
|
||||
[Description("Auto Launch")]
|
||||
[JsonPropertyName("auto_launch")]
|
||||
public bool AutoLaunch { get; set; } = true;
|
||||
[JsonInclude]
|
||||
[Description("Auto Update")]
|
||||
[JsonPropertyName("auto_update")]
|
||||
public bool AutoUpdate { get; set; } = false;
|
||||
|
||||
[JsonInclude]
|
||||
[Description("Check For Updates")]
|
||||
[JsonPropertyName("update_check")]
|
||||
public bool AutoUpdateCheck { get; set; } = true;
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(UpdaterSettings))]
|
||||
[JsonSourceGenerationOptions(
|
||||
GenerationMode = JsonSourceGenerationMode.Default,
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
|
||||
WriteIndented = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
|
||||
internal partial class UpdaterSettingsContext : JsonSerializerContext
|
||||
{
|
||||
|
||||
}
|
21
Luski/ConsoleLog.cs
Normal file
21
Luski/ConsoleLog.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Luski;
|
||||
|
||||
[Flags]
|
||||
public enum ConsoleLog : long
|
||||
{
|
||||
None = 0,
|
||||
[Description("Show OpenGL Major Errors")]
|
||||
BigErrosForOpenGL = 1,
|
||||
[Description("Show OpenGL Medium Errors")]
|
||||
MediumErrosForOpenGL = 2,
|
||||
[Description("Show OpenGL Small Errors")]
|
||||
LowErrosForOpenGL = 4,
|
||||
[Description("Show OpenGL Info")]
|
||||
InfoForOpenGL = 8,
|
||||
[Description("Show Draw Frams")]
|
||||
DrawFrames = 16,
|
||||
[Description("Show Missing Charters")]
|
||||
ShowMissingChar = 32
|
||||
}
|
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);
|
||||
}
|
8
Luski/GUI/MainScreen/Interfaces/IChannelPick.cs
Normal file
8
Luski/GUI/MainScreen/Interfaces/IChannelPick.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using Luski.net.Structures.Main;
|
||||
|
||||
namespace Luski.GUI.MainScreen.Interfaces;
|
||||
|
||||
public interface IChannelPick
|
||||
{
|
||||
public MainSocketTextChannel Channel { get; }
|
||||
}
|
95
Luski/GUI/MainScreen/UI/AccountButton.cs
Normal file
95
Luski/GUI/MainScreen/UI/AccountButton.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using Luski.Interfaces;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI;
|
||||
|
||||
public class AccountButton : UserControl
|
||||
{
|
||||
private IServerOverlay SM;
|
||||
public Label l;
|
||||
public required Action OnPageLoad;
|
||||
|
||||
public AccountButton(string Text, IServerOverlay SM)
|
||||
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
|
||||
{
|
||||
this.SM = SM;
|
||||
base.Size = new(297.ScaleInt(), 40.ScaleInt());
|
||||
TextureDisplay = TextureDisplay.HorizontalCenter;
|
||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||
l = new Label(Globals.DefaultFont)
|
||||
{
|
||||
Text = Text,
|
||||
Color = Color4.Gray,
|
||||
IgnoreHover = true,
|
||||
};
|
||||
l.Location = new((base.Size.X / 2) - (l.Size.X / 2),
|
||||
((base.Size.Y - l.Size.Y) / 2)
|
||||
, 0);
|
||||
Controls.Add(l);
|
||||
base.BackgroundColor = new(0, 0, 0, 0);
|
||||
Clicked += OnClicked;
|
||||
MouseEnter += o =>
|
||||
{
|
||||
if (!Selected)
|
||||
{
|
||||
BackgroundColor = new(141, 151, 165, 30);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
MouseLeave += o =>
|
||||
{
|
||||
if (!Selected)
|
||||
{
|
||||
BackgroundColor = new(0,0,0,0);
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
}
|
||||
|
||||
private async Task OnClicked(IRenderObject arg)
|
||||
{
|
||||
if (!Selected) await ToggleSelected();
|
||||
}
|
||||
|
||||
public bool Selected { get; private set; }
|
||||
|
||||
public async Task ToggleSelected()
|
||||
{
|
||||
try
|
||||
{
|
||||
Color4 bc = new(141,151,165,51), f= Color4.White;
|
||||
if (Selected)
|
||||
{
|
||||
bc = new (0,0,0,0);
|
||||
f = Color4.Gray;
|
||||
}
|
||||
|
||||
BlockDraw = true;
|
||||
Selected = !Selected;
|
||||
|
||||
if (SM.Selected is not null && SM.Selected != this)
|
||||
{
|
||||
await SM.Selected.ToggleSelected();
|
||||
}
|
||||
BackgroundColor = bc;
|
||||
l.Color = f;
|
||||
if (Selected)
|
||||
{
|
||||
SM.Selected = this;
|
||||
SM.page.Controls.Clear();
|
||||
OnPageLoad.Invoke();
|
||||
}
|
||||
|
||||
BlockDraw = false;
|
||||
TryDraw();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
23
Luski/GUI/MainScreen/UI/AddServerIcon.cs
Normal file
23
Luski/GUI/MainScreen/UI/AddServerIcon.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using GraphicsManager.Objects;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI;
|
||||
|
||||
public class AddServerIcon : UserControl
|
||||
{
|
||||
public Rectangle Button;
|
||||
public AddServerIcon()
|
||||
{
|
||||
Button = new(Globals.ms.TextureManager.GetTextureResource("add.png"))
|
||||
{
|
||||
Location = new(18.ScaleInt(), 8.ScaleInt(), 0),
|
||||
Size = new(32.ScaleInt()),
|
||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||
BackgroundColor = Color4.White,
|
||||
IgnoreHover = true
|
||||
};
|
||||
Controls.Add(Button);
|
||||
base.BackgroundColor = new(26, 26, 26, 255);
|
||||
base.Size = new(68.ScaleInt(), 48.ScaleInt());
|
||||
}
|
||||
}
|
606
Luski/GUI/MainScreen/UI/AddServerOverlay.cs
Normal file
606
Luski/GUI/MainScreen/UI/AddServerOverlay.cs
Normal file
@ -0,0 +1,606 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using Luski.Classes;
|
||||
using Luski.GUI.MainScreen.UI.LuskiControls;
|
||||
using Luski.Interfaces;
|
||||
using Luski.net;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
using Rectangle = GraphicsManager.Objects.Rectangle;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI;
|
||||
|
||||
public class AddServerOverlay : UserControl, IServerOverlay
|
||||
{
|
||||
private UserControl Form, btn;
|
||||
private DropDown<VersionDropButton> version;
|
||||
|
||||
public AccountButton? Selected { get; set; }
|
||||
public UserControl page { get; set; }
|
||||
private TextBox? UserName, Password, DisplayName, tb;
|
||||
|
||||
private Rectangle? rec;
|
||||
|
||||
public AddServerOverlay()
|
||||
{
|
||||
base.Size = Globals.ms.ClientSize;
|
||||
BackgroundColor = new(0, 0, 0, 130);
|
||||
Anchor = ObjectAnchor.All;
|
||||
|
||||
|
||||
|
||||
Form = new(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
|
||||
{
|
||||
Size = new(350.ScaleInt(), 347.ScaleInt()),
|
||||
BackgroundColor = new(32,32,32,255),
|
||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||
TextureDisplay = TextureDisplay.Center
|
||||
};
|
||||
Label t;
|
||||
Form.Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f, Text = "Add Server", Color = Globals.DodgerBlue });
|
||||
t.Location = new((Form.Size.X / 2) - (t.Size.X / 2), t.Location.Y, 0);
|
||||
|
||||
#region Server Loc
|
||||
Label? ll = new Label(Globals.DefaultFont)
|
||||
{
|
||||
Text = net.API.DefaultVersion,
|
||||
Color = Color4.DarkGray,
|
||||
IgnoreHover = true
|
||||
};
|
||||
Vector2i s =new((int)(ll.Size.X * 1.6f),27.ScaleInt());
|
||||
ll = null;
|
||||
|
||||
Rectangle line = new Rectangle()
|
||||
{
|
||||
Size = new Vector2i(1.ScaleInt()),
|
||||
BackgroundColor = Globals.DodgerBlue
|
||||
};
|
||||
|
||||
tb = new()
|
||||
{
|
||||
Location = new(10.ScaleInt(),50.ScaleInt(), 0),
|
||||
Size = s,
|
||||
WatermarkText = "Server Address",
|
||||
TextLocation = TextLocation.LineCenter,
|
||||
AllowMultiLine = false
|
||||
};
|
||||
tb.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
tb.KeyPress += args =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete) && string.IsNullOrWhiteSpace(tb.Text))
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (tb.Textures[0].handel != t.handel)
|
||||
{
|
||||
tb.Textures[0] = t;
|
||||
if (t.handel == good.handel &&
|
||||
UserName!.Textures[0].handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel &&
|
||||
(rec is null || rec.Textures.Count > 1) &&
|
||||
btn!.Textures[0].handel != good.handel &&
|
||||
tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
if (Selected!.l.Text != "Login")
|
||||
{
|
||||
if (DisplayName!.Textures[0].handel == good.handel) btn.Textures[0] = good;
|
||||
}
|
||||
else btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel &&
|
||||
(UserName!.Textures[0].handel != good.handel ||
|
||||
Password!.Textures[0].handel != good.handel ||
|
||||
(rec is not null && rec!.Textures.Count == 1) ||
|
||||
btn!.Textures[0].handel == good.handel ||
|
||||
tb.Textures[0].handel != good.handel ||
|
||||
(DisplayName is not null && DisplayName.Textures[0].handel != good.handel)))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
tb.Size = new(Form.Size.X - tb.Location.X - tb.Location.X - tb.Location.X - s.X, tb.Size.Y);
|
||||
|
||||
Form.Controls.Add(tb);
|
||||
|
||||
version = new DropDown<VersionDropButton>(Form.Textures[0], line)
|
||||
{
|
||||
DropDownParentOverride = Form,
|
||||
Size = s,
|
||||
BackgroundColor = new(255,20,20,255),
|
||||
TextureDisplay = TextureDisplay.HorizontalCenter,
|
||||
Shader = Form.Shader,
|
||||
Location = new(tb.Location.X + tb.Size.X + tb.Location.X, tb.Location.Y, 0)
|
||||
};
|
||||
foreach (string v in Globals.Luski.SupportedVersions)
|
||||
{
|
||||
VersionDropButton option = new VersionDropButton(s, v)
|
||||
{
|
||||
LoadDisplay = () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Label ll2 = new Label(Globals.DefaultFont)
|
||||
{
|
||||
Text = v,
|
||||
Color = Color4.DarkGray,
|
||||
IgnoreHover = true,
|
||||
|
||||
};
|
||||
ll2.Location = new((version.Size.X / 2) - (ll2.Size.X / 2),
|
||||
((version.Size.Y - ll2.Size.Y) / 2)
|
||||
, 0);
|
||||
version.Controls.Add(ll2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
version.AddOption(option);
|
||||
if (v == net.API.DefaultVersion)
|
||||
{
|
||||
version.SetSelected(option);
|
||||
}
|
||||
}
|
||||
|
||||
version.OpenStatusChanged += VersionOnOpenStatusChanged;
|
||||
version.OptionSelected += VersionOnOptionSelected;
|
||||
|
||||
|
||||
version.DropDownContainer.Textures.Add(Globals.ms.TextureManager.GetTextureResource("RoundedRectangleBottom.png"));
|
||||
version.DropDownContainer.TextureDisplay = TextureDisplay.Center;
|
||||
version.DropDownContainer.Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||
version.DropDownContainer.BackgroundColor = version.BackgroundColor;
|
||||
version.OpenStatusChanged += b =>
|
||||
{
|
||||
BlockDraw = true;
|
||||
if (b)
|
||||
{
|
||||
version.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangleTop.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
version.Textures[0] = Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png");
|
||||
}
|
||||
|
||||
BlockDraw = false;
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Buttons
|
||||
|
||||
AccountButton ca = new AccountButton("Create Account", this)
|
||||
{
|
||||
Location = new(tb.Location.X, tb.Location.Y + tb.Location.X + tb.Size.Y, 0),
|
||||
OnPageLoad = () =>
|
||||
{
|
||||
btn.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
page!.Controls.Add(UserName = new()
|
||||
{
|
||||
Location = new(0, 10.ScaleInt(), 0),
|
||||
Size = new(page.Size.X, 30.ScaleInt()),
|
||||
WatermarkText = "Username",
|
||||
TextLocation = TextLocation.LineCenter,
|
||||
AllowMultiLine = false
|
||||
});
|
||||
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
UserName.KeyPress += args =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) && string.IsNullOrWhiteSpace(UserName.Text))
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (UserName.Textures[0].handel != t.handel)
|
||||
{
|
||||
UserName.Textures[0] = t;
|
||||
if (t.handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel &&
|
||||
DisplayName!.Textures[0].handel == good.handel &&
|
||||
rec!.Textures.Count > 1 &&
|
||||
btn!.Textures[0].handel != good.handel &&
|
||||
tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel &&
|
||||
(Password!.Textures[0].handel != good.handel ||
|
||||
DisplayName!.Textures[0].handel != good.handel ||
|
||||
rec!.Textures.Count == 1 ||
|
||||
btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
page.Controls.Add(Password = new()
|
||||
{
|
||||
Location = new(0, UserName.Location.Y + UserName.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
|
||||
Size = new(page.Size.X, UserName.Size.Y),
|
||||
WatermarkText = "Password",
|
||||
TextLocation = TextLocation.LineCenter,
|
||||
AllowMultiLine = false,
|
||||
PasswordChar = '●'
|
||||
});
|
||||
Password.Textures[0] = UserName.Textures[0];
|
||||
Password.KeyPress += args =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) && string.IsNullOrWhiteSpace(Password.Text))
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (Password.Textures[0].handel != t.handel)
|
||||
{
|
||||
Password.Textures[0] = t;
|
||||
if (t.handel == good.handel && UserName!.Textures[0].handel == good.handel && DisplayName!.Textures[0].handel == good.handel && rec!.Textures.Count > 1 && btn!.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel && (UserName!.Textures[0].handel != good.handel || DisplayName!.Textures[0].handel != good.handel || rec!.Textures.Count == 1 || btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
page.Controls.Add(rec = new(Globals.ms.TextureManager.GetAlphaCircle())
|
||||
{
|
||||
Size = new(50.ScaleInt()),
|
||||
BackgroundColor = Color4.Red,
|
||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
|
||||
IgnoreHover = false
|
||||
});
|
||||
rec.Location = new(page.Size.X - rec.Size.X, page.Size.Y - rec.Size.Y, 0);
|
||||
|
||||
page.Controls.Add(DisplayName = new()
|
||||
{
|
||||
Location = new(0, Password.Location.Y + Password.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
|
||||
Size = new(page.Size.X- tb.Location.X - rec.Size.X, Password.Size.Y ),
|
||||
WatermarkText = "Display Name",
|
||||
TextLocation = TextLocation.LineCenter,
|
||||
AllowMultiLine = false
|
||||
});
|
||||
DisplayName.KeyPress += args =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) &&
|
||||
string.IsNullOrWhiteSpace(UserName.Text))
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (DisplayName.Textures[0].handel != t.handel)
|
||||
{
|
||||
DisplayName.Textures[0] = t;
|
||||
if (t.handel == good.handel && UserName!.Textures[0].handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel && rec!.Textures.Count > 1 &&
|
||||
btn!.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel && (UserName!.Textures[0].handel != good.handel ||
|
||||
Password!.Textures[0].handel != good.handel ||
|
||||
rec!.Textures.Count == 1 ||
|
||||
btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
rec.FilesDroped += RecOnFilesDroped;
|
||||
DisplayName.Textures[0] = UserName.Textures[0];
|
||||
rec.ForceDistanceUpdate(page);
|
||||
Globals.ms.TryDraw();
|
||||
Globals.ms.ForceUpdate(new(Size));
|
||||
}
|
||||
};
|
||||
ca.Size = new((Form.Size.X - tb.Location.X - tb.Location.X - (tb.Location.X / 2)) / 2, ca.Size.Y);
|
||||
ca.l.Location = new((ca.Size.X - ca.l.Size.X) / 2,
|
||||
((ca.Size.Y - ca.l.Size.Y) / 2)
|
||||
, 0);
|
||||
ca.l.ForceDistanceUpdate(ca);
|
||||
Form.Controls.Add(ca);
|
||||
|
||||
AccountButton lo = new AccountButton("Login", this)
|
||||
{
|
||||
Location = new(ca.Location.X + ca.Size.X + (tb.Location.X / 2),ca.Location.Y, 0),
|
||||
OnPageLoad = () =>
|
||||
{
|
||||
btn!.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
page!.Controls.Add(UserName = new()
|
||||
{
|
||||
Location = new(0, 22.ScaleInt(), 0),
|
||||
Size = new(page.Size.X, 31.ScaleInt()),
|
||||
WatermarkText = "Username",
|
||||
TextLocation = TextLocation.LineCenter,
|
||||
AllowMultiLine = false
|
||||
});
|
||||
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
UserName.KeyPress += args =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) && string.IsNullOrWhiteSpace(UserName.Text))
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (UserName.Textures[0].handel != t.handel)
|
||||
{
|
||||
UserName.Textures[0] = t;
|
||||
if (t.handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel &&
|
||||
btn!.Textures[0].handel != good.handel &&
|
||||
tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel &&
|
||||
(Password!.Textures[0].handel != good.handel ||
|
||||
btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
page.Controls.Add(Password = new()
|
||||
{
|
||||
Location = new(0, UserName.Location.Y + UserName.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
|
||||
Size = new(page.Size.X, UserName.Size.Y),
|
||||
WatermarkText = "Password",
|
||||
TextLocation = TextLocation.LineCenter,
|
||||
AllowMultiLine = false,
|
||||
PasswordChar = '●'
|
||||
});
|
||||
Password.Textures[0] = UserName.Textures[0];
|
||||
Password.KeyPress += args =>
|
||||
{
|
||||
Texture t;
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if ((args.Key == Keys.Backspace || args.Key == Keys.Delete || args.Alt || args.Shift || args.Control || args.Key == Keys.Enter || args.Key == Keys.KeyPadEnter || args.Key== Keys.Space) &&
|
||||
string.IsNullOrWhiteSpace(Password.Text))
|
||||
{
|
||||
t = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
t = good;
|
||||
}
|
||||
|
||||
if (Password.Textures[0].handel != t.handel)
|
||||
{
|
||||
Password.Textures[0] = t;
|
||||
if (t.handel == good.handel &&
|
||||
UserName!.Textures[0].handel == good.handel &&
|
||||
btn!.Textures[0].handel != good.handel &&
|
||||
tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
btn.Textures[0] = good;
|
||||
}
|
||||
else if (t.handel != good.handel &&
|
||||
(UserName!.Textures[0].handel != good.handel ||
|
||||
btn!.Textures[0].handel == good.handel || tb.Textures[0].handel != good.handel))
|
||||
{
|
||||
btn!.Textures[0] = t;
|
||||
}
|
||||
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
DisplayName = null!;
|
||||
rec = null!;
|
||||
}
|
||||
};
|
||||
lo.Size = ca.Size;
|
||||
lo.l.Location = new((lo.Size.X / 2) - (lo.l.Size.X / 2),
|
||||
((lo.Size.Y - lo.l.Size.Y) / 2)
|
||||
, 0);
|
||||
lo.l.ForceDistanceUpdate(lo);
|
||||
Form.Controls.Add(lo);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
Form.Controls.Add(version);
|
||||
|
||||
page = new()
|
||||
{
|
||||
Location = new(tb.Location.X, ca.Location.Y + ca.Size.Y + tb.Location.X, 0),
|
||||
BackgroundColor = Form.BackgroundColor
|
||||
};
|
||||
page.Size = new(Form.Size.X - tb.Location.X - tb.Location.X, Form.Size.Y - tb.Location.X - page.Location.Y - ca.Size.Y - tb.Location.X);
|
||||
Console.Write(page.Size.Y - tb.Location.X - tb.Location.X - (50*2*3));
|
||||
Console.WriteLine(page.Size);
|
||||
Form.Controls.Add(page);
|
||||
|
||||
btn = new(Globals.ms.TextureManager.GetTextureResource("BadTextbox.png"))
|
||||
{
|
||||
Location = new(page.Location.X, page.Location.Y + page.Size.Y + tb.Location.X, 0),
|
||||
Size = new(page.Size.X, ca.Size.Y),
|
||||
TextureDisplay = TextureDisplay.Center
|
||||
};
|
||||
_ = ca.ToggleSelected();
|
||||
Label sub = new(Globals.DefaultFont)
|
||||
{
|
||||
Text = "Submit",
|
||||
IgnoreHover = true
|
||||
};
|
||||
sub.Location = new((btn.Size.X / 2) - (sub.Size.X / 2),
|
||||
((btn.Size.Y - sub.Size.Y) / 2)
|
||||
, 0);
|
||||
sub.ForceDistanceUpdate(btn);
|
||||
btn.Controls.Add(sub);
|
||||
Form.Controls.Add(btn);
|
||||
|
||||
Form.Location = new((base.Size.X - Form.Size.X) / 2, (base.Size.Y - Form.Size.Y) / 2, 0);
|
||||
Controls.Add(Form);
|
||||
btn.Clicked += BtnOnClicked;
|
||||
}
|
||||
|
||||
private async Task BtnOnClicked(IRenderObject arg)
|
||||
{
|
||||
if (btn.Textures[0].handel == Globals.ms.TextureManager.GetTextureResource("BadTextbox.png").handel)
|
||||
return;
|
||||
bool s = true;
|
||||
string d = tb!.Text;
|
||||
if (d.Contains("://"))
|
||||
{
|
||||
string[] a = d.Split("://");
|
||||
d = a[1];
|
||||
if (a[0] == "http") s = false;
|
||||
}
|
||||
ServerInfo si = new()
|
||||
{
|
||||
Domain = d,
|
||||
Version = version.SelectedOption.l.Text,
|
||||
Main = false,
|
||||
Secure = s
|
||||
};
|
||||
bool g = await Globals.Luski.TryGetPublicServer(out PublicServer ps, si.Domain, si.Version, si.Secure);
|
||||
|
||||
if (!g)
|
||||
{
|
||||
Texture b = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
tb!.Textures[0] = b;
|
||||
btn.Textures[0] = b;
|
||||
Globals.ms.TryDraw();
|
||||
return;
|
||||
}
|
||||
|
||||
if (g && !ps.IsLogedIn)
|
||||
{
|
||||
if (DisplayName is null)
|
||||
{
|
||||
g = await ps.Login(UserName!.Text, Password!.Text, CancellationToken.None);
|
||||
}
|
||||
else
|
||||
{
|
||||
g = await ps.CreateAccount(UserName!.Text, Password!.Text, DisplayName.Text, pfp,
|
||||
CancellationToken.None);
|
||||
}
|
||||
}
|
||||
|
||||
if (!g)
|
||||
{
|
||||
Texture b = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
|
||||
UserName!.Textures[0] = b;
|
||||
Password!.Textures[0] = b;
|
||||
btn.Textures[0] = b;
|
||||
Globals.ms.TryDraw();
|
||||
return;
|
||||
}
|
||||
|
||||
var l = Globals.ServerList.Servers.ToList();
|
||||
l.Add(si);
|
||||
Globals.ServerList.Servers = l.ToArray();
|
||||
Globals.ServerList.SaveSettings(Path.Combine(Globals.LuskiPath, "Servers.json"), ServerListContext.Default.ServerList);
|
||||
ServerIcon<PublicServer> ss = new ServerIcon<PublicServer>(ps);
|
||||
Globals.ms.ser.Controls.Insert(Globals.ms.ser.Controls.Length - 1, ss);
|
||||
await ss.LoadServer();
|
||||
Globals.ms.Controls.Remove(this);
|
||||
Globals.ms.ForceUpdate(new(Size));
|
||||
Globals.ms.TryDraw();
|
||||
}
|
||||
|
||||
private Task VersionOnOptionSelected(VersionDropButton arg)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task VersionOnOpenStatusChanged(bool arg)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private string pfp = "";
|
||||
|
||||
private Task RecOnFilesDroped(string[] arg)
|
||||
{
|
||||
Console.WriteLine(arg[0]);
|
||||
if (!arg[0].ToLower().EndsWith("png")) return Task.CompletedTask;
|
||||
|
||||
pfp = arg[0];
|
||||
if (rec!.Textures.Count() ==1 )
|
||||
{
|
||||
Texture good = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
|
||||
if (UserName!.Textures[0].handel == good.handel &&
|
||||
Password!.Textures[0].handel == good.handel &&
|
||||
btn!.Textures[0].handel != good.handel && tb.Textures[0].handel == good.handel)
|
||||
{
|
||||
if (DisplayName is not null)
|
||||
{
|
||||
if (Password!.Textures[0].handel == good.handel) btn.Textures[0] = good;
|
||||
}
|
||||
else btn.Textures[0] = good;
|
||||
}
|
||||
Texture tex = Globals.ms.TextureManager.AddTexture(File.OpenRead(arg[0]));
|
||||
tex.Unit = TextureUnit.Texture1;
|
||||
rec.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
|
||||
rec.Textures.Add(tex);
|
||||
}
|
||||
else
|
||||
{
|
||||
rec.Textures[1] = Globals.ms.TextureManager.AddTexture(File.OpenRead(arg[0]));
|
||||
rec.Textures[1].Unit = TextureUnit.Texture1;
|
||||
}
|
||||
|
||||
Window!.TryDraw();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
30
Luski/GUI/MainScreen/UI/FullScreenMedia.cs
Normal file
30
Luski/GUI/MainScreen/UI/FullScreenMedia.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI;
|
||||
|
||||
public class FullScreenMedia : UserControl
|
||||
{
|
||||
public Rectangle IMG;
|
||||
|
||||
public FullScreenMedia(Texture t)
|
||||
{
|
||||
base.Size = Globals.ms.ClientSize;
|
||||
IMG = new(t)
|
||||
{
|
||||
Size = t.RawSize!.Value,
|
||||
Location = new((base.Size.X - t.RawSize!.Value.X) / 2, (base.Size.Y - t.RawSize!.Value.Y) / 2, 0),
|
||||
Anchor = ObjectAnchor.All
|
||||
};
|
||||
BackgroundColor = new(0, 0, 0, 130);
|
||||
Controls.Add(IMG);
|
||||
IMG.ForceDistanceUpdate(this);
|
||||
Anchor = ObjectAnchor.All;
|
||||
}
|
||||
|
||||
public static FullScreenMedia GetDisplay(Texture t)
|
||||
{
|
||||
return new FullScreenMedia(t);
|
||||
}
|
||||
}
|
52
Luski/GUI/MainScreen/UI/LuskiContextMenu.cs
Normal file
52
Luski/GUI/MainScreen/UI/LuskiContextMenu.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Graphics.ES20;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI;
|
||||
|
||||
public class LuskiContextMenu : BetterContextMenu
|
||||
{
|
||||
public LuskiContextMenu()
|
||||
:base(Globals.ms.TextureManager.GetTextureResource("Context.png"))
|
||||
{
|
||||
Margins = new(5.ScaleInt());
|
||||
TextureDisplay = TextureDisplay.Center;
|
||||
SpaceBetweenObjects = 8.ScaleInt();
|
||||
}
|
||||
|
||||
public Label AddLabel(string text, Color4 color)
|
||||
{
|
||||
return AddLabel(Globals.DefaultFont, text, color);
|
||||
}
|
||||
|
||||
public Label AddLabel(string text)
|
||||
{
|
||||
Label l = AddLabel(Globals.DefaultFont, text, Color4.Gray);
|
||||
l.Clicked += o =>
|
||||
{
|
||||
HideContext(Window!);
|
||||
TryDraw();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
l.MouseEnter += o =>
|
||||
{
|
||||
l.Color = Color4.White;
|
||||
TryDraw();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
l.MouseLeave += o =>
|
||||
{
|
||||
l.Color = Color4.Gray;
|
||||
TryDraw();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
return l;
|
||||
}
|
||||
|
||||
public new void AddLine()
|
||||
{
|
||||
AddLine(Color4.White, 1.ScaleInt());
|
||||
}
|
||||
}
|
192
Luski/GUI/MainScreen/UI/LuskiControls/DropDown.cs
Normal file
192
Luski/GUI/MainScreen/UI/LuskiControls/DropDown.cs
Normal file
@ -0,0 +1,192 @@
|
||||
using GraphicsManager.Enums;
|
||||
using GraphicsManager.Interfaces;
|
||||
using GraphicsManager.Objects;
|
||||
using GraphicsManager.Objects.Core;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
|
||||
namespace Luski.GUI.MainScreen.UI.LuskiControls;
|
||||
|
||||
public class DropDown<TSelection> : UserControl where TSelection : DropDownOption
|
||||
{
|
||||
public readonly FlowLayout DropDownContainer;
|
||||
|
||||
private IParent ip;
|
||||
|
||||
public required IParent DropDownParentOverride
|
||||
{
|
||||
get
|
||||
{
|
||||
return ip;
|
||||
}
|
||||
set
|
||||
{
|
||||
ip = value;
|
||||
DropDownContainer.TransferOwners(Globals.ms, value);
|
||||
}
|
||||
}
|
||||
private bool IsOpen;
|
||||
public event Func<bool, Task>? OpenStatusChanged;
|
||||
|
||||
public DropDown(TSelection defaultOption)
|
||||
{
|
||||
ip = this;
|
||||
DropDownContainer = new()
|
||||
{
|
||||
Visible = false
|
||||
};
|
||||
Clicked += OnClicked;
|
||||
WindowLoaded += OnWindowLoaded;
|
||||
AddOption(defaultOption);
|
||||
SelectedOption = defaultOption;
|
||||
}
|
||||
|
||||
public DropDown(Texture t, TSelection defaultOption)
|
||||
:base(t)
|
||||
{
|
||||
ip = this;
|
||||
TextureDisplay = TextureDisplay.HorizontalCenter;
|
||||
DropDownContainer = new()
|
||||
{
|
||||
Visible = false,
|
||||
Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right
|
||||
};
|
||||
Clicked += OnClicked;
|
||||
WindowLoaded += OnWindowLoaded;
|
||||
DropDownContainer.Size = new(base.Size.X, DropDownContainer.Size.Y + defaultOption.Size.Y);
|
||||
DropDownContainer.Controls.Add(defaultOption);
|
||||
defaultOption.Clicked += OptionOnClicked;
|
||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||
SelectedOption = defaultOption;
|
||||
}
|
||||
|
||||
public void SetSelected(TSelection obj)
|
||||
{
|
||||
SelectedOption = obj;
|
||||
Controls.Clear();
|
||||
obj.LoadDisplay.Invoke();
|
||||
}
|
||||
|
||||
public DropDown(Texture t, IRenderObject spacer, TSelection defaultOption)
|
||||
:base(t)
|
||||
{
|
||||
ip = this;
|
||||
TextureDisplay = TextureDisplay.HorizontalCenter;
|
||||
DropDownContainer = new()
|
||||
{
|
||||
Visible = false,
|
||||
Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right
|
||||
};
|
||||
Clicked += OnClicked;
|
||||
WindowLoaded += OnWindowLoaded;
|
||||
DropDownContainer.Size = new(base.Size.X, DropDownContainer.Size.Y + spacer.Size.Y);
|
||||
DropDownContainer.Controls.Add(spacer);
|
||||
DropDownContainer.Size = new(base.Size.X, DropDownContainer.Size.Y + defaultOption.Size.Y);
|
||||
DropDownContainer.Controls.Add(defaultOption);
|
||||
defaultOption.Clicked += OptionOnClicked;
|
||||
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
|
||||
SelectedOption = defaultOption;
|
||||
}
|
||||
|
||||
public DropDown(Texture t, IRenderObject spacer)
|
||||
:base(t)
|
||||
{
|
||||
ip = this;
|
||||
TextureDisplay = TextureDisplay.HorizontalCenter;
|
||||
DropDownContainer = new()
|
||||
{
|
||||