add 复活点路线与死亡按键可配置
- 死亡管理新增复活点路线JSON两阶段跑尸逻辑 - GUI参数配置支持释放灵魂/复活按键自定义 - 复活点路线JSON选择控件移到攻击循环前面 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -317,6 +317,9 @@ class GameLoopWorker(QThread):
|
||||
flight_takeoff_hold_sec=None,
|
||||
flight_land_key=None,
|
||||
flight_land_hold_sec=None,
|
||||
resurrection_waypoints_path=None,
|
||||
release_spirit_key=None,
|
||||
resurrect_key=None,
|
||||
):
|
||||
super().__init__()
|
||||
self.mode = mode # 'monitor' | 'patrol' | 'combat' | 'quest_follow' | 'flight' | 'record'
|
||||
@@ -352,6 +355,9 @@ class GameLoopWorker(QThread):
|
||||
self.flight_takeoff_hold_sec = flight_takeoff_hold_sec
|
||||
self.flight_land_key = flight_land_key
|
||||
self.flight_land_hold_sec = flight_land_hold_sec
|
||||
self.resurrection_waypoints_path = resurrection_waypoints_path
|
||||
self.release_spirit_key = release_spirit_key
|
||||
self.resurrect_key = resurrect_key
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
@@ -372,6 +378,9 @@ class GameLoopWorker(QThread):
|
||||
eat_hp_threshold=self.eat_hp_threshold,
|
||||
eat_max_wait_sec=self.eat_max_wait_sec,
|
||||
stop_check=lambda: not self.running,
|
||||
resurrection_waypoints_path=self.resurrection_waypoints_path,
|
||||
release_spirit_key=self.release_spirit_key,
|
||||
resurrect_key=self.resurrect_key,
|
||||
)
|
||||
self.bot_move._on_hearthstone_stop = self.stop_signal.emit
|
||||
except ImportError as e:
|
||||
@@ -606,6 +615,9 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
refresh_btn.clicked.connect(self._refresh_recorder_combos)
|
||||
patrol_layout.addRow("巡逻点 JSON:", self.waypoints_combo)
|
||||
patrol_layout.addRow("修理商 JSON:", self.vendor_combo)
|
||||
self.resurrection_waypoints_combo = QComboBox()
|
||||
self.resurrection_waypoints_combo.setMinimumWidth(200)
|
||||
patrol_layout.addRow("复活点路线 JSON:", self.resurrection_waypoints_combo)
|
||||
patrol_layout.addRow("攻击循环:", self.patrol_attack_loop_combo)
|
||||
patrol_layout.addRow("", refresh_btn)
|
||||
self.patrol_group.setVisible(False)
|
||||
@@ -945,6 +957,17 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
params_right.addRow("上马按住时长 (mount_hold_sec):", self.gs_mount_hold)
|
||||
params_right.addRow("上马重试间隔 (mount_retry_after_sec):", self.gs_mount_retry)
|
||||
|
||||
self.gs_release_spirit_key = QLineEdit()
|
||||
self.gs_release_spirit_key.setPlaceholderText("如 9")
|
||||
self.gs_release_spirit_key.setMaxLength(16)
|
||||
self.gs_release_spirit_key.setText("9")
|
||||
self.gs_resurrect_key = QLineEdit()
|
||||
self.gs_resurrect_key.setPlaceholderText("如 0")
|
||||
self.gs_resurrect_key.setMaxLength(16)
|
||||
self.gs_resurrect_key.setText("0")
|
||||
params_right.addRow("释放灵魂按键:", self.gs_release_spirit_key)
|
||||
params_right.addRow("复活按键:", self.gs_resurrect_key)
|
||||
|
||||
params_row.addLayout(params_left)
|
||||
params_row.addLayout(params_right)
|
||||
params_layout.addWidget(params_content)
|
||||
@@ -985,6 +1008,8 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
self.gs_hearthstone_key.setText(str(cfg.get('hearthstone_key', 'b') or 'b'))
|
||||
self.gs_bag_full_hearthstone.setChecked(bool(cfg.get('bag_full_hearthstone', False)))
|
||||
self.gs_mount_retry.setValue(float(cfg.get('mount_retry_after_sec', 2.0)))
|
||||
self.gs_release_spirit_key.setText(str(cfg.get('release_spirit_key', '9') or '9'))
|
||||
self.gs_resurrect_key.setText(str(cfg.get('resurrect_key', '0') or '0'))
|
||||
except Exception as e:
|
||||
self.log(f"加载参数配置失败: {e}")
|
||||
try:
|
||||
@@ -1017,6 +1042,8 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
cfg['mount_retry_after_sec'] = float(self.gs_mount_retry.value())
|
||||
cfg['hearthstone_key'] = (self.gs_hearthstone_key.text().strip() or 'b')
|
||||
cfg['bag_full_hearthstone'] = self.gs_bag_full_hearthstone.isChecked()
|
||||
cfg['release_spirit_key'] = (self.gs_release_spirit_key.text().strip() or '9')
|
||||
cfg['resurrect_key'] = (self.gs_resurrect_key.text().strip() or '0')
|
||||
path = save_layout_config(cfg)
|
||||
# bot 参数写入主配置文件
|
||||
self.config = self.config or {}
|
||||
@@ -1212,22 +1239,34 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
self.preview_canvas.reset_view()
|
||||
|
||||
def _refresh_recorder_combos(self):
|
||||
"""刷新巡逻点、修理商下拉列表"""
|
||||
"""刷新巡逻点、修理商、复活点路线下拉列表"""
|
||||
items = list_recorder_json()
|
||||
combos = [(self.waypoints_combo, 'waypoints.json'), (self.vendor_combo, 'vendor.json')]
|
||||
combos_with_default = [
|
||||
(self.waypoints_combo, 'waypoints.json'),
|
||||
(self.vendor_combo, 'vendor.json'),
|
||||
]
|
||||
if hasattr(self, "repair_vendor_combo"):
|
||||
combos.append((self.repair_vendor_combo, 'vendor.json'))
|
||||
for combo, default_name in combos:
|
||||
combos_with_default.append((self.repair_vendor_combo, 'vendor.json'))
|
||||
for combo, default_name in combos_with_default:
|
||||
combo.blockSignals(True)
|
||||
combo.clear()
|
||||
combo.addItem("-- 请选择 --", "")
|
||||
for name, path in items:
|
||||
combo.addItem(name, path)
|
||||
# 尝试选中默认项
|
||||
idx = combo.findData(os.path.join(get_recorder_dir(), default_name))
|
||||
if idx >= 0:
|
||||
combo.setCurrentIndex(idx)
|
||||
elif combo.count() > 1:
|
||||
combo.setCurrentIndex(1)
|
||||
combo.blockSignals(False)
|
||||
# 复活点路线下拉(无默认值,可置空)
|
||||
if hasattr(self, "resurrection_waypoints_combo"):
|
||||
self.resurrection_waypoints_combo.blockSignals(True)
|
||||
self.resurrection_waypoints_combo.clear()
|
||||
self.resurrection_waypoints_combo.addItem("-- 置空(直接跑尸体) --", "")
|
||||
for name, path in items:
|
||||
self.resurrection_waypoints_combo.addItem(name, path)
|
||||
self.resurrection_waypoints_combo.blockSignals(False)
|
||||
|
||||
def _refresh_repair_vendor_json_combo(self):
|
||||
"""刷新“回城修理配置”的修理商下拉框。"""
|
||||
@@ -1365,9 +1404,11 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
waypoints_path = None
|
||||
vendor_path = None
|
||||
flight_json_path = None
|
||||
resurrection_waypoints_path = None
|
||||
if mode == 'patrol':
|
||||
wp = self.waypoints_combo.currentData() or ""
|
||||
vp = self.vendor_combo.currentData() or ""
|
||||
rwp = self.resurrection_waypoints_combo.currentData() or ""
|
||||
if not wp:
|
||||
QMessageBox.warning(self, "提示", "巡逻打怪模式需选择巡逻点 JSON 文件")
|
||||
return
|
||||
@@ -1382,6 +1423,7 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
return
|
||||
waypoints_path = wp
|
||||
vendor_path = vp
|
||||
resurrection_waypoints_path = rwp if rwp and os.path.exists(rwp) else None
|
||||
attack_loop_path = None
|
||||
if mode == 'patrol':
|
||||
attack_loop_path = self.patrol_attack_loop_combo.currentData() or None
|
||||
@@ -1447,6 +1489,16 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
except Exception:
|
||||
eat_max_wait_sec = 30.0
|
||||
|
||||
# 从 layout_config 读取死亡/复活按键
|
||||
try:
|
||||
from game_state import load_layout_config
|
||||
layout_cfg = load_layout_config()
|
||||
release_spirit_key = str(layout_cfg.get('release_spirit_key', '9') or '9')
|
||||
resurrect_key = str(layout_cfg.get('resurrect_key', '0') or '0')
|
||||
except Exception:
|
||||
release_spirit_key = '9'
|
||||
resurrect_key = '0'
|
||||
|
||||
self.game_worker = GameLoopWorker(
|
||||
mode, waypoints_path=waypoints_path, vendor_path=vendor_path,
|
||||
attack_loop_path=attack_loop_path,
|
||||
@@ -1462,6 +1514,9 @@ class WoWMultiKeyGUI(QMainWindow):
|
||||
flight_takeoff_hold_sec=self.flight_takeoff_hold_spin.value(),
|
||||
flight_land_key=self.flight_land_key_edit.text(),
|
||||
flight_land_hold_sec=self.flight_land_hold_spin.value(),
|
||||
resurrection_waypoints_path=resurrection_waypoints_path,
|
||||
release_spirit_key=release_spirit_key,
|
||||
resurrect_key=resurrect_key,
|
||||
)
|
||||
self.game_worker.state_signal.connect(self.state_label.setText)
|
||||
self.game_worker.log_signal.connect(self.log)
|
||||
|
||||
Reference in New Issue
Block a user