实验: 编队列表滑动补丁重写 (默认关闭, LCP_TEAM_SCROLL_PATCH=1 启用)
替代 66418dc 中的版本, 只验证"Windows 缺少队伍拖拽规避"这一假设:
- 几何/行程沿用 AALC build_windows_scroll_swipe_plan, 不改变 Windows 翻页标定
(原版两端各加 60px escape);
- 参照 MuMu 在脱离段后保持 0.1s、松手前停稳 0.5s;
- 显式等待驱动分段移动: 原版后台每段 duration<0.01s, AALC _mouse_move_to
步数为 0, 一个移动事件都不发; 前台关闭 pyautogui 默认 0.1s 停顿
(原版单次滑动约 4.4s);
- 默认不安装, 需实机在编队界面验证后再决定是否默认开启。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,100 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""编队列表滑动补丁 (实验, 默认关闭; LCP_TEAM_SCROLL_PATCH=1 启用)。
|
||||||
|
|
||||||
|
AALC 基类注释说 ``mouse_swipe_for_team_scroll`` 可由适配器覆盖"以规避队伍拖拽判定",
|
||||||
|
上游只有 MuMu 覆盖了它, Windows 前台/后台沿用普通列表手势。是否因此误触发队伍拖拽
|
||||||
|
尚无实机证据 (2026-10-03 的记录未在编队界面复测), 所以这里只做最小改动来验证:
|
||||||
|
|
||||||
|
- 几何与行程完全沿用 AALC 的 ``build_windows_scroll_swipe_plan``,
|
||||||
|
不改变 AALC 为 Windows 标定的翻页距离;
|
||||||
|
- 参照 MuMu, 脱离段后保持 0.1s 让游戏先认定为滚动, 松手前停稳 0.5s;
|
||||||
|
- 分段移动用显式等待驱动, 不经过适配器的 duration 参数
|
||||||
|
(BackgroundInput 在 duration < 0.01s 时步数为 0, 不发任何移动事件),
|
||||||
|
前台关闭 pyautogui 每次调用后默认的 0.1s 停顿。
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
ENV_FLAG = 'LCP_TEAM_SCROLL_PATCH'
|
||||||
|
ESCAPE_HOLD_SECONDS = 0.1 # MUMU_TEAM_SCROLL_ESCAPE_HOLD_DURATION
|
||||||
|
SETTLE_SECONDS = 0.5 # MUMU_TEAM_SCROLL_SETTLE_DURATION
|
||||||
|
STEP_SECONDS = 0.01 # 与 AALC _mouse_move_to 的步长一致
|
||||||
|
|
||||||
|
|
||||||
|
def _plan(x, y, dx, dy, duration):
|
||||||
|
from module.automation.input_handlers.scroll_swipe import build_windows_scroll_swipe_plan
|
||||||
|
plan, settle = build_windows_scroll_swipe_plan(x, y, dx, dy, duration)
|
||||||
|
return plan, max(settle, SETTLE_SECONDS) if len(plan) > 1 else 0
|
||||||
|
|
||||||
|
|
||||||
|
def run_plan(plan, settle, press, move, release, sleep=None):
|
||||||
|
"""按计划拖动: 每段按耗时均匀插值, 每个插值点之间显式等待。
|
||||||
|
plan 元素为 (终点, 到达该点前的耗时); 第一段之后(脱离段)保持一小会儿。"""
|
||||||
|
sleep = sleep or time.sleep
|
||||||
|
position = plan[0][0]
|
||||||
|
press(position)
|
||||||
|
try:
|
||||||
|
for index, (point, duration) in enumerate(plan[1:]):
|
||||||
|
steps = max(1, round(duration / STEP_SECONDS))
|
||||||
|
for k in range(1, steps + 1):
|
||||||
|
ratio = k / steps
|
||||||
|
move((position[0] + (point[0] - position[0]) * ratio,
|
||||||
|
position[1] + (point[1] - position[1]) * ratio))
|
||||||
|
if duration > 0:
|
||||||
|
sleep(duration / steps)
|
||||||
|
position = point
|
||||||
|
if index == 0 and len(plan) > 2:
|
||||||
|
sleep(ESCAPE_HOLD_SECONDS)
|
||||||
|
if settle:
|
||||||
|
sleep(settle)
|
||||||
|
finally:
|
||||||
|
release(position)
|
||||||
|
|
||||||
|
|
||||||
|
def _foreground_team_scroll(self, x, y, duration=0.3, dx=0, dy=0, move_back=True):
|
||||||
|
import pyautogui
|
||||||
|
restore = self.get_mouse_position() if move_back else None
|
||||||
|
plan, settle = _plan(x, y, dx, dy, duration)
|
||||||
|
|
||||||
|
def screen(point):
|
||||||
|
return tuple(int(round(v)) for v in self.pos_offset(*point))
|
||||||
|
|
||||||
|
def press(point):
|
||||||
|
pyautogui.moveTo(*screen(point), _pause=False)
|
||||||
|
pyautogui.mouseDown(_pause=False)
|
||||||
|
|
||||||
|
run_plan(plan, settle, press,
|
||||||
|
lambda point: pyautogui.moveTo(*screen(point), _pause=False),
|
||||||
|
lambda point: pyautogui.mouseUp(*screen(point), _pause=False))
|
||||||
|
if restore:
|
||||||
|
self.mouse_move(restore)
|
||||||
|
|
||||||
|
|
||||||
|
def _background_team_scroll(self, x, y, duration=0.3, dx=0, dy=0, move_back=True):
|
||||||
|
restore = self.get_mouse_position() if move_back else None
|
||||||
|
plan, settle = _plan(x, y, dx, dy, duration)
|
||||||
|
|
||||||
|
def press(point):
|
||||||
|
self.set_mouse_pos(*point)
|
||||||
|
self.set_active()
|
||||||
|
self.mouse_down(*point)
|
||||||
|
|
||||||
|
run_plan(plan, settle, press,
|
||||||
|
lambda point: self.set_mouse_pos(*point),
|
||||||
|
lambda point: self.mouse_up(*point))
|
||||||
|
if restore:
|
||||||
|
self.mouse_move(restore)
|
||||||
|
|
||||||
|
|
||||||
|
def install(force=False):
|
||||||
|
"""给 Windows 前台/后台适配器装上编队滑动 (幂等)。未设 LCP_TEAM_SCROLL_PATCH=1 时不做任何事。"""
|
||||||
|
if not force and os.environ.get(ENV_FLAG) != '1':
|
||||||
|
return []
|
||||||
|
from module.automation.input_handlers import input as input_module
|
||||||
|
patched = []
|
||||||
|
for name, impl in (('Input', _foreground_team_scroll), ('BackgroundInput', _background_team_scroll)):
|
||||||
|
cls = getattr(input_module, name, None)
|
||||||
|
if cls is not None and cls.__dict__.get('mouse_swipe_for_team_scroll') is not impl:
|
||||||
|
cls.mouse_swipe_for_team_scroll = impl
|
||||||
|
patched.append(name)
|
||||||
|
return patched
|
||||||
Reference in New Issue
Block a user