Skip to content

Commit

Permalink
Check DPI; User Note; Quest Event; ScreenCut bug (#105)
Browse files Browse the repository at this point in the history
* Feat: check dpi when start up

* Fix: Encap and add screen_cut signal

* Remove print

* 交换25-1的队伍颜色,与25的其它关卡保持一致 (#102)

25-2到25-5都是A队黄色B队紫色,把25-1的队伍颜色交换以保持一致。

Co-authored-by: Yusen Wu <[email protected]>

* Feat: Note in GUI

* #56 (#94)

* add: Check event active status button

* add:  normal, hard, exchange - check status button

* fix : special, exchange - check point

* fix exchange and jp special

* fix : global quest

* fix:HardQuest

* Remove : useless notes

* fix: special and exchange

---------

Co-authored-by: Yusen Wu <[email protected]>

* chore: text format

* version 1.6.2

---------

Co-authored-by: Peter Li <[email protected]>
Co-authored-by: LLL1997 <[email protected]>
  • Loading branch information
3 people authored Aug 18, 2024
1 parent 4b77ae5 commit 56de335
Show file tree
Hide file tree
Showing 22 changed files with 125 additions and 51 deletions.
6 changes: 5 additions & 1 deletion BAAH_CONFIGS/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,9 @@
"USER_DEF_TASKS": "",
"PUSH_NORMAL_USE_SIMPLE": false,
"PUSH_HARD_USE_SIMPLE": false,
"CRAFT_TIMES": 1
"CRAFT_TIMES": 1,
"SPEICAL_EVENT_STATUS": false,
"NORMAL_QUEST_EVENT_STATUS": false,
"HARD_QUEST_EVENT_STATUS": false,
"EXCHANGE_EVENT_STATUS": false
}
24 changes: 12 additions & 12 deletions DATA/grid_solution/quest/25-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,59 @@
"initial_teams": [
{
"name": "A",
"type": "purple",
"position": "left-down"
"type": "yellow",
"position": "right-up"
},
{
"name": "B",
"type": "yellow",
"position": "right-up"
"type": "purple",
"position": "left-down"
}
],
"fight_plan": [
[
{
"team": "A",
"team": "B",
"action": "move",
"target": "left-up"
},
{
"team": "B",
"team": "A",
"action": "move",
"target": "left-down"
}
],
[
{
"team": "B",
"team": "A",
"action": "move",
"target": "left-down"
},
{
"team": "A",
"team": "B",
"action": "move",
"target": "left-up"
}
],
[
{
"team": "B",
"team": "A",
"action": "move",
"target": "right-up"
},
{
"team": "A",
"team": "B",
"action": "move",
"target": "right-up"
}
],
[
{
"team": "A",
"team": "B",
"action": "move",
"target": "right-up"
}
]
]
}
}
}
8 changes: 5 additions & 3 deletions DATA/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button_get_now_app":"Get Current App Activity",
"button_get_now_app_enter":"Get Current App Enter Activity",
"button_edit":"Edit",
"button_show":"Show",
"button_hide":"Hide",

"config_cafe_attention": "For the global/JP server, please zoom out the camera, and keep the following item checked",
"config_camera_full": "Enter Cafe with Maximum Camera View",
Expand Down Expand Up @@ -137,6 +139,7 @@
"config_use_simple_explore":"Use simple explore",
"config_craft_desc":"Currently, the craft task only supports one node and does not support the priority of specified items. After the Chinese server implements one-click manufacturing, it will be supported through one-click manufacturing",
"config_craft_max_times":"Maximum times of craft",
"desc_note":"Note",

"config_server_jp": "Japanese Server",
"config_server_cn": "Chinese Official Server",
Expand All @@ -145,6 +148,7 @@
"config_server_global_en" : "Global Server (English)",


"config_event_status": "Execute only when the event is active",



Expand All @@ -153,9 +157,7 @@








"status_finish": "All Tasks Completed"
}
6 changes: 4 additions & 2 deletions DATA/i18n/jp_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button_get_now_app": "現在のページを取得",
"button_get_now_app_enter": "現在のアプリの入り口ページを取得",
"button_edit": "編集",
"button_show":"表示",
"button_hide":"非表示",

"config_cafe_attention": "カフェの視点を最大にしてください。以下の項目をチェックして効率を向上させます",
"config_camera_full": "カフェに入るときに視点が最大になる",
Expand Down Expand Up @@ -137,6 +139,7 @@
"config_use_simple_explore":"簡易攻略を使用する",
"config_craft_desc":"現在、クラフトタスクは1つのノードのみをサポートし、指定されたアイテムの優先順位をサポートしていません。国内サーバーがワンクリック製造を実装した後、ワンクリック製造を使用してサポートする予定です",
"config_craft_max_times":"最大製造回数",
"desc_note":"備考",

"config_server_jp": "日本サーバー",
"config_server_cn": "中国公式サーバー",
Expand All @@ -145,8 +148,7 @@
"config_server_global_en": "国際版(英語)",




"config_event_status": "イベントがアクティブな状態のときにのみ実行する",



