From 47578306cb19d66c919bc3439933286a648f829f Mon Sep 17 00:00:00 2001 From: Zebartin <16185081+Zebartin@users.noreply.github.com> Date: Wed, 21 Jun 2023 22:08:57 +0800 Subject: [PATCH] Fix: Help text & details of assignment - https://github.com/LmeSzinc/StarRailCopilot/pull/23#discussion_r1235492724 - https://github.com/LmeSzinc/StarRailCopilot/pull/23#discussion_r1235495266 - https://github.com/LmeSzinc/StarRailCopilot/pull/23#discussion_r1235497216 - https://github.com/LmeSzinc/StarRailCopilot/pull/23#discussion_r1235500507 --- module/config/i18n/en-US.json | 4 ++-- module/config/i18n/zh-CN.json | 2 +- module/config/i18n/zh-TW.json | 2 +- module/ocr/ocr.py | 19 ++++--------------- module/ui/draggable_list.py | 2 +- tasks/assignment/ui.py | 5 ++++- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 42a1e73dc..e7e8cdb62 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -223,11 +223,11 @@ "Assignment": { "_info": { "name": "Assignment Settings", - "help": "" + "help": "Claim rewards and dispatch, handling specified assignments first\nIf the assignment limit is not reached after that, others will be dispatched according to preset priority (EXP Materials/Credits → Character Materials → Synthesis Materials)" }, "Filter": { "name": "Assignment Priority", - "help": "Example: Nameless Land Nameless People > Akashic Records > The Invisible Hand > Root Out the Turpitude" + "help": "Make sure there are no typos\nExample: Nameless Land Nameless People > Akashic Records > The Invisible Hand > Root Out the Turpitude" }, "Duration": { "name": "Assignment Duration", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 97e327582..e81b6c236 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -223,7 +223,7 @@ "Assignment": { "_info": { "name": "委托设置", - "help": "" + "help": "领取奖励并派遣,优先处理指定委托\n若处理指定委托之后未达到上限,则按经验材料 → 角色专属素材 → 合成材料的顺序来派遣委托" }, "Filter": { "name": "委托优先级", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 4314a64e9..c2c1b1724 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -223,7 +223,7 @@ "Assignment": { "_info": { "name": "委託設置", - "help": "" + "help": "領取獎勵並派遣,優先處理指定委託\n若處理指定委託之後未達到上限,則按經驗材料 → 角色專屬素材 → 合成材料的順序來派遣委託" }, "Filter": { "name": "委託優先級", diff --git a/module/ocr/ocr.py b/module/ocr/ocr.py index 7a2a17289..f4446f2b6 100644 --- a/module/ocr/ocr.py +++ b/module/ocr/ocr.py @@ -263,22 +263,11 @@ class DigitCounter(Ocr): class Duration(Ocr): @cached_property def timedelta_regex(self): - hour_regex = { - 'ch': '小时', - 'en': 'h\s*' + regex_str = { + 'ch': r'\D*((?P\d{1,2})小时)?((?P\d{1,2})分钟)?((?P\d{1,2})秒})?', + 'en': r'\D*((?P\d{1,2})h\s*)?((?P\d{1,2})m\s*)?((?P\d{1,2})s)?' }[self.lang] - minute_regex = { - 'ch': '分钟', - 'en': 'm\s*' - }[self.lang] - second_regex = { - 'ch': '秒', - 'en': 's' - }[self.lang] - ret = rf'\D*((?P\d{{1,2}}){hour_regex})?' - ret += rf'((?P\d{{1,2}}){minute_regex})?' - ret += rf'((?P\d{{1,2}}){second_regex})?' - return re.compile(ret) + return re.compile(regex_str) def format_result(self, result: str) -> timedelta: """ diff --git a/module/ui/draggable_list.py b/module/ui/draggable_list.py index 7303d7706..9ddc6468e 100644 --- a/module/ui/draggable_list.py +++ b/module/ui/draggable_list.py @@ -28,7 +28,7 @@ class DraggableList: keyword_class, ocr_class, search_button: ButtonWrapper, - active_color: tuple[int, int, int] + active_color: tuple[int, int, int] = (190, 175, 124) ): """ Args: diff --git a/tasks/assignment/ui.py b/tasks/assignment/ui.py index 0649cab63..c028cea6e 100644 --- a/tasks/assignment/ui.py +++ b/tasks/assignment/ui.py @@ -61,8 +61,11 @@ class AssignmentOcr(Ocr): matched = self.ocr_regex.fullmatch(result) if matched is None: return result + keyword_lang = self.lang + if self.lang == 'ch': + keyword_lang = 'cn' matched = getattr(KEYWORDS_ASSIGNMENT_ENTRY, matched.lastgroup) - matched = getattr(matched, self.lang) + matched = getattr(matched, keyword_lang) logger.attr(name=f'{self.name} after_process', text=f'{result} -> {matched}') return matched