Skip to content

Commit e0b4589

Browse files
committed
#251 加入配置编辑页面 可查看战斗配置所需配队
1 parent bdac735 commit e0b4589

14 files changed

+299
-48
lines changed

config/auto_battle/专属配队-朱鸢.sample.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
description: |
2-
专属配队-朱鸢
3-
配队列表:击破-妮可-朱鸢
4-
备注:角色顺序没问题就行 你再问就要攻击你啦 除 青衣 以外的其他击破没有做任何的优化
5-
版本号: 1.0
6-
作者: 笙梦昱
7-
协作: 巡夜子 starlight
1+
# 基础信息
2+
author: "笙梦昱"
3+
thanks: "巡夜子 starlight"
4+
homepage: "https://b23.tv/QBbqzRK"
5+
version: "1.0"
6+
team_list:
7+
- ["击破", "妮可", "朱鸢"]
8+
introduction: "除 青衣 以外的其他击破没有做任何的优化"
89

910
#基础配置
1011
check_dodge_interval: 0.01

config/auto_battle/专属配队-柳.sample.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
description: |
2-
专属配队-月城柳
3-
配队列表:柳-支援/防护-柏妮思 柳-支援/防护-支援
4-
备注: 角色顺序没问题就行 你再问就要攻击你啦
5-
版本号: 0.1
6-
作者: 笙梦昱
7-
协作: 巡夜子 starlight
1+
# 基础信息
2+
author: "笙梦昱"
3+
thanks: "巡夜子 starlight"
4+
homepage: "https://b23.tv/QBbqzRK"
5+
version: "1.0"
6+
team_list:
7+
- ["柳", "支援", "柏妮思"]
8+
- ["柳", "防护", "柏妮思"]
9+
introduction: "柏妮思 可换成支援"
810

911
#基础配置
1012
check_dodge_interval: 0.01

config/auto_battle/专属配队-派派.sample.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
description: |
2-
专属配队-派派
3-
配队列表:支援-派派-凯撒 柏妮思-派派-露西
4-
备注: 角色顺序没问题就行 你再问就要攻击你啦
5-
版本号: 1.1
6-
作者: 笙梦昱
7-
协作: 巡夜子 starlight
1+
# 基础信息
2+
author: "笙梦昱"
3+
thanks: "巡夜子 starlight"
4+
homepage: "https://b23.tv/QBbqzRK"
5+
version: "1.1"
6+
team_list:
7+
- ["支援", "派派", "凯撒"]
8+
- ["柏妮思", "派派", "露西"]
9+
introduction: ""
810

911
#基础配置
1012
check_dodge_interval: 0.01

config/auto_battle/专属配队-简.sample.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
description: |
2-
专属配队-简
3-
配队列表:支援/凯撒-简-凯撒/赛斯 柏妮思-简-凯撒/赛斯
4-
备注: 角色顺序没问题就行 你再问就要攻击你啦
5-
版本号: 0.4
6-
作者: 笙梦昱
7-
协作: 巡夜子 starlight
1+
# 基础信息
2+
author: "笙梦昱"
3+
thanks: "巡夜子 starlight"
4+
homepage: "https://b23.tv/QBbqzRK"
5+
version: "1.4"
6+
team_list:
7+
- ["凯撒", "简", "赛斯"]
8+
- ["支援", "简", "凯撒"]
9+
- ["柏妮思", "简", "凯撒"]
10+
- ["柏妮思", "简", "赛斯"]
11+
introduction: ""
812

913
#基础配置
1014
check_dodge_interval: 0.01

config/auto_battle/专属配队-艾莲.sample.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
description: |
2-
专属配队-艾莲
3-
配队列表:艾莲 + 凯撒/莱卡恩 + 莱卡恩/苍角
4-
备注: 2号位、3号位可任意更换击破、支援、防护
5-
版本号: 2.7
6-
作者: 巡夜子
7-
协作: 笙梦昱
8-
1+
# 基础信息
2+
author: "巡夜子"
3+
thanks: "笙梦昱"
4+
homepage: ""
5+
version: "2.7"
6+
team_list:
7+
- ["艾莲", "凯撒", "莱卡恩"]
8+
- ["艾莲", "莱卡恩", "苍角"]
9+
introduction: "2号位、3号位可任意更换击破、支援、防护"
10+
911
#基础配置
1012
check_dodge_interval: 0.02
1113
check_agent_interval: [0.4, 0.6]

