Align AVA2 Windows behavior and improve mobile touch interactions
This commit is contained in:
@@ -114,6 +114,14 @@ class RoundButton(ui.Window):
|
||||
return True
|
||||
|
||||
|
||||
class ShortcutHitArea(ui.Window):
|
||||
def __init__(self, event):
|
||||
ui.Window.__init__(self)
|
||||
self.event = event
|
||||
def OnMouseLeftButtonUp(self):
|
||||
self.event(0)
|
||||
return True
|
||||
|
||||
class QuickSlotDisc(ui.Window):
|
||||
"""一个快捷栏格子:圆框 + 原版 SlotWindow 绘制技能/物品/表情图标、数量和冷却。
|
||||
slotIndex 为 None 时显示当前快捷页的 localIndex(与 PC 任务栏 1-4/F1-F4 同一份数据);
|
||||
@@ -128,6 +136,11 @@ class QuickSlotDisc(ui.Window):
|
||||
self.globalIndex = globalIndex
|
||||
self.disc = MakeDisc(self, 0, 0, diameter, STYLE_FRAME)
|
||||
|
||||
self.hit_area = ShortcutHitArea(ui.__mem_func__(self.__OnSelectItem))
|
||||
self.hit_area.SetParent(self)
|
||||
self.hit_area.SetSize(diameter, diameter)
|
||||
self.hit_area.GetTouchSkillSlot = ui.__mem_func__(self.GetTouchSkillSlot)
|
||||
self.hit_area.Show()
|
||||
off = (diameter - self.SLOT_SIZE) / 2
|
||||
slot = ui.SlotWindow()
|
||||
slot.SetParent(self)
|
||||
@@ -139,6 +152,7 @@ class QuickSlotDisc(ui.Window):
|
||||
slot.SetSelectItemSlotEvent(ui.__mem_func__(self.__OnSelectItem))
|
||||
slot.Show()
|
||||
self.slot = slot
|
||||
slot.GetTouchSkillSlot = ui.__mem_func__(self.GetTouchSkillSlot)
|
||||
|
||||
def __del__(self):
|
||||
ui.Window.__del__(self)
|
||||
@@ -148,6 +162,12 @@ class QuickSlotDisc(ui.Window):
|
||||
return player.GetGlobalQuickSlot(self.globalIndex)
|
||||
return player.GetLocalQuickSlot(self.localIndex)
|
||||
|
||||
def GetTouchSkillSlot(self):
|
||||
if mouseModule.mouseController.isAttached():
|
||||
return -1
|
||||
(Type, Position) = self.GetQuickSlot()
|
||||
return Position if Type == player.SLOT_TYPE_SKILL and player.GetSkillIndex(Position) else -1
|
||||
|
||||
def __Use(self):
|
||||
if self.globalIndex is not None:
|
||||
player.RequestUseGlobalQuickSlot(self.globalIndex)
|
||||
|
||||
Reference in New Issue
Block a user