Make some gui touchups to launcher, default to 640x480.

This commit is contained in:
UnknownShadow200 2015-12-09 15:41:28 +11:00
parent ac42cf3bc8
commit 55db094c0b
8 changed files with 44 additions and 40 deletions

View File

@ -22,6 +22,7 @@ namespace ClassicalSharp {
Socket socket;
Game game;
bool receivedFirstPosition;
DateTime lastPacket;
public override void Connect( IPAddress address, int port ) {
socket = new Socket( address.AddressFamily, SocketType.Stream, ProtocolType.Tcp );
@ -41,9 +42,9 @@ namespace ClassicalSharp {
gzippedMap = new FixedBufferStream( reader.buffer );
MakeLoginPacket( game.Username, game.Mppass );
SendPacket();
lastPacket = DateTime.UtcNow;
}
public override void Dispose() {
socket.Close();
Disconnected = true;

View File

@ -13,7 +13,7 @@ namespace Launcher2 {
titleFont = new Font( "Arial", 15, FontStyle.Bold );
inputFont = new Font( "Arial", 15, FontStyle.Regular );
enterIndex = 4;
widgets = new LauncherWidget[8];
widgets = new LauncherWidget[7];
}
public override void Init() {
@ -101,10 +101,6 @@ namespace Launcher2 {
140, 0, (x, y) => game.SetScreen( new MainScreen( game ) ) );
string text = widgets[6] == null ? "" : widgets[6].Text;
MakeLabelAt( text, inputFont, Anchor.Centre, Anchor.Centre, 0, 50 );
if( HasServers && !signingIn )
MakeButtonAt( "Servers", 90, 35, titleFont, Anchor.Centre,
35, 0, ShowServers );
}
string lastStatus;
@ -143,11 +139,6 @@ namespace Launcher2 {
SetStatus( "&eSigning in.." );
signingIn = true;
}
void ShowServers( int mouseX, int mouseY ) {
if( signingIn || !HasServers ) return;
game.SetScreen( new ClassiCubeServersScreen( game ) );
}
void DisplayWebException( WebException ex, string action ) {
ErrorHandler.LogError( action, ex );

View File

@ -97,17 +97,17 @@ namespace Launcher2 {
void Draw() {
widgetIndex = 0;
MakeLabelAt( "Search", titleFont, Anchor.Centre, Anchor.LeftOrTop, -190, 10 );
MakeInput( Get(), 270, Anchor.LeftOrTop, false, -5, 5, 32 );
MakeLabelAt( "Search servers:", inputFont, Anchor.LeftOrTop, Anchor.LeftOrTop, 5, 10 );
MakeInput( Get(), 330, Anchor.LeftOrTop, Anchor.LeftOrTop, false, 135, 5, 32 );
MakeLabelAt( "/play/", inputFont, Anchor.Centre, Anchor.LeftOrTop, -215, 55 );
MakeInput( Get(), 310, Anchor.LeftOrTop, false, -35, 50, 32 );
MakeLabelAt( "../server/play/", inputFont, Anchor.LeftOrTop, Anchor.LeftOrTop, 5, 55 );
MakeInput( Get(), 330, Anchor.LeftOrTop, Anchor.LeftOrTop, false, 135, 50, 32 );
((LauncherInputWidget)widgets[3]).ClipboardFilter = HashFilter;
MakeButtonAt( "Back", 70, 30, titleFont, Anchor.LeftOrTop,
195, 5, (x, y) => game.SetScreen( new ClassiCubeScreen( game ) ) );
MakeButtonAt( "Connect", 100, 30, titleFont, Anchor.LeftOrTop,
180, 50, ConnectToServer );
MakeButtonAt( "Back", 70, 30, titleFont, Anchor.BottomOrRight, Anchor.LeftOrTop,
-10, 5, (x, y) => game.SetScreen( new ClassiCubeScreen( game ) ) );
MakeButtonAt( "Connect", 100, 30, titleFont, Anchor.BottomOrRight, Anchor.LeftOrTop,
-10, 50, ConnectToServer );
MakeTableWidget();
}

View File

@ -128,6 +128,24 @@ namespace Launcher2 {
widgets[widgetIndex++] = widget;
}
protected void MakeInput( string text, int width, Anchor horAnchor, Anchor verAnchor,
bool password, int x, int y, int maxChars ) {
if( widgets[widgetIndex] != null ) {
LauncherInputWidget input = (LauncherInputWidget)widgets[widgetIndex];
input.DrawAt( drawer, text, inputFont, horAnchor, verAnchor, width, 30, x, y );
widgetIndex++;
return;
}
LauncherInputWidget widget = new LauncherInputWidget( game );
widget.OnClick = InputClick;
widget.Password = password;
widget.MaxTextLength = maxChars;
widget.DrawAt( drawer, text, inputFont, horAnchor, verAnchor, width, 30, x, y );
widgets[widgetIndex++] = widget;
}
public override void Dispose() {
game.Window.Mouse.Move -= MouseMove;
game.Window.Mouse.ButtonDown -= MouseButtonDown;

View File

@ -124,10 +124,15 @@ namespace Launcher2 {
protected void MakeButtonAt( string text, int width, int height, Font font,
Anchor verAnchor, int x, int y, Action<int, int> onClick ) {
MakeButtonAt( text, width, height, font, Anchor.Centre, verAnchor, x, y, onClick );
}
protected void MakeButtonAt( string text, int width, int height, Font font, Anchor horAnchor,
Anchor verAnchor, int x, int y, Action<int, int> onClick ) {
if( widgets[widgetIndex] != null ) {
LauncherButtonWidget input = (LauncherButtonWidget)widgets[widgetIndex];
input.Active = false;
input.DrawAt( drawer, text, font, Anchor.Centre, verAnchor, width, height, x, y );
LauncherButtonWidget button = (LauncherButtonWidget)widgets[widgetIndex];
button.Active = false;
button.DrawAt( drawer, text, font, horAnchor, verAnchor, width, height, x, y );
widgetIndex++;
return;
}
@ -137,7 +142,7 @@ namespace Launcher2 {
widget.OnClick = onClick;
widget.Active = false;
widget.DrawAt( drawer, text, font, Anchor.Centre, verAnchor, width, height, x, y );
widget.DrawAt( drawer, text, font, horAnchor, verAnchor, width, height, x, y );
widgets[widgetIndex++] = widget;
}

View File

@ -85,6 +85,7 @@ namespace Launcher2 {
int currentIndex = (int)(mouseY / scale);
CurrentIndex = currentIndex;
ClampIndex();
NeedRedraw();
}
}

View File

@ -53,8 +53,8 @@ namespace Launcher2 {
}
public int CurrentIndex, Count;
public int[] ColumnWidths = { 280, 80, 80 };
public int[] DesiredColumnWidths = { 280, 80, 80 };
public int[] ColumnWidths = { 360, 80, 80 };
public int[] DesiredColumnWidths = { 360, 80, 80 };
internal struct TableEntry {
public string Hash, Name, Players, Uptime;
@ -107,7 +107,7 @@ namespace Launcher2 {
Height = Window.Height - Y;
if( separator )
drawer.DrawRect( foreCol, x + maxWidth + 2, Y + 2, 3, Height );
drawer.DrawRect( foreCol, x + maxWidth + 2, Y + 2, 2, Height );
return maxWidth + 5;
}
@ -135,24 +135,12 @@ namespace Launcher2 {
drawer.DrawRect( foreCol, 0, Y + size.Height + 10, Window.Width, 3 );
headerStartY = Y;
headerEndY = Y + size.Height + 10;
args = new DrawTextArgs( "I", font, true );
int y = Y + size.Height + 10;
size = drawer.MeasureSize( ref args );
numEntries = 0;
for( ; ; ) {
if( y + size.Height > Window.Height ) break;
numEntries++;
drawer.DrawRect( foreCol, 0, y, Window.Width, 1 );
y += size.Height + 5;
}
}
int maxIndex;
void DrawScrollbar( IDrawer2D drawer ) {
drawer.DrawRect( backCol, Window.Width - 10, Y, 10, Window.Height - Y );
float scale = (Window.Height - 10 - Y) / (float)Count;
float scale = (Window.Height - Y) / (float)Count;
int y1 = (int)(Y + CurrentIndex * scale);
int height = (int)((maxIndex - CurrentIndex) * scale);

View File

@ -117,7 +117,7 @@ namespace Launcher2 {
}
public void Run() {
Window = new NativeWindow( 480, 480, Program.AppName, 0,
Window = new NativeWindow( 640, 480, Program.AppName, 0,
GraphicsMode.Default, DisplayDevice.Default );
Window.Visible = true;
Drawer = new GdiPlusDrawer2D( null );