Align AVA2 Windows behavior and improve mobile touch interactions

This commit is contained in:
shen
2026-10-13 23:46:26 -07:00
parent 31c5b3dd9b
commit b3808d8d0c
106 changed files with 5162 additions and 637 deletions
+5 -2
View File
@@ -369,8 +369,11 @@ class CMouseController(object):
if True == self.isAttached():
if 0 != self.AttachedIconHandle:
grpImage.SetDiffuseColor(self.AttachedIconHandle, 1.0, 1.0, 1.0, 0.5)
grpImage.SetPosition(self.AttachedIconHandle, self.x - self.AttachedIconHalfWidth, self.y - self.AttachedIconHalfHeight)
self.countNumberLine.SetPosition(self.x, self.y - self.AttachedIconHalfHeight - 3)
import touch
lift = min(48, wndMgr.GetScreenHeight() * 0.06) if touch.IsEnabled() else 0
icon_y = max(touch.GetSafeArea()[1], self.y - self.AttachedIconHalfHeight - lift) if lift else self.y - self.AttachedIconHalfHeight
grpImage.SetPosition(self.AttachedIconHandle, self.x - self.AttachedIconHalfWidth, icon_y)
self.countNumberLine.SetPosition(self.x, icon_y - 3)
if self.IsSoftwareCursor:
if 0 != self.curCursorImage:
+10 -1
View File
@@ -22,7 +22,7 @@ class MobileCombatWheel(ui.Window):
"""
ATTACK_RADIUS = 60
SLOT_DIAMETER = 50
SMALL_DIAMETER = 40
SMALL_DIAMETER = 44
AUTO_DIAMETER = 46
# (半径, 角度):角度从 +x 逆时针,内外圈各 4 格,外圈错开半格;相邻格间距大于格子直径
SLOT_LAYOUT = [(108, 90), (108, 120), (108, 150), (108, 180),
@@ -66,6 +66,8 @@ class MobileCombatWheel(ui.Window):
self.attack_icon.Show()
except:
pass
self.aim_marker = widgets.MakeDisc(self, 0, 0, 44, widgets.STYLE_JOY_KNOB)
self.aim_marker.Hide()
self.attack_pressed = False
touch.SetAttackButton(origin_x, origin_y, r)
@@ -138,6 +140,13 @@ class MobileCombatWheel(ui.Window):
slot.Refresh()
def OnUpdate(self):
active, ox, oy, x, y = touch.GetSkillAim()
if active and math.hypot(x - ox, y - oy) > 14:
px, py = self.GetGlobalPosition()
self.aim_marker.SetPosition(int(x - px - 22), int(y - py - 22))
self.aim_marker.Show()
else:
self.aim_marker.Hide()
pressed = touch.IsAttackPressed()
if pressed != self.attack_pressed:
self.attack_pressed = pressed
+6 -8
View File
@@ -25,13 +25,8 @@ class MobileJoystick(ui.Window):
self.base_bar = widgets.MakeDisc(self, 0, 0, radius * 2, widgets.STYLE_JOY_BASE)
self.knob = widgets.MakeDisc(self, 0, 0, knob_radius * 2, widgets.STYLE_JOY_KNOB)
# 未按下时停在默认位置,提示摇杆区
if base_y is None:
import wndMgr
base_y = wndMgr.GetScreenHeight() - 180
self.rest_x = base_x
self.rest_y = base_y
self.__Place(base_x, base_y, base_x, base_y)
self.base_bar.Hide()
self.knob.Hide()
def __del__(self):
ui.Window.__del__(self)
@@ -45,5 +40,8 @@ class MobileJoystick(ui.Window):
active, base_x, base_y, knob_x, knob_y = touch.GetJoystick()
if active:
self.__Place(base_x, base_y, knob_x, knob_y)
self.base_bar.Show()
self.knob.Show()
else:
self.__Place(self.rest_x, self.rest_y, self.rest_x, self.rest_y)
self.base_bar.Hide()
self.knob.Hide()
+20
View File
@@ -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)