diff --git a/app/setting_interface.py b/app/setting_interface.py index d39470b1..24b64380 100644 --- a/app/setting_interface.py +++ b/app/setting_interface.py @@ -280,6 +280,23 @@ def __initCard(self): "", "universe_enable" ) + fates = {} + for a in ["存护", "记忆", "虚无", "丰饶", "巡猎", "毁灭", "欢愉", "繁育", "智识"]: + fates[a] = a + self.universeFateCard = ComboBoxSettingCard2( + "universe_fate", + FIF.PIE_SINGLE, + self.tr('命途'), + '', + texts=fates + ) + self.universeDifficultyCard = RangeSettingCard1( + "universe_difficulty", + [1, 5], + FIF.HISTORY, + self.tr("难度"), + self.tr(""), + ) self.universeOperationModeCard = ComboBoxSettingCard2( "universe_operation_mode", FIF.COMMAND_PROMPT, @@ -579,6 +596,8 @@ def __initLayout(self): self.FightGroup.addSettingCard(self.FightRunTimeCard) self.UniverseGroup.addSettingCard(self.universeEnableCard) + self.UniverseGroup.addSettingCard(self.universeFateCard) + self.UniverseGroup.addSettingCard(self.universeDifficultyCard) self.UniverseGroup.addSettingCard(self.universeOperationModeCard) self.UniverseGroup.addSettingCard(self.universeTimeoutCard) self.UniverseGroup.addSettingCard(self.universeBonusEnableCard) diff --git a/assets/config/config.example.yaml b/assets/config/config.example.yaml index f6779c3e..14cced4f 100644 --- a/assets/config/config.example.yaml +++ b/assets/config/config.example.yaml @@ -127,6 +127,8 @@ universe_path: .\3rdparty\Auto_Simulated_Universe # 模拟宇宙路径,指向 universe_timeout: 20 # 模拟宇宙超时时间(单位:小时),设置脚本或程序的最长运行时间。 universe_requirements: false # 是否已安装模拟宇宙依赖。true 表示已安装,false 表示未安装或需要重新安装。 universe_timestamp: 0 # 上次运行模拟宇宙的时间戳,用于记录和控制运行频率。 +universe_fate: '巡猎' # 模拟宇宙使用的命途 +universe_difficulty: 4 # 模拟宇宙使用的难度 # 忘却之庭配置 forgottenhall_enable: false # 是否启用混沌回忆功能。true 开启,false 关闭。 diff --git a/module/config/asu_config.py b/module/config/asu_config.py new file mode 100644 index 00000000..52d878ce --- /dev/null +++ b/module/config/asu_config.py @@ -0,0 +1,30 @@ +import os +import shutil + +import yaml +from module.config import cfg + + +def auto_config(): + if not os.path.exists(os.path.join(cfg.universe_path, "info.yml")): + shutil.copyfile(os.path.join(cfg.universe_path, "info_example.yml"), os.path.join( + cfg.universe_path, "info.yml")) + with open(os.path.join(cfg.universe_path, "info.yml"), 'r', encoding='utf-8') as f: + info = yaml.safe_load(f) + if info['config']['fate'] != cfg.universe_fate or info['config']['difficulty'] != cfg.universe_difficulty: + info['config']['fate'] = cfg.universe_fate + info['config']['difficulty'] = cfg.universe_difficulty + with open(os.path.join(cfg.universe_path, "info.yml"), 'w', encoding='utf-8') as f: + yaml.dump(info, f, default_flow_style=False, + allow_unicode=True) + + +def reload_config_from_asu(): + file = os.path.join(cfg.universe_path, "info.yml") + if not os.path.exists(file): + return None + with open(file, 'r', encoding='utf-8') as f: + info = yaml.safe_load(f) + if info['config']['fate'] != cfg.universe_fate: + pass + # todo: save cfg memory/file and reload gui diff --git a/tasks/weekly/universe.py b/tasks/weekly/universe.py index ba3b665c..ab53a314 100644 --- a/tasks/weekly/universe.py +++ b/tasks/weekly/universe.py @@ -11,6 +11,7 @@ import time import sys import os +from module.config import asu_config class Universe: @@ -152,6 +153,8 @@ def start(nums=cfg.universe_count, save=True): # 进入黑塔办公室 screen.change_to('main') + asu_config.auto_config() + if Universe.start_calibration() and Universe.start_simulation(nums, save): return True @@ -182,6 +185,7 @@ def get_reward(): def gui(): if Universe.before_start(): if subprocess.run(["start", "gui.exe"], shell=True, check=True, cwd=cfg.universe_path, env=cfg.env): + asu_config.reload_config_from_asu() return True return False