🐛 | Fixed SHIFT-button getting stuck.
Some checks are pending
Gitea Action Test / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
NikkeDoy 2024-12-12 02:01:05 +02:00
parent 04072b16e6
commit fb0451d49f

15
main.py
View File

@ -11,6 +11,10 @@ def save_preferences():
save_preferences_button.config(state=DISABLED, text="Saved!") save_preferences_button.config(state=DISABLED, text="Saved!")
root.after(5000, lambda: save_preferences_button.config(state=NORMAL, text="Save")) root.after(5000, lambda: save_preferences_button.config(state=NORMAL, text="Save"))
def release_shift(is_windowed):
if is_windowed:
pyautogui.keyUp("shift")
def launch_exe(): def launch_exe():
# Check for valid server address (Currently only supports numerical addresses (not domains.)) # Check for valid server address (Currently only supports numerical addresses (not domains.))
if not validate_server_address(server_address_field.get()): if not validate_server_address(server_address_field.get()):
@ -29,8 +33,7 @@ def launch_exe():
# If game needs to be windowed then we use BF42Plus provided "workaround." # If game needs to be windowed then we use BF42Plus provided "workaround."
if windowed.get(): if windowed.get():
pyautogui.keyDown("shift") pyautogui.keyDown("shift")
root.after(5000, lambda: pyautogui.keyUp("shift")) try:
subprocess.call([ subprocess.call([
"./BF1942.exe", "./BF1942.exe",
"+game", "FinnWars", "+game", "FinnWars",
@ -38,7 +41,13 @@ def launch_exe():
"+game", "FinnWars", "+game", "FinnWars",
"+joinServer", server_address_field.get() "+joinServer", server_address_field.get()
]) ])
root.quit() root.after(2000, lambda: release_shift(windowed.get()))
root.after(2050, lambda: root.quit())
except:
launch_game.config(state=DISABLED, text=".exe not found!")
root.after(5000, lambda: launch_game.config(state=NORMAL, text="Launch"))
root.after(50, lambda: release_shift(windowed.get()))
def validate_server_address(server_address): def validate_server_address(server_address):
ip_regex = r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$" ip_regex = r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"