Mobile gestures: item tap/drag/double-tap/long-press on original windows
Port the EterPythonLib CSlotWindow/CGridSlotWindow mouse handlers (select, drop, use, right click, tooltips, grid picking/CheckMoving) and CWindowManager IsDragging/right button, which were missing so item interaction did not work on desktop either. app.SetMouseHandler now renders the attached icon, app.IsPressed reads real key state, desktop double clicks reach the window manager. The touch router maps UI touches to the original mouse: tap = click at the touch-down point, drag = press-and-drag, double tap = double click, long press on an item slot = touch.SetLongPressEvent, which opens the ui_mobile_actions item sheet (use / split / quick slot via virtual Shift/Ctrl). New ava2.inventory_touch test drives uiinventory.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
908838c8f9
commit
6244b1d860
@@ -130,6 +130,23 @@ Python 更新(原版脚本 + mobile HUD)
|
||||
- 20:9 等宽屏需按安全区域布局。
|
||||
- 不使用其他服务器的界面美术;图标用 AVA2 自带技能/道具图标,按钮底框和摇杆另制。
|
||||
|
||||
## 物品与窗口手势
|
||||
|
||||
原版窗口不改,触摸由 `src/app/input/touch_router` 翻译成原版鼠标事件,经窗口管理器和移植的 `CSlotWindow` 鼠标处理进入 `uiinventory.py` 等原版脚本:
|
||||
|
||||
| 手势 | 翻译成 | 原版效果 |
|
||||
|---|---|---|
|
||||
| 手指按住不动 | 鼠标移到该处 | 物品格显示原版物品提示 |
|
||||
| 点按 | 在按下点依次发移动、左键按下、左键抬起 | 拿起物品(图标跟随);再点空格/装备格/其他窗口即放下、穿戴、交易放入 |
|
||||
| 拖动(超过 tap_slop) | 在起点按下左键,随后跟随移动,抬起即松开 | 原版拖拽:换格、拖到装备栏、拖出窗口丢弃、拖到商店出售 |
|
||||
| 双击(300 ms、40 px 内) | 原版左键双击 | `OnUseSlot`:使用药水、穿戴/卸下装备 |
|
||||
| 长按物品格(450 ms) | `touch.SetLongPressEvent` 回调 | 提示保持显示,弹出 `ui_mobile_actions.ItemActionSheet`:使用、拆分、加入快捷栏、关闭 |
|
||||
|
||||
- 长按面板的按钮调用原版槽位事件。“使用”调用 `OnUseSlot`;“拆分”和“加入快捷栏”通过 `touch.SetVirtualKey` 临时按住 Shift / Ctrl,再调用 `OnSelectItemSlot`,走原版的修饰键分支。
|
||||
- 点面板外任意处关闭面板。长按空格子没有操作,按普通按下处理。
|
||||
- 手指抬起后指针移到屏幕外(拿着物品时除外),以免提示一直停留。
|
||||
- 技能:技能圈和底部栏是原版快捷栏格,点按即使用(第 4 步)。从技能窗口把技能拖到快捷栏用的是同一套槽位拖拽,但还没有单独测试。
|
||||
|
||||
## 目录变化
|
||||
|
||||
- `support/android` → 顶层 `android/`(补全)。
|
||||
|
||||
@@ -1453,3 +1453,45 @@ the app is in the background (iOS suspends SDL_AppIterate). Android still
|
||||
uses the classic loop. Paths the client opens without lower-casing them
|
||||
would fail on iOS; none showed up in the login screen or the game phase,
|
||||
but character select and a real-server login have not been run on iOS yet.
|
||||
|
||||
### 2026-10-13 Mobile gestures — item and window interaction
|
||||
|
||||
- Before this step the port's `CSlotWindow` had no mouse handlers, so item
|
||||
pick-up, drop, equip, double-click use, right-click and hover tooltips did
|
||||
not work on desktop either. Ported from EterPythonLib, 1:1:
|
||||
- `PythonSlotWindow.cpp` handlers: left down → OnSelectItemSlot/OnSelectEmptySlot,
|
||||
the drop on left up, right down, double click → OnUseSlot, over/over-out
|
||||
tooltips, RefreshSlot.
|
||||
- `PythonGridSlotWindow.cpp`: the slot vector, GetPickedSlotList,
|
||||
OnRefreshSlot, CheckMoving, the grid GetPickedSlotPointer.
|
||||
- `CWindowManager`: IsDragging (the 10 px rule), mouse over on every move,
|
||||
right button down/up with DeattachIcon.
|
||||
- `app.SetMouseHandler` now stores the handler. app_loop calls its
|
||||
Update/Render after the phase window, so the attached icon follows the
|
||||
pointer. `app.IsPressed` reads the real keyboard state, so desktop
|
||||
Shift-split and Ctrl-quickslot work. Desktop double clicks
|
||||
(`clicks >= 2`) reach RunMouseLeftButtonDoubleClick. Keys are released on
|
||||
focus loss and when the app goes to the background.
|
||||
- Touch router UI gestures:
|
||||
- A tap sends move, down and up at the touch-down point.
|
||||
- A drag past tap_slop presses at the start point.
|
||||
- A double tap (within 300 ms and 40 px) becomes a double click.
|
||||
- A long press (450 ms) on an item slot calls `touch.SetLongPressEvent`.
|
||||
- The callback opens `ui_mobile_actions.ItemActionSheet` with Use, Split and
|
||||
Quick slot. Split and Quick slot run the original Shift/Ctrl branches via
|
||||
`touch.SetVirtualKey`.
|
||||
- Mapping table: docs/MOBILE-ARCHITECTURE.md, "物品与窗口手势".
|
||||
|
||||
Verified: the new `ava2.inventory_touch` test drives the original
|
||||
uiinventory.py through the router and the window manager. It covers the
|
||||
hover tooltip, tap pick-up and tap drop (move packet 0→5), drag 0→6,
|
||||
double-tap use, the long-press sheet (Use, Split opens dlgPickMoney,
|
||||
Quick slot), tap-outside close, long press on an empty cell, and
|
||||
app.IsPressed. `touch_router_test` covers the gesture timing. The phone
|
||||
simulation (`--phone --touch`) draws no software cursor. Desktop 55/55.
|
||||
Outstanding:
|
||||
- Gestures have not been tried on an Android or iOS device yet.
|
||||
- Drop and sell are drag-only; the sheet has no buttons for them.
|
||||
- A button's zero-size TextLine sits at the button's exact centre pixel,
|
||||
and IsIn is inclusive, as in the original. Only that one pixel misses
|
||||
the button.
|
||||
|
||||
Reference in New Issue
Block a user