I did a few things

Text rendering and settings changes.
This commit is contained in:
JacobTech 2024-09-25 12:45:20 -04:00
parent 2dee38084e
commit bd5405866b
31 changed files with 869 additions and 307 deletions

View File

@ -0,0 +1,14 @@
using System.Numerics;
namespace Luski.Classes.Attribs;
[AttributeUsage(AttributeTargets.Property)]
public class NumberSelectorAttribute : Attribute
{
public NumberSelectorAttribute(Type propertyType)
{
Kind = propertyType;
}
public Type Kind { get; init; }
}

View File

@ -0,0 +1,14 @@
using System.Numerics;
namespace Luski.Classes.Attribs.NumberSlider;
[AttributeUsage(AttributeTargets.Property)]
public class NumberDefault<TNumber> : Attribute where TNumber : INumber<TNumber>
{
public NumberDefault(TNumber @default)
{
Default = @default;
}
public TNumber Default { get; init; }
}

View File

@ -0,0 +1,14 @@
using System.Numerics;
namespace Luski.Classes.Attribs.NumberSlider;
[AttributeUsage(AttributeTargets.Property)]
public class NumberMax<TNumber> : Attribute where TNumber : INumber<TNumber>
{
public NumberMax(TNumber max)
{
Max = max;
}
public TNumber Max { get; init; }
}

View File

@ -0,0 +1,14 @@
using System.Numerics;
namespace Luski.Classes.Attribs.NumberSlider;
[AttributeUsage(AttributeTargets.Property)]
public class NumberMin<TNumber> : Attribute where TNumber : INumber<TNumber>
{
public NumberMin(TNumber min)
{
Min = min;
}
public TNumber Min { get; init; }
}

View File

@ -0,0 +1,23 @@
using Luski.Enums;
using Luski.Enums.Strings;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
namespace Luski.Classes.Attribs;
[AttributeUsage(AttributeTargets.Property)]
public class SettingInfoAttribute : Attribute
{
public SettingInfoAttribute(string group, byte Page)
{
Group = group;
this.Page = Page;
}
public ISettingsPage CreatePage()
{
return SettingsPage.Pages[Page].Page;
}
public byte Page { get; init; }
public string Group { get; init; }
}

View File

@ -0,0 +1,9 @@
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
namespace Luski.Classes;
public class SettingPageStruct
{
public string Name;
public ISettingsPage Page;
}

View File

