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