From fcecfd0d84a5e4a1ace5df7aa8eb877cb2e15d4f Mon Sep 17 00:00:00 2001 From: SnuffSocket <82658601+SnuffSocket@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:23:24 +0300 Subject: [PATCH] Request: Parley w/dfgHiatus's "Please use our new locale system for text!" --- BabbleApp/Locale/English/locale.json | 2 ++ BabbleApp/Locale/OwO/locale.json | 2 ++ BabbleApp/Locale/Pirate Speak/locale.json | 2 ++ BabbleApp/babbleapp.py | 15 +++++++-------- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/BabbleApp/Locale/English/locale.json b/BabbleApp/Locale/English/locale.json index 1cc25fd..b2a9dd4 100644 --- a/BabbleApp/Locale/English/locale.json +++ b/BabbleApp/Locale/English/locale.json @@ -35,12 +35,14 @@ "error.frame": "Problem while getting frame", "error.size": "Size of frames to display are of unequal sizes", "error.capture": "Frame capture issue detected", + "error.winmm": "Failed to load winmm", "warn.frameDrop": "Frame drop. Corrupted JPEG", "warn.captureProblem": "Capture source problem, assuming camera disconnected, waiting for reconnect", "warn.serialCapture": "Serial capture source problem, assuming camera disconnected, waiting for reconnect", "warn.backpressure1": "CAPTURE QUEUE BACKPRESSURE OF", "warn.backpressure2": "CHECK FOR CRASH OR TIMING ISSUES IN ALGORITHM", "warn.oneEuroValues": "OneEuroFilter values must be a legal number", + "warn.timerRes": "Failed to set timer resolution:", "info.moveToTrackingMode": "Moving to tracking mode", "info.moveToROIMode": "Moving to ROI mode", "info.setROI": "Set ROI", diff --git a/BabbleApp/Locale/OwO/locale.json b/BabbleApp/Locale/OwO/locale.json index 76a2411..4f800b5 100644 --- a/BabbleApp/Locale/OwO/locale.json +++ b/BabbleApp/Locale/OwO/locale.json @@ -35,12 +35,14 @@ "error.frame": "Problem while getting frame", "error.size": "Size of frames to display are of unequal sizes", "error.capture": "Frame capture issue detected", + "error.winmmDll": "Faiwed to woad winmm", "warn.frameDrop": "Frame drop. Corrupted JPEG", "warn.captureProblem": "Capture source problem, assuming camera disconnected, waiting for reconnect", "warn.serialCapture": "Serial capture source problem, assuming camera disconnected, waiting for reconnect", "warn.backpressure1": "CAPTURE QUEUE BACKPRESSURE OF", "warn.backpressure2": "CHECK FOR CRASH OR TIMING ISSUES IN ALGORITHM", "warn.oneEuroValues": "OneEuroFilter values must be a legal number", + "warn.timerRes": "Faiwed to set timew wesowution:", "info.moveToTrackingMode": "Moving to tracking mode", "info.moveToROIMode": "Moving to ROI mode", "info.setROI": "Set ROI", diff --git a/BabbleApp/Locale/Pirate Speak/locale.json b/BabbleApp/Locale/Pirate Speak/locale.json index 6fefdda..982d6d6 100644 --- a/BabbleApp/Locale/Pirate Speak/locale.json +++ b/BabbleApp/Locale/Pirate Speak/locale.json @@ -35,12 +35,14 @@ "error.frame": "Problem while getting frame", "error.size": "Size of frames to display are of unequal sizes", "error.capture": "Frame capture issue detected", + "error.winmmDll": "We be failin' to load th' winmm, matey!", "warn.frameDrop": "Frame drop. Corrupted JPEG", "warn.captureProblem": "Capture source problem, assuming camera disconnected, waiting for reconnect", "warn.serialCapture": "Serial capture source problem, assuming camera disconnected, waiting for reconnect", "warn.backpressure1": "CAPTURE QUEUE BACKPRESSURE OF", "warn.backpressure2": "CHECK FOR CRASH OR TIMING ISSUES IN ALGORITHM", "warn.oneEuroValues": "OneEuroFilter values must be a legal number", + "warn.timerRes": "We be failin' to set th' timer resolution:", "info.moveToTrackingMode": "Moving to tracking mode", "info.moveToROIMode": "Moving to ROI mode", "info.setROI": "Set ROI", diff --git a/BabbleApp/babbleapp.py b/BabbleApp/babbleapp.py index c01d3e9..4e7e880 100644 --- a/BabbleApp/babbleapp.py +++ b/BabbleApp/babbleapp.py @@ -33,17 +33,16 @@ from calib_settings_widget import CalibSettingsWidget from utils.misc_utils import EnsurePath, is_nt, bg_color_highlight, bg_color_clear from lang_manager import LocaleStringManager as lang +winmm = None + if is_nt: from winotify import Notification + try: + winmm = windll.winmm + except OSError: + print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("error.winmm")}.\033[0m') os.system("color") # init ANSI color -winmm = None -try: - winmm = windll.winmm -except OSError: - #print("[DEBUG] Failed to load winmm.dll") - pass - # Random environment variable to speed up webcam opening on the MSMF backend. # https://github.com/opencv/opencv/issues/17687 os.environ["OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS"] = "0" @@ -67,7 +66,7 @@ def timerResolution(toggle): rc = c_int(winmm.timeBeginPeriod(1)) if rc.value != 0: # TIMEERR_NOCANDO = 97 - print(f"[WARN] Failed to set timer resolution: {rc.value}") + print(f'\033[93m[{lang._instance.get_string("log.warn")}] {lang._instance.get_string("warn.timerRes")} {rc.value}\033[0m') else: winmm.timeEndPeriod(1)