diff --git a/Honkai_Star_Rail.py b/Honkai_Star_Rail.py index f6546f05..6d96c066 100644 --- a/Honkai_Star_Rail.py +++ b/Honkai_Star_Rail.py @@ -102,6 +102,8 @@ def stop(self): return [{}] def end(self): + if sra_config_obj.auto_shutdown: + os.system("shutdown -s -t 60") try: plugin_manager.hook.end(SRA=self) except: @@ -256,6 +258,12 @@ def set_config(self, start = True): options = [_('没打开'), _('打开了'), _('这是什么')] option = questionary.select(title, options).ask() sra_config_obj.auto_battle_persistence = options.index(option) + + title = _("需要锄大地结束后自动关机么?:") + options = [_('不需要'), _('需要')] + option = questionary.select(title, options).ask() + sra_config_obj.auto_shutdown = bool(options.index(option)) + sra_config_obj.start = True raise Exception(_("请重新运行")) diff --git a/gui.py b/gui.py index 241dca68..b5a5b11c 100644 --- a/gui.py +++ b/gui.py @@ -243,7 +243,9 @@ def set_config(e): language = list(filter(lambda key: language_dict[key] == language, language_dict))[0] fighting_list = [_('没打开'), _('打开了'), _('这是什么')] + shutdown_list = [_('不需要'), _('需要')] fighting = fighting_list[sra_config_obj.auto_battle_persistence] + shutdown = shutdown_list[sra_config_obj.auto_shutdown] github_proxy_list = ['https://ghproxy.com/', 'https://ghproxy.net/', "不设置代理"] github_proxy = sra_config_obj.github_proxy @@ -300,7 +302,14 @@ def set_config(e): value=fighting, width=200, ) - + shutdown_dd = ft.Dropdown( + label= _("需要锄大地结束后自动关机么?"), + hint_text= _("设置自动关机?"), + options=[ft.dropdown.Option(i) for i in shutdown_list], + value=shutdown, + width=200, + ) + open_map_tf = ft.TextField(label=_("打开地图按钮"), value=open_map, width=200) def save(e): sra_config_obj.github_proxy = "" if github_proxy_dd.value == "不设置代理" else github_proxy_dd.value @@ -310,6 +319,7 @@ def save(e): sra_config_obj.level = level_dd.value sra_config_obj.language = language_dict[language_dd.value] sra_config_obj.auto_battle_persistence = fighting_list.index(fighting_dd.value) + sra_config_obj.auto_shutdown = bool(shutdown_list.index(shutdown_dd.value)) sra_config_obj.start = True to_page_main(page) page.clean() @@ -324,6 +334,7 @@ def save(e): open_map_tf, language_dd, fighting_dd, + shutdown_dd, ft.ElevatedButton(_("保存"), on_click=save), ) diff --git a/requirements.txt b/requirements.txt index fa58ac5d..97d6cc05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ packaging protobuf sympy whl/Polygon3-3.0.9-cp311-cp311-win_amd64.whl -cnocr>=2.2.2.3 +cnocr[ort-cpu]>=2.2.2.3 docopt httpx httpx_socks diff --git a/utils/config.py b/utils/config.py index dc333ee7..f1df29f9 100644 --- a/utils/config.py +++ b/utils/config.py @@ -328,7 +328,8 @@ class SRAData(metaclass=SRADataMeta): """是否在打印遗器信息时显示拓展信息""" ndigits_for_relic: int = 2 """在打印遗器信息时的小数精度""" - + auto_shutdown: bool = False + """是否自动关机""" def __init__(self) -> None: ...