Files
AVA2/upstream/python-root/ui_mobile_joystick.py
T
shenleiandClaude Opus 5.5 11bd94d1ce Mobile HUD layout: disc widgets, quickslot wheel and belt (mobile step 4)
Native CDisc window for procedural round frames; ui_mobile_widgets
(RoundButton, QuickSlotDisc); HUD laid out as the phone plan: player
panel, top-right entry row with minimap, left button column, attack disc
with two quickslot rings, potion belt on quickslot page 4, exp bar. The
PC taskbar and its tooltips are hidden in mobile mode. Adds global
quickslot use/add/move for the belt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 21:14:29 +09:00

50 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
import ui
import touch
import ui_mobile_widgets as widgets
class MobileJoystick(ui.Window):
"""
移动端虚拟摇杆的显示层。
触摸由原生触摸分流器处理(src/app/input/touch_router.h):手指落在左下摇杆区时,
摇杆以落点为中心出现,方向经 player 模块的移动接口驱动主角,与键盘 WASD 走同一路径。
本窗口只读取 touch.GetJoystick() 绘制底盘和摇杆头,不接收点击。
"""
def __init__(self, base_x=160, base_y=None, radius=None, knob_radius=35):
ui.Window.__init__(self)
self.SetWindowName("MobileJoystick")
self.AddFlag("not_pick")
if radius is None:
radius = int(touch.GetLayout()[1][4])
self.radius = radius
self.knob_radius = knob_radius
self.SetSize(radius * 2, radius * 2)
# 外圈底盘与摇杆头:原生圆框(ui_mobile_widgets.Disc)
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)
def __del__(self):
ui.Window.__del__(self)
def __Place(self, base_x, base_y, knob_x, knob_y):
self.SetPosition(int(base_x) - self.radius, int(base_y) - self.radius)
self.knob.SetPosition(int(knob_x - base_x) + self.radius - self.knob_radius,
int(knob_y - base_y) + self.radius - self.knob_radius)
def OnUpdate(self):
active, base_x, base_y, knob_x, knob_y = touch.GetJoystick()
if active:
self.__Place(base_x, base_y, knob_x, knob_y)
else:
self.__Place(self.rest_x, self.rest_y, self.rest_x, self.rest_y)