From b1bcfab88773d774ab3f1e4dea763cd72e5b98ec Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 29 Dec 2015 11:37:43 +1100 Subject: [PATCH] Fixed player model being difficult to squeeze through 8 pixel gaps (Thanks Empy), fix first keyboard press not showing up in input bar (Thanks imjonnyboy) --- ClassicalSharp/Model/PlayerModel.cs | 2 +- Launcher2/Gui/Widgets/LauncherInputWidget.cs | 5 +++++ Launcher2/Utils/LauncherSkin.cs | 4 ++-- OpenTK/Platform/MacOS/CarbonGLNative.cs | 13 ++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ClassicalSharp/Model/PlayerModel.cs b/ClassicalSharp/Model/PlayerModel.cs index 35085b647..dc28c441c 100644 --- a/ClassicalSharp/Model/PlayerModel.cs +++ b/ClassicalSharp/Model/PlayerModel.cs @@ -53,7 +53,7 @@ namespace ClassicalSharp.Model { } public override Vector3 CollisionSize { - get { return new Vector3( 8/16f - 0.005f, 28.5f/16f - 0.005f, 8/16f - 0.005f ); } + get { return new Vector3( 8/16f - 0.4f/16f, 28.5f/16f - 0.4f/16f, 8/16f - 0.4f/16f ); } } public override BoundingBox PickingBounds { diff --git a/Launcher2/Gui/Widgets/LauncherInputWidget.cs b/Launcher2/Gui/Widgets/LauncherInputWidget.cs index 59a58d556..dcf4c1ddb 100644 --- a/Launcher2/Gui/Widgets/LauncherInputWidget.cs +++ b/Launcher2/Gui/Widgets/LauncherInputWidget.cs @@ -25,6 +25,9 @@ namespace Launcher2 { /// Delegate invoked when the text changes. public Action TextChanged; + /// Delegate that only lets certain characters be entered. + public Func TextFilter; + public LauncherInputWidget( LauncherWindow window ) : base( window ) { } @@ -56,6 +59,8 @@ namespace Launcher2 { /// Appends a character to the end of the currently entered text. /// true if a redraw is necessary, false otherwise. public bool AppendChar( char c ) { + if( TextFilter != null && !TextFilter( c ) ) + return false; if( c >= ' ' && c <= '~' && Text.Length < MaxTextLength ) { Text += c; if( TextChanged != null ) TextChanged( this ); diff --git a/Launcher2/Utils/LauncherSkin.cs b/Launcher2/Utils/LauncherSkin.cs index f8b06a0a1..d8d3c87c6 100644 --- a/Launcher2/Utils/LauncherSkin.cs +++ b/Launcher2/Utils/LauncherSkin.cs @@ -6,14 +6,14 @@ namespace Launcher2 { public static class LauncherSkin { - public static FastColour BackgroundCol = new FastColour( 151, 122, 172 ); + public static FastColour BackgroundCol = new FastColour( 153, 127, 172 ); public static FastColour ButtonBorderCol = new FastColour( 97, 81, 110 ); public static FastColour ButtonForeActiveCol = new FastColour( 189, 168, 206 ); public static FastColour ButtonForeCol = new FastColour( 164, 138, 186 ); public static FastColour ButtonHighlightCol = new FastColour( 182, 158, 201 ); public static void ResetToDefault() { - BackgroundCol = new FastColour( 151, 122, 172 ); + BackgroundCol = new FastColour( 153, 127, 172 ); ButtonBorderCol = new FastColour( 97, 81, 110 ); ButtonForeActiveCol = new FastColour( 189, 168, 206 ); ButtonForeCol = new FastColour( 164, 138, 186 ); diff --git a/OpenTK/Platform/MacOS/CarbonGLNative.cs b/OpenTK/Platform/MacOS/CarbonGLNative.cs index 1f92e5fe3..dc7df7fef 100644 --- a/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -254,7 +254,7 @@ namespace OpenTK.Platform.MacOS MacOSKeyCode code = (MacOSKeyCode)0; char charCode = '\0'; - //Debug.Print("Processing keyboard event {0}", evt.KeyboardEventKind); + //Debug.Print("Processing Keyboard event {0}", (KeyboardEventKind)evt.EventKind); switch ((KeyboardEventKind)evt.EventKind) { @@ -277,9 +277,9 @@ namespace OpenTK.Platform.MacOS keyboard.KeyRepeat = true; goto case KeyboardEventKind.RawKeyDown; - case KeyboardEventKind.RawKeyDown: - OnKeyPress(mKeyPressArgs); + case KeyboardEventKind.RawKeyDown: keyboard[Keymap[code]] = true; + OnKeyPress(mKeyPressArgs); return OSStatus.NoError; case KeyboardEventKind.RawKeyUp: @@ -564,19 +564,14 @@ namespace OpenTK.Platform.MacOS public Point PointToClient(Point point) { IntPtr handle = window.WindowRef; - Rect r = Carbon.API.GetWindowBounds(window.WindowRef, WindowRegionCode.ContentRegion); - Debug.Print("Rect: {0}", r); - return new Point(point.X - r.X, point.Y - r.Y); } + public Point PointToScreen(Point point) { IntPtr handle = window.WindowRef; - Rect r = Carbon.API.GetWindowBounds(window.WindowRef, WindowRegionCode.ContentRegion); - Debug.Print("Rect: {0}", r); - return new Point(point.X + r.X, point.Y + r.Y); }