mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Combine ClassicubeScreen and MainScreen into one screen.
This commit is contained in:
parent
5fc02e4536
commit
30f9e7aee9
@ -90,6 +90,7 @@ namespace ClassicalSharp.Renderers {
|
||||
}
|
||||
|
||||
void RenderClouds( double delta ) {
|
||||
if( game.Map.CloudHeight < -2000 ) return;
|
||||
double time = game.accumulator;
|
||||
float offset = (float)( time / 2048f * 0.6f * map.CloudsSpeed );
|
||||
graphics.SetMatrixMode( MatrixType.Texture );
|
||||
|
@ -119,7 +119,7 @@ namespace Launcher2 {
|
||||
((LauncherInputWidget)widgets[3]).ClipboardFilter = HashFilter;
|
||||
|
||||
MakeButtonAt( "Back", 70, 30, titleFont, Anchor.BottomOrRight, Anchor.LeftOrTop,
|
||||
-10, 5, (x, y) => game.SetScreen( new ClassiCubeScreen( game ) ) );
|
||||
-10, 5, (x, y) => game.SetScreen( new MainScreen( game ) ) );
|
||||
MakeButtonAt( "Connect", 100, 30, titleFont, Anchor.BottomOrRight, Anchor.LeftOrTop,
|
||||
-10, 50, ConnectToServer );
|
||||
MakeTableWidget();
|
||||
|
@ -7,14 +7,7 @@ using ClassicalSharp;
|
||||
|
||||
namespace Launcher2 {
|
||||
|
||||
public sealed class ClassiCubeScreen : LauncherInputScreen {
|
||||
|
||||
public ClassiCubeScreen( LauncherWindow game ) : base( game ) {
|
||||
titleFont = new Font( "Arial", 15, FontStyle.Bold );
|
||||
inputFont = new Font( "Arial", 15, FontStyle.Regular );
|
||||
enterIndex = 4;
|
||||
widgets = new LauncherWidget[7];
|
||||
}
|
||||
public sealed partial class MainScreen : LauncherInputScreen {
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
@ -78,29 +71,18 @@ namespace Launcher2 {
|
||||
Options.Set( "launcher-cc-password", Secure.Encode( password, user ) );
|
||||
Options.Save();
|
||||
}
|
||||
|
||||
public override void Resize() {
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
Draw();
|
||||
}
|
||||
Dirty = true;
|
||||
}
|
||||
|
||||
void Draw() {
|
||||
widgetIndex = 0;
|
||||
MakeLabelAt( "Username", titleFont, Anchor.Centre, Anchor.Centre, -180, -100 );
|
||||
MakeLabelAt( "Password", titleFont, Anchor.Centre, Anchor.Centre, -180, -50 );
|
||||
void DrawClassicube() {
|
||||
MakeLabelAt( "Username", titleFont, Anchor.Centre, Anchor.Centre, -180, -150 );
|
||||
MakeLabelAt( "Password", titleFont, Anchor.Centre, Anchor.Centre, -180, -100 );
|
||||
|
||||
MakeInput( Get(), 300, Anchor.Centre, false, 30, -100, 32 );
|
||||
MakeInput( Get(), 300, Anchor.Centre, true, 30, -50, 32 );
|
||||
MakeInput( Get(), 280, Anchor.Centre, false, 30, -150, 32 );
|
||||
MakeInput( Get(), 280, Anchor.Centre, true, 30, -100, 32 );
|
||||
|
||||
MakeButtonAt( "Sign in", 90, 35, titleFont, Anchor.Centre,
|
||||
-75, 0, StartClient );
|
||||
MakeButtonAt( "Back", 80, 35, titleFont, Anchor.Centre,
|
||||
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 );
|
||||
MakeButtonAt( "Sign in", buttonWidth / 2, buttonHeight, buttonFont,
|
||||
Anchor.Centre, Anchor.Centre, 0, -50, LoginAsync );
|
||||
string text = widgets[5] == null ? "" : widgets[5].Text;
|
||||
MakeLabelAt( text, inputFont, Anchor.Centre, Anchor.Centre, 0, 0 );
|
||||
}
|
||||
|
||||
string lastStatus;
|
||||
@ -108,10 +90,10 @@ namespace Launcher2 {
|
||||
lastStatus = text;
|
||||
using( drawer ) {
|
||||
drawer.SetBitmap( game.Framebuffer );
|
||||
LauncherLabelWidget widget = (LauncherLabelWidget)widgets[6];
|
||||
LauncherLabelWidget widget = (LauncherLabelWidget)widgets[5];
|
||||
|
||||
game.ClearArea( widget.X, widget.Y, widget.Width, widget.Height );
|
||||
widget.DrawAt( drawer, text, inputFont, Anchor.Centre, Anchor.Centre, 0, 50 );
|
||||
widget.DrawAt( drawer, text, inputFont, Anchor.Centre, Anchor.Centre, 0, 0 );
|
||||
Dirty = true;
|
||||
}
|
||||
}
|
||||
@ -123,7 +105,7 @@ namespace Launcher2 {
|
||||
}
|
||||
|
||||
bool signingIn;
|
||||
void StartClient( int mouseX, int mouseY ) {
|
||||
void LoginAsync( int mouseX, int mouseY ) {
|
||||
if( String.IsNullOrEmpty( Get( 2 ) ) ) {
|
||||
SetStatus( "&ePlease enter a username" ); return;
|
||||
}
|
||||
@ -165,18 +147,12 @@ namespace Launcher2 {
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
StoreFields();
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
void StoreFields() {
|
||||
Dictionary<string, object> metadata;
|
||||
if( !game.ScreenMetadata.TryGetValue( "screen-CC", out metadata ) ) {
|
||||
metadata = new Dictionary<string, object>();
|
||||
game.ScreenMetadata["screen-CC"] = metadata;
|
||||
}
|
||||
|
||||
}
|
||||
metadata["user"] = Get( 2 );
|
||||
metadata["pass"] = Get( 3 );
|
||||
}
|
@ -5,40 +5,14 @@ using OpenTK.Input;
|
||||
|
||||
namespace Launcher2 {
|
||||
|
||||
public sealed class MainScreen : LauncherScreen {
|
||||
public sealed partial class MainScreen : LauncherInputScreen {
|
||||
|
||||
public MainScreen( LauncherWindow game ) : base( game ) {
|
||||
textFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
widgets = new LauncherWidget[4];
|
||||
buttonFont = textFont;
|
||||
}
|
||||
|
||||
void KeyDown( object sender, KeyboardKeyEventArgs e ) {
|
||||
if( e.Key == Key.Tab ) {
|
||||
HandleTab();
|
||||
} else if( e.Key == Key.Enter ) {
|
||||
LauncherWidget widget = selectedWidget != null ?
|
||||
selectedWidget : widgets[0];
|
||||
if( widget.OnClick != null )
|
||||
widget.OnClick( 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void KeyUp( object sender, KeyboardKeyEventArgs e ) {
|
||||
if( e.Key == Key.Tab )
|
||||
tabDown = false;
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
game.Window.Keyboard.KeyDown += KeyDown;
|
||||
game.Window.Keyboard.KeyUp += KeyUp;
|
||||
|
||||
game.Window.Mouse.Move += MouseMove;
|
||||
game.Window.Mouse.ButtonDown += MouseButtonDown;
|
||||
Resize();
|
||||
}
|
||||
|
||||
public override void Tick() {
|
||||
titleFont = new Font( "Arial", 15, FontStyle.Bold );
|
||||
buttonFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
inputFont = new Font( "Arial", 15, FontStyle.Regular );
|
||||
enterIndex = 4;
|
||||
widgets = new LauncherWidget[10];
|
||||
}
|
||||
|
||||
public override void Resize() {
|
||||
@ -49,45 +23,28 @@ namespace Launcher2 {
|
||||
Dirty = true;
|
||||
}
|
||||
|
||||
Font textFont;
|
||||
void Draw() {
|
||||
widgetIndex = 0;
|
||||
MakeButtonAt( "ClassiCube.net", Anchor.Centre, Anchor.Centre,
|
||||
buttonWidth, buttonHeight, 0, -100,
|
||||
(x, y) => game.SetScreen( new ClassiCubeScreen( game ) ) );
|
||||
DrawClassicube();
|
||||
|
||||
MakeButtonAt( "Direct connect", Anchor.Centre, Anchor.Centre,
|
||||
buttonWidth, buttonHeight, 0, -50,
|
||||
MakeButtonAt( "Direct connect", buttonWidth, buttonHeight, buttonFont,
|
||||
Anchor.Centre, Anchor.Centre, 0, 50,
|
||||
(x, y) => game.SetScreen( new DirectConnectScreen( game ) ) );
|
||||
|
||||
MakeButtonAt( "Singleplayer", Anchor.Centre, Anchor.Centre,
|
||||
buttonWidth, buttonHeight, 0, 0,
|
||||
MakeButtonAt( "Singleplayer", buttonWidth, buttonHeight, buttonFont,
|
||||
Anchor.Centre, Anchor.Centre, 0, 100,
|
||||
(x, y) => Client.Start( "", ref game.ShouldExit ) );
|
||||
|
||||
MakeButtonAt( "Check for updates", Anchor.Centre, Anchor.Centre,
|
||||
buttonWidth, buttonHeight, 0, 100,
|
||||
MakeButtonAt( "Update check", buttonWidth - 40, buttonHeight, buttonFont,
|
||||
Anchor.BottomOrRight, Anchor.BottomOrRight, -10, -10,
|
||||
(x, y) => game.SetScreen( new UpdatesScreen( game ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
const int buttonWidth = 220, buttonHeight = 35, sideButtonWidth = 150;
|
||||
void MakeButtonAt( string text, Anchor horAnchor,
|
||||
Anchor verAnchor, int width, int height, int x, int y, Action<int, int> onClick ) {
|
||||
LauncherButtonWidget widget = new LauncherButtonWidget( game );
|
||||
widget.Text = text;
|
||||
widget.OnClick = onClick;
|
||||
|
||||
widget.Active = false;
|
||||
widget.DrawAt( drawer, text, textFont, horAnchor, verAnchor, width, height, x, y );
|
||||
widgets[widgetIndex++] = widget;
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
game.Window.Mouse.Move -= MouseMove;
|
||||
game.Window.Mouse.ButtonDown -= MouseButtonDown;
|
||||
|
||||
game.Window.Keyboard.KeyDown -= KeyDown;
|
||||
game.Window.Keyboard.KeyUp -= KeyUp;
|
||||
textFont.Dispose();
|
||||
buttonFont.Dispose();
|
||||
StoreFields();
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,11 +57,11 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Gui\PlatformDrawer.cs" />
|
||||
<Compile Include="Gui\Screens\ClassiCubeScreen.cs" />
|
||||
<Compile Include="Gui\Screens\ClassiCubeServersScreen.cs" />
|
||||
<Compile Include="Gui\Screens\DirectConnectScreen.cs" />
|
||||
<Compile Include="Gui\Screens\LauncherInputScreen.cs" />
|
||||
<Compile Include="Gui\Screens\LauncherScreen.cs" />
|
||||
<Compile Include="Gui\Screens\MainScreen.Classicube.cs" />
|
||||
<Compile Include="Gui\Screens\MainScreen.cs" />
|
||||
<Compile Include="Gui\Screens\ResourcesScreen.cs" />
|
||||
<Compile Include="Gui\Screens\UpdatesScreen.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user