From 5e9f401449329c3ba526eefa1e41a3db680d5bc5 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 16 Apr 2016 12:26:41 +1000 Subject: [PATCH] Revert last commit, makes no sense to reimplement Clipboard handling. --- ClassicalSharp/Entities/LocalPlayer.cs | 8 ++- Launcher2/Updater/Patcher.cs | 10 +-- OpenTK/Platform/Windows/API.cs | 31 --------- OpenTK/Platform/Windows/WinGLNative.cs | 95 +------------------------- 4 files changed, 13 insertions(+), 131 deletions(-) diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs index 8a41f60e2..a1224111c 100644 --- a/ClassicalSharp/Entities/LocalPlayer.cs +++ b/ClassicalSharp/Entities/LocalPlayer.cs @@ -29,6 +29,7 @@ namespace ClassicalSharp.Entities { public HacksComponent Hacks; internal PhysicsComponent physics; internal InputComponent input; + Predicate checkSoundNonSolid, checkSoundSolid; public LocalPlayer( Game game ) : base( game ) { DisplayName = game.Username; @@ -48,7 +49,10 @@ namespace ClassicalSharp.Entities { Hacks.DoubleJump = !game.ClassicMode && Options.GetBool( OptionsKey.DoubleJump, false ); Hacks.Enabled = !game.ClassicMode && Options.GetBool( OptionsKey.HacksEnabled, true ); if( game.ClassicMode && game.ClassicHacks ) Hacks.Enabled = true; + InitRenderingData(); + checkSoundNonSolid = CheckSoundNonSolid; + checkSoundSolid = CheckSoundSolid; } Vector3 lastSoundPos = new Vector3( float.PositiveInfinity ); @@ -102,7 +106,7 @@ namespace ClassicalSharp.Entities { anyNonAir = false; // first check surrounding liquids/gas for sounds - TouchesAny( bounds, CheckSoundNonSolid ); + TouchesAny( bounds, checkSoundNonSolid ); if( sndType != SoundType.None ) return; // then check block standing on @@ -116,7 +120,7 @@ namespace ClassicalSharp.Entities { // then check all solid blocks at feet pos.Y -= 0.01f; bounds.Max.Y = bounds.Min.Y = pos.Y; - TouchesAny( bounds, CheckSoundSolid ); + TouchesAny( bounds, checkSoundSolid ); } bool CheckSoundNonSolid( byte b ) { diff --git a/Launcher2/Updater/Patcher.cs b/Launcher2/Updater/Patcher.cs index c2778fc04..20a850dbc 100644 --- a/Launcher2/Updater/Patcher.cs +++ b/Launcher2/Updater/Patcher.cs @@ -35,11 +35,11 @@ namespace Launcher.Updater { if( code != 0 ) throw new InvalidOperationException( "chmod returned : " + code ); - if( OpenTK.Configuration.RunningOnMacOS ) - info = new ProcessStartInfo( "open -a Terminal ", - '"' + path + '"'); - else - info = new ProcessStartInfo( "xterm", '"' + path + '"'); + //if( OpenTK.Configuration.RunningOnMacOS ) + // info = new ProcessStartInfo( "open -a Terminal ", + // '"' + path + '"'); + //else + info = new ProcessStartInfo( "xterm", '"' + path + '"'); } info.CreateNoWindow = false; info.UseShellExecute = false; diff --git a/OpenTK/Platform/Windows/API.cs b/OpenTK/Platform/Windows/API.cs index 9ffdeb28d..e4a172fc7 100644 --- a/OpenTK/Platform/Windows/API.cs +++ b/OpenTK/Platform/Windows/API.cs @@ -167,37 +167,6 @@ namespace OpenTK.Platform.Windows { [DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] internal static extern ushort GetKeyState( int code ); - - #region Clipboard - - [DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern bool OpenClipboard(IntPtr hwndMain); - - [DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern bool CloseClipboard(); - - [DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern bool IsClipboardFormatAvailable(int format); - - [DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern IntPtr GetClipboardData(int format); - - [DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern IntPtr SetClipboardData(int format, IntPtr hGlobal); - - [DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern bool EmptyClipboard(); - - [DllImport("kernel32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern IntPtr GlobalLock(IntPtr hGlobal); - - [DllImport("kernel32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern bool GlobalUnlock(IntPtr hGlobal); - - [DllImport("kernel32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity] - internal static extern IntPtr GlobalAlloc(int flags, int bytes); - - #endregion } internal struct Constants { diff --git a/OpenTK/Platform/Windows/WinGLNative.cs b/OpenTK/Platform/Windows/WinGLNative.cs index 3f04247d2..d2a2ac871 100644 --- a/OpenTK/Platform/Windows/WinGLNative.cs +++ b/OpenTK/Platform/Windows/WinGLNative.cs @@ -453,100 +453,9 @@ namespace OpenTK.Platform.Windows suppress_resize--; } - #region Clipboard - - const int CF_UNICODETEXT = 13, CF_TEXT = 1, GMEM_MOVABLE = 2; - public string GetClipboardText() { - if( !API.OpenClipboard( window.handle ) ) - throw new InvalidOperationException( "Failed to lock the clipboard." ); - - string value = ""; - if( API.IsClipboardFormatAvailable( CF_UNICODETEXT ) ) - value = GetUnicodeString(); - else if( API.IsClipboardFormatAvailable( CF_TEXT ) ) - value = GetAnsiString(); - - API.CloseClipboard(); - return value; - } + public string GetClipboardText() { return ""; } - string GetUnicodeString() { - IntPtr hGlobal = API.GetClipboardData( CF_UNICODETEXT ); - IntPtr ptr = API.GlobalLock( hGlobal ); - - if( ptr == IntPtr.Zero ) { - API.CloseClipboard(); - throw new InvalidOperationException( "Failed to lock the pointer from clipboard."); - } - - string value = Marshal.PtrToStringUni( ptr ); - API.GlobalUnlock( hGlobal ); - return value; - } - - string GetAnsiString() { - IntPtr hGlobal = API.GetClipboardData( CF_TEXT ); - IntPtr ptr = API.GlobalLock( hGlobal ); - - if( ptr == IntPtr.Zero ) { - API.CloseClipboard(); - throw new InvalidOperationException( "Failed to lock the pointer from clipboard."); - } - - string value = Marshal.PtrToStringAnsi( ptr ); - API.GlobalUnlock( hGlobal ); - return value; - } - - public void SetClipboardText( string value ) { - if( !API.OpenClipboard( window.handle ) ) - throw new InvalidOperationException( "Failed to lock the clipboard." ); - - if( !API.EmptyClipboard()) { - API.CloseClipboard(); - throw new InvalidOperationException( "Failed to empty the clipboard." ); - } - - bool unicode = Environment.OSVersion.Platform == PlatformID.Win32NT; - int bytes = unicode ? value.Length * 2 : value.Length; - IntPtr hGlobal = API.GlobalAlloc( GMEM_MOVABLE, bytes + 2 ); - if( hGlobal == IntPtr.Zero ) { - API.CloseClipboard(); - throw new InvalidOperationException( "Failed to allocate handle."); - } - - CopyString( value, hGlobal, unicode ); - } - - unsafe void CopyString( string value, IntPtr hGlobal, bool unicode ) { - IntPtr ptr = API.GlobalLock( hGlobal ); - if( ptr == IntPtr.Zero ) { - API.CloseClipboard(); - throw new InvalidOperationException( "Failed to lock handle." ); - } - byte* dataPtr = (byte*)ptr; - if( unicode ) { - for( int i = 0; i < value.Length; i++ ) { - *dataPtr = (byte)value[i]; dataPtr++; - *dataPtr = (byte)(value[i] >> 8); dataPtr++; - } - *dataPtr = 0; dataPtr++; - *dataPtr = 0; dataPtr++; - ptr = API.SetClipboardData( CF_UNICODETEXT, hGlobal ); - } else { - for( int i = 0; i < value.Length; i++ ) { - *dataPtr = (byte)value[i]; dataPtr++; - } - *dataPtr = 0; dataPtr++; - ptr = API.SetClipboardData( CF_TEXT, hGlobal ); - } - - API.GlobalUnlock( hGlobal ); - API.CloseClipboard(); - if( ptr == IntPtr.Zero ) - throw new InvalidOperationException( "Failed to set clipboard data." ); - } - #endregion + public void SetClipboardText( string value ) { } public Rectangle Bounds { get { return bounds; }