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
@@ -8,7 +8,9 @@
|
||||
# 使用/装备 -> slotWindow.OnUseSlot(原版右键/双击)
|
||||
# 拆分 -> 按住 Shift 调 OnSelectItemSlot(uiinventory.SelectItemSlot 的拆分分支)
|
||||
# 加入快捷栏 -> 按住 Ctrl 调 OnSelectItemSlot(交易/商店等窗口打开时是原版 Ctrl 放入)
|
||||
# 点面板外任意处关闭。丢弃、出售沿用拖拽(拖出窗口 / 拖到商店)。
|
||||
# 长按背包空格子(参考 jhaizhou-ops/d2r-mobile 的“长按空格整理”,MIT,未拷贝代码):
|
||||
# 整理 -> 原版整理按钮 separateButton 的事件(确认框后 /click_sort_items)
|
||||
# 点面板外任意处关闭。丢弃、出售沿用拖拽(拖出窗口 / 拖到商店任一格)。
|
||||
import ui
|
||||
import grp
|
||||
import app
|
||||
@@ -59,7 +61,9 @@ class ItemActionSheet(ui.Window):
|
||||
return inventory is not None and slotWindow is getattr(inventory, "wndItem", None)
|
||||
|
||||
# touch.SetLongPressEvent: True = 已处理(手指松开不再点击)
|
||||
def OnLongPress(self, slotWindow, slotNumber, itemCount, x, y):
|
||||
def OnLongPress(self, slotWindow, slotNumber, itemCount, x, y, isEmpty=0):
|
||||
if isEmpty:
|
||||
return self.__OnLongPressEmpty(slotWindow, slotNumber, x, y)
|
||||
actions = []
|
||||
if getattr(slotWindow, "eventUseSlot", None):
|
||||
actions.append((_Text("MOBILE_ITEM_USE", "Use"), self.__OnUse))
|
||||
@@ -80,6 +84,31 @@ class ItemActionSheet(ui.Window):
|
||||
self.SetTop()
|
||||
return True
|
||||
|
||||
# 空格子:只有背包格有整理;其他窗口照常按下(False)
|
||||
def __OnLongPressEmpty(self, slotWindow, slotNumber, x, y):
|
||||
if not self.__IsInventoryGrid(slotWindow) or not self.__SortButton():
|
||||
return False
|
||||
self.slotWindow = slotWindow
|
||||
self.slotNumber = slotNumber
|
||||
self.__Build([(_Text("MOBILE_ITEM_SORT", "Sort"), self.__OnSort), (_Text("UI_CLOSE", "Close"), self.Close)])
|
||||
self.__Place(x, y)
|
||||
self.Show()
|
||||
self.SetTop()
|
||||
return True
|
||||
|
||||
def __SortButton(self):
|
||||
inventory = getattr(self.interface, "wndInventory", None) if self.interface else None
|
||||
button = getattr(inventory, "separateButton", None) if inventory else None
|
||||
if button is None or not getattr(button, "eventFunc", None):
|
||||
return None
|
||||
return button
|
||||
|
||||
def __OnSort(self):
|
||||
self.__Take()
|
||||
button = self.__SortButton()
|
||||
if button:
|
||||
button.CallEvent()
|
||||
|
||||
def __Build(self, actions):
|
||||
for button in self.buttons:
|
||||
button.Hide()
|
||||
|
||||
Reference in New Issue
Block a user