diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs index 437e35b1b..d61ffc1ac 100644 --- a/ClassicalSharp/2D/Screens/ChatScreen.cs +++ b/ClassicalSharp/2D/Screens/ChatScreen.cs @@ -160,11 +160,14 @@ namespace ClassicalSharp { suppressNextPress = false; if( HandlesAllInput ) { // text input bar - if( key == game.Keys[KeyMapping.SendChat] ) { + if( key == game.Keys[KeyMapping.SendChat] || key == game.Keys[KeyMapping.PauseOrExit] ) { HandlesAllInput = false; if( game.CursorVisible ) game.CursorVisible = false; game.Camera.RegrabMouse(); + + if( key == game.Keys[KeyMapping.PauseOrExit] ) + textInput.chatInputText.Clear(); textInput.SendTextInBufferAndReset(); } else if( key == Key.PageUp ) { chatIndex -= chatLines; @@ -177,6 +180,8 @@ namespace ClassicalSharp { if( chatIndex > game.ChatLog.Count - chatLines ) chatIndex = game.ChatLog.Count - chatLines; ResetChat(); + } else if( key == game.Keys[KeyMapping.HideGui] ) { + game.HideGui = !game.HideGui; } else { textInput.HandlesKeyDown( key ); } @@ -197,7 +202,7 @@ namespace ClassicalSharp { if( !HandlesAllInput ) return false; chatIndex += -delta; int maxIndex = game.ChatLog.Count - chatLines; - int minIndex = Math.Min( 0, maxIndex ); + int minIndex = Math.Min( 0, maxIndex ); Utils.Clamp( ref chatIndex, minIndex, maxIndex ); ResetChat(); return true; diff --git a/ClassicalSharp/2D/Screens/PauseScreen.cs b/ClassicalSharp/2D/Screens/PauseScreen.cs index 6d7a8f996..e624007ac 100644 --- a/ClassicalSharp/2D/Screens/PauseScreen.cs +++ b/ClassicalSharp/2D/Screens/PauseScreen.cs @@ -175,7 +175,7 @@ namespace ClassicalSharp { void SetWidgetToChange( KeyMapWidget widget ) { Key oldKey = game.Keys[widget.Mapping]; - if( !game.Keys.IsLockedKey( oldKey ) ) { + if( oldKey != Key.Escape ) { const string format = "&ePress new key for \"{0}\"."; keyStatusWidget.SetText( String.Format( format, widget.Description ) ); widgetToChange = widget; diff --git a/ClassicalSharp/Game/Game.InputHandling.cs b/ClassicalSharp/Game/Game.InputHandling.cs index 8e03122d0..595b02df0 100644 --- a/ClassicalSharp/Game/Game.InputHandling.cs +++ b/ClassicalSharp/Game/Game.InputHandling.cs @@ -90,7 +90,15 @@ namespace ClassicalSharp { Key key = e.Key; if( key == Key.F4 && ( IsKeyDown( Key.AltLeft ) || IsKeyDown( Key.AltRight ) ) ) { Exit(); - } else if( key == Keys[KeyMapping.HideGui] ) { + } else if( activeScreen == null || !activeScreen.HandlesKeyDown( key ) ) { + if( !HandleBuiltinKey( key ) ) { + LocalPlayer.HandleKeyDown( key ); + } + } + } + + bool HandleBuiltinKey( Key key ) { + if( key == Keys[KeyMapping.HideGui] ) { HideGui = !HideGui; } else if( key == Keys[KeyMapping.Screenshot] ) { screenshotRequested = true; @@ -110,7 +118,7 @@ namespace ClassicalSharp { int newDist = viewDistances[i]; if( newDist > ViewDistance ) { SetViewDistance( newDist ); - return; + return true; } } SetViewDistance( viewDistances[0] ); @@ -120,13 +128,12 @@ namespace ClassicalSharp { } else { SetNewScreen( new NormalScreen( this ) ); } - } else if( activeScreen == null || !activeScreen.HandlesKeyDown( key ) ) { - if( key == Keys[KeyMapping.OpenInventory] ) { - SetNewScreen( new BlockSelectScreen( this ) ); - } else { - LocalPlayer.HandleKeyDown( key ); - } + } else if( key == Keys[KeyMapping.OpenInventory] ) { + SetNewScreen( new BlockSelectScreen( this ) ); + } else { + return false; } + return true; } DateTime lastClick = DateTime.MinValue; @@ -205,16 +212,12 @@ namespace ClassicalSharp { Key[] Keys; bool IsReservedKey( Key key ) { - return IsLockedKey( key ) || key == Key.Slash || key == Key.BackSpace || + return key == Key.Escape || key == Key.Slash || key == Key.BackSpace || ( key >= Key.Insert && key <= Key.End ) || ( key >= Key.Up && key <= Key.Right ) || // chat screen movement ( key >= Key.Number0 && key <= Key.Number9 ); // block hotbar } - public bool IsLockedKey( Key key ) { - return key == Key.Escape || ( key >= Key.F1 && key <= Key.F35 ); - } - public bool IsKeyOkay( Key key, out string reason ) { if( IsReservedKey( key ) ) { reason = "Given key is reserved for gui"; @@ -236,7 +239,7 @@ namespace ClassicalSharp { Keys = new Key[] { Key.W, Key.S, Key.A, Key.D, Key.Space, Key.R, Key.Y, Key.T, Key.Enter, Key.Escape, Key.B, Key.F12, Key.F11, Key.F7, - Key.F5, Key.F6, Key.Z, Key.ShiftLeft, Key.X, Key.Q, + Key.F5, Key.F, Key.Z, Key.ShiftLeft, Key.X, Key.Q, Key.E, Key.Tab, Key.F1 }; #else Keys = new Key[23]; @@ -244,7 +247,7 @@ namespace ClassicalSharp { Keys[4] = Key.Space; Keys[5] = Key.R; Keys[6] = Key.Y; Keys[7] = Key.T; Keys[8] = Key.Enter; Keys[9] = Key.Escape; Keys[10] = Key.B; Keys[11] = Key.F12; Keys[12] = Key.F11; Keys[13] = Key.F7; - Keys[14] = Key.F5; Keys[15] = Key.F6; Keys[16] = Key.Z; + Keys[14] = Key.F5; Keys[15] = Key.F; Keys[16] = Key.Z; Keys[17] = Key.ShiftLeft; Keys[18] = Key.X; Keys[19] = Key.Q; Keys[20] = Key.E; Keys[21] = Key.Tab; Keys[22] = Key.F1; #endif diff --git a/ClassicalSharp/GraphicsAPI/IGraphicsApi.cs b/ClassicalSharp/GraphicsAPI/IGraphicsApi.cs index 263311b8f..44e3c1498 100644 --- a/ClassicalSharp/GraphicsAPI/IGraphicsApi.cs +++ b/ClassicalSharp/GraphicsAPI/IGraphicsApi.cs @@ -17,15 +17,6 @@ namespace ClassicalSharp.GraphicsAPI { public abstract bool Texturing { set; } - public int CreateTexture( string path ) { - if( !File.Exists( path ) ) { - throw new FileNotFoundException( path + " not found" ); - } - using( Bitmap bmp = new Bitmap( path ) ) { - return CreateTexture( bmp ); - } - } - public int CreateTexture( Bitmap bmp ) { Rectangle rec = new Rectangle( 0, 0, bmp.Width, bmp.Height ); BitmapData data = bmp.LockBits( rec, ImageLockMode.ReadOnly, bmp.PixelFormat ); diff --git a/ClassicalSharp/Network/NetworkProcessor.cs b/ClassicalSharp/Network/NetworkProcessor.cs index 4409a65f9..f2619dc08 100644 --- a/ClassicalSharp/Network/NetworkProcessor.cs +++ b/ClassicalSharp/Network/NetworkProcessor.cs @@ -9,6 +9,7 @@ using System.IO.Compression; using System.Net; using System.Net.Sockets; using ClassicalSharp.Network; +using ClassicalSharp.TexturePack; using OpenTK; using OpenTK.Input; @@ -602,8 +603,8 @@ namespace ClassicalSharp { game.Map.SetEdgeBlock( (Block)edgeBlock ); game.Map.SetSidesBlock( (Block)sideBlock ); if( url == String.Empty ) { - Bitmap bmp = new Bitmap( "terrain.png" ); - game.ChangeTerrainAtlas( bmp ); + TexturePackExtractor extractor = new TexturePackExtractor(); + extractor.Extract( game.defaultTexPack, game ); } else { game.AsyncDownloader.DownloadImage( url, true, "terrain" ); }