mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
Enter in main screen should switch to classicube.net screen, option to auto close launcher, fix crashing when username or password is invalid.
This commit is contained in:
parent
75fce33012
commit
1a8ae3e8f8
@ -21,6 +21,7 @@ namespace ClassicalSharp {
|
|||||||
g.Players.ShowHoveredNames = v == "yes";
|
g.Players.ShowHoveredNames = v == "yes";
|
||||||
Options.Set( OptionsKey.ShowHoveredNames, v == "yes" );
|
Options.Set( OptionsKey.ShowHoveredNames, v == "yes" );
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Make( -140, -50, "Speed multiplier", Anchor.Centre, OnWidgetClick,
|
Make( -140, -50, "Speed multiplier", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.LocalPlayer.SpeedMultiplier.ToString(),
|
g => g.LocalPlayer.SpeedMultiplier.ToString(),
|
||||||
(g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse( v );
|
(g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse( v );
|
||||||
@ -37,12 +38,17 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
// Column 2
|
// Column 2
|
||||||
!network.IsSinglePlayer ? null :
|
!network.IsSinglePlayer ? null :
|
||||||
Make( 140, -50, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
|
Make( 140, -100, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
|
||||||
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
|
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
|
||||||
(g, v) => {
|
(g, v) => {
|
||||||
((SinglePlayerServer)network).physics.Enabled = v == "yes";
|
((SinglePlayerServer)network).physics.Enabled = v == "yes";
|
||||||
Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" );
|
Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" );
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
Make( 140, -50, "Auto close launcher", Anchor.Centre, OnWidgetClick,
|
||||||
|
g => Options.GetBool( OptionsKey.AutoCloseLauncher, false ) ? "yes" : "no",
|
||||||
|
(g, v) => Options.Set( OptionsKey.AutoCloseLauncher, v == "yes" ) ),
|
||||||
|
|
||||||
Make( 140, 0, "Pushback block placing", Anchor.Centre, OnWidgetClick,
|
Make( 140, 0, "Pushback block placing", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.LocalPlayer.PushbackBlockPlacing
|
g => g.LocalPlayer.PushbackBlockPlacing
|
||||||
&& g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",
|
&& g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",
|
||||||
@ -50,10 +56,12 @@ namespace ClassicalSharp {
|
|||||||
if( g.LocalPlayer.CanPushbackBlocks)
|
if( g.LocalPlayer.CanPushbackBlocks)
|
||||||
g.LocalPlayer.PushbackBlockPlacing = v == "yes";
|
g.LocalPlayer.PushbackBlockPlacing = v == "yes";
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Make( 140, 50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
|
Make( 140, 50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.MouseSensitivity.ToString(),
|
g => g.MouseSensitivity.ToString(),
|
||||||
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
||||||
Options.Set( OptionsKey.Sensitivity, v ); } ),
|
Options.Set( OptionsKey.Sensitivity, v ); } ),
|
||||||
|
|
||||||
Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
|
Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
|
||||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
|
(g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
|
||||||
null,
|
null,
|
||||||
|
@ -22,6 +22,7 @@ namespace ClassicalSharp {
|
|||||||
public const string MouseMiddle = "mousemiddle";
|
public const string MouseMiddle = "mousemiddle";
|
||||||
public const string MouseRight = "mouseright";
|
public const string MouseRight = "mouseright";
|
||||||
public const string VSync = "vsync";
|
public const string VSync = "vsync";
|
||||||
|
public const string AutoCloseLauncher = "autocloselauncher";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement this
|
// TODO: implement this
|
||||||
|
@ -146,7 +146,7 @@ namespace Launcher2 {
|
|||||||
if( String.IsNullOrEmpty( mppass ) ) mppass = "(none)";
|
if( String.IsNullOrEmpty( mppass ) ) mppass = "(none)";
|
||||||
ClientStartData data = new ClientStartData( Get( 3 ), mppass, ipPart, portPart );
|
ClientStartData data = new ClientStartData( Get( 3 ), mppass, ipPart, portPart );
|
||||||
bool ccSkins = ((LauncherBooleanWidget)widgets[10]).Value;
|
bool ccSkins = ((LauncherBooleanWidget)widgets[10]).Value;
|
||||||
Client.Start( data, ccSkins );
|
Client.Start( data, ccSkins, ref game.ShouldExit );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
|
@ -29,6 +29,8 @@ namespace Launcher2 {
|
|||||||
void KeyDown( object sender, KeyboardKeyEventArgs e ) {
|
void KeyDown( object sender, KeyboardKeyEventArgs e ) {
|
||||||
if( e.Key == Key.Tab )
|
if( e.Key == Key.Tab )
|
||||||
HandleTab();
|
HandleTab();
|
||||||
|
else if( e.Key == Key.Enter )
|
||||||
|
widgets[0].OnClick( 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyUp( object sender, KeyboardKeyEventArgs e ) {
|
void KeyUp( object sender, KeyboardKeyEventArgs e ) {
|
||||||
@ -69,7 +71,7 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
MakeButtonAt( "Singleplayer", Anchor.Centre, Anchor.Centre,
|
MakeButtonAt( "Singleplayer", Anchor.Centre, Anchor.Centre,
|
||||||
buttonWidth, buttonHeight, 0, 0,
|
buttonWidth, buttonHeight, 0, 0,
|
||||||
(x, y) => Client.Start( "" ) );
|
(x, y) => Client.Start( "", ref game.ShouldExit ) );
|
||||||
|
|
||||||
MakeButtonAt( "Check for updates", Anchor.Centre, Anchor.Centre,
|
MakeButtonAt( "Check for updates", Anchor.Centre, Anchor.Centre,
|
||||||
buttonWidth, buttonHeight, 0, 100,
|
buttonWidth, buttonHeight, 0, 100,
|
||||||
|
@ -40,6 +40,9 @@ namespace Launcher2 {
|
|||||||
/// <summary> Bitmap that contains the entire array of pixels that describe the client drawing area. </summary>
|
/// <summary> Bitmap that contains the entire array of pixels that describe the client drawing area. </summary>
|
||||||
public Bitmap Framebuffer;
|
public Bitmap Framebuffer;
|
||||||
|
|
||||||
|
/// <summary> Whether at the next tick, the launcher window should proceed to stop displaying frames and subsequently exit. </summary>
|
||||||
|
public bool ShouldExit;
|
||||||
|
|
||||||
/// <summary> Contains metadata attached for different screen instances,
|
/// <summary> Contains metadata attached for different screen instances,
|
||||||
/// typically used to save 'last text entered' text when a screen is disposed. </summary>
|
/// typically used to save 'last text entered' text when a screen is disposed. </summary>
|
||||||
public Dictionary<string, Dictionary<string, object>> ScreenMetadata =
|
public Dictionary<string, Dictionary<string, object>> ScreenMetadata =
|
||||||
@ -90,7 +93,7 @@ namespace Launcher2 {
|
|||||||
if( entry.Hash == hash ) {
|
if( entry.Hash == hash ) {
|
||||||
data = new ClientStartData( Session.Username, entry.Mppass,
|
data = new ClientStartData( Session.Username, entry.Mppass,
|
||||||
entry.IPAddress, entry.Port );
|
entry.IPAddress, entry.Port );
|
||||||
Client.Start( data, true );
|
Client.Start( data, true, ref ShouldExit );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,7 +105,7 @@ namespace Launcher2 {
|
|||||||
ErrorHandler.LogError( "retrieving server information", ex );
|
ErrorHandler.LogError( "retrieving server information", ex );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Client.Start( data, true );
|
Client.Start( data, true, ref ShouldExit );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,12 +127,18 @@ namespace Launcher2 {
|
|||||||
while( true ) {
|
while( true ) {
|
||||||
Window.ProcessEvents();
|
Window.ProcessEvents();
|
||||||
if( !Window.Exists ) break;
|
if( !Window.Exists ) break;
|
||||||
|
if( ShouldExit ) {
|
||||||
|
if( Screen != null )
|
||||||
|
Screen.Dispose();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Screen.Tick();
|
Screen.Tick();
|
||||||
if( Dirty || Screen.Dirty )
|
if( Dirty || Screen.Dirty )
|
||||||
Display();
|
Display();
|
||||||
Thread.Sleep( 1 );
|
Thread.Sleep( 1 );
|
||||||
}
|
}
|
||||||
|
Window.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display() {
|
void Display() {
|
||||||
|
@ -7,21 +7,26 @@ namespace Launcher2 {
|
|||||||
|
|
||||||
public static class Client {
|
public static class Client {
|
||||||
|
|
||||||
public static bool Start( ClientStartData data, bool classicubeSkins ) {
|
public static bool Start( ClientStartData data, bool classicubeSkins, ref bool shouldExit ) {
|
||||||
string skinServer = classicubeSkins ? "http://www.classicube.net/static/skins/" : "http://s3.amazonaws.com/MinecraftSkins/";
|
string skinServer = classicubeSkins ? "http://www.classicube.net/static/skins/" :
|
||||||
|
"http://s3.amazonaws.com/MinecraftSkins/";
|
||||||
string args = data.Username + " " + data.Mppass + " " +
|
string args = data.Username + " " + data.Mppass + " " +
|
||||||
data.Ip + " " + data.Port + " " + skinServer;
|
data.Ip + " " + data.Port + " " + skinServer;
|
||||||
|
return Start( args, ref shouldExit );
|
||||||
UpdateResumeInfo( data, classicubeSkins );
|
|
||||||
return Start( args );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Start( string args ) {
|
public static bool Start( string args, ref bool shouldExit ) {
|
||||||
|
return StartImpl( null, true, args, ref shouldExit );
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool StartImpl( ClientStartData data, bool classicubeSkins,
|
||||||
|
string args, ref bool shouldExit ) {
|
||||||
Process process = null;
|
Process process = null;
|
||||||
string path = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "ClassicalSharp.exe" );
|
string path = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "ClassicalSharp.exe" );
|
||||||
if( !File.Exists( path ) )
|
if( !File.Exists( path ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
CheckSettings( data, classicubeSkins, out shouldExit );
|
||||||
if( Type.GetType( "Mono.Runtime" ) != null ) {
|
if( Type.GetType( "Mono.Runtime" ) != null ) {
|
||||||
process = Process.Start( "mono", "\"" + path + "\" " + args );
|
process = Process.Start( "mono", "\"" + path + "\" " + args );
|
||||||
} else {
|
} else {
|
||||||
@ -30,16 +35,19 @@ namespace Launcher2 {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void UpdateResumeInfo( ClientStartData data, bool classiCubeSkins ) {
|
internal static void CheckSettings( ClientStartData data, bool classiCubeSkins, out bool shouldExit ) {
|
||||||
// If the client has changed some settings in the meantime, make sure we keep the changes
|
shouldExit = false;
|
||||||
|
// Make sure if the client has changed some settings in the meantime, we keep the changes
|
||||||
if( !Options.Load() )
|
if( !Options.Load() )
|
||||||
return;
|
return;
|
||||||
|
shouldExit = Options.GetBool( OptionsKey.AutoCloseLauncher, false );
|
||||||
|
if( data == null ) return;
|
||||||
|
|
||||||
Options.Set( "launcher-username", data.Username );
|
Options.Set( "launcher-username", data.Username );
|
||||||
Options.Set( "launcher-ip", data.Ip );
|
Options.Set( "launcher-ip", data.Ip );
|
||||||
Options.Set( "launcher-port", data.Port );
|
Options.Set( "launcher-port", data.Port );
|
||||||
Options.Set( "launcher-mppass", Secure.Encode( data.Mppass, data.Username ) );
|
Options.Set( "launcher-mppass", Secure.Encode( data.Mppass, data.Username ) );
|
||||||
Options.Set( "launcher-ccskins", classiCubeSkins );
|
Options.Set( "launcher-ccskins", classiCubeSkins );
|
||||||
Options.Save();
|
Options.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace Launcher2 {
|
|||||||
data = (Dictionary<string, object>)Json.ParseValue( response, ref index, ref success );
|
data = (Dictionary<string, object>)Json.ParseValue( response, ref index, ref success );
|
||||||
|
|
||||||
List<object> errors = (List<object>)data["errors"];
|
List<object> errors = (List<object>)data["errors"];
|
||||||
if( errors.Count > 0 )
|
if( errors.Count > 0 || (data.ContainsKey( "username" ) && data["username"] == null) )
|
||||||
throw new InvalidOperationException( "Wrong username or password." );
|
throw new InvalidOperationException( "Wrong username or password." );
|
||||||
|
|
||||||
Username = (string)data["username"];
|
Username = (string)data["username"];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user