Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

SpencerEverly
Copy link
Contributor

@SpencerEverly SpencerEverly commented Jan 28, 2024

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

@SpencerEverly SpencerEverly changed the title onFocusWindow, onUnfocusWindow, WM_KILLFOCUS input fixes, and Misc.runWhenUnfocused(bool) Window focus events, WM_KILLFOCUS input fixes, and the addition of "Misc.runWhenUnfocused(bool)" Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant