Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pur1fying committed Dec 30, 2023
2 parents e264b37 + db13d9e commit fd108e9
Show file tree
Hide file tree
Showing 19 changed files with 747 additions and 124 deletions.
7 changes: 4 additions & 3 deletions core/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,17 @@
"explore_normal_task_regions": [
],
"explore_hard_task_regions": [
],
"explore_hard_task_list": "此处填写需要推图的关卡",
"manual_boss": false,
"burst1": "1",
"burst2": "2",
"pierce1": "1",
"pierce2": "2",
"mystic1": "1",
"mystic2": "2",
"explore_hard_task_need_sss": true,
"explore_hard_task_need_present": true,
"explore_hard_task_need_task": true,
"TacticalChallengeShopRefreshTime": "0",
"TacticalChallengeShopList": [
0,
Expand Down
2 changes: 2 additions & 0 deletions core/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def init_image_data(self):
try:
global iad, ibd
base_path = ''
iad.clear()
ibd.clear()
self.logger.info("Start initializing image data")
if self.server == 'CN':
ibd = {
Expand Down
2 changes: 1 addition & 1 deletion core/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def wait_loading(self):
self.logger.info("loading, t load : " + str(t_load))
if t_load > 20:
self.logger.warning("LOADING TOO LONG add screenshot interval to 1")
t_load = 0
t_start = time.time()
self.screenshot_interval = 1
time.sleep(self.screenshot_interval)
continue
Expand Down
1 change: 1 addition & 0 deletions gui/components/expand/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
from .totalForceFightPriority import Layout
from .exploreConfig import Layout
from .otherConfig import Layout
from .hardTaskConfig import Layout
from .featureSwitch import Layout
1 change: 0 additions & 1 deletion gui/components/expand/createPriority.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIntValidator
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QPushButton, QVBoxLayout
from qfluentwidgets import LineEdit, InfoBar, InfoBarIcon, InfoBarPosition

Expand Down
40 changes: 29 additions & 11 deletions gui/components/expand/exploreConfig.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import threading

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QHBoxLayout, QLabel
from qfluentwidgets import LineEdit, PushButton
from qfluentwidgets import LineEdit, PushButton, InfoBar, InfoBarIcon, InfoBarPosition

import main
from .expandTemplate import TemplateLayout


Expand Down Expand Up @@ -61,7 +58,9 @@ def __init__(self, parent=None):
'type': 'label'
},
{
'label': '如果有多支队伍一队编号必须小于二队,如15图神秘1队编号要小于神秘2队',
'label': '              '
'        '
'<b>如果有多个队伍一定要设置主队编号小于副队(如15图神秘1队必须小于神秘2队编号)</b>',
'type': 'label'
}
]
Expand All @@ -75,6 +74,7 @@ def __init__(self, parent=None):
self.input_push = LineEdit(self)
self.accept_push = PushButton('开始推图', self)

self.input_push.setText(self.get('explore_normal_task_regions').__str__().replace('[', '').replace(']', ''))
self.input_push.setFixedWidth(700)
self.accept_push.clicked.connect(self._accept_push)

Expand All @@ -94,11 +94,29 @@ def __init__(self, parent=None):
self.hBoxLayout.addLayout(self.push_card)

def _accept_push(self):
thread = threading.Thread(target=self.start_push, daemon=True)
thread.start()

def start_push(self):
push_list = [int(x) for x in self.input_push.text().split(',')]
self.set('explore_normal_task_regions', push_list)
t = main.Main()
t.solve('explore_normal_task')
value = self.input_push.text()
w = InfoBar(
icon=InfoBarIcon.SUCCESS,
title='设置成功',
content=f'你的普通关配置已经被设置为:{value},正在推普通关。',
orient=Qt.Vertical, # vertical layout
position=InfoBarPosition.TOP_RIGHT,
duration=800,
parent=self.parent().parent().parent().parent().parent().parent().parent()
)
w.show()
import threading
threading.Thread(target=self.action).start()

def get_thread(self, parent=None):
if parent is None:
parent = self.parent()
for component in parent.children():
if type(component).__name__ == 'HomeFragment':
return component.get_main_thread()
return self.get_thread(parent.parent())

def action(self):
self.get_thread().start_normal_task()
1 change: 0 additions & 1 deletion gui/components/expand/featureSwitch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json