Expand Down
7 changes: 4 additions & 3 deletions DATA/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button_get_now_app":"获取当前页面",
"button_get_now_app_enter":"获取当前应用的入口页面",
"button_edit":"编辑",
"button_show":"显示",
"button_hide":"隐藏",

"config_cafe_attention":"请将咖啡馆视角拉到最高,保持勾选以下这项以提高效率",
"config_camera_full":"进入咖啡馆时视角为最高",
Expand Down Expand Up @@ -137,7 +139,7 @@
"config_use_simple_explore":"使用简易攻略",
"config_craft_desc":"制造任务目前只能一个节点,且不支持指定物品的优先级,等国服实装一键制造后会通过一键制造来支持",
"config_craft_max_times":"尝试制造次数",

"desc_note":"备注",

"config_server_jp":"日服",
"config_server_cn":"国服官服",
Expand All @@ -146,8 +148,7 @@
"config_server_global_en" : "国际服(英文)",




"config_event_status": "是否只在活动开启状态下执行",



Expand Down
2 changes: 1 addition & 1 deletion gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def show_GUI(load_jsonname, config, shared_softwareconfig):
set_assault(config)

# 困难关卡
set_hard(config)
set_hard(config, shared_softwareconfig)

# 普通关卡
set_normal(config)
Expand Down
22 changes: 15 additions & 7 deletions gui/components/cut_screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,31 @@ def screencut_button(inconfig, resultdict, resultkey, input_text="Screencut", bu

with ui.row():
ui.input(input_text).bind_value(resultdict, resultkey).style("width: 400px")
ui.button(button_text, on_click=lambda: cut_screenshot(inconfig=inconfig, resultdict=resultdict, resultkey=resultkey))

ui.button(button_text, on_click=lambda: cut_screenshot(inconfig=inconfig, resultdict=resultdict, resultkey=resultkey, left_click=True, right_click=False, quick_return=True))


async def cut_screenshot(inconfig, resultdict, resultkey):
cut_lock = False
async def cut_screenshot(inconfig, resultdict=None, resultkey=None, left_click=True, right_click=False, quick_return=True):
"""
截取截图的一部分,返回截图文件名
"""

global cut_lock
if cut_lock:
print("Multiple cut_screenshot is not allowed")
return
cut_lock = True
connect_to_device(use_config=inconfig)
screen_shot_to_global(use_config=inconfig)
screenshotname = inconfig.userconfigdict['SCREENSHOT_NAME']
result = await run.io_bound(
screencut_tool,
left_click=True,
right_click=False,
left_click=left_click,
right_click=right_click,
img_path=screenshotname,
quick_return=True
quick_return=quick_return
)
resultdict[resultkey] = result
if resultdict is not None and resultkey is not None:
resultdict[resultkey] = result
cut_lock = False
return result
2 changes: 1 addition & 1 deletion gui/pages/Setting_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def set_exchange(config):
ui.label(config.get_text("task_exchange")).style('font-size: x-large')

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

ui.switch(config.get_text("config_event_status")).bind_value(config.userconfigdict, "EXCHANGE_EVENT_STATUS")
list_edit_area(
config.userconfigdict["EXCHANGE_HIGHEST_LEVEL"],
[
Expand Down
7 changes: 6 additions & 1 deletion gui/pages/Setting_hard.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from nicegui import ui
from gui.components.list_edit_area import list_edit_area

def set_hard(config):
def set_hard(config, shared_softwareconfig):
with ui.row():
ui.link_target("HARD")
ui.label(config.get_text("task_hard")).style('font-size: x-large')

ui.label(config.get_text("config_desc_times"))
ui.switch(config.get_text("config_event_status")).bind_value(config.userconfigdict, "HARD_QUEST_EVENT_STATUS")

show_note = {"val": False}
ui.switch(config.get_text("button_show")+config.get_text("desc_note")).bind_value(show_note, "val")
ui.textarea().bind_value(shared_softwareconfig.softwareconfigdict["NOTE"], "HARD_NOTE").style("width: 70%").bind_visibility_from(show_note, "val")

list_edit_area(
config.userconfigdict["HARD"],
Expand Down
2 changes: 1 addition & 1 deletion gui/pages/Setting_normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def set_normal(config):
ui.label(config.get_text("task_normal")).style('font-size: x-large')

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

ui.switch(config.get_text("config_event_status")).bind_value(config.userconfigdict, "NORMAL_QUEST_EVENT_STATUS")
list_edit_area(
config.userconfigdict["NORMAL"],
[
Expand Down
12 changes: 5 additions & 7 deletions gui/pages/Setting_other.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from nicegui import ui, run
from gui.components.cut_screenshot import cut_screenshot
from gui.components.list_edit_area import list_edit_area
import os

Expand Down Expand Up @@ -63,15 +64,12 @@ def set_other(config, load_jsonname):
# ui.button("测试截图/screencut test", on_click=lambda: os.system(f'start screencut.exe "{load_jsonname}"'))

async def test_screencut():
connect_to_device(use_config=config)
screen_shot_to_global(use_config=config)
screenshotname = config.userconfigdict['SCREENSHOT_NAME']
await run.io_bound(
screencut_tool,
await cut_screenshot(
inconfig=config,
left_click=True,
right_click=True,
img_path=screenshotname
)
quick_return=False
)

# 将截图功能内嵌进GUI
with ui.row():
Expand Down
2 changes: 1 addition & 1 deletion gui/pages/Setting_special.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def set_special(config):
ui.label(config.get_text("task_special")).style('font-size: x-large')

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

ui.switch(config.get_text("config_event_status")).bind_value(config.userconfigdict, "SPEICAL_EVENT_STATUS")
list_edit_area(
config.userconfigdict["SPECIAL_HIGHTEST_LEVEL"],
[
Expand Down
11 changes: 5 additions & 6 deletions gui/pages/Setting_vpn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from nicegui import ui, run
from gui.components.cut_screenshot import cut_screenshot
from modules.utils import connect_to_device, get_now_running_app, get_now_running_app_entrance_activity, screen_shot_to_global, screencut_tool

def set_vpn(config):
Expand Down Expand Up @@ -41,14 +42,12 @@ async def set_click_pos_of_line(lineind):
"""
设置点击位置
"""
connect_to_device(use_config=config)
screen_shot_to_global(use_config=config)
screenshotname = config.userconfigdict['SCREENSHOT_NAME']
click_and_wait_list[lineind][0] = await run.io_bound(
screencut_tool,
await cut_screenshot(
inconfig=config,
resultdict=click_and_wait_list[lineind],
resultkey=0,
left_click=True,
right_click=True,
img_path=screenshotname,
quick_return=True
)
show_table.refresh()
Expand Down
8 changes: 8 additions & 0 deletions modules/AllPage/Page.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ class Page:
"""
用于交战时右上角暂停按钮的像素识别,按钮有时半透明,受到游戏内交战环境影响,阈值可以低点
"""

COLOR_BUTTON_GRAY = ((200, 200, 200), (230, 230, 230))


COLOR_PINK = ((175, 130, 250 ), (202, 155, 255 ))
"""
用于判断是否在活动中,如果在活动(双倍/三倍活动)中,这个颜色的横幅会出现在选关时左上角
"""

# 父类
def __init__(self, pagename) -> None:
self.name = pagename
Expand Down
6 changes: 5 additions & 1 deletion modules/AllTask/InExchange/InExchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from modules.AllPage.Page import Page
from modules.AllTask.Task import Task

from modules.utils import click, swipe, match, page_pic, button_pic, popup_pic, sleep, ocr_area_0
from modules.utils import click, swipe, match, page_pic, button_pic, popup_pic, sleep, ocr_area_0,match_pixel,screenshot
from modules.utils.log_utils import logging
import time
import numpy as np
Expand Down Expand Up @@ -72,6 +72,10 @@ def on_run(self) -> None:
lambda: click((963, points[each_target[0]])),
lambda: Page.is_page(PageName.PAGE_EXCHANGE_SUB),
)
# 判断是否在活动开启期间
if config.userconfigdict["SPEICAL_EVENT_STATUS"] and each_target == target_info[0] and not match_pixel((195, 221), Page.COLOR_PINK,printit=True):
logging.warn({"zh_CN": "设置为没有活动不进行,跳过", "en_US":"event is not open, skip"})
break
# 扫荡对应的level
RunExchangeFight(levelnum = each_target[1], runtimes = each_target[2]).run()
# 如果是回到SUB界面之后,点击一下返回,如果是回到EXCHANGE界面,就不用点击了
Expand Down
3 changes: 3 additions & 0 deletions modules/AllTask/InQuest/HardQuest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def on_run(self) -> None:
lambda: click((1064, 161)),
lambda: match(button_pic(ButtonName.BUTTON_HARD))
)
if config.userconfigdict["HARD_QUEST_EVENT_STATUS"] and not match_pixel((155, 266), Page.COLOR_PINK,printit=True):
logging.warn({"zh_CN": "今天没有开启活动,跳过", "en_US":"Today is not in the activity, skip"})
return
# after switch to hard, go to the page
for each_quest in self.questlist:
to_page_num = each_quest[0] + 1
Expand Down
5 changes: 4 additions & 1 deletion modules/AllTask/InQuest/NormalQuest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, questlist, name="NormalQuest") -> None:
super().__init__(name)
self.questlist = questlist


def pre_condition(self) -> bool:
return Page.is_page(PageName.PAGE_QUEST_SEL)

Expand All @@ -30,6 +30,9 @@ def on_run(self) -> None:
lambda: click((798, 159)),
lambda: match(button_pic(ButtonName.BUTTON_NORMAL))
)
if config.userconfigdict["NORMAL_QUEST_EVENT_STATUS"] and not match_pixel((155, 266), Page.COLOR_PINK, printit=True):
logging.warn({"zh_CN": "今天没有开启活动,跳过", "en_US":"Today is not in the activity, skip"})
return
# after switch to normal, go to the page
for each_quest in self.questlist:
to_page_num = each_quest[0]+1
Expand Down
Loading

0 comments on commit 56de335

Please sign in to comment.