Skip to content

Commit

Permalink
Merge pull request #124 from sanmusen214/dev
Browse files Browse the repository at this point in the history
1.7.0
  • Loading branch information
sanmusen214 authored Nov 5, 2024
2 parents 106bc6a + 8b7abf6 commit 7125fc5
Show file tree
Hide file tree
Showing 22 changed files with 476 additions and 371 deletions.
4 changes: 2 additions & 2 deletions BAAH.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def BAAH_kill_emulator():
杀掉模拟器进程
"""
if (config.userconfigdict["TARGET_EMULATOR_PATH"] and
config.userconfigdict["TARGET_EMULATOR_PATH"] != "" and config.userconfigdict["CLOSE_EMULATOR_BAAH"]):
config.userconfigdict["TARGET_EMULATOR_PATH"] != "" and config.userconfigdict["CLOSE_EMULATOR_FINISH"]):
try:
if not config.sessiondict["EMULATOR_PROCESS_PID"]:
logging.error({"zh_CN": "未能获取到模拟器进程,跳过关闭模拟器",
Expand Down Expand Up @@ -263,7 +263,7 @@ def BAAH_auto_quit(forcewait = False, key_map_func = None):
# 默认值空字典
if key_map_func is None:
key_map_func = dict()
if forcewait or not config.userconfigdict["CLOSE_EMULATOR_BAAH"]:
if forcewait or not config.userconfigdict["CLOSE_BAAH_FINISH"]:
user_input = input(f"Press Enter to exit/回车退出, [{key_map_func.keys()}]:")
for k in key_map_func:
if user_input.upper() == k.upper():
Expand Down
4 changes: 3 additions & 1 deletion BAAH_CONFIGS/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,7 @@
"HARD_QUEST_EVENT_STATUS": false,
"EXCHANGE_EVENT_STATUS": false,
"CONTEST_LEVEL_PRIORITY": 10,
"CONTEST_RANK_PRIORITY": 10
"CONTEST_RANK_PRIORITY": 10,
"CLOSE_EMULATOR_FINISH": true,
"CLOSE_BAAH_FINISH": true
}
6 changes: 5 additions & 1 deletion DATA/i18n/en_US.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"config_file":"Config File",

"task_login_game": "Login Game",
"task_clear_momotalk": "Clear Momotalk",
"task_cafe": "Cafe",
Expand Down Expand Up @@ -48,7 +50,7 @@
"button_save_and_run_gui":"Save and execute (GUI, experimental)",
"button_save_and_run_terminal":"Save and execute (Terminal)",
"button_check_version": "Check for Updates and Download(Make sure BAAH is not running)",
"button_update_advance":"One Click to update to the latest version (experimental)",
"button_update_advance":"One Click to update to the latest version (recommend)",
"button_select_all": "Select All",
"button_select_none": "Deselect All",
"button_enable": "Enable",
Expand All @@ -66,6 +68,8 @@
"config_kill_port": "Whether force to kill the port before starting emulator",
"config_emulator_path": "Emulator Path",
"config_close_emulator_and_baah": "Close Emulator and BAAH After Execution",
"config_close_emulator_when_finish" : "Close Emulator After Execution",
"config_close_BAAH_when_finish" : "Close BAAH After Execution",
"config_desc_times": "About the number of times: 4 times means sweep 4 times, -1 means sweep max times, -2 means sweep max - 2 times.",
"config_nth": "The",
"config_day": "Day",
Expand Down
6 changes: 5 additions & 1 deletion DATA/i18n/jp_JP.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"config_file":"設定ファイル",

"task_login_game": "ゲームにログインする",
"task_clear_momotalk": "モモトークをクリアする",
"task_cafe": "カフェ",
Expand Down Expand Up @@ -48,7 +50,7 @@
"button_save_and_run_gui": "保存して実行(GUI、実験的)",
"button_save_and_run_terminal": "保存して実行(ターミナル)",
"button_check_version": "更新を確認してダウンロードする(BAAHが実行されていないことを確認してください)",
"button_update_advance":"最新バージョンに一括更新(実験的",
"button_update_advance":"最新バージョンに一括更新(推薦する",
"button_select_all": "すべて選択",
"button_select_none": "選択解除",
"button_enable": "有効にする",
Expand All @@ -66,6 +68,8 @@
"config_kill_port": "エミュレータ起動前にポートを強制解放する",
"config_emulator_path": "エミュレータパス",
"config_close_emulator_and_baah": "実行終了後、エミュレータとBAAHを閉じる",
"config_close_emulator_when_finish" : "実行が終了したら、シミュレーターを閉じます",
"config_close_BAAH_when_finish" : "実行が終了したら、BAAHを閉じます",
"config_desc_times": "回数に関する説明:4回は4回扫荡することを意味し、-1回は最大回数(中国版の最大回数をサポート)を意味します。-2回は最大回数から2回扫荡することを意味します。",
"config_nth": "",
"config_day": "",
Expand Down
6 changes: 5 additions & 1 deletion DATA/i18n/zh_CN.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"config_file":"配置文件",

"task_login_game":"登录游戏",
"task_clear_momotalk":"清momotalk",
"task_cafe":"咖啡馆",
Expand Down Expand Up @@ -48,7 +50,7 @@
"button_save_and_run_gui":"保存并执行(GUI,实验性功能)",
"button_save_and_run_terminal":"保存并执行(终端)",
"button_check_version":"检查更新并下载(确保BAAH不在运行),下载完成后请关闭BAAH手动解压更新补丁",
"button_update_advance":"一键更新到最新版本(实验性功能",
"button_update_advance":"一键更新到最新版本(推荐",
"button_select_all":"全选",
"button_select_none":"全不选",
"button_enable":"启用",
Expand All @@ -66,6 +68,8 @@
"config_kill_port": "模拟器启动前强制释放端口",
"config_emulator_path":"模拟器路径",
"config_close_emulator_and_baah": "运行结束后关闭模拟器和BAAH",
"config_close_emulator_when_finish" : "运行结束后关闭模拟器",
"config_close_BAAH_when_finish" : "运行结束后关闭BAAH",
"config_desc_times":"关于次数的说明:4次就是扫荡4次,-1次即为扫荡max次(支持国服max次),-2次即为扫荡max-2次。",
"config_nth":"",
"config_day":"",
Expand Down
1 change: 1 addition & 0 deletions common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .constant import TaskName
27 changes: 27 additions & 0 deletions common/constant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from enum import Enum


class TaskName(Enum):
LOGIN_GAME = "登录游戏"
MOMOTALK = "清momotalk"
CAFE = "咖啡馆"
CAFE_ONLY_TOUCH = "咖啡馆只摸头"
TIMETABLE = "课程表"
CLUB = "社团"
MANUFACTURE = "制造"
STORE = "商店"
BUY_AP = "购买AP"
BOUNTY = "悬赏通缉"
SPECIAL = "特殊任务"
SCHOOL_EXCHANGE_MEETING = "学园交流会"
TACTICAL_CHALLENGE = "战术大赛"
HARD = "困难关卡"
EVENT = "活动关卡"
ASSAULT = "总力战"
DAILY = "每日任务"
MAIL = "邮件"
NORMAL = "普通关卡"
PUSH_NORMAL = "普通推图"
PUSH_HARD = "困难推图"
MAIN_STORY = "主线剧情"
CUSTOM = "自定义任务"
211 changes: 1 addition & 210 deletions gui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,210 +1 @@
# 一个用户config的GUI显示
from nicegui import ui, run
import requests

import os
from gui.components.run_baah_in_gui import run_baah_task
from gui.pages.Setting_BAAH import set_BAAH
from gui.pages.Setting_Craft import set_craft
from gui.pages.Setting_cafe import set_cafe
from gui.pages.Setting_emulator import set_emulator
from gui.pages.Setting_event import set_event
from gui.pages.Setting_exchange import set_exchange
from gui.pages.Setting_hard import set_hard
from gui.pages.Setting_normal import set_normal
from gui.pages.Setting_other import set_other
from gui.pages.Setting_server import set_server
from gui.pages.Setting_shop import set_shop
from gui.pages.Setting_special import set_special
from gui.pages.Setting_task_order import set_task_order
from gui.pages.Setting_timetable import set_timetable
from gui.pages.Setting_wanted import set_wanted
from gui.pages.Setting_notification import set_notification
from gui.pages.Setting_vpn import set_vpn
from gui.pages.Setting_Assault import set_assault
from gui.pages.Setting_BuyAP import set_buyAP
from gui.pages.Setting_UserTask import set_usertask



@ui.refreshable
def show_GUI(load_jsonname, config, shared_softwareconfig):

# 如果是example.json,则大字提醒
if load_jsonname == "example.json":
ui.label(config.get_text("notice_example_json")).style("font-size: 30px; color: red;")

config.parse_user_config(load_jsonname)

# myAllTask里面的key与GUI显示的key的映射
real_taskname_to_show_taskname = {
"登录游戏":config.get_text("task_login_game"),
"清momotalk":config.get_text("task_clear_momotalk"),
"咖啡馆":config.get_text("task_cafe"),
"咖啡馆只摸头":config.get_text("task_cafe_deprecated"), # 为了兼容以前的配置里的咖啡馆只摸头,这里只改显示名
"课程表":config.get_text("task_timetable"),
"社团":config.get_text("task_club"),
"制造":config.get_text("task_craft"),
"商店":config.get_text("task_shop"),
"购买AP":config.get_text("task_buy_ap"),
"悬赏通缉":config.get_text("task_wanted"),
"特殊任务":config.get_text("task_special"),
"学园交流会":config.get_text("task_exchange"),
"战术大赛":config.get_text("task_contest"),
"困难关卡":config.get_text("task_hard"),
"活动关卡":config.get_text("task_event"),
"总力战":config.get_text("task_assault"),
"每日任务":config.get_text("task_daily"),
"邮件":config.get_text("task_mail"),
"普通关卡":config.get_text("task_normal"),
"普通推图":config.get_text("push_normal"),
"困难推图":config.get_text("push_hard"),
"主线剧情":config.get_text("push_main_story"),
"自定义任务":config.get_text("task_user_def_task"),
}

# =============================================

# =============================================

with ui.row().style('min-width: 800px; display: flex; flex-direction: row;flex-wrap: nowrap;'):
with ui.column().style('height:80vh;min-width: 200px; width: 10vw; overflow: auto;flex-grow: 1; position: sticky; top: 0px;'):
with ui.card().style('overflow: auto;'):
ui.link("BAAH", '#BAAH')
ui.link(config.get_text("setting_emulator"), '#EMULATOR')
ui.link(config.get_text("setting_server"), '#SERVER')
ui.link(config.get_text("setting_vpn"), '#VPN')
ui.link(config.get_text("setting_task_order"), '#TASK_ORDER')
ui.link(config.get_text("setting_notification"), '#NOTIFICATION')
# ui.link(config.get_text("setting_next_config"), '#NEXT_CONFIG')
ui.link(config.get_text("task_cafe"), '#CAFE')
ui.link(config.get_text("task_timetable"), '#TIME_TABLE')
ui.link(config.get_text("task_craft"), '#CRAFT')
ui.link(config.get_text("task_shop"), '#SHOP_NORMAL')
ui.link(config.get_text("task_buy_ap"), '#BUY_AP')
ui.link(config.get_text("task_wanted"), '#WANTED')
ui.link(config.get_text("task_special"), '#SPECIAL_TASK')
ui.link(config.get_text("task_exchange"), '#EXCHANGE')
ui.link(config.get_text("task_event"), '#ACTIVITY')
ui.link(config.get_text("task_assault"), '#ASSAULT')
ui.link(config.get_text("task_hard"), '#HARD')
ui.link(config.get_text("task_normal"), '#NORMAL')
ui.link(config.get_text("task_user_def_task"), '#USER_DEF_TASK')
ui.link(config.get_text("setting_other"), '#TOOL_PATH')


with ui.column().style('flex-grow: 4; width: 50vw;'):

set_BAAH(config, shared_softwareconfig)

# 模拟器配置
set_emulator(config)

# 服务器配置
set_server(config)

# 自己的加速器配置
set_vpn(config)

# 任务执行顺序,后续配置文件
set_task_order(config, real_taskname_to_show_taskname)

# 通知
set_notification(config, shared_softwareconfig)

# 咖啡馆
set_cafe(config)

# 课程表
set_timetable(config)

# 制造
set_craft(config)

# 商店
set_shop(config)

# 购买AP
set_buyAP(config)

# 悬赏通缉
set_wanted(config)

# 特殊任务
set_special(config)

# 学园交流会
set_exchange(config)

# 活动关卡
set_event(config)

# 总力战
set_assault(config)

# 困难关卡
set_hard(config, shared_softwareconfig)

# 普通关卡
set_normal(config)

# 用户定义任务
set_usertask(config)

# 其他设置
set_other(config, load_jsonname)

msg_obj = {
"stop_signal": 0,
"runing_signal": 0
}

# GUI运行BAAH打印日志的区域
with ui.column().style('flex-grow: 1;width: 30vw;position:sticky; top: 0px;'):
output_card = ui.card().style('width: 30vw; height: 80vh;overflow-y: auto;')
with output_card:
logArea = ui.log(max_lines=1000).classes('w-full h-full')

with ui.column().style('width: 10vw; overflow: auto; position: fixed; bottom: 40px; right: 20px;min-width: 150px;'):

def save_and_alert():
config.save_user_config(load_jsonname)
config.save_software_config()
shared_softwareconfig.save_software_config()
ui.notify(config.get_text("notice_save_success"))
ui.button(config.get_text("button_save"), on_click=save_and_alert)

def save_and_alert_and_run_in_terminal():
config.save_user_config(load_jsonname)
config.save_software_config()
shared_softwareconfig.save_software_config()
ui.notify(config.get_text("notice_save_success"))
ui.notify(config.get_text("notice_start_run"))
# 打开同目录中的BAAH.exe,传入当前config的json文件名
os.system(f'start BAAH.exe "{load_jsonname}"')
ui.button(config.get_text("button_save_and_run_terminal"), on_click=save_and_alert_and_run_in_terminal)

# ======Run in GUI======
async def save_and_alert_and_run():
config.save_user_config(load_jsonname)
config.save_software_config()
shared_softwareconfig.save_software_config()
ui.notify(config.get_text("notice_save_success"))
ui.notify(config.get_text("notice_start_run"))
# 打开同目录中的BAAH.exe,传入当前config的json文件名
# os.system(f'start BAAH.exe "{load_jsonname}"')
msg_obj["runing_signal"] = 1
await run.io_bound(run_baah_task, msg_obj, logArea, config)
ui.button(config.get_text("button_save_and_run_gui"), on_click=save_and_alert_and_run).bind_visibility_from(msg_obj, "runing_signal", backward=lambda x:x == 0)

async def stop_run() -> None:
msg_obj["stop_signal"] = 1
ui.button(config.get_text("notice_finish_run"), on_click=stop_run, color='red').bind_visibility_from(msg_obj, "runing_signal", backward=lambda x:x == 1)

ui.button("...").bind_visibility_from(msg_obj, "runing_signal", backward=lambda x:x == 0.25)

# ================

# 加载完毕保存一下config,应用最新的对config的更改
config.save_user_config(load_jsonname)
config.save_software_config()
from .refactor_pages import *
Loading

0 comments on commit 7125fc5

Please sign in to comment.