Coordinates & Switches

• The client now uses the new coordinate system.
• Added a new control for a toggle switch.
This commit is contained in:
JacobTech 2024-04-11 15:44:12 -04:00
parent 149c893d3b
commit 452009675e
21 changed files with 459 additions and 112 deletions

View File

@ -1,4 +1,6 @@
using System.ComponentModel;
using System.Text.Json.Serialization;
using GraphicsManager.Objects;
namespace Luski.Classes;
@ -29,11 +31,53 @@ public class Settings
/// 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; set; } = (ConsoleLog)(-25);
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; set; } = true;
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;
@ -46,9 +90,30 @@ public class Settings
[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; set; } = false;
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;
}

View File

@ -1,3 +1,4 @@
using System.ComponentModel;
using System.Text.Json.Serialization;
using Luski.net.Enums;
@ -6,26 +7,29 @@ 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("branch")]
public string Branch { get; set; } = "beta";
[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;
}

View File

@ -1,13 +1,21 @@
using System.ComponentModel;
namespace Luski;
[Flags]
public enum ConsoleLog : int
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
}

View File

@ -30,7 +30,7 @@ public class AccountButton : UserControl
((base.Size.Y - l.Size.Y) / 2)
, 0);
Controls.Add(l);
BackgroundColor = new(0, 0, 0, 0);
base.BackgroundColor = new(0, 0, 0, 0);
Clicked += OnClicked;
MouseEnter += o =>
{

View File

@ -26,7 +26,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
public AddServerOverlay()
{
base.Size = Globals.ms.Size;
base.Size = Globals.ms.ClientSize;
BackgroundColor = new(0, 0, 0, 130);
Anchor = ObjectAnchor.All;

View File

@ -10,7 +10,7 @@ public class FullScreenMedia : UserControl
public FullScreenMedia(Texture t)
{
base.Size = Globals.ms.Size;
base.Size = Globals.ms.ClientSize;
IMG = new(t)
{
Size = t.RawSize!.Value,

View File

@ -0,0 +1,52 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class ToggleSwitch : UserControl
{
public ToggleSwitch()
:base(Globals.ms.TextureManager.GetTextureResource("Toggle.png"))
{
base.Size = new(40.ScaleInt(), 24.ScaleInt());
base.BackgroundColor = OffBackgroundColor;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
Clicked += o =>
{
Value = !Value;
return Task.CompletedTask;
};
}
public event Func<ToggleSwitch, Task>? ValueChanged;
public override void LoadToParent(IParent Parent, IWindow Window)
{
Value = !Value;
Value = !Value;
base.LoadToParent(Parent, Window);
}
public new Vector2i Size
{
get => base.Size;
private set => base.Size = value;
}
public bool Value
{
get => val;
set
{
if (value) BackgroundColor = OnBackgroundColor;
else BackgroundColor = OffBackgroundColor;
val = value;
if (Loaded && ValueChanged is not null) ValueChanged.Invoke(this);
}
}
public Color4 OnBackgroundColor { get; set; }= new(35, 165, 90, 255);
public Color4 OffBackgroundColor { get; set; } = new(128, 132, 142, 255);
private bool val = true;
}

View File

@ -18,7 +18,7 @@ public class AddChannel : UserControl
{
this.CA = CA;
Cat = cat;
base.Size = Globals.ms.Size;
base.Size = Globals.ms.ClientSize;
base.BackgroundColor = new(0, 0, 0, 130);
Anchor = ObjectAnchor.All;
FlowLayout fl = new()

View File

@ -88,9 +88,10 @@ public class ChatMessage : UserControl
//(int)(UserIcon.Location.Y + (UserIcon.Size.Y / 2) - (label1.Font.CurrentFonts[0].Face.Size.Metrics.NominalHeight / 2) - label1.Size.Y + label1.Font.PixelHeight),
UserIcon.Location.Y,
0);
Label label2;
LastObject = label1;
FirstL = label1;
Controls.Add(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 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});
if (!string.IsNullOrWhiteSpace(Msg.Context))
{
Label l;
@ -98,6 +99,42 @@ public class ChatMessage : UserControl
LastObject = l;
MessageObjs.Add(l);
}
Globals.Settings.DayTimeChanged += () =>
{
if (Globals.Settings.DayTime)
{
if (time.Date == DateTime.Now.ToLocalTime().Date)
{
time_str = $"Today at {time:HH:mm}";
}
else if (time.Date == DateTime.Now.ToLocalTime().AddDays(-1).Date)
{
time_str = $"Yesterday at {time:HH:mm}";
}
else
{
time_str = $"{time:M/dd/yyyy HH:mm}";
}
}
else
{
if (time.Date == DateTime.Now.ToLocalTime().Date)
{
time_str = $"Today at {time.ToShortTimeString().Replace('\u202f', ' ')}";
}
else if (time.Date == DateTime.Now.ToLocalTime().AddDays(-1).Date)
{
time_str = $"Yesterday at {time.ToShortTimeString().Replace('\u202f', ' ')}";
}
else
{
time_str = $"{time:M/dd/yyyy h:mm tt}";
}
}
label2.Text = time_str;
return Task.CompletedTask;
};
if (Msg.Files.Count > 0)
{
@ -219,6 +256,13 @@ public class ChatMessage : UserControl
string b;
if (!Globals.Settings.DayTime) b = time.ToString("h:mm tt");
else b = time.ToString("HH:mm");
Globals.Settings.DayTimeChanged += () =>
{
if (!Globals.Settings.DayTime) b = time.ToString("h:mm tt");
else b = time.ToString("HH:mm");
return Task.CompletedTask;
};
Label[] l = Labels.Where(s => s.Text == b).ToArray();
if (l.Any())
{
@ -242,6 +286,12 @@ public class ChatMessage : UserControl
{
Text = time.ToString("HH:mm"),
};
Globals.Settings.DayTimeChanged += () =>
{
if (!Globals.Settings.DayTime) m.Text = time.ToString("h:mm tt");
else m.Text = time.ToString("HH:mm");
return Task.CompletedTask;
};
m.Location = new(
label.Location.X - m.Size.X - 5.ScaleInt(),
(int)(label.Location.Y + label.Font.PixelHeight - Globals.SmallTimeFont.PixelHeight),

View File

@ -6,10 +6,12 @@ using GraphicsManager.Objects;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
using OpenTK.Graphics.ES11;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Common.Input;
using OpenTK.Windowing.GraphicsLibraryFramework;
using MatrixMode = OpenTK.Graphics.OpenGL.MatrixMode;
namespace Luski.GUI.MainScreen.UI.PublicServers;
@ -33,7 +35,7 @@ public class PublicChat : UserControl
Anchor = ObjectAnchor.All;
Controls.Add(MessageFlow = new()
{
Size = new(base.Size.X, 761.ScaleInt()),
Size = new(base.Size.X, 785.ScaleInt()),
Location = new(0, 52.ScaleInt(), 0),
BackgroundColor = new(40,40,40,255),
Anchor = ObjectAnchor.All,
@ -55,23 +57,20 @@ public class PublicChat : UserControl
Size = new(980.ScaleInt(), 48.ScaleInt()),
BackgroundColor = new(50,50,50,255),
});
if (LuskiExperiments.GUI.MemberList.IsEnabled())
{
UserCon =
new(Globals.ms.TextureManager.GetTextureResource("person.png"))
{
Size = new(24.ScaleInt()),
Location = new(944.ScaleInt(), 12.ScaleInt(),0),
Anchor = ObjectAnchor.Right | ObjectAnchor.Top,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.LightGray
};
UserCon.MouseEnter += o => { UserCon.BackgroundColor = Color4.White; return Task.CompletedTask; };
UserCon.MouseLeave += o => { UserCon.BackgroundColor = Color4.LightGray; return Task.CompletedTask; };
UserCon.Clicked += UserConOnClicked;
titlecon.Controls.Add(UserCon);
}
LuskiExperiments.GUI.MemberList.EventToggled += MemberListOnEventToggled;
UserCon =
new(Globals.ms.TextureManager.GetTextureResource("person.png"))
{
Size = new(24.ScaleInt()),
Location = new(944.ScaleInt(), 12.ScaleInt(),0),
Anchor = ObjectAnchor.Right | ObjectAnchor.Top,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.LightGray
};
UserCon.MouseEnter += o => { UserCon.BackgroundColor = Color4.White; return Task.CompletedTask; };
UserCon.MouseLeave += o => { UserCon.BackgroundColor = Color4.LightGray; return Task.CompletedTask; };
UserCon.Clicked += UserConOnClicked;
titlecon.Controls.Add(UserCon);
titlecon.ForceDistanceUpdate(this);
titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
@ -131,7 +130,6 @@ public class PublicChat : UserControl
if (cm.MessageObjs[i] is Label l)
{
l.MaxSize = new(MessageFlow.Size.X - l.Location.X - 10.ScaleInt(), Int32.MaxValue);
//l.Text = l.Text;
}
}
@ -171,8 +169,11 @@ public class PublicChat : UserControl
private async Task TbOnKeyPress(KeyboardKeyEventArgs arg)
{
//var t = Matrix4.Identity * Matrix4.CreateScale(2 / (float)Size.X, 2 / (float)Size.Y, 1) * Matrix4.CreateTranslation(-1.0f, -1.0f, 0.0f);
//var tt = Matrix4.CreateOrthographicOffCenter(0.0f, Size.X, 0.0f, Size.Y, 1, -1);
if (arg.Key == Keys.Enter && !arg.Shift)
{
await Channel!.SendMessage(tb.Text);
tb.Text = string.Empty;
tb.CursorLocation = 0;
@ -196,33 +197,7 @@ public class PublicChat : UserControl
BlockDraw = false;
return Task.CompletedTask;
}
private async Task MemberListOnEventToggled(bool arg)
{
if (arg)
{
UserCon =
new(Globals.ms.TextureManager.GetTextureResource("person.png"))
{
Size = new(24.ScaleInt()),
Location = new(base.Size.X - 36.ScaleInt(), 12.ScaleInt(),0),
Anchor = ObjectAnchor.Right | ObjectAnchor.Top,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.LightGray
};
UserCon.MouseEnter += o => { UserCon.BackgroundColor = Color4.White; return Task.CompletedTask; };
UserCon.MouseLeave += o => { UserCon.BackgroundColor = Color4.LightGray; return Task.CompletedTask; };
UserCon.Clicked += UserConOnClicked;
titlecon.Controls.Add(UserCon);
}
else
{
if (um_open) await UserConOnClicked(UserCon!);
titlecon.Controls.Remove(UserCon!);
UserCon = null;
}
}
private bool um_open = false;
private bool SeperateOffline = true;

View File

@ -73,9 +73,9 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
Controls.Add(SelectedRect);
Controls.Add(rr);
Controls.Add(r);
BackgroundColor = new(26, 26, 26, 255);
base.BackgroundColor = new(26, 26, 26, 255);
this.Clicked += OnClicked;
Size = new(68.ScaleInt(), 48.ScaleInt());
base.Size = new(68.ScaleInt(), 48.ScaleInt());
}
private async Task OnClicked(IRenderObject arg)

View File

@ -26,8 +26,8 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
public ServerLoginOverlay(string address)
{
base.Size = Globals.ms.Size;
BackgroundColor = new(0, 0, 0, 130);
base.Size = Globals.ms.ClientSize;
base.BackgroundColor = new(0, 0, 0, 130);
Anchor = ObjectAnchor.All;

View File

@ -1,3 +1,5 @@
using System.ComponentModel;
using System.Reflection;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
@ -13,7 +15,7 @@ public class SettingsMenu : UserControl
{
private string BehindName;
public FlowLayout page;
public CategoryButton? Selected;
public CategoryButton? Selected, apper;
private FlowLayout fl;
private Category? AppSettings;
private FontInteraction f;
@ -24,7 +26,7 @@ public class SettingsMenu : UserControl
BehindName = Globals.ms.Title;
Globals.ms.Title = "Settings - Luski";
base.BackgroundColor = new(34, 34, 34, 255);
base.Size = Globals.ms.Size;
base.Size = Globals.ms.ClientSize;
Anchor = ObjectAnchor.All;
if (CategoryButton.seltec is null)
{
@ -39,11 +41,89 @@ public class SettingsMenu : UserControl
f = Globals.DefaultFont.Clone();
f.FontSize = FontSize.Bold;
f.PixelHeight = (uint)(f.PixelHeight * 1.4f);
AppSettings = new("APP SETTINGS");
CategoryButton cb3 = new("General", this)
{
OnPageLoad = () =>
{
page!.Controls.Add(new Label(f)
{
Text = " \nGeneral\n "
});
foreach (PropertyInfo prop in typeof(Settings).GetProperties())
{
object PropVal = prop.GetValue(Globals.Settings)!;
Type PropType = prop.PropertyType;
if (PropType.IsEnum)
{
IEnumerable<Enum> values = Enum.GetValues(PropType).Cast<Enum>();
foreach (var val in values)
{
try
{
MemberInfo[] memberInfos =
PropType.GetMember(val.ToString());
MemberInfo? enumValueMemberInfo = memberInfos.FirstOrDefault(m =>
m.DeclaringType == PropType);
object[] valueAttributes =
enumValueMemberInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (valueAttributes.Length == 0) continue;
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, ((Enum)PropVal).HasFlag(val), bb =>
{
long va = Convert.ToInt64(val);
long v = Convert.ToInt64(PropVal);
if (bb)
{
object e = Enum.Parse(PropType, (v + va).ToString());
PropVal = e;
prop.SetValue(Globals.Settings, e);
}
else
{
var 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
}
}
}
if (PropType.FullName == typeof(bool).FullName)
{
try
{
object[] valueAttributes =
prop.GetCustomAttributes(typeof(DescriptionAttribute), false);
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, (bool)PropVal, b =>
{
prop.SetValue(Globals.Settings, b);
Globals.Settings.SaveSettings(Path.Combine(Globals.LuskiPath, "Settings.json"), SettingsContext.Default.Settings);
});
}
catch
{
// ignored
}
}
}
}
};
AppSettings.AddButton(cb3);
fl.Controls.Add(AppSettings);
if (LuskiExperiments.Settings.Theme.IsEnabled())
{
AppSettings = new("APP SETTINGS");
Label Top = new(Globals.DefaultFont)
{
Location = new(5.ScaleInt(), 5.ScaleInt(), 0),
@ -147,12 +227,40 @@ public class SettingsMenu : UserControl
{
BackgroundColor = this.BackgroundColor,
Location = new(fl.Size.X + 40.ScaleInt(), 0, 0),
Size = new(Globals.ms.Size.X - fl.Size.X - 80.ScaleInt(), Globals.ms.Size.Y),
Size = new(Globals.ms.ClientSize.X - fl.Size.X - 80.ScaleInt(), Globals.ms.Size.Y),
AllowHoverFromBehind = true,
Anchor = ObjectAnchor.All,
HScrollPixels = Globals.Settings.PerScrollPixels
};
Controls.Add(page);
void AddBool(string Name, bool s, Action<bool> a)
{
ToggleSwitch ts = new()
{
Value = s
};
UserControl tc = new()
{
Size = ts.Size,
BackgroundColor = page.BackgroundColor
};
Label l;
tc.Controls.Add(l =new Label(Globals.DefaultFont)
{
Text = Name + ": "
});
tc.Size = l.Size;
tc.Controls.Add(ts);
ts.Location = new(l.Size.X + 10.ScaleInt(), 0, 0);
ts.ValueChanged += @switch =>
{
a.Invoke(@switch .Value);
return Task.CompletedTask;
};
page.Controls.Add(tc);
}
page.ForceDistanceUpdate(this);
Category As = new("ADVANCED SETTINGS");
CategoryButton cb = new("Experiments", this)
@ -174,7 +282,7 @@ public class SettingsMenu : UserControl
{
g.line.WindowLoaded += _ =>
{
page.ParentResize(new(Globals.ms.Size));
page.ParentResize(new(Globals.ms.ClientSize));
return Task.CompletedTask;
};
}
@ -190,10 +298,7 @@ public class SettingsMenu : UserControl
});
void AddBool(string Name, ref bool s)
{
}
TextBox t;
page!.Controls.Add(t =new TextBox()
@ -205,6 +310,71 @@ public class SettingsMenu : UserControl
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
});
foreach (PropertyInfo prop in typeof(UpdaterSettings).GetProperties())
{
object PropVal = prop.GetValue(Globals.UpdaterSettings)!;
Type PropType = prop.PropertyType;
if (PropType.IsEnum)
{
IEnumerable<Enum> values = Enum.GetValues(PropType).Cast<Enum>();
foreach (var val in values)
{
try
{
MemberInfo[] memberInfos =
PropType.GetMember(val.ToString());
MemberInfo? enumValueMemberInfo = memberInfos.FirstOrDefault(m =>
m.DeclaringType == PropType);
object[] valueAttributes =
enumValueMemberInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (valueAttributes.Length == 0) continue;
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, ((Enum)PropVal).HasFlag(val), bb =>
{
long va = Convert.ToInt64(val);
long v = Convert.ToInt64(PropVal);
if (bb)
{
object e = Enum.Parse(PropType, (v + va).ToString());
PropVal = e;
prop.SetValue(Globals.Settings, e);
}
else
{
var e = Enum.Parse(PropType, (v - va).ToString());
PropVal = e;
prop.SetValue(Globals.Settings, e);
}
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
});
}
catch
{
//ignore
}
}
}
if (PropType.FullName == typeof(bool).FullName)
{
try
{
object[] valueAttributes =
prop.GetCustomAttributes(typeof(DescriptionAttribute), false);
string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, (bool)PropVal, b =>
{
prop.SetValue(Globals.Settings, b);
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
});
}
catch
{
// ignored
}
}
}
t.ForceDistanceUpdate(page);
t.KeyPress += args =>
{
@ -212,7 +382,7 @@ public class SettingsMenu : UserControl
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
return Task.CompletedTask;
};
Globals.ms.ForceUpdate(new(Globals.ms.Size));
Globals.ms.ForceUpdate(new(Globals.ms.ClientSize));
}
};
As.AddButton(cb);
@ -221,11 +391,11 @@ public class SettingsMenu : UserControl
fl.ForceDistanceUpdate(this);
_ = cb.ToggleSelected();
_ = cb3.ToggleSelected();
Rectangle closebtn = new(Globals.ms.TextureManager.GetTextureResource("close.png"))
{
Location = new(Globals.ms.Size.X - 40.ScaleInt(), 8.ScaleInt(),0),
Location = new(Globals.ms.ClientSize.X - 40.ScaleInt(), 8.ScaleInt(),0),
Size = new(32.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Gray,
@ -251,8 +421,7 @@ public class SettingsMenu : UserControl
{
if (arg)
{
AppSettings = new("APP SETTINGS");
CategoryButton cb = new("Appearance", this)
apper = new("Appearance", this)
{
OnPageLoad = () =>
{
@ -262,13 +431,12 @@ public class SettingsMenu : UserControl
});
}
};
AppSettings.AddButton(cb);
fl.Controls.Insert(0, AppSettings);
AppSettings!.AddButton(apper);
fl.ScrollToBottom();
}
else
{
fl.Controls.Remove(AppSettings!);
AppSettings!.RemoveButton(apper);
}
return Task.CompletedTask;

View File

@ -49,4 +49,17 @@ public class Category : UserControl
line.Location = new(line.Location.X, line.Location.Y + cb.Size.Y + f, 0);
Size = new(Size.X, Size.Y + cb.Size.Y + f);
}
public void RemoveButton(CategoryButton cb)
{
int f = 5.ScaleInt();
line.Location = new(line.Location.X, line.Location.Y - cb.Size.Y - f, 0);
Controls.Remove(cb);
Size = new(Size.X, Size.Y - cb.Size.Y + f);
for (int i = 0; i < Controls.Length; i++)
{
ReportSizeUpdate(Controls[i]);
}
TryDraw();
}
}

View File

@ -130,7 +130,7 @@ public class ExperimentGUI : UserControl
}
dd.OptionSelected += DdOnOptionSelected;
Controls.Add(dd);
base.Size = new(Globals.ms.Size.X - 307.ScaleInt() - 80.ScaleInt(), 15.ScaleInt() + dd.Size.Y + dd.Location.Y );
base.Size = new(Globals.ms.ClientSize.X - 307.ScaleInt() - 80.ScaleInt(), 15.ScaleInt() + dd.Size.Y + dd.Location.Y );
dd.Size = new(base.Size.X - Top.Location.X - Top.Location.X, dd.Size.Y);
dd.ForceDistanceUpdate(this);

View File

@ -2,6 +2,7 @@ using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using GraphicsManager.Enums;
using GraphicsManager.Globals;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
@ -9,20 +10,26 @@ using Luski.GUI.MainScreen.UI;
using Luski.GUI.MainScreen.UI.PublicServers;
using Luski.net;
using Luski.net.Structures.Public;
using OpenTK.Graphics.GL;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;
using DebugProc = OpenTK.Graphics.OpenGL4.DebugProc;
using DebugSeverity = OpenTK.Graphics.OpenGL4.DebugSeverity;
using DebugSource = OpenTK.Graphics.OpenGL4.DebugSource;
using DebugType = OpenTK.Graphics.OpenGL4.DebugType;
using Window = GraphicsManager.Window;
namespace Luski.GUI;
public class MainScreenWindow : Window
{
private static readonly NativeWindowSettings Settings = new()
public static readonly NativeWindowSettings Settings = new()
{
Title = "Luski",
WindowBorder = WindowBorder.Fixed,
WindowBorder = WindowBorder.Resizable,
APIVersion = new Version(3, 2),
API = ContextAPI.OpenGL,
StartFocused = true,
@ -89,6 +96,7 @@ public class MainScreenWindow : Window
public MainScreenWindow() : base(Settings)
{
Globals.ms = this;
Size = new(1332.ScaleInt(), 866.ScaleInt());
ShowMissingChar = true;
LogFrames = ((Globals.Settings.Logs & ConsoleLog.DrawFrames) == ConsoleLog.DrawFrames);
VSync = VSyncMode.On;
@ -147,11 +155,10 @@ public class MainScreenWindow : Window
private async Task OnWindowLoaded(Window arg)
{
string r = new HttpClient()
.GetAsync(
$"https://www.jacobtech.com/Updater/GetProgramVersion?directory=Luski&branch={Globals.UpdaterSettings.Branch.ToString()}&selfcontained={Globals.UpdaterSettings.SelfContained.ToString().ToLower()}&platform={Globals.UpdaterSettings.Platform}")
.Result.Content.ReadAsStringAsync().Result;
if (Globals.UpdaterSettings.AutoUpdateCheck && r !=
if (Globals.UpdaterSettings.AutoUpdateCheck && new HttpClient()
.GetAsync(
$"https://www.jacobtech.com/Updater/GetProgramVersion?directory=Luski&branch=main&selfcontained={Globals.UpdaterSettings.SelfContained.ToString().ToLower()}&platform={Globals.UpdaterSettings.Platform}")
.Result.Content.ReadAsStringAsync().Result !=
FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion)
{
var update = new UpdateWindow();
@ -179,7 +186,8 @@ public class MainScreenWindow : Window
{
ServerLoginOverlay SLO = new(Server.Domain);
Controls.Add(SLO);
ForceUpdate(new(Size));
ForceUpdate(new(ClientSize));
Globals.PrintParent(this);
return;
}
BlockDraw = true;
@ -192,7 +200,7 @@ public class MainScreenWindow : Window
SerBox = new()
{
Location = new(ser.Size.X, 0, 0),
Size = new(Size.X - ser.Size.X, Size.Y),
Size = new(Size.X - ser.Size.X, ClientSize.Y),
Anchor = ObjectAnchor.All,
BackgroundColor = new(20, 20, 20, 255)
};
@ -328,7 +336,11 @@ public class MainScreenWindow : Window
Controls.Clear();
BlockDraw = true;
Title = "Luski";
Size = new(1332.ScaleInt(), 866.ScaleInt());
unsafe
{
GLFW.SetWindowSizeLimits(WindowPtr, 500.ScaleInt(), 250.ScaleInt(),GLFW.DontCare, GLFW.DontCare);
}
try
{
CenterWindow(Globals.Settings.Display);
@ -343,10 +355,11 @@ public class MainScreenWindow : Window
Controls.Add(ser = new FlowLayout()
{
BackgroundColor = new(26, 26, 26, 255),
Size = new(68.ScaleInt(), 868.ScaleInt()),
Size = new(68.ScaleInt(), ClientSize.Y),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom,
Location = new(0,0,0)
});
ser.LoadToParent(this,this);
DrawFrame();
DateTime utcNow = DateTime.UtcNow;
Task.WhenAll(Globals.ServersLoading.ToArray()).Wait();
@ -354,6 +367,7 @@ public class MainScreenWindow : Window
{
ServerIcon<PublicServer> si = new ServerIcon<PublicServer>(pser);
ser.Controls.Add(si);
si.LoadToParent(ser, this);
}
AddServerIcon asi = new();
@ -369,6 +383,12 @@ public class MainScreenWindow : Window
return Task.CompletedTask;
}
protected override void OnResize(ResizeEventArgs e)
{
base.OnResize(e);
}
private Task AddButtonClicked(IRenderObject arg)
{
AddServerOverlay aso = new();

View File

@ -54,11 +54,18 @@ public static class Globals
private static int LastExpCount = 0;
public static Color4 DodgerBlue = new Color4(30, 144, 255, 255);
private static bool msc = true;
private static double mscale = -1;
public static double GetScale()
{
if (Settings.Scale is not null) return Settings.Scale.Value;
return Monitors.GetMonitorFromWindow(ms).HorizontalScale;
if (msc)
{
msc = false;
mscale = Monitors.GetMonitorFromWindow(ms).HorizontalScale;
}
return mscale;
}
public static int ScaleInt(this int i)
{

View File

@ -5,7 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<FileVersion>1.0.0.0</FileVersion>
<FileVersion>0.0.0.1</FileVersion>
<Company>JacobTech, LLC</Company>
</PropertyGroup>
@ -21,8 +21,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha26" />
<PackageReference Include="Luski.net" Version="2.0.0-alpha83" />
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha72" />
<PackageReference Include="Luski.net" Version="2.0.0-alpha89" />
</ItemGroup>
<ItemGroup>

View File

@ -9,15 +9,6 @@ public static class LuskiExperiments
Parents.MainServer,
Parents.ThemeEdit,
new()
{
DisplayName = "Server Member List",
Name = "2023_12_member_list",
Options = new()
{
GUI.MemberList
}
},
new()
{
DisplayName = "Proper Message Label Size",
Name = "2024_04_label_size",
@ -78,12 +69,6 @@ public static class LuskiExperiments
public static class GUI
{
public static readonly ExperimentSelectorInfo MemberList = new()
{
Name = "Member List",
Description = "Adds a list on the side of a chat that shows members.",RequiresRestart = false
};
public static readonly ExperimentSelectorInfo MessageLiveSize = new()
{
Name = "Proper Label Size",

View File

@ -96,7 +96,7 @@ if (Globals.Download)
"--localdirectory",
AppDomain.CurrentDomain.BaseDirectory,
"--branch",
Globals.UpdaterSettings.Branch.ToString(),
"main",
"--selfcontained",
Globals.UpdaterSettings.SelfContained.ToString().ToLower(),
"--platform",

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB