Merge dev into main #18

Merged
JacobTech merged 5 commits from dev into main 2024-04-11 20:36:04 -04:00
8 changed files with 47 additions and 13 deletions

View File

@ -82,6 +82,7 @@ public class AccountButton : UserControl
SM.Selected = this; SM.Selected = this;
SM.page.Controls.Clear(); SM.page.Controls.Clear();
OnPageLoad.Invoke(); OnPageLoad.Invoke();
Globals.ms.ForceUpdate(new(Globals.ms.CS));
} }
BlockDraw = false; BlockDraw = false;

View File

@ -27,11 +27,9 @@ public class AddServerOverlay : UserControl, IServerOverlay
public AddServerOverlay() public AddServerOverlay()
{ {
base.Size = Globals.ms.ClientSize; base.Size = Globals.ms.ClientSize;
BackgroundColor = new(0, 0, 0, 130); base.BackgroundColor = new(0, 0, 0, 130);
Anchor = ObjectAnchor.All; Anchor = ObjectAnchor.All;
Form = new(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png")) Form = new(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{ {
Size = new(350.ScaleInt(), 347.ScaleInt()), Size = new(350.ScaleInt(), 347.ScaleInt()),
@ -337,7 +335,6 @@ public class AddServerOverlay : UserControl, IServerOverlay
DisplayName.Textures[0] = UserName.Textures[0]; DisplayName.Textures[0] = UserName.Textures[0];
rec.ForceDistanceUpdate(page); rec.ForceDistanceUpdate(page);
Globals.ms.TryDraw(); 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.Size = new((Form.Size.X - tb.Location.X - tb.Location.X - (tb.Location.X / 2)) / 2, ca.Size.Y);
@ -396,6 +393,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
return Task.CompletedTask; return Task.CompletedTask;
}; };
UserName.Size = UserName.Size;
page.Controls.Add(Password = new() page.Controls.Add(Password = new()
{ {
@ -443,8 +441,12 @@ public class AddServerOverlay : UserControl, IServerOverlay
return Task.CompletedTask; return Task.CompletedTask;
}; };
Password.Size = Password.Size;
Password.ForceDistanceUpdate(page);
DisplayName = null!; DisplayName = null!;
rec = null!; rec = null!;
Globals.ms.ForceUpdate(new(Globals.ms.CS));
TryDraw();
} }
}; };
lo.Size = ca.Size; lo.Size = ca.Size;
@ -554,7 +556,6 @@ public class AddServerOverlay : UserControl, IServerOverlay
Globals.ms.ser.Controls.Insert(Globals.ms.ser.Controls.Length - 1, ss); Globals.ms.ser.Controls.Insert(Globals.ms.ser.Controls.Length - 1, ss);
await ss.LoadServer(); await ss.LoadServer();
Globals.ms.Controls.Remove(this); Globals.ms.Controls.Remove(this);
Globals.ms.ForceUpdate(new(Size));
Globals.ms.TryDraw(); Globals.ms.TryDraw();
} }

View File

@ -115,7 +115,9 @@ public class Channel : UserControl
Console.WriteLine("Waiting"); Console.WriteLine("Waiting");
Task.WaitAll(mm); Task.WaitAll(mm);
Globals.ms.pc.MessageFlow.ForceScrollUpdate(); Globals.ms.pc.MessageFlow.ForceScrollUpdate();
Globals.ms.pc.MessageFlow.ScrollToBottom(); if (Globals.ms.pc.MessageFlow.Controls.Length > 1 && Globals.ms.pc.MessageFlow.Controls[Globals.ms.pc.MessageFlow.Controls.Length - 1].Location.Y + Globals.ms.pc.MessageFlow.Controls[Globals.ms.pc.MessageFlow.Controls.Length - 1].Size.Y > Globals.ms.pc.MessageFlow.Size.Y)
Globals.ms.pc.MessageFlow.ScrollToBottom();
else Globals.ms.pc.MessageFlow.ScrollToTop();
Console.WriteLine("Done"); Console.WriteLine("Done");
} }
BlockDraw = false; BlockDraw = false;

View File

