From c674c7a53becce2e677be6f0e7efb2d69612c687 Mon Sep 17 00:00:00 2001 From: RedDeadDepresso <94017243+RedDeadDepresso@users.noreply.github.com> Date: Sat, 6 Jan 2024 00:11:18 +0000 Subject: [PATCH] feat: exit AAS & emulator --- MCE/custom_widgets/ctk_add_button.py | 5 ++++- module/alas.py | 18 ++++++++++-------- module/config/argument/args.json | 1 + module/config/argument/argument.yaml | 2 +- module/config/config_generated.py | 2 +- module/config/i18n/en-US.json | 3 ++- module/config/i18n/zh-CN.json | 1 + 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/MCE/custom_widgets/ctk_add_button.py b/MCE/custom_widgets/ctk_add_button.py index 6ed2446..f589ea8 100644 --- a/MCE/custom_widgets/ctk_add_button.py +++ b/MCE/custom_widgets/ctk_add_button.py @@ -13,4 +13,7 @@ class CTkAddButton(customtkinter.CTkFrame): def set_button(self, value): self.option_menu.set("") - self.button.configure(text=value) \ No newline at end of file + self.button.configure(text=value) + + def configure(self, *args, **kwargs): + self.button.configure(*args, **kwargs) \ No newline at end of file diff --git a/module/alas.py b/module/alas.py index e155377..7013f20 100644 --- a/module/alas.py +++ b/module/alas.py @@ -233,17 +233,19 @@ class AzurLaneAutoScript: del_cached_property(self, 'config') continue elif method == 'exit_aas': + self.config.Optimization_WhenTaskQueueEmpty = 'goto_main' self.exit_aas() - release_resources() - self.device.release_during_wait() - if not self.wait_until(task.next_run): - del_cached_property(self, 'config') - continue + exit(1) + elif method == 'exit_emulator': + self.config.Optimization_WhenTaskQueueEmpty = 'goto_main' + self.exit_emulator() + exit(1) # stops AAS from restarting emulator elif method == 'exit_aas_emulator': self.exit_emulator() self.exit_aas() - exit(0) + exit(1) elif method == 'shutdown': + self.config.Optimization_WhenTaskQueueEmpty = 'goto_main' self.shutdown() release_resources() self.device.release_during_wait() @@ -338,7 +340,7 @@ class AzurLaneAutoScript: from module.device.platform.platform_windows import PlatformWindows PlatformWindows(self.config).emulator_stop() except: - logger.error("Failed to stop emulator. It may be due to a lack of administrator privileges or incorrect input in Emulator Settings.") + logger.error("Failed to stop emulator. It may be due to a lack of administrator privileges.") def exit_aas(self): if self.operating_system != 'Windows': @@ -352,7 +354,7 @@ class AzurLaneAutoScript: def shutdown(self): if self.operating_system not in ["Windows", "Linux", "Darwin"]: - logger.info("Shutdown set during wait but operating system not supported") + logger.error("Shutdown set during wait but operating system not supported") else: logger.info('Shutdown during wait') try: diff --git a/module/config/argument/args.json b/module/config/argument/args.json index a0bd144..a221e0a 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -130,6 +130,7 @@ "goto_main", "close_game", "exit_aas", + "exit_emulator", "exit_aas_emulator", "shutdown" ] diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index e27fe1e..a09333d 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -71,7 +71,7 @@ Optimization: CombatScreenshotInterval: 1.0 WhenTaskQueueEmpty: value: goto_main - option: [ stay_there, goto_main, close_game, exit_aas, exit_aas_emulator, shutdown ] + option: [ stay_there, goto_main, close_game, exit_aas, exit_emulator, exit_aas_emulator, shutdown ] # ==================== Daily ==================== diff --git a/module/config/config_generated.py b/module/config/config_generated.py index ae27721..849eff6 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -37,7 +37,7 @@ class GeneratedConfig: # Group `Optimization` Optimization_ScreenshotInterval = 0.3 Optimization_CombatScreenshotInterval = 1.0 - Optimization_WhenTaskQueueEmpty = 'goto_main' # stay_there, goto_main, close_game, exit_aas, exit_aas_emulator, shutdown + Optimization_WhenTaskQueueEmpty = 'goto_main' # stay_there, goto_main, close_game, exit_aas, exit_emulator, exit_aas_emulator, shutdown # Group `Cafe` Cafe_Reward = True diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index c14d8ee..a7c4f65 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -221,11 +221,12 @@ }, "WhenTaskQueueEmpty": { "name": "When Task Queue is Empty", - "help": "Close AL when there are no pending tasks, can help reduce CPU", + "help": "Close Blue Archive when there are no pending tasks, can help reduce CPU.\nExit AAS, emulator and shutdown should be set while AAS is running tasks otherwise it won't start.\nExit AAS and emulator are only available on Windows.\nExit emulator is only possible if instance name and emulator path follow the same auto-filled values according to 'Serial' in Emulator Settings", "stay_there": "Stay There", "goto_main": "Goto Main Page", "close_game": "Close Game", "exit_aas": "Exit AAS", + "exit_emulator": "Exit Emulator", "exit_aas_emulator": "Exit AAS & Emulator", "shutdown": "Shutdown" } diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index bb1425a..925b396 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -226,6 +226,7 @@ "goto_main": "前往主界面", "close_game": "关闭游戏", "exit_aas": "exit_aas", + "exit_emulator": "exit_emulator", "exit_aas_emulator": "exit_aas_emulator", "shutdown": "shutdown" }