diff --git a/ClassicalSharp/2D/Screens/HudScreen.cs b/ClassicalSharp/2D/Screens/HudScreen.cs
index a1b1c0762..cca2d6a4f 100644
--- a/ClassicalSharp/2D/Screens/HudScreen.cs
+++ b/ClassicalSharp/2D/Screens/HudScreen.cs
@@ -88,9 +88,7 @@ namespace ClassicalSharp.Gui.Screens {
if (!hadPlayerList) return;
- if (game.UseClassicTabList) {
- playerList = new ClassicPlayerListWidget(game, playerFont);
- } else if (game.Server.UsingExtPlayerList) {
+ if (game.Server.UsingExtPlayerList && !game.UseClassicTabList) {
playerList = new ExtPlayerListWidget(game, playerFont);
} else {
playerList = new NormalPlayerListWidget(game, playerFont);
diff --git a/ClassicalSharp/2D/Widgets/PlayerList/ClassicPlayerListWidget.cs b/ClassicalSharp/2D/Widgets/PlayerList/ClassicPlayerListWidget.cs
deleted file mode 100644
index ce7cb2659..000000000
--- a/ClassicalSharp/2D/Widgets/PlayerList/ClassicPlayerListWidget.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
-using System;
-using System.Drawing;
-
-namespace ClassicalSharp.Gui.Widgets {
- public sealed class ClassicPlayerListWidget : NormalPlayerListWidget {
-
- TextWidget overview;
- static FastColour topCol = new FastColour(0, 0, 0, 180);
- static FastColour bottomCol = new FastColour(50, 50, 50, 205);
- public ClassicPlayerListWidget(Game game, Font font) : base(game, font) {
- }
-
- protected override void OnSort() {
- int width = 0, centreX = game.Width / 2;
- for (int col = 0; col < columns; col++)
- width += GetColumnWidth(col);
- if (width < 480) width = 480;
-
- xMin = centreX - width / 2;
- xMax = centreX + width / 2;
-
- int x = xMin, y = game.Height / 2 - yHeight / 2;
- for (int col = 0; col < columns; col++) {
- SetColumnPos(col, x, y);
- x += GetColumnWidth(col);
- }
- }
-
- public override void Render(double delta) {
- gfx.Texturing = false;
- int offset = overview.Height + 10;
- int height = Math.Max(300, Height + overview.Height);
- gfx.Draw2DQuad(X, Y - offset, Width, height, topCol, bottomCol);
-
- gfx.Texturing = true;
- overview.YOffset = Y - offset + 5;
- overview.Reposition();
- overview.Render(delta);
-
- for (int i = 0; i < namesCount; i++) {
- Texture tex = textures[i];
- int texY = tex.Y;
- tex.Y1 -= 10;
- if (tex.IsValid) tex.Render(gfx);
- tex.Y1 = texY;
- }
- }
-
- public override void Init() {
- overview = TextWidget.Create(game, "Connected players:", font)
- .SetLocation(Anchor.Centre, Anchor.LeftOrTop, 0, 0);
- base.Init();
- }
-
- protected override Texture DrawName(PlayerInfo pInfo) {
- string name = pInfo.ColouredName;
- if (game.PureClassic) name = Utils.StripColours(name);
-
- DrawTextArgs args = new DrawTextArgs(name, font, false);
- Texture tex = game.Drawer2D.MakeTextTexture(ref args, 0, 0);
- game.Drawer2D.ReducePadding(ref tex, Utils.Floor(font.Size), 3);
- return tex;
- }
-
- public override void Dispose() {
- base.Dispose();
- overview.Dispose();
- }
- }
-}
\ No newline at end of file
diff --git a/ClassicalSharp/2D/Widgets/PlayerList/ExtPlayerListWidget.cs b/ClassicalSharp/2D/Widgets/PlayerList/ExtPlayerListWidget.cs
index da96a0bca..2aee70a23 100644
--- a/ClassicalSharp/2D/Widgets/PlayerList/ExtPlayerListWidget.cs
+++ b/ClassicalSharp/2D/Widgets/PlayerList/ExtPlayerListWidget.cs
@@ -10,7 +10,6 @@ namespace ClassicalSharp.Gui.Widgets {
public ExtPlayerListWidget(Game game, Font font) : base(game, font) {
textures = new Texture[512];
- titleFont = new Font(game.FontName, font.Size);
elementOffset = 10;
}
@@ -57,7 +56,6 @@ namespace ClassicalSharp.Gui.Widgets {
return info[i] == null || !info[i].IsGroup;
}
- Font titleFont;
public override void Init() {
base.Init();
game.EntityEvents.TabListEntryAdded += TabEntryAdded;
@@ -70,7 +68,6 @@ namespace ClassicalSharp.Gui.Widgets {
game.EntityEvents.TabListEntryAdded -= TabEntryAdded;
game.EntityEvents.TabListEntryChanged -= TabEntryChanged;
game.EntityEvents.TabListEntryRemoved -= TabEntryRemoved;
- titleFont.Dispose();
}
void TabEntryChanged(object sender, IdEventArgs e) {
@@ -112,10 +109,10 @@ namespace ClassicalSharp.Gui.Widgets {
public override string GetNameUnder(int mouseX, int mouseY) {
for (int i = 0; i < namesCount; i++) {
- Texture texture = textures[i];
- if (texture.IsValid && texture.Bounds.Contains(mouseX, mouseY)
- && info[i].PlayerName != null)
+ Texture tex = textures[i];
+ if (tex.IsValid && tex.Bounds.Contains(mouseX, mouseY) && !info[i].IsGroup) {
return Utils.StripColours(info[i].PlayerName);
+ }
}
return null;
}
@@ -166,9 +163,9 @@ namespace ClassicalSharp.Gui.Widgets {
}
void AddGroup(string group, ref int index) {
- DrawTextArgs args = new DrawTextArgs(group, titleFont, true);
+ DrawTextArgs args = new DrawTextArgs(group, font, true);
Texture tex = game.Drawer2D.MakeTextTexture(ref args, 0, 0);
- game.Drawer2D.ReducePadding(ref tex, Utils.Floor(titleFont.Size), 3);
+ game.Drawer2D.ReducePadding(ref tex, Utils.Floor(font.Size), 3);
for (int i = info.Length - 1; i > index; i--) {
info[i] = info[i - 1];
diff --git a/ClassicalSharp/2D/Widgets/PlayerList/NormalPlayerListWidget.cs b/ClassicalSharp/2D/Widgets/PlayerList/NormalPlayerListWidget.cs
index a5628e4df..4c8d29ec0 100644
--- a/ClassicalSharp/2D/Widgets/PlayerList/NormalPlayerListWidget.cs
+++ b/ClassicalSharp/2D/Widgets/PlayerList/NormalPlayerListWidget.cs
@@ -58,7 +58,7 @@ namespace ClassicalSharp.Gui.Widgets {
}
void AddPlayerInfo(PlayerInfo pInfo, int index) {
- Texture tex = DrawName(pInfo);
+ Texture tex = DrawName(pInfo);
if (index < 0) {
info[namesCount] = pInfo;
textures[namesCount] = tex;
@@ -69,8 +69,11 @@ namespace ClassicalSharp.Gui.Widgets {
}
}
- protected virtual Texture DrawName(PlayerInfo pInfo) {
- DrawTextArgs args = new DrawTextArgs(pInfo.ColouredName, font, false);
+ Texture DrawName(PlayerInfo pInfo) {
+ string name = pInfo.ColouredName;
+ if (game.PureClassic) name = Utils.StripColours(name);
+
+ DrawTextArgs args = new DrawTextArgs(name, font, false);
Texture tex = game.Drawer2D.MakeTextTexture(ref args, 0, 0);
game.Drawer2D.ReducePadding(ref tex, Utils.Floor(font.Size), 3);
return tex;
diff --git a/ClassicalSharp/2D/Widgets/PlayerList/PlayerListWidget.cs b/ClassicalSharp/2D/Widgets/PlayerList/PlayerListWidget.cs
index 6ccb3ddfc..5e1411bd3 100644
--- a/ClassicalSharp/2D/Widgets/PlayerList/PlayerListWidget.cs
+++ b/ClassicalSharp/2D/Widgets/PlayerList/PlayerListWidget.cs
@@ -11,19 +11,25 @@ namespace ClassicalSharp.Gui.Widgets {
VerticalAnchor = Anchor.Centre;
this.font = font;
}
-
- protected int columnPadding = 5;
- protected int elementOffset = 0;
-
+
+ protected const int columnPadding = 5;
protected const int boundsSize = 10;
protected const int namesPerColumn = 20;
+
+ protected int elementOffset = 0;
protected int namesCount = 0;
protected Texture[] textures;
protected int columns;
protected int xMin, xMax, yHeight;
- protected static FastColour tableCol = new FastColour(50, 50, 50, 205);
+
+ static FastColour topCol = new FastColour(0, 0, 0, 180);
+ static FastColour bottomCol = new FastColour(50, 50, 50, 205);
+ TextWidget overview;
public override void Init() {
+ overview = TextWidget.Create(game, "Connected players:", font)
+ .SetLocation(Anchor.Centre, Anchor.LeftOrTop, 0, 0);
+
CreateInitialPlayerInfo();
SortPlayerInfo();
}
@@ -32,12 +38,21 @@ namespace ClassicalSharp.Gui.Widgets {
public override void Render(double delta) {
gfx.Texturing = false;
- gfx.Draw2DQuad(X, Y, Width, Height, tableCol);
+ int offset = overview.Height + 10;
+ int height = Math.Max(300, Height + overview.Height);
+ gfx.Draw2DQuad(X, Y - offset, Width, height, topCol, bottomCol);
+
gfx.Texturing = true;
+ overview.YOffset = Y - offset + 5;
+ overview.Reposition();
+ overview.Render(delta);
+
for (int i = 0; i < namesCount; i++) {
- Texture texture = textures[i];
- if (texture.IsValid)
- texture.Render(gfx);
+ Texture tex = textures[i];
+ int texY = tex.Y;
+ tex.Y1 -= 10;
+ if (tex.IsValid) tex.Render(gfx);
+ tex.Y1 = texY;
}
}
@@ -47,6 +62,7 @@ namespace ClassicalSharp.Gui.Widgets {
gfx.DeleteTexture(ref tex);
textures[i] = tex;
}
+ overview.Dispose();
}
protected void UpdateTableDimensions() {
@@ -93,7 +109,7 @@ namespace ClassicalSharp.Gui.Widgets {
tex.X1 = x; tex.Y1 = y;
y += tex.Height + 1;
- if (ShouldOffset(i))
+ if (ShouldOffset(i))
tex.X1 += elementOffset;
textures[i] = tex;
}
@@ -121,7 +137,7 @@ namespace ClassicalSharp.Gui.Widgets {
protected void RemoveTextureAt(int i) {
Texture tex = textures[i];
- gfx.DeleteTexture(ref tex);
+ gfx.DeleteTexture(ref tex);
RemoveItemAt(textures, i);
namesCount--;
SortPlayerInfo();
@@ -166,6 +182,20 @@ namespace ClassicalSharp.Gui.Widgets {
Reposition();
}
- protected virtual void OnSort() { }
+ protected virtual void OnSort() {
+ int width = 0, centreX = game.Width / 2;
+ for (int col = 0; col < columns; col++)
+ width += GetColumnWidth(col);
+ if (width < 480) width = 480;
+
+ xMin = centreX - width / 2;
+ xMax = centreX + width / 2;
+
+ int x = xMin, y = game.Height / 2 - yHeight / 2;
+ for (int col = 0; col < columns; col++) {
+ SetColumnPos(col, x, y);
+ x += GetColumnWidth(col);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/ClassicalSharp/ClassicalSharp.csproj b/ClassicalSharp/ClassicalSharp.csproj
index d20c9c96f..10113c629 100644
--- a/ClassicalSharp/ClassicalSharp.csproj
+++ b/ClassicalSharp/ClassicalSharp.csproj
@@ -127,7 +127,6 @@
-