Fix background MCP input and add mirror dungeon feedback records

Browse Source
This commit is contained in:
Codex Agent
2026-10-02 13:58:43 +08:00
parent a4b27f991c
commit da7dcefadd
45 changed files with 6180 additions and 9 deletions
+38 -4
View File
@@ -125,11 +125,26 @@ class AalcEngine(Engine):
def find_image(self, name, threshold=0.8, model='normal'): def find_image(self, name, threshold=0.8, model='normal'):
if name not in self.list_images(name): if name not in self.list_images(name):
raise ValueError('没有模板图 %r (用 list_images 查)' % name) raise ValueError('没有模板图 %r (用 list_images 查)' % name)
self._grab(gray=True) img = self._grab(gray=True)
pos = self.auto.find_image_element(name, threshold, model=model) # 模板按 2560x1440 制作。配置中的目标窗口尺寸不一定等于
# 当前客户区;临时按实际 16:9 画面缩放,不调整窗口或保存配置。
old_size = self.cfg.set_win_size
# 保留亚像素比例:例如 1278 宽对应 718.875 高,取整会改变
# 缩放采样,使小图标的匹配置信度明显下降。
match_size = max(1, min(img.height, img.width * 9 / 16))
changed = match_size != old_size
try:
if changed:
self.auto.clear_img_cache()
self.cfg.unsaved_set_value('set_win_size', match_size)
pos = self.auto.find_image_element(name, threshold, model=model)
finally:
if changed:
self.cfg.unsaved_set_value('set_win_size', old_size)
self.auto.clear_img_cache()
return (int(pos[0]), int(pos[1])) if pos else None return (int(pos[0]), int(pos[1])) if pos else None
# ---- 动手 (AALC 输入后端, 由 config.yaml win_input_type 决定: 默认后台 PostMessage) ---- # ---- 动手 (AALC 输入后端,由 config.yaml 决定后台消息/前台输入) ----
def click(self, x, y, times=1): def click(self, x, y, times=1):
self.auto.mouse_click(int(x), int(y), times=int(times)) self.auto.mouse_click(int(x), int(y), times=int(times))
@@ -137,7 +152,26 @@ class AalcEngine(Engine):
k = str(key).lower() k = str(key).lower()
if k not in self.key_names: if k not in self.key_names:
raise ValueError('AALC 不支持按键 %r, 可用: %s' % (key, ' '.join(self.key_names))) raise ValueError('AALC 不支持按键 %r, 可用: %s' % (key, ' '.join(self.key_names)))
self.auto.key_press(k) if not self.cfg.simulator and self.cfg.win_input_type == 'background':
# Unity 可能在同一帧收到 down/up,导致快捷键被吞掉。
handler = self.auto.input_handler
self.auto.wait_pause()
handler.set_active()
handler.key_down(k)
try:
time.sleep(0.12)
finally:
handler.key_up(k)
else:
self.auto.key_press(k)
def drag(self, from_x, from_y, to_x, to_y, duration=1.0):
img = self._grab(gray=False)
for x, y in ((from_x, from_y), (to_x, to_y)):
if not (0 <= x < img.width and 0 <= y < img.height):
raise ValueError('拖动坐标超出游戏客户区 %sx%s' % (img.width, img.height))
self.auto.mouse_drag(int(from_x), int(from_y), drag_time=float(duration),
dx=int(to_x) - int(from_x), dy=int(to_y) - int(from_y))
def type_text(self, text): def type_text(self, text):
self.auto.input_text(str(text)) self.auto.input_text(str(text))