Merging dev into main #19

Merged
JacobTech merged 5 commits from dev into main 2024-04-14 14:44:25 -04:00
7 changed files with 118 additions and 9 deletions
Showing only changes of commit 532d212494 - Show all commits

View File

@ -0,0 +1,39 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.net.Structures.Public;
using OpenTK.Mathematics;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class ProfileView : UserControl
{
public SocketUser User { get; set; }
private ProfileView(IRenderObject user, SocketUser u, ServerProfile p, Role r, Color? c = null)
{
this.User = u;
base.Size = new(244.ScaleInt(), 44.ScaleInt());
base.BackgroundColor = new(34, 34, 34, 255);
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
user.ForceDistanceUpdate(this);
user.IgnoreHover = true;
Color4 col = r.Color.ToColor4();
if (c is not null) col = c.ToColor4();
Label uname = new(Globals.DefaultFont)
{
Text = p.DisplayName,
Color = col,
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);
Controls.Add(user);
}
public static async Task<ProfileView> Make(SocketUser u, ServerProfile p, Role r)
{
ProfileView m = new(await p.MakeRct(u, new(32.ScaleInt())), u, p, r);
return m;
}
}

View File

@ -1,9 +1,7 @@
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;
using Luski.net.Interfaces;
using Luski.net.Structures.Main; using Luski.net.Structures.Main;
using Luski.net.Structures.Public; using Luski.net.Structures.Public;
using OpenTK.Mathematics; using OpenTK.Mathematics;

View File

