dev #17

Merged
JacobTech merged 29 commits from dev into main 2024-04-11 15:50:14 -04:00
22 changed files with 333 additions and 99 deletions
Showing only changes of commit 6748e7548d - Show all commits

View File

@ -25,10 +25,12 @@ public class Settings
[JsonInclude]
[JsonPropertyName("default_display")]
public int Display { get; set; } = 0;
/// <summary>
/// Sets the log value for the console. Default value of -25 to enable all logs by default except for DrawFrames and InfoOpenGL even if new ones are added.
/// </summary>
[JsonInclude]
[JsonPropertyName("log")]
public ConsoleLog Logs { get; set; } = ConsoleLog.DrawFrames | ConsoleLog.BigErrosForOpenGL |
ConsoleLog.MediumErrosForOpenGL | ConsoleLog.LowErrosForOpenGL;
public ConsoleLog Logs { get; set; } = (ConsoleLog)(-25);
[JsonInclude]
[JsonPropertyName("scale_fonts")]
public bool ScaleFonts { get; set; } = true;
@ -37,7 +39,7 @@ public class Settings
public uint DefaultFontPX { get; set; } = 20;
[JsonInclude]
[JsonPropertyName("top_time_font_px")]
public uint TopTimeFonttPX { get; set; } = 11;
public uint TopTimeFonttPX { get; set; } = 12;
[JsonInclude]
[JsonPropertyName("message_font_px")]
public uint MessageFontPX { get; set; } = 17;

View File

@ -27,7 +27,7 @@ public class AccountButton : UserControl
IgnoreHover = true,
};
l.Location = new((base.Size.X / 2) - (l.Size.X / 2),
(base.Size.Y / 2) - ((int)l.Font.PixelHeight) + (l.PostiveTrueHeight / 2)
((base.Size.Y - l.Size.Y) / 2)
, 0);
Controls.Add(l);
BackgroundColor = new(0, 0, 0, 0);

View File

@ -64,7 +64,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
Location = new(10.ScaleInt(),50.ScaleInt(), 0),
Size = s,
WatermarkText = "Server Address",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
};
tb.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
@ -141,7 +141,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
};
ll2.Location = new((version.Size.X / 2) - (ll2.Size.X / 2),
(version.Size.Y / 2) - ((int)ll2.Font.PixelHeight) + (ll2.PostiveTrueHeight / 2)
((version.Size.Y - ll2.Size.Y) / 2)
, 0);
version.Controls.Add(ll2);
}
@ -198,7 +198,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
Location = new(0, 10.ScaleInt(), 0),
Size = new(page.Size.X, 30.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
});
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
@ -246,7 +246,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
Location = new(0, UserName.Location.Y + UserName.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
Size = new(page.Size.X, UserName.Size.Y),
WatermarkText = "Password",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false,
PasswordChar = '●'
});
@ -295,7 +295,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
Location = new(0, Password.Location.Y + Password.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
Size = new(page.Size.X- tb.Location.X - rec.Size.X, Password.Size.Y ),
WatermarkText = "Display Name",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
});
DisplayName.KeyPress += args =>
@ -342,7 +342,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
};
ca.Size = new((Form.Size.X - tb.Location.X - tb.Location.X - (tb.Location.X / 2)) / 2, ca.Size.Y);
ca.l.Location = new((ca.Size.X - ca.l.Size.X) / 2,
(ca.Size.Y / 2) - ((int)ca.l.Font.PixelHeight) + (ca.l.PostiveTrueHeight / 2)
((ca.Size.Y - ca.l.Size.Y) / 2)
, 0);
ca.l.ForceDistanceUpdate(ca);
Form.Controls.Add(ca);
@ -358,7 +358,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
Location = new(0, 22.ScaleInt(), 0),
Size = new(page.Size.X, 31.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
});
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
@ -402,7 +402,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
Location = new(0, UserName.Location.Y + UserName.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
Size = new(page.Size.X, UserName.Size.Y),
WatermarkText = "Password",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false,
PasswordChar = '●'
});
@ -449,7 +449,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
};
lo.Size = ca.Size;
lo.l.Location = new((lo.Size.X / 2) - (lo.l.Size.X / 2),
(lo.Size.Y / 2) - ((int)lo.l.Font.PixelHeight) + (lo.l.PostiveTrueHeight / 2)
((lo.Size.Y - lo.l.Size.Y) / 2)
, 0);
lo.l.ForceDistanceUpdate(lo);
Form.Controls.Add(lo);
@ -482,7 +482,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
IgnoreHover = true
};
sub.Location = new((btn.Size.X / 2) - (sub.Size.X / 2),
(btn.Size.Y / 2) - ((int)sub.Font.PixelHeight) + (sub.PostiveTrueHeight / 2)
((btn.Size.Y - sub.Size.Y) / 2)
, 0);
sub.ForceDistanceUpdate(btn);
btn.Controls.Add(sub);

View File

@ -1,34 +1,69 @@
using GraphicsManager.Objects;
using Luski.net.Structures.Public;
using Luski.Shared.PublicServers.V1.Enums;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class RoleView : FlowLayout
{
private string n = "";
private int i = 0;
private Label l;
private Role r;
public RoleView(Role r)
private string n = "Offline";
public int i = 0;
public Role? r;
public RoleView(Role? r = null)
{
n = r.Name;
this.r = r;
Console.WriteLine(r.Name);
if (r is not null) n = r.DisplayName;
l = new(Globals.DefaultFont)
{
Text = " " + n + " — " + i.ToString(),
Text = " " + n + " — " + i,
};
base.Size = new(0, 30.ScaleInt());
base.BackgroundColor = new(43, 45, 49, 255);
base.BackgroundColor = new(34, 34, 34, 255);
Controls.Add(l);
}
public async Task AddUser(SocketUser user)
private Dictionary<long, UserView> uuu = new();
public List<SocketUser> Users = new();
public async Task AddUser(SocketUser user, Role TopRole)
{
var f = await UserView.Make(user, r);
UserView f = await UserView.Make(user, TopRole, r is null);
uuu.Add(user.Id, f);
bool ff = false;
for (int j = 0; j < Users.Count; j++)
{
if (string.Compare(Users[j].DisplayName, user.DisplayName) > 0)
{
Users.Insert(j, user);
Controls.Insert(j+1, f);
ff = true;
break;
}
}
if (!ff)
{
Users.Add(user);
Controls.Add(f);
}
Size = new(Size.X, Size.Y + f.Size.Y);
i++;
l.Text = " " + n + " — " + i.ToString();
l.Text = " " + n + " — " + i;
}
public void RemoveUser(long id)
{
Size = new(Size.X, Size.Y - uuu[id].Size.Y);
i--;
l.Text = " " + n + " — " + i;
Users.Remove(uuu[id].User);
Controls.Remove(uuu[id]);
uuu.Remove(id);
for (int j = 0; j < Controls.Length; j++)
{
ReportSizeUpdate(Controls[i]);
}
}
}

View File

