Skip to content

Commit ef26562

Browse files
committed
Merge branch '2.0.0' into Linted-pyi-files
2 parents 33a49c6 + 21947d0 commit ef26562

File tree

6 files changed

+40
-45
lines changed

6 files changed

+40
-45
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ Given these splits: 1 dummy, 2 normal, 3 dummy, 4 dummy, 5 normal, 6 normal.
155155
In this situation you would have only 3 splits in LiveSplit/wsplit (even though there are 6 split images, only 3 are "real" splits). This basically results in 3 groups of splits: 1st split is images 1 and 2. 2nd split is images 3, 4 and 5. 3rd split is image 6.
156156

157157
- If you are in the 1st or 2nd image and press the skip key, it will end up on the 3rd image
158-
- If you are in the 3rd, 4th or 5th image and press the undo key, it will end up on the 1st image
158+
- If you are in the 3rd, 4th or 5th image and press the undo key, it will end up on the 2nd image
159159
- If you are in the 3rd, 4th or 5th image and press the skip key, it will end up on the 6th image
160-
- If you are in the 6th image and press the undo key, it will end up on the 3rd image
160+
- If you are in the 6th image and press the undo key, it will end up on the 5th image
161161

162162
### Loop Split Images
163163

res/settings.ui

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@
427427
<string/>
428428
</property>
429429
<property name="readOnly">
430-
<bool>false</bool>
430+
<bool>true</bool>
431431
</property>
432432
</widget>
433433
<widget class="QLineEdit" name="undo_split_input">
@@ -477,9 +477,6 @@
477477
<property name="text">
478478
<string/>
479479
</property>
480-
<property name="frame">
481-
<bool>true</bool>
482-
</property>
483480
<property name="readOnly">
484481
<bool>true</bool>
485482
</property>

src/AutoControlledWorker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def run(self):
2020
except RuntimeError:
2121
self.autosplit.show_error_signal.emit(error_messages.stdin_lost)
2222
break
23+
except EOFError:
24+
continue
2325
# TODO: "AutoSplit Integration" needs to call this and wait instead of outright killing the app.
2426
# For now this can only used in a Development environment
2527
if line == "kill":

src/AutoSplit.py

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def excepthook(exception_type: type[BaseException], exception: BaseException, _t
5454
sys.exit(0)
5555
autosplit.show_error_signal.emit(lambda: error_messages.exception_traceback(
5656
"AutoSplit encountered an unhandled exception and will try to recover, "
57-
+ f"however, there is no guarantee everything will work properly. {CREATE_NEW_ISSUE_MESSAGE}",
57+
+ f"however, there is no guarantee it will keep working properly. {CREATE_NEW_ISSUE_MESSAGE}",
5858
exception))
5959
return excepthook
6060

@@ -100,7 +100,6 @@ class AutoSplit(QMainWindow, design.Ui_MainWindow):
100100
"""Window Handle used for Capture Region"""
101101
last_saved_settings: list[Union[str, float, int, bool]] = []
102102
similarity = 0.0
103-
live_image_function_on_open = True
104103
split_image_number = 0
105104
split_images_and_loop_number: list[tuple[AutoSplitImage, int]] = []
106105
split_groups: list[list[int]] = []
@@ -238,22 +237,16 @@ def __browse(self):
238237
self.load_start_image()
239238

240239
def __live_image_function(self):
241-
try:
242-
self.capture_region_window_label.setText(self.settings_dict["captured_window_title"])
243-
if not self.settings_dict["captured_window_title"]:
244-
self.timer_live_image.stop()
245-
self.live_image.clear()
246-
if self.live_image_function_on_open:
247-
self.live_image_function_on_open = False
248-
return
249-
# Set live image in UI
250-
if self.hwnd:
251-
capture = capture_region(self.hwnd, self.settings_dict["capture_region"],
252-
self.settings_dict["force_print_window"])
253-
set_ui_image(self.live_image, capture, False)
254-
255-
except AttributeError:
256-
pass
240+
self.capture_region_window_label.setText(self.settings_dict["captured_window_title"])
241+
if not (self.settings_dict["live_capture_region"] and self.settings_dict["captured_window_title"]):
242+
self.live_image.clear()
243+
return
244+
# Set live image in UI
245+
if self.hwnd:
246+
capture = capture_region(self.hwnd,
247+
self.settings_dict["capture_region"],
248+
self.settings_dict["force_print_window"])
249+
set_ui_image(self.live_image, capture, False)
257250

258251
def load_start_image(self, started_by_button: bool = False, wait_for_delay: bool = True):
259252
self.timer_start_image.stop()
@@ -300,9 +293,9 @@ def __start_image_function(self):
300293
or not self.start_image \
301294
or time() < self.check_start_image_timestamp \
302295
or (not self.settings_dict["split_hotkey"] and not self.is_auto_controlled):
303-
pause_time_left = f"{self.check_start_image_timestamp - time():.1f}"
296+
pause_time_left = self.check_start_image_timestamp - time()
304297
self.current_split_image.setText(
305-
f"None\n (Paused before loading Start Image).\n {pause_time_left} sec remaining")
298+
f"None\n (Paused before loading Start Image).\n {seconds_remaining_text(pause_time_left)}")
306299
return
307300

