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

Native Hotkey for Manual Swap #73

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Bizhawk Shuffler 2
* written by authorblues, inspired by [Brossentia's Bizhawk Shuffler](https://github.com/brossentia/BizHawk-Shuffler), based on slowbeef's original project
* [tested on Bizhawk v2.6.3-v2.9.1](https://github.com/TASVideos/BizHawk/releases/)
* [click here to download the latest version](https://github.com/authorblues/bizhawk-shuffler-2/archive/refs/heads/main.zip)
* [click here to download the latest version](https://github.com/edzwoo/bizhawk-shuffler-2/archive/refs/heads/main.zip)

## Hotkey for Manual Swap
* This fork adds a manual swap on input as well as additional hotkey combinations

## Additional Resources
* **[Setup Instructions](https://github.com/authorblues/bizhawk-shuffler-2/wiki/Setup-Instructions)**
Expand Down
49 changes: 48 additions & 1 deletion shuffler-src/setupform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ end
function module.initial_setup(callback)
local setup_window, resume, start_btn
local seed_text, min_text, max_text
local mode_combo, hk_complete, plugin_label
local mode_combo, hk_complete, hk_swap, plugin_label
local plugin_btn, seed_btn
local immutable_inputs
local plugin_window = -1
Expand Down Expand Up @@ -268,6 +268,47 @@ function module.initial_setup(callback)
'Alt+Shift+D',
'Backslash (above Enter)',
'RightCtrl',
'F1',
'F2',
'F3',
'F4',
'F5',
'F6',
'F7',
'F8',
'F9',
'F10',
'F11',
'F12',
'F13',
'F14',
'F15',
}
-- Additional for swap
local HOTKEY_OPTIONS_SWAP = {
'Ctrl+Shift+Delete',
'Ctrl+Shift+End',
'Ctrl+Shift+D',
'Alt+Shift+End',
'Alt+Shift+Delete',
'Alt+Shift+D',
'Backslash (above Enter)',
'RightCtrl',
'F1',
'F2',
'F3',
'F4',
'F5',
'F6',
'F7',
'F8',
'F9',
'F10',
'F11',
'F12',
'F13',
'F14',
'F15',
}
local function invert_table(t)
local keys = {}
Expand Down Expand Up @@ -337,6 +378,7 @@ function module.initial_setup(callback)
config.max_swap = math.max(a, b)

config.hk_complete = (forms.gettext(hk_complete) or 'Ctrl+Shift+End'):match("[^%s]+")
config.hk_swap = (forms.gettext(hk_swap) or 'Ctrl+Shift+Delete'):match("[^%s]+")
end

function main_cleanup()
Expand Down Expand Up @@ -404,6 +446,11 @@ function module.initial_setup(callback)
forms.settext(hk_complete, config.hk_complete or 'Ctrl+Shift+End')
y = y + 30

hk_swap = forms.dropdown(setup_window, HOTKEY_OPTIONS_SWAP, 10, y, 150, 20)
forms.label(setup_window, "Hotkey: Swap Game", 165, y+3, 150, 20)
forms.settext(hk_swap, config.hk_swap or 'Ctrl+Shift+Delete')
y = y + 30

output_files_combo = forms.dropdown(setup_window, OUTPUT_FILE_MODES, 10, y, 150, 20)
forms.label(setup_window, "Output info files for OBS", 165, y+3, 150, 20)
forms.settext(output_files_combo, OUTPUT_FILE_MODES[config.output_files] or OUTPUT_FILE_MODES[OUTPUT_FILE_MODES_DEFAULT])
Expand Down
7 changes: 5 additions & 2 deletions shuffler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,11 @@ while true do
-- mark the game as complete if the hotkey is pressed (and some time buffer)
-- the time buffer should hopefully prevent somebody from attempting to
-- press the hotkey and the game swapping, marking the wrong game complete
if current_input[config.hk_complete] and not prev_input[config.hk_complete] and
frames_since_restart > math.min(3, config.min_swap/2) * 60 then mark_complete() end
if current_input[config.hk_complete] and not prev_input[config.hk_complete] and frames_since_restart > math.min(3, config.min_swap/2) * 60 then
mark_complete()
elseif current_input[config.hk_swap] and not prev_input[config.hk_swap] then
swap_game()
end
prev_input = current_input

-- time to swap!
Expand Down