mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Make servers list screen somewhat nicer in the launcher.
This commit is contained in:
parent
0a17f9e8f1
commit
750eeae6be
@ -9,9 +9,11 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
const int tableIndex = 4, searchIndex = 0, hashIndex = 1;
|
const int tableIndex = 4, searchIndex = 0, hashIndex = 1;
|
||||||
Font boldInputFont, tableFont;
|
Font boldInputFont, tableFont;
|
||||||
|
const int tableY = 50;
|
||||||
|
|
||||||
public ClassiCubeServersScreen( LauncherWindow game ) : base( game, true ) {
|
public ClassiCubeServersScreen( LauncherWindow game ) : base( game, true ) {
|
||||||
boldInputFont = new Font( "Arial", 14, FontStyle.Bold );
|
boldInputFont = new Font( "Arial", 14, FontStyle.Bold );
|
||||||
tableFont = new Font( "Arial", 12, FontStyle.Regular );
|
tableFont = new Font( "Arial", 11, FontStyle.Regular );
|
||||||
enterIndex = 3;
|
enterIndex = 3;
|
||||||
widgets = new LauncherWidget[7];
|
widgets = new LauncherWidget[7];
|
||||||
}
|
}
|
||||||
@ -85,14 +87,12 @@ namespace Launcher2 {
|
|||||||
public override void Resize() {
|
public override void Resize() {
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
game.ClearArea( 0, 0, game.Width, 100 );
|
game.ClearArea( 0, 0, game.Width, tableY );
|
||||||
FastColour col = LauncherTableWidget.backGridCol;
|
|
||||||
drawer.Clear( col, 0, 100, game.Width, game.Height - 100 );
|
|
||||||
|
|
||||||
Draw();
|
|
||||||
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
|
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
|
||||||
|
if( table != null )
|
||||||
table.ClampIndex();
|
table.ClampIndex();
|
||||||
table.Redraw( drawer, tableFont, inputFont, inputFont );
|
Draw();
|
||||||
}
|
}
|
||||||
Dirty = true;
|
Dirty = true;
|
||||||
}
|
}
|
||||||
@ -101,20 +101,25 @@ namespace Launcher2 {
|
|||||||
widgetIndex = 0;
|
widgetIndex = 0;
|
||||||
MakeInput( Get(), 475, Anchor.LeftOrTop, Anchor.LeftOrTop,
|
MakeInput( Get(), 475, Anchor.LeftOrTop, Anchor.LeftOrTop,
|
||||||
false, 10, 10, 32, "&7Search servers.." );
|
false, 10, 10, 32, "&7Search servers.." );
|
||||||
MakeInput( Get(), 475, Anchor.LeftOrTop, Anchor.LeftOrTop,
|
MakeInput( Get(), 475, Anchor.LeftOrTop, Anchor.BottomOrRight,
|
||||||
false, 10, 55, 32, "&7classicube.net/server/play/..." );
|
false, 10, -10, 32, "&7classicube.net/server/play/..." );
|
||||||
((LauncherInputWidget)widgets[hashIndex]).ClipboardFilter = HashFilter;
|
((LauncherInputWidget)widgets[hashIndex]).ClipboardFilter = HashFilter;
|
||||||
|
|
||||||
MakeButtonAt( "Back", 110, 30, titleFont, Anchor.BottomOrRight, Anchor.LeftOrTop,
|
MakeButtonAt( "Back", 110, 30, titleFont, Anchor.BottomOrRight, Anchor.LeftOrTop,
|
||||||
-20, 10, (x, y) => game.SetScreen( new MainScreen( game ) ) );
|
-20, 10, (x, y) => game.SetScreen( new MainScreen( game ) ) );
|
||||||
MakeButtonAt( "Connect", 110, 35, titleFont, Anchor.BottomOrRight, Anchor.LeftOrTop,
|
MakeButtonAt( "Connect", 110, 30, titleFont, Anchor.BottomOrRight, Anchor.BottomOrRight,
|
||||||
-20, 55, ConnectToServer );
|
-20, -10, ConnectToServer );
|
||||||
MakeTableWidget();
|
MakeTableWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeTableWidget() {
|
void MakeTableWidget() {
|
||||||
|
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
|
||||||
|
FastColour col = LauncherTableWidget.backGridCol;
|
||||||
|
drawer.Clear( col, 0, tableY, game.Width, tableHeight );
|
||||||
|
|
||||||
if( widgets[tableIndex] != null ) {
|
if( widgets[tableIndex] != null ) {
|
||||||
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
|
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
|
||||||
|
table.Height = tableHeight;
|
||||||
table.Redraw( drawer, tableFont, inputFont, inputFont );
|
table.Redraw( drawer, tableFont, inputFont, inputFont );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -122,8 +127,9 @@ namespace Launcher2 {
|
|||||||
LauncherTableWidget widget = new LauncherTableWidget( game );
|
LauncherTableWidget widget = new LauncherTableWidget( game );
|
||||||
widget.CurrentIndex = 0;
|
widget.CurrentIndex = 0;
|
||||||
widget.SetEntries( game.Session.Servers );
|
widget.SetEntries( game.Session.Servers );
|
||||||
|
widget.Height = tableHeight;
|
||||||
widget.DrawAt( drawer, tableFont, inputFont, inputFont,
|
widget.DrawAt( drawer, tableFont, inputFont, inputFont,
|
||||||
Anchor.LeftOrTop, Anchor.LeftOrTop, 0, 100 );
|
Anchor.LeftOrTop, Anchor.LeftOrTop, 0, tableY );
|
||||||
|
|
||||||
widget.NeedRedraw = Resize;
|
widget.NeedRedraw = Resize;
|
||||||
widget.SelectedChanged = SelectedChanged;
|
widget.SelectedChanged = SelectedChanged;
|
||||||
|
@ -73,8 +73,7 @@ namespace Launcher2 {
|
|||||||
Redraw( drawer, font, titleFont, boldFont );
|
Redraw( drawer, font, titleFont, boldFont );
|
||||||
}
|
}
|
||||||
|
|
||||||
static FastColour backCol = new FastColour( 120, 85, 151 ), foreCol = new FastColour( 160, 133, 186 );
|
static FastColour scrollBackCol = new FastColour( 120, 85, 151 ), scrollCol = new FastColour( 200, 184, 216 );
|
||||||
static FastColour scrollCol = new FastColour( 200, 184, 216 );
|
|
||||||
public void Redraw( IDrawer2D drawer, Font font, Font titleFont, Font boldFont ) {
|
public void Redraw( IDrawer2D drawer, Font font, Font titleFont, Font boldFont ) {
|
||||||
for( int i = 0; i < ColumnWidths.Length; i++ ) {
|
for( int i = 0; i < ColumnWidths.Length; i++ ) {
|
||||||
ColumnWidths[i] = DesiredColumnWidths[i];
|
ColumnWidths[i] = DesiredColumnWidths[i];
|
||||||
@ -111,7 +110,6 @@ namespace Launcher2 {
|
|||||||
int bodyStartY = y;
|
int bodyStartY = y;
|
||||||
y += 3;
|
y += 3;
|
||||||
|
|
||||||
|
|
||||||
for( int i = CurrentIndex; i < Count; i++ ) {
|
for( int i = CurrentIndex; i < Count; i++ ) {
|
||||||
args = new DrawTextArgs( filter( usedEntries[i] ), font, true );
|
args = new DrawTextArgs( filter( usedEntries[i] ), font, true );
|
||||||
if( i == SelectedIndex && !separator )
|
if( i == SelectedIndex && !separator )
|
||||||
@ -122,9 +120,8 @@ namespace Launcher2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Height = Window.Height - Y;
|
|
||||||
if( separator )
|
if( separator )
|
||||||
drawer.Clear( foreCol, x - 7, Y, 2, Height );
|
drawer.Clear( LauncherSkin.BackgroundCol, x - 7, Y, 2, Height );
|
||||||
return maxWidth + 5;
|
return maxWidth + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,8 +131,8 @@ namespace Launcher2 {
|
|||||||
bool empty = args.Text == "";
|
bool empty = args.Text == "";
|
||||||
if( empty )
|
if( empty )
|
||||||
size.Height = defaultInputHeight;
|
size.Height = defaultInputHeight;
|
||||||
if( y + size.Height > Window.Height ) {
|
if( y + size.Height > Y + Height ) {
|
||||||
y = Window.Height + 3; return false;
|
y = Y + Height + 3; return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.Y = y; entry.Height = size.Height;
|
entry.Y = y; entry.Height = size.Height;
|
||||||
@ -160,18 +157,18 @@ namespace Launcher2 {
|
|||||||
void DrawGrid( IDrawer2D drawer, Font font, Font titleFont ) {
|
void DrawGrid( IDrawer2D drawer, Font font, Font titleFont ) {
|
||||||
DrawTextArgs args = new DrawTextArgs( "I", titleFont, true );
|
DrawTextArgs args = new DrawTextArgs( "I", titleFont, true );
|
||||||
Size size = drawer.MeasureSize( ref args );
|
Size size = drawer.MeasureSize( ref args );
|
||||||
drawer.Clear( foreCol, 0, Y + size.Height + 5, Window.Width, 2 );
|
drawer.Clear( LauncherSkin.BackgroundCol, 0, Y + size.Height + 5, Window.Width, 2 );
|
||||||
headerStartY = Y;
|
headerStartY = Y;
|
||||||
|
|
||||||
headerEndY = Y + size.Height + 5;
|
headerEndY = Y + size.Height + 5;
|
||||||
int startY = headerEndY + 3;
|
int startY = headerEndY + 3;
|
||||||
numEntries = (Window.Height - startY) / (defaultInputHeight + 3);
|
numEntries = (Y + Height - startY) / (defaultInputHeight + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxIndex;
|
int maxIndex;
|
||||||
void DrawScrollbar( IDrawer2D drawer ) {
|
void DrawScrollbar( IDrawer2D drawer ) {
|
||||||
drawer.Clear( backCol, Window.Width - 10, Y, 10, Window.Height - Y + 1 );
|
drawer.Clear( scrollBackCol, Window.Width - 10, Y, 10, Height );
|
||||||
float scale = (Window.Height - Y) / (float)Count;
|
float scale = Height / (float)Count;
|
||||||
|
|
||||||
int y1 = (int)(Y + CurrentIndex * scale);
|
int y1 = (int)(Y + CurrentIndex * scale);
|
||||||
int height = (int)((maxIndex - CurrentIndex) * scale);
|
int height = (int)((maxIndex - CurrentIndex) * scale);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user