mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Tab list redesign #1: Always have classic tab list sized box, show 'connected players' at top.
This commit is contained in:
parent
416247c0b0
commit
9066bf55ae
@ -88,9 +88,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
|
|
||||||
if (!hadPlayerList) return;
|
if (!hadPlayerList) return;
|
||||||
|
|
||||||
if (game.UseClassicTabList) {
|
if (game.Server.UsingExtPlayerList && !game.UseClassicTabList) {
|
||||||
playerList = new ClassicPlayerListWidget(game, playerFont);
|
|
||||||
} else if (game.Server.UsingExtPlayerList) {
|
|
||||||
playerList = new ExtPlayerListWidget(game, playerFont);
|
playerList = new ExtPlayerListWidget(game, playerFont);
|
||||||
} else {
|
} else {
|
||||||
playerList = new NormalPlayerListWidget(game, playerFont);
|
playerList = new NormalPlayerListWidget(game, playerFont);
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,6 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
|
|
||||||
public ExtPlayerListWidget(Game game, Font font) : base(game, font) {
|
public ExtPlayerListWidget(Game game, Font font) : base(game, font) {
|
||||||
textures = new Texture[512];
|
textures = new Texture[512];
|
||||||
titleFont = new Font(game.FontName, font.Size);
|
|
||||||
elementOffset = 10;
|
elementOffset = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +56,6 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
return info[i] == null || !info[i].IsGroup;
|
return info[i] == null || !info[i].IsGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
Font titleFont;
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
base.Init();
|
base.Init();
|
||||||
game.EntityEvents.TabListEntryAdded += TabEntryAdded;
|
game.EntityEvents.TabListEntryAdded += TabEntryAdded;
|
||||||
@ -70,7 +68,6 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
game.EntityEvents.TabListEntryAdded -= TabEntryAdded;
|
game.EntityEvents.TabListEntryAdded -= TabEntryAdded;
|
||||||
game.EntityEvents.TabListEntryChanged -= TabEntryChanged;
|
game.EntityEvents.TabListEntryChanged -= TabEntryChanged;
|
||||||
game.EntityEvents.TabListEntryRemoved -= TabEntryRemoved;
|
game.EntityEvents.TabListEntryRemoved -= TabEntryRemoved;
|
||||||
titleFont.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabEntryChanged(object sender, IdEventArgs e) {
|
void TabEntryChanged(object sender, IdEventArgs e) {
|
||||||
@ -112,10 +109,10 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
|
|
||||||
public override string GetNameUnder(int mouseX, int mouseY) {
|
public override string GetNameUnder(int mouseX, int mouseY) {
|
||||||
for (int i = 0; i < namesCount; i++) {
|
for (int i = 0; i < namesCount; i++) {
|
||||||
Texture texture = textures[i];
|
Texture tex = textures[i];
|
||||||
if (texture.IsValid && texture.Bounds.Contains(mouseX, mouseY)
|
if (tex.IsValid && tex.Bounds.Contains(mouseX, mouseY) && !info[i].IsGroup) {
|
||||||
&& info[i].PlayerName != null)
|
|
||||||
return Utils.StripColours(info[i].PlayerName);
|
return Utils.StripColours(info[i].PlayerName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -166,9 +163,9 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AddGroup(string group, ref int index) {
|
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);
|
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--) {
|
for (int i = info.Length - 1; i > index; i--) {
|
||||||
info[i] = info[i - 1];
|
info[i] = info[i - 1];
|
||||||
|
@ -69,8 +69,11 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Texture DrawName(PlayerInfo pInfo) {
|
Texture DrawName(PlayerInfo pInfo) {
|
||||||
DrawTextArgs args = new DrawTextArgs(pInfo.ColouredName, font, false);
|
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);
|
Texture tex = game.Drawer2D.MakeTextTexture(ref args, 0, 0);
|
||||||
game.Drawer2D.ReducePadding(ref tex, Utils.Floor(font.Size), 3);
|
game.Drawer2D.ReducePadding(ref tex, Utils.Floor(font.Size), 3);
|
||||||
return tex;
|
return tex;
|
||||||
|
@ -12,18 +12,24 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
this.font = font;
|
this.font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int columnPadding = 5;
|
protected const int columnPadding = 5;
|
||||||
protected int elementOffset = 0;
|
|
||||||
|
|
||||||
protected const int boundsSize = 10;
|
protected const int boundsSize = 10;
|
||||||
protected const int namesPerColumn = 20;
|
protected const int namesPerColumn = 20;
|
||||||
|
|
||||||
|
protected int elementOffset = 0;
|
||||||
protected int namesCount = 0;
|
protected int namesCount = 0;
|
||||||
protected Texture[] textures;
|
protected Texture[] textures;
|
||||||
protected int columns;
|
protected int columns;
|
||||||
protected int xMin, xMax, yHeight;
|
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() {
|
public override void Init() {
|
||||||
|
overview = TextWidget.Create(game, "Connected players:", font)
|
||||||
|
.SetLocation(Anchor.Centre, Anchor.LeftOrTop, 0, 0);
|
||||||
|
|
||||||
CreateInitialPlayerInfo();
|
CreateInitialPlayerInfo();
|
||||||
SortPlayerInfo();
|
SortPlayerInfo();
|
||||||
}
|
}
|
||||||
@ -32,12 +38,21 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
|
|
||||||
public override void Render(double delta) {
|
public override void Render(double delta) {
|
||||||
gfx.Texturing = false;
|
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;
|
gfx.Texturing = true;
|
||||||
|
overview.YOffset = Y - offset + 5;
|
||||||
|
overview.Reposition();
|
||||||
|
overview.Render(delta);
|
||||||
|
|
||||||
for (int i = 0; i < namesCount; i++) {
|
for (int i = 0; i < namesCount; i++) {
|
||||||
Texture texture = textures[i];
|
Texture tex = textures[i];
|
||||||
if (texture.IsValid)
|
int texY = tex.Y;
|
||||||
texture.Render(gfx);
|
tex.Y1 -= 10;
|
||||||
|
if (tex.IsValid) tex.Render(gfx);
|
||||||
|
tex.Y1 = texY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +62,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
gfx.DeleteTexture(ref tex);
|
gfx.DeleteTexture(ref tex);
|
||||||
textures[i] = tex;
|
textures[i] = tex;
|
||||||
}
|
}
|
||||||
|
overview.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UpdateTableDimensions() {
|
protected void UpdateTableDimensions() {
|
||||||
@ -166,6 +182,20 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
Reposition();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -127,7 +127,6 @@
|
|||||||
<Compile Include="2D\Widgets\Menu\MenuInputValidator.cs" />
|
<Compile Include="2D\Widgets\Menu\MenuInputValidator.cs" />
|
||||||
<Compile Include="2D\Widgets\Menu\MenuInputWidget.cs" />
|
<Compile Include="2D\Widgets\Menu\MenuInputWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\ButtonWidget.cs" />
|
<Compile Include="2D\Widgets\ButtonWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\PlayerList\ClassicPlayerListWidget.cs" />
|
|
||||||
<Compile Include="2D\Widgets\PlayerList\ExtPlayerListWidget.cs" />
|
<Compile Include="2D\Widgets\PlayerList\ExtPlayerListWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\PlayerList\NormalPlayerListWidget.cs" />
|
<Compile Include="2D\Widgets\PlayerList\NormalPlayerListWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\PlayerList\PlayerListWidget.cs" />
|
<Compile Include="2D\Widgets\PlayerList\PlayerListWidget.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user