Mobile touch: system edges, per-finger cancel, long-press sort
Interaction ideas from jhaizhou-ops/d2r-mobile (MIT), no code taken: - world fingers in the bottom safe inset (gesture bar) are ignored - SDL_EVENT_FINGER_CANCELED cancels one finger; a cancelled joystick keeps its vector for 300 ms and a finger near the old base re-acquires it - attack taps shorter than a frame release on the next Update - cancelled UI touches and world taps park the pointer (no hover residue) - long press on an empty inventory cell offers the original sort Desktop ctest 59/59; sort sheet verified on the device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c132891aef
commit
ae713a0772
@@ -141,10 +141,21 @@ Python 更新(原版脚本 + mobile HUD)
|
||||
| 拖动(超过 tap_slop) | 在起点按下左键,随后跟随移动,抬起即松开 | 原版拖拽:换格、拖到装备栏、拖出窗口丢弃、拖到商店出售 |
|
||||
| 双击(300 ms、40 px 内) | 原版左键双击 | `OnUseSlot`:使用药水、穿戴/卸下装备 |
|
||||
| 长按物品格(450 ms) | `touch.SetLongPressEvent` 回调 | 提示保持显示,弹出 `ui_mobile_actions.ItemActionSheet`:使用、拆分、加入快捷栏、关闭 |
|
||||
| 长按背包空格子(450 ms) | 同一回调,`isEmpty=1` | 面板只有“整理”和“关闭”;整理调用原版整理按钮 `separateButton` 的事件(确认框 → `/click_sort_items`) |
|
||||
|
||||
- 长按面板的按钮调用原版槽位事件。“使用”调用 `OnUseSlot`;“拆分”和“加入快捷栏”通过 `touch.SetVirtualKey` 临时按住 Shift / Ctrl,再调用 `OnSelectItemSlot`,走原版的修饰键分支。
|
||||
- 点面板外任意处关闭面板。长按空格子没有操作,按普通按下处理。
|
||||
- 手指抬起后指针移到屏幕外(拿着物品时除外),以免提示一直停留。
|
||||
- 点面板外任意处关闭面板。长按其他窗口的空格子、或被大件物品占住的格子,仍按普通按下处理。
|
||||
- 手指抬起后指针移到屏幕外(拿着物品时除外),以免提示一直停留。被取消的触摸、点地面(世界点击)结束后也一样。
|
||||
- 快捷栏和药水栏:每次点按的左键按下都会触发一次使用;第二下被识别成双击时只多发一个双击,快捷格没有双击事件,所以连点 N 次就是用 N 次。
|
||||
|
||||
## 系统边缘与取消
|
||||
|
||||
以下交互思路参考 [jhaizhou-ops/d2r-mobile](https://github.com/jhaizhou-ops/d2r-mobile)(MIT),只借鉴想法,没有拷贝代码:
|
||||
|
||||
- 底部安全区(手势导航条)里落下的世界手指不拖镜头,也不算点地面。
|
||||
- 系统取消某一根手指(`SDL_EVENT_FINGER_CANCELED`,例如边缘手势从它下面开始)时只释放这一根,其他手指不受影响。摇杆手指被取消后,摇杆保持原方向 `joy_reacquire_ms`(300 ms);这段时间内在原基点 1.5 倍半径内落下的手指接管摇杆,基点不变。
|
||||
- 攻击键点得比一帧还快时,松开推迟到下一帧,保证原版 player 模块至少看到一次按下。
|
||||
- 没有采用的:技能拖动瞄准(Metin2 技能按目标/朝向释放)、点面板外关闭所有窗口(点世界要移动角色)、手柄自动切换(以后再说)。
|
||||
- 技能:技能圈和底部栏是原版快捷栏格,点按即使用(第 4 步)。从技能窗口把技能拖到快捷栏用的是同一套槽位拖拽,但还没有单独测试。
|
||||
|
||||
## 目录变化
|
||||
|
||||
+37
-1
@@ -1588,4 +1588,40 @@ Verified on the device: minimap inside its frame, portrait/status bars and the e
|
||||
at the top edge. Desktop ctest 59/59.
|
||||
|
||||
Outstanding: after a tap the cursor stays where the finger lifted, so hover tooltips
|
||||
(e.g. "[F6] Battle pass") remain until the next touch.
|
||||
(e.g. "[F6] Battle pass") remain until the next touch. (Addressed below: world taps and
|
||||
cancelled touches now park the pointer too.)
|
||||
|
||||
### 2026-10-13 Mobile touch: system edges, cancel, long-press sort
|
||||
|
||||
Interaction ideas from jhaizhou-ops/d2r-mobile (MIT); only the ideas were taken, no code.
|
||||
docs/MOBILE-ARCHITECTURE.md has the details ("系统边缘与取消").
|
||||
|
||||
- `TouchRouter`:
|
||||
- world fingers that land in the bottom safe inset (the gesture bar) are `Owner::Ignored`;
|
||||
- new `FingerCancel(id, ms)`: `SDL_EVENT_FINGER_CANCELED` now cancels only that finger
|
||||
instead of `CancelAll`;
|
||||
- a cancelled joystick finger keeps the stick vector for `joy_reacquire_ms` (300). A finger
|
||||
landing within 1.5 radii of the old base takes it over, keeping the same base;
|
||||
- an attack tap shorter than a frame releases on the next `Update`;
|
||||
- new sink hook `UiPointerIdle`: a cancelled pending UI touch parks the pointer.
|
||||
- Host: a world tap's deferred button-up also parks the pointer (`TouchUiPointerIdle`), so no
|
||||
hover tooltip or target stays under the tap point.
|
||||
- Long press on an empty inventory cell: `touch.SetLongPressEvent` callbacks get a sixth
|
||||
argument, `isEmpty`. `ItemActionSheet` offers Sort / Close. Sort fires the original
|
||||
`separateButton` event, which opens the question and then sends `/click_sort_items`.
|
||||
Cells covered by a larger item and empty cells in other windows still press normally.
|
||||
- Checked, no change needed: every quick-slot tap uses the slot once (select on button
|
||||
down; the double click goes to `OnUseSlot`, and quick-slot discs have no use event).
|
||||
Dropping an item on any shop slot, empty or occupied, already sells it (uishop).
|
||||
- Tests:
|
||||
- `touch_router_test` `system_edges`;
|
||||
- `inventory_touch_test`: long-press empty cell → Sort → question → `/click_sort_items`;
|
||||
- `touch_game_test` now keeps its assert()s in release builds.
|
||||
- Desktop ctest 59/59.
|
||||
- Verified on the device: long press on an empty bag cell → Sort / Close → the original
|
||||
sort question.
|
||||
|
||||
Outstanding:
|
||||
- the system-edge strip and joystick re-acquire are covered by unit tests only, not yet
|
||||
exercised by hand on the phone;
|
||||
- hold-to-repeat on quick slots (d2r's held potion) is not done.
|
||||
|
||||
Reference in New Issue
Block a user