Skip to content

Commit

Permalink
Fix hotkey checking on start
Browse files Browse the repository at this point in the history
reset hotkey for reset image wasn't properly being checked
start image only needs to check for start hotkey
start image now also checked on start
Closes #243
  • Loading branch information
Avasam committed Jun 21, 2023
1 parent fc27a71 commit 0872cbd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
16 changes: 4 additions & 12 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,7 @@ def __load_start_image(self, started_by_button: bool = False, wait_for_delay: bo
QApplication.processEvents()
return

if self.start_image:
if not self.is_auto_controlled \
and (
not self.settings_dict["split_hotkey"]
or not self.settings_dict["reset_hotkey"]
or not self.settings_dict["pause_hotkey"]
):
error_messages.load_start_image()
QApplication.processEvents()
return
else:
if not self.start_image:
if started_by_button:
error_messages.no_keyword_image(START_KEYWORD)
QApplication.processEvents()
Expand Down Expand Up @@ -518,7 +508,9 @@ def __auto_splitter(self): # noqa: PLR0912,PLR0915
self.run_start_time = time()

if not (validate_before_parsing(self) and parse_and_validate_images(self)):
self.gui_changes_on_reset(True)
# `safe_to_reload_start_image: bool = False` becasue __load_start_image also does this check,
# we don't want to double a start/reset image error message
self.gui_changes_on_reset(False)
return

# Construct a list of images + loop count tuples.
Expand Down
4 changes: 2 additions & 2 deletions src/error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def check_for_updates():

def load_start_image():
set_text_message(
"Start Image found, but cannot be loaded unless Start, Reset, and Pause hotkeys are set. "
+ "Please set these hotkeys, and then click the Reload Start Image button.",
"Start Image found, but cannot be loaded unless Start hotkey is set. "
+ "Please set the hotkey, and then click the Reload Start Image button.",
)


Expand Down
25 changes: 20 additions & 5 deletions src/split_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,26 @@ def parse_and_validate_images(autosplit: AutoSplit):
autosplit.reset_image = __pop_image_type(all_images, ImageType.RESET)
autosplit.split_images = all_images

# If there is no start hotkey set but a start image is present, and is not auto controlled, throw an error.
if (
autosplit.start_image
and not autosplit.settings_dict["split_hotkey"]
and not autosplit.is_auto_controlled
):
autosplit.gui_changes_on_reset()
error_messages.load_start_image()
return False

# If there is no reset hotkey set but a reset image is present, and is not auto controlled, throw an error.
if (
autosplit.reset_image
and not autosplit.settings_dict["reset_hotkey"]
and not autosplit.is_auto_controlled
):
autosplit.gui_changes_on_reset()
error_messages.reset_hotkey()
return False

# Make sure that each of the images follows the guidelines for correct format
# according to all of the settings selected by the user.
for image in autosplit.split_images:
Expand All @@ -206,11 +226,6 @@ def parse_and_validate_images(autosplit: AutoSplit):

# Check that there's only one reset image
if image.image_type == ImageType.RESET:
# If there is no reset hotkey set but a reset image is present, and is not auto controlled, throw an error.
if not autosplit.settings_dict["reset_hotkey"] and not autosplit.is_auto_controlled:
autosplit.gui_changes_on_reset()
error_messages.reset_hotkey()
return False
autosplit.gui_changes_on_reset()
error_messages.multiple_keyword_images(RESET_KEYWORD)
return False
Expand Down

0 comments on commit 0872cbd

Please sign in to comment.