Skip to content

Commit

Permalink
v0.5.3.3
Browse files Browse the repository at this point in the history
+ removed unnecessary EventInput code from the linux build, null check before disposing sprite texture
  • Loading branch information
Regalis committed Nov 9, 2016
1 parent f3bea27 commit 50a770a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 56 deletions.
4 changes: 2 additions & 2 deletions Subsurface/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.3.2")]
[assembly: AssemblyFileVersion("0.5.3.2")]
[assembly: AssemblyVersion("0.5.3.3")]
[assembly: AssemblyFileVersion("0.5.3.3")]
108 changes: 55 additions & 53 deletions Subsurface/Source/EventInput/EventInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace EventInput
{

#if WINDOWS
public class KeyboardLayout
{
const uint KLF_ACTIVATE = 1; //activate the layout
Expand All @@ -16,14 +16,14 @@ public class KeyboardLayout

[DllImport("user32.dll")]
private static extern long LoadKeyboardLayout(
string pwszKLID, // input locale identifier
uint Flags // input locale identifier options
);
string pwszKLID, // input locale identifier
uint Flags // input locale identifier options
);

[DllImport("user32.dll")]
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()
{
Expand All @@ -32,6 +32,7 @@ public static string getName()
return name.ToString();
}
}
#endif

public class CharacterEventArgs : EventArgs
{
Expand Down Expand Up @@ -115,9 +116,12 @@ public static class EventInput
/// </summary>
public static event KeyEventHandler KeyUp;

static bool initialized;

#if WINDOWS
delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);

static bool initialized;

static IntPtr prevWndProc;
static WndProc hookProcDelegate;
static IntPtr hIMC;
Expand Down Expand Up @@ -145,7 +149,7 @@ public static class EventInput

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

#endif

/// <summary>
/// Initialize the TextInput with the given GameWindow.
Expand All @@ -157,15 +161,15 @@ public static void Initialize(GameWindow window)
{
return;
}
//throw new InvalidOperationException("TextInput.Initialize can only be called once!");

hookProcDelegate = HookProc;
#if WINDOWS
prevWndProc = (IntPtr)SetWindowLong(window.Handle, GWL_WNDPROC,
(int)Marshal.GetFunctionPointerForDelegate(hookProcDelegate));
hookProcDelegate = HookProc;

prevWndProc = (IntPtr)SetWindowLong(window.Handle, GWL_WNDPROC,
(int)Marshal.GetFunctionPointerForDelegate(hookProcDelegate));

hIMC = ImmGetContext(window.Handle);
#elif LINUX
hIMC = ImmGetContext(window.Handle);
#else
window.TextInput += ReceiveInput;
#endif

Expand All @@ -181,50 +185,48 @@ public static void OnCharEntered(char character)
{
if (CharEntered != null) CharEntered(null, new CharacterEventArgs(character, 0));
}

#if WINDOWS
static IntPtr HookProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
{
IntPtr returnCode = CallWindowProc(prevWndProc, hWnd, msg, wParam, lParam);

switch (msg)
{
case WM_GETDLGCODE:
returnCode = (IntPtr)(returnCode.ToInt32() | DLGC_WANTALLKEYS);
break;

case WM_KEYDOWN:
if (KeyDown != null)
KeyDown(null, new KeyEventArgs((Keys)wParam));

break;

case WM_KEYUP:
if (KeyUp != null)
KeyUp(null, new KeyEventArgs((Keys)wParam));
break;

case WM_CHAR:
if (CharEntered != null)
CharEntered(null, new CharacterEventArgs((char)wParam, lParam.ToInt32()));
break;

case WM_IME_SETCONTEXT:
if (wParam.ToInt32() == 1)
ImmAssociateContext(hWnd, hIMC);
break;

case WM_INPUTLANGCHANGE:
ImmAssociateContext(hWnd, hIMC);
returnCode = (IntPtr)1;
break;
}

IntPtr returnCode = CallWindowProc(prevWndProc, hWnd, msg, wParam, lParam);

switch (msg)
{
case WM_GETDLGCODE:
returnCode = (IntPtr)(returnCode.ToInt32() | DLGC_WANTALLKEYS);
break;

case WM_KEYDOWN:
if (KeyDown != null)
KeyDown(null, new KeyEventArgs((Keys)wParam));

break;

case WM_KEYUP:
if (KeyUp != null)
KeyUp(null, new KeyEventArgs((Keys)wParam));
break;

case WM_CHAR:
if (CharEntered != null)
CharEntered(null, new CharacterEventArgs((char)wParam, lParam.ToInt32()));
break;

case WM_IME_SETCONTEXT:
if (wParam.ToInt32() == 1)
ImmAssociateContext(hWnd, hIMC);
break;

case WM_INPUTLANGCHANGE:
ImmAssociateContext(hWnd, hIMC);
returnCode = (IntPtr)1;
break;
}

return returnCode;

return returnCode;
}
}

#endif
}

}
6 changes: 5 additions & 1 deletion Subsurface/Source/Sprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ public void Remove()
}

//if not, free the texture
texture.Dispose();
if (texture != null)
{
texture.Dispose();
texture = null;
}
}

}
Expand Down
11 changes: 11 additions & 0 deletions Subsurface/changelog.txt
Original file line number Diff line number Diff line change
@@ -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
---------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 50a770a

Please sign in to comment.