Merge pull request 'Merge dev into main' (#18) from dev into main

Reviewed-on: #18
This commit is contained in:
JacobTech 2024-04-11 20:36:03 -04:00
commit 77ec87d795
8 changed files with 47 additions and 13 deletions

View File

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

View File

@ -27,10 +27,8 @@ public class AddServerOverlay : UserControl, IServerOverlay
public AddServerOverlay()
{
base.Size = Globals.ms.ClientSize;
BackgroundColor = new(0, 0, 0, 130);
base.BackgroundColor = new(0, 0, 0, 130);
Anchor = ObjectAnchor.All;
Form = new(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{
@ -337,7 +335,6 @@ public class AddServerOverlay : UserControl, IServerOverlay
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);
@ -396,6 +393,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
return Task.CompletedTask;
};
UserName.Size = UserName.Size;
page.Controls.Add(Password = new()
{
@ -443,8 +441,12 @@ public class AddServerOverlay : UserControl, IServerOverlay
return Task.CompletedTask;
};
Password.Size = Password.Size;
Password.ForceDistanceUpdate(page);
DisplayName = null!;
rec = null!;
Globals.ms.ForceUpdate(new(Globals.ms.CS));
TryDraw();
}
};
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);
await ss.LoadServer();
Globals.ms.Controls.Remove(this);
Globals.ms.ForceUpdate(new(Size));
Globals.ms.TryDraw();
}

View File

@ -115,7 +115,9 @@ public class Channel : UserControl
Console.WriteLine("Waiting");
Task.WaitAll(mm);
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");
}
BlockDraw = false;

View File

@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
@ -7,6 +8,7 @@ using Luski.net.Structures.Main;
using Luski.net.Structures.Public;
using OpenTK.Mathematics;
using OpenTK.Windowing.Common.Input;
using OpenTK.Windowing.GraphicsLibraryFramework;
using Label = GraphicsManager.Objects.Label;
namespace Luski.GUI.MainScreen.UI.PublicServers;
@ -97,6 +99,17 @@ public class ChatMessage : UserControl
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});
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);
}
Globals.Settings.DayTimeChanged += () =>
@ -196,6 +209,17 @@ public class ChatMessage : UserControl
Controls.Add(newLabel);
MessageObjs.Add(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()
{
MessageFlow.Controls.Clear();
MessageFlow.ScrollValue = 0;
MessageFlow.ScrollUpdatesInterval = 33;
lastm = null;
lastUser = null;

View File

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

View File

@ -298,8 +298,6 @@ public class SettingsMenu : UserControl
});
TextBox t;
page!.Controls.Add(t =new TextBox()
{
@ -344,7 +342,7 @@ public class SettingsMenu : UserControl
{
var e = Enum.Parse(PropType, (v - va).ToString());
PropVal = e;
prop.SetValue(Globals.Settings, e);
prop.SetValue(Globals.UpdaterSettings, e);
}
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;
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);
});
}
@ -373,6 +371,7 @@ public class SettingsMenu : UserControl
// ignored
}
}
}
t.ForceDistanceUpdate(page);
@ -382,7 +381,8 @@ 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.ClientSize));
TryDraw();
Globals.ms.ForceUpdate(new(Globals.ms.CS));
}
};
As.AddButton(cb);

View File

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