Merge branch 'DLMS_dev' into dev
This commit is contained in:
@@ -33,6 +33,7 @@ import sys
|
||||
import shutil
|
||||
import re
|
||||
import base64
|
||||
import calendar
|
||||
from datetime import datetime, timedelta, date
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
@@ -387,9 +388,7 @@ class MaaUserConfig(LQConfig):
|
||||
self.Info_Mode = OptionsConfigItem(
|
||||
"Info", "Mode", "简洁", OptionsValidator(["简洁", "详细"])
|
||||
)
|
||||
self.Info_GameIdMode = OptionsConfigItem(
|
||||
"Info", "GameIdMode", "固定", OptionsValidator(["固定"])
|
||||
)
|
||||
self.Info_GameIdMode = ConfigItem("Info", "GameIdMode", "固定")
|
||||
self.Info_Server = OptionsConfigItem(
|
||||
"Info", "Server", "Official", OptionsValidator(["Official", "Bilibili"])
|
||||
)
|
||||
@@ -435,7 +434,21 @@ class MaaUserConfig(LQConfig):
|
||||
"Data", "CustomInfrastPlanIndex", "0"
|
||||
)
|
||||
|
||||
# 新增用户单独通知字段
|
||||
self.Task_IfWakeUp = ConfigItem("Task", "IfWakeUp", True, BoolValidator())
|
||||
self.Task_IfRecruiting = ConfigItem(
|
||||
"Task", "IfRecruiting", True, BoolValidator()
|
||||
)
|
||||
self.Task_IfBase = ConfigItem("Task", "IfBase", True, BoolValidator())
|
||||
self.Task_IfCombat = ConfigItem("Task", "IfCombat", True, BoolValidator())
|
||||
self.Task_IfMall = ConfigItem("Task", "IfMall", True, BoolValidator())
|
||||
self.Task_IfMission = ConfigItem("Task", "IfMission", True, BoolValidator())
|
||||
self.Task_IfAutoRoguelike = ConfigItem(
|
||||
"Task", "IfAutoRoguelike", False, BoolValidator()
|
||||
)
|
||||
self.Task_IfReclamation = ConfigItem(
|
||||
"Task", "IfReclamation", False, BoolValidator()
|
||||
)
|
||||
|
||||
self.Notify_Enabled = ConfigItem("Notify", "Enabled", False, BoolValidator())
|
||||
self.Notify_IfSendStatistic = ConfigItem(
|
||||
"Notify", "IfSendStatistic", False, BoolValidator()
|
||||
@@ -460,6 +473,29 @@ class MaaUserConfig(LQConfig):
|
||||
"Notify", "CompanyWebHookBotUrl", ""
|
||||
)
|
||||
|
||||
def get_plan_info(self) -> Dict[str, Union[str, int]]:
|
||||
"""获取当前的计划下信息"""
|
||||
|
||||
if self.get(self.Info_GameIdMode) == "固定":
|
||||
return {
|
||||
"MedicineNumb": self.get(self.Info_MedicineNumb),
|
||||
"SeriesNumb": self.get(self.Info_SeriesNumb),
|
||||
"GameId": self.get(self.Info_GameId),
|
||||
"GameId_1": self.get(self.Info_GameId_1),
|
||||
"GameId_2": self.get(self.Info_GameId_2),
|
||||
"GameId_Remain": self.get(self.Info_GameId_Remain),
|
||||
}
|
||||
elif "计划" in self.get(self.Info_GameIdMode):
|
||||
plan = Config.plan_dict[self.get(self.Info_GameIdMode)]["Config"]
|
||||
return {
|
||||
"MedicineNumb": plan.get(plan.get_current_info("MedicineNumb")),
|
||||
"SeriesNumb": plan.get(plan.get_current_info("SeriesNumb")),
|
||||
"GameId": plan.get(plan.get_current_info("GameId")),
|
||||
"GameId_1": plan.get(plan.get_current_info("GameId_1")),
|
||||
"GameId_2": plan.get(plan.get_current_info("GameId_2")),
|
||||
"GameId_Remain": plan.get(plan.get_current_info("GameId_Remain")),
|
||||
}
|
||||
|
||||
|
||||
class MaaPlanConfig(LQConfig):
|
||||
"""MAA计划表配置"""
|
||||
@@ -467,119 +503,66 @@ class MaaPlanConfig(LQConfig):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.Info_Name = ConfigItem("Info", "Name", "新表格")
|
||||
self.Info_Name = ConfigItem("Info", "Name", "")
|
||||
self.Info_Mode = OptionsConfigItem(
|
||||
"Info", "Mode", "ALL", OptionsValidator(["ALL", "Weekly"])
|
||||
)
|
||||
|
||||
self.Global_MedicineNumb = ConfigItem(
|
||||
"Global", "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.Global_SeriesNumb = OptionsConfigItem(
|
||||
"Global",
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.Global_GameId = ConfigItem("Global", "GameId", "-")
|
||||
self.Global_GameId_1 = ConfigItem("Global", "GameId_1", "-")
|
||||
self.Global_GameId_2 = ConfigItem("Global", "GameId_2", "-")
|
||||
self.Global_GameId_Remain = ConfigItem("Global", "GameId_Remain", "-")
|
||||
self.config_item_dict: dict[str, Dict[str, ConfigItem]] = {}
|
||||
|
||||
self.Monday_MedicineNumb = ConfigItem(
|
||||
"Monday", "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.Monday_SeriesNumb = OptionsConfigItem(
|
||||
for group in [
|
||||
"ALL",
|
||||
"Monday",
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.Monday_GameId = ConfigItem("Monday", "GameId", "-")
|
||||
self.Monday_GameId_1 = ConfigItem("Monday", "GameId_1", "-")
|
||||
self.Monday_GameId_2 = ConfigItem("Monday", "GameId_2", "-")
|
||||
self.Monday_GameId_Remain = ConfigItem("Monday", "GameId_Remain", "-")
|
||||
|
||||
self.Tuesday_MedicineNumb = ConfigItem(
|
||||
"Tuesday", "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.Tuesday_SeriesNumb = OptionsConfigItem(
|
||||
"Tuesday",
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.Tuesday_GameId = ConfigItem("Tuesday", "GameId", "-")
|
||||
self.Tuesday_GameId_1 = ConfigItem("Tuesday", "GameId_1", "-")
|
||||
self.Tuesday_GameId_2 = ConfigItem("Tuesday", "GameId_2", "-")
|
||||
self.Tuesday_GameId_Remain = ConfigItem("Tuesday", "GameId_Remain", "-")
|
||||
|
||||
self.Wednesday_MedicineNumb = ConfigItem(
|
||||
"Wednesday", "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.Wednesday_SeriesNumb = OptionsConfigItem(
|
||||
"Wednesday",
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.Wednesday_GameId = ConfigItem("Wednesday", "GameId", "-")
|
||||
self.Wednesday_GameId_1 = ConfigItem("Wednesday", "GameId_1", "-")
|
||||
self.Wednesday_GameId_2 = ConfigItem("Wednesday", "GameId_2", "-")
|
||||
self.Wednesday_GameId_Remain = ConfigItem("Wednesday", "GameId_Remain", "-")
|
||||
|
||||
self.Thursday_MedicineNumb = ConfigItem(
|
||||
"Thursday", "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.Thursday_SeriesNumb = OptionsConfigItem(
|
||||
"Thursday",
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.Thursday_GameId = ConfigItem("Thursday", "GameId", "-")
|
||||
self.Thursday_GameId_1 = ConfigItem("Thursday", "GameId_1", "-")
|
||||
self.Thursday_GameId_2 = ConfigItem("Thursday", "GameId_2", "-")
|
||||
self.Thursday_GameId_Remain = ConfigItem("Thursday", "GameId_Remain", "-")
|
||||
|
||||
self.Friday_MedicineNumb = ConfigItem(
|
||||
"Friday", "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.Friday_SeriesNumb = OptionsConfigItem(
|
||||
"Friday",
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.Friday_GameId = ConfigItem("Friday", "GameId", "-")
|
||||
self.Friday_GameId_1 = ConfigItem("Friday", "GameId_1", "-")
|
||||
self.Friday_GameId_2 = ConfigItem("Friday", "GameId_2", "-")
|
||||
self.Friday_GameId_Remain = ConfigItem("Friday", "GameId_Remain", "-")
|
||||
|
||||
self.Saturday_MedicineNumb = ConfigItem(
|
||||
"Saturday", "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.Saturday_SeriesNumb = OptionsConfigItem(
|
||||
"Saturday",
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.Saturday_GameId = ConfigItem("Saturday", "GameId", "-")
|
||||
self.Saturday_GameId_1 = ConfigItem("Saturday", "GameId_1", "-")
|
||||
self.Saturday_GameId_2 = ConfigItem("Saturday", "GameId_2", "-")
|
||||
self.Saturday_GameId_Remain = ConfigItem("Saturday", "GameId_Remain", "-")
|
||||
|
||||
self.Sunday_MedicineNumb = ConfigItem(
|
||||
"Sunday", "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.Sunday_SeriesNumb = OptionsConfigItem(
|
||||
"Sunday",
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.Sunday_GameId = ConfigItem("Sunday", "GameId", "-")
|
||||
self.Sunday_GameId_1 = ConfigItem("Sunday", "GameId_1", "-")
|
||||
self.Sunday_GameId_2 = ConfigItem("Sunday", "GameId_2", "-")
|
||||
self.Sunday_GameId_Remain = ConfigItem("Sunday", "GameId_Remain", "-")
|
||||
]:
|
||||
self.config_item_dict[group] = {}
|
||||
|
||||
self.config_item_dict[group]["MedicineNumb"] = ConfigItem(
|
||||
group, "MedicineNumb", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
self.config_item_dict[group]["SeriesNumb"] = OptionsConfigItem(
|
||||
group,
|
||||
"SeriesNumb",
|
||||
"0",
|
||||
OptionsValidator(["0", "6", "5", "4", "3", "2", "1", "-1"]),
|
||||
)
|
||||
self.config_item_dict[group]["GameId"] = ConfigItem(group, "GameId", "-")
|
||||
self.config_item_dict[group]["GameId_1"] = ConfigItem(
|
||||
group, "GameId_1", "-"
|
||||
)
|
||||
self.config_item_dict[group]["GameId_2"] = ConfigItem(
|
||||
group, "GameId_2", "-"
|
||||
)
|
||||
self.config_item_dict[group]["GameId_Remain"] = ConfigItem(
|
||||
group, "GameId_Remain", "-"
|
||||
)
|
||||
|
||||
for name in [
|
||||
"MedicineNumb",
|
||||
"SeriesNumb",
|
||||
"GameId",
|
||||
"GameId_1",
|
||||
"GameId_2",
|
||||
"GameId_Remain",
|
||||
]:
|
||||
setattr(self, f"{group}_{name}", self.config_item_dict[group][name])
|
||||
|
||||
def get_current_info(self, name: str) -> ConfigItem:
|
||||
"""获取当前的计划表配置项"""
|
||||
|
||||
if self.get(self.Info_Mode) == "ALL":
|
||||
return self.config_item_dict["ALL"][name]
|
||||
elif self.get(self.Info_Mode) == "Weekly":
|
||||
today = datetime.now().strftime("%A")
|
||||
if today in self.config_item_dict:
|
||||
return self.config_item_dict[today][name]
|
||||
else:
|
||||
return self.config_item_dict["ALL"][name]
|
||||
|
||||
|
||||
class AppConfig(GlobalConfig):
|
||||
@@ -610,7 +593,13 @@ class AppConfig(GlobalConfig):
|
||||
self.silence_list = []
|
||||
self.gameid_dict = {
|
||||
"ALL": {"value": [], "text": []},
|
||||
"Today": {"value": [], "text": []},
|
||||
"Monday": {"value": [], "text": []},
|
||||
"Tuesday": {"value": [], "text": []},
|
||||
"Wednesday": {"value": [], "text": []},
|
||||
"Thursday": {"value": [], "text": []},
|
||||
"Friday": {"value": [], "text": []},
|
||||
"Saturday": {"value": [], "text": []},
|
||||
"Sunday": {"value": [], "text": []},
|
||||
}
|
||||
self.power_sign = "NoAction"
|
||||
self.if_ignore_silence = False
|
||||
@@ -676,7 +665,7 @@ class AppConfig(GlobalConfig):
|
||||
logger.warning(f"无法从MAA服务器获取活动关卡信息:{Network.error_message}")
|
||||
gameid_infos = []
|
||||
|
||||
gameid_dict = {"value": [], "text": []}
|
||||
ss_gameid_dict = {"value": [], "text": []}
|
||||
|
||||
for gameid_info in gameid_infos:
|
||||
|
||||
@@ -689,53 +678,11 @@ class AppConfig(GlobalConfig):
|
||||
gameid_info["Activity"]["UtcExpireTime"], "%Y/%m/%d %H:%M:%S"
|
||||
)
|
||||
):
|
||||
gameid_dict["value"].append(gameid_info["Value"])
|
||||
gameid_dict["text"].append(gameid_info["Value"])
|
||||
ss_gameid_dict["value"].append(gameid_info["Value"])
|
||||
ss_gameid_dict["text"].append(gameid_info["Value"])
|
||||
|
||||
# 生成全部关卡信息
|
||||
self.gameid_dict["ALL"]["value"] = gameid_dict["value"] + [
|
||||
"-",
|
||||
"1-7",
|
||||
"R8-11",
|
||||
"12-17-HARD",
|
||||
"CE-6",
|
||||
"AP-5",
|
||||
"CA-5",
|
||||
"LS-6",
|
||||
"SK-5",
|
||||
"PR-A-1",
|
||||
"PR-A-2",
|
||||
"PR-B-1",
|
||||
"PR-B-2",
|
||||
"PR-C-1",
|
||||
"PR-C-2",
|
||||
"PR-D-1",
|
||||
"PR-D-2",
|
||||
]
|
||||
self.gameid_dict["ALL"]["text"] = gameid_dict["text"] + [
|
||||
"当前/上次",
|
||||
"1-7",
|
||||
"R8-11",
|
||||
"12-17-HARD",
|
||||
"龙门币-6/5",
|
||||
"红票-5",
|
||||
"技能-5",
|
||||
"经验-6/5",
|
||||
"碳-5",
|
||||
"奶/盾芯片",
|
||||
"奶/盾芯片组",
|
||||
"术/狙芯片",
|
||||
"术/狙芯片组",
|
||||
"先/辅芯片",
|
||||
"先/辅芯片组",
|
||||
"近/特芯片",
|
||||
"近/特芯片组",
|
||||
]
|
||||
|
||||
# 生成本日关卡信息
|
||||
days = self.server_date().isoweekday()
|
||||
|
||||
gameid_list = [
|
||||
# 生成每日关卡信息
|
||||
gameid_daily_info = [
|
||||
{"value": "-", "text": "当前/上次", "days": [1, 2, 3, 4, 5, 6, 7]},
|
||||
{"value": "1-7", "text": "1-7", "days": [1, 2, 3, 4, 5, 6, 7]},
|
||||
{"value": "R8-11", "text": "R8-11", "days": [1, 2, 3, 4, 5, 6, 7]},
|
||||
@@ -759,12 +706,20 @@ class AppConfig(GlobalConfig):
|
||||
{"value": "PR-D-2", "text": "近/特芯片组", "days": [2, 3, 6, 7]},
|
||||
]
|
||||
|
||||
for gameid_info in gameid_list:
|
||||
if days in gameid_info["days"]:
|
||||
gameid_dict["value"].append(gameid_info["value"])
|
||||
gameid_dict["text"].append(gameid_info["text"])
|
||||
for day in range(0, 8):
|
||||
|
||||
self.gameid_dict["Today"] = gameid_dict
|
||||
today_gameid_dict = {"value": [], "text": []}
|
||||
|
||||
for gameid_info in gameid_daily_info:
|
||||
|
||||
if day in gameid_info["days"] or day == 0:
|
||||
today_gameid_dict["value"].append(gameid_info["value"])
|
||||
today_gameid_dict["text"].append(gameid_info["text"])
|
||||
|
||||
self.gameid_dict[calendar.day_name[day - 1] if day > 0 else "ALL"] = {
|
||||
"value": today_gameid_dict["value"] + ss_gameid_dict["value"],
|
||||
"text": today_gameid_dict["text"] + ss_gameid_dict["text"],
|
||||
}
|
||||
|
||||
self.gameid_refreshed.emit()
|
||||
|
||||
@@ -1207,7 +1162,7 @@ class AppConfig(GlobalConfig):
|
||||
maa_plan_config.load(maa_plan_dir / "config.json", maa_plan_config)
|
||||
maa_plan_config.save()
|
||||
|
||||
self.member_dict[maa_plan_dir.name] = {
|
||||
self.plan_dict[maa_plan_dir.name] = {
|
||||
"Type": "Maa",
|
||||
"Path": maa_plan_dir,
|
||||
"Config": maa_plan_config,
|
||||
@@ -1264,6 +1219,16 @@ class AppConfig(GlobalConfig):
|
||||
if queue["Config"].get(queue["Config"].queue_Member_10) == old:
|
||||
queue["Config"].set(queue["Config"].queue_Member_10, new)
|
||||
|
||||
def change_plan(self, old: str, new: str) -> None:
|
||||
"""修改脚本管理所有下属用户的计划表配置参数"""
|
||||
|
||||
for member in self.member_dict.values():
|
||||
|
||||
for user in member["UserData"].values():
|
||||
|
||||
if user["Config"].get(user["Config"].Info_GameIdMode) == old:
|
||||
user["Config"].set(user["Config"].Info_GameIdMode, new)
|
||||
|
||||
def change_user_info(
|
||||
self, name: str, user_data: Dict[str, Dict[str, Union[str, Path, dict]]]
|
||||
) -> None:
|
||||
|
||||
@@ -29,6 +29,7 @@ from loguru import logger
|
||||
from PySide6.QtWidgets import QWidget
|
||||
from PySide6.QtCore import QTimer
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import pyautogui
|
||||
|
||||
from .config import Config
|
||||
@@ -97,6 +98,16 @@ class _MainTimer(QWidget):
|
||||
):
|
||||
|
||||
windows = System.get_window_info()
|
||||
|
||||
# 排除雷电名为新通知的窗口
|
||||
windows = [
|
||||
window
|
||||
for window in windows
|
||||
if not (
|
||||
window[0] == "新通知" and Path(window[1]) in Config.silence_list
|
||||
)
|
||||
]
|
||||
|
||||
if any(
|
||||
str(emulator_path) in window
|
||||
for window in windows
|
||||
|
||||
@@ -102,6 +102,9 @@ class MaaManager(QObject):
|
||||
"Path": info["Path"],
|
||||
"Config": info["Config"].toDict(),
|
||||
}
|
||||
planed_info = info["Config"].get_plan_info()
|
||||
for key, value in planed_info.items():
|
||||
self.data[name]["Config"]["Info"][key] = value
|
||||
|
||||
self.data = dict(sorted(self.data.items(), key=lambda x: int(x[0][3:])))
|
||||
|
||||
@@ -271,9 +274,23 @@ class MaaManager(QObject):
|
||||
)
|
||||
|
||||
# 解析任务构成
|
||||
if user_data["Info"]["Mode"] == "简洁":
|
||||
if mode == "Routine":
|
||||
|
||||
self.task_dict = {
|
||||
"WakeUp": str(user_data["Task"]["IfWakeUp"]),
|
||||
"Recruiting": str(user_data["Task"]["IfRecruiting"]),
|
||||
"Base": str(user_data["Task"]["IfBase"]),
|
||||
"Combat": str(user_data["Task"]["IfCombat"]),
|
||||
"Mission": str(user_data["Task"]["IfMission"]),
|
||||
"Mall": str(user_data["Task"]["IfMall"]),
|
||||
"AutoRoguelike": str(user_data["Task"]["IfAutoRoguelike"]),
|
||||
"Reclamation": str(user_data["Task"]["IfReclamation"]),
|
||||
}
|
||||
|
||||
elif mode == "Annihilation":
|
||||
|
||||
if user_data["Info"]["Mode"] == "简洁":
|
||||
|
||||
if mode == "Annihilation":
|
||||
self.task_dict = {
|
||||
"WakeUp": "True",
|
||||
"Recruiting": "False",
|
||||
@@ -285,52 +302,40 @@ class MaaManager(QObject):
|
||||
"Reclamation": "False",
|
||||
}
|
||||
|
||||
elif mode == "Routine":
|
||||
elif user_data["Info"]["Mode"] == "详细":
|
||||
|
||||
with (self.data[user[2]]["Path"] / f"{mode}/gui.json").open(
|
||||
mode="r", encoding="utf-8"
|
||||
) as f:
|
||||
data = json.load(f)
|
||||
|
||||
self.task_dict = {
|
||||
"WakeUp": "True",
|
||||
"Recruiting": "True",
|
||||
"Base": "True",
|
||||
"Combat": "True",
|
||||
"Mission": "True",
|
||||
"Mall": "True",
|
||||
"AutoRoguelike": "False",
|
||||
"Reclamation": "False",
|
||||
"WakeUp": data["Configurations"]["Default"][
|
||||
"TaskQueue.WakeUp.IsChecked"
|
||||
],
|
||||
"Recruiting": data["Configurations"]["Default"][
|
||||
"TaskQueue.Recruiting.IsChecked"
|
||||
],
|
||||
"Base": data["Configurations"]["Default"][
|
||||
"TaskQueue.Base.IsChecked"
|
||||
],
|
||||
"Combat": data["Configurations"]["Default"][
|
||||
"TaskQueue.Combat.IsChecked"
|
||||
],
|
||||
"Mission": data["Configurations"]["Default"][
|
||||
"TaskQueue.Mission.IsChecked"
|
||||
],
|
||||
"Mall": data["Configurations"]["Default"][
|
||||
"TaskQueue.Mall.IsChecked"
|
||||
],
|
||||
"AutoRoguelike": data["Configurations"]["Default"][
|
||||
"TaskQueue.AutoRoguelike.IsChecked"
|
||||
],
|
||||
"Reclamation": data["Configurations"]["Default"][
|
||||
"TaskQueue.Reclamation.IsChecked"
|
||||
],
|
||||
}
|
||||
|
||||
elif user_data["Info"]["Mode"] == "详细":
|
||||
|
||||
with (self.data[user[2]]["Path"] / f"{mode}/gui.json").open(
|
||||
mode="r", encoding="utf-8"
|
||||
) as f:
|
||||
data = json.load(f)
|
||||
|
||||
self.task_dict = {
|
||||
"WakeUp": data["Configurations"]["Default"][
|
||||
"TaskQueue.WakeUp.IsChecked"
|
||||
],
|
||||
"Recruiting": data["Configurations"]["Default"][
|
||||
"TaskQueue.Recruiting.IsChecked"
|
||||
],
|
||||
"Base": data["Configurations"]["Default"][
|
||||
"TaskQueue.Base.IsChecked"
|
||||
],
|
||||
"Combat": data["Configurations"]["Default"][
|
||||
"TaskQueue.Combat.IsChecked"
|
||||
],
|
||||
"Mission": data["Configurations"]["Default"][
|
||||
"TaskQueue.Mission.IsChecked"
|
||||
],
|
||||
"Mall": data["Configurations"]["Default"][
|
||||
"TaskQueue.Mall.IsChecked"
|
||||
],
|
||||
"AutoRoguelike": data["Configurations"]["Default"][
|
||||
"TaskQueue.AutoRoguelike.IsChecked"
|
||||
],
|
||||
"Reclamation": data["Configurations"]["Default"][
|
||||
"TaskQueue.Reclamation.IsChecked"
|
||||
],
|
||||
}
|
||||
|
||||
# 尝试次数循环
|
||||
for i in range(self.set["RunSet"]["RunTimesLimit"]):
|
||||
|
||||
@@ -564,9 +569,6 @@ class MaaManager(QObject):
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
# 移除静默进程标记
|
||||
Config.silence_list.remove(self.emulator_path)
|
||||
|
||||
# 任务结束后释放ADB
|
||||
try:
|
||||
subprocess.run(
|
||||
@@ -905,6 +907,9 @@ class MaaManager(QObject):
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
# 移除静默进程标记
|
||||
Config.silence_list.remove(self.emulator_path)
|
||||
|
||||
if "-" in self.ADB_address:
|
||||
ADB_ip = f"{self.ADB_address.split("-")[0]}-"
|
||||
ADB_port = int(self.ADB_address.split("-")[1])
|
||||
@@ -1272,6 +1277,9 @@ class MaaManager(QObject):
|
||||
]["Id"]
|
||||
|
||||
# 按预设设定任务
|
||||
data["Configurations"]["Default"][
|
||||
"TaskQueue.WakeUp.IsChecked"
|
||||
] = "True" # 开始唤醒
|
||||
data["Configurations"]["Default"]["TaskQueue.Recruiting.IsChecked"] = (
|
||||
self.task_dict["Recruiting"]
|
||||
) # 自动公招
|
||||
@@ -1296,10 +1304,6 @@ class MaaManager(QObject):
|
||||
|
||||
if user_data["Info"]["Mode"] == "简洁":
|
||||
|
||||
data["Configurations"]["Default"][
|
||||
"TaskQueue.WakeUp.IsChecked"
|
||||
] = "True" # 开始唤醒
|
||||
|
||||
data["Configurations"]["Default"]["Start.ClientType"] = user_data[
|
||||
"Info"
|
||||
][
|
||||
|
||||
@@ -254,7 +254,7 @@ class Notification(QWidget):
|
||||
self.push_info_bar.emit(
|
||||
"error",
|
||||
"企业微信群机器人通知推送失败",
|
||||
f'使用企业微信群机器人推送通知时出错:{info["errmsg"]}',
|
||||
f"使用企业微信群机器人推送通知时出错:{err}",
|
||||
-1,
|
||||
)
|
||||
return None
|
||||
@@ -267,10 +267,10 @@ class Notification(QWidget):
|
||||
self.push_info_bar.emit(
|
||||
"error",
|
||||
"企业微信群机器人通知推送失败",
|
||||
f'使用企业微信群机器人推送通知时出错:{info["errmsg"]}',
|
||||
f"使用企业微信群机器人推送通知时出错:{err}",
|
||||
-1,
|
||||
)
|
||||
return f'使用企业微信群机器人推送通知时出错:{info["errmsg"]}'
|
||||
return f"使用企业微信群机器人推送通知时出错:{err}"
|
||||
|
||||
def send_test_notification(self):
|
||||
"""发送测试通知到所有已启用的通知渠道"""
|
||||
|
||||
546
app/ui/Widget.py
546
app/ui/Widget.py
@@ -82,6 +82,7 @@ from qfluentwidgets import (
|
||||
Pivot,
|
||||
PivotItem,
|
||||
FlyoutViewBase,
|
||||
PushSettingCard,
|
||||
)
|
||||
from qfluentwidgets.common.overload import singledispatchmethod
|
||||
|
||||
@@ -306,6 +307,8 @@ class SettingFlyoutView(FlyoutViewBase):
|
||||
self.viewLayout.addWidget(self.title)
|
||||
self.viewLayout.addWidget(scrollArea)
|
||||
|
||||
self.setVisible(False)
|
||||
|
||||
|
||||
class SwitchSettingCard(SettingCard):
|
||||
"""Setting card with switch button"""
|
||||
@@ -477,7 +480,7 @@ class LineEditSettingCard(SettingCard):
|
||||
|
||||
def __textChanged(self, content: str):
|
||||
|
||||
self.configItem.valueChanged.disconnect()
|
||||
self.configItem.valueChanged.disconnect(self.setValue)
|
||||
self.qconfig.set(self.configItem, content.strip())
|
||||
self.configItem.valueChanged.connect(self.setValue)
|
||||
|
||||
@@ -485,7 +488,7 @@ class LineEditSettingCard(SettingCard):
|
||||
|
||||
def setValue(self, content: str):
|
||||
|
||||
self.LineEdit.textChanged.disconnect()
|
||||
self.LineEdit.textChanged.disconnect(self.__textChanged)
|
||||
self.LineEdit.setText(content.strip())
|
||||
self.LineEdit.textChanged.connect(self.__textChanged)
|
||||
|
||||
@@ -527,7 +530,7 @@ class PasswordLineEditSettingCard(SettingCard):
|
||||
|
||||
def __textChanged(self, content: str):
|
||||
|
||||
self.configItem.valueChanged.disconnect()
|
||||
self.configItem.valueChanged.disconnect(self.setValue)
|
||||
if self.algorithm == "DPAPI":
|
||||
self.qconfig.set(self.configItem, Crypto.win_encryptor(content))
|
||||
elif self.algorithm == "AUTO":
|
||||
@@ -538,7 +541,7 @@ class PasswordLineEditSettingCard(SettingCard):
|
||||
|
||||
def setValue(self, content: str):
|
||||
|
||||
self.LineEdit.textChanged.disconnect()
|
||||
self.LineEdit.textChanged.disconnect(self.__textChanged)
|
||||
if self.algorithm == "DPAPI":
|
||||
self.LineEdit.setText(Crypto.win_decryptor(content))
|
||||
elif self.algorithm == "AUTO":
|
||||
@@ -557,57 +560,6 @@ class PasswordLineEditSettingCard(SettingCard):
|
||||
self.LineEdit.textChanged.connect(self.__textChanged)
|
||||
|
||||
|
||||
class UserLableSettingCard(SettingCard):
|
||||
"""Setting card with User's Lable"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
qconfig: QConfig,
|
||||
configItems: Dict[str, ConfigItem],
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItems = configItems
|
||||
self.Lable = SubtitleLabel(self)
|
||||
|
||||
if configItems:
|
||||
for configItem in configItems.values():
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
self.setValue()
|
||||
|
||||
self.hBoxLayout.addWidget(self.Lable, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
def setValue(self):
|
||||
if self.configItems:
|
||||
|
||||
text_list = []
|
||||
if not self.qconfig.get(self.configItems["IfPassCheck"]):
|
||||
text_list.append("未通过人工排查")
|
||||
text_list.append(
|
||||
f"今日已代理{self.qconfig.get(self.configItems["ProxyTimes"])}次"
|
||||
if Config.server_date().strftime("%Y-%m-%d")
|
||||
== self.qconfig.get(self.configItems["LastProxyDate"])
|
||||
else "今日未进行代理"
|
||||
)
|
||||
text_list.append(
|
||||
"本周剿灭已完成"
|
||||
if datetime.strptime(
|
||||
self.qconfig.get(self.configItems["LastAnnihilationDate"]),
|
||||
"%Y-%m-%d",
|
||||
).isocalendar()[:2]
|
||||
== Config.server_date().isocalendar()[:2]
|
||||
else "本周剿灭未完成"
|
||||
)
|
||||
|
||||
self.Lable.setText(" | ".join(text_list))
|
||||
|
||||
|
||||
class PushAndSwitchButtonSettingCard(SettingCard):
|
||||
"""Setting card with push & switch button"""
|
||||
|
||||
@@ -756,7 +708,7 @@ class NoOptionComboBoxSettingCard(SettingCard):
|
||||
value: List[str],
|
||||
texts: List[str],
|
||||
qconfig: QConfig,
|
||||
configItem: OptionsConfigItem,
|
||||
configItem: ConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
@@ -789,7 +741,7 @@ class NoOptionComboBoxSettingCard(SettingCard):
|
||||
|
||||
def reLoadOptions(self, value: List[str], texts: List[str]):
|
||||
|
||||
self.comboBox.currentIndexChanged.disconnect()
|
||||
self.comboBox.currentIndexChanged.disconnect(self._onCurrentIndexChanged)
|
||||
self.comboBox.clear()
|
||||
self.optionToText = {o: t for o, t in zip(value, texts)}
|
||||
for text, option in zip(texts, value):
|
||||
@@ -811,7 +763,7 @@ class EditableComboBoxSettingCard(SettingCard):
|
||||
value: List[str],
|
||||
texts: List[str],
|
||||
qconfig: QConfig,
|
||||
configItem: OptionsConfigItem,
|
||||
configItem: ConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
@@ -861,7 +813,7 @@ class EditableComboBoxSettingCard(SettingCard):
|
||||
|
||||
def reLoadOptions(self, value: List[str], texts: List[str]):
|
||||
|
||||
self.comboBox.currentIndexChanged.disconnect()
|
||||
self.comboBox.currentIndexChanged.disconnect(self._onCurrentIndexChanged)
|
||||
self.comboBox.clear()
|
||||
self.optionToText = {o: t for o, t in zip(value, texts)}
|
||||
for text, option in zip(texts, value):
|
||||
@@ -899,6 +851,169 @@ class EditableComboBoxSettingCard(SettingCard):
|
||||
self.currentIndexChanged.emit(self.count() - 1)
|
||||
|
||||
|
||||
class SpinBoxWithPlanSettingCard(SpinBoxSettingCard):
|
||||
|
||||
textChanged = Signal(int)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
range: tuple[int, int],
|
||||
qconfig: QConfig,
|
||||
configItem: ConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, range, qconfig, configItem, parent)
|
||||
|
||||
self.configItem_plan = None
|
||||
|
||||
self.LineEdit = LineEdit(self)
|
||||
self.LineEdit.setMinimumWidth(150)
|
||||
self.LineEdit.setReadOnly(True)
|
||||
self.LineEdit.setVisible(False)
|
||||
|
||||
self.hBoxLayout.insertWidget(5, self.LineEdit, 0, Qt.AlignRight)
|
||||
|
||||
def setText(self, value: int) -> None:
|
||||
self.LineEdit.setText(str(value))
|
||||
|
||||
def switch_mode(self, mode: str) -> None:
|
||||
"""切换模式"""
|
||||
|
||||
if mode == "固定":
|
||||
|
||||
self.LineEdit.setVisible(False)
|
||||
self.SpinBox.setVisible(True)
|
||||
|
||||
elif mode == "计划":
|
||||
|
||||
self.SpinBox.setVisible(False)
|
||||
self.LineEdit.setVisible(True)
|
||||
|
||||
def change_plan(self, configItem_plan: ConfigItem) -> None:
|
||||
"""切换计划"""
|
||||
|
||||
if self.configItem_plan is not None:
|
||||
self.configItem_plan.valueChanged.disconnect(self.setText)
|
||||
self.configItem_plan = configItem_plan
|
||||
self.configItem_plan.valueChanged.connect(self.setText)
|
||||
self.setText(self.qconfig.get(self.configItem_plan))
|
||||
|
||||
|
||||
class ComboBoxWithPlanSettingCard(ComboBoxSettingCard):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
texts: List[str],
|
||||
qconfig: QConfig,
|
||||
configItem: OptionsConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, texts, qconfig, configItem, parent)
|
||||
|
||||
self.configItem_plan = None
|
||||
|
||||
self.LineEdit = LineEdit(self)
|
||||
self.LineEdit.setMinimumWidth(150)
|
||||
self.LineEdit.setReadOnly(True)
|
||||
self.LineEdit.setVisible(False)
|
||||
|
||||
self.hBoxLayout.insertWidget(5, self.LineEdit, 0, Qt.AlignRight)
|
||||
|
||||
def setText(self, value: str) -> None:
|
||||
|
||||
if value not in self.optionToText:
|
||||
self.optionToText[value] = value
|
||||
|
||||
self.LineEdit.setText(self.optionToText[value])
|
||||
|
||||
def switch_mode(self, mode: str) -> None:
|
||||
"""切换模式"""
|
||||
|
||||
if mode == "固定":
|
||||
|
||||
self.LineEdit.setVisible(False)
|
||||
self.comboBox.setVisible(True)
|
||||
|
||||
elif mode == "计划":
|
||||
|
||||
self.comboBox.setVisible(False)
|
||||
self.LineEdit.setVisible(True)
|
||||
|
||||
def change_plan(self, configItem_plan: ConfigItem) -> None:
|
||||
"""切换计划"""
|
||||
|
||||
if self.configItem_plan is not None:
|
||||
self.configItem_plan.valueChanged.disconnect(self.setText)
|
||||
self.configItem_plan = configItem_plan
|
||||
self.configItem_plan.valueChanged.connect(self.setText)
|
||||
self.setText(self.qconfig.get(self.configItem_plan))
|
||||
|
||||
|
||||
class EditableComboBoxWithPlanSettingCard(EditableComboBoxSettingCard):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
value: List[str],
|
||||
texts: List[str],
|
||||
qconfig: QConfig,
|
||||
configItem: ConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(
|
||||
icon, title, content, value, texts, qconfig, configItem, parent
|
||||
)
|
||||
|
||||
self.configItem_plan = None
|
||||
|
||||
self.LineEdit = LineEdit(self)
|
||||
self.LineEdit.setMinimumWidth(150)
|
||||
self.LineEdit.setReadOnly(True)
|
||||
self.LineEdit.setVisible(False)
|
||||
|
||||
self.hBoxLayout.insertWidget(5, self.LineEdit, 0, Qt.AlignRight)
|
||||
|
||||
def setText(self, value: str) -> None:
|
||||
|
||||
if value not in self.optionToText:
|
||||
self.optionToText[value] = value
|
||||
|
||||
self.LineEdit.setText(self.optionToText[value])
|
||||
|
||||
def switch_mode(self, mode: str) -> None:
|
||||
"""切换模式"""
|
||||
|
||||
if mode == "固定":
|
||||
|
||||
self.LineEdit.setVisible(False)
|
||||
self.comboBox.setVisible(True)
|
||||
|
||||
elif mode == "计划":
|
||||
|
||||
self.comboBox.setVisible(False)
|
||||
self.LineEdit.setVisible(True)
|
||||
|
||||
def change_plan(self, configItem_plan: ConfigItem) -> None:
|
||||
"""切换计划"""
|
||||
|
||||
if self.configItem_plan is not None:
|
||||
self.configItem_plan.valueChanged.disconnect(self.setText)
|
||||
self.configItem_plan = configItem_plan
|
||||
self.configItem_plan.valueChanged.connect(self.setText)
|
||||
self.setText(self.qconfig.get(self.configItem_plan))
|
||||
|
||||
|
||||
class TimeEditSettingCard(SettingCard):
|
||||
|
||||
enabledChanged = Signal(bool)
|
||||
@@ -965,6 +1080,115 @@ class TimeEditSettingCard(SettingCard):
|
||||
self.TimeEdit.setTime(QTime.fromString(value, "HH:mm"))
|
||||
|
||||
|
||||
class UserLableSettingCard(SettingCard):
|
||||
"""Setting card with User's Lable"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
qconfig: QConfig,
|
||||
configItems: Dict[str, ConfigItem],
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItems = configItems
|
||||
self.Lable = SubtitleLabel(self)
|
||||
|
||||
if configItems:
|
||||
for configItem in configItems.values():
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
self.setValue()
|
||||
|
||||
self.hBoxLayout.addWidget(self.Lable, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
def setValue(self):
|
||||
|
||||
text_list = []
|
||||
|
||||
if self.configItems:
|
||||
|
||||
if not self.qconfig.get(self.configItems["IfPassCheck"]):
|
||||
text_list.append("未通过人工排查")
|
||||
text_list.append(
|
||||
f"今日已代理{self.qconfig.get(self.configItems["ProxyTimes"])}次"
|
||||
if Config.server_date().strftime("%Y-%m-%d")
|
||||
== self.qconfig.get(self.configItems["LastProxyDate"])
|
||||
else "今日未进行代理"
|
||||
)
|
||||
text_list.append(
|
||||
"本周剿灭已完成"
|
||||
if datetime.strptime(
|
||||
self.qconfig.get(self.configItems["LastAnnihilationDate"]),
|
||||
"%Y-%m-%d",
|
||||
).isocalendar()[:2]
|
||||
== Config.server_date().isocalendar()[:2]
|
||||
else "本周剿灭未完成"
|
||||
)
|
||||
|
||||
self.Lable.setText(" | ".join(text_list))
|
||||
|
||||
|
||||
class UserTaskSettingCard(PushSettingCard):
|
||||
"""Setting card with User's Task"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title: str,
|
||||
content: Union[str, None],
|
||||
text: str,
|
||||
qconfig: QConfig,
|
||||
configItems: Dict[str, ConfigItem],
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(text, icon, title, content, parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItems = configItems
|
||||
self.Lable = SubtitleLabel(self)
|
||||
|
||||
if configItems:
|
||||
for config_item in configItems.values():
|
||||
config_item.valueChanged.connect(self.setValues)
|
||||
self.setValues()
|
||||
|
||||
self.hBoxLayout.addWidget(self.Lable, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
def setValues(self):
|
||||
|
||||
text_list = []
|
||||
|
||||
if self.configItems:
|
||||
|
||||
if self.qconfig.get(self.configItems["IfWakeUp"]):
|
||||
text_list.append("开始唤醒")
|
||||
if self.qconfig.get(self.configItems["IfRecruiting"]):
|
||||
text_list.append("自动公招")
|
||||
if self.qconfig.get(self.configItems["IfBase"]):
|
||||
text_list.append("基建换班")
|
||||
if self.qconfig.get(self.configItems["IfCombat"]):
|
||||
text_list.append("刷理智")
|
||||
if self.qconfig.get(self.configItems["IfMall"]):
|
||||
text_list.append("获取信用及购物")
|
||||
if self.qconfig.get(self.configItems["IfMission"]):
|
||||
text_list.append("领取奖励")
|
||||
if self.qconfig.get(self.configItems["IfAutoRoguelike"]):
|
||||
text_list.append("自动肉鸽")
|
||||
if self.qconfig.get(self.configItems["IfReclamation"]):
|
||||
text_list.append("生息演算")
|
||||
|
||||
if text_list:
|
||||
self.setContent(f"任务序列:{" - ".join(text_list)}")
|
||||
else:
|
||||
self.setContent("未启用任何任务项")
|
||||
|
||||
|
||||
class UserNoticeSettingCard(PushAndSwitchButtonSettingCard):
|
||||
"""Setting card with User's Notice"""
|
||||
|
||||
@@ -1021,7 +1245,7 @@ class UserNoticeSettingCard(PushAndSwitchButtonSettingCard):
|
||||
# 普通字符串:末尾3字符
|
||||
return f"***{s[-3:]}" if len(s) > 3 else s
|
||||
|
||||
content_list = []
|
||||
text_list = []
|
||||
|
||||
if self.configItems:
|
||||
|
||||
@@ -1029,27 +1253,27 @@ class UserNoticeSettingCard(PushAndSwitchButtonSettingCard):
|
||||
self.qconfig.get(self.configItems["IfSendStatistic"])
|
||||
or self.qconfig.get(self.configItems["IfSendSixStar"])
|
||||
):
|
||||
content_list.append("未启用任何通知项")
|
||||
text_list.append("未启用任何通知项")
|
||||
|
||||
if self.qconfig.get(self.configItems["IfSendStatistic"]):
|
||||
content_list.append("统计信息已启用")
|
||||
text_list.append("统计信息已启用")
|
||||
if self.qconfig.get(self.configItems["IfSendSixStar"]):
|
||||
content_list.append("六星喜报已启用")
|
||||
text_list.append("六星喜报已启用")
|
||||
|
||||
if self.qconfig.get(self.configItems["IfSendMail"]):
|
||||
content_list.append(
|
||||
text_list.append(
|
||||
f"邮箱通知:{short_str(self.qconfig.get(self.configItems["ToAddress"]))}"
|
||||
)
|
||||
if self.qconfig.get(self.configItems["IfServerChan"]):
|
||||
content_list.append(
|
||||
text_list.append(
|
||||
f"Server酱通知:{short_str(self.qconfig.get(self.configItems["ServerChanKey"]))}"
|
||||
)
|
||||
if self.qconfig.get(self.configItems["IfCompanyWebHookBot"]):
|
||||
content_list.append(
|
||||
text_list.append(
|
||||
f"企业微信通知:{short_str(self.qconfig.get(self.configItems["CompanyWebHookBotUrl"]))}"
|
||||
)
|
||||
|
||||
self.setContent(" | ".join(content_list))
|
||||
self.setContent(" | ".join(text_list))
|
||||
|
||||
|
||||
class StatusSwitchSetting(SwitchButton):
|
||||
@@ -1084,6 +1308,190 @@ class StatusSwitchSetting(SwitchButton):
|
||||
self.setChecked(isChecked)
|
||||
|
||||
|
||||
class ComboBoxSetting(ComboBox):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
texts: List[str],
|
||||
qconfig: QConfig,
|
||||
configItem: OptionsConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItem = configItem
|
||||
|
||||
self.optionToText = {o: t for o, t in zip(configItem.options, texts)}
|
||||
for text, option in zip(texts, configItem.options):
|
||||
self.addItem(text, userData=option)
|
||||
|
||||
self.setCurrentText(self.optionToText[self.qconfig.get(configItem)])
|
||||
self.currentIndexChanged.connect(self._onCurrentIndexChanged)
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
|
||||
def _onCurrentIndexChanged(self, index: int):
|
||||
|
||||
self.qconfig.set(self.configItem, self.itemData(index))
|
||||
|
||||
def setValue(self, value):
|
||||
if value not in self.optionToText:
|
||||
return
|
||||
|
||||
self.setCurrentText(self.optionToText[value])
|
||||
self.qconfig.set(self.configItem, value)
|
||||
|
||||
|
||||
class NoOptionComboBoxSetting(ComboBox):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
value: List[str],
|
||||
texts: List[str],
|
||||
qconfig: QConfig,
|
||||
configItem: OptionsConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItem = configItem
|
||||
|
||||
self.optionToText = {o: t for o, t in zip(value, texts)}
|
||||
for text, option in zip(texts, value):
|
||||
self.addItem(text, userData=option)
|
||||
|
||||
self.setCurrentText(self.optionToText[self.qconfig.get(configItem)])
|
||||
self.currentIndexChanged.connect(self._onCurrentIndexChanged)
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
|
||||
def _onCurrentIndexChanged(self, index: int):
|
||||
|
||||
self.qconfig.set(self.configItem, self.itemData(index))
|
||||
|
||||
def setValue(self, value):
|
||||
if value not in self.optionToText:
|
||||
return
|
||||
|
||||
self.setCurrentText(self.optionToText[value])
|
||||
self.qconfig.set(self.configItem, value)
|
||||
|
||||
def reLoadOptions(self, value: List[str], texts: List[str]):
|
||||
|
||||
self.currentIndexChanged.disconnect(self._onCurrentIndexChanged)
|
||||
self.clear()
|
||||
self.optionToText = {o: t for o, t in zip(value, texts)}
|
||||
for text, option in zip(texts, value):
|
||||
self.addItem(text, userData=option)
|
||||
self.setCurrentText(self.optionToText[self.qconfig.get(self.configItem)])
|
||||
self.currentIndexChanged.connect(self._onCurrentIndexChanged)
|
||||
|
||||
|
||||
class EditableComboBoxSetting(EditableComboBox):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
value: List[str],
|
||||
texts: List[str],
|
||||
qconfig: QConfig,
|
||||
configItem: OptionsConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItem = configItem
|
||||
|
||||
self.optionToText = {o: t for o, t in zip(value, texts)}
|
||||
for text, option in zip(texts, value):
|
||||
self.addItem(text, userData=option)
|
||||
|
||||
if qconfig.get(configItem) not in self.optionToText:
|
||||
self.optionToText[qconfig.get(configItem)] = qconfig.get(configItem)
|
||||
self.addItem(qconfig.get(configItem), userData=qconfig.get(configItem))
|
||||
|
||||
self.setCurrentText(self.optionToText[qconfig.get(configItem)])
|
||||
self.currentIndexChanged.connect(self._onCurrentIndexChanged)
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
|
||||
def _onCurrentIndexChanged(self, index: int):
|
||||
|
||||
self.qconfig.set(
|
||||
self.configItem,
|
||||
(self.itemData(index) if self.itemData(index) else self.itemText(index)),
|
||||
)
|
||||
|
||||
def setValue(self, value):
|
||||
if value not in self.optionToText:
|
||||
self.optionToText[value] = value
|
||||
if self.findText(value) == -1:
|
||||
self.addItem(value, userData=value)
|
||||
else:
|
||||
self.setItemData(self.findText(value), value)
|
||||
|
||||
self.setCurrentText(self.optionToText[value])
|
||||
self.qconfig.set(self.configItem, value)
|
||||
|
||||
def reLoadOptions(self, value: List[str], texts: List[str]):
|
||||
|
||||
self.currentIndexChanged.disconnect(self._onCurrentIndexChanged)
|
||||
self.clear()
|
||||
self.optionToText = {o: t for o, t in zip(value, texts)}
|
||||
for text, option in zip(texts, value):
|
||||
self.addItem(text, userData=option)
|
||||
if self.qconfig.get(self.configItem) not in self.optionToText:
|
||||
self.optionToText[self.qconfig.get(self.configItem)] = self.qconfig.get(
|
||||
self.configItem
|
||||
)
|
||||
self.addItem(
|
||||
self.qconfig.get(self.configItem),
|
||||
userData=self.qconfig.get(self.configItem),
|
||||
)
|
||||
self.setCurrentText(self.optionToText[self.qconfig.get(self.configItem)])
|
||||
self.currentIndexChanged.connect(self._onCurrentIndexChanged)
|
||||
|
||||
def _onReturnPressed(self):
|
||||
if not self.text():
|
||||
return
|
||||
|
||||
index = self.findText(self.text())
|
||||
if index >= 0 and index != self.currentIndex():
|
||||
self._currentIndex = index
|
||||
self.currentIndexChanged.emit(index)
|
||||
elif index == -1:
|
||||
self.addItem(self.text())
|
||||
self.setCurrentIndex(self.count() - 1)
|
||||
self.currentIndexChanged.emit(self.count() - 1)
|
||||
|
||||
|
||||
class SpinBoxSetting(SpinBox):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
range: tuple[int, int],
|
||||
qconfig: QConfig,
|
||||
configItem: ConfigItem,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(parent)
|
||||
self.qconfig = qconfig
|
||||
self.configItem = configItem
|
||||
self.setRange(range[0], range[1])
|
||||
|
||||
if configItem:
|
||||
self.set_value(qconfig.get(configItem))
|
||||
configItem.valueChanged.connect(self.set_value)
|
||||
|
||||
self.valueChanged.connect(self.set_value)
|
||||
|
||||
def set_value(self, value: int):
|
||||
if self.configItem:
|
||||
self.qconfig.set(self.configItem, value)
|
||||
|
||||
self.setValue(value)
|
||||
|
||||
|
||||
class HistoryCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, qconfig: QConfig, configItem: ConfigItem, parent=None):
|
||||
@@ -1203,9 +1611,7 @@ class UrlListSettingCard(ExpandSettingCard):
|
||||
"""show confirm dialog"""
|
||||
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
f"确定要删除 {item.url} 代理网址吗?",
|
||||
self.window(),
|
||||
"确认", f"确定要删除 {item.url} 代理网址吗?", self.window()
|
||||
)
|
||||
if choice.exec():
|
||||
self.__removeUrl(item)
|
||||
|
||||
@@ -49,6 +49,7 @@ from app.core import Config, TaskManager, MainTimer, MainInfoBar
|
||||
from app.services import Notify, Crypto, System
|
||||
from .home import Home
|
||||
from .member_manager import MemberManager
|
||||
from .plan_manager import PlanManager
|
||||
from .queue_manager import QueueManager
|
||||
from .dispatch_center import DispatchCenter
|
||||
from .history import History
|
||||
@@ -80,6 +81,7 @@ class AUTO_MAA(MSFluentWindow):
|
||||
|
||||
# 创建主窗口
|
||||
self.home = Home(self)
|
||||
self.plan_manager = PlanManager(self)
|
||||
self.member_manager = MemberManager(self)
|
||||
self.queue_manager = QueueManager(self)
|
||||
self.dispatch_center = DispatchCenter(self)
|
||||
@@ -100,6 +102,13 @@ class AUTO_MAA(MSFluentWindow):
|
||||
FluentIcon.ROBOT,
|
||||
NavigationItemPosition.TOP,
|
||||
)
|
||||
self.addSubInterface(
|
||||
self.plan_manager,
|
||||
FluentIcon.CALENDAR,
|
||||
"计划管理",
|
||||
FluentIcon.CALENDAR,
|
||||
NavigationItemPosition.TOP,
|
||||
)
|
||||
self.addSubInterface(
|
||||
self.queue_manager,
|
||||
FluentIcon.BOOK_SHELF,
|
||||
@@ -128,23 +137,7 @@ class AUTO_MAA(MSFluentWindow):
|
||||
FluentIcon.SETTING,
|
||||
NavigationItemPosition.BOTTOM,
|
||||
)
|
||||
self.stackedWidget.currentChanged.connect(
|
||||
lambda index: (
|
||||
self.queue_manager.reload_member_name() if index == 2 else None
|
||||
)
|
||||
)
|
||||
self.stackedWidget.currentChanged.connect(
|
||||
lambda index: (
|
||||
self.dispatch_center.pivot.setCurrentItem("主调度台")
|
||||
if index == 3
|
||||
else None
|
||||
)
|
||||
)
|
||||
self.stackedWidget.currentChanged.connect(
|
||||
lambda index: (
|
||||
self.dispatch_center.update_top_bar() if index == 3 else None
|
||||
)
|
||||
)
|
||||
self.stackedWidget.currentChanged.connect(self.__currentChanged)
|
||||
|
||||
# 创建系统托盘及其菜单
|
||||
self.tray = QSystemTrayIcon(
|
||||
@@ -241,43 +234,6 @@ class AUTO_MAA(MSFluentWindow):
|
||||
else:
|
||||
self.setStyleSheet("background-color: #ffffff;")
|
||||
|
||||
def start_up_task(self) -> None:
|
||||
"""启动时任务"""
|
||||
|
||||
# 清理旧日志
|
||||
self.clean_old_logs()
|
||||
|
||||
# 清理安装包
|
||||
if (Config.app_path / "AUTO_MAA-Setup.exe").exists():
|
||||
try:
|
||||
(Config.app_path / "AUTO_MAA-Setup.exe").unlink()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 检查密码
|
||||
self.setting.check_PASSWORD()
|
||||
|
||||
# 获取主题图像
|
||||
if Config.get(Config.function_HomeImageMode) == "主题图像":
|
||||
self.home.get_home_image()
|
||||
|
||||
# 直接运行主任务
|
||||
if Config.get(Config.start_IfRunDirectly):
|
||||
|
||||
self.start_main_task()
|
||||
|
||||
# 获取公告
|
||||
self.setting.show_notice(if_first=True)
|
||||
|
||||
# 检查更新
|
||||
if Config.get(Config.update_IfAutoUpdate):
|
||||
self.setting.check_update(if_first=True)
|
||||
|
||||
# 直接最小化
|
||||
if Config.get(Config.start_IfMinimizeDirectly):
|
||||
|
||||
self.titleBar.minBtn.click()
|
||||
|
||||
def set_min_method(self) -> None:
|
||||
"""设置最小化方法"""
|
||||
|
||||
@@ -296,61 +252,6 @@ class AUTO_MAA(MSFluentWindow):
|
||||
if reason == QSystemTrayIcon.DoubleClick:
|
||||
self.show_ui("显示主窗口")
|
||||
|
||||
def clean_old_logs(self):
|
||||
"""
|
||||
删除超过用户设定天数的日志文件(基于目录日期)
|
||||
"""
|
||||
|
||||
if Config.get(Config.function_HistoryRetentionTime) == 0:
|
||||
logger.info("由于用户设置日志永久保留,跳过日志清理")
|
||||
return
|
||||
|
||||
deleted_count = 0
|
||||
|
||||
for date_folder in (Config.app_path / "history").iterdir():
|
||||
if not date_folder.is_dir():
|
||||
continue # 只处理日期文件夹
|
||||
|
||||
try:
|
||||
# 只检查 `YYYY-MM-DD` 格式的文件夹
|
||||
folder_date = datetime.strptime(date_folder.name, "%Y-%m-%d")
|
||||
if datetime.now() - folder_date > timedelta(
|
||||
days=Config.get(Config.function_HistoryRetentionTime)
|
||||
):
|
||||
shutil.rmtree(date_folder, ignore_errors=True)
|
||||
deleted_count += 1
|
||||
logger.info(f"已删除超期日志目录: {date_folder}")
|
||||
except ValueError:
|
||||
logger.warning(f"非日期格式的目录: {date_folder}")
|
||||
|
||||
logger.info(f"清理完成: {deleted_count} 个日期目录")
|
||||
|
||||
def start_main_task(self) -> None:
|
||||
"""启动主任务"""
|
||||
|
||||
if "调度队列_1" in Config.queue_dict:
|
||||
|
||||
logger.info("自动添加任务:调度队列_1")
|
||||
TaskManager.add_task(
|
||||
"自动代理_主调度台",
|
||||
"调度队列_1",
|
||||
Config.queue_dict["调度队列_1"]["Config"].toDict(),
|
||||
)
|
||||
|
||||
elif "脚本_1" in Config.member_dict:
|
||||
|
||||
logger.info("自动添加任务:脚本_1")
|
||||
TaskManager.add_task(
|
||||
"自动代理_主调度台", "自定义队列", {"Queue": {"Member_1": "脚本_1"}}
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
logger.warning("启动主任务失败:未找到有效的主任务配置文件")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "启动主任务失败", "“调度队列_1”与“脚本_1”均不存在", -1
|
||||
)
|
||||
|
||||
def show_ui(
|
||||
self, mode: str, if_quick: bool = False, if_start: bool = False
|
||||
) -> None:
|
||||
@@ -431,6 +332,109 @@ class AUTO_MAA(MSFluentWindow):
|
||||
self.window().hide()
|
||||
self.tray.show()
|
||||
|
||||
def start_up_task(self) -> None:
|
||||
"""启动时任务"""
|
||||
|
||||
# 清理旧日志
|
||||
self.clean_old_logs()
|
||||
|
||||
# 清理安装包
|
||||
if (Config.app_path / "AUTO_MAA-Setup.exe").exists():
|
||||
try:
|
||||
(Config.app_path / "AUTO_MAA-Setup.exe").unlink()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 检查密码
|
||||
self.setting.check_PASSWORD()
|
||||
|
||||
# 获取主题图像
|
||||
if Config.get(Config.function_HomeImageMode) == "主题图像":
|
||||
self.home.get_home_image()
|
||||
|
||||
# 直接运行主任务
|
||||
if Config.get(Config.start_IfRunDirectly):
|
||||
|
||||
self.start_main_task()
|
||||
|
||||
# 获取公告
|
||||
self.setting.show_notice(if_first=True)
|
||||
|
||||
# 检查更新
|
||||
if Config.get(Config.update_IfAutoUpdate):
|
||||
self.setting.check_update(if_first=True)
|
||||
|
||||
# 直接最小化
|
||||
if Config.get(Config.start_IfMinimizeDirectly):
|
||||
|
||||
self.titleBar.minBtn.click()
|
||||
|
||||
def clean_old_logs(self):
|
||||
"""
|
||||
删除超过用户设定天数的日志文件(基于目录日期)
|
||||
"""
|
||||
|
||||
if Config.get(Config.function_HistoryRetentionTime) == 0:
|
||||
logger.info("由于用户设置日志永久保留,跳过日志清理")
|
||||
return
|
||||
|
||||
deleted_count = 0
|
||||
|
||||
for date_folder in (Config.app_path / "history").iterdir():
|
||||
if not date_folder.is_dir():
|
||||
continue # 只处理日期文件夹
|
||||
|
||||
try:
|
||||
# 只检查 `YYYY-MM-DD` 格式的文件夹
|
||||
folder_date = datetime.strptime(date_folder.name, "%Y-%m-%d")
|
||||
if datetime.now() - folder_date > timedelta(
|
||||
days=Config.get(Config.function_HistoryRetentionTime)
|
||||
):
|
||||
shutil.rmtree(date_folder, ignore_errors=True)
|
||||
deleted_count += 1
|
||||
logger.info(f"已删除超期日志目录: {date_folder}")
|
||||
except ValueError:
|
||||
logger.warning(f"非日期格式的目录: {date_folder}")
|
||||
|
||||
logger.info(f"清理完成: {deleted_count} 个日期目录")
|
||||
|
||||
def start_main_task(self) -> None:
|
||||
"""启动主任务"""
|
||||
|
||||
if "调度队列_1" in Config.queue_dict:
|
||||
|
||||
logger.info("自动添加任务:调度队列_1")
|
||||
TaskManager.add_task(
|
||||
"自动代理_主调度台",
|
||||
"调度队列_1",
|
||||
Config.queue_dict["调度队列_1"]["Config"].toDict(),
|
||||
)
|
||||
|
||||
elif "脚本_1" in Config.member_dict:
|
||||
|
||||
logger.info("自动添加任务:脚本_1")
|
||||
TaskManager.add_task(
|
||||
"自动代理_主调度台", "自定义队列", {"Queue": {"Member_1": "脚本_1"}}
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
logger.warning("启动主任务失败:未找到有效的主任务配置文件")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "启动主任务失败", "“调度队列_1”与“脚本_1”均不存在", -1
|
||||
)
|
||||
|
||||
def __currentChanged(self, index: int) -> None:
|
||||
"""切换界面时任务"""
|
||||
|
||||
if index == 1:
|
||||
self.member_manager.reload_plan_name()
|
||||
elif index == 3:
|
||||
self.queue_manager.reload_member_name()
|
||||
elif index == 4:
|
||||
self.dispatch_center.pivot.setCurrentItem("主调度台")
|
||||
self.dispatch_center.update_top_bar()
|
||||
|
||||
def closeEvent(self, event: QCloseEvent):
|
||||
"""清理残余进程"""
|
||||
|
||||
|
||||
@@ -67,9 +67,13 @@ from .Widget import (
|
||||
SpinBoxSettingCard,
|
||||
ComboBoxMessageBox,
|
||||
SettingFlyoutView,
|
||||
EditableComboBoxSettingCard,
|
||||
NoOptionComboBoxSettingCard,
|
||||
ComboBoxWithPlanSettingCard,
|
||||
EditableComboBoxWithPlanSettingCard,
|
||||
SpinBoxWithPlanSettingCard,
|
||||
PasswordLineEditSettingCard,
|
||||
UserLableSettingCard,
|
||||
UserTaskSettingCard,
|
||||
ComboBoxSettingCard,
|
||||
SwitchSettingCard,
|
||||
PushAndSwitchButtonSettingCard,
|
||||
@@ -183,7 +187,7 @@ class MemberManager(QWidget):
|
||||
|
||||
name = self.member_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("删除脚本实例时未选择脚本实例")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择脚本实例", "请选择一个脚本实例", 5000
|
||||
@@ -197,11 +201,7 @@ class MemberManager(QWidget):
|
||||
)
|
||||
return None
|
||||
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
f"确定要删除 {name} 实例吗?",
|
||||
self.window(),
|
||||
)
|
||||
choice = MessageBox("确认", f"确定要删除 {name} 实例吗?", self.window())
|
||||
if choice.exec():
|
||||
|
||||
self.member_manager.clear_SettingBox()
|
||||
@@ -227,7 +227,7 @@ class MemberManager(QWidget):
|
||||
|
||||
name = self.member_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("向左移动脚本实例时未选择脚本实例")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择脚本实例", "请选择一个脚本实例", 5000
|
||||
@@ -275,7 +275,7 @@ class MemberManager(QWidget):
|
||||
|
||||
name = self.member_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("向右移动脚本实例时未选择脚本实例")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择脚本实例", "请选择一个脚本实例", 5000
|
||||
@@ -476,11 +476,57 @@ class MemberManager(QWidget):
|
||||
self.key.setIcon(FluentIcon.HIDE)
|
||||
self.key.setChecked(False)
|
||||
|
||||
def reload_plan_name(self):
|
||||
"""刷新计划表名称"""
|
||||
|
||||
plan_list = [
|
||||
["固定"] + [_ for _ in Config.plan_dict.keys()],
|
||||
["固定"]
|
||||
+ [
|
||||
(
|
||||
k
|
||||
if v["Config"].get(v["Config"].Info_Name) == ""
|
||||
else f"{k} - {v["Config"].get(v["Config"].Info_Name)}"
|
||||
)
|
||||
for k, v in Config.plan_dict.items()
|
||||
],
|
||||
]
|
||||
for member in self.member_manager.script_list:
|
||||
|
||||
if isinstance(member, MemberManager.MemberSettingBox.MaaSettingBox):
|
||||
|
||||
for user_setting in member.user_setting.user_manager.script_list:
|
||||
|
||||
user_setting.card_GameIdMode.comboBox.currentIndexChanged.disconnect(
|
||||
user_setting.switch_gameid_mode
|
||||
)
|
||||
user_setting.card_GameIdMode.reLoadOptions(
|
||||
plan_list[0], plan_list[1]
|
||||
)
|
||||
user_setting.card_GameIdMode.comboBox.currentIndexChanged.connect(
|
||||
user_setting.switch_gameid_mode
|
||||
)
|
||||
|
||||
self.refresh_plan_info()
|
||||
|
||||
def refresh_dashboard(self):
|
||||
"""刷新所有脚本实例的用户仪表盘"""
|
||||
|
||||
for script in self.member_manager.script_list:
|
||||
script.user_setting.user_manager.user_dashboard.load_info()
|
||||
for member in self.member_manager.script_list:
|
||||
|
||||
if isinstance(member, MemberManager.MemberSettingBox.MaaSettingBox):
|
||||
member.user_setting.user_manager.user_dashboard.load_info()
|
||||
|
||||
def refresh_plan_info(self):
|
||||
"""刷新所有计划信息"""
|
||||
|
||||
for member in self.member_manager.script_list:
|
||||
|
||||
if isinstance(member, MemberManager.MemberSettingBox.MaaSettingBox):
|
||||
|
||||
member.user_setting.user_manager.user_dashboard.load_info()
|
||||
for user_setting in member.user_setting.user_manager.script_list:
|
||||
user_setting.switch_gameid_mode()
|
||||
|
||||
class MemberSettingBox(QWidget):
|
||||
"""脚本管理子页面组"""
|
||||
@@ -845,7 +891,7 @@ class MemberManager(QWidget):
|
||||
|
||||
name = self.user_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("未选择用户")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择用户", "请先选择一个用户", 5000
|
||||
@@ -866,9 +912,7 @@ class MemberManager(QWidget):
|
||||
return None
|
||||
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
f"确定要删除 {name} 吗?",
|
||||
self.window(),
|
||||
"确认", f"确定要删除 {name} 吗?", self.window()
|
||||
)
|
||||
if choice.exec():
|
||||
|
||||
@@ -906,7 +950,7 @@ class MemberManager(QWidget):
|
||||
|
||||
name = self.user_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("未选择用户")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择用户", "请先选择一个用户", 5000
|
||||
@@ -965,7 +1009,7 @@ class MemberManager(QWidget):
|
||||
|
||||
name = self.user_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("未选择用户")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择用户", "请先选择一个用户", 5000
|
||||
@@ -1201,6 +1245,8 @@ class MemberManager(QWidget):
|
||||
else "本周剿灭未完成"
|
||||
)
|
||||
|
||||
gameid_info = config.get_plan_info()
|
||||
|
||||
button = PrimaryToolButton(
|
||||
FluentIcon.CHEVRON_RIGHT, self
|
||||
)
|
||||
@@ -1249,9 +1295,7 @@ class MemberManager(QWidget):
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
5,
|
||||
QTableWidgetItem(
|
||||
str(config.get(config.Info_MedicineNumb))
|
||||
),
|
||||
QTableWidgetItem(str(gameid_info["MedicineNumb"])),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
@@ -1259,12 +1303,12 @@ class MemberManager(QWidget):
|
||||
QTableWidgetItem(
|
||||
Config.gameid_dict["ALL"]["text"][
|
||||
Config.gameid_dict["ALL"]["value"].index(
|
||||
config.get(config.Info_GameId)
|
||||
gameid_info["GameId"]
|
||||
)
|
||||
]
|
||||
if config.get(config.Info_GameId)
|
||||
if gameid_info["GameId"]
|
||||
in Config.gameid_dict["ALL"]["value"]
|
||||
else config.get(config.Info_GameId)
|
||||
else gameid_info["GameId"]
|
||||
),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
@@ -1273,12 +1317,12 @@ class MemberManager(QWidget):
|
||||
QTableWidgetItem(
|
||||
Config.gameid_dict["ALL"]["text"][
|
||||
Config.gameid_dict["ALL"]["value"].index(
|
||||
config.get(config.Info_GameId_1)
|
||||
gameid_info["GameId_1"]
|
||||
)
|
||||
]
|
||||
if config.get(config.Info_GameId_1)
|
||||
if gameid_info["GameId_1"]
|
||||
in Config.gameid_dict["ALL"]["value"]
|
||||
else config.get(config.Info_GameId_1)
|
||||
else gameid_info["GameId_1"]
|
||||
),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
@@ -1287,12 +1331,12 @@ class MemberManager(QWidget):
|
||||
QTableWidgetItem(
|
||||
Config.gameid_dict["ALL"]["text"][
|
||||
Config.gameid_dict["ALL"]["value"].index(
|
||||
config.get(config.Info_GameId_2)
|
||||
gameid_info["GameId_2"]
|
||||
)
|
||||
]
|
||||
if config.get(config.Info_GameId_2)
|
||||
if gameid_info["GameId_2"]
|
||||
in Config.gameid_dict["ALL"]["value"]
|
||||
else config.get(config.Info_GameId_2)
|
||||
else gameid_info["GameId_2"]
|
||||
),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
@@ -1300,22 +1344,20 @@ class MemberManager(QWidget):
|
||||
9,
|
||||
QTableWidgetItem(
|
||||
"不使用"
|
||||
if config.get(config.Info_GameId_Remain) == "-"
|
||||
if gameid_info["GameId_Remain"] == "-"
|
||||
else (
|
||||
(
|
||||
Config.gameid_dict["ALL"]["text"][
|
||||
Config.gameid_dict["ALL"][
|
||||
"value"
|
||||
].index(
|
||||
config.get(
|
||||
config.Info_GameId_Remain
|
||||
)
|
||||
gameid_info["GameId_Remain"]
|
||||
)
|
||||
]
|
||||
)
|
||||
if config.get(config.Info_GameId_Remain)
|
||||
if gameid_info["GameId_Remain"]
|
||||
in Config.gameid_dict["ALL"]["value"]
|
||||
else config.get(config.Info_GameId_Remain)
|
||||
else gameid_info["GameId_Remain"]
|
||||
)
|
||||
),
|
||||
)
|
||||
@@ -1339,6 +1381,19 @@ class MemberManager(QWidget):
|
||||
f"用户_{uid}"
|
||||
]["Path"]
|
||||
|
||||
plan_list = [
|
||||
["固定"] + [_ for _ in Config.plan_dict.keys()],
|
||||
["固定"]
|
||||
+ [
|
||||
(
|
||||
k
|
||||
if v["Config"].get(v["Config"].Info_Name) == ""
|
||||
else f"{k} - {v["Config"].get(v["Config"].Info_Name)}"
|
||||
)
|
||||
for k, v in Config.plan_dict.items()
|
||||
],
|
||||
]
|
||||
|
||||
self.card_Name = LineEditSettingCard(
|
||||
icon=FluentIcon.PEOPLE,
|
||||
title="用户名",
|
||||
@@ -1366,15 +1421,17 @@ class MemberManager(QWidget):
|
||||
configItem=self.config.Info_Mode,
|
||||
parent=self,
|
||||
)
|
||||
self.card_GameIdMode = ComboBoxSettingCard(
|
||||
self.card_GameIdMode = NoOptionComboBoxSettingCard(
|
||||
icon=FluentIcon.DICTIONARY,
|
||||
title="关卡配置模式",
|
||||
content="刷理智关卡号的配置模式",
|
||||
texts=["固定"],
|
||||
value=plan_list[0],
|
||||
texts=plan_list[1],
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Info_GameIdMode,
|
||||
parent=self,
|
||||
)
|
||||
self.card_GameIdMode.comboBox.setMinimumWidth(0)
|
||||
self.card_Server = ComboBoxSettingCard(
|
||||
icon=FluentIcon.PROJECTOR,
|
||||
title="服务器",
|
||||
@@ -1452,7 +1509,7 @@ class MemberManager(QWidget):
|
||||
configItem=self.config.Info_Notes,
|
||||
parent=self,
|
||||
)
|
||||
self.card_MedicineNumb = SpinBoxSettingCard(
|
||||
self.card_MedicineNumb = SpinBoxWithPlanSettingCard(
|
||||
icon=FluentIcon.GAME,
|
||||
title="吃理智药",
|
||||
content="吃理智药次数,输入0以关闭",
|
||||
@@ -1461,7 +1518,7 @@ class MemberManager(QWidget):
|
||||
configItem=self.config.Info_MedicineNumb,
|
||||
parent=self,
|
||||
)
|
||||
self.card_SeriesNumb = ComboBoxSettingCard(
|
||||
self.card_SeriesNumb = ComboBoxWithPlanSettingCard(
|
||||
icon=FluentIcon.GAME,
|
||||
title="连战次数",
|
||||
content="连战次数较大时建议搭配剩余理智关卡使用",
|
||||
@@ -1471,7 +1528,7 @@ class MemberManager(QWidget):
|
||||
parent=self,
|
||||
)
|
||||
self.card_SeriesNumb.comboBox.setMinimumWidth(150)
|
||||
self.card_GameId = EditableComboBoxSettingCard(
|
||||
self.card_GameId = EditableComboBoxWithPlanSettingCard(
|
||||
icon=FluentIcon.GAME,
|
||||
title="关卡选择",
|
||||
content="按下回车以添加自定义关卡号",
|
||||
@@ -1481,7 +1538,7 @@ class MemberManager(QWidget):
|
||||
configItem=self.config.Info_GameId,
|
||||
parent=self,
|
||||
)
|
||||
self.card_GameId_1 = EditableComboBoxSettingCard(
|
||||
self.card_GameId_1 = EditableComboBoxWithPlanSettingCard(
|
||||
icon=FluentIcon.GAME,
|
||||
title="备选关卡 - 1",
|
||||
content="按下回车以添加自定义关卡号",
|
||||
@@ -1491,7 +1548,7 @@ class MemberManager(QWidget):
|
||||
configItem=self.config.Info_GameId_1,
|
||||
parent=self,
|
||||
)
|
||||
self.card_GameId_2 = EditableComboBoxSettingCard(
|
||||
self.card_GameId_2 = EditableComboBoxWithPlanSettingCard(
|
||||
icon=FluentIcon.GAME,
|
||||
title="备选关卡 - 2",
|
||||
content="按下回车以添加自定义关卡号",
|
||||
@@ -1501,18 +1558,20 @@ class MemberManager(QWidget):
|
||||
configItem=self.config.Info_GameId_2,
|
||||
parent=self,
|
||||
)
|
||||
self.card_GameId_Remain = EditableComboBoxSettingCard(
|
||||
icon=FluentIcon.GAME,
|
||||
title="剩余理智关卡",
|
||||
content="按下回车以添加自定义关卡号",
|
||||
value=Config.gameid_dict["ALL"]["value"],
|
||||
texts=[
|
||||
"不使用" if _ == "当前/上次" else _
|
||||
for _ in Config.gameid_dict["ALL"]["text"]
|
||||
],
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Info_GameId_Remain,
|
||||
parent=self,
|
||||
self.card_GameId_Remain = (
|
||||
EditableComboBoxWithPlanSettingCard(
|
||||
icon=FluentIcon.GAME,
|
||||
title="剩余理智关卡",
|
||||
content="按下回车以添加自定义关卡号",
|
||||
value=Config.gameid_dict["ALL"]["value"],
|
||||
texts=[
|
||||
"不使用" if _ == "当前/上次" else _
|
||||
for _ in Config.gameid_dict["ALL"]["text"]
|
||||
],
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Info_GameId_Remain,
|
||||
parent=self,
|
||||
)
|
||||
)
|
||||
|
||||
self.card_UserLable = UserLableSettingCard(
|
||||
@@ -1529,7 +1588,106 @@ class MemberManager(QWidget):
|
||||
parent=self,
|
||||
)
|
||||
|
||||
# 新增单独通知卡片
|
||||
# 单独任务卡片
|
||||
self.card_TaskSet = UserTaskSettingCard(
|
||||
icon=FluentIcon.LIBRARY,
|
||||
title="自动日常代理任务序列",
|
||||
content="未启用任何任务项",
|
||||
text="设置",
|
||||
qconfig=self.config,
|
||||
configItems={
|
||||
"IfWakeUp": self.config.Task_IfWakeUp,
|
||||
"IfRecruiting": self.config.Task_IfRecruiting,
|
||||
"IfBase": self.config.Task_IfBase,
|
||||
"IfCombat": self.config.Task_IfCombat,
|
||||
"IfMall": self.config.Task_IfMall,
|
||||
"IfMission": self.config.Task_IfMission,
|
||||
"IfAutoRoguelike": self.config.Task_IfAutoRoguelike,
|
||||
"IfReclamation": self.config.Task_IfReclamation,
|
||||
},
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfWakeUp = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="开始唤醒",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfWakeUp,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfRecruiting = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="自动公招",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfRecruiting,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfBase = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="基建换班",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfBase,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfCombat = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="刷理智",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfCombat,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfMall = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="获取信用及购物",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfMall,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfMission = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="领取奖励",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfMission,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfAutoRoguelike = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="自动肉鸽",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfAutoRoguelike,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfReclamation = SwitchSettingCard(
|
||||
icon=FluentIcon.TILES,
|
||||
title="生息演算",
|
||||
content="",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Task_IfReclamation,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
self.TaskSetCard = SettingFlyoutView(
|
||||
self,
|
||||
"自动日常代理任务序列设置",
|
||||
[
|
||||
self.card_IfWakeUp,
|
||||
self.card_IfRecruiting,
|
||||
self.card_IfBase,
|
||||
self.card_IfCombat,
|
||||
self.card_IfMall,
|
||||
self.card_IfMission,
|
||||
self.card_IfAutoRoguelike,
|
||||
self.card_IfReclamation,
|
||||
],
|
||||
)
|
||||
|
||||
# 单独通知卡片
|
||||
self.card_NotifySet = UserNoticeSettingCard(
|
||||
icon=FluentIcon.MAIL,
|
||||
title="用户单独通知设置",
|
||||
@@ -1560,17 +1718,16 @@ class MemberManager(QWidget):
|
||||
self.CompanyWechatPushSettingCard(self.config, self)
|
||||
)
|
||||
|
||||
self.card_NotifySet_list = [
|
||||
self.card_NotifyContent,
|
||||
self.card_EMail,
|
||||
self.card_ServerChan,
|
||||
self.card_CompanyWebhookBot,
|
||||
]
|
||||
|
||||
self.NotifySetCard = SettingFlyoutView(
|
||||
self, "用户通知设置", self.card_NotifySet_list
|
||||
self,
|
||||
"用户通知设置",
|
||||
[
|
||||
self.card_NotifyContent,
|
||||
self.card_EMail,
|
||||
self.card_ServerChan,
|
||||
self.card_CompanyWebhookBot,
|
||||
],
|
||||
)
|
||||
self.NotifySetCard.setVisible(False)
|
||||
|
||||
h1_layout = QHBoxLayout()
|
||||
h1_layout.addWidget(self.card_Name)
|
||||
@@ -1609,6 +1766,7 @@ class MemberManager(QWidget):
|
||||
Layout.addLayout(h6_layout)
|
||||
Layout.addLayout(h7_layout)
|
||||
Layout.addLayout(h8_layout)
|
||||
Layout.addWidget(self.card_TaskSet)
|
||||
Layout.addWidget(self.card_NotifySet)
|
||||
|
||||
self.viewLayout.addLayout(Layout)
|
||||
@@ -1629,11 +1787,16 @@ class MemberManager(QWidget):
|
||||
self.card_InfrastMode.clicked.connect(
|
||||
self.set_infrastructure
|
||||
)
|
||||
self.card_TaskSet.clicked.connect(self.set_task)
|
||||
self.card_NotifySet.clicked.connect(self.set_notify)
|
||||
self.card_GameIdMode.comboBox.currentIndexChanged.connect(
|
||||
self.switch_gameid_mode
|
||||
)
|
||||
Config.gameid_refreshed.connect(self.refresh_gameid)
|
||||
Config.PASSWORD_refreshed.connect(self.refresh_password)
|
||||
|
||||
self.switch_mode()
|
||||
self.switch_gameid_mode()
|
||||
self.switch_infrastructure()
|
||||
|
||||
def switch_mode(self) -> None:
|
||||
@@ -1652,6 +1815,40 @@ class MemberManager(QWidget):
|
||||
self.card_Annihilation.button.setVisible(True)
|
||||
self.card_Routine.setVisible(True)
|
||||
|
||||
def switch_gameid_mode(self) -> None:
|
||||
|
||||
for card, name in zip(
|
||||
[
|
||||
self.card_MedicineNumb,
|
||||
self.card_SeriesNumb,
|
||||
self.card_GameId,
|
||||
self.card_GameId_1,
|
||||
self.card_GameId_2,
|
||||
self.card_GameId_Remain,
|
||||
],
|
||||
[
|
||||
"MedicineNumb",
|
||||
"SeriesNumb",
|
||||
"GameId",
|
||||
"GameId_1",
|
||||
"GameId_2",
|
||||
"GameId_Remain",
|
||||
],
|
||||
):
|
||||
|
||||
card.switch_mode(
|
||||
self.config.get(self.config.Info_GameIdMode)[:2]
|
||||
)
|
||||
if (
|
||||
self.config.get(self.config.Info_GameIdMode)
|
||||
!= "固定"
|
||||
):
|
||||
card.change_plan(
|
||||
Config.plan_dict[
|
||||
self.config.get(self.config.Info_GameIdMode)
|
||||
]["Config"].get_current_info(name)
|
||||
)
|
||||
|
||||
def switch_infrastructure(self) -> None:
|
||||
|
||||
if (
|
||||
@@ -1755,6 +1952,18 @@ class MemberManager(QWidget):
|
||||
},
|
||||
)
|
||||
|
||||
def set_task(self) -> None:
|
||||
"""设置用户任务序列相关配置"""
|
||||
|
||||
self.TaskSetCard.setVisible(True)
|
||||
Flyout.make(
|
||||
self.TaskSetCard,
|
||||
self.card_TaskSet,
|
||||
self,
|
||||
aniType=FlyoutAnimationType.PULL_UP,
|
||||
isDeleteOnClose=False,
|
||||
)
|
||||
|
||||
def set_notify(self) -> None:
|
||||
"""设置用户通知相关配置"""
|
||||
|
||||
|
||||
@@ -28,49 +28,29 @@ v4.3
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget,
|
||||
QFileDialog,
|
||||
QHBoxLayout,
|
||||
QVBoxLayout,
|
||||
QStackedWidget,
|
||||
QTableWidgetItem,
|
||||
QHeaderView,
|
||||
)
|
||||
from PySide6.QtGui import QIcon
|
||||
from qfluentwidgets import (
|
||||
Action,
|
||||
ScrollArea,
|
||||
FluentIcon,
|
||||
MessageBox,
|
||||
HeaderCardWidget,
|
||||
CommandBar,
|
||||
ExpandGroupSettingCard,
|
||||
PushSettingCard,
|
||||
TableWidget,
|
||||
PrimaryToolButton,
|
||||
)
|
||||
from PySide6.QtCore import Signal
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
from typing import List, Dict, Union
|
||||
import shutil
|
||||
import json
|
||||
|
||||
from app.core import Config, MainInfoBar, TaskManager, MaaPlanConfig, Network
|
||||
from app.services import Crypto
|
||||
from .downloader import DownloadManager
|
||||
from app.core import Config, MainInfoBar, MaaPlanConfig
|
||||
from .Widget import (
|
||||
LineEditMessageBox,
|
||||
LineEditSettingCard,
|
||||
SpinBoxSettingCard,
|
||||
ComboBoxMessageBox,
|
||||
EditableComboBoxSettingCard,
|
||||
PasswordLineEditSettingCard,
|
||||
UserLableSettingCard,
|
||||
LineEditSettingCard,
|
||||
ComboBoxSettingCard,
|
||||
SwitchSettingCard,
|
||||
PushAndSwitchButtonSettingCard,
|
||||
PushAndComboBoxSettingCard,
|
||||
SpinBoxSetting,
|
||||
EditableComboBoxSetting,
|
||||
ComboBoxSetting,
|
||||
PivotArea,
|
||||
)
|
||||
|
||||
@@ -142,7 +122,7 @@ class PlanManager(QWidget):
|
||||
"Config": maa_plan_config,
|
||||
}
|
||||
|
||||
self.plan_manager.add_MaaSettingBox(index)
|
||||
self.plan_manager.add_MaaPlanSettingBox(index)
|
||||
self.plan_manager.switch_SettingBox(index)
|
||||
|
||||
logger.success(f"计划管理 计划_{index} 添加成功")
|
||||
@@ -155,7 +135,7 @@ class PlanManager(QWidget):
|
||||
|
||||
name = self.plan_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("删除计划表时未选择计划表")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择计划表", "请选择一个计划表", 5000
|
||||
@@ -169,11 +149,7 @@ class PlanManager(QWidget):
|
||||
)
|
||||
return None
|
||||
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
f"确定要删除 {name} 吗?",
|
||||
self.window(),
|
||||
)
|
||||
choice = MessageBox("确认", f"确定要删除 {name} 吗?", self.window())
|
||||
if choice.exec():
|
||||
|
||||
self.plan_manager.clear_SettingBox()
|
||||
@@ -185,7 +161,7 @@ class PlanManager(QWidget):
|
||||
Config.plan_dict[f"计划_{i}"]["Path"].rename(
|
||||
Config.plan_dict[f"计划_{i}"]["Path"].with_name(f"计划_{i-1}")
|
||||
)
|
||||
Config.change_queue(f"计划_{i}", f"计划_{i-1}")
|
||||
Config.change_plan(f"计划_{i}", f"计划_{i-1}")
|
||||
|
||||
self.plan_manager.show_SettingBox(max(int(name[3:]) - 1, 1))
|
||||
|
||||
@@ -197,7 +173,7 @@ class PlanManager(QWidget):
|
||||
|
||||
name = self.plan_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("向左移动计划表时未选择计划表")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择计划表", "请选择一个计划表", 5000
|
||||
@@ -225,15 +201,15 @@ class PlanManager(QWidget):
|
||||
Config.plan_dict[name]["Path"].rename(
|
||||
Config.plan_dict[name]["Path"].with_name("计划_0")
|
||||
)
|
||||
Config.change_queue(name, "计划_0")
|
||||
Config.change_plan(name, "计划_0")
|
||||
Config.plan_dict[f"计划_{index-1}"]["Path"].rename(
|
||||
Config.plan_dict[name]["Path"]
|
||||
)
|
||||
Config.change_queue(f"计划_{index-1}", name)
|
||||
Config.change_plan(f"计划_{index-1}", name)
|
||||
Config.plan_dict[name]["Path"].with_name("计划_0").rename(
|
||||
Config.plan_dict[f"计划_{index-1}"]["Path"]
|
||||
)
|
||||
Config.change_queue("计划_0", f"计划_{index-1}")
|
||||
Config.change_plan("计划_0", f"计划_{index-1}")
|
||||
|
||||
self.plan_manager.show_SettingBox(index - 1)
|
||||
|
||||
@@ -245,7 +221,7 @@ class PlanManager(QWidget):
|
||||
|
||||
name = self.plan_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("向右移动计划表时未选择计划表")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择计划表", "请选择一个计划表", 5000
|
||||
@@ -273,27 +249,21 @@ class PlanManager(QWidget):
|
||||
Config.plan_dict[name]["Path"].rename(
|
||||
Config.plan_dict[name]["Path"].with_name("计划_0")
|
||||
)
|
||||
Config.change_queue(name, "计划_0")
|
||||
Config.change_plan(name, "计划_0")
|
||||
Config.plan_dict[f"计划_{index+1}"]["Path"].rename(
|
||||
Config.plan_dict[name]["Path"]
|
||||
)
|
||||
Config.change_queue(f"计划_{index+1}", name)
|
||||
Config.change_plan(f"计划_{index+1}", name)
|
||||
Config.plan_dict[name]["Path"].with_name("计划_0").rename(
|
||||
Config.plan_dict[f"计划_{index+1}"]["Path"]
|
||||
)
|
||||
Config.change_queue("计划_0", f"计划_{index+1}")
|
||||
Config.change_plan("计划_0", f"计划_{index+1}")
|
||||
|
||||
self.plan_manager.show_SettingBox(index + 1)
|
||||
|
||||
logger.success(f"计划表 {name} 右移成功")
|
||||
MainInfoBar.push_info_bar("success", "操作成功", f"右移计划表 {name}", 3000)
|
||||
|
||||
def refresh_dashboard(self):
|
||||
"""刷新所有计划表的用户仪表盘"""
|
||||
|
||||
for script in self.plan_manager.script_list:
|
||||
script.user_setting.user_manager.user_dashboard.load_info()
|
||||
|
||||
class PlanSettingBox(QWidget):
|
||||
"""计划管理子页面组"""
|
||||
|
||||
@@ -331,7 +301,7 @@ class PlanManager(QWidget):
|
||||
|
||||
for name, info in Config.plan_dict.items():
|
||||
if info["Type"] == "Maa":
|
||||
self.add_MaaSettingBox(int(name[3:]))
|
||||
self.add_MaaPlanSettingBox(int(name[3:]))
|
||||
|
||||
self.switch_SettingBox(index)
|
||||
|
||||
@@ -352,6 +322,7 @@ class PlanManager(QWidget):
|
||||
"""清空所有子界面"""
|
||||
|
||||
for sub_interface in self.script_list:
|
||||
Config.gameid_refreshed.disconnect(sub_interface.refresh_gameid)
|
||||
self.stackedWidget.removeWidget(sub_interface)
|
||||
sub_interface.deleteLater()
|
||||
self.script_list.clear()
|
||||
@@ -375,167 +346,150 @@ class PlanManager(QWidget):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setObjectName(f"计划_{uid}")
|
||||
self.setTitle("MAA计划表")
|
||||
self.config = Config.plan_dict[f"计划_{uid}"]["Config"]
|
||||
|
||||
self.dashboard = TableWidget(self)
|
||||
self.dashboard.setColumnCount(11)
|
||||
self.dashboard.setHorizontalHeaderLabels(
|
||||
self.card_Name = LineEditSettingCard(
|
||||
icon=FluentIcon.EDIT,
|
||||
title="计划表名称",
|
||||
content="用于标识计划表的名称",
|
||||
text="请输入计划表名称",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Info_Name,
|
||||
parent=self,
|
||||
)
|
||||
self.card_Mode = ComboBoxSettingCard(
|
||||
icon=FluentIcon.DICTIONARY,
|
||||
title="计划模式",
|
||||
content="全局模式下计划内容固定,周计划模式下计划按周一到周日切换",
|
||||
texts=["全局", "周计划"],
|
||||
qconfig=self.config,
|
||||
configItem=self.config.Info_Mode,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
self.table = TableWidget(self)
|
||||
self.table.setColumnCount(8)
|
||||
self.table.setRowCount(6)
|
||||
self.table.setHorizontalHeaderLabels(
|
||||
["全局", "周一", "周二", "周三", "周四", "周五", "周六", "周日"]
|
||||
)
|
||||
self.table.setVerticalHeaderLabels(
|
||||
[
|
||||
"吃理智药",
|
||||
"连战次数",
|
||||
"关卡选择",
|
||||
"备选关卡 - 1",
|
||||
"备选关卡 - 2",
|
||||
"剩余理智关卡",
|
||||
"备选 - 1",
|
||||
"备选 - 2",
|
||||
"剩余理智",
|
||||
]
|
||||
)
|
||||
self.dashboard.setEditTriggers(TableWidget.NoEditTriggers)
|
||||
self.dashboard.verticalHeader().setVisible(False)
|
||||
for col in range(6):
|
||||
self.dashboard.horizontalHeader().setSectionResizeMode(
|
||||
self.table.setAlternatingRowColors(False)
|
||||
self.table.setEditTriggers(TableWidget.NoEditTriggers)
|
||||
for col in range(8):
|
||||
self.table.horizontalHeader().setSectionResizeMode(
|
||||
col, QHeaderView.ResizeMode.Stretch
|
||||
)
|
||||
for row in range(6):
|
||||
self.table.verticalHeader().setSectionResizeMode(
|
||||
row, QHeaderView.ResizeMode.ResizeToContents
|
||||
)
|
||||
|
||||
self.viewLayout.addWidget(self.dashboard)
|
||||
self.item_dict: Dict[
|
||||
str,
|
||||
Dict[
|
||||
str,
|
||||
Union[SpinBoxSetting, ComboBoxSetting, EditableComboBoxSetting],
|
||||
],
|
||||
] = {}
|
||||
|
||||
for col, (group, name_dict) in enumerate(
|
||||
self.config.config_item_dict.items()
|
||||
):
|
||||
|
||||
self.item_dict[group] = {}
|
||||
|
||||
for row, (name, configItem) in enumerate(name_dict.items()):
|
||||
|
||||
if name == "MedicineNumb":
|
||||
self.item_dict[group][name] = SpinBoxSetting(
|
||||
range=(0, 1024),
|
||||
qconfig=self.config,
|
||||
configItem=configItem,
|
||||
parent=self,
|
||||
)
|
||||
elif name == "SeriesNumb":
|
||||
self.item_dict[group][name] = ComboBoxSetting(
|
||||
texts=["AUTO", "6", "5", "4", "3", "2", "1", "不选择"],
|
||||
qconfig=self.config,
|
||||
configItem=configItem,
|
||||
parent=self,
|
||||
)
|
||||
elif name == "GameId_Remain":
|
||||
self.item_dict[group][name] = EditableComboBoxSetting(
|
||||
value=Config.gameid_dict[group]["value"],
|
||||
texts=[
|
||||
"不使用" if _ == "当前/上次" else _
|
||||
for _ in Config.gameid_dict[group]["text"]
|
||||
],
|
||||
qconfig=self.config,
|
||||
configItem=configItem,
|
||||
parent=self,
|
||||
)
|
||||
elif "GameId" in name:
|
||||
self.item_dict[group][name] = EditableComboBoxSetting(
|
||||
value=Config.gameid_dict[group]["value"],
|
||||
texts=Config.gameid_dict[group]["text"],
|
||||
qconfig=self.config,
|
||||
configItem=configItem,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
self.table.setCellWidget(row, col, self.item_dict[group][name])
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_Name)
|
||||
Layout.addWidget(self.card_Mode)
|
||||
Layout.addWidget(self.table)
|
||||
|
||||
self.viewLayout.addLayout(Layout)
|
||||
self.viewLayout.setSpacing(3)
|
||||
self.viewLayout.setContentsMargins(3, 0, 3, 3)
|
||||
|
||||
Config.PASSWORD_refreshed.connect(self.load_info)
|
||||
self.card_Mode.comboBox.currentIndexChanged.connect(self.switch_mode)
|
||||
Config.gameid_refreshed.connect(self.refresh_gameid)
|
||||
|
||||
def load_info(self):
|
||||
self.switch_mode()
|
||||
|
||||
self.user_data = Config.plan_dict[self.name]["UserData"]
|
||||
def switch_mode(self) -> None:
|
||||
"""切换计划模式"""
|
||||
|
||||
self.dashboard.setRowCount(len(self.user_data))
|
||||
for group, name_dict in self.item_dict.items():
|
||||
for name, setting_item in name_dict.items():
|
||||
setting_item.setEnabled(
|
||||
(group == "ALL")
|
||||
== (self.config.get(self.config.Info_Mode) == "ALL")
|
||||
)
|
||||
|
||||
for name, info in self.user_data.items():
|
||||
def refresh_gameid(self):
|
||||
|
||||
config = info["Config"]
|
||||
for group, name_dict in self.item_dict.items():
|
||||
|
||||
text_list = []
|
||||
if not config.get(config.Data_IfPassCheck):
|
||||
text_list.append("未通过人工排查")
|
||||
text_list.append(
|
||||
f"今日已代理{config.get(config.Data_ProxyTimes)}次"
|
||||
if Config.server_date().strftime("%Y-%m-%d")
|
||||
== config.get(config.Data_LastProxyDate)
|
||||
else "今日未进行代理"
|
||||
)
|
||||
text_list.append(
|
||||
"本周剿灭已完成"
|
||||
if datetime.strptime(
|
||||
config.get(config.Data_LastAnnihilationDate),
|
||||
"%Y-%m-%d",
|
||||
).isocalendar()[:2]
|
||||
== Config.server_date().isocalendar()[:2]
|
||||
else "本周剿灭未完成"
|
||||
)
|
||||
for name, setting_item in name_dict.items():
|
||||
|
||||
button = PrimaryToolButton(FluentIcon.CHEVRON_RIGHT, self)
|
||||
button.setFixedSize(32, 32)
|
||||
button.clicked.connect(partial(self.switch_to.emit, name))
|
||||
if name == "GameId_Remain":
|
||||
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
0,
|
||||
QTableWidgetItem(config.get(config.Info_Name)),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
1,
|
||||
QTableWidgetItem(config.get(config.Info_Id)),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
2,
|
||||
QTableWidgetItem(
|
||||
Crypto.AUTO_decryptor(
|
||||
config.get(config.Info_Password),
|
||||
Config.PASSWORD,
|
||||
setting_item.reLoadOptions(
|
||||
Config.gameid_dict[group]["value"],
|
||||
[
|
||||
"不使用" if _ == "当前/上次" else _
|
||||
for _ in Config.gameid_dict[group]["text"]
|
||||
],
|
||||
)
|
||||
if Config.PASSWORD
|
||||
else "******"
|
||||
),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
3,
|
||||
QTableWidgetItem(
|
||||
"启用"
|
||||
if config.get(config.Info_Status)
|
||||
and config.get(config.Info_RemainedDay) != 0
|
||||
else "禁用"
|
||||
),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
4,
|
||||
QTableWidgetItem(" | ".join(text_list)),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
5,
|
||||
QTableWidgetItem(str(config.get(config.Info_MedicineNumb))),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
6,
|
||||
QTableWidgetItem(
|
||||
Config.gameid_dict["ALL"]["text"][
|
||||
Config.gameid_dict["ALL"]["value"].index(
|
||||
config.get(config.Info_GameId)
|
||||
)
|
||||
]
|
||||
if config.get(config.Info_GameId)
|
||||
in Config.gameid_dict["ALL"]["value"]
|
||||
else config.get(config.Info_GameId)
|
||||
),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
7,
|
||||
QTableWidgetItem(
|
||||
Config.gameid_dict["ALL"]["text"][
|
||||
Config.gameid_dict["ALL"]["value"].index(
|
||||
config.get(config.Info_GameId_1)
|
||||
)
|
||||
]
|
||||
if config.get(config.Info_GameId_1)
|
||||
in Config.gameid_dict["ALL"]["value"]
|
||||
else config.get(config.Info_GameId_1)
|
||||
),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
8,
|
||||
QTableWidgetItem(
|
||||
Config.gameid_dict["ALL"]["text"][
|
||||
Config.gameid_dict["ALL"]["value"].index(
|
||||
config.get(config.Info_GameId_2)
|
||||
)
|
||||
]
|
||||
if config.get(config.Info_GameId_2)
|
||||
in Config.gameid_dict["ALL"]["value"]
|
||||
else config.get(config.Info_GameId_2)
|
||||
),
|
||||
)
|
||||
self.dashboard.setItem(
|
||||
int(name[3:]) - 1,
|
||||
9,
|
||||
QTableWidgetItem(
|
||||
"不使用"
|
||||
if config.get(config.Info_GameId_Remain) == "-"
|
||||
else (
|
||||
(
|
||||
Config.gameid_dict["ALL"]["text"][
|
||||
Config.gameid_dict["ALL"]["value"].index(
|
||||
config.get(config.Info_GameId_Remain)
|
||||
)
|
||||
]
|
||||
)
|
||||
if config.get(config.Info_GameId_Remain)
|
||||
in Config.gameid_dict["ALL"]["value"]
|
||||
else config.get(config.Info_GameId_Remain)
|
||||
|
||||
elif "GameId" in name:
|
||||
|
||||
setting_item.reLoadOptions(
|
||||
Config.gameid_dict[group]["value"],
|
||||
Config.gameid_dict[group]["text"],
|
||||
)
|
||||
),
|
||||
)
|
||||
self.dashboard.setCellWidget(int(name[3:]) - 1, 10, button)
|
||||
|
||||
@@ -122,7 +122,7 @@ class QueueManager(QWidget):
|
||||
|
||||
name = self.queue_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("未选择调度队列")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择调度队列", "请先选择一个调度队列", 5000
|
||||
@@ -136,11 +136,7 @@ class QueueManager(QWidget):
|
||||
)
|
||||
return None
|
||||
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
f"确定要删除 {name} 吗?",
|
||||
self.window(),
|
||||
)
|
||||
choice = MessageBox("确认", f"确定要删除 {name} 吗?", self.window())
|
||||
if choice.exec():
|
||||
|
||||
self.queue_manager.clear_SettingBox()
|
||||
@@ -164,7 +160,7 @@ class QueueManager(QWidget):
|
||||
|
||||
name = self.queue_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("未选择调度队列")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择调度队列", "请先选择一个调度队列", 5000
|
||||
@@ -209,7 +205,7 @@ class QueueManager(QWidget):
|
||||
|
||||
name = self.queue_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
if name is None:
|
||||
logger.warning("未选择调度队列")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择调度队列", "请先选择一个调度队列", 5000
|
||||
|
||||
@@ -252,9 +252,7 @@ class Setting(QWidget):
|
||||
choice.exec()
|
||||
else:
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
"您没有输入管理密钥,是否取消修改管理密钥?",
|
||||
self.window(),
|
||||
"确认", "您没有输入管理密钥,是否取消修改管理密钥?", self.window()
|
||||
)
|
||||
if choice.exec():
|
||||
break
|
||||
|
||||
@@ -4,7 +4,13 @@
|
||||
"4.3.8.4": {
|
||||
"新增功能": [
|
||||
"支持为每一个用户执行独立通知",
|
||||
"输入文本框适配文本插入操作"
|
||||
"输入文本框适配文本插入操作",
|
||||
"计划表功能上线",
|
||||
"静默控制时长从全任务内缩短至搜索ADB时段内",
|
||||
"UI界面添加自动日常代理任务序列设置项"
|
||||
],
|
||||
"修复bug": [
|
||||
"修复雷电模拟器静默模式无法正常识别模拟器是否隐藏相关问题"
|
||||
]
|
||||
},
|
||||
"4.3.8.3": {
|
||||
@@ -23,7 +29,7 @@
|
||||
"日志分析忽略MAA超时提示"
|
||||
],
|
||||
"程序优化": [
|
||||
"配置类定义方法更新,预载入计划表相关配置"
|
||||
"配置类定义方法更新"
|
||||
]
|
||||
},
|
||||
"4.3.8.1": {
|
||||
|
||||
Reference in New Issue
Block a user