@ -1,6 +1,10 @@
using System.ComponentModel;
using System.Text.Json.Serialization;
using GraphicsManager.Objects;
using Luski.Classes.Attribs;
using Luski.Classes.Attribs.NumberSlider;
using Luski.Enums;
using Luski.Enums.Strings;
namespace Luski.Classes;
@ -8,6 +12,7 @@ public class Settings
{
[JsonInclude]
[JsonPropertyName("scale")]
[SettingInfo(SettingGroup.AppSettings, SettingsPage.General)]
public double? Scale { get; set; } = null;
[JsonInclude]
[JsonPropertyName("perscrollpixels")]
@ -23,6 +28,7 @@ public class Settings
public string Theme { get; set; } = "Dark";
[JsonInclude]
[JsonPropertyName("experiments")]
[SettingInfo(SettingGroup.Advanced, SettingsPage.Experiments)]
public List<ExperimentJson> Experiments { get; set; } = Array.Empty<ExperimentJson>().ToList();
[JsonInclude]
[JsonPropertyName("default_display")]
@ -33,6 +39,7 @@ public class Settings
[JsonInclude]
[Shared.GlobalAttributes.DisplayName("Console Logs")]
[Description("The Log values for the console")]
[SettingInfo(SettingGroup.AppSettings, SettingsPage.General)]
[JsonPropertyName("log")]
public ConsoleLog Logs
{
@ -55,6 +62,7 @@ public class Settings
[Shared.GlobalAttributes.DisplayName("Scale Fonts")]
[Description("Scales fonts using the scale property")]
[JsonPropertyName("scale_fonts")]
[SettingInfo(SettingGroup.AppSettings, SettingsPage.General)]
public bool ScaleFonts
{
get
@ -89,9 +97,31 @@ public class Settings
[JsonInclude]
[JsonPropertyName("role_settings_font_px")]
public uint RoleSettingsFontPX { get; set; } = 14;
[JsonInclude]
[JsonPropertyName("message_font_px")]
public uint MessageFontPX { get; set; } = 17;
[SettingInfo(SettingGroup.AppSettings, SettingsPage.Appearance)]
[Shared.GlobalAttributes.DisplayName("Message Font Size")]
[Description("Sets the px value for the message font size")]
[NumberSelector(typeof(uint))]
[NumberMin<uint>(12)]
[NumberDefault<uint>(17)]
[NumberMax<uint>(24)]
public uint MessageFontPX
{
get
{
return mfpx;
}
set
{
mfpx = value;
if (Globals.MessageFont is not null) Globals.MessageFont.PixelHeight = value;
}
}
[JsonIgnore]
private uint mfpx = 17;
[JsonInclude]
[JsonPropertyName("message_font_line_space_px")]
public uint MessageFontLineSpacePX { get; set; } = 5;
@ -100,6 +130,7 @@ public class Settings
[Shared.GlobalAttributes.DisplayName("24 Hour Time")]
[Description("Shows time in the 24 hour format")]
[JsonPropertyName("24hour_time")]
[SettingInfo(SettingGroup.AppSettings, SettingsPage.General)]
public bool DayTime
{
get
@ -117,6 +148,7 @@ public class Settings
[Shared.GlobalAttributes.DisplayName("Memory Fonts")]
[Description("Stores fonts in memory for faster load times")]
[JsonPropertyName("memory_fonts")]
[SettingInfo(SettingGroup.AppSettings, SettingsPage.General)]
public bool StoreFontsInMemory
{
get

View File

@ -1,6 +1,8 @@
using System.ComponentModel;
using System.Text.Json.Serialization;
using Luski.net.Enums;
using Luski.Classes.Attribs;
using Luski.Enums.Strings;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
namespace Luski.Classes;
@ -10,31 +12,37 @@ public class UpdaterSettings
[Shared.GlobalAttributes.DisplayName("Self Contained")]
[Description("This tells the updater to download the self contained version of the app.")]
[JsonPropertyName("self_contained")]
[SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
public bool SelfContained { get; set; } = false;
[JsonInclude]
[JsonPropertyName("updater")]
[SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
public string? Updater { get; set; } = null;
[JsonInclude]
[JsonPropertyName("platform")]
[SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
public string Platform { get; set; } = "linux-x64";
[JsonInclude]
[Shared.GlobalAttributes.DisplayName("Auto Launch")]
[Description("Tells the updater to relaunch the app after the update is complete.")]
[JsonPropertyName("auto_launch")]
[SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
public bool AutoLaunch { get; set; } = true;
[JsonInclude]
[Description("If the app can check for updates and an update is available, then the app will start the update process automatically.")]
[Shared.GlobalAttributes.DisplayName("Auto Update")]
[JsonPropertyName("auto_update")]
[SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
public bool AutoUpdate { get; set; } = false;
[JsonInclude]
[Description("This will allow the client to check for update during the launch process.")]
[Shared.GlobalAttributes.DisplayName("Check For Updates")]
[JsonPropertyName("update_check")]
[SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
public bool AutoUpdateCheck { get; set; } = true;
}
@ -44,7 +52,4 @@ public class UpdaterSettings
PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
WriteIndented = true,
DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
internal partial class UpdaterSettingsContext : JsonSerializerContext
{
}
internal partial class UpdaterSettingsContext : JsonSerializerContext;

7
Luski/Enums/BlendType.cs Normal file
View File

@ -0,0 +1,7 @@
namespace Luski.Enums;
public enum BlendType
{
None,
MultiplyAlpha,
}

View File

@ -0,0 +1,8 @@
namespace Luski.Enums;
public enum LockingMode : byte
{
Points,
Int,
Float
}

View File

@ -0,0 +1,7 @@
namespace Luski.Enums.Strings;
public static class SettingGroup
{
public const string AppSettings = "App Settings";
public const string Advanced = "Advanced Settings";
}

View File

@ -0,0 +1,37 @@
using Luski.Classes;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
namespace Luski.Enums.Strings;
public static class SettingsPage
{
public static SettingPageStruct[] Pages = new[]
{
new SettingPageStruct()
{
Name = "Updater Config",
Page = new Updater()
},
new SettingPageStruct()
{
Name = "Experiments",
Page = new ExperimentSettings()
},
new SettingPageStruct()
{
Name = "General",
Page = new Generic("General", 2)
},
new SettingPageStruct()
{
Name = "Appearance",
Page = new Generic("Appearance", 3)
}
};
public const byte Updater = 0;
public const byte Experiments = 1;
public const byte General = 2;
public const byte Appearance = 3;
}

View File

@ -25,6 +25,7 @@ public class LuskiLabel : LabelBase
if (Shader is null) Shader = Globals.GradientShader[win.Context];
base.LoadToParent(window, win);
}
float _alpha = 1;
protected virtual (Color4,Color4) getGradcols(int Start, int charter, int End, int StartLine, int Line, int EndLine, GradType GT, Color4[] Colors)
{
Vector2i cl = GetCharLocation(charter);
@ -77,7 +78,6 @@ public class LuskiLabel : LabelBase
}
catch (Exception e)
{
LeftColor = Color4.DarkRed;
RightColor = Color4.DarkRed;
}
@ -88,7 +88,7 @@ public class LuskiLabel : LabelBase
float b = LeftColor.B + (RightColor.B - LeftColor.B) * t;
float a = LeftColor.A + (RightColor.A - LeftColor.A) * t;
return new Color4(r, g, b, a);
return new Color4(r, g, b, a * _alpha);
}
List<Tuple<TextCode, int, int, object?>> Commands = new();
@ -117,7 +117,7 @@ public class LuskiLabel : LabelBase
Commands.Clear();
List<(GradType, int)> RainGrad = new();
List<(Color4[], GradType, int)> Grad = new();
List<Color4> ccccc = new();
List<(Color4, BlendType)> ccccc = new();
List<bool> Itilacs = new();
List<FontSize> Fonts = new();
List<uint> Sizes = new();
@ -197,7 +197,6 @@ public class LuskiLabel : LabelBase
GradType gt = GradType.Line;
for (int j = 1; j < args.Length-2; j+=3)
{
Console.WriteLine(args[j]);
switch (args[j])
{
case "colors":
@ -218,7 +217,17 @@ public class LuskiLabel : LabelBase
i = brack;
Color_End.Add(sb.Length);
Color col = new(args[2].Replace("#", ""));
ccccc.Add(col.ToColor4());
BlendType bt = BlendType.None;
for (int j = 3; j < args.Length-2; j+=3)
{
switch (args[j])
{
case "blend":
bt = (BlendType)byte.Parse(args[j + 2]);
break;
}
}
ccccc.Add(new(col.ToColor4(), bt));
i = brack;
continue;
case "fontsize":
@ -319,7 +328,7 @@ public class LuskiLabel : LabelBase
i = brack;
continue;
}
Commands.Add(new(TextCode.Color, Color_End[Color_End.Count-1], sb.Length-1, ccccc[ccccc.Count-1]));
Commands.Add(new(TextCode.Color, Color_End[Color_End.Count-1], sb.Length-1, new Tuple<Color4, BlendType>(ccccc[ccccc.Count-1].Item1, ccccc[ccccc.Count-1].Item2) ));
Color_End.RemoveAt(Color_End.Count-1);
ccccc.RemoveAt(ccccc.Count-1);
i = brack;
@ -495,8 +504,12 @@ public class LuskiLabel : LabelBase
if ((xrel + w) >= lw) lw = (xrel + w);
}
}
MaxLineSizes.Add(new(new((int)lw,(int)lh), Largest));
max_lh += (uint) ((double) lh * ((double) Largest.CurrentFonts[0].Face.Height / (double) Largest.CurrentFonts[0].Face.UnitsPerEM) * (double) this.Scale);
if (Largest is not null)
{
MaxLineSizes.Add(new(new((int)lw,(int)lh), Largest));
max_lh += (uint) ((double) lh * ((double) Largest.CurrentFonts[0].Face.Height / (double) Largest.CurrentFonts[0].Face.UnitsPerEM) * (double) this.Scale);
}
Largest = null;
PlainText = sb.ToString();
@ -566,7 +579,7 @@ public class LuskiLabel : LabelBase
float angle_rad = (float)Math.Atan2(DIR.Y, DIR.X);
Matrix4 rotateM = Matrix4.CreateRotationZ(angle_rad);
Matrix4 transOriginM = Matrix4.CreateTranslation(new Vector3(loc_.X + Parent!.IntToWindow(0), loc_.Y + (MaxLineSizes[0].Item1.Y * Scale) + Parent!.IntToWindow(0, true), 0f));
float char_x = 0.0f;
float char_x = 0.0f;
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
@ -627,7 +640,18 @@ public class LuskiLabel : LabelBase
}
else if (com.Item1 == TextCode.Color)
{
col = new((Color4)com.Item4!, (Color4)com.Item4!);
Tuple<Color4, BlendType> item4 = (Tuple<Color4, BlendType>)com.Item4!;
if (item4.Item2 == BlendType.MultiplyAlpha)
{
_alpha = item4.Item1.A;
col = getGradcols(com.Item2, i, com.Item3, 0, line, 0, GradType.Block,
new Color4[] { DefaultColor, DefaultColor });
}
else
{
col = new(item4.Item1, item4.Item1);
}
}
else if (com.Item1 == TextCode.url)
{
@ -636,7 +660,7 @@ public class LuskiLabel : LabelBase
else
{
Tuple<Color4[], GradType, int, int> item4 = (Tuple<Color4[], GradType, int, int>)com.Item4!;
col = getGradcols(com.Item2, i, com.Item3, item4.Item3, line, item4.Item4, item4.Item2, item4.Item1);
col = getGradcols(com.Item2, i, com.Item3, item4.Item4, line, item4.Item4, item4.Item2, item4.Item1);
}
GL.Uniform4(Shader.GetUniformLocation("textColor"), col.Item1);
GL.Uniform4(Shader.GetUniformLocation("rightColor"), col.Item2);
@ -684,6 +708,13 @@ public class LuskiLabel : LabelBase
Active_Links.RemoveAt(Active_Links.Count-1);
}
Tuple<TextCode, int, int, object?> com2 = Commands[Active_Grads[Active_Grads.Count - 1]];
if (com2.Item1 == TextCode.Color)
{
Tuple<Color4, BlendType> item4 = (Tuple<Color4, BlendType>)com.Item4!;
if (item4.Item2 == BlendType.MultiplyAlpha) _alpha = 1;
}
Active_Grads.RemoveAt(Active_Grads.Count-1);
}
}

View File

@ -0,0 +1,227 @@
using System.Numerics;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.Enums;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class NumberSelector<TNumber> : UserControl where TNumber : INumber<TNumber>
{
public event Func<NumberSelector<TNumber>, Task>? ValueChanged;
public int Space
{
get
{
return space;
}
set
{
space = value;
progressBar.Location = new(value, progressBar.Location.Y, 0);
progressBar.Size = new(base.Size.X - value - value, progressBar.Size.Y);
//progressBar.SetLocation(value, progressBar.Location.Y);
//progressBar.SetSize(base.Size.X - value - value, progressBar.Size.Y);
progressBar.UpdateProgress();
Min = Min;
}
}
public TNumber Min
{
get
{
return _Min;
}
set
{
_Min = value;
L1.Text = value.ToString() + Suffix;
int x = GetX(value);
L1.SetLocation(x - (L1.Size.X/2) + space, L1.Location.Y);
L1.ForceDistanceUpdate(this);
MinLine.SetLocation(x + space, MinLine.Location.Y);
Max = Max;
Value = Value;
}
}
public TNumber Max
{
get
{
return progressBar.MaxProgressValue + Min;
}
set
{
progressBar.MaxProgressValue = value - Min;
L3.Text = value.ToString() + Suffix;
int x = GetX(value);
L3.SetLocation(x - (L3.Size.X/2) + space, L3.Location.Y);
MaxLine.SetLocation(x + space, MaxLine.Location.Y);
progressBar.UpdateProgress();
}
}
private int GetX(TNumber number)
{
return progressBar.GetParentLocation(number - Min, IgnoreEnd: true);
}
public TNumber Default { get; set; } = TNumber.Zero;
public TNumber Value
{
get
{
return progressBar.ProgressValue + Min;
}
set
{
int i = 0;
TNumber tmp = value - Min;
if (progressBar.ProgressValue == tmp) return;
BlockDraw = true;
progressBar.ProgressValue = tmp;
Type tt = typeof(TNumber);
if (tt == typeof(double))
L2Cursor.Text = Math.Round((double)(object)value, 2) + Suffix;
else if (tt == typeof(float))
L2Cursor.Text = Math.Round((float)(object)value, 2) + Suffix;
else
L2Cursor.Text = value.ToString() + Suffix;
int x = GetX(value);
L2Cursor.SetLocation(x - (L2Cursor.Size.X/2) + space, L2Cursor.Location.Y);
Cursor.SetLocation(x - (Cursor.Size.X/2) + space, MaxLine.Location.Y);
Cursor.ForceDistanceUpdate(this);
BlockDraw = false;
progressBar.UpdateProgress();
if (Loaded && ValueChanged is not null) ValueChanged.Invoke(this);
}
}
public bool LockToPoints { get; set; } = false;
public string Suffix = "";
private ProgressBar<TNumber> progressBar = new();
private Rectangle Cursor = new(), MinLine = new(), MaxLine = new();
private List<TNumber> ExtraPoints = new();
private int space = 5;
private TNumber _Min = TNumber.Zero, _Default = TNumber.Zero;
public Label
L1 = new(Globals.DefaultFont),
L2Default = new(Globals.DefaultFont),
L2Cursor = new(Globals.DefaultFont),
L3 = new(Globals.DefaultFont);
public NumberSelector()
{
base.SetSize(300.ScaleInt());
progressBar.SetSize(base.Size.X, 8.ScaleInt());
progressBar.Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right;
progressBar.DisallowAboveMax = false;
progressBar.DrawingGap.X = 1.ScaleInt();
progressBar.UpdateProgress();
progressBar.DrawingGap.X = 0;
progressBar.DrawingGap.Y = progressBar.DrawingGap.X;
progressBar.DrawingGap.Z = progressBar.DrawingGap.X;
progressBar.DrawingGap.W = progressBar.DrawingGap.X;
progressBar.ProgressGap.X = 4.ScaleInt();
progressBar.ProgressGap.Y = progressBar.ProgressGap.X;
progressBar.BackgroundColor = Color4.DarkRed;
progressBar.ProgressColor = Globals.DodgerBlue;
progressBar.UpdateOnDraw = false;
progressBar.Anchor = ObjectAnchor.Left | ObjectAnchor.Right;
progressBar.UpdateProgress();
progressBar.SetLocation(progressBar.Location.X, base.Size.Y-progressBar.Size.Y-progressBar.Size.Y);
progressBar.Clicked += ProgressBarOnClicked;
Cursor.SetSize(10.ScaleInt(),24.ScaleInt());
Cursor.SetLocation(0, base.Size.Y-Cursor.Size.Y);
Cursor.BackgroundColor = Color4.White;
Cursor.Anchor = ObjectAnchor.PreventWidthChange;
MinLine.SetSize(2.ScaleInt(), Cursor.Size.Y);
MinLine.SetLocation(0, Cursor.Location.Y);
MaxLine.SetSize(MinLine.Size.X, Cursor.Size.Y);
MaxLine.SetLocation(0, Cursor.Location.Y);
L1.Text = Min.ToString() + Suffix;
L1.Anchor = ObjectAnchor.Top | ObjectAnchor.Left;
L2Default.Text = Default.ToString() + Suffix;
L2Cursor.Text = Value.ToString() + Suffix;
L3.Text = Max.ToString() + Suffix;
L3.Anchor = ObjectAnchor.Top | ObjectAnchor.Right;
MaxLine.Anchor = L3.Anchor;
Controls.Add(progressBar);
MaxLine.BackgroundColor = Color4.Cyan;
MinLine.BackgroundColor = MaxLine.BackgroundColor;
Controls.Add(MinLine);
Controls.Add(L1);
Controls.Add(L3);
Controls.Add(L2Cursor);
Controls.Add(MaxLine);
Controls.Add(Cursor);
Cursor.ForceDistanceUpdate(this);
real_x = Cursor.Location.X;
//Controls.Add(L2Cursor);
progressBar.ForceDistanceUpdate(this);
AllowHoverFromBehind = true;
}
private Task ProgressBarOnClicked(IRenderObject arg)
{
Value = progressBar.GetValueFromX((int)Window!.MousePosition.X - progressBar.GetWindowLocation().X) + Min;
return Task.CompletedTask;
}
public void AddPoint(TNumber value)
{
if (value < _Min || value > Max) return;
ExtraPoints.Add(value);
}
public override void SetSize(int w, int h)
{
base.SetSize(w, 50.ScaleInt());
progressBar.SetSize(w, 8.ScaleInt());
progressBar.UpdateProgress();
progressBar.ForceDistanceUpdate(this);
Min = Min;
Value--;
Value++;
progressBar.UpdateProgress();
}
public override void LoadToParent(IParent p, IWindow w)
{
base.LoadToParent(p, w);
w.MouseUp += WindowOnMouseUp;
w.MouseMove += WindowOnMouseMove;
Cursor.Clicked += CursorOnClicked;
}
public bool Draging;
private int real_x, real_dif;
private Task CursorOnClicked(IRenderObject arg)
{
Draging = true;
real_dif = ((int)Window!.MousePosition.X - Cursor.GetWindowLocation().X);
real_x = Cursor.Location.X + real_dif;
return Task.CompletedTask;
}
private void WindowOnMouseMove(MouseMoveEventArgs obj)
{
if (!Draging) return;
real_x += (int)obj.DeltaX;
Value = progressBar.GetValueFromX(real_x) + Min;
}
private void WindowOnMouseUp(MouseButtonEventArgs obj)
{
if (!Draging) return;
Draging = false;
}
}

View File

@ -11,7 +11,7 @@ public class ProfileView : UserControl
{
public SocketUser User { get; set; }
private ProfileView(IRenderObject user, SocketUser u, ServerProfile p, Role r, Color[] c, ColorType ct)
private ProfileView(IRenderObject user, SocketUser u, ServerProfile p, Role r)
{
this.User = u;
base.Size = new(244.ScaleInt(), 44.ScaleInt());
@ -20,26 +20,20 @@ public class ProfileView : UserControl
user.ForceDistanceUpdate(this);
user.IgnoreHover = true;
LabelBase uname;
if (ct == ColorType.Full)
string name = p.DisplayName;
if (r.ColorType == ColorType.Full)
{
uname = new Label(Globals.DefaultFont)
{
Text = p.DisplayName,
Color = c[0].ToColor4(),
IgnoreHover = true
};
name = $"[color=\"{r.Colors[0].ToDatabaseStr()}\"]{name}[/color]";
}
else
{
uname = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = p.DisplayName,
Colors = c.ToColor4Array(),
IgnoreHover = true
};
name = $"[gradient colors=\"{r.Colors.ToDB()}\"]{name}[/gradient]";
}
LuskiLabel uname = new(Globals.DefaultFont)
{
Text = name,
IgnoreHover = true
};
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
@ -48,16 +42,7 @@ public class ProfileView : UserControl
public static async Task<ProfileView> Make(SocketUser u, ServerProfile p, Role r)
{
ColorType ct = await u.GetColorType();
Color[] c = await u.GetColors();
ColorType? cct = await p.GetColorType();
Color[]? cc = await p.GetColors();
if (cc is not null)
{
c = cc;
ct = cct!.Value;
}
ProfileView m = new(await p.MakeRct(u, new(32.ScaleInt())), u, p, r, c, ct);
ProfileView m = new(await p.MakeRct(u, new(32.ScaleInt())), u, p, r);
return m;
}
}

View File

@ -51,6 +51,8 @@ public class SettingsCategory<TSettingsMenu> : UserControl where TSettingsMenu :
Page.AllowHoverFromBehind = true;
Page.Anchor = ObjectAnchor.All;
Page.BackgroundColor = ss.BackgroundColor;
pagest.Add(typeof(TPage));
pages.Add(Page.PageName);
ss.Controls.Add(Page);
if (Page is PageFlow pbf) pbf.HScrollPixels = Globals.Settings.PerScrollPixels;
PageTab cb = new(Page.PageName, ss)
@ -66,6 +68,19 @@ public class SettingsCategory<TSettingsMenu> : UserControl where TSettingsMenu :
return cb;
}
private List<string> pages = new();
private List<Type> pagest = new();
public bool HasPage(string name)
{
return pages.Contains(name);
}
public bool HasPage(Type name)
{
return pagest.Contains(name);
}
public void RemovePage<TPage>(TPage Page) where TPage : ISettingsPage
{
if (Page.Tag is PageTab cb)

View File

@ -51,7 +51,7 @@ public class SettingsMenu : UserControl
private Task ClosebtnOnClicked(IRenderObject arg)
{
Globals.ms.Controls.Remove(this);
Globals.ms.Controls.Remove(this, false);
Globals.ms.Title = BehindName;
Globals.ms.DrawFrame();
return Task.CompletedTask;

View File

@ -1,6 +1,7 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.Enums;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Mathematics;
@ -18,37 +19,24 @@ public class UserView : UserControl
base.BackgroundColor = new(34, 34, 34, 255);
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
user.ForceDistanceUpdate(this);
string name = p.DisplayName;
if (r.ColorType == ColorType.Full)
{
Label uname = new(Globals.DefaultFont)
{
Text = p.DisplayName,
Color = r.Colors[0].ToColor4()
};
if (offline) uname.Color = new(uname.Color.R, uname.Color.G, uname.Color.B, uname.Color.A * 0.6f);
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
name = $"[color=\"{r.Colors[0].ToDatabaseStr()}\"]{name}[/color]";
}
else
{
AdvancedGradientLabel uname = new(Globals.DefaultFont)
{
Text = p.DisplayName,
Colors = r.Colors.ToColor4Array()
};
if (offline)
{
for (int i = 0; i < uname.Colors.Length; i++)
{
uname.Colors[i] = new(uname.Colors[i].R, uname.Colors[i].G, uname.Colors[i].B,
uname.Colors[i].A * 0.6f);
}
}
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
name = $"[gradient colors=\"{r.Colors.ToDB()}\"]{name}[/gradient]";
}
Console.WriteLine(name);
LuskiLabel uname = new(Globals.DefaultFont)
{
Text = (offline ? $"[color=\"#00000099\" blend=\"{(int)BlendType.MultiplyAlpha}\"]{name}[/color]" : name)
};
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
Controls.Add(user);
}

View File

@ -1,37 +1,54 @@
using System.Reflection;
using GraphicsManager.Enums;
using Luski.Classes;
using Luski.Classes.Attribs;
using Luski.Enums.Strings;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
using Luski.Shared.GlobalAttributes;
namespace Luski.GUI.MainScreen.UI.LuskiSettings;
public class GlobalSettingsMenu : SettingsMenu
{
private Appearance a;
private Dictionary<string, SettingsCategory<GlobalSettingsMenu>> categories = new();
private PageTab? First;
public GlobalSettingsMenu()
:base("Settings - Luski")
{
SettingsCategory<GlobalSettingsMenu> AppSettings = new("App Settings", this);
SettingsCategory<GlobalSettingsMenu> AdvancedSettings = new("Advanced Settings", this);
PageTab cb = AppSettings.AddPage(new General());
if (LuskiExperiments.Settings.Theme.IsEnabled()) _ = AppSettings.AddPage(a=new Appearance());
LuskiExperiments.Settings.Theme.EventToggled += b =>
LoadPages<Settings>();
LoadPages<UpdaterSettings>();
for (int i = 1; i < fl.Controls.Length; i++) // Fix the pos because why not and better than redrawing window
{
if (b)
{
_ = AppSettings.AddPage(a=new Appearance());
Globals.ms.ForceUpdate();
}
else AppSettings.RemovePage(a!);
return Task.CompletedTask;
};
_ = AdvancedSettings.AddPage(new ExperimentSettings());
_ = AdvancedSettings.AddPage(new Updater());
fl.Controls.Add(AppSettings);
fl.Controls.Add(AdvancedSettings);
cb.ToggleSelected().Wait();
fl.Controls[i].SetLocation(fl.Controls[i].Location.X, fl.Controls[i-1].Size.Y + fl.Controls[i-1].Location.Y);
}
First!.ToggleSelected().Wait();
Anchor = ObjectAnchor.All;
}
private void LoadPages<TFile>()
{
foreach (PropertyInfo prop in typeof(TFile).GetProperties())
{
if (!prop.TryGetAnyAttribute(out SettingInfoAttribute? p)) continue;
if (!categories.ContainsKey(p.Group))
{
categories.Add(p.Group, new SettingsCategory<GlobalSettingsMenu>(p.Group, this));
fl.Controls.Add(categories[p.Group]);
}
if (!categories[p.Group].HasPage(SettingsPage.Pages[p.Page].Name))
{
PageTab tab = categories[p.Group].AddPage(p.CreatePage());
if (First is null)
{
First = tab;
}
}
}
}
}

View File

@ -1,5 +1,7 @@
using System.Reflection;
using Luski.Classes;
using Luski.Classes.Attribs;
using Luski.Enums.Strings;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AppSettings;
@ -8,9 +10,9 @@ public class General : PageFlow
{
public General()
{
PageName = "General";
foreach (PropertyInfo prop in typeof(Settings).GetProperties())
{
object PropVal = prop.GetValue(Globals.Settings)!;
Type PropType = prop.PropertyType;
if (PropType.IsEnum)

View File

@ -0,0 +1,103 @@
using System.Numerics;
using System.Reflection;
using GraphicsManager.Enums;
using GraphicsManager.Objects;
using Luski.Classes;
using Luski.Classes.Attribs;
using Luski.Classes.Attribs.NumberSlider;
using Luski.Enums.Strings;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.GUI.MainScreen.UI.LuskiControls.SettingsMenuBase.Core;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiSettings.Pages;
public class Generic : PageFlow
{
public Generic(string Name, byte code, bool LoadEnums = true, bool LoadBools = true, bool LoadNumberSelectors = true)
{
PageName = Name;
foreach (PropertyInfo prop in typeof(Settings).GetProperties())
{
if (!prop.TryGetAnyAttribute(out SettingInfoAttribute? p)) continue;
if (p.Page != code) continue;
object PropVal = prop.GetValue(Globals.Settings)!;
Type PropType = prop.PropertyType;
if (LoadEnums && PropType.IsEnum)
{
IEnumerable<Enum> values = Enum.GetValues(PropType).Cast<Enum>();
foreach (var val in values)
{
try
{
Globals.AddBool(this, PropType, val, ((Enum)PropVal).HasFlag(val), bb =>
{
long va = Convert.ToInt64(val);
long v = Convert.ToInt64(PropVal);
object e;
if (bb) e = Enum.Parse(PropType, (v + va).ToString());
else e = Enum.Parse(PropType, (v - va).ToString());
PropVal = e;
prop.SetValue(Globals.Settings, e);
Globals.Settings.SaveSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
});
}
catch
{
//ignore
}
}
continue;
}
if (LoadBools && PropType.FullName == typeof(bool).FullName)
{
try
{
Globals.AddBool(this, prop, (bool)PropVal, b =>
{
prop.SetValue(Globals.Settings, b);
Globals.Settings.SaveSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
});
}
catch
{
// ignored
}
continue;
}
if (LoadNumberSelectors && prop.TryGetAnyAttribute(out NumberSelectorAttribute? typeinfo))
{
if (typeinfo.Kind.FullName == typeof(uint).FullName)
{
Globals.AddNumberSlider(this, prop, (uint)PropVal, b =>
{
prop.SetValue(Globals.Settings, b);
Globals.Settings.SaveSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
});
//AddSelector(prop, (uint)PropVal);
}
}
}
}
private void AddSelector<TNumber>(PropertyInfo prop , TNumber val) where TNumber : INumber<TNumber>
{
UserControl space = new();
space.BackgroundColor = Color4.Blue;
NumberSelector<TNumber> selector = new();
selector.BackgroundColor = this.BackgroundColor;
space.SetSize(Size.X, selector.Size.Y + 40.ScaleInt());
selector.SetSize(this.Size.X, 0);
selector.SetLocation(0,40.ScaleInt());
selector.Min = prop.GetAnyAttribute<NumberMin<TNumber>>().Min;
selector.Max = prop.GetAnyAttribute<NumberMax<TNumber>>().Max;
selector.Default = prop.GetAnyAttribute<NumberDefault<TNumber>>().Default;
selector.Value = val;
selector.Anchor = ObjectAnchor.All;
space.Controls.Add(selector);
Controls.Add(space);
}
}

View File

@ -21,7 +21,7 @@ public class Category : UserControl, IChannelAdder
public event Func<int, Task>? AddY;
private LabelBase Name;
private LuskiLabel Name;
public UserControl tmp;
public static Task<Category> MakeCat(SocketCategory cat, ChannelSelector cs)
@ -40,40 +40,19 @@ public class Category : UserControl, IChannelAdder
c.tmp.Clicked += c.TmpOnClicked;
c.tmp.HoverMouse = MouseCursor.Hand;
c.Controls.Add(c.tmp);
if (cat.ColorType == ColorType.Full)
c.tmp.Controls.Add(c.ee = new AdvancedGradientLabel(Globals.DefaultFont)
{
c.tmp.Controls.Add(c.ee = new Label(Globals.DefaultFont)
{
Text = ">",
Location = new(5.ScaleInt()),
Color = cat.Colors[0].ToColor4(),
DIR = new(1,0),
IgnoreHover = true
});
c.tmp.Controls.Add(c.Name = new Label(Globals.DefaultFont)
{
Text = cat.Name,
Color = cat.Colors[0].ToColor4(),
IgnoreHover = true
});
}
else
Text = ">",
Location = new(5.ScaleInt()),
DIR = new(1,0),
IgnoreHover = true
});
c.tmp.Controls.Add(c.Name = new(Globals.DefaultFont)
{
c.tmp.Controls.Add(c.ee = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = ">",
Location = new(5.ScaleInt()),
Colors = cat.Colors.ToColor4Array(),
DIR = new(1,0),
IgnoreHover = true
});
c.tmp.Controls.Add(c.Name = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = cat.Name,
Colors = cat.Colors.ToColor4Array(),
IgnoreHover = true
});
}
Text = cat.Name,
IgnoreHover = true
});
c.Clicked += c.AllOnClicked;
c.Name.Location = new(26.ScaleInt(), (((c.Size.Y - c.Name.Size.Y)/2)), 0);

View File

@ -42,24 +42,11 @@ public class Channel : UserControl
r.Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context];
Controls.Add(r);
if (chan.ColorType == ColorType.Full)
ChannelName = new(Globals.DefaultFont)
{
ChannelName = new Label(Globals.DefaultFont)
{
Text = chan.Name,
Color = chan.Colors[0].ToColor4(),
IgnoreHover = true
};
}
else
{
ChannelName = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = chan.Name,
Colors = chan.Colors.ToColor4Array(),
IgnoreHover = true
};
}
Text = chan.Name,
IgnoreHover = true
};
Controls.Add(ChannelName);
Clicked += AllOnClicked;
@ -80,24 +67,11 @@ public class Channel : UserControl
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
int i = 4.ScaleInt();
GC.Collect();
if (chan.ColorType == ColorType.Full)
ChannelName = new(Globals.DefaultFont)
{
ChannelName = new Label(Globals.DefaultFont)
{
Text = chan.Name,
Color = chan.Colors[0].ToColor4(),
IgnoreHover = true
};
}
else
{
ChannelName = new AdvancedGradientLabel(Globals.DefaultFont)
{
Text = chan.Name,
Colors = chan.Colors.ToColor4Array(),
IgnoreHover = true
};
}
Text = chan.Name,
IgnoreHover = true
};
Controls.Add(ChannelName);
Clicked += AllOnClicked;
ChannelName.Location = new(i,
@ -155,7 +129,7 @@ public class Channel : UserControl
Console.WriteLine(e);
}
}
public LabelBase ChannelName;
public LuskiLabel ChannelName;
public Rectangle r;
public static async Task<Channel> MakeChannel(SocketChannel chan, ChannelSelector cs)