from PyQt5.QtGui import QIntValidator
from PyQt5.QtWidgets import QWidget, QLabel
from qfluentwidgets import FlowLayout, CheckBox

Expand Down
104 changes: 104 additions & 0 deletions gui/components/expand/hardTaskConfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QHBoxLayout, QLabel
from qfluentwidgets import LineEdit, PushButton, InfoBar, InfoBarIcon, InfoBarPosition

from .expandTemplate import TemplateLayout


class Layout(TemplateLayout):
def __init__(self, parent=None):
configItems = [
{
'label': '打到SSS',
'key': 'explore_hard_task_need_sss',
'type': 'switch'
},
{
'label': '拿礼物',
'key': 'explore_hard_task_need_present',
'type': 'switch'
},
{
'label': '完成成就任务',
'key': 'explore_hard_task_need_task',
'type': 'switch'
},
{
'label': """
推图关卡中填写的数据不应该超出这些字符或单词 "-" , "sss", "present", "task", "," , 和数字
按逗号拆分后变为若干关卡
1.如果只有一个数字
例子:15
根据上面三个按钮的开关 将(15-1,15-2,15-3)打到sss/拿礼物/完成挑战任务
2.如果是一个数字并跟字符串,则用‘-’分隔
例子: 15-sss-present
会将(15-1,15-2,15-3)打到sss并拿礼物
3.如果有两个数字则指定到对应关卡
例子:15-3-sss-task
会将15-3打到sss并且完成挑战任务
4.例子
开关都开启,填写: 7,8-sss,9-3-task
表示依次执行(7-1,7-2,7-3)打到sss,拿礼物并完成挑战任务,(8-1,8-2,8-3)打到sss,9-3完成挑战任务
注:Baas会自动判断关卡是否已经打到sss,是否拿了礼物,如果已经打到sss或拿了礼物,则不会再次打该关卡
""",
'type': 'label'
},
]

super().__init__(parent=parent, configItems=configItems)

self.push_card = QHBoxLayout(self)
self.push_card_label = QHBoxLayout(self)
self.label_tip_push = QLabel(
'<b>困难图队伍属性和普通图相同(见普通图推图设置),请按照以上说明选择推困难图关卡并按对应图设置队伍</b>', self)
self.input_push = LineEdit(self)
self.accept_push = PushButton('开始推图', self)

self.input_push.setText(self.get('explore_hard_task_list'))
self.input_push.setFixedWidth(700)
self.accept_push.clicked.connect(self._accept_push)

self.push_card_label.addWidget(self.label_tip_push, 0, Qt.AlignLeft)
self.push_card.addWidget(self.input_push, 1, Qt.AlignLeft)
self.push_card.addWidget(self.accept_push, 0, Qt.AlignLeft)

self.push_card.addStretch(1)
self.push_card.setAlignment(Qt.AlignCenter)
self.push_card.setContentsMargins(10, 0, 0, 10)

self.push_card_label.addStretch(1)
self.push_card_label.setAlignment(Qt.AlignCenter)
self.push_card_label.setContentsMargins(10, 0, 0, 10)

self.hBoxLayout.addLayout(self.push_card_label)
self.hBoxLayout.addLayout(self.push_card)

def _accept_push(self):
value = self.input_push.text()
self.set('explore_hard_task_list', value)
w = InfoBar(
icon=InfoBarIcon.SUCCESS,
title='设置成功',
content=f'你的困难关配置已经被设置为:{value},正在推困难关。',
orient=Qt.Vertical, # vertical layout
position=InfoBarPosition.TOP_RIGHT,
duration=800,
parent=self.parent().parent().parent().parent().parent().parent().parent()
)
w.show()
import threading
threading.Thread(target=self.action).start()

def get_thread(self, parent=None):
if parent is None:
parent = self.parent()
for component in parent.children():
if type(component).__name__ == 'HomeFragment':
return component.get_main_thread()
return self.get_thread(parent.parent())

def action(self):
self.get_thread().start_hard_task()
1 change: 0 additions & 1 deletion gui/components/expand/mainlinePriority.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIntValidator
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QPushButton, QVBoxLayout
from qfluentwidgets import LineEdit, InfoBar, InfoBarIcon, InfoBarPosition

Expand Down
27 changes: 12 additions & 15 deletions gui/components/expand/otherConfig.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QHBoxLayout, QLabel, QVBoxLayout
from qfluentwidgets import SwitchButton, PushButton