308301
if self.check_start_image_timestamp > 0:
@@ -347,9 +340,9 @@ def __start_image_function(self):
347340
delay_start_time = time()
348341
start_delay = self.start_image.delay / 1000
349342
while time() - delay_start_time < start_delay:
350-
delay_time_left = round(start_delay - (time() - delay_start_time), 1)
343+
delay_time_left = start_delay - (time() - delay_start_time)
351344
self.current_split_image.setText(
352-
f"Delayed Before Starting:\n {delay_time_left} sec remaining")
345+
f"Delayed Before Starting:\n {seconds_remaining_text(delay_time_left)}")
353346
# Email sent to [email protected]
354347
QtTest.QTest.qWait(1) # type: ignore
355348

@@ -418,9 +411,7 @@ def __check_fps(self):
418411
while count < CHECK_FPS_ITERATIONS:
419412
capture = self.__get_capture_for_comparison()
420413
_ = image.compare_with_capture(self, capture)
421-
set_ui_image(self.current_split_image, image.bytes, True)
422414
count += 1
423-
self.current_split_image.clear()
424415

425416
# calculate FPS
426417
t1 = time()
@@ -444,9 +435,9 @@ def __undo_split(self, navigate_image_only: bool = False):
444435
return
445436

446437
if not navigate_image_only:
447-
for i, group in enumerate(self.split_groups):
438+
for i, group in enumerate(self.split_groups,):
448439
if i > 0 and self.split_image_number in group:
449-
self.split_image_number = self.split_groups[i - 1][0]
440+
self.split_image_number = self.split_groups[i - 1][-1]
450441
break
451442
else:
452443
self.split_image_number -= 1
@@ -636,8 +627,8 @@ def __auto_splitter(self):
636627
# check for reset while delayed and display a counter of the remaining split delay time
637628
delay_start_time = time()
638629
while time() - delay_start_time < split_delay:
639-
delay_time_left = round(split_delay - (time() - delay_start_time), 1)
640-
self.current_split_image.setText(f"Delayed Split: {delay_time_left} sec remaining")
630+
delay_time_left = split_delay - (time() - delay_start_time)
631+
self.current_split_image.setText(f"Delayed Split: {seconds_remaining_text(delay_time_left)}")
641632
if self.__check_for_reset():
642633
return
643634

@@ -684,8 +675,8 @@ def __auto_splitter(self):
684675
if pause_time > 0:
685676
pause_start_time = time()
686677
while time() - pause_start_time < pause_time:
687-
pause_time_left = round(pause_time - (time() - pause_start_time), 1)
688-
self.current_split_image.setText(f"None (Paused). {pause_time_left} sec remaining")
678+
pause_time_left = pause_time - (time() - pause_start_time)
679+
self.current_split_image.setText(f"None (Paused). {seconds_remaining_text(pause_time_left)}")
689680

690681
if self.__check_for_reset():
691682
return
@@ -869,6 +860,10 @@ def exit_program():
869860
exit_program()
870861

