Merging dev into main #19
@ -5,6 +5,7 @@ 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;
|
||||||
|
|
||||||
@ -45,15 +46,30 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerIcon(TServer Server)
|
public ServerIcon(TServer Server, bool Failed = false)
|
||||||
{
|
{
|
||||||
Rectangle r = new(Globals.ms.TextureManager.GetTextureResource("rc.png"))
|
Rectangle r;
|
||||||
|
if (Server is PublicServer ps)
|
||||||
{
|
{
|
||||||
Location = new(18.ScaleInt(), 8.ScaleInt(), 0),
|
var rpre = ps.MakeRct(new(32.ScaleInt()));
|
||||||
Size = new(32.ScaleInt()),
|
Task.WaitAll(rpre);
|
||||||
Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context],
|
r = (Rectangle)rpre.Result;
|
||||||
IgnoreHover = true
|
}
|
||||||
};
|
else
|
||||||
|
{
|
||||||
|
r = new(Globals.ms.TextureManager.GetTextureResource("rc.png"))
|
||||||
|
{
|
||||||
|
Size = new(32.ScaleInt()),
|
||||||
|
Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context],
|
||||||
|
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),
|
||||||
@ -70,10 +86,9 @@ 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);
|
||||||
|
@ -442,6 +442,14 @@ 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);
|
||||||
|
@ -300,6 +300,46 @@ public static class Globals
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<IRenderObject> MakeRct(this PublicServer Server, Vector2i Size)
|
||||||
|
{
|
||||||
|
Texture t = ms.TextureManager.GetTextureResource("rc.png");
|
||||||
|
if (Server.PictureType == PictureType.none)
|
||||||
|
{
|
||||||
|
UserControl r = new(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)
|
private static async Task<Texture> GetIcon(this ServerProfile User)
|
||||||
{
|
{
|
||||||
if (ProfileTextureMap.TryGetValue(User.ID, out Texture? t)) return t;
|
if (ProfileTextureMap.TryGetValue(User.ID, out Texture? t)) return t;
|
||||||
|
@ -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-alpha95" />
|
<PackageReference Include="Luski.net" Version="2.0.0-alpha98" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user