from .expandTemplate import TemplateLayout
import main
from qfluentwidgets import LineEdit, InfoBar, InfoBarIcon, InfoBarPosition


def fhx():
try:
t = main.Main()
t.solve('de_clothes')
except Exception as e:
print(e)


class Layout(TemplateLayout):
Expand All @@ -21,7 +7,7 @@ def __init__(self, parent=None):
{
'label': '一键反和谐',
'type': 'button',
'selection': fhx,
'selection': self.fhx,
'key': None
},
{
Expand All @@ -32,3 +18,14 @@ def __init__(self, parent=None):
]

super().__init__(parent=parent, configItems=configItems)

def get_thread(self, parent=None):
if parent is None:
parent = self.parent()
for component in parent.children():
if type(component).__name__ == 'HomeFragment':
return component.get_main_thread()
return self.get_thread(parent.parent())

def fhx(self):
self.get_thread().start_fhx()
2 changes: 1 addition & 1 deletion gui/components/expand/schedulePriority.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIntValidator, QDoubleValidator
from PyQt5.QtGui import QDoubleValidator
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QPushButton
from qfluentwidgets import LineEdit

Expand Down
3 changes: 2 additions & 1 deletion gui/components/expand/serverConfig.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import cv2
from main import Main

from .expandTemplate import TemplateLayout


def screenshot():
from main import Main
main = Main()
test_img = main.get_screenshot_array()
cv2.imshow('Test Screenshot', test_img)
Expand Down
54 changes: 44 additions & 10 deletions gui/fragments/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ExpandLayout
)

from core.notification import notify
from gui.components.logger_box import LoggerBox
from gui.util import log
from gui.util.config_set import ConfigSet
Expand Down Expand Up @@ -98,7 +99,7 @@ def resizeEvent(self, event):
self.banner.setPixmap(pixmap)
self.banner.setScaledContents(True)
if self.banner_visible:
self.logger_box.setFixedHeight(int(self.parent().height() * 0.4))
self.logger_box.setFixedHeight(int(self.parent().height() * 0.35))
else:
self.logger_box.setFixedHeight(int(self.parent().height() * 0.7))

Expand Down Expand Up @@ -136,6 +137,9 @@ def _start_clicked(self):
else:
self._main_thread_attach.start()

def get_main_thread(self):
return self._main_thread_attach

# def __init_starter(self):
# if self._main_thread is None:
# from main import Main
Expand Down Expand Up @@ -166,23 +170,53 @@ def __init__(self):

def run(self):
self.running = True
self.button_signal.emit("停止")
self.display('停止')
log.d("Starting Blue Archive Auto Script...", level=1, logger_box=self.logger_signal)
if self.Main is None:
from main import Main
self.Main = Main
self._main_thread = self.Main(logger_signal=self.logger_signal, button_signal=self.button_signal,
update_signal=self.update_signal)
self._init_script()
self._main_thread.send('start')

def stop_play(self):
self.running = False
if self._main_thread is None:
return
self.button_signal.emit("启动")
self.display('启动')
self._main_thread.send('stop')
self.exit(0)

def _init_script(self):
if self.Main is None:
from main import Main
self.Main = Main
self._main_thread = self.Main(logger_signal=self.logger_signal, button_signal=self.button_signal,
update_signal=self.update_signal)
self._main_thread.init_all_data()
self._main_thread.flag_run = True

def display(self, text):
self.button_signal.emit(text)

def get_screen(self):
if self._main_thread is not None:
return self._main_thread.log_screenshot()
self._init_script()
self._main_thread.init_emulator()
return self._main_thread.log_screenshot()

def start_hard_task(self):
self._init_script()
self.display('停止')
# 这里可能有Bug,若用户还未登入,则会报错。
if self._main_thread.solve('explore_hard_task'):
notify(title='BAAS', body='困难图推图已完成')

def start_normal_task(self):
self._init_script()
self.display('停止')
# 这里可能有Bug,若用户还未登入,则会报错。
if self._main_thread.solve('explore_normal_task'):
notify(title='BAAS', body='普通图推图已完成')

def start_fhx(self):
self._init_script()
if self._main_thread.solve('de_clothes'):
notify(title='BAAS', body='反和谐成功,请重启BA下载资源')
else:
notify(title='BAAS', body='反和谐失败')
Loading

0 comments on commit fd108e9

Please sign in to comment.