@ -174,7 +174,7 @@ public class PublicChat : UserControl
if (arg.Key == Keys.Enter && !arg.Shift) if (arg.Key == Keys.Enter && !arg.Shift)
{ {
await Channel!.SendMessage(tb.Text); await Channel!.SendMessage(tb.Text, FakeProfile: Globals.ServerProfile);
tb.Text = string.Empty; tb.Text = string.Empty;
tb.CursorLocation = 0; tb.CursorLocation = 0;
} }
@ -446,10 +446,9 @@ public class PublicChat : UserControl
bool hasbeentenmin = false; bool hasbeentenmin = false;
if (lastm is not null) if (lastm is not null)
{ {
DateTime chan = Channel!.Epoch.AddMilliseconds(lastm.ID >> 22).ToLocalTime();
hasbeentenmin = hasbeentenmin =
Channel!.Epoch.AddMilliseconds(lastm.ID >> 22).ToLocalTime().AddMinutes(10) < Channel!.Epoch.AddMilliseconds(lastm.TimeStamp).ToLocalTime().AddMinutes(10) <
Channel!.Epoch.AddMilliseconds(Message.ID >> 22).ToLocalTime(); Channel!.Epoch.AddMilliseconds(Message.TimeStamp).ToLocalTime();
} }
lastm = Message; lastm = Message;
@ -498,8 +497,8 @@ public class PublicChat : UserControl
bool hasbeentenmin = false; bool hasbeentenmin = false;
if (lastmIndex is not null) if (lastmIndex is not null)
hasbeentenmin = hasbeentenmin =
Channel!.Epoch.AddMilliseconds(lastmIndex.ID >> 22).ToLocalTime().AddMinutes(10) < Channel!.Epoch.AddMilliseconds(lastmIndex.TimeStamp).ToLocalTime().AddMinutes(10) <
Channel!.Epoch.AddMilliseconds(Message.ID >> 22).ToLocalTime(); Channel!.Epoch.AddMilliseconds(Message.TimeStamp).ToLocalTime();
lastmIndex = Message; lastmIndex = Message;
if (lastUserIndex is null || lastUserIndex != Message.ProfileID || hasbeentenmin) if (lastUserIndex is null || lastUserIndex != Message.ProfileID || hasbeentenmin)
{ {

View File

@ -7,6 +7,7 @@ using GraphicsManager.Interfaces;
using GraphicsManager.Objects; using GraphicsManager.Objects;
using GraphicsManager.Objects.Core; using GraphicsManager.Objects.Core;
using Luski.GUI.MainScreen.UI; using Luski.GUI.MainScreen.UI;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.GUI.MainScreen.UI.PublicServers; using Luski.GUI.MainScreen.UI.PublicServers;
using Luski.net; using Luski.net;
using Luski.net.Structures.Public; using Luski.net.Structures.Public;
@ -276,6 +277,29 @@ public class MainScreenWindow : Window
ul.Location = new(u.Location.X + u.Size.X + 5.ScaleInt(), ul.Location = new(u.Location.X + u.Size.X + 5.ScaleInt(),
(u.Location.Y + ((u.Size.Y - ul.Size.Y) / 2)), 0); (u.Location.Y + ((u.Size.Y - ul.Size.Y) / 2)), 0);
Rectangle Expand = new(TextureManager.GetTextureResource("Expand.png"))
{
Size = new(20.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Context],
BackgroundColor = Color4.Gray,
Tag = new Tuple<SocketAppUser, IRenderObject, Label>(Server.User, u, ul),
Anchor = u.Anchor
};
Expand.Clicked += ExpandOnClicked;
Expand.MouseEnter += _ =>
{
Expand.BackgroundColor = Color4.White;
return Task.CompletedTask;
};
Expand.MouseLeave += _ =>
{
Expand.BackgroundColor = Color4.Gray;
return Task.CompletedTask;
};
Expand.Location = new(ul.Location.X + ul.Size.X + 5.ScaleInt(),
u.Location.Y + ((u.Size.Y - Expand.Size.Y) / 2), 0);
Expand.ForceDistanceUpdate(SerBox);
SerBox.Controls.Add(Expand);
SerBox.Controls.Add(ul); SerBox.Controls.Add(ul);
Rectangle setting = new(TextureManager.GetTextureResource("settings.png")) Rectangle setting = new(TextureManager.GetTextureResource("settings.png"))
{ {
@ -310,6 +334,53 @@ public class MainScreenWindow : Window
BlockDraw = false; BlockDraw = false;
} }
private FlowLayout? ProfileFlow = null;
private async Task ExpandOnClicked(IRenderObject arg)
{
if (ProfileFlow is null)
{
ProfileFlow = new();
Tuple<SocketAppUser, IRenderObject, Label> s = (Tuple<SocketAppUser, IRenderObject, Label>)arg.Tag!;
var role = (await s.Item1.GetRoles())[0];
foreach (var prof in await s.Item1.GetProfiles(CancellationToken.None))
{
ProfileView con = await ProfileView.Make(s.Item1, prof, role);
con.Clicked += async o =>
{
IRenderObject iro = await prof.MakeRct(s.Item1, s.Item2.Size);
iro.Location = s.Item2.Location;
iro.Distance = s.Item2.Distance;
iro.Anchor = s.Item2.Anchor;
int oldx = s.Item3.Size.X;
s.Item2.Parent!.Controls.Add(iro);
s.Item2.Parent!.Controls.Remove(s.Item2);
s.Item3.Text = prof.DisplayName;
Controls.Remove(ProfileFlow);
ProfileFlow = null;
arg.Location = new(arg.Location.X - oldx + s.Item3.Size.X, arg.Location.Y, arg.Location.Z);
arg.ForceDistanceUpdate(arg.Parent!);
Globals.ServerProfile = prof;
arg.Tag = new Tuple<SocketAppUser, IRenderObject, Label>(s.Item1, iro, s.Item3);
TryDraw();
};
ProfileFlow.Controls.Add(con);
ProfileFlow.Size = new((int)arg.SizeAsFloat.X, ProfileFlow.Size.Y + con.Size.Y);
}
ProfileFlow.Location = new(ser.Size.X + 5.ScaleInt(),
CS.Y - 54.ScaleInt() - ProfileFlow.Size.Y,
0);
Controls.Add(ProfileFlow);
}
else
{
Controls.Remove(ProfileFlow);
ProfileFlow = null;
}
DrawFrame();
}
private Task SettingOnClicked(IRenderObject arg) private Task SettingOnClicked(IRenderObject arg)
{ {
SettingsMenu sm = new(); SettingsMenu sm = new();

View File

@ -266,6 +266,8 @@ public static class Globals
public static Dictionary<long, Texture> UserTextureMap = new(); public static Dictionary<long, Texture> UserTextureMap = new();
public static Dictionary<long, Texture> ProfileTextureMap = new(); public static Dictionary<long, Texture> ProfileTextureMap = new();
public static ServerProfile? ServerProfile = null;
public static async Task<IRenderObject> MakeRct<TUser>(this ServerProfile Profile, TUser User, Vector2i Size) where TUser : SocketUser public static async Task<IRenderObject> MakeRct<TUser>(this ServerProfile Profile, TUser User, Vector2i Size) where TUser : SocketUser
{ {
Texture t = ms.TextureManager.GetTextureResource("Status.png"); Texture t = ms.TextureManager.GetTextureResource("Status.png");

View File

@ -22,7 +22,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="GraphicsManager" Version="1.0.9-alpha72" /> <PackageReference Include="GraphicsManager" Version="1.0.9-alpha72" />
<PackageReference Include="Luski.net" Version="2.0.0-alpha93" /> <PackageReference Include="Luski.net" Version="2.0.0-alpha95" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B