config/auto_battle/专属配队-莱卡恩.sample.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
# 配队 莱卡恩 凯撒 苍角
1+
# 基础信息
2+
author: "DoctorReid"
3+
thanks: ""
4+
homepage: ""
5+
version: "1.0"
6+
team_list:
7+
- ["莱卡恩", "凯撒", "苍角"]
8+
introduction: "纯整活 让狼哥在日常刷本露露脸"
9+
210
allow_ultimate:
311
- agent_name: "莱卡恩"
412

config/project.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ requirements: "requirements-prod.txt"
1010
screen_standard_width: 1920
1111
screen_standard_height: 1080
1212
pip_source: "https://pypi.tuna.tsinghua.edu.cn/simple"
13+
qq_link: "https://qm.qq.com/q/wuVRYuZzkA"

src/one_dragon/envs/project_config.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ def __init__(self):
1818

1919
self.screen_standard_width = int(self.get('screen_standard_width'))
2020
self.screen_standard_height = int(self.get('screen_standard_height'))
21+
22+
self.qq_link = self.get('qq_link')

src/phosdeiz/gui/widgets/combo_box.py

+10
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,13 @@ def set_items(self, items: List[ConfigItem], target_value: Any = None) -> None:
4040

4141
self.setCurrentIndex(new_idx)
4242
self.blockSignals(False)
43+
44+
def init_with_value(self, target_value: Any = None) -> None:
45+
"""
46+
根据目标值初始化 不抛出事件
47+
:param target_value:
48+
:return:
49+
"""
50+
self.blockSignals(True)
51+
self.setCurrentIndex(self.findData(target_value))
52+
self.blockSignals(False)

src/zzz_od/auto_battle/auto_battle_operator.py

+24
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,30 @@ def lock_periodically(self) -> None:
377377
op.execute()
378378
self.last_lock_time = time.time()
379379

380+
@property
381+
def team_list(self) -> List[List[str]]:
382+
return self.get('team_list', [])
383+
384+
@property
385+
def author(self) -> str:
386+
return self.get('author', '')
387+
388+
@property
389+
def homepage(self) -> str:
390+
return self.get('homepage', 'https://qm.qq.com/q/wuVRYuZzkA')
391+
392+
@property
393+
def thanks(self) -> str:
394+
return self.get('thanks', '')
395+
396+
@property
397+
def version(self) -> str:
398+
return self.get('version', '')
399+
400+
@property
401+
def introduction(self) -> str:
402+
return self.get('introduction', '')
403+
380404

