LunaLua icon indicating copy to clipboard operation
LunaLua copied to clipboard

Window focus events, WM_KILLFOCUS input fixes, and the addition of "Misc.runWhenUnfocused(bool)"

Open SolaceEllery opened this issue 1 year ago • 0 comments

This is once again, another pull request by me.

In this PR, I fixed and added a few things related to the window process of the engine.

Here is what's in this PR:

New LunaLua Events

Adds the following LunaLua events: "onFocusWindow", and "onUnfocusWindow"

Input fix when the main process priority is not SMBX2

When the window is unfocused, and runWhenUnfocused is on, inputs still work when the main process priority is not SMBX2. WM_KILLFOCUS, which handles putting the game into the background when clicking off the game, now has a toggle for disabling inputs, and is disabled until the window is the main process priority again

New Functions

  • Misc.runWhenUnfocused(isEnabled): SMBX2 already has a "runWhenUnfocused" setting, but it can only be toggled running LunaLoader.exe with the command "--runWhenUnfocused" beside it. With this function, the setting can now be enabled or disabled anytime with Lua

Conclusion

These events, along with the fix and function, will be useful for many things:

  • Doing something else outside of drawing an unfocused screen on your episode
  • Preventing game movement when switched to another application process
  • Toggling the "runWhenUnfocused" variable will help out with doing file-related tasks running in the engine, or if an online multiplayer thing gets made for SMBX2

SolaceEllery avatar Jan 28 '24 01:01 SolaceEllery