Skip to content

Commit

Permalink
Merge pull request #109 from sanmusen214/dev
Browse files Browse the repository at this point in the history
1.6.4
  • Loading branch information
sanmusen214 authored Sep 3, 2024
2 parents 90b70ff + 4fbdd8e commit e55db71
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 14 deletions.
29 changes: 21 additions & 8 deletions BAAH.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def print_BAAH_info():
print("||" + "".center(80, " ") + "||")
print("+" + "".center(80, "=") + "+")

def print_BAAH_start():
print_BAAH_info()
def print_BAAH_config_info():
# 打印config信息
logging.info({"zh_CN": f"读取的配置文件: {config.nowuserconfigname}", "en_US": f"Read config file: {config.nowuserconfigname}"})
logging.info({"zh_CN": f"模拟器:{config.userconfigdict['TARGET_EMULATOR_PATH']}",
Expand Down Expand Up @@ -191,7 +190,7 @@ def BAAH_run_post_command():

def BAAH_kill_emulator():
"""
杀掉模拟器的用户可见窗口进程
杀掉模拟器进程
"""
if (config.userconfigdict["TARGET_EMULATOR_PATH"] and
config.userconfigdict["TARGET_EMULATOR_PATH"] != "" and config.userconfigdict["CLOSE_EMULATOR_BAAH"]):
Expand Down Expand Up @@ -250,18 +249,26 @@ def BAAH_send_email():
info_str += f"{info}\n"
content.append(info_str)
# 发送
notificationer.send("\n".join(content))
fullcontent = "\r\n".join(content)
notificationer.send(fullcontent)
logging.info({"zh_CN": "通知发送结束", "en_US": "Finished sending notification"})
except Exception as e:
logging.error({"zh_CN": "发送通知失败", "en_US": "Failed to send notification"})
logging.error(e)

def BAAH_auto_quit(forcewait = False):
def BAAH_auto_quit(forcewait = False, key_map_func = None):
""" 结束运行,如果用户没有勾选自动关闭模拟器与BAAH,等待用户按回车键 """
# 用于GUI识别是否结束的关键字
print("GUI_BAAH_TASK_END")
# 默认值空字典
if key_map_func is None:
key_map_func = dict()
if forcewait or not config.userconfigdict["CLOSE_EMULATOR_BAAH"]:
input("Press Enter to exit/回车退出:")
user_input = input(f"Press Enter to exit/回车退出, [{key_map_func.keys()}]:")
for k in key_map_func:
if user_input.upper() == k.upper():
key_map_func[k]()
break
else:
logging.info({"zh_CN": "10秒后自动关闭", "en_US": "Auto close in 10 seconds"})
sleep(10)
Expand Down Expand Up @@ -300,7 +307,8 @@ def BAAH_main():
"""
try:
config.sessiondict["BAAH_START_TIME"] = time.strftime("%Y-%m-%d %H:%M:%S")
print_BAAH_start()
print_BAAH_info()
print_BAAH_config_info()
BAAH_run_pre_command()
BAAH_release_adb_port()
BAAH_start_emulator()
Expand All @@ -318,6 +326,7 @@ def BAAH_main():
BAAH_rm_pic()
BAAH_run_post_command()

print_BAAH_config_info()
BAAH_auto_quit()


Expand All @@ -328,4 +337,8 @@ def BAAH_main():
traceback.print_exc()
BAAH_send_err_mail(e)
print_BAAH_finish()
BAAH_auto_quit(forcewait=True)

print_BAAH_config_info()
BAAH_auto_quit(forcewait=True, key_map_func={
"R": lambda: [config.parse_user_config(config.nowuserconfigname), BAAH_main()]
})
Binary file modified DATA/assets/PAGE/PAGE_EDIT_QUEST_TEAM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified DATA/assets_global_en/PAGE/PAGE_EDIT_QUEST_TEAM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified DATA/assets_jp/PAGE/PAGE_EDIT_QUEST_TEAM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion modules/AllTask/InCraft/InCraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,41 @@ def dealing_with_craft_details(self):
选择制造内容,确定制造
"""
#! 点击开放节点按钮后,如果没有走到最后一步,那么下次进入制造页面时,会直接跳转到这里
# 点左下角节点,使节点左移
# 点左下角节点,使左上角超大一个UI节点左移
COLOR_W_CIRCLE = ((252, 252, 245), (255, 255, 252))
POS_W_LEFT = (156, 109)
# 黄色小节点
COLOR_YELLOW_CRAFT_POINT = ((120, 180, 250), (190, 255, 255))
# 五个节点坐标
ALL_POINTS = (
(174, 554),
(303, 531),
(413, 474),
(505, 388),
(570, 276)
)
self.run_until(
lambda: click((444, 554)),
lambda: match_pixel(POS_W_LEFT, COLOR_W_CIRCLE),
times=3
)
sleep(0.7)
# 选择具体节点 并确定
# 从五个节点里面挑黄的出来,没有的话就第一个
logging.info(istr({
CN:"进入节点页面,选择制造节点",
EN:"At Node Selection Page, select the craft node"
}))
for point in ALL_POINTS:
if match_pixel(point, COLOR_YELLOW_CRAFT_POINT):
click(point)
break
# 第一个制造节点结束
# 点击右下角按钮, 直到出现弹窗
logging.info(istr({
CN:"开始制造",
EN:"Start crafting"
}))
self.run_until(
lambda: click(self.BUTTON_CRAFT),
lambda: self.has_popup(),
Expand Down
5 changes: 4 additions & 1 deletion modules/AllTask/Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from modules.utils import click, swipe, match, page_pic, match_pixel, button_pic, popup_pic, sleep, screenshot, config

from modules.utils.adb_utils import check_app_running, open_app
from modules.utils.log_utils import logging


Expand Down Expand Up @@ -73,12 +74,14 @@ def run(self) -> None:
@staticmethod
def back_to_home(times = 3) -> bool:
"""
尝试从游戏内的页面返回主页
尝试返回到游戏主页,如果游戏不在前台,会尝试打开游戏到前台,但不会等待登录加载,因此必须确保游戏在后台
返回成功与否
"""
logging.info({"zh_CN": "尝试返回主页", "en_US":"Try back to homepage"})
can_back_home = False
if not check_app_running(config.userconfigdict["ACTIVITY_PATH"]):
open_app(config.userconfigdict["ACTIVITY_PATH"])
for i in range(times):
click(Page.MAGICPOINT, sleeptime=0.1)
click(Page.MAGICPOINT, sleeptime=0.2)
Expand Down
2 changes: 1 addition & 1 deletion modules/configs/MyConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MyConfigger:
"""
维护config字典,包含软件config,用户任务config,语言包
"""
NOWVERSION="1.6.3"
NOWVERSION="1.6.4"
USER_CONFIG_FOLDER="./BAAH_CONFIGS"
SOFTWARE_CONFIG_FOLDER="./DATA/CONFIGS"
LANGUAGE_PACKAGE_FOLDER="./DATA/i18n"
Expand Down
9 changes: 7 additions & 2 deletions modules/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,16 @@ def check_connect():
# 第一维度是高,第二维度是宽
elif img.shape[0] == 720 and img.shape[1] == 1280:
logging.info({"zh_CN": "图片分辨率为1280*720", "en_US":"The resolution is 1280*720"})
if "240" not in get_dpi():
raise Exception(istr({
dpi_res = get_dpi()
logging.info(f"DPI: {dpi_res}")
if "240" not in dpi_res:
logging.warn(istr({
CN: "请设置模拟器dpi为240",
EN: "Please set the emulator dpi to 240"
}))
# auto fix
set_dpi(240)
return False
return True
elif img.shape[0] == 1280 and img.shape[1] == 720:
logging.warn({"zh_CN": "图片分辨率为720*1280,可能是模拟器设置错误,也可能是模拟器bug", "en_US":"The resolution is 720*1280, it may be the wrong setting of the emulator, or it may be a bug of the emulator"})
Expand Down
11 changes: 11 additions & 0 deletions modules/utils/adb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ def get_dpi(use_config=None):
dpires = subprocess_run([get_config_adb_path(use_config), "-s", getNewestSeialNumber(use_config), "shell", "wm", "density"]).stdout
return dpires

def set_dpi(target_dpi, use_config=None):
"""
set DPI
"""
if not use_config:
use_config = config
if isinstance(target_dpi, float):
target_dpi = int(target_dpi)
subprocess_run([get_config_adb_path(use_config), "-s", getNewestSeialNumber(use_config), "shell", "wm", "density", str(target_dpi)], isasync=True)


# NO_NEED = "NO_NEED"
# ERROR = "ERROR"
# FAILED = "FAILED"
Expand Down
2 changes: 1 addition & 1 deletion modules/utils/log_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def format_msg(self, msg, level):
# 目前EN = "en_US",与传入的json的代表英语的key是对应的
if EN in msg:
msg = msg[EN]
return f"{strftime('%d-%b-%y %H:%M:%S')} - {level} : {str(msg)}"
return f"{config.NOWVERSION} - {strftime('%M:%S')} - {level} : {str(msg)}"

def colorful_print(self, msg, level):
"""
Expand Down

0 comments on commit e55db71

Please sign in to comment.