381405
def __debug():
382406
ctx = ZContext()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
from PySide6.QtCore import Signal
2+
from PySide6.QtWidgets import QWidget
3+
from qfluentwidgets import PushButton, FluentIcon, SettingCardGroup, HyperlinkCard
4+
from typing import Optional, List
5+
6+
from one_dragon.base.config.config_item import ConfigItem
7+
from one_dragon.gui.widgets.setting_card.multi_push_setting_card import MultiPushSettingCard
8+
from one_dragon.gui.widgets.vertical_scroll_interface import VerticalScrollInterface
9+
from one_dragon.utils.i18_utils import gt
10+
from phosdeiz.gui.widgets import Column, ComboBox, Row
11+
from zzz_od.application.battle_assistant.auto_battle_config import get_auto_battle_op_config_list
12+
from zzz_od.auto_battle.auto_battle_operator import AutoBattleOperator
13+
from zzz_od.context.zzz_context import ZContext
14+
from zzz_od.game_data.agent import AgentEnum, AgentTypeEnum
15+
16+
17+
class TeamSettingCard(MultiPushSettingCard):
18+
19+
value_changed = Signal(List[str])
20+
21+
def __init__(self):
22+
config_list = [ConfigItem(i.value.agent_name) for i in AgentEnum] + [ConfigItem(i.value) for i in AgentTypeEnum if i != AgentTypeEnum.UNKNOWN]
23+
self.btn_list: List[ComboBox] = []
24+
for i in range(3):
25+
opt = ComboBox()
26+
opt.set_items(config_list)
27+
opt.currentIndexChanged.connect(self.on_character_chosen)
28+
opt.setDisabled(True)
29+
self.btn_list.append(opt)
30+
31+
MultiPushSettingCard.__init__(self, title='配队', btn_list=self.btn_list)
32+
33+
def init_team(self, character_list: List[str]) -> None:
34+
"""
35+
初始化
36+
:param character_list:
37+
:return:
38+
"""
39+
if character_list is None:
40+
return
41+
for i in range(3):
42+
if i >= len(character_list):
43+
self.btn_list[i].init_with_value(None)
44+
else:
45+
self.btn_list[i].init_with_value(character_list[i])
46+
47+
def on_character_chosen(self) -> None:
48+
self.value_changed.emit([opt.currentData() for opt in self.btn_list])
49+
50+
51+
class AutoBattleEditorInterface(VerticalScrollInterface):
52+
53+
def __init__(self, ctx: ZContext, parent=None):
54+
VerticalScrollInterface.__init__(
55+
self,
56+
object_name='auto_battle_editor_interface',
57+
parent=parent,
58+
content_widget=None,
59+
nav_text_cn='配置编辑'
60+
)
61+
62+
self.ctx: ZContext = ctx
63+
self.chosen_config: Optional[AutoBattleOperator] = None
64+
65+
def get_content_widget(self) -> QWidget:
66+
content_widget = Row()
67+
68+
content_widget.add_widget(self.init_left_part(), stretch=1)
69+
content_widget.add_widget(self.init_right_part(), stretch=1)
70+
71+
return content_widget
72+
73+
def init_left_part(self) -> QWidget:
74+
widget = Column()
75+
76+
info_opt = HyperlinkCard(icon=FluentIcon.INFO, title='当前仅用于信息展示',
77+
content='角色顺序 朱青妮 跟 青妮朱 是一样的',
78+
text='', url='')
79+
info_opt.setFixedHeight(50)
80+
widget.add_widget(info_opt)
81+
82+
btn_row = Row()
83+
widget.add_widget(btn_row)
84+
85+
self.existed_yml_btn = ComboBox()
86+
self.existed_yml_btn.setPlaceholderText(gt('选择已有', 'ui'))
87+
self.existed_yml_btn.currentIndexChanged.connect(self.on_config_chosen)
88+
btn_row.add_widget(self.existed_yml_btn)
89+
90+
self.create_btn = PushButton(text=gt('新建', 'ui'))
91+
# self.create_btn.clicked.connect(self._on_create_clicked)
92+
btn_row.add_widget(self.create_btn)
93+
94+
self.copy_btn = PushButton(text=gt('复制', 'ui'))
95+
# self.copy_btn.clicked.connect(self._on_copy_clicked)
96+
btn_row.add_widget(self.copy_btn)
97+
98+
self.delete_btn = PushButton(text=gt('删除', 'ui'))
99+
# self.delete_btn.clicked.connect(self._on_delete_clicked)
100+
btn_row.add_widget(self.delete_btn)
101+
102+
self.cancel_btn = PushButton(text=gt('取消', 'ui'))
103+
self.cancel_btn.clicked.connect(self.on_cancel_clicked)
104+
btn_row.add_widget(self.cancel_btn)
105+
106+
btn_row.add_stretch(1)
107+
108+
basic_group = SettingCardGroup('基础信息')
109+
widget.add_widget(basic_group)
110+
self.author_opt = HyperlinkCard(icon=FluentIcon.PEOPLE, title='作者', text='作者',
111+
url=self.ctx.project_config.qq_link)
112+
basic_group.addSettingCard(self.author_opt)
113+
self.version_opt = HyperlinkCard(icon=FluentIcon.INFO, title='版本', text='1.0', url='')
114+
basic_group.addSettingCard(self.version_opt)
115+
self.introduction_opt = HyperlinkCard(icon=FluentIcon.INFO, title='简介', text='', url='')
116+
basic_group.addSettingCard(self.introduction_opt)
117+
118+
self.team_group = SettingCardGroup('适用配队')
119+
self.team_opt_list: List[TeamSettingCard] = []
120+
widget.add_widget(self.team_group)
121+
122+
widget.add_stretch(1)
123+
return widget
124+
125+
def init_right_part(self) -> QWidget:
126+
widget = Column()
127+
128+
widget.add_stretch(1)
129+
130+
return widget
131+
132+
def on_interface_shown(self) -> None:
133+
VerticalScrollInterface.on_interface_shown(self)
134+
135+
self.update_auto_battle_config_opts()
136+
self.update_display_by_config()
137+
138+
def update_auto_battle_config_opts(self) -> None:
139+
self.existed_yml_btn.set_items(
140+
get_auto_battle_op_config_list('auto_battle'),
141+
target_value=self.chosen_config.module_name if self.chosen_config is not None else None
142+
)
143+
144+
def update_display_by_config(self) -> None:
145+
chosen = self.chosen_config is not None
146+
147+
self.existed_yml_btn.setDisabled(chosen)
148+
self.create_btn.setDisabled(True)
149+
self.copy_btn.setDisabled(True)
150+
self.delete_btn.setDisabled(True)
151+
self.cancel_btn.setDisabled(not chosen)
152+
153+
self.update_team_group_display()
154+
155+
if chosen:
156+
self.author_opt.setContent(
157+
f'感谢 {self.chosen_config.thanks}' if self.chosen_config.thanks != '' else ''
158+
)
159+
self.author_opt.linkButton.setText(self.chosen_config.author)
160+
self.author_opt.linkButton.setUrl(self.chosen_config.homepage)
161+
self.version_opt.linkButton.setText(self.chosen_config.version)
162+
self.introduction_opt.setContent(self.chosen_config.introduction)
163+
else:
164+
self.author_opt.setContent('')
165+
self.author_opt.linkButton.setText('作者')
166+
self.author_opt.linkButton.setUrl(self.ctx.project_config.qq_link)
167+
self.version_opt.linkButton.setText('1.0')
168+
self.introduction_opt.setContent('')
169+
170+
def update_team_group_display(self) -> None:
171+
if self.chosen_config is None:
172+
for i in self.team_opt_list:
173+
i.setVisible(False)
174+
else:
175+
# 删除多余的卡片
176+
while len(self.team_opt_list) > len(self.chosen_config.team_list):
177+
opt = self.team_opt_list.pop()
178+
self.team_group.cardLayout.removeWidget(opt)
179+
self.team_group.adjustSize()
180+
181+
# 增加不足的卡片
182+
while len(self.team_opt_list) < len(self.chosen_config.team_list):
183+
opt = TeamSettingCard()
184+
# opt.value_changed.connect(self.on_team_changed)
185+
self.team_group.addSettingCard(opt)
186+
self.team_opt_list.append(opt)
187+
188+
# 初始化数据
189+
for i in range(len(self.team_opt_list)):
190+
self.team_opt_list[i].init_team(self.chosen_config.team_list[i])
191+
self.team_opt_list[i].setVisible(True)
192+
193+
def on_config_chosen(self, idx: int) -> None:
194+
module_name = self.existed_yml_btn.currentData()
195+
self.chosen_config = AutoBattleOperator(self.ctx, 'auto_battle', module_name)
196+
self.update_display_by_config()
197+
198+
def on_cancel_clicked(self) -> None:
199+
self.chosen_config = None
200+
self.existed_yml_btn.blockSignals(True)
201+
self.existed_yml_btn.setCurrentIndex(-1)
202+
self.existed_yml_btn.blockSignals(False)
203+
self.update_display_by_config()

src/zzz_od/gui/view/battle_assistant/auto_battle_interface.py

-5
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,7 @@ def _update_auto_battle_config_opts(self) -> None:
133133
更新闪避指令
134134
:return:
135135
"""
136-
try:
137-
self.config_opt.value_changed.disconnect(self._on_auto_battle_config_changed)
138-
except:
139-
pass
140136
self.config_opt.set_options_by_list(get_auto_battle_op_config_list('auto_battle'))
141-
self.config_opt.value_changed.connect(self._on_auto_battle_config_changed)
142137

143138
def _on_auto_battle_config_changed(self, index, value):
144139
self.ctx.battle_assistant_config.auto_battle_config = value

0 commit comments

Comments
 (0)