Skip to content

Commit

Permalink
Merge pull request #160 from sanmusen214/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sanmusen214 authored Jan 10, 2025
2 parents f2be1cf + f9959dd commit 732850c
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 34 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
tools/
test.spec
jsoneditor.spec
BAAH_UPDATE.spec
BAAH.spec
*.spec
compact_log.txt
/*.png
/DATA/CONFIGS/software_config.json
Expand Down
2 changes: 1 addition & 1 deletion DATA/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"vpn_desc":"If you want to use VPN application",
"cafe_collect_desc":"Whether collect in cafe",
"cafe_touch_desc":"Whether touch in cafe",
"cafe_invite_desc":"Whether invite in cafe (the first or second in the invitation list)",
"cafe_invite_desc":"cafe invite which student (0 means no invite)",
"raise_error_if_can_not_push_event_level": "Raise error if can not push event level",
"config_email_advaned":"Advanced Email Configuration",
"config_email_sender":"Sender Email",
Expand Down
2 changes: 1 addition & 1 deletion DATA/i18n/jp_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"vpn_desc": "エミュレータ内の加速器ソフトウェアを手動でシミュレートするためにこの項目をチェックします(MUMU自動加速を使用することをお勧めします)。編集をクリックすると、左クリックでスクリーンショットをドラッグし、右クリックで座標を確定します",
"cafe_collect_desc": "カフェでのコレクションをするかどうか",
"cafe_touch_desc": "カフェでのなでなでをするかどうか",
"cafe_invite_desc": "カフェでの招待をするかどうか(デフォルトは1番目/2番目のリスト",
"cafe_invite_desc": "カフェでの学生の招待番号(0は招待しない",
"raise_error_if_can_not_push_event_level": "この項目をチェックすると、イベントステージが3つ星にならない場合にエラーが発生し、チェックを外すとエラーが発生しても次のタスクが実行されます",
"config_email_advaned": "カスタムメール送信サーバー",
"config_email_sender": "送信者のメールアドレス",
Expand Down
2 changes: 1 addition & 1 deletion DATA/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"vpn_desc":"勾选此项来模拟手动开启模拟器里的加速器软件(建议使用MUMU自动加速)。点击编辑后,左键拖拽截图;右键点击确定坐标点",
"cafe_collect_desc":"咖啡馆是否收集",
"cafe_touch_desc":"咖啡馆是否摸头",
"cafe_invite_desc":"咖啡馆是否邀请(默认邀请列表第一个/第二个",
"cafe_invite_desc":"号咖啡馆邀请学生序号(0为不邀请",
"raise_error_if_can_not_push_event_level":"勾选此项,推图无法三星时会报错;取消勾选以略过错误执行下一个任务",
"config_email_advaned":"自定义邮件发送服务器",
"config_email_sender":"发件人邮箱",
Expand Down
2 changes: 1 addition & 1 deletion gui/define.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# 构造一个config,用于在tab间共享softwareconfigdict
gui_shared_config = MyConfigger()

gui_shared_config.save_software_config() # 保存下全局的softwareconfigdict,以记录版本变更
# 用于注入到配置页面的js,使tab内容间滚动
injectJSforTabs = """
<script>
Expand Down
22 changes: 15 additions & 7 deletions gui/pages/Setting_cafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ def set_cafe(config):
ui.link_target("CAFE")
ui.label(config.get_text("task_cafe")).style('font-size: x-large')

ui.label(config.get_text("config_cafe_attention"))

# 收集
with ui.row():
ui.checkbox(config.get_text("cafe_collect_desc")).bind_value(config.userconfigdict, "CAFE_COLLECT")


# 摸头
with ui.row():
ui.checkbox(config.get_text("cafe_touch_desc")).bind_value(config.userconfigdict, "CAFE_TOUCH")
full_camera = ui.checkbox(config.get_text("config_camera_full")).bind_value(config.userconfigdict, "CAFE_CAMERA_FULL").bind_visibility_from(config.userconfigdict, "CAFE_TOUCH")
full_camera.set_value(True)
full_camera.set_enabled(False)
ui.checkbox(config.get_text("enable_diff_touch")).bind_value(config.userconfigdict, "CAFE_TOUCH_WAY_DIFF").bind_visibility_from(config.userconfigdict, "CAFE_TOUCH")

with ui.row():
ui.checkbox(config.get_text("cafe_invite_desc")).bind_value(config.userconfigdict, "CAFE_INVITE").bind_visibility_from(config.userconfigdict, "CAFE_TOUCH")
# 一号咖啡馆邀请
ui.number("1" + config.get_text("cafe_invite_desc"), min=0, max=2, precision=0, step=1).bind_value(config.userconfigdict, "CAFE1_INVITE_SEQ", forward=lambda x:int(x), backward=lambda x: int(x)).bind_visibility_from(config.userconfigdict, "CAFE_TOUCH").style("width: 200px;")
# 二号咖啡馆邀请
ui.number("2" + config.get_text("cafe_invite_desc"), min=0, max=2, precision=0, step=1).bind_value(config.userconfigdict, "CAFE2_INVITE_SEQ", forward=lambda x:int(x), backward=lambda x: int(x)).bind_visibility_from(config.userconfigdict, "CAFE_TOUCH").style("width: 200px;")



# 关于视角的提示
ui.label(config.get_text("config_cafe_attention"))
full_camera = ui.checkbox(config.get_text("config_camera_full")).bind_value(config.userconfigdict, "CAFE_CAMERA_FULL").bind_visibility_from(config.userconfigdict, "CAFE_TOUCH")
full_camera.set_value(True)
full_camera.set_enabled(False)
6 changes: 4 additions & 2 deletions modules/AllTask/InCafe/InCafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def on_run(self) -> None:
TouchHead().run()
if self.invite:
config.sessiondict["CAFE_HAD_INVITED"] = False
InviteStudent(0).run()
if config.userconfigdict["CAFE1_INVITE_SEQ"] > 0:
InviteStudent(config.userconfigdict["CAFE1_INVITE_SEQ"]-1).run()
if config.sessiondict["CAFE_HAD_INVITED"]:
TouchHead(try_touch_epoch=1).run()
else:
Expand Down Expand Up @@ -75,7 +76,8 @@ def on_run(self) -> None:
TouchHead().run()
if self.invite:
config.sessiondict["CAFE_HAD_INVITED"] = False
InviteStudent(1).run()
if config.userconfigdict["CAFE2_INVITE_SEQ"] > 0:
InviteStudent(config.userconfigdict["CAFE2_INVITE_SEQ"]-1).run()
if config.sessiondict["CAFE_HAD_INVITED"]:
TouchHead(try_touch_epoch=1).run()
else:
Expand Down
6 changes: 3 additions & 3 deletions modules/AllTask/InCafe/InviteStudent.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def on_run(self) -> None:
# 打开确认弹窗
# 默认邀请第一个学生
click_pos = (787, 225)
# 如果邀请第二个学生
if self.stuind == 1:
click_pos = (785, 303)
# 如果邀请第n个学生
for i in range(self.stuind):
click_pos[1] += 78
# 邀请
self.run_until(
lambda: click(click_pos),
Expand Down
2 changes: 1 addition & 1 deletion modules/AllTask/InEvent/InEvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def on_run(self) -> None:
# 序号转下标
quest_list_2 = [[x[0] - 1, x[1], *x[2:]] for x in quest_list]
# do Event QUEST
EventQuest(quest_list_2, quest_button_xy=self.quest_button_xy).run()
EventQuest(quest_list_2, explore=False, raid=True, collect=True, quest_button_xy=self.quest_button_xy).run()

def post_condition(self) -> bool:
config.sessiondict["HAS_ENTER_EVENT"] = True
Expand Down
7 changes: 5 additions & 2 deletions modules/AllTask/SubTask/FightQuest.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,19 @@ def on_run(self) -> None:
sleeptime=2
)
logging.info({"zh_CN": "等待战斗结束...", "en_US": "Waiting for the battle to end..."})
# 点魔法点直到战斗结束 或匹配到应当返回的界面
skip_story = SkipStory()
# 点魔法点直到战斗结束 或匹配到应当返回的界面,或匹配到story界面
self.run_until(
lambda: click(Page.MAGICPOINT),
lambda: match(button_pic(ButtonName.BUTTON_FIGHT_RESULT_CONFIRMB)) or match(
button_pic(ButtonName.BUTTON_CONFIRMY),
threshold=0.8
) or self.backtopic(),
) or self.backtopic() or skip_story.pre_condition(),
times=90,
sleeptime=2
)
if skip_story.pre_condition():
skip_story.run()
if self.backtopic():
# 此处返回到backtopic,意味着错误进入了战斗
click(Page.MAGICPOINT)
Expand Down
2 changes: 1 addition & 1 deletion modules/configs/MyConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MyConfigger:
"""
维护config字典,包含软件config,用户任务config,语言包
"""
NOWVERSION="1.8.9"
NOWVERSION="1.8.10"
USER_CONFIG_FOLDER="./BAAH_CONFIGS"
SOFTWARE_CONFIG_FOLDER="./DATA/CONFIGS"
LANGUAGE_PACKAGE_FOLDER="./DATA/i18n"
Expand Down
12 changes: 10 additions & 2 deletions modules/configs/defaultSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@
"AUTO_PUSH_EVENT_QUEST":{"d":True},
"CAFE_COLLECT":{"d":True},
"CAFE_TOUCH":{"d":True},
"CAFE_INVITE":{"d":True},
"CAFE_INVITE":{
"d":True,
"p": lambda val, parsedjson: True # 1.8.10 deprecated
},
"RAISE_ERROR_IF_CANNOT_PUSH_EVENT_QUEST":{"d":True},

# 多倍活动开启状态相关
Expand Down Expand Up @@ -223,7 +226,12 @@
{"red":10, "blue":10, "yellow":10, "purple":10},
{"red":0, "blue":0, "yellow":0, "purple":0}
]
}
},

# 咖啡馆设置
# 要邀请的学生在momotalk中的序号,从1开始
"CAFE1_INVITE_SEQ":{"d":1},
"CAFE2_INVITE_SEQ":{"d":2},
}

# 软件的config里的默认值
Expand Down
54 changes: 46 additions & 8 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,36 @@
import os
import zipfile
import time
import sys

# 本文件内容不要频繁变更
print("This Updator Version: 0.1.0")
updater_version = "0.2.0"
print(f"This Updator Version: {updater_version}")

def copy_to_temp_and_run():
"""
如果当前文件不是temp,创造并运行temp
返回True时,代表当前文件是update
返回False时,代表当前文件是temp
"""
# 获取当前文件的绝对路径
# print(os.path.realpath(sys.argv[0]))
path = os.path.realpath(sys.executable)
# print(os.path.dirname(os.path.realpath(sys.argv[0])))
print(f"This exe file path is: {os.path.dirname(path)}")
temp_update_name = "update_temp.exe"
if not path.endswith(temp_update_name):
# 复制此文件并且粘贴为temp.exe
with open(path, "rb") as f:
content = f.read()
with open(temp_update_name, "wb") as f2:
f2.write(content)
# 执行temp.exe
os.system(f'start {temp_update_name}')
return True
else:
print(f"This is {temp_update_name}")
return False

def get_one_version_num(versionstr=None):
"""
Expand Down Expand Up @@ -208,15 +235,22 @@ def check_and_update():
# 删除下载的zip文件
os.remove(targetfilename)
print(f"Deleted the downloaded ZIP file: {targetfilename}.")

open_GUI_again = False
if __name__ == "__main__":

def main():
try:
check_and_update()
print("========== [UPDATE SUCCESS] =========")
is_update_file = copy_to_temp_and_run()
if not is_update_file:
# 如果是temp,执行check_and_update
check_and_update()
print("========== [UPDATE SUCCESS] =========")
else:
# 如果是update本体,直接退出,让temp执行
return
except Exception as e:
traceback.print_exc()
print("========== ERROR! =========")
print("========== [ERROR!] =========")
if "BAAH_UPDATE.exe" in str(e) and "Permission denied" in str(e):
print(">>> You can not use this script to replace itself. Please unpack the zip manually. <<<")

Expand All @@ -230,4 +264,8 @@ def check_and_update():
except Exception as e:
print(f"Failed to start BAAH_GUI.exe: {e}")

input("Press Enter to exit the updater.")
input("Press Enter to exit: ")


if __name__ == "__main__":
main()

0 comments on commit 732850c

Please sign in to comment.