mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Revert last commit, makes no sense to reimplement Clipboard handling.
This commit is contained in:
parent
4387e18dea
commit
5e9f401449
@ -29,6 +29,7 @@ namespace ClassicalSharp.Entities {
|
||||
public HacksComponent Hacks;
|
||||
internal PhysicsComponent physics;
|
||||
internal InputComponent input;
|
||||
Predicate<byte> 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 ) {
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user