Skip to content

Commit

Permalink
Don't set images if parsing doesn't pass
Browse files Browse the repository at this point in the history
Fixes live preview not showing when parsing fail with a start image present
  • Loading branch information
Avasam committed Jun 23, 2023
1 parent 0f9f3f0 commit 7c9e1a5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/split_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,23 @@ def parse_and_validate_images(autosplit: AutoSplit):
]

# Find non-split images and then remove them from the list
autosplit.start_image = __pop_image_type(all_images, ImageType.START)
autosplit.reset_image = __pop_image_type(all_images, ImageType.RESET)
autosplit.split_images = all_images
start_image = __pop_image_type(all_images, ImageType.START)
reset_image = __pop_image_type(all_images, ImageType.RESET)
split_images = all_images

error_message: Callable[[], object] | None = None

# 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
start_image
and not autosplit.settings_dict["split_hotkey"]
and not autosplit.is_auto_controlled
):
error_message = error_messages.load_start_image

# If there is no reset hotkey set but a reset image is present, and is not auto controlled, throw an error.
elif (
autosplit.reset_image
reset_image
and not autosplit.settings_dict["reset_hotkey"]
and not autosplit.is_auto_controlled
):
Expand All @@ -208,7 +208,7 @@ def parse_and_validate_images(autosplit: AutoSplit):
# Make sure that each of the images follows the guidelines for correct format
# according to all of the settings selected by the user.
else:
for image in autosplit.split_images:
for image in split_images:
# Test for image without transparency
if not is_valid_image(image.byte_array):
def image_validity(filename: str):
Expand Down Expand Up @@ -236,8 +236,14 @@ def image_validity(filename: str):
break

if error_message:
autosplit.start_image = None
autosplit.reset_image = None
autosplit.split_images = []
autosplit.gui_changes_on_reset()
error_message()
return False

autosplit.start_image = start_image
autosplit.reset_image = reset_image
autosplit.split_images = split_images
return True

0 comments on commit 7c9e1a5

Please sign in to comment.