View File

@ -34,22 +34,15 @@ public class ChatMessage : UserControl
{
SocketUser auth = (SocketUser)(await message.GetAuthor(CancellationToken.None));
ServerProfile prof = await message.GetProfile(CancellationToken.None);
Color[]? c = await prof.GetColors();
ColorType? ct = await prof.GetColorType();
if (c is null)
{
c = await auth.GetColors();
ct = await auth.GetColorType();
}
Color4[] c4 = (ct!.Value == ColorType.Full ? new Color4[]{c[0].ToColor4()} : new Color4[]{c[0].ToColor4(), c[1].ToColor4()});
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), prof, await prof.MakeRct(auth, new(40.ScaleInt())), ct.Value, c4);
Role r = (await ((SocketUser)await message.GetAuthor(CancellationToken.None)).GetRoles())[0];
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), prof, await prof.MakeRct(auth, new(40.ScaleInt())), r);
}
private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, ServerProfile Author, IRenderObject UserIcon, ColorType ct, Color4[] UserNameColor)
private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, ServerProfile Author, IRenderObject UserIcon, Role r)
{
pc = p;
LabelBase label1;
LuskiLabel label1;
base.SetSize(723.5.ScaleInt(), 37.ScaleInt());
ch = chan;
base.BackgroundColor = new(40, 40, 40, 255);
@ -92,8 +85,16 @@ public class ChatMessage : UserControl
UserIcon.Location = new(10.ScaleInt(), 2.ScaleInt(), 0);
Controls.Add(UserIcon);
if (ct == ColorType.Full) Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor[0], Text = Author.DisplayName });
else Controls.Add(label1 = new AdvancedGradientLabel(Globals.DefaultFont) { Colors = UserNameColor, Text = Author.DisplayName });
string name = Author.DisplayName;
if (r.ColorType == ColorType.Full)
{
name = $"[color=\"{r.Colors[0].ToDatabaseStr()}\"]{name}[/color]";
}
else
{
name = $"[gradient colors=\"{r.Colors.ToDB()}\"]{name}[/gradient]";
}
Controls.Add(label1 = new (Globals.DefaultFont) { Text = name });
label1.Location = new(
54.ScaleInt(),
UserIcon.Location.Y,
@ -101,11 +102,11 @@ public class ChatMessage : UserControl
Label label2;
LastObject = label1;
FirstL = label1;
Controls.Add(label2 = new Label(Globals.TopTimeFont) { Location = new(label1.Location.X + label1.Size.X + 8.ScaleInt(), (int)(label1.Location.Y + label1.Font.PixelHeight - Globals.TopTimeFont.PixelHeight), 0), Text = time_str});
Controls.Add(label2 = new(Globals.TopTimeFont) { Location = new(label1.Location.X + label1.Size.X + 8.ScaleInt(), (int)(label1.Location.Y + label1.Font.PixelHeight - Globals.TopTimeFont.PixelHeight), 0), Text = time_str});
if (!string.IsNullOrWhiteSpace(Msg.Context))
{
Label l;
Controls.Add(l = new Label(Globals.MessageFont) { Location = new(LastObject.Location.X, (int)(UserIcon.Location.Y + UserIcon.Size.Y - Globals.MessageFont.PixelHeight), 0), Text = message.Context});
LuskiLabel l;
Controls.Add(l = new(Globals.MessageFont) { Location = new(LastObject.Location.X, (int)(UserIcon.Location.Y + UserIcon.Size.Y - Globals.MessageFont.PixelHeight), 0), Text = message.Context});
LastObject = l;
LuskiContextMenu lcm = new();
Label llllll = lcm.AddLabel("Copy Text");
@ -118,10 +119,6 @@ public class ChatMessage : UserControl
};
}
l.ContextMenu = lcm;
if (Msg.Context == "test message with picture")
{
//Console.WriteLine(Msg.FileIDs.Length);
}
MessageObjs.Add(l);
}
Globals.Settings.DayTimeChanged += () =>

