Skip to content
Merged
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
3 changes: 3 additions & 0 deletions res/design.ui
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@
<height>22</height>
</rect>
</property>
<property name="text">
<string>No Folder Selected</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
Expand Down
3 changes: 0 additions & 3 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ def _show_error_signal_slot(error_message_box: Callable[..., object]):
self.update_auto_control = AutoControlledThread(self)
self.update_auto_control.start()

# split image folder line edit text
self.split_image_folder_input.setText("No Folder Selected")

# Connecting menu actions
self.action_view_help.triggered.connect(view_help)
self.action_about.triggered.connect(lambda: open_about(self))
Expand Down
130 changes: 64 additions & 66 deletions src/error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,26 @@
if TYPE_CHECKING:
from AutoSplit import AutoSplit

# Keep in sync with README.md#DOWNLOAD_AND_OPEN
WAYLAND_WARNING = """\
All screen capture method are incompatible with Wayland. Follow this guide to disable it:
<a href="https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop"> \
https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop</a>"""

CREATE_NEW_ISSUE_MESSAGE = (
f"Please create a New Issue at <a href='https://github.com/{GITHUB_REPOSITORY}/issues'>"
+ f"github.com/{GITHUB_REPOSITORY}/issues</a>, describe what happened, "
+ "and copy & paste the entire error message below"
)


def __exit_program():
# stop main thread (which is probably blocked reading input) via an interrupt signal
os.kill(os.getpid(), signal.SIGINT)
sys.exit(1)


def set_text_message(
def _set_text_message(
message: str,
details: str = "",
kill_button: str = "",
Expand Down Expand Up @@ -53,115 +65,115 @@ def set_text_message(


def split_image_directory():
set_text_message("No Split Image Folder is selected.")
_set_text_message("No Split Image Folder is selected.")


def invalid_directory(directory: str):
set_text_message(f"Folder {directory!r} is invalid or does not exist.")
_set_text_message(f"Folder {directory!r} is invalid or does not exist.")


def no_split_image():
set_text_message("Your Split Image Folder should contain at least one Split Image.")
_set_text_message("Your Split Image Folder should contain at least one Split Image.")


def image_type(image: str):
set_text_message(
_set_text_message(
f"{image!r} is not a valid image file, does not exist, "
+ "or the full image file path contains a special character."
)


def region():
set_text_message(
_set_text_message(
"No region is selected or the Capture Region window is not open. "
+ "Select a region or load settings while the Capture Region window is open."
)


def split_hotkey():
set_text_message("No split hotkey has been set.")
_set_text_message("No split hotkey has been set.")


def pause_hotkey():
set_text_message(
_set_text_message(
"Your Split Image Folder contains an image filename with a pause flag {p}, "
+ "but no pause hotkey is set."
)


def image_validity(image: str = "File"):
set_text_message(f"{image} not a valid image file")
_set_text_message(f"{image} not a valid image file")


def alignment_not_matched():
set_text_message("No area in capture region matched reference image. Alignment failed.")
_set_text_message("No area in capture region matched reference image. Alignment failed.")


def no_keyword_image(keyword: str):
set_text_message(
_set_text_message(
f"Your Split Image Folder does not contain an image with the keyword {keyword!r}."
)


def multiple_keyword_images(keyword: str):
set_text_message(f"Only one image with the keyword {keyword!r} is allowed.")
_set_text_message(f"Only one image with the keyword {keyword!r} is allowed.")


def reset_hotkey():
set_text_message("Your Split Image Folder contains a Reset Image, but no reset hotkey is set.")
_set_text_message("Your Split Image Folder contains a Reset Image, but no reset hotkey is set.")


def old_version_settings_file():
set_text_message(
_set_text_message(
"Old version settings file detected. "
+ "This version allows settings files in .toml format. "
+ "Starting from v2.0."
)


def invalid_settings():
set_text_message("Invalid settings file.")
_set_text_message("Invalid settings file.")


def invalid_hotkey(hotkey_name: str):
set_text_message(f"Invalid hotkey {hotkey_name!r}")
_set_text_message(f"Invalid hotkey {hotkey_name!r}")


def no_settings_file_on_open():
set_text_message(
_set_text_message(
"No settings file found. "
+ "One can be loaded on open if placed in the same folder as the AutoSplit executable."
)


def too_many_settings_files_on_open():
set_text_message(
_set_text_message(
"Too many settings files found. "
+ "Only one can be loaded on open if placed in the same folder as the AutoSplit executable."
)


def check_for_updates():
set_text_message(
_set_text_message(
"An error occurred while attempting to check for updates. Please check your connection."
)


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


def stdin_lost():
set_text_message(
_set_text_message(
"stdin not supported or lost, external control like LiveSplit integration will not work."
)


def already_open():
set_text_message(
_set_text_message(
"An instance of AutoSplit is already running."
+ "<br/>Are you sure you want to open a another one?",
"",
Expand All @@ -171,7 +183,7 @@ def already_open():


def linux_groups():
set_text_message(
_set_text_message(
"Linux users must ensure they are in the 'tty' and 'input' groups "
+ "and have write access to '/dev/uinput'. You can run the following commands to do so:",
# Keep in sync with README.md and scripts/install.ps1
Expand All @@ -188,22 +200,15 @@ def linux_groups():


def linux_uinput():
set_text_message(
_set_text_message(
"Failed to create a device file using `uinput` module. "
+ "This can happen when running Linux under WSL. "
+ "Keyboard events have been disabled."
)


# Keep in sync with README.md#DOWNLOAD_AND_OPEN
WAYLAND_WARNING = """\
All screen capture method are incompatible with Wayland. Follow this guide to disable it:
<a href="https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop"> \
https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop</a>"""


def linux_wayland():
set_text_message(WAYLAND_WARNING)
_set_text_message(WAYLAND_WARNING)


def exception_traceback(exception: BaseException, message: str = ""):
Expand All @@ -213,18 +218,39 @@ def exception_traceback(exception: BaseException, message: str = ""):
+ "however, there is no guarantee it will keep working properly. "
+ CREATE_NEW_ISSUE_MESSAGE
)
set_text_message(
_set_text_message(
message,
"\n".join(traceback.format_exception(None, exception, exception.__traceback__)),
"Close AutoSplit",
)


CREATE_NEW_ISSUE_MESSAGE = (
f"Please create a New Issue at <a href='https://github.com/{GITHUB_REPOSITORY}/issues'>"
+ f"github.com/{GITHUB_REPOSITORY}/issues</a>, describe what happened, "
+ "and copy & paste the entire error message below"
)
def tesseract_missing(ocr_split_file_path: str):
_set_text_message(
f"{ocr_split_file_path!r} is an Optical Character Recognition split file "
+ "but tesseract couldn't be found."
+ f'\nPlease read <a href="https://github.com/{GITHUB_REPOSITORY}#install-tesseract">'
+ f"github.com/{GITHUB_REPOSITORY}#install-tesseract</a> for installation instructions."
)


def ocr_missing_key(ocr_split_file_path: str, missing_key: str):
_set_text_message(f"{ocr_split_file_path!r} is missing an entry for {missing_key!r}")


def wrong_ocr_values(ocr_split_file_path: str):
_set_text_message(
f"{ocr_split_file_path!r} has invalid values."
+ "\nPlease make sure that `left &lt; right` and `top &lt; bottom`. "
+ "Also check for negative values in the 'methods' or 'fps_limit' settings"
)


def invalid_filename_delimiters(filename: str, delimiters: str):
_set_text_message(
f"Split '{filename}' contains invalid parameters. "
+ f"'{delimiters}' must not appear more than once."
)


def make_excepthook(autosplit: AutoSplit):
Expand Down Expand Up @@ -258,31 +284,3 @@ def handle_top_level_exceptions(exception: Exception) -> NoReturn:
else:
traceback.print_exception(type(exception), exception, exception.__traceback__)
sys.exit(1)


def tesseract_missing(ocr_split_file_path: str):
set_text_message(
f"{ocr_split_file_path!r} is an Optical Character Recognition split file "
+ "but tesseract couldn't be found."
+ f'\nPlease read <a href="https://github.com/{GITHUB_REPOSITORY}#install-tesseract">'
+ f"github.com/{GITHUB_REPOSITORY}#install-tesseract</a> for installation instructions."
)


def ocr_missing_key(ocr_split_file_path: str, missing_key: str):
set_text_message(f"{ocr_split_file_path!r} is missing an entry for {missing_key!r}")


def wrong_ocr_values(ocr_split_file_path: str):
set_text_message(
f"{ocr_split_file_path!r} has invalid values."
+ "\nPlease make sure that `left &lt; right` and `top &lt; bottom`. "
+ "Also check for negative values in the 'methods' or 'fps_limit' settings"
)


def invalid_filename_delimiters(filename: str, delimiters: str):
set_text_message(
f"Split '{filename}' contains invalid parameters. "
+ f"'{delimiters}' must not appear more than once."
)
Loading