+ removed unnecessary EventInput code from the linux build, null check before disposing sprite texture
This commit is contained in:
Regalis
2016-11-09 21:01:38 +02:00
parent f3bea2702b
commit 50a770a2a6
4 changed files with 68 additions and 51 deletions
+2 -2
View File
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.3.2")] [assembly: AssemblyVersion("0.5.3.3")]
[assembly: AssemblyFileVersion("0.5.3.2")] [assembly: AssemblyFileVersion("0.5.3.3")]
+50 -48
View File
@@ -6,7 +6,7 @@ using Microsoft.Xna.Framework.Input;
namespace EventInput namespace EventInput
{ {
#if WINDOWS
public class KeyboardLayout public class KeyboardLayout
{ {
const uint KLF_ACTIVATE = 1; //activate the layout const uint KLF_ACTIVATE = 1; //activate the layout
@@ -16,14 +16,14 @@ namespace EventInput
[DllImport("user32.dll")] [DllImport("user32.dll")]
private static extern long LoadKeyboardLayout( private static extern long LoadKeyboardLayout(
string pwszKLID, // input locale identifier string pwszKLID, // input locale identifier
uint Flags // input locale identifier options uint Flags // input locale identifier options
); );
[DllImport("user32.dll")] [DllImport("user32.dll")]
private static extern long GetKeyboardLayoutName( private static extern long GetKeyboardLayoutName(
StringBuilder pwszKLID //[out] string that receives the name of the locale identifier StringBuilder pwszKLID //[out] string that receives the name of the locale identifier
); );
public static string getName() public static string getName()
{ {
@@ -32,6 +32,7 @@ namespace EventInput
return name.ToString(); return name.ToString();
} }
} }
#endif
public class CharacterEventArgs : EventArgs public class CharacterEventArgs : EventArgs
{ {
@@ -115,9 +116,12 @@ namespace EventInput
/// </summary> /// </summary>
public static event KeyEventHandler KeyUp; public static event KeyEventHandler KeyUp;
static bool initialized;
#if WINDOWS
delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
static bool initialized;
static IntPtr prevWndProc; static IntPtr prevWndProc;
static WndProc hookProcDelegate; static WndProc hookProcDelegate;
static IntPtr hIMC; static IntPtr hIMC;
@@ -145,7 +149,7 @@ namespace EventInput
[DllImport("user32.dll", CharSet = CharSet.Unicode)] [DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
#endif
/// <summary> /// <summary>
/// Initialize the TextInput with the given GameWindow. /// Initialize the TextInput with the given GameWindow.
@@ -157,15 +161,15 @@ namespace EventInput
{ {
return; return;
} }
//throw new InvalidOperationException("TextInput.Initialize can only be called once!");
hookProcDelegate = HookProc;
#if WINDOWS #if WINDOWS
prevWndProc = (IntPtr)SetWindowLong(window.Handle, GWL_WNDPROC, hookProcDelegate = HookProc;
(int)Marshal.GetFunctionPointerForDelegate(hookProcDelegate));
hIMC = ImmGetContext(window.Handle); prevWndProc = (IntPtr)SetWindowLong(window.Handle, GWL_WNDPROC,
#elif LINUX (int)Marshal.GetFunctionPointerForDelegate(hookProcDelegate));
hIMC = ImmGetContext(window.Handle);
#else
window.TextInput += ReceiveInput; window.TextInput += ReceiveInput;
#endif #endif
@@ -181,50 +185,48 @@ namespace EventInput
{ {
if (CharEntered != null) CharEntered(null, new CharacterEventArgs(character, 0)); if (CharEntered != null) CharEntered(null, new CharacterEventArgs(character, 0));
} }
#if WINDOWS
static IntPtr HookProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) static IntPtr HookProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
{ {
IntPtr returnCode = CallWindowProc(prevWndProc, hWnd, msg, wParam, lParam); IntPtr returnCode = CallWindowProc(prevWndProc, hWnd, msg, wParam, lParam);
switch (msg) switch (msg)
{ {
case WM_GETDLGCODE: case WM_GETDLGCODE:
returnCode = (IntPtr)(returnCode.ToInt32() | DLGC_WANTALLKEYS); returnCode = (IntPtr)(returnCode.ToInt32() | DLGC_WANTALLKEYS);
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
if (KeyDown != null) if (KeyDown != null)
KeyDown(null, new KeyEventArgs((Keys)wParam)); KeyDown(null, new KeyEventArgs((Keys)wParam));
break; break;
case WM_KEYUP: case WM_KEYUP:
if (KeyUp != null) if (KeyUp != null)
KeyUp(null, new KeyEventArgs((Keys)wParam)); KeyUp(null, new KeyEventArgs((Keys)wParam));
break; break;
case WM_CHAR: case WM_CHAR:
if (CharEntered != null) if (CharEntered != null)
CharEntered(null, new CharacterEventArgs((char)wParam, lParam.ToInt32())); CharEntered(null, new CharacterEventArgs((char)wParam, lParam.ToInt32()));
break; break;
case WM_IME_SETCONTEXT: case WM_IME_SETCONTEXT:
if (wParam.ToInt32() == 1) if (wParam.ToInt32() == 1)
ImmAssociateContext(hWnd, hIMC); ImmAssociateContext(hWnd, hIMC);
break; break;
case WM_INPUTLANGCHANGE:
ImmAssociateContext(hWnd, hIMC);
returnCode = (IntPtr)1;
break;
}
return returnCode;
case WM_INPUTLANGCHANGE:
ImmAssociateContext(hWnd, hIMC);
returnCode = (IntPtr)1;
break;
} }
return returnCode;
}
#endif
} }
} }
+5 -1
View File
@@ -379,7 +379,11 @@ namespace Barotrauma
} }
//if not, free the texture //if not, free the texture
texture.Dispose(); if (texture != null)
{
texture.Dispose();
texture = null;
}
} }
} }
+11
View File
@@ -1,3 +1,14 @@
---------------------------------------------------------------------------------------------------------
v0.5.3.3
---------------------------------------------------------------------------------------------------------
- fixed a bug that caused crashes after a husk-infected player died
- disabled the "zoom effect" when under pressure as a huskified human
- only a limited number of messages are kept in the debug console (prevents performance issues if large
amounts of messages are added)
- some item and electricity logic optimization
- fixed "sprite tigerthresher not found" errors in the Linux version
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
v0.5.3.2 v0.5.3.2
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------