@ -1,4 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices;
using GraphicsManager.Enums; using GraphicsManager.Enums;
using GraphicsManager.Interfaces; using GraphicsManager.Interfaces;
using GraphicsManager.Objects; using GraphicsManager.Objects;
@ -7,6 +8,7 @@ using Luski.net.Structures.Main;
using Luski.net.Structures.Public; using Luski.net.Structures.Public;
using OpenTK.Mathematics; using OpenTK.Mathematics;
using OpenTK.Windowing.Common.Input; using OpenTK.Windowing.Common.Input;
using OpenTK.Windowing.GraphicsLibraryFramework;
using Label = GraphicsManager.Objects.Label; using Label = GraphicsManager.Objects.Label;
namespace Luski.GUI.MainScreen.UI.PublicServers; namespace Luski.GUI.MainScreen.UI.PublicServers;
@ -97,6 +99,17 @@ public class ChatMessage : UserControl
Label l; 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}); 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});
LastObject = l; LastObject = l;
LuskiContextMenu lcm = new();
Label llllll = lcm.AddLabel("Copy Text");
unsafe
{
llllll.Clicked += (o) =>
{
GLFW.SetClipboardString(Globals.ms.WindowPtr, message.Context);
return Task.CompletedTask;
};
}
l.ContextMenu = lcm;
MessageObjs.Add(l); MessageObjs.Add(l);
} }
Globals.Settings.DayTimeChanged += () => Globals.Settings.DayTimeChanged += () =>
@ -196,6 +209,17 @@ public class ChatMessage : UserControl
Controls.Add(newLabel); Controls.Add(newLabel);
MessageObjs.Add(newLabel); MessageObjs.Add(newLabel);
LastObject = newLabel; LastObject = newLabel;
LuskiContextMenu lcm = new();
Label llllll = lcm.AddLabel("Copy Text");
unsafe
{
llllll.Clicked += (o) =>
{
GLFW.SetClipboardString(Globals.ms.WindowPtr, msg.Context);
return Task.CompletedTask;
};
}
newLabel.ContextMenu = lcm;
} }

View File

@ -402,6 +402,7 @@ public class PublicChat : UserControl
public void ClearChat() public void ClearChat()
{ {
MessageFlow.Controls.Clear(); MessageFlow.Controls.Clear();
MessageFlow.ScrollValue = 0;
MessageFlow.ScrollUpdatesInterval = 33; MessageFlow.ScrollUpdatesInterval = 33;
lastm = null; lastm = null;
lastUser = null; lastUser = null;

View File

@ -13,17 +13,21 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
private Rectangle SelectedRect; private Rectangle SelectedRect;
private static ServerIcon<MainServer>? ser1; private static ServerIcon<MainServer>? ser1;
private static ServerIcon<PublicServer>? ser2; private static ServerIcon<PublicServer>? ser2;
private bool Selected = false;
public async Task LoadServer() public async Task LoadServer()
{ {
Selected = true;
if (ser1 is not null) if (ser1 is not null)
{ {
ser1.SelectedRect.BackgroundColor = new(26, 26, 26, 255); ser1.SelectedRect.BackgroundColor = new(26, 26, 26, 255);
ser1.Selected = false;
ser1 = null; ser1 = null;
} }
if (ser2 is not null) if (ser2 is not null)
{ {
ser2.SelectedRect.BackgroundColor = new(26, 26, 26, 255); ser2.SelectedRect.BackgroundColor = new(26, 26, 26, 255);
ser2.Selected = false;
ser2 = null; ser2 = null;
} }
@ -80,6 +84,7 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
private async Task OnClicked(IRenderObject arg) private async Task OnClicked(IRenderObject arg)
{ {
if (Selected) return;
await LoadServer(); await LoadServer();
} }

View File

@ -298,8 +298,6 @@ public class SettingsMenu : UserControl
}); });
TextBox t; TextBox t;
page!.Controls.Add(t =new TextBox() page!.Controls.Add(t =new TextBox()
{ {
@ -344,7 +342,7 @@ public class SettingsMenu : UserControl
{ {
var e = Enum.Parse(PropType, (v - va).ToString()); var e = Enum.Parse(PropType, (v - va).ToString());
PropVal = e; PropVal = e;
prop.SetValue(Globals.Settings, e); prop.SetValue(Globals.UpdaterSettings, e);
} }
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings); Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
}); });
@ -364,7 +362,7 @@ public class SettingsMenu : UserControl
string description = ((DescriptionAttribute)valueAttributes[0]).Description; string description = ((DescriptionAttribute)valueAttributes[0]).Description;
AddBool(description, (bool)PropVal, b => AddBool(description, (bool)PropVal, b =>
{ {
prop.SetValue(Globals.Settings, b); prop.SetValue(Globals.UpdaterSettings, b);
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings); Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
}); });
} }
@ -373,6 +371,7 @@ public class SettingsMenu : UserControl
// ignored // ignored
} }
} }
} }
t.ForceDistanceUpdate(page); t.ForceDistanceUpdate(page);
@ -382,7 +381,8 @@ public class SettingsMenu : UserControl
Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings); Globals.UpdaterSettings.SaveSettings(Path.Combine(Globals.LuskiPath, "UpdaterSettings.json"), UpdaterSettingsContext.Default.UpdaterSettings);
return Task.CompletedTask; return Task.CompletedTask;
}; };
Globals.ms.ForceUpdate(new(Globals.ms.ClientSize)); TryDraw();
Globals.ms.ForceUpdate(new(Globals.ms.CS));
} }
}; };
As.AddButton(cb); As.AddButton(cb);

View File

@ -396,7 +396,7 @@ public class MainScreenWindow : Window
Controls.Add(aso); Controls.Add(aso);
TryDraw(); TryDraw();
OnResize(new(Size)); OnResize(new(CS));
return Task.CompletedTask; return Task.CompletedTask;
} }