Compare commits
No commits in common. "baa7fc74e08b83ec825dfc121c7b8492353d71e2" and "77ec87d795788367d4e62663d1f109dc9e738957" have entirely different histories.
baa7fc74e0
...
77ec87d795
@ -1,39 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,14 +28,12 @@ public class RoleView : FlowLayout
|
|||||||
|
|
||||||
public async Task AddUser(SocketUser user, Role TopRole)
|
public async Task AddUser(SocketUser user, Role TopRole)
|
||||||
{
|
{
|
||||||
ServerProfile DefaultProfile = await user.Server.GetProfile(user.ServerProfile, CancellationToken.None);
|
UserView f = await UserView.Make(user, TopRole, r is null);
|
||||||
UserView f = await UserView.Make(user, DefaultProfile, TopRole, r is null);
|
|
||||||
|
|
||||||
uuu.Add(user.Id, f);
|
uuu.Add(user.Id, f);
|
||||||
bool ff = false;
|
bool ff = false;
|
||||||
for (int j = 0; j < Users.Count; j++)
|
for (int j = 0; j < Users.Count; j++)
|
||||||
{
|
{
|
||||||
if (string.Compare(DefaultProfile.DisplayName, DefaultProfile.DisplayName) > 0)
|
if (string.Compare(Users[j].DisplayName, user.DisplayName) > 0)
|
||||||
{
|
{
|
||||||
Users.Insert(j, user);
|
Users.Insert(j, user);
|
||||||
Controls.Insert(j+1, f);
|
Controls.Insert(j+1, f);
|
||||||
|
@ -236,13 +236,6 @@ public class TextBox : UserControl
|
|||||||
_label.Location = _label.Location;
|
_label.Location = _label.Location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_label.Text.Length < CursorLocation)
|
|
||||||
{
|
|
||||||
CursorLocation = _label.Text.Length;
|
|
||||||
var xy = _label.GetCharLocation(CursorLocation);
|
|
||||||
Pointer.Location = new(_label.Location.X + xy.X, _label.Location.Y + xy.Y, Pointer.Location.Z);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string WatermarkText
|
public string WatermarkText
|
||||||
@ -290,8 +283,8 @@ public class TextBox : UserControl
|
|||||||
Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight);
|
Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight);
|
||||||
if (OnRemoveLine is not null) OnRemoveLine.Invoke();
|
if (OnRemoveLine is not null) OnRemoveLine.Invoke();
|
||||||
}
|
}
|
||||||
|
Text = Text.Remove(CursorLocation - 1, 1);
|
||||||
CursorLocation--;
|
CursorLocation--;
|
||||||
Text = Text.Remove(CursorLocation, 1);
|
|
||||||
var f = _label.GetCharLocation(CursorLocation);
|
var f = _label.GetCharLocation(CursorLocation);
|
||||||
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
|
||||||
Pointer.Visible = true;
|
Pointer.Visible = true;
|
||||||
|
@ -9,7 +9,7 @@ public class UserView : UserControl
|
|||||||
{
|
{
|
||||||
public SocketUser User { get; set; }
|
public SocketUser User { get; set; }
|
||||||
|
|
||||||
private UserView(IRenderObject user, SocketUser u, ServerProfile p, Role r, bool offline)
|
private UserView(IRenderObject user, SocketUser u, Role r, bool offline)
|
||||||
{
|
{
|
||||||
this.User = u;
|
this.User = u;
|
||||||
base.Size = new(244.ScaleInt(), 44.ScaleInt());
|
base.Size = new(244.ScaleInt(), 44.ScaleInt());
|
||||||
@ -18,7 +18,7 @@ public class UserView : UserControl
|
|||||||
user.ForceDistanceUpdate(this);
|
user.ForceDistanceUpdate(this);
|
||||||
Label uname = new(Globals.DefaultFont)
|
Label uname = new(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Text = p.DisplayName,
|
Text = u.DisplayName,
|
||||||
Color = r.Color.ToColor4()
|
Color = r.Color.ToColor4()
|
||||||
};
|
};
|
||||||
if (offline) uname.Color = new(uname.Color.R, uname.Color.G, uname.Color.B, uname.Color.A * 0.6f);
|
if (offline) uname.Color = new(uname.Color.R, uname.Color.G, uname.Color.B, uname.Color.A * 0.6f);
|
||||||
@ -28,9 +28,9 @@ public class UserView : UserControl
|
|||||||
Controls.Add(user);
|
Controls.Add(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<UserView> Make(SocketUser u, ServerProfile p, Role r, bool offline)
|
public static async Task<UserView> Make(SocketUser u, Role r, bool offline)
|
||||||
{
|
{
|
||||||
UserView m = new(await p.MakeRct(u, new(32.ScaleInt())), u, p, r, offline);
|
UserView m = new(await u.MakeRct(new(32.ScaleInt()), true), u, r, offline);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
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;
|
||||||
@ -29,16 +31,14 @@ public class ChatMessage : UserControl
|
|||||||
|
|
||||||
public static async Task<ChatMessage> MakeChatMessage(PublicChat p, SocketMessage message)
|
public static async Task<ChatMessage> MakeChatMessage(PublicChat p, SocketMessage message)
|
||||||
{
|
{
|
||||||
SocketUser auth = (SocketUser)(await message.GetAuthor(CancellationToken.None));
|
IUser auth = await message.GetAuthor(CancellationToken.None);
|
||||||
ServerProfile prof = await message.GetProfile(CancellationToken.None);
|
Color c = await auth.GetColor();
|
||||||
Color? c = await prof.GetColor();
|
|
||||||
if (c is null) c = await auth.GetColor();
|
|
||||||
Color4 c4 = new(c.R, c.G, c.B, c.A);
|
Color4 c4 = new(c.R, c.G, c.B, c.A);
|
||||||
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), prof, await prof.MakeRct(auth, new(40.ScaleInt())), c4);
|
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), auth, await auth.MakeRct(new(40.ScaleInt()), message.IsProfile), c4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, ServerProfile Author, IRenderObject UserIcon, Color4 UserNameColor)
|
private ChatMessage(PublicChat p, SocketMessage message, SocketChannel chan, IUser Author, IRenderObject UserIcon, Color4 UserNameColor)
|
||||||
{
|
{
|
||||||
pc = p;
|
pc = p;
|
||||||
Label label1;
|
Label label1;
|
||||||
@ -87,6 +87,7 @@ public class ChatMessage : UserControl
|
|||||||
Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor, Text = Author.DisplayName });
|
Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor, Text = Author.DisplayName });
|
||||||
label1.Location = new(
|
label1.Location = new(
|
||||||
54.ScaleInt(),
|
54.ScaleInt(),
|
||||||
|
//(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,
|
UserIcon.Location.Y,
|
||||||
0);
|
0);
|
||||||
Label label2;
|
Label label2;
|
||||||
|
@ -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, FakeProfile: Globals.ServerProfile);
|
await Channel!.SendMessage(tb.Text);
|
||||||
tb.Text = string.Empty;
|
tb.Text = string.Empty;
|
||||||
tb.CursorLocation = 0;
|
tb.CursorLocation = 0;
|
||||||
}
|
}
|
||||||
@ -355,6 +355,7 @@ public class PublicChat : UserControl
|
|||||||
|
|
||||||
private SocketMessage? lastm;
|
private SocketMessage? lastm;
|
||||||
private long? lastUser;
|
private long? lastUser;
|
||||||
|
private bool fake = false;
|
||||||
public ChatMessage? LastChatMessage;
|
public ChatMessage? LastChatMessage;
|
||||||
|
|
||||||
private SocketMessage? lastmIndex;
|
private SocketMessage? lastmIndex;
|
||||||
@ -446,14 +447,16 @@ 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.TimeStamp).ToLocalTime().AddMinutes(10) <
|
Channel!.Epoch.AddMilliseconds(lastm.ID >> 22).ToLocalTime().AddMinutes(10) <
|
||||||
Channel!.Epoch.AddMilliseconds(Message.TimeStamp).ToLocalTime();
|
Channel!.Epoch.AddMilliseconds(Message.ID >> 22).ToLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
lastm = Message;
|
lastm = Message;
|
||||||
if (lastUser is null || lastUser != Message.ProfileID || hasbeentenmin)
|
if (lastUser is null || lastUser != Message.AuthorID || hasbeentenmin || fake != Message.IsProfile)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Window is null || !Globals.ms.InvokeRequired)
|
if (Window is null || !Globals.ms.InvokeRequired)
|
||||||
{
|
{
|
||||||
MessageFlow.Controls.Add(LastChatMessage = await ChatMessage.MakeChatMessage(this, Message));
|
MessageFlow.Controls.Add(LastChatMessage = await ChatMessage.MakeChatMessage(this, Message));
|
||||||
@ -487,7 +490,8 @@ public class PublicChat : UserControl
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastUser = Message.ProfileID;
|
fake = Message.IsProfile;
|
||||||
|
lastUser = Message.AuthorID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
@ -497,10 +501,10 @@ 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.TimeStamp).ToLocalTime().AddMinutes(10) <
|
Channel!.Epoch.AddMilliseconds(lastmIndex.ID >> 22).ToLocalTime().AddMinutes(10) <
|
||||||
Channel!.Epoch.AddMilliseconds(Message.TimeStamp).ToLocalTime();
|
Channel!.Epoch.AddMilliseconds(Message.ID >> 22).ToLocalTime();
|
||||||
lastmIndex = Message;
|
lastmIndex = Message;
|
||||||
if (lastUserIndex is null || lastUserIndex != Message.ProfileID || hasbeentenmin)
|
if (lastUserIndex is null || lastUserIndex != Message.AuthorID || hasbeentenmin || fake != Message.IsProfile)
|
||||||
{
|
{
|
||||||
if (Window is null || !Globals.ms.InvokeRequired)
|
if (Window is null || !Globals.ms.InvokeRequired)
|
||||||
{
|
{
|
||||||
@ -535,6 +539,7 @@ public class PublicChat : UserControl
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastUserIndex = Message.ProfileID;
|
fakeIndex = Message.IsProfile;
|
||||||
|
lastUserIndex = Message.AuthorID;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ using GraphicsManager.Objects;
|
|||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using Luski.net;
|
using Luski.net;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using OpenTK.Mathematics;
|
|
||||||
|
|
||||||
namespace Luski.GUI.MainScreen.UI;
|
namespace Luski.GUI.MainScreen.UI;
|
||||||
|
|
||||||
@ -46,30 +45,15 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerIcon(TServer Server, bool Failed = false)
|
public ServerIcon(TServer Server)
|
||||||
{
|
{
|
||||||
Rectangle r;
|
Rectangle r = new(Globals.ms.TextureManager.GetTextureResource("rc.png"))
|
||||||
if (Server is PublicServer ps)
|
|
||||||
{
|
|
||||||
var rpre = ps.MakeRct(new(32.ScaleInt()));
|
|
||||||
Task.WaitAll(rpre);
|
|
||||||
r = (Rectangle)rpre.Result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = new(Globals.ms.TextureManager.GetTextureResource("rc.png"))
|
|
||||||
{
|
{
|
||||||
|
Location = new(18.ScaleInt(), 8.ScaleInt(), 0),
|
||||||
Size = new(32.ScaleInt()),
|
Size = new(32.ScaleInt()),
|
||||||
Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context],
|
Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context],
|
||||||
IgnoreHover = true
|
IgnoreHover = true
|
||||||
};
|
};
|
||||||
Texture t = Globals.ms.TextureManager.AddTexture(Server.GetAvatar(CancellationToken.None).Result);
|
|
||||||
t.Unit = TextureUnit.Texture1;
|
|
||||||
r.Textures.Add(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
r.Location = new(18.ScaleInt(), 8.ScaleInt(), 0);
|
|
||||||
r.IgnoreHover = true;
|
|
||||||
Rectangle rr = new(r.Textures[0])
|
Rectangle rr = new(r.Textures[0])
|
||||||
{
|
{
|
||||||
Location = new(17.ScaleInt(), 7.ScaleInt(), 0),
|
Location = new(17.ScaleInt(), 7.ScaleInt(), 0),
|
||||||
@ -86,9 +70,10 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
|
|||||||
BackgroundColor = new(26, 26, 26, 255),
|
BackgroundColor = new(26, 26, 26, 255),
|
||||||
IgnoreHover = true
|
IgnoreHover = true
|
||||||
};
|
};
|
||||||
if (Failed) SelectedRect.BackgroundColor = Color4.DarkRed;
|
|
||||||
this.Server = Server;
|
this.Server = Server;
|
||||||
|
Texture t = Globals.ms.TextureManager.AddTexture(Server.GetAvatar(CancellationToken.None).Result);
|
||||||
|
t.Unit = TextureUnit.Texture1;
|
||||||
|
r.Textures.Add(t);
|
||||||
Controls.Add(SelectedRect);
|
Controls.Add(SelectedRect);
|
||||||
Controls.Add(rr);
|
Controls.Add(rr);
|
||||||
Controls.Add(r);
|
Controls.Add(r);
|
||||||
|
@ -7,7 +7,6 @@ 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;
|
||||||
@ -260,8 +259,7 @@ public class MainScreenWindow : Window
|
|||||||
Role[] ra = await Server.User.GetRoles();
|
Role[] ra = await Server.User.GetRoles();
|
||||||
Color c = ra[0].Color;
|
Color c = ra[0].Color;
|
||||||
Color4 c4 = new(c.R, c.G, c.B, c.A);
|
Color4 c4 = new(c.R, c.G, c.B, c.A);
|
||||||
ServerProfile DefaultProfile = await Server.GetProfile(Server.User.ServerProfile, CancellationToken.None);
|
IRenderObject u = await Server.User.MakeRct(new(46.ScaleInt()), false);
|
||||||
IRenderObject u = await DefaultProfile.MakeRct(Server.User, new(46.ScaleInt()));
|
|
||||||
int ii = 4.ScaleInt();
|
int ii = 4.ScaleInt();
|
||||||
u.Location = new(ii, cs.Size.Y + ii, 0);
|
u.Location = new(ii, cs.Size.Y + ii, 0);
|
||||||
u.Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left;
|
u.Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left;
|
||||||
@ -271,35 +269,12 @@ public class MainScreenWindow : Window
|
|||||||
Label ul = new Label(Globals.DefaultFont)
|
Label ul = new Label(Globals.DefaultFont)
|
||||||
{
|
{
|
||||||
Anchor = u.Anchor,
|
Anchor = u.Anchor,
|
||||||
Text = DefaultProfile.DisplayName,
|
Text = Server.User.DisplayName,
|
||||||
Color = c4
|
Color = c4
|
||||||
};
|
};
|
||||||
|
|
||||||
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"))
|
||||||
{
|
{
|
||||||
@ -334,53 +309,6 @@ 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();
|
||||||
@ -442,14 +370,6 @@ public class MainScreenWindow : Window
|
|||||||
si.LoadToParent(ser, this);
|
si.LoadToParent(ser, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (PublicServer pser in Globals.Luski.FailedServers)
|
|
||||||
{
|
|
||||||
Console.WriteLine(pser.Name);
|
|
||||||
ServerIcon<PublicServer> si = new ServerIcon<PublicServer>(pser, true);
|
|
||||||
ser.Controls.Add(si);
|
|
||||||
si.LoadToParent(ser, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
AddServerIcon asi = new();
|
AddServerIcon asi = new();
|
||||||
asi.Clicked += AddButtonClicked;
|
asi.Clicked += AddButtonClicked;
|
||||||
ser.Controls.Add(asi);
|
ser.Controls.Add(asi);
|
||||||
|
@ -266,12 +266,21 @@ 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;
|
private static async Task<Texture> GetIcon(this SocketUser User)
|
||||||
|
{
|
||||||
|
if (UserTextureMap.TryGetValue(User.Id, out Texture? t)) return t;
|
||||||
|
Stream UserStream = await User.GetAvatar(CancellationToken.None);
|
||||||
|
t = Globals.ms.TextureManager.AddTexture(UserStream);
|
||||||
|
UserTextureMap.Add(User.Id, t);
|
||||||
|
UserStream.Dispose();
|
||||||
|
t.Unit = TextureUnit.Texture1;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
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 TUser User, Vector2i Size, bool IsProfile) where TUser : IUser
|
||||||
{
|
{
|
||||||
Texture t = ms.TextureManager.GetTextureResource("Status.png");
|
Texture t = ms.TextureManager.GetTextureResource("Status.png");
|
||||||
if (Profile.PictureType == PictureType.none)
|
if (User.PictureType == PictureType.none)
|
||||||
{
|
{
|
||||||
UserControl r = new(t);
|
UserControl r = new(t);
|
||||||
r.Size = Size;
|
r.Size = Size;
|
||||||
@ -282,7 +291,7 @@ public static class Globals
|
|||||||
{
|
{
|
||||||
Color = c.ToColor4()
|
Color = c.ToColor4()
|
||||||
};
|
};
|
||||||
l.Text = Profile.DisplayName[0].ToString();
|
l.Text = User.DisplayName[0].ToString();
|
||||||
var y = l.GetSizeOfChar(0);
|
var y = l.GetSizeOfChar(0);
|
||||||
l.Location = new((r.Size.X - l.Size.X)/2,
|
l.Location = new((r.Size.X - l.Size.X)/2,
|
||||||
(int)(r.Size.Y - (l.Font.PixelHeight - y.Y) - (r.Size.Y / 2) - (y.Y/2)),
|
(int)(r.Size.Y - (l.Font.PixelHeight - y.Y) - (r.Size.Y / 2) - (y.Y/2)),
|
||||||
@ -295,61 +304,34 @@ public static class Globals
|
|||||||
Rectangle r = new(t);
|
Rectangle r = new(t);
|
||||||
r.Size = Size;
|
r.Size = Size;
|
||||||
r.Shader = Rectangle.DefaultAlphaTextureShader[ms.Context];
|
r.Shader = Rectangle.DefaultAlphaTextureShader[ms.Context];
|
||||||
r.Textures.Add(await Profile.GetIcon());
|
r.Textures.Add(await User.GetIcon(IsProfile));
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<IRenderObject> MakeRct(this PublicServer Server, Vector2i Size)
|
private static async Task<Texture> GetIcon(this IUser User, bool IsProfile)
|
||||||
{
|
{
|
||||||
Texture t = ms.TextureManager.GetTextureResource("rc.png");
|
if (IsProfile)
|
||||||
if (Server.PictureType == PictureType.none)
|
|
||||||
{
|
{
|
||||||
UserControl r = new(t);
|
if (ProfileTextureMap.TryGetValue(User.Id, out Texture? t)) return t;
|
||||||
r.Size = Size;
|
|
||||||
r.Shader = Rectangle.DefaultAlphaShader[ms.Context];
|
|
||||||
r.BackgroundColor = new(25, 25, 25, 255);
|
|
||||||
Label l = new(DefaultFont)
|
|
||||||
{
|
|
||||||
Color = new(255,255,255,255)
|
|
||||||
};
|
|
||||||
l.Text = Server.Name[0].ToString();
|
|
||||||
var y = l.GetSizeOfChar(0);
|
|
||||||
l.Location = new((r.Size.X - l.Size.X)/2,
|
|
||||||
(int)(r.Size.Y - (l.Font.PixelHeight - y.Y) - (r.Size.Y / 2) - (y.Y/2)),
|
|
||||||
0);
|
|
||||||
r.Controls.Add(l);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Rectangle r = new(t);
|
|
||||||
r.Size = Size;
|
|
||||||
r.Shader = Rectangle.DefaultAlphaTextureShader[ms.Context];
|
|
||||||
r.Textures.Add(await Server.GetIcon());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<Texture> GetIcon<TServer>(this TServer Server) where TServer : Server
|
|
||||||
{
|
|
||||||
Stream UserStream = await Server.GetAvatar(CancellationToken.None);
|
|
||||||
Texture t = Globals.ms.TextureManager.AddTexture(UserStream);
|
|
||||||
UserStream.Dispose();
|
|
||||||
t.Unit = TextureUnit.Texture1;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<Texture> GetIcon(this ServerProfile User)
|
|
||||||
{
|
|
||||||
if (ProfileTextureMap.TryGetValue(User.ID, out Texture? t)) return t;
|
|
||||||
Stream UserStream = await User.GetAvatar(CancellationToken.None);
|
Stream UserStream = await User.GetAvatar(CancellationToken.None);
|
||||||
t = Globals.ms.TextureManager.AddTexture(UserStream);
|
t = Globals.ms.TextureManager.AddTexture(UserStream);
|
||||||
ProfileTextureMap.Add(User.ID, t);
|
ProfileTextureMap.Add(User.Id, t);
|
||||||
UserStream.Dispose();
|
UserStream.Dispose();
|
||||||
t.Unit = TextureUnit.Texture1;
|
t.Unit = TextureUnit.Texture1;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (UserTextureMap.TryGetValue(User.Id, out Texture? t)) return t;
|
||||||
|
Stream UserStream = await User.GetAvatar(CancellationToken.None);
|
||||||
|
t = Globals.ms.TextureManager.AddTexture(UserStream);
|
||||||
|
UserTextureMap.Add(User.Id, t);
|
||||||
|
UserStream.Dispose();
|
||||||
|
t.Unit = TextureUnit.Texture1;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Settings Settings { get; set; }
|
public static Settings Settings { get; set; }
|
||||||
|
|
||||||
|
@ -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-alpha98" />
|
<PackageReference Include="Luski.net" Version="2.0.0-alpha89" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 218 B |
Loading…
Reference in New Issue
Block a user