871862

863+
def seconds_remaining_text(seconds: float):
864+
return f"{seconds:.1f} second{'' if 0 < seconds <= 1 else 's'} remaining"
865+
866+
872867
def main():
873868
# Call to QApplication outside the try-except so we can show error messages
874869
app = QApplication(sys.argv)

src/hotkeys.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from AutoSplit import AutoSplit
77

88
import threading
9-
from keyboard._keyboard_event import KeyboardEvent, KEY_DOWN
9+
1010
import keyboard # https://github.com/boppreh/keyboard/issues/505
1111
import pyautogui # https://github.com/asweigart/pyautogui/issues/645
12-
# While not usually recommended, we don'thread manipulate the mouse, and we don'thread want the extra delay
12+
# While not usually recommended, we don't manipulate the mouse, and we don't want the extra delay
1313
pyautogui.FAILSAFE = False
1414

1515
SET_HOTKEY_TEXT = "Set Hotkey"
@@ -100,11 +100,11 @@ def _send_hotkey(key_or_scan_code: Union[int, str]):
100100
pyautogui.hotkey(key_or_scan_code.replace(" ", ""))
101101

102102

103-
def __validate_keypad(expected_key: str, keyboard_event: KeyboardEvent) -> bool:
103+
def __validate_keypad(expected_key: str, keyboard_event: keyboard.KeyboardEvent) -> bool:
104104
# Prevent "(keypad)delete", "(keypad)./decimal" and "del" from triggering each other
105105
# as well as "." and "(keypad)./decimal"
106106
if keyboard_event.scan_code in {83, 52}:
107-
# TODO: "del" won'thread work with "(keypad)delete" if localized in non-english (ie: "suppr" in french)
107+
# TODO: "del" won't work with "(keypad)delete" if localized in non-english (ie: "suppr" in french)
108108
return expected_key == keyboard_event.name
109109
# Prevent "action keys" from triggering "keypad keys"
110110
if keyboard_event.name and is_digit(keyboard_event.name[-1]):
@@ -125,16 +125,16 @@ def __validate_keypad(expected_key: str, keyboard_event: KeyboardEvent) -> bool:
125125

126126
# We're doing the check here instead of saving the key code because it'll
127127
# cause issues with save files and the non-keypad shared keys are localized
128-
# while the keypad ones aren'thread.
128+
# while the keypad ones aren't.
129129

130-
# Since we reuse the key string we set to send to LiveSplit, we can'thread use fake names like "num home".
130+
# Since we reuse the key string we set to send to LiveSplit, we can't use fake names like "num home".
131131
# We're also trying to achieve the same hotkey behaviour as LiveSplit has.
132-
def _hotkey_action(keyboard_event: KeyboardEvent, key_name: str, action: Callable[[], None]):
133-
if keyboard_event.event_type == KEY_DOWN and __validate_keypad(key_name, keyboard_event):
132+
def _hotkey_action(keyboard_event: keyboard.KeyboardEvent, key_name: str, action: Callable[[], None]):
133+
if keyboard_event.event_type == keyboard.KEY_DOWN and __validate_keypad(key_name, keyboard_event):
134134
action()
135135

136136

137-
def __get_key_name(keyboard_event: KeyboardEvent):
137+
def __get_key_name(keyboard_event: keyboard.KeyboardEvent):
138138
return f"num {keyboard_event.name}" \
139139
if keyboard_event.is_keypad and is_digit(keyboard_event.name) \
140140
else str(keyboard_event.name)

typings/keyboard/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ from threading import Lock as _Lock
99
from ._keyboard_event import KEY_DOWN, KEY_UP, KeyboardEvent
1010
from ._generic import GenericListener as _GenericListener
1111
from ._canonical_names import all_modifiers, normalize_name, sided_modifiers
12+
__all__ = ["all_modifiers", "normalize_name", "sided_modifiers", "KEY_DOWN", "KEY_UP", "KeyboardEvent"]
1213

1314
__all__ = [
1415
"KEY_DOWN",

0 commit comments

Comments
 (0)