@ -40,7 +40,8 @@ public class TextBox : UserControl
};
Pointer = new()
{
Size = new(1.ScaleInt(), (int)(Globals.DefaultFont.PixelHeight * ((float)Globals.DefaultFont.CurrentFonts[0].Face.Height/Globals.DefaultFont.CurrentFonts[0].Face.UnitsPerEM)) ),
Size = new(1.ScaleInt(),
(int)_label.LineHeight ),
Location = _watermark.Location,
BackgroundColor = Color4.White,
Visible = false
@ -64,6 +65,7 @@ public class TextBox : UserControl
public override void UnFocus()
{
use = false;
t.Stop();
Pointer.Visible = false;
if (Window is not null && Window.focused == this)
Window.focused = null;
@ -108,7 +110,7 @@ public class TextBox : UserControl
public char? PasswordChar { get => _label.PasswordChar; set => _label.PasswordChar = value; }
private TextLocation tl = TextLocation.PxLeft;
private TextLocation tl = TextLocation.TopLeft;
public TextLocation TextLocation
{
@ -120,8 +122,8 @@ public class TextBox : UserControl
{
_label.Location = value switch
{
TextLocation.PostiveTureCenterLeft => new(10.ScaleInt(),
((Size.Y - _label.PostiveTrueHeight) / 2) - _label.Size.Y + _label.TrueHeight, Location.Z),
TextLocation.LineCenter => new(10.ScaleInt(),
((Size.Y - _label.Size.Y) / 2), Location.Z),
_ => _label.Location
};
_watermark.Location = _label.Location;
@ -130,8 +132,8 @@ public class TextBox : UserControl
{
_watermark.Location = value switch
{
TextLocation.PostiveTureCenterLeft => new(10.ScaleInt(),
((Size.Y - _watermark.PostiveTrueHeight) / 2) - _watermark.Size.Y + _watermark.TrueHeight, Location.Z),
TextLocation.LineCenter => new(10.ScaleInt(),
((Size.Y - _watermark.Size.Y) / 2), Location.Z),
_ => _watermark.Location
};
_label.Location = _watermark.Location;
@ -181,7 +183,7 @@ public class TextBox : UserControl
get => _label.Text;
set
{
int old = _label.TrueHeight;
int old = _label.Size.Y;
_label.Text = value;
if (!string.IsNullOrEmpty(value))
{
@ -192,7 +194,7 @@ public class TextBox : UserControl
_label.Visible = true;
_label.Location = TextLocation switch
{
TextLocation.PostiveTureCenterLeft => new(10.ScaleInt(), ((Size.Y - _label.PostiveTrueHeight) / 2) - _label.Size.Y + _label.TrueHeight, Location.Z),
TextLocation.LineCenter => new(10.ScaleInt(), ((Size.Y - _label.Size.Y) / 2), Location.Z),
_ => _label.Location
};
/*
@ -206,7 +208,7 @@ public class TextBox : UserControl
_watermark.Location = _label.Location;
}
if (_watermark.Visible) _watermark.Visible = false;
if (!f && TextLocation == TextLocation.TrueCenterLeft && old != _label.TrueHeight)
if (!f && TextLocation == TextLocation.LineCenter && old != _label.Size.Y)
{
//_label.Location = new(Location.X + 5, Location.Y + ((Size.Y - _label.TrueHeight) / 2) - (_label.Size.Y - _label.TrueHeight), Location.Z);
_watermark.Location = _label.Location;
@ -220,7 +222,7 @@ public class TextBox : UserControl
_watermark.Visible = true;
_watermark.Location = TextLocation switch
{
TextLocation.PostiveTureCenterLeft => new(10.ScaleInt(), ((Size.Y - _watermark.PostiveTrueHeight) / 2) - _watermark.Size.Y + _watermark.TrueHeight, Location.Z),
TextLocation.LineCenter => new(10.ScaleInt(), ((Size.Y - _watermark.Size.Y) / 2), Location.Z),
_ => _watermark.Location
};
/*
@ -327,6 +329,6 @@ public class TextBox : UserControl
use = true;
Focus();
}
else use = false;
else UnFocus();
}
}

View File

@ -1,15 +1,19 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.net.Structures.Public;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class UserView : UserControl
{
private UserView(IRenderObject user, SocketUser u, Role r)
public SocketUser User { get; set; }
private UserView(IRenderObject user, SocketUser u, Role r, bool offline)
{
this.User = u;
base.Size = new(244.ScaleInt(), 44.ScaleInt());
base.BackgroundColor = new(43, 45, 49, 255);
base.BackgroundColor = new(34, 34, 34, 255);
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
user.ForceDistanceUpdate(this);
Label uname = new(Globals.DefaultFont)
@ -17,15 +21,16 @@ public class UserView : UserControl
Text = u.DisplayName,
Color = r.Color.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.PostiveTrueHeight / 2) - uname.Size.Y + uname.TrueHeight), 0);
(user.Location.Y + (user.Size.Y / 2) - (uname.Size.Y / 2)), 0);
Controls.Add(uname);
Controls.Add(user);
}
public static async Task<UserView> Make(SocketUser u, Role r)
public static async Task<UserView> Make(SocketUser u, Role r, bool offline)
{
UserView m = new(await u.MakeRct(new(32.ScaleInt()), true), u, r);
UserView m = new(await u.MakeRct(new(32.ScaleInt()), true), u, r, offline);
return m;
}
}

View File

@ -21,7 +21,7 @@ public class VersionDropButton : DropDownOption
IgnoreHover = true
};
l.Location = new((base.Size.X / 2) - (l.Size.X / 2),
(base.Size.Y / 2) - ((int)l.Font.PixelHeight) + (l.PostiveTrueHeight / 2)
((base.Size.Y - l.Size.Y) / 2)
, 0);
Controls.Add(l);
BackgroundColor = new(0, 0, 0, 0);

View File

@ -36,7 +36,7 @@ public class AddChannel : UserControl
WatermarkText = "Channel Name",
Size = new(34.ScaleInt()),
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
TextLocation = TextLocation.PostiveTureCenterLeft
TextLocation = TextLocation.LineCenter
});
fl.Controls.Add(new Label(Globals.DefaultFont) {Text = "Channel Description"});
fl.Controls.Add(cd =new TextBox()
@ -44,7 +44,7 @@ public class AddChannel : UserControl
WatermarkText = "Channel Description",
Size = cn.Size,
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
TextLocation = TextLocation.PostiveTureCenterLeft
TextLocation = TextLocation.LineCenter
});
fl.Controls.Add(new Label(Globals.DefaultFont) {Text = "\n "});
fl.Controls.Add(btn = new(Globals.ms.TextureManager.GetTextureResource("Textbox.png"))
@ -58,7 +58,7 @@ public class AddChannel : UserControl
IgnoreHover = true
};
sub.Location = new((btn.Size.X / 2) - (sub.Size.X / 2),
(btn.Size.Y / 2) - ((int)sub.Font.PixelHeight) + (sub.PostiveTrueHeight / 2)
((btn.Size.Y - sub.Size.Y) / 2)
, 0);
btn.Clicked += BtnOnClicked;
sub.ForceDistanceUpdate(btn);

View File

@ -52,7 +52,7 @@ public class Category : UserControl, IChannelAdder
IgnoreHover = true
});
c.Clicked += c.AllOnClicked;
c.Name.Location = new(26.ScaleInt(), ((c.Size.Y/2) - (c.Name.TrueHeight/ 2) - (c.Name.Size.Y - c.Name.TrueHeight)), 0);
c.Name.Location = new(26.ScaleInt(), (((c.Size.Y - c.Name.Size.Y)/2)), 0);
c.Members = new()
{
Anchor = ObjectAnchor.All,
@ -120,12 +120,12 @@ public class Category : UserControl, IChannelAdder
if (value)
{
ee.DIR = new(0,1);
ee.Location = new(ee.Location.X, (ee.Location.Y - ee.PostiveTrueHeight), 0);
ee.Location = new(ee.Location.X, (ee.Location.Y - ee.Size.Y), 0);
}
else
{
ee.DIR = new(1,0);
ee.Location = new(ee.Location.X, (ee.Location.Y + ee.PostiveTrueHeight), 0);
ee.Location = new(ee.Location.X, (ee.Location.Y + ee.Size.Y), 0);
}
e = value;
}

View File

@ -49,7 +49,7 @@ public class Channel : UserControl
Controls.Add(ChannelName);
Clicked += AllOnClicked;
ChannelName.Location = new(40.ScaleInt(),
(base.Size.Y / 2) - ((int)ChannelName.Font.PixelHeight) + (ChannelName.PostiveTrueHeight / 2)
((base.Size.Y - ChannelName.Size.Y) / 2)
, 0);
base.HoverMouse = MouseCursor.Hand;
}
@ -74,7 +74,7 @@ public class Channel : UserControl
Controls.Add(ChannelName);
Clicked += AllOnClicked;
ChannelName.Location = new(i,
(base.Size.Y / 2) - ((int)ChannelName.Font.PixelHeight) + (ChannelName.PostiveTrueHeight / 2)
((base.Size.Y - ChannelName.Size.Y) / 2)
, 0);
base.HoverMouse = MouseCursor.Hand;
}

View File

@ -19,9 +19,10 @@ public class ChatMessage : UserControl
public PublicChat pc;
private IRenderObject LastObject;
public List<IRenderObject> MessageObjs = new();
private Label FirstL;
private readonly double HorPadding = 12.ScaleDouble(),
public readonly double HorPadding = 12.ScaleDouble(),
VerticalPadding = 0.ScaleDouble();
private static Dictionary<MainSocketRemoteUser, List<ChatMessage>> Messages = new();
@ -37,6 +38,8 @@ public class ChatMessage : UserControl
private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, IUser Author, IRenderObject UserIcon, Color4 UserNameColor)
{
pc = p;
Label label1;
base.Size = new(723.5.ScaleInt(), 37.ScaleInt());
@ -77,6 +80,7 @@ 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;
MessageObjs.Add(l);
}
if (Msg.Files.Count > 0)
@ -105,6 +109,7 @@ public class ChatMessage : UserControl
else base.Size = new(base.Size.X ,(int)(LastObject.Location.Y + LastObject.Size.Y + VerticalPadding));
}
public async Task AddMessage(SocketMessage msg)
{
BlockDraw = true;
@ -136,9 +141,11 @@ public class ChatMessage : UserControl
newLabel.MouseEnter += NewLabel_MouseEnter;
newLabel.MouseLeave += NewLabel_MouseLeave;
Controls.Add(newLabel);
MessageObjs.Add(newLabel);
LastObject = newLabel;
}
if (msg.Files.Count > 0)
{
int row = 1;

View File

@ -5,6 +5,7 @@ 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;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Common.Input;
@ -28,7 +29,7 @@ public class PublicChat : UserControl
{
base.Size = new(980.ScaleInt(), 866.ScaleInt());
BackgroundColor = new(40,40,40,255);
base.BackgroundColor = new(40,40,40,255);
Anchor = ObjectAnchor.All;
Controls.Add(MessageFlow = new()
{
@ -39,14 +40,22 @@ public class PublicChat : UserControl
HScrollPixels = Globals.Settings.PerScrollPixels,
});
MessageFlow.FlowUpdate += MessageFlowOnFlowUpdate;
if (LuskiExperiments.GUI.MessageLiveSize.IsEnabled()) MessageFlow.SizeChanged += OnSizeChanged;
LuskiExperiments.GUI.MessageLiveSize.EventToggled += MessageLiveSizeOnEventToggled;
Task MessageLiveSizeOnEventToggled(bool arg)
{
if (arg) MessageFlow.SizeChanged += OnSizeChanged;
else MessageFlow.SizeChanged -= OnSizeChanged;
return Task.CompletedTask;
}
Controls.Add(titlecon = new UserControl()
{
Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right,
Size = new(980.ScaleInt(), 48.ScaleInt()),
BackgroundColor = new(50,50,50,255),
});
if (LuskiExperiments.ServerExperiments.MemberList.IsEnabled())
if (LuskiExperiments.GUI.MemberList.IsEnabled())
{
UserCon =
new(Globals.ms.TextureManager.GetTextureResource("person.png"))
@ -55,12 +64,14 @@ public class PublicChat : UserControl
Location = new(944.ScaleInt(), 12.ScaleInt(),0),
Anchor = ObjectAnchor.Right | ObjectAnchor.Top,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Red
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.ServerExperiments.MemberList.EventToggled += MemberListOnEventToggled;
LuskiExperiments.GUI.MemberList.EventToggled += MemberListOnEventToggled;
titlecon.ForceDistanceUpdate(this);
titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
@ -84,7 +95,7 @@ public class PublicChat : UserControl
//Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
//Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Red,
TextLocation = TextLocation.PostiveTureCenterLeft
TextLocation = TextLocation.LineCenter
});
tb.KeyPress += TbOnKeyPress;
tb.OnRemoveLine += TbOnOnRemoveLine;
@ -94,6 +105,51 @@ public class PublicChat : UserControl
//Globals.Luski.MainServer.MessageReceived += LuskiOnMessageReceived;
}
private bool ssss = false;
private Task OnSizeChanged(IRenderObject arg)
{
if (ssss) return Task.CompletedTask;
ssss = true;
BlockDraw = true;
bool off = false;
for (int j = 0; j < MessageFlow.Controls.Length; j++)
{
if (MessageFlow.Controls[j] is ChatMessage cm && cm.Controls.Length != 0 && cm.Location.Y + cm.Size.Y >= 0 && !off)
{
if (cm.MessageObjs[0] is Label First)
{
First.MaxSize = new(MessageFlow.Size.X - First.Location.X - 10.ScaleInt(), Int32.MaxValue);
First.ForceDistanceUpdate(cm);
}
for (int i = 1; i < cm.MessageObjs.Count; i++)
{
cm.MessageObjs[i].Location = new(cm.MessageObjs[i].Location.X,
cm.MessageObjs[i - 1].Location.Y + cm.MessageObjs[i - 1].Size.Y,
cm.MessageObjs[i].Location.Z);
cm.MessageObjs[i].ForceDistanceUpdate(cm);
if (cm.MessageObjs[i] is Label l)
{
l.MaxSize = new(MessageFlow.Size.X - l.Location.X - 10.ScaleInt(), Int32.MaxValue);
//l.Text = l.Text;
}
}
int ny = cm.MessageObjs.Last().Size.Y + cm.MessageObjs.Last().Location.Y + (int)cm.VerticalPadding;
if (cm.Location.Y + ny > MessageFlow.Size.Y) off = true;
if (cm.Size.Y != ny)
{
cm.Size = new(Size.X, ny);
MessageFlow.ReportSizeUpdate(cm);
}
ssss = false;
}
}
BlockDraw = false;
return Task.CompletedTask;
}
private async Task MessageFlowOnFlowUpdate(bool arg1, uint arg2, uint arg3)
{
if (!loadingm && arg1 && arg3 == 0 && (arg2 != 0 || MessageFlow.MaxScrollValue == 0))
@ -152,8 +208,10 @@ public class PublicChat : UserControl
Location = new(base.Size.X - 36.ScaleInt(), 12.ScaleInt(),0),
Anchor = ObjectAnchor.Right | ObjectAnchor.Top,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Red
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);
}
@ -166,6 +224,8 @@ public class PublicChat : UserControl
}
private bool um_open = false;
private bool SeperateOffline = true;
private async Task UserConOnClicked(IRenderObject arg)
{
@ -177,28 +237,125 @@ public class PublicChat : UserControl
int x = 232.ScaleInt();
memberflow = new()
{
BackgroundColor = new(255, 0, 0, 255),
BackgroundColor = new(34, 34, 34, 255),
Size = new(x, Size.Y - titlecon.Size.Y),
Location = new(Size.X - x, titlecon.Size.Y, 0)
Location = new(Size.X - x, titlecon.Size.Y, 0),
Anchor = ObjectAnchor.Top | ObjectAnchor.Right | ObjectAnchor.Bottom
};
memberflow.ForceDistanceUpdate(this);
Controls.Add(memberflow);
Dictionary<long, RoleView> Roles = new();
}
foreach (var m in await Channel!.GetMembers())
if (memberflow.Controls.Length == 0)
{
Dictionary<long, RoleView> Roles = new();
RoleView? Offline = null;
Dictionary<long, RoleView> Users = new();
foreach (var m in (await Channel!.GetMembers()))
{
Role top_role = (await m.GetRoles())[0];
if (m.Status == UserStatus.Offline && SeperateOffline)
{
if (Offline is null)
{
Offline = new();
memberflow.Controls.Add(Offline);
}
await Offline.AddUser(m, top_role);
Users.Add(m.Id, Offline);
memberflow.ReportSizeUpdate(Offline);
}
else
{
if (!Roles.ContainsKey(top_role.ID))
{
Roles.Add(top_role.ID, new(top_role));
memberflow.Controls.Add(Roles[top_role.ID]);
int _index_ = 0;
for (int index_ = memberflow.Controls.Length-1; index_ >= 0; index_--)
{
RoleView r = ((RoleView)memberflow.Controls[index_]);
if (r.r is null) continue;
if (r.r.Index > top_role.Index)
{
_index_ = index_ + 1;
break;
}
Roles[top_role.ID].AddUser(m);
}
memberflow.Controls.Insert(_index_, Roles[top_role.ID]);
}
await Roles[top_role.ID].AddUser(m, top_role);
Users.Add(m.Id, Roles[top_role.ID]);
memberflow.ReportSizeUpdate(Roles[top_role.ID]);
}
}
Channel!.Server.StatusUpdate += async (status, user) =>
{
if (!SeperateOffline && !Users.ContainsKey(user.Id)) return;
Role top_role2 = (await user.GetRoles())[0];
Globals.ms.Invoke(async () =>
{
if (status == UserStatus.Offline && user.Status != UserStatus.Offline)
{
Offline!.RemoveUser(user.Id);
if (Offline.i == 0)
{
memberflow.Controls.Remove(Offline);
}
if (!Roles.ContainsKey(top_role2.ID))
{
Roles.Add(top_role2.ID, new(top_role2));
int _index_ = 0;
for (int index_ = memberflow.Controls.Length-1; index_ >= 0; index_--)
{
RoleView r = ((RoleView)memberflow.Controls[index_]);
if (r.r is null) continue;
if (r.r.Index > top_role2.Index)
{
_index_ = index_ + 1;
break;
}
}
memberflow.Controls.Insert(_index_, Roles[top_role2.ID]);
}
await Roles[top_role2.ID].AddUser(user, top_role2);
memberflow.ReportSizeUpdate(Roles[top_role2.ID]);
if (Offline is not null) memberflow.ReportSizeUpdate(Offline);
Users[user.Id] = Roles[top_role2.ID];
}
if (status != UserStatus.Offline && user.Status == UserStatus.Offline)
{
Users[user.Id].RemoveUser(user.Id);
if (Users[user.Id].i == 0)
{
if (Roles.ContainsKey(top_role2.ID)) Roles.Remove(top_role2.ID);
memberflow.Controls.Remove(Users[user.Id]);
}
if (Offline is null)
{
Offline = new();
memberflow.Controls.Add(Offline);
}
await Offline.AddUser(user, top_role2);
memberflow.ReportSizeUpdate(Offline);
memberflow.ReportSizeUpdate(Users[user.Id]);
Users[user.Id] = Offline;
}
Globals.ms.DrawFrame();
});
};
}
TryDraw();
memberflow.Visible = true;
MessageFlow.Size = new(MessageFlow.Size.X - memberflow.Size.X, MessageFlow.Size.Y);
MessageFlow.ForceDistanceUpdate(this);
tb.Size = new(tb.Size.X - memberflow.Size.X, tb.Size.Y);
tb.ForceDistanceUpdate();
}
@ -206,6 +363,7 @@ public class PublicChat : UserControl
{
memberflow!.Visible = false;
MessageFlow.Size = new(MessageFlow.Size.X + memberflow.Size.X, MessageFlow.Size.Y);
MessageFlow.ForceDistanceUpdate(this);
tb.Size = new(tb.Size.X + memberflow.Size.X, tb.Size.Y);
tb.ForceDistanceUpdate();
}
@ -227,11 +385,23 @@ public class PublicChat : UserControl
Channel = channel;
if (memberflow is not null)
{
BlockDraw = true;
await UserConOnClicked(UserCon!);
memberflow.Controls.Clear();
await UserConOnClicked(UserCon!);
BlockDraw = false;
}
title.Text = channel.Name;
var five = 5.ScaleInt();
title.Location = new(five + five,
(titlecon.Size.Y - ((int)(title.Font.PixelHeight * ((float)title.Font.CurrentFonts[0].Face.Height /
title.Font.CurrentFonts[0].Face.UnitsPerEM)))) / 2,
title.Location.Z);
desc.Text = channel.Description;
desc.Location = new((int)(title.Location.X + title.Size.X + 5.ScaleInt()), desc.Location.Y, 0);
desc.Location = new((int)(title.Location.X + title.Size.X + five),
(titlecon.Size.Y - ((int)(desc.Font.PixelHeight * ((float)desc.Font.CurrentFonts[0].Face.Height /
desc.Font.CurrentFonts[0].Face.UnitsPerEM)))) / 2,
desc.Location.Z);
if (Window is not null)
{
Window.Title = $"{channel.Name} | {channel.Server.Name} - Luski";

View File

@ -65,7 +65,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Size = s,
Text = address,
WatermarkText = "Server Address",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
};
tb.Textures[0] = Globals.ms.TextureManager.GetTextureResource("Textbox.png");
@ -142,7 +142,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
};
ll2.Location = new((version.Size.X / 2) - (ll2.Size.X / 2),
(version.Size.Y / 2) - ((int)ll2.Font.PixelHeight) + (ll2.PostiveTrueHeight / 2)
((version.Size.Y - ll2.Size.Y) / 2)
, 0);
version.Controls.Add(ll2);
}
@ -199,7 +199,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Location = new(0, 10.ScaleInt(), 0),
Size = new(page.Size.X, 30.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
});
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
@ -247,7 +247,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Location = new(0, UserName.Location.Y + UserName.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
Size = new(page.Size.X, UserName.Size.Y),
WatermarkText = "Password",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false,
PasswordChar = '●'
});
@ -296,7 +296,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Location = new(0, Password.Location.Y + Password.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
Size = new(page.Size.X- tb.Location.X - rec.Size.X, Password.Size.Y ),
WatermarkText = "Display Name",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
});
DisplayName.KeyPress += args =>
@ -343,7 +343,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
};
ca.Size = new((Form.Size.X - tb.Location.X - tb.Location.X - (tb.Location.X / 2)) / 2, ca.Size.Y);
ca.l.Location = new((ca.Size.X - ca.l.Size.X) / 2,
(ca.Size.Y / 2) - ((int)ca.l.Font.PixelHeight) + (ca.l.PostiveTrueHeight / 2)
((ca.Size.Y - ca.l.Size.Y) / 2)
, 0);
ca.l.ForceDistanceUpdate(ca);
Form.Controls.Add(ca);
@ -359,7 +359,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Location = new(0, 22.ScaleInt(), 0),
Size = new(page.Size.X, 31.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
});
UserName.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
@ -403,7 +403,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Location = new(0, UserName.Location.Y + UserName.Size.Y + UserName.Location.Y + UserName.Location.Y, 0),
Size = new(page.Size.X, UserName.Size.Y),
WatermarkText = "Password",
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false,
PasswordChar = '●'
});
@ -450,7 +450,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
};
lo.Size = ca.Size;
lo.l.Location = new((lo.Size.X / 2) - (lo.l.Size.X / 2),
(lo.Size.Y / 2) - ((int)lo.l.Font.PixelHeight) + (lo.l.PostiveTrueHeight / 2)
((lo.Size.Y - lo.l.Size.Y) / 2)
, 0);
lo.l.ForceDistanceUpdate(lo);
Form.Controls.Add(lo);
@ -481,7 +481,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
IgnoreHover = true
};
sub.Location = new((btn.Size.X / 2) - (sub.Size.X / 2),
(btn.Size.Y / 2) - ((int)sub.Font.PixelHeight) + (sub.PostiveTrueHeight / 2)
((btn.Size.Y - sub.Size.Y) / 2)
, 0);
sub.ForceDistanceUpdate(btn);
btn.Controls.Add(sub);

View File

@ -75,7 +75,7 @@ public class SettingsMenu : UserControl
IgnoreHover = true
};
ll.Location = new(10.ScaleInt(),
(ThemeDrop!.Size.Y / 2) - ((int)ll.Font.PixelHeight) + (ll.PostiveTrueHeight / 2)
((ThemeDrop.Size.Y - ll.Size.Y) / 2)
, 0);
ThemeDrop.Controls.Add(ll);
},
@ -99,7 +99,7 @@ public class SettingsMenu : UserControl
IgnoreHover = true
};
ll.Location = new(10.ScaleInt(),
(ThemeDrop!.Size.Y / 2) - ((int)ll.Font.PixelHeight) + (ll.PostiveTrueHeight / 2)
((ThemeDrop.Size.Y - ll.Size.Y) / 2)
, 0);
ThemeDrop.Controls.Add(ll);
},
@ -193,7 +193,7 @@ public class SettingsMenu : UserControl
WatermarkText = "Updater File",
TextureDisplay = TextureDisplay.Center,
Size = new(page.Size.X, 34.ScaleInt()),
TextLocation = TextLocation.PostiveTureCenterLeft,
TextLocation = TextLocation.LineCenter,
AllowMultiLine = false
});
t.KeyPress += args =>

View File

@ -27,7 +27,7 @@ public class CategoryButton : UserControl
IgnoreHover = true
};
l.Location = new(5.ScaleInt(),
(base.Size.Y / 2) - ((int)l.Font.PixelHeight) + (l.PostiveTrueHeight / 2)
((base.Size.Y - l.Size.Y) / 2)
, 0);
Controls.Add(l);
BackgroundColor = new(0, 0, 0, 0);

View File

@ -27,7 +27,7 @@ public class ExperimentDropButton : DropDownOption
IgnoreHover = true
};
l.Location = new(10.ScaleInt(),
(base.Size.Y / 2) - ((int)l.Font.PixelHeight) + (l.PostiveTrueHeight / 2)
((base.Size.Y - l.Size.Y) / 2)
, 0);
d = new(Globals.MessageFont)
{

View File

@ -60,7 +60,7 @@ public class ExperimentGUI : UserControl
IgnoreHover = true
};
ll.Location = new(10.ScaleInt(),
(dd!.Size.Y / 2) - ((int)ll.Font.PixelHeight) + (ll.PostiveTrueHeight / 2)
((dd!.Size.Y - ll.Size.Y) / 2)
, 0);
dd.Controls.Add(ll);
},
@ -116,7 +116,7 @@ public class ExperimentGUI : UserControl
IgnoreHover = true
};
ll.Location = new(10.ScaleInt(),
(dd.Size.Y / 2) - ((int)ll.Font.PixelHeight) + (ll.PostiveTrueHeight / 2)
((dd.Size.Y - ll.Size.Y) / 2)
, 0);
dd.Controls.Add(ll);
}

View File

@ -27,7 +27,7 @@ public class ThemeDropButton : DropDownOption
IgnoreHover = true
};
l.Location = new(10.ScaleInt(),
(base.Size.Y / 2) - ((int)l.Font.PixelHeight) + (l.PostiveTrueHeight / 2)
((base.Size.Y - l.Size.Y) / 2)
, 0);
d = new(Globals.MessageFont)
{

View File

@ -1,7 +1,6 @@
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
@ -265,7 +264,7 @@ public class MainScreenWindow : Window
};
ul.Location = new(u.Location.X + u.Size.X + 5.ScaleInt(),
(u.Location.Y + (u.Size.Y / 2) - (ul.PostiveTrueHeight / 2) - ul.Size.Y + ul.TrueHeight), 0);
(u.Location.Y + ((u.Size.Y - ul.Size.Y) / 2)), 0);
SerBox.Controls.Add(ul);
Rectangle setting = new(TextureManager.GetTextureResource("settings.png"))
{

View File

@ -192,8 +192,7 @@ public static class Globals
{
if (!TextureResources.ContainsKey(tm)) TextureResources.Add(tm, new());
if (TextureResources[tm].TryGetValue(File, out Texture? t)) return t;
t = tm.AddTexture(Tools.GetResourceStream(Assembly.GetExecutingAssembly(),
$"Luski.Resources.Textures.{File}"));
t = tm.AddTexture(GetResource($"Textures.{File}"));
TextureResources[tm].Add(File,t);
return t;
}

View File

@ -21,8 +21,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha07" />
<PackageReference Include="Luski.net" Version="2.0.0-alpha76" />
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha24" />
<PackageReference Include="Luski.net" Version="2.0.0-alpha80" />
</ItemGroup>
<ItemGroup>

View File

@ -14,7 +14,16 @@ public static class LuskiExperiments
Name = "2023_12_member_list",
Options = new()
{
ServerExperiments.MemberList
GUI.MemberList
}
},
new()
{
DisplayName = "Proper Message Label Size",
Name = "2024_04_label_size",
Options = new()
{
GUI.MessageLiveSize
}
}
};
@ -67,12 +76,18 @@ public static class LuskiExperiments
};
}
public static class ServerExperiments
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",
Description = "Live updates messages to be the right length during resize.", RequiresRestart = false
};
}
}