View File

@ -20,7 +20,8 @@ public class PublicChat : UserControl
{
public FlowLayout MessageFlow;
private LabelBase title, desc;
private Label desc;
private LuskiLabel title;
private TextBox tb;
private SocketChannel? Channel;
UserControl titlecon;
@ -73,11 +74,11 @@ public class PublicChat : UserControl
titlecon.ForceDistanceUpdate(this);
titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
titlecon.Controls.Add(title = new(Globals.DefaultFont)
{
//Location = new(
});
titlecon.Controls.Add(desc = new Label(Globals.DefaultFont)
titlecon.Controls.Add(desc = new(Globals.DefaultFont)
{
Color = new(161,161,161,255),
Location = new(title.Location.X + title.Size.X + 5, title.Location.Y, 0)
@ -427,30 +428,6 @@ public class PublicChat : UserControl
await UserConOnClicked(UserCon!);
}
if (channel.ColorType == ColorType.Full)
{
titlecon.Controls.Remove(title, false);
if (title is not Label) title = new Label(title.Font)
{
Location = title.Location
};
((Label)title).Color = channel.Colors[0].ToColor4();
titlecon.Controls.Add(title);
}
else
{
if (title is not AdvancedGradientLabel)
{
titlecon.Controls.Remove(title, false);
title = new AdvancedGradientLabel(title.Font)
{
Location = title.Location
};
titlecon.Controls.Add(title);
}
((AdvancedGradientLabel)title).Colors = channel.Colors.ToColor4Array();
}
title.Text = channel.Name;
var five = 5.ScaleInt();
title.Location = new(five + five,

View File

@ -1,6 +1,8 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.PublicServers.ServerSettings.Pages.Server.Roles;
@ -15,9 +17,9 @@ public class RoleMember : UserControl
int val = 8.ScaleInt();
icon.Result.Location = new(val, val, 0);
Controls.Add(icon.Result);
Label dn = new(Globals.DefaultFont)
LuskiLabel dn = new(Globals.DefaultFont)
{
Text = p.DisplayName
Text = u.ToDisplayString(p)
};
Controls.Add(dn);

View File

@ -30,14 +30,13 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
base.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
TextureDisplay = TextureDisplay.Center,
Anchor = ObjectAnchor.Prevent
};
Label t;
Form.Controls.Add(t=new Label(Globals.DefaultFont) { Scale = 1.6f, Text = "Server Login", Color = Globals.DodgerBlue });
@ -200,7 +199,8 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Size = new(page.Size.X, 30.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
AllowMultiLine = false,
Anchor = ObjectAnchor.Left | ObjectAnchor.Right
});
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
UserName.KeyPress += args =>
@ -360,7 +360,8 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Size = new(page.Size.X, 31.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
AllowMultiLine = false,
Anchor = ObjectAnchor.Left | ObjectAnchor.Right
});
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
UserName.KeyPress += args =>
@ -405,7 +406,8 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
WatermarkText = "Password",
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false,
PasswordChar = '●'
PasswordChar = '●',
Anchor = ObjectAnchor.Left | ObjectAnchor.Right
});
Password.Textures[0] = UserName.Textures[0];
Password.KeyPress += args =>
@ -463,7 +465,8 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
page = new()
{
Location = new(tb.Location.X, ca.Location.Y + ca.Size.Y + tb.Location.X, 0),
BackgroundColor = Form.BackgroundColor
BackgroundColor = Form.BackgroundColor,
Anchor = ObjectAnchor.All
};
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);
Form.Controls.Add(page);
@ -472,13 +475,15 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
{
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
TextureDisplay = TextureDisplay.Center,
Anchor = ObjectAnchor.All
};
_ = lo.ToggleSelected();
Label sub = new(Globals.DefaultFont)
{
Text = "Submit",
IgnoreHover = true
IgnoreHover = true,
Anchor = ObjectAnchor.All
};
sub.Location = new((btn.Size.X / 2) - (sub.Size.X / 2),
((btn.Size.Y - sub.Size.Y) / 2)

View File

@ -314,15 +314,6 @@ public class MainScreenWindow : Window
#region User Icon
ServerProfile DefaultProfile = await Server.GetProfile(Server.User.ServerProfile, CancellationToken.None);
ColorType ct = await Server.User.GetColorType();
Color[] c = await Server.User.GetColors();
ColorType? cct = await DefaultProfile.GetColorType();
Color[]? cc = await DefaultProfile.GetColors();
if (cc is not null)
{
c = cc;
ct = cct!.Value;
}
IRenderObject u = await DefaultProfile.MakeRct(Server.User, new(46.ScaleInt()));
int ii = 4.ScaleInt();
u.Location = new(ii, cs.Location.Y + cs.Size.Y + ii, 0);
@ -330,25 +321,20 @@ public class MainScreenWindow : Window
SerBox.Controls.Add(u);
u.LoadToParent(SerBox, this);
u.ForceDistanceUpdate();
LabelBase ul;
if (ct == ColorType.Full)
string name = DefaultProfile.DisplayName;
Role r = (await Server.User.GetRoles())[0];if (r.ColorType == ColorType.Full)
{
ul = new Label(Globals.DefaultFont)
{
Anchor = u.Anchor,
Text = DefaultProfile.DisplayName,
Color = c[0].ToColor4()
};
name = $"[color=\"{r.Colors[0].ToDatabaseStr()}\"]{name}[/color]";
}
else
{
ul = new AdvancedGradientLabel(Globals.DefaultFont)
{
Anchor = u.Anchor,
Text = DefaultProfile.DisplayName,
Colors = c.ToColor4Array()
};
name = $"[gradient colors=\"{r.Colors.ToDB()}\"]{name}[/gradient]";
}
LuskiLabel ul = new(Globals.DefaultFont)
{
Anchor = u.Anchor,
Text = name,
};
ul.Location = new(u.Location.X + u.Size.X + 5.ScaleInt(),
(u.Location.Y + ((u.Size.Y - ul.Size.Y) / 2)), 0);

View File

@ -1,5 +1,8 @@
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
@ -11,6 +14,7 @@ using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.Classes;
using Luski.Classes.Attribs.NumberSlider;
using Luski.Classes.ThemeSub;
using Luski.GUI;
using Luski.GUI.MainScreen.UI.LuskiControls;
@ -269,7 +273,8 @@ public static class Globals
};
UserControl tc = new()
{
BackgroundColor = new(0,0,0,0)
BackgroundColor = new(0,0,0,0),
Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right
};
Label l, ll;
int space = 5.ScaleInt();
@ -301,7 +306,65 @@ public static class Globals
tc.SetSize(parent.Size.X, TempLine.Location.Y + TempLine.Size.Y);
TempLine.ForceDistanceUpdate(tc);
tc.Controls.Add(TempLine);
//ts.ForceDistanceUpdate(tc);
ts.ForceDistanceUpdate(tc);
ts.ValueChanged += @switch =>
{
a.Invoke(@switch.Value);
return Task.CompletedTask;
};
tc.ForceDistanceUpdate(parent);
parent.Controls.Add(tc);
return tc;
}
public static UserControl AddNumberSlider<TNumber>(IParent parent, string Name, string description, TNumber defaul, TNumber min, TNumber val, TNumber max, Action<TNumber> a) where TNumber : INumber<TNumber>
{
NumberSelector<TNumber> ts = new()
{
Default = defaul,
Min = min,
Max = max,
Value = val,
Anchor = ObjectAnchor.Top | ObjectAnchor.Right | ObjectAnchor.Left,
BackgroundColor = new(0,0,0,0),
Space = 10.ScaleInt()
};
UserControl tc = new()
{
BackgroundColor = new(0,0,0,0)
};
Label l, ll;
int space = 5.ScaleInt();
tc.Controls.Add(ll =new Label(Globals.DefaultFont)
{
Location = new(0, space + space, 0),
Text = Name
});
tc.Controls.Add(l =new Label(Globals.DefaultFont)
{
Location = new(ll.Location.X, ll.Size.Y + space, 0),
Color = Color4.Gray,
MaxSize = parent.Size,
Text = description
});
tc.Size = l.Size;
tc.Controls.Add(ts);
ts.Location = new(5.ScaleInt(), l.Location.Y + l.Size.Y + space, 0);
Rectangle TempLine = new()
{
Location = new(0, ts.Location.Y + ts.Size.Y + space, 0),
BackgroundColor = Color4.White,
Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Top
};
l.Tag = TempLine;
TempLine.Size = new(parent.Size.X - space - space, 2.ScaleInt());
tc.SetSize(parent.Size.X, TempLine.Location.Y + TempLine.Size.Y);
ts.SetSize(TempLine.Size.X - 10.ScaleInt(), 0);
ts.SetLocation(TempLine.Location.X, ts.Location.Y);
ts.ForceDistanceUpdate(tc);
TempLine.ForceDistanceUpdate(tc);
tc.Controls.Add(TempLine);
ts.ValueChanged += @switch =>
{
a.Invoke(@switch.Value);
@ -339,7 +402,41 @@ public static class Globals
AddBool(parent, Name, description,s,a,List);
}
public static TAttribute GetAttribute<TAttribute, TEnum>(Type t, TEnum e) where TAttribute : Attribute where TEnum : Enum
public static void AddNumberSlider<TNumber>(IParent parent, PropertyInfo t, TNumber s, Action<TNumber> a) where TNumber : INumber<TNumber>
{
object[] valueAttributes =
t.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (valueAttributes.Length == 0) return;
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
object[] namevalueAttributes =
t.GetCustomAttributes(typeof(Luski.Shared.GlobalAttributes.DisplayNameAttribute), false);
if (namevalueAttributes.Length == 0) return;
string Name = ((Luski.Shared.GlobalAttributes.DisplayNameAttribute)namevalueAttributes[0]).DisplayName;
AddNumberSlider(parent, Name, description, t.GetAnyAttribute<NumberDefault<TNumber>>().Default, t.GetAnyAttribute<NumberMin<TNumber>>().Min, s, t.GetAnyAttribute<NumberMax<TNumber>>().Max,a);
}
public static TAttribute GetAnyAttribute<TAttribute>(this PropertyInfo t)
{
object[] valueAttributes =
t.GetCustomAttributes(typeof(TAttribute), false);
if (valueAttributes.Length == 0) throw new MissingMemberException("No attribute found");
return (TAttribute)valueAttributes[0];
}
public static bool TryGetAnyAttribute<TAttribute>(this PropertyInfo t, [NotNullWhen(true)]out TAttribute? attribute)
{
object[] valueAttributes =
t.GetCustomAttributes(typeof(TAttribute), false);
if (valueAttributes.Length == 0)
{
attribute = default;
return false;
}
attribute = (TAttribute)valueAttributes[0]!;
return true;
}
public static TAttribute GetEnumAttribute<TAttribute, TEnum>(this Type t, TEnum e) where TAttribute : Attribute where TEnum : Enum
{
MemberInfo? enumValueMemberInfo = GetMemberInfo(t, e);
object[] valueAttributes =
@ -347,6 +444,14 @@ public static class Globals
return (TAttribute)valueAttributes[0];
}
public static TAttribute GetEnumAttribute<TAttribute, TEnum>(this TEnum e) where TAttribute : Attribute where TEnum : Enum
{
MemberInfo? enumValueMemberInfo = GetMemberInfo(typeof(TAttribute), e);
object[] valueAttributes =
enumValueMemberInfo!.GetCustomAttributes(typeof(TAttribute), false);
return (TAttribute)valueAttributes[0];
}
public static TAttribute GetAttribute<TAttribute, TEnum>(MemberInfo enumValueMemberInfo, TEnum e) where TAttribute : Attribute where TEnum : Enum
{
object[] valueAttributes =
@ -384,7 +489,7 @@ public static class Globals
StringBuilder sb = new();
foreach (Color c in col)
{
sb.Append(Convert.ToHexString(new byte[] { c.R, c.G, c.B, c.A }));
sb.Append(c.ToDatabaseStr());
}
return sb.ToString();
}
@ -419,6 +524,36 @@ public static class Globals
public static ServerProfile? ServerProfile = null;
public static string ToDisplayString(this ServerProfile profile)
{
return profile.DisplayName;
}
public static string ToDisplayString(this SocketUser user)
{
Task<ServerProfile> profile = user.Server.GetProfile(user.ServerProfile, CancellationToken.None);
profile.Wait();
return user.ToDisplayString(profile.Result);
}
public static string ToDisplayString(this SocketUser user, ServerProfile profile)
{
string name = profile.DisplayName;
Task<Role[]> roles = user.GetRoles();
roles.Wait();
Role r = roles.Result[0];
if (r.ColorType == ColorType.Full)
{
name = $"[color=\"{r.Colors[0].ToDatabaseStr()}\"]{name}[/color]";
}
else
{
name = $"[gradient colors=\"{r.Colors.ToDB()}\"]{name}[/gradient]";
}
return name;
}
public static async Task<IRenderObject> MakeRct<TUser>(this ServerProfile Profile, TUser User, Vector2i Size) where TUser : SocketUser
{
Texture t = ms.TextureManager.GetTextureResource("Status.png");
@ -427,44 +562,17 @@ public static class Globals
UserControl r = new(t);
r.Size = Size;
r.Shader = Rectangle.DefaultAlphaShader[ms.Context];
ColorType ct = await User.GetColorType();
Color[] c = await User.GetColors();
ColorType? cct = await Profile.GetColorType();
Color[]? cc = await Profile.GetColors();
if (cc is not null)
{
c = cc;
ct = cct!.Value;
}
r.BackgroundColor = new(25, 25, 25, 255);
if (ct == ColorType.Full)
LuskiLabel l = new(DefaultFont)
{
Label l = new(DefaultFont)
{
Color = c[0].ToColor4()
};
l.Text = Profile.DisplayName[0].ToString();
Vector2i y = l.GetSizeOfChar(0),
yy = l.GetBearingOfChar(0);
l.Location = new((r.Size.X - l.Size.X)/2,
(int)(r.Size.Y - l.Font.PixelHeight + yy.Y - (r.Size.Y / 2) - (y.Y/2)),
0);
r.Controls.Add(l);
}
else
{
AdvancedGradientLabel l = new(DefaultFont)
{
Colors = c.ToColor4Array()
};
l.Text = Profile.DisplayName[0].ToString();
Vector2i y = l.GetSizeOfChar(0),
yy = l.GetBearingOfChar(0);
l.Location = new((r.Size.X - l.Size.X)/2,
(int)(r.Size.Y - l.Font.PixelHeight + yy.Y - (r.Size.Y / 2) - (y.Y/2)),
0);
r.Controls.Add(l);
}
Text = Profile.DisplayName[0].ToString(),
};
Vector2i y = l.GetSizeOfChar(0),
yy = l.GetBearingOfChar(0);
l.Location = new((r.Size.X - l.Size.X)/2,
(int)(r.Size.Y - l.Font.PixelHeight + yy.Y - (r.Size.Y / 2) - (y.Y/2)),
0);
r.Controls.Add(l);
return r;
}
else

View File

@ -22,8 +22,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.1.0-alpha50" />
<PackageReference Include="Luski.net" Version="2.0.1-alpha15" />
<PackageReference Include="GraphicsManager" Version="1.1.0-alpha68" />
<PackageReference Include="Luski.net" Version="2.0.1-alpha17" />
</ItemGroup>
<ItemGroup>
@ -48,4 +48,8 @@
<ApplicationIcon>Luski.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
</Project>

View File

@ -1,7 +1,11 @@
using System.Diagnostics;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Objects.Core;
using Luski;
using Luski.Classes;
using Luski.GUI;
using Luski.GUI.MainScreen.UI.LuskiControls;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common.Input;
using SixLabors.ImageSharp;
@ -10,23 +14,6 @@ using Image = OpenTK.Windowing.Common.Input.Image;
try
{
unsafe
{
int * a1;
int * a2;
int b1;
b1 = 20;
a1 = &b1;
a2 = a1;
*a1 = 25;
Console.WriteLine(*a2);
}
Globals.Settings = Globals.GetSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
foreach (ExperimentInfo le in LuskiExperiments.LuskiExperimentsList)
{
@ -90,15 +77,6 @@ try
Globals.Icon = new WindowIcon(new Image(Logo.Width, Logo.Height, pixels));
Logo.Dispose();
Console.WriteLine(new Color4[]{
Color4.Red,
Color4.Orange,
Color4.Yellow,
Color4.Green,
Color4.Blue,
Color4.Indigo,
Color4.Violet,
}.ToDB());
MainScreenWindow.Settings.Icon = Globals.Icon;
Globals.ms = new MainScreenWindow();