aram-mayhem-dsh 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -9
- package/config/settings.json +70 -57
- package/docs/DETAIL.md +19 -3
- package/docs/DETAIL.zh.md +19 -3
- package/index.js +3 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
- package/requirements-dsh.txt +3 -0
- package/scripts/desktop_overlay.py +128 -14
- package/scripts/dsh_service.py +8 -4
- package/src/app.py +7 -0
- package/src/core/settings.py +34 -18
- package/src/data/matcher.py +89 -0
- package/src/data/models.py +1 -0
- package/src/main.py +1 -0
- package/src/ui/augment_panel.py +2 -2
- package/src/vision/capture.py +28 -0
- package/src/vision/debug_export.py +66 -0
- package/src/vision/ocr_engine.py +194 -1
- package/src/vision/scanner.py +135 -19
- package/src/vision/title_strip.py +127 -0
package/README.md
CHANGED
|
@@ -78,16 +78,16 @@ powershell -ExecutionPolicy Bypass -File .\scripts\package_share.ps1
|
|
|
78
78
|
|
|
79
79
|
## 桌面图标
|
|
80
80
|
|
|
81
|
-
-
|
|
82
|
-
- 点击展开:英雄 / 推荐海克斯 /
|
|
83
|
-
- 点标题栏「收起」、按 `Esc
|
|
81
|
+
- 默认停靠主屏右边缘并**半隐藏**:只露出约 45% 宽度,透明度约 0.45;鼠标移入平滑滑出完整图标,移出 400ms 后缩回。
|
|
82
|
+
- 点击展开:英雄 / 推荐海克斯 / 出装三个页签;功能菜单打开或主面板展开时不会缩回。
|
|
83
|
+
- 点标题栏「收起」、按 `Esc`,或点击游戏/其他窗口时自动缩回半隐藏图标,减少对视野的遮挡。
|
|
84
84
|
- **游戏必须使用「无边框」或「窗口化」**:独占全屏会盖住所有 Windows 置顶窗口,图标和 OCR 都无法显示/截图。游戏内按 Esc → 视频 → 窗口模式 → 无边框。
|
|
85
|
-
-
|
|
85
|
+
- 展开后可以拖动标题栏移动;拖到左/右边缘会吸附,收起后回到右边缘半隐藏。
|
|
86
86
|
- 海克斯品质使用官方配色:**棱彩**为青→紫→金的虹彩渐变,**黄金**为金色,**白银**为银灰;页面和桌面图标保持一致。
|
|
87
87
|
- 游戏中如果服务是在选人结束后才启动,会通过 **Live Client Data API** 读取当前英雄,不要求重新进选人。
|
|
88
88
|
- 关闭图标或页面开关会退出进程并记住「关闭」,下次插件加载不会再自动弹出;点页面开关或调用 `aram_overlay open` 可重新打开。
|
|
89
89
|
- 关闭 **「服务」** 会终止 Python 进程,并同时关闭桌面图标;下次使用时需重新点「服务 开」。
|
|
90
|
-
- 页面右上角的 **「桌面图标 开/关」**
|
|
90
|
+
- 页面右上角的 **「桌面图标 开/关」** 开关会立即启动/关闭图标;关闭后即使重载插件也不会自动弹出。
|
|
91
91
|
|
|
92
92
|
## 页面
|
|
93
93
|
|
|
@@ -101,12 +101,24 @@ powershell -ExecutionPolicy Bypass -File .\scripts\package_share.ps1
|
|
|
101
101
|
|
|
102
102
|
### 对局内 OCR
|
|
103
103
|
|
|
104
|
-
- 用 `mss`
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
-
|
|
104
|
+
- 用 `mss` 截取游戏客户区,按 **16:9 居中安全区**换算坐标,超宽屏不会把卡排拉伸到侧边。
|
|
105
|
+
- 只扫描一条 `vision.augment_title_strip` 横向标题带,默认 `[0.08, 0.38, 0.84, 0.055]`,避开图标和技能描述。
|
|
106
|
+
- 预处理为 HSV 亮度/饱和度掩码 + 局部自适应阈值(不使用全局 Otsu),2x 双三次放大,白底黑字加 16px 白边。
|
|
107
|
+
- 通过 X 轴墨迹投影自动分卡,原生兼容 **3 卡/4 卡**及长名称折行;再用拼音 + 字形闭集纠错(`pypinyin` + `rapidfuzz`)还原同音/误识字。
|
|
108
|
+
- 默认轮询约 250ms;连续 2 帧结果一致才刷新,避免画面粒子导致闪烁。
|
|
109
|
+
- 游戏建议使用**无边框/窗口化**;独占全屏可能截到黑屏。
|
|
110
|
+
- `vision.region` 仍保留作为无标题带配置时的兼容回退区域;`vision.card_merge_gap_ratio` 控制同卡合并间距,`vision.ocr_closed_threshold` 控制纠错阈值。
|
|
108
111
|
- OCR 只读屏幕,不注入游戏、不自动点击卡片。
|
|
109
112
|
|
|
113
|
+
### F9 视觉调试
|
|
114
|
+
|
|
115
|
+
- 在 DSH 图标上按 **F9**,或调用 `aram_scan` 并传 `debug=true`,会把调试包写到 `debug_output/<时间>/`:
|
|
116
|
+
- `annotated_strip.png`:蓝色标题带、绿色分卡框和序号;
|
|
117
|
+
- `title_strip_raw.png` / `title_strip_processed.png`;
|
|
118
|
+
- `game_fullscreen.png`(如果可用);
|
|
119
|
+
- `ocr_log.txt`:卡片数量、原始 OCR、匹配置信度、最终海克斯名。
|
|
120
|
+
- legacy 入口也支持 `python src/main.py --debug-vision` 和 F9。`vision.debug_vision=true` 可让每次扫描都导出(只建议排查时开启)。
|
|
121
|
+
|
|
110
122
|
**注意**:桌面图标是真正的 Windows 置顶悬浮窗;DSH 页面位于 Harness 窗口内,适合副屏。原来的 PySide 完整桌面版仍保留在 `src/main.py`,作为可选 legacy 入口。
|
|
111
123
|
|
|
112
124
|
## Agent 工具
|
package/config/settings.json
CHANGED
|
@@ -1,57 +1,70 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 1,
|
|
3
|
-
"window": {
|
|
4
|
-
"x": null,
|
|
5
|
-
"y": null,
|
|
6
|
-
"width": 420,
|
|
7
|
-
"height": 680,
|
|
8
|
-
"min_width": 360,
|
|
9
|
-
"opacity": 0.97,
|
|
10
|
-
"always_on_top": true,
|
|
11
|
-
"mini": false,
|
|
12
|
-
"click_through": false
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"window": {
|
|
4
|
+
"x": null,
|
|
5
|
+
"y": null,
|
|
6
|
+
"width": 420,
|
|
7
|
+
"height": 680,
|
|
8
|
+
"min_width": 360,
|
|
9
|
+
"opacity": 0.97,
|
|
10
|
+
"always_on_top": true,
|
|
11
|
+
"mini": false,
|
|
12
|
+
"click_through": false,
|
|
13
|
+
"edge_hide": true,
|
|
14
|
+
"edge_hide_ratio": 0.55,
|
|
15
|
+
"edge_hover_delay_ms": 400
|
|
16
|
+
},
|
|
17
|
+
"hotkeys": {
|
|
18
|
+
"enabled": true,
|
|
19
|
+
"toggle_visible": "Ctrl+Shift+H",
|
|
20
|
+
"toggle_mini": "Ctrl+Shift+M",
|
|
21
|
+
"rescan_augments": "Ctrl+Shift+R",
|
|
22
|
+
"toggle_click_through": "Ctrl+Shift+L",
|
|
23
|
+
"debug_vision": "F9"
|
|
24
|
+
},
|
|
25
|
+
"lcu": {
|
|
26
|
+
"enabled": true,
|
|
27
|
+
"poll_interval": 1.0,
|
|
28
|
+
"use_websocket": true,
|
|
29
|
+
"reconnect_interval": 5.0,
|
|
30
|
+
"request_timeout": 3.0
|
|
31
|
+
},
|
|
32
|
+
"vision": {
|
|
33
|
+
"enabled": true,
|
|
34
|
+
"interval": 0.25,
|
|
35
|
+
"region": [
|
|
36
|
+
0.06,
|
|
37
|
+
0.12,
|
|
38
|
+
0.88,
|
|
39
|
+
0.76
|
|
40
|
+
],
|
|
41
|
+
"augment_title_strip": [
|
|
42
|
+
0.08,
|
|
43
|
+
0.38,
|
|
44
|
+
0.84,
|
|
45
|
+
0.055
|
|
46
|
+
],
|
|
47
|
+
"card_merge_gap_ratio": 0.025,
|
|
48
|
+
"ocr_closed_threshold": 0.65,
|
|
49
|
+
"debug_vision": false,
|
|
50
|
+
"ocr_min_confidence": 0.45,
|
|
51
|
+
"match_threshold": 0.72,
|
|
52
|
+
"min_matches": 2,
|
|
53
|
+
"cooldown": 8.0
|
|
54
|
+
},
|
|
55
|
+
"data": {
|
|
56
|
+
"seed_file": "data/seed_16.23.json",
|
|
57
|
+
"cache_file": "data/cache/stats.sqlite3",
|
|
58
|
+
"stats_url": "",
|
|
59
|
+
"auto_refresh": false,
|
|
60
|
+
"refresh_hours": 24.0
|
|
61
|
+
},
|
|
62
|
+
"ui": {
|
|
63
|
+
"language": "zh_CN",
|
|
64
|
+
"font_family": "Microsoft YaHei UI",
|
|
65
|
+
"exclude_from_capture": true
|
|
66
|
+
},
|
|
67
|
+
"demo": {
|
|
68
|
+
"enabled": false
|
|
69
|
+
}
|
|
70
|
+
}
|
package/docs/DETAIL.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
# ARAM: Mayhem assistant
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# ARAM: Mayhem assistant
|
|
2
|
+
|
|
3
|
+
An on-demand ARAM: Mayhem companion for DeepSeek Harness: screen-top overlay, champion/augment/build data, live LCU state, local OCR, and nine `aram_*` tools.
|
|
4
|
+
|
|
5
|
+
## Important: game window mode
|
|
6
|
+
|
|
7
|
+
**League of Legends must run in Borderless or Windowed mode for the always-on-top icon and OCR to work.**
|
|
8
|
+
|
|
9
|
+
- Exclusive Fullscreen (`WindowMode=0` in `game.cfg`) covers normal Windows topmost windows;
|
|
10
|
+
- In game: **Esc → Video → Window Mode → Borderless**; no restart is required;
|
|
11
|
+
- This is a Windows limitation, not an identification or permission failure.
|
|
12
|
+
|
|
13
|
+
## Service and icon
|
|
14
|
+
|
|
15
|
+
- The local service does **not** auto-start with the plugin;
|
|
16
|
+
- Open the sidebar page and click **Service On**; click **Service Off** to stop the Python process;
|
|
17
|
+
- Turn on the desktop icon separately with **Desktop Icon On**; stopping the service also closes the icon.
|
|
18
|
+
|
|
19
|
+

|
package/docs/DETAIL.zh.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
# 海斗助手
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# 海斗助手
|
|
2
|
+
|
|
3
|
+
按需启动的《英雄联盟》**海克斯大乱斗**(ARAM: Mayhem)DSH 助手:屏幕置顶图标、英雄/推荐海克斯/出装、LCU 当前选人、本地 OCR,以及九个 `aram_*` 工具。
|
|
4
|
+
|
|
5
|
+
## 重要:游戏窗口模式
|
|
6
|
+
|
|
7
|
+
**游戏必须使用「无边框」或「窗口化」模式,图标才能置顶显示,OCR 才能截图。**
|
|
8
|
+
|
|
9
|
+
- 独占全屏(`game.cfg` 的 `WindowMode=0`)会盖住所有普通 Windows 置顶窗口;
|
|
10
|
+
- 游戏内按 **Esc → 视频 → 窗口模式 → 无边框**,无需重启游戏;
|
|
11
|
+
- 这不是识别失败,也不是插件权限问题。
|
|
12
|
+
|
|
13
|
+
## 服务与图标
|
|
14
|
+
|
|
15
|
+
- 插件加载时**不会自动启动**本地服务;
|
|
16
|
+
- 打开侧边栏「海斗助手」,点右上角 **「服务 开」**;不用时点 **「服务 关」**,Python 进程会停止;
|
|
17
|
+
- 需要桌面图标时再点 **「桌面图标 开」**;关闭服务会同时关闭图标。
|
|
18
|
+
|
|
19
|
+

|
package/index.js
CHANGED
|
@@ -413,10 +413,11 @@ export function apply(ctx, config = {}) {
|
|
|
413
413
|
+ 'Use only when the user is in an ARAM: Mayhem game and asks about the current cards.',
|
|
414
414
|
parameters: objectSchema({
|
|
415
415
|
champion: { type: 'string', description: 'Optional champion name/ID; omit to use the champion detected in champ select.' },
|
|
416
|
+
debug: { type: 'boolean', description: 'Write annotated strip, preprocessed image and OCR log to debug_output/.' },
|
|
416
417
|
}, []),
|
|
417
418
|
output: { schema: { type: 'string' }, render: (_args, value) => asText(value) },
|
|
418
419
|
execute: async args => {
|
|
419
|
-
const data = await post('/scan', { champion: args?.champion || undefined })
|
|
420
|
+
const data = await post('/scan', { champion: args?.champion || undefined, debug: !!args?.debug })
|
|
420
421
|
if (!data.ok) return `识别失败:${data.error || '未知原因'}`
|
|
421
422
|
if (!data.matches?.length) return '没有识别到海克斯卡片。请确认游戏使用无边框/窗口化,并调整识别区域。'
|
|
422
423
|
const lines = [`识别到 ${data.matches.length} 张卡片:${data.matches.map(item => `${item.name}(${Math.round(item.confidence * 100)}%)`).join(' / ')}`]
|
|
@@ -425,6 +426,7 @@ export function apply(ctx, config = {}) {
|
|
|
425
426
|
lines.push('', '按当前英雄推荐:')
|
|
426
427
|
data.evaluations.forEach((item, index) => lines.push(`${index + 1}. ${fmtEval(item)}`))
|
|
427
428
|
}
|
|
429
|
+
if (args?.debug) lines.push('', '调试截图与 OCR 日志已写入 debug_output/。')
|
|
428
430
|
lines.push('', await dataNote())
|
|
429
431
|
return lines.join('\n')
|
|
430
432
|
},
|
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "ARAM: Mayhem assistant",
|
|
4
|
-
"description": "On-demand ARAM: Mayhem companion for DSH. Start the local service from the page, then open the screen-top icon for champions, recommended augments and builds; includes nine aram_* tools. Install the Python dependencies in requirements-dsh.txt first.",
|
|
4
|
+
"description": "On-demand ARAM: Mayhem companion for DSH. Start the local service from the page, then open the screen-top icon for champions, recommended augments and builds; includes nine aram_* tools. League must run in Borderless or Windowed mode for the icon to stay on top. Install the Python dependencies in requirements-dsh.txt first.",
|
|
5
5
|
"detail": "docs/DETAIL.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "海斗助手",
|
|
4
|
-
"description": "按需启动的《英雄联盟》海克斯大乱斗 DSH 助手:页面开关启动/停止本地服务,再打开屏幕置顶图标查看英雄、推荐海克斯和出装;同时提供九个 aram_*
|
|
4
|
+
"description": "按需启动的《英雄联盟》海克斯大乱斗 DSH 助手:页面开关启动/停止本地服务,再打开屏幕置顶图标查看英雄、推荐海克斯和出装;同时提供九个 aram_* 工具。游戏需使用无边框/窗口化,图标才能置顶显示。首次使用需安装 requirements-dsh.txt 中的 Python 依赖。",
|
|
5
5
|
"detail": "docs/DETAIL.zh.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aram-mayhem-dsh",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "ARAM: Mayhem companion for DSH:
|
|
5
|
+
"description": "ARAM: Mayhem companion for DSH: an on-demand local service, screen-top desktop icon, sidebar page with LCU state, champion/augment statistics, builds and screen OCR, with nine agent tools.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "mumu1001ai-jpg",
|
|
8
8
|
"repository": {
|
package/requirements-dsh.txt
CHANGED
|
@@ -19,7 +19,19 @@ from pathlib import Path
|
|
|
19
19
|
from typing import Any
|
|
20
20
|
from urllib.parse import quote
|
|
21
21
|
|
|
22
|
-
from PySide6.QtCore import
|
|
22
|
+
from PySide6.QtCore import (
|
|
23
|
+
QEasingCurve,
|
|
24
|
+
QEvent,
|
|
25
|
+
QLockFile,
|
|
26
|
+
QParallelAnimationGroup,
|
|
27
|
+
QPoint,
|
|
28
|
+
QPropertyAnimation,
|
|
29
|
+
QRectF,
|
|
30
|
+
Qt,
|
|
31
|
+
QTimer,
|
|
32
|
+
QUrl,
|
|
33
|
+
Signal,
|
|
34
|
+
)
|
|
23
35
|
from PySide6.QtGui import (
|
|
24
36
|
QColor,
|
|
25
37
|
QFont,
|
|
@@ -355,6 +367,8 @@ class IconWidget(QWidget):
|
|
|
355
367
|
if event.button() == Qt.MouseButton.LeftButton:
|
|
356
368
|
if not self._moved:
|
|
357
369
|
self.clicked.emit()
|
|
370
|
+
else:
|
|
371
|
+
self._overlay._on_icon_drag_release()
|
|
358
372
|
self._press = None
|
|
359
373
|
super().mouseReleaseEvent(event)
|
|
360
374
|
|
|
@@ -438,6 +452,11 @@ class FloatingOverlay(QWidget):
|
|
|
438
452
|
self._expanded_at = 0.0
|
|
439
453
|
self._signature: Any = None
|
|
440
454
|
self._search_busy = False
|
|
455
|
+
self._peeked = False
|
|
456
|
+
self._hide_timer = QTimer(self)
|
|
457
|
+
self._hide_timer.setSingleShot(True)
|
|
458
|
+
self._hide_timer.timeout.connect(self._hide_peek)
|
|
459
|
+
self._icon_animation: QParallelAnimationGroup | None = None
|
|
441
460
|
self._state_path = root / "config" / "overlay_state.json"
|
|
442
461
|
self._pid_path = root / "data" / "cache" / "overlay.pid"
|
|
443
462
|
self._lock_path = root / "data" / "cache" / "overlay.lock"
|
|
@@ -480,6 +499,11 @@ class FloatingOverlay(QWidget):
|
|
|
480
499
|
self._top_timer.setInterval(1200)
|
|
481
500
|
self._top_timer.timeout.connect(self._raise_topmost)
|
|
482
501
|
self._top_timer.start()
|
|
502
|
+
self._f9_down = False
|
|
503
|
+
self._f9_timer = QTimer(self)
|
|
504
|
+
self._f9_timer.setInterval(80)
|
|
505
|
+
self._f9_timer.timeout.connect(self._poll_f9)
|
|
506
|
+
self._f9_timer.start()
|
|
483
507
|
QTimer.singleShot(120, self._api.get_snapshot)
|
|
484
508
|
if start_expanded:
|
|
485
509
|
QTimer.singleShot(200, self.expand)
|
|
@@ -591,6 +615,11 @@ class FloatingOverlay(QWidget):
|
|
|
591
615
|
self.expanded = expanded
|
|
592
616
|
if expanded:
|
|
593
617
|
self._expanded_at = time.monotonic()
|
|
618
|
+
self._hide_timer.stop()
|
|
619
|
+
if self._icon_animation is not None:
|
|
620
|
+
self._icon_animation.stop()
|
|
621
|
+
self._icon_animation = None
|
|
622
|
+
self.setWindowOpacity(1.0)
|
|
594
623
|
self.stack.setCurrentIndex(1)
|
|
595
624
|
self.setMinimumSize(350, 480)
|
|
596
625
|
self.setMaximumSize(500, 900)
|
|
@@ -604,21 +633,96 @@ class FloatingOverlay(QWidget):
|
|
|
604
633
|
self.setMinimumSize(68, 68)
|
|
605
634
|
self.setMaximumSize(68, 68)
|
|
606
635
|
self.resize(68, 68)
|
|
607
|
-
self.
|
|
636
|
+
self._hide_timer.stop()
|
|
637
|
+
self._peeked = True
|
|
638
|
+
self._snap_icon(peek=True, animate=False)
|
|
639
|
+
self.setWindowOpacity(0.45)
|
|
608
640
|
self._raise_topmost()
|
|
609
641
|
|
|
642
|
+
def _edge_x(self, peek: bool) -> int:
|
|
643
|
+
screen = self.screen() or QApplication.primaryScreen()
|
|
644
|
+
if screen is None:
|
|
645
|
+
return self.x()
|
|
646
|
+
area = screen.availableGeometry()
|
|
647
|
+
if peek:
|
|
648
|
+
ratio = 0.55
|
|
649
|
+
visible = max(16, round(self.width() * (1.0 - ratio)))
|
|
650
|
+
return area.right() - visible
|
|
651
|
+
return area.right() - self.width() - 14
|
|
652
|
+
|
|
610
653
|
def _snap_right(self) -> None:
|
|
611
|
-
"""
|
|
654
|
+
"""Backward-compatible alias for the half-hidden right edge."""
|
|
655
|
+
|
|
656
|
+
self._snap_icon(peek=True, animate=False)
|
|
657
|
+
|
|
658
|
+
def _snap_icon(self, *, peek: bool, animate: bool) -> None:
|
|
612
659
|
screen = self.screen() or QApplication.primaryScreen()
|
|
613
660
|
if screen is None:
|
|
614
661
|
return
|
|
615
662
|
area = screen.availableGeometry()
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
self.
|
|
663
|
+
target_x = self._edge_x(peek)
|
|
664
|
+
target_y = self.y()
|
|
665
|
+
target_y = max(area.top() + 12, min(target_y, area.bottom() - self.height() - 12))
|
|
666
|
+
target = QPoint(target_x, target_y)
|
|
667
|
+
self._peeked = peek
|
|
668
|
+
if not animate or not self.isVisible():
|
|
669
|
+
self.move(target)
|
|
670
|
+
self.setWindowOpacity(0.45 if peek else 1.0)
|
|
671
|
+
return
|
|
672
|
+
if self._icon_animation is not None:
|
|
673
|
+
self._icon_animation.stop()
|
|
674
|
+
group = QParallelAnimationGroup(self)
|
|
675
|
+
move = QPropertyAnimation(self, b"pos", group)
|
|
676
|
+
move.setDuration(180)
|
|
677
|
+
move.setStartValue(self.pos())
|
|
678
|
+
move.setEndValue(target)
|
|
679
|
+
move.setEasingCurve(QEasingCurve.Type.OutCubic)
|
|
680
|
+
fade = QPropertyAnimation(self, b"windowOpacity", group)
|
|
681
|
+
fade.setDuration(180)
|
|
682
|
+
fade.setStartValue(float(self.windowOpacity()))
|
|
683
|
+
fade.setEndValue(0.45 if peek else 1.0)
|
|
684
|
+
fade.setEasingCurve(QEasingCurve.Type.OutCubic)
|
|
685
|
+
group.addAnimation(move)
|
|
686
|
+
group.addAnimation(fade)
|
|
687
|
+
group.finished.connect(lambda: setattr(self, "_icon_animation", None))
|
|
688
|
+
self._icon_animation = group
|
|
689
|
+
group.start()
|
|
690
|
+
|
|
691
|
+
def _reveal_icon(self) -> None:
|
|
692
|
+
if self.expanded:
|
|
693
|
+
return
|
|
694
|
+
self._hide_timer.stop()
|
|
695
|
+
self._snap_icon(peek=False, animate=True)
|
|
696
|
+
|
|
697
|
+
def _hide_peek(self) -> None:
|
|
698
|
+
if self.expanded or self.underMouse():
|
|
699
|
+
return
|
|
700
|
+
self._snap_icon(peek=True, animate=True)
|
|
701
|
+
|
|
702
|
+
def enterEvent(self, event):
|
|
703
|
+
self._hide_timer.stop()
|
|
704
|
+
if not self.expanded:
|
|
705
|
+
self._reveal_icon()
|
|
706
|
+
super().enterEvent(event)
|
|
707
|
+
|
|
708
|
+
def leaveEvent(self, event):
|
|
709
|
+
if not self.expanded:
|
|
710
|
+
self._hide_timer.start(400)
|
|
711
|
+
super().leaveEvent(event)
|
|
712
|
+
|
|
713
|
+
def _on_icon_drag_release(self) -> None:
|
|
714
|
+
if self.expanded:
|
|
715
|
+
return
|
|
716
|
+
screen = self.screen() or QApplication.primaryScreen()
|
|
717
|
+
if screen is None:
|
|
718
|
+
return
|
|
719
|
+
area = screen.availableGeometry()
|
|
720
|
+
if self.x() + self.width() >= area.right() - 20 or self.x() <= area.left() + 20:
|
|
721
|
+
self._snap_icon(peek=True, animate=True)
|
|
722
|
+
else:
|
|
723
|
+
self._peeked = False
|
|
724
|
+
self.setWindowOpacity(1.0)
|
|
725
|
+
self._save_position()
|
|
622
726
|
|
|
623
727
|
def showEvent(self, event):
|
|
624
728
|
super().showEvent(event)
|
|
@@ -657,7 +761,6 @@ class FloatingOverlay(QWidget):
|
|
|
657
761
|
self._apply_mode(True)
|
|
658
762
|
self.raise_()
|
|
659
763
|
self.activateWindow()
|
|
660
|
-
|
|
661
764
|
def collapse(self) -> None:
|
|
662
765
|
if not self.expanded:
|
|
663
766
|
return
|
|
@@ -1103,7 +1206,7 @@ class FloatingOverlay(QWidget):
|
|
|
1103
1206
|
self.content_layout.addLayout(row)
|
|
1104
1207
|
|
|
1105
1208
|
# --------------------------------------------------------------- actions
|
|
1106
|
-
def _scan(self) -> None:
|
|
1209
|
+
def _scan(self, *, debug: bool = False) -> None:
|
|
1107
1210
|
if self.scanning:
|
|
1108
1211
|
return
|
|
1109
1212
|
active = self._active()
|
|
@@ -1114,7 +1217,18 @@ class FloatingOverlay(QWidget):
|
|
|
1114
1217
|
self.scanning = True
|
|
1115
1218
|
self.scan_error = ""
|
|
1116
1219
|
self._rebuild(force=True)
|
|
1117
|
-
self._api.scan(champion)
|
|
1220
|
+
self._api.scan(champion, debug=debug)
|
|
1221
|
+
|
|
1222
|
+
def _poll_f9(self) -> None:
|
|
1223
|
+
if os.name != "nt":
|
|
1224
|
+
return
|
|
1225
|
+
try:
|
|
1226
|
+
down = bool(ctypes.windll.user32.GetAsyncKeyState(0x78) & 0x8000)
|
|
1227
|
+
except OSError:
|
|
1228
|
+
return
|
|
1229
|
+
if down and not self._f9_down:
|
|
1230
|
+
self._scan(debug=True)
|
|
1231
|
+
self._f9_down = down
|
|
1118
1232
|
|
|
1119
1233
|
def _search_champion(self) -> None:
|
|
1120
1234
|
if self._search_busy:
|
|
@@ -1182,11 +1296,11 @@ class ApiClient(QWidget):
|
|
|
1182
1296
|
finally:
|
|
1183
1297
|
reply.deleteLater()
|
|
1184
1298
|
|
|
1185
|
-
def scan(self, champion_id: int | None) -> None:
|
|
1299
|
+
def scan(self, champion_id: int | None, *, debug: bool = False) -> None:
|
|
1186
1300
|
if self._scan_pending:
|
|
1187
1301
|
return
|
|
1188
1302
|
self._scan_pending = True
|
|
1189
|
-
reply = self._request("/scan", "post", {"champion": champion_id})
|
|
1303
|
+
reply = self._request("/scan", "post", {"champion": champion_id, "debug": debug})
|
|
1190
1304
|
reply.finished.connect(lambda: self._scan_done(reply))
|
|
1191
1305
|
|
|
1192
1306
|
def _scan_done(self, reply: QNetworkReply) -> None:
|
package/scripts/dsh_service.py
CHANGED
|
@@ -65,7 +65,7 @@ from src.lcu.listener import parse_champ_select, parse_queue_info
|
|
|
65
65
|
log = logging.getLogger("aram-dsh-service")
|
|
66
66
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
67
67
|
|
|
68
|
-
VERSION = "0.
|
|
68
|
+
VERSION = "0.4.0"
|
|
69
69
|
IN_GAME_PHASES = {"InProgress", "Reconnect"}
|
|
70
70
|
|
|
71
71
|
|
|
@@ -586,7 +586,7 @@ class AramService:
|
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
# -------------------------------------------------------------------- scan
|
|
589
|
-
def scan(self, champion_query: str | int | None = None) -> dict[str, Any]:
|
|
589
|
+
def scan(self, champion_query: str | int | None = None, *, debug: bool = False) -> dict[str, Any]:
|
|
590
590
|
with self._scan_lock:
|
|
591
591
|
try:
|
|
592
592
|
from src.vision.capture import CaptureError, ScreenCapture
|
|
@@ -612,7 +612,7 @@ class AramService:
|
|
|
612
612
|
if self._ocr is None:
|
|
613
613
|
self._ocr = RapidOCREngine(min_confidence=vision.ocr_min_confidence)
|
|
614
614
|
detector = AugmentDetector(capture, self._ocr, self.matcher, vision)
|
|
615
|
-
result = detector.detect_once(force=True)
|
|
615
|
+
result = detector.detect_once(force=True, debug=debug)
|
|
616
616
|
matches = list(result.matches)
|
|
617
617
|
evaluations = (
|
|
618
618
|
self.matcher.evaluate_detected(champion.id, matches)
|
|
@@ -631,10 +631,14 @@ class AramService:
|
|
|
631
631
|
"confidence": match.confidence,
|
|
632
632
|
"match_score": match.match_score,
|
|
633
633
|
"raw_text": match.raw_text,
|
|
634
|
+
"x_center_ratio": match.x_center_ratio,
|
|
634
635
|
}
|
|
635
636
|
for match in matches
|
|
636
637
|
],
|
|
637
638
|
"evaluations": [_evaluation_json(item) for item in evaluations],
|
|
639
|
+
"card_count": result.card_count,
|
|
640
|
+
"stable": result.stable,
|
|
641
|
+
"ocr_texts": list(result.ocr_texts),
|
|
638
642
|
"ocr_lines": result.ocr_lines,
|
|
639
643
|
"elapsed": result.elapsed,
|
|
640
644
|
"image_size": list(result.image_size),
|
|
@@ -931,7 +935,7 @@ def _handler_for(service: AramService):
|
|
|
931
935
|
try:
|
|
932
936
|
body = self._body()
|
|
933
937
|
if path == "/scan":
|
|
934
|
-
return self._send(200, service.scan(body.get("champion")))
|
|
938
|
+
return self._send(200, service.scan(body.get("champion"), debug=bool(body.get("debug"))))
|
|
935
939
|
if path == "/refresh":
|
|
936
940
|
return self._send(200, {"ok": True, "meta": service.refresh(str(body.get("url") or ""))})
|
|
937
941
|
if path == "/overlay/start":
|
package/src/app.py
CHANGED
|
@@ -153,6 +153,8 @@ class AssistantApp(QObject):
|
|
|
153
153
|
self._setup_hotkeys()
|
|
154
154
|
if self.demo_mode or self.args.screenshot:
|
|
155
155
|
QTimer.singleShot(250, self._start_demo)
|
|
156
|
+
if getattr(self.args, "debug_vision", False) and self.scanner is not None:
|
|
157
|
+
QTimer.singleShot(1200, self.scanner.request_debug)
|
|
156
158
|
if self.args.screenshot:
|
|
157
159
|
QTimer.singleShot(2800, self._capture_screenshot)
|
|
158
160
|
self.args.quit_after = max(3.2, float(self.args.quit_after or 0))
|
|
@@ -199,6 +201,7 @@ class AssistantApp(QObject):
|
|
|
199
201
|
"toggle_mini": cfg.toggle_mini,
|
|
200
202
|
"rescan_augments": cfg.rescan_augments,
|
|
201
203
|
"toggle_click_through": cfg.toggle_click_through,
|
|
204
|
+
"debug_vision": cfg.debug_vision,
|
|
202
205
|
}
|
|
203
206
|
self.hotkeys.start()
|
|
204
207
|
for name, combo in mapping.items():
|
|
@@ -310,6 +313,7 @@ class AssistantApp(QObject):
|
|
|
310
313
|
self._last_detection = result
|
|
311
314
|
matches = list(result.matches)
|
|
312
315
|
if not matches:
|
|
316
|
+
self.window.augment_panel.set_waiting("画面已回到对局,等待下一次海克斯出现")
|
|
313
317
|
return
|
|
314
318
|
champion = self._my_summary.champion if self._my_summary else None
|
|
315
319
|
if champion is not None:
|
|
@@ -353,6 +357,9 @@ class AssistantApp(QObject):
|
|
|
353
357
|
self.rescan()
|
|
354
358
|
elif name == "toggle_click_through":
|
|
355
359
|
self.window.toggle_click_through()
|
|
360
|
+
elif name == "debug_vision" and self.scanner is not None:
|
|
361
|
+
self.scanner.request_debug()
|
|
362
|
+
self.window.show_toast("正在导出 F9 视觉调试包…")
|
|
356
363
|
|
|
357
364
|
# ------------------------------------------------------------------- demo
|
|
358
365
|
def _start_demo(self) -> None:
|