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>
This commit is contained in:
shenlei
2026-10-12 21:14:29 +09:00
co-authored by Claude Opus 5.5
parent b79fbce0b0
commit 11bd94d1ce
17 changed files with 968 additions and 397 deletions
+2
View File
@@ -244,6 +244,8 @@ class GameWindow(ui.ScriptWindow):
self.notificationItem.SetEvent(self.__ClickCalendarioButton)
#self.notificationItem.SetPosition(100, 10)
self.notificationItem.Open()
if self.interface.wndMobileHUD:
self.interface.wndMobileHUD.AdoptGameWindows(self)
##
self.cantDestroyItemDialog = uiCantDestroyItem.CantDestroyItemDialog()
+4
View File
@@ -1823,6 +1823,7 @@ class Interface(object):
self.wndMiniMap.ShowMiniMap()
if self.wndEnergyBar:
self.wndEnergyBar.Show()
if hasattr(self, "wndMobileHUD") and self.wndMobileHUD: self.wndMobileHUD.AdoptDefaultWindows()
def ShowAllWindows(self):
self.wndTaskBar.Show()
@@ -1850,6 +1851,9 @@ class Interface(object):
self.wnd12ziTimer.Show()
if self.wnd12ziReward:
self.wnd12ziReward.Show()
if hasattr(self, "wndMobileHUD") and self.wndMobileHUD:
self.wndMobileHUD.Show()
self.wndMobileHUD.AdoptDefaultWindows()
def HideAllWindows(self):
if self.wndTaskBar:
+120 -83
View File
@@ -1,105 +1,142 @@
# -*- coding: utf-8 -*-
import ui
import grp
import math
import player
import net
import app
import wndMgr
import touch
import constInfo
import ui_mobile_widgets as widgets
class MobileCombatWheel(ui.Window):
"""
移动端核心战斗轮盘 (Combat Radial Controller)
- 位于屏幕右下角
- 超大普攻按钮 (长按/轻点):按下由原生触摸分流器判定(touch.SetAttackButton),
按住期间等同键盘攻击键 player.SetAttackKeyState,本按钮只做按下显示
- 环绕式扇形技能槽位 (带 CD 倒计时遮罩与等阶显示)
- 辅助功能按键 (自动锁定、上下马等)
"""
ATTACK_IDLE_COLOR = grp.GenerateColor(0.6, 0.15, 0.1, 0.45)
ATTACK_DOWN_COLOR = grp.GenerateColor(0.95, 0.35, 0.2, 0.75)
"""
移动端战斗轮盘(屏幕右下角)
- 大攻击键:按下由原生触摸分流器判定(touch.SetAttackButton),按住等同键盘攻击键;
本窗口只画圆框并显示按下状态
- 攻击键外两圈共 8 个快捷格 = 当前快捷页的 8 格(PC 任务栏 1-4 / F1-F4 同一份数据),
第 4 页留给底部药水栏,所以这里只在第 1-3 页间切换
- 小按钮:快捷页切换、上下马(原版 Ctrl+G 的 /ride)、拾取(原版 ` / Z 键)
"""
ATTACK_RADIUS = 60
SLOT_DIAMETER = 50
SMALL_DIAMETER = 40
# (半径, 角度):角度从 +x 逆时针,内外圈各 4 格,外圈错开半格;相邻格间距大于格子直径
SLOT_LAYOUT = [(108, 90), (108, 120), (108, 150), (108, 180),
(172, 97.5), (172, 122.5), (172, 147.5), (172, 172.5)]
RING_PAGE_COUNT = 3
WINDOW_EXTENT = 200
def __init__(self, origin_x=None, origin_y=None):
ui.Window.__init__(self)
self.SetWindowName("MobileCombatWheel")
# 轮盘本身不拦截触摸,否则会盖住攻击键热区和世界点击;技能槽按钮仍可点
self.AddFlag("not_pick")
def __init__(self, origin_x=None, origin_y=None):
ui.Window.__init__(self)
self.SetWindowName("MobileCombatWheel")
# 轮盘容器不拦截触摸,否则会盖住攻击键热区和世界点击;子按钮仍可点
self.AddFlag("not_pick")
sw = wndMgr.GetScreenWidth()
sh = wndMgr.GetScreenHeight()
# 安全区(刘海/圆角/手势条)内缩,桌面为 0
safe_l, safe_t, safe_r, safe_b = touch.GetSafeArea()
if origin_x is None:
origin_x = sw - safe_r - 120
if origin_y is None:
origin_y = sh - safe_b - 120
sw = wndMgr.GetScreenWidth()
sh = wndMgr.GetScreenHeight()
# 安全区(刘海/圆角/手势条)内缩,桌面为 0
safe_l, safe_t, safe_r, safe_b = touch.GetSafeArea()
if origin_x is None:
origin_x = sw - safe_r - 120
if origin_y is None:
origin_y = sh - safe_b - 120
self.origin_x = origin_x
self.origin_y = origin_y
self.origin_x = origin_x
self.origin_y = origin_y
# 窗口左上角 = 圆心 - WINDOW_EXTENT;右下留出攻击键与小按钮
ext = self.WINDOW_EXTENT
self.SetPosition(origin_x - ext, origin_y - ext)
self.SetSize(ext + 120, ext + 120)
cx = cy = ext
self.SetPosition(origin_x - 260, origin_y - 260)
self.SetSize(380, 380)
# 1. 攻击键
r = self.ATTACK_RADIUS
self.attack_disc = widgets.MakeDisc(self, cx - r, cy - r, r * 2, widgets.STYLE_ATTACK)
self.attack_icon = ui.ExpandedImageBox()
self.attack_icon.SetParent(self)
self.attack_icon.AddFlag("not_pick")
try:
self.attack_icon.LoadImage("d:/ymir work/ui/game/taskbar/mouse_button_attack_01.sub")
self.attack_icon.SetScale(2.0, 2.0)
self.attack_icon.SetPosition(cx - self.attack_icon.GetWidth() / 2, cy - self.attack_icon.GetHeight() / 2)
self.attack_icon.Show()
except:
pass
self.attack_pressed = False
touch.SetAttackButton(origin_x, origin_y, r)
# 1. 普通攻击主键 (超大圆形热区)
# 包内没有 taskbar/attack_button_0x.sub,先用半透明色块标出热区(与摇杆同风格)
self.attack_btn = ui.Bar()
self.attack_btn.SetParent(self)
self.attack_btn.AddFlag("not_pick")
self.attack_btn.SetPosition(260 - 60, 260 - 60)
self.attack_btn.SetSize(120, 120)
self.attack_btn.SetColor(self.ATTACK_IDLE_COLOR)
self.attack_btn.Show()
self.attack_pressed = False
touch.SetAttackButton(origin_x, origin_y, 60)
# 2. 快捷格
self.slots = []
half = self.SLOT_DIAMETER / 2
for i, (radius, angle) in enumerate(self.SLOT_LAYOUT):
rad = math.radians(angle)
x = int(cx + radius * math.cos(rad)) - half
y = int(cy - radius * math.sin(rad)) - half
slot = widgets.QuickSlotDisc(self.SLOT_DIAMETER, localIndex=i)
slot.SetParent(self)
slot.SetPosition(x, y)
slot.Show()
self.slots.append(slot)
# 2. 扇形技能槽位群
self.skills = []
angles = [180, 150, 120, 90] # 左上四个扇区
radius = 150
for i, ang in enumerate(angles):
rad = math.radians(ang)
sx = int(260 + radius * math.cos(rad) - 30)
sy = int(260 - radius * math.sin(rad) - 30)
# 3. 小按钮(攻击键左下 / 右上)
d = self.SMALL_DIAMETER
self.page_button = self.__MakeSmall(cx - 150 - d / 2, cy + 40 - d / 2, ui.__mem_func__(self.__OnNextPage))
self.page_button.SetLabel("1")
self.mount_button = self.__MakeSmall(cx + 62 - d / 2, cy - 92 - d / 2, ui.__mem_func__(self.__OnMount))
self.mount_button.SetLabel("Ride")
self.pickup_button = self.__MakeSmall(cx - 86 - d / 2, cy + 82 - d / 2, ui.__mem_func__(self.__OnPickUp))
self.pickup_button.SetLabel("Pick")
slot = ui.Button()
slot.SetParent(self)
slot.SetPosition(sx, sy)
slot.SetUpVisual("d:/ymir work/ui/game/taskbar/quickslot_01.sub")
slot.SetOverVisual("d:/ymir work/ui/game/taskbar/quickslot_02.sub")
slot.SetDownVisual("d:/ymir work/ui/game/taskbar/quickslot_03.sub")
slot.SetEvent(lambda s=i: self.__OnSkillCast(s))
slot.Show()
self.page = -1
self.lastRefresh = 0
self.Refresh()
# CD 遮罩
cd_text = ui.TextLine()
cd_text.SetParent(slot)
cd_text.SetPosition(15, 20)
cd_text.SetText("")
cd_text.Show()
def __del__(self):
ui.Window.__del__(self)
self.skills.append({'btn': slot, 'cd_text': cd_text, 'slot': i})
def __MakeSmall(self, x, y, event):
button = widgets.RoundButton(self.SMALL_DIAMETER)
button.SetParent(self)
button.SetPosition(x, y)
button.SetEvent(event)
button.Show()
return button
def __del__(self):
ui.Window.__del__(self)
def __OnNextPage(self):
# game.__SelectQuickPage 同一路径(player.SetQuickPage)
player.SetQuickPage((player.GetQuickPage() + 1) % self.RING_PAGE_COUNT)
self.Refresh()
def __OnSkillCast(self, index):
# 释放技能 (对应 Metin2 技能槽 1~4)
player.ClickSkillSlot(index + 1)
def __OnMount(self):
net.SendChatPacket("/ride")
def OnUpdate(self):
pressed = touch.IsAttackPressed()
if pressed != self.attack_pressed:
self.attack_pressed = pressed
if pressed:
self.attack_btn.SetColor(self.ATTACK_DOWN_COLOR)
else:
self.attack_btn.SetColor(self.ATTACK_IDLE_COLOR)
def __OnPickUp(self):
game = constInfo.GetGameInstance()
if game:
game.PickUpItem()
else:
player.PickCloseItem()
# 刷新技能冷却状态
for item in self.skills:
slot_idx = item['slot'] + 1
if player.IsSkillCoolTime(slot_idx):
remaining = player.GetSkillCoolTime(slot_idx)
item['cd_text'].SetText("%.1f" % remaining)
else:
item['cd_text'].SetText("")
def Refresh(self):
page = player.GetQuickPage()
if page >= self.RING_PAGE_COUNT:
# 第 4 页是药水栏,PC 端切到那里时轮盘回到第 1 页
player.SetQuickPage(0)
page = 0
if page != self.page:
self.page = page
self.page_button.label.SetText(str(page + 1))
for slot in self.slots:
slot.Refresh()
def OnUpdate(self):
pressed = touch.IsAttackPressed()
if pressed != self.attack_pressed:
self.attack_pressed = pressed
self.attack_disc.SetStyle(widgets.STYLE_ATTACK_DOWN if pressed else widgets.STYLE_ATTACK)
# 与 uitaskbar.TaskBar.OnUpdate 相同的 500 ms 刷新(冷却、数量、激活状态)
if app.GetGlobalTime() - self.lastRefresh > 500:
self.lastRefresh = app.GetGlobalTime()
self.Refresh()
+110 -89
View File
@@ -3,109 +3,130 @@ import ui
import grp
import wndMgr
import touch
import ui_mobile_widgets as widgets
class MobileDrawer(ui.Window):
"""
移动端系统抽屉菜单与顶部快捷导航
- 位于屏幕右上角
- 包含:通知、邮件、战力属性、背包、汉堡折叠按钮
- 点击汉堡按钮自右侧滑出二级扩展菜单 (设置/角色/公会/离线挂机等)
"""
def __init__(self, interface=None):
ui.Window.__init__(self)
self.SetWindowName("MobileDrawer")
self.interface = interface
"""
移动端右上角入口
- 一排圆形入口按钮(图标用 AVA2 任务栏自己的贴图):好友、角色、背包、菜单
- 菜单按钮展开二级面板:技能、任务、公会、系统设置
- 原版小地图由 MobileHUD.AdoptDefaultWindows 挪到这一排下面
"""
BUTTON_DIAMETER = 44
BUTTON_STEP = 52
TASKBAR = "d:/ymir work/ui/game/taskbar/"
sw = wndMgr.GetScreenWidth()
self.sw = sw
safe_l, safe_t, safe_r, safe_b = touch.GetSafeArea()
self.SetPosition(sw - safe_r - 380, safe_t + 15)
self.SetSize(360, 240)
self.AddFlag("attach")
def __init__(self, interface=None):
ui.Window.__init__(self)
self.SetWindowName("MobileDrawer")
self.AddFlag("not_pick")
self.interface = interface
self.is_menu_open = False
self.__BuildUI()
sw = wndMgr.GetScreenWidth()
safe_l, safe_t, safe_r, safe_b = touch.GetSafeArea()
self.width = 4 * self.BUTTON_STEP
self.SetPosition(sw - safe_r - self.width - 8, safe_t + 8)
self.SetSize(self.width, self.BUTTON_DIAMETER)
def __del__(self):
ui.Window.__del__(self)
self.is_menu_open = False
self.__BuildUI()
def __BuildUI(self):
# 1. 一级横向快捷按钮组 (直径 48px)
btn_data = [
("Inv", self.__OnClickInventory),
("Stat", self.__OnClickStatus),
("Mail", self.__OnClickMail),
("Menu", self.__OnToggleMenu)
]
def __del__(self):
ui.Window.__del__(self)
self.quick_buttons = []
for i, (label, callback) in enumerate(btn_data):
btn = ui.Button()
btn.SetParent(self)
btn.SetPosition(i * 65 + 100, 0)
btn.SetUpVisual("d:/ymir work/ui/public/middle_button_01.sub")
btn.SetOverVisual("d:/ymir work/ui/public/middle_button_02.sub")
btn.SetDownVisual("d:/ymir work/ui/public/middle_button_03.sub")
btn.SetText(label)
btn.SetEvent(ui.__mem_func__(callback))
btn.Show()
self.quick_buttons.append(btn)
def GetRowHeight(self):
return self.BUTTON_DIAMETER
# 2. 二级抽屉面板 (默认隐藏)
self.drawer_panel = ui.Bar()
self.drawer_panel.SetParent(self)
self.drawer_panel.SetPosition(120, 50)
self.drawer_panel.SetSize(240, 180)
self.drawer_panel.SetColor(grp.GenerateColor(0.08, 0.08, 0.12, 0.88))
self.drawer_panel.Hide()
def __BuildUI(self):
# 1. 入口按钮(自右向左:菜单、背包、角色、好友)
btn_data = [
("community_button_01.sub", "Friend", self.__OnClickMessenger),
("character_button_01.sub", "Char", self.__OnClickStatus),
("inventory_button_01.sub", "Bag", self.__OnClickInventory),
("system_button_01.sub", "Menu", self.__OnToggleMenu),
]
self.quick_buttons = []
for i, (icon, label, callback) in enumerate(btn_data):
btn = widgets.RoundButton(self.BUTTON_DIAMETER)
btn.SetParent(self)
btn.SetPosition(i * self.BUTTON_STEP + (self.BUTTON_STEP - self.BUTTON_DIAMETER), 0)
if not btn.SetIcon(self.TASKBAR + icon):
btn.SetLabel(label)
btn.SetEvent(ui.__mem_func__(callback))
btn.Show()
self.quick_buttons.append(btn)
menu_items = [
("Character", self.__OnClickStatus),
("Messenger", self.__OnClickMessenger),
("System Option", self.__OnClickSystem),
("Exit Game", self.__OnClickExit)
]
# 2. 二级面板(默认隐藏),挂在 HUD 根窗口下,展开在入口行左下方
self.drawer_panel = ui.Bar()
self.drawer_panel.SetColor(grp.GenerateColor(0.08, 0.07, 0.06, 0.88))
self.drawer_panel.SetSize(180, 15 + 5 * 40)
self.drawer_panel.Hide()
self.drawer_buttons = []
for i, (text, action) in enumerate(menu_items):
item_btn = ui.Button()
item_btn.SetParent(self.drawer_panel)
item_btn.SetPosition(20, 15 + i * 40)
item_btn.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
item_btn.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
item_btn.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
item_btn.SetText(text)
item_btn.SetEvent(ui.__mem_func__(action))
item_btn.Show()
self.drawer_buttons.append(item_btn)
menu_items = [
("Skill", self.__OnClickSkill),
("Quest", self.__OnClickQuest),
("Guild", self.__OnClickGuild),
("System", self.__OnClickSystem),
("Close", self.__OnToggleMenu),
]
self.drawer_buttons = []
for i, (text, action) in enumerate(menu_items):
item_btn = ui.Button()
item_btn.SetParent(self.drawer_panel)
item_btn.SetPosition(20, 15 + i * 40)
item_btn.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
item_btn.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
item_btn.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
item_btn.SetText(text)
item_btn.SetEvent(ui.__mem_func__(action))
item_btn.Show()
self.drawer_buttons.append(item_btn)
def __OnClickInventory(self):
if self.interface:
self.interface.ToggleInventoryWindow()
def AttachPanel(self, parent):
(x, y) = self.GetLocalPosition()
self.drawer_panel.SetParent(parent)
self.drawer_panel.SetPosition(x + self.width - 180 - self.BUTTON_STEP, y + self.BUTTON_DIAMETER + 6)
def __OnClickStatus(self):
if self.interface:
self.interface.ToggleCharacterWindowStatusPage()
def __CloseMenu(self):
self.is_menu_open = False
self.drawer_panel.Hide()
def __OnClickMail(self):
if self.interface and hasattr(self.interface, 'OpenMail'):
self.interface.OpenMail()
def __OnClickInventory(self):
if self.interface:
self.interface.ToggleInventoryWindow()
def __OnClickMessenger(self):
if self.interface:
self.interface.ToggleMessenger()
def __OnClickStatus(self):
if self.interface:
self.interface.ToggleCharacterWindowStatusPage()
def __OnClickSystem(self):
if self.interface:
self.interface.ToggleSystemDialog()
def __OnClickMessenger(self):
if self.interface:
self.interface.ToggleMessenger()
def __OnClickExit(self):
if self.interface:
self.interface.ToggleSystemDialog()
def __OnClickSkill(self):
self.__CloseMenu()
if self.interface:
self.interface.ToggleCharacterWindow("SKILL")
def __OnToggleMenu(self):
self.is_menu_open = not self.is_menu_open
if self.is_menu_open:
self.drawer_panel.Show()
else:
self.drawer_panel.Hide()
def __OnClickQuest(self):
self.__CloseMenu()
if self.interface:
self.interface.ToggleCharacterWindow("QUEST")
def __OnClickGuild(self):
self.__CloseMenu()
if self.interface:
self.interface.ToggleGuildWindow()
def __OnClickSystem(self):
self.__CloseMenu()
if self.interface:
self.interface.ToggleSystemDialog()
def __OnToggleMenu(self):
self.is_menu_open = not self.is_menu_open
if self.is_menu_open:
self.drawer_panel.Show()
self.drawer_panel.SetTop()
else:
self.drawer_panel.Hide()
+242 -185
View File
@@ -2,222 +2,279 @@
import ui
import grp
import player
import chr
import chrmgr
import net
import app
import wndMgr
import math
import ui_mobile_joystick
import ui_mobile_combat
import ui_mobile_drawer
import ui_mobile_widgets as widgets
import touch
import uiCharacter
def unsigned32(n):
return n & 0xFFFFFFFFL
class MobileHUD(ui.Window):
"""
ava2-client 移动端全屏战斗 HUD (完整集成版)
自适应 2376 x 1080 横屏规范
包含:
1. 左上角主角状态 HUD (圆形头像 + HP/MP/体力条)
2. 顶部悬浮目标血条 HUD (Monster Name, Level, HP Gauge)
3. 右上角导航快捷入口与小地图挂载抽屉 (MobileDrawer)
4. 底部药水/消耗品快捷轮盘 (Quick Belt)
5. 右下角核心战斗轮盘 (MobileCombatWheel: 大普攻 + 扇形技能槽)
6. 左下角虚拟摇杆触控层 (MobileJoystick)
"""
def __init__(self, interface=None):
ui.Window.__init__(self)
self.SetWindowName("MobileHUD")
self.interface = interface
"""
移动端战斗 HUD(docs/MOBILE-ARCHITECTURE.md 第 4 步),按安全区内缩:
1. 左上:头像圆框 + 名字等级 + HP/SP/体力条;原版 buff 图标(AffectShower)挪到其下方
2. 顶部居中:沿用原版目标栏 uiTarget.TargetBoard(本来就在顶部居中)
3. 右上:圆形入口按钮行 + 菜单面板(MobileDrawer);原版小地图挪到其下方
4. 左侧:竖排功能按钮(任务、技能、表情、聊天)
5. 右下:攻击键 + 当前快捷页 8 格(MobileCombatWheel)
6. 底部居中:药水栏 = 第 4 快捷页 8 格;最底一条经验条
7. 左下:浮动摇杆显示层(MobileJoystick)
移动模式下隐藏 PC 任务栏(AdoptDefaultWindows)。快捷栏数据与 PC 端完全相同。
"""
BELT_PAGE = 3
BELT_DIAMETER = 46
BELT_STEP = 50
SIDE_DIAMETER = 48
SIDE_STEP = 58
FACE_DIAMETER = 64
HP_WIDTH = 190
SP_WIDTH = 170
ST_WIDTH = 150
sw = wndMgr.GetScreenWidth()
sh = wndMgr.GetScreenHeight()
self.SetPosition(0, 0)
self.SetSize(sw, sh)
self.AddFlag("attach")
self.AddFlag("not_pick")
def __init__(self, interface=None):
ui.Window.__init__(self)
self.SetWindowName("MobileHUD")
self.interface = interface
self.safe_area = touch.GetSafeArea()
self.__BuildUI(sw, sh)
sw = wndMgr.GetScreenWidth()
sh = wndMgr.GetScreenHeight()
self.SetPosition(0, 0)
self.SetSize(sw, sh)
self.AddFlag("attach")
self.AddFlag("not_pick")
def __del__(self):
ui.Window.__del__(self)
self.safe_area = touch.GetSafeArea()
self.race = -1
self.lastBeltRefresh = 0
self.__BuildUI(sw, sh)
def __BuildUI(self, w, h):
# ---------------------------------------------------------------------
# 1. 左上角:主角状态 (Player HUD)
# ---------------------------------------------------------------------
self.player_hud = ui.Window()
self.player_hud.SetParent(self)
safe_l, safe_t, safe_r, safe_b = self.safe_area
self.player_hud.SetPosition(safe_l + 25, safe_t + 20)
self.player_hud.SetSize(320, 100)
self.player_hud.Show()
def __del__(self):
ui.Window.__del__(self)
# 头像框背景底板
self.avatar_bg = ui.Bar()
self.avatar_bg.SetParent(self.player_hud)
self.avatar_bg.SetPosition(0, 0)
self.avatar_bg.SetSize(72, 72)
self.avatar_bg.SetColor(grp.GenerateColor(0.15, 0.15, 0.22, 0.85))
self.avatar_bg.Show()
def __Container(self, x, y, w, h):
wnd = ui.Window()
wnd.SetParent(self)
wnd.AddFlag("not_pick")
wnd.SetPosition(x, y)
wnd.SetSize(w, h)
wnd.Show()
return wnd
# 角色名称
self.text_name = ui.TextLine()
self.text_name.SetParent(self.player_hud)
self.text_name.SetPosition(80, 2)
self.text_name.SetText("Player")
self.text_name.Show()
def __Gauge(self, parent, x, y, w, h, back, front):
bg = ui.Bar()
bg.SetParent(parent)
bg.AddFlag("not_pick")
bg.SetPosition(x, y)
bg.SetSize(w, h)
bg.SetColor(back)
bg.Show()
bar = ui.Bar()
bar.SetParent(parent)
bar.AddFlag("not_pick")
bar.SetPosition(x, y)
bar.SetSize(w, h)
bar.SetColor(front)
bar.Show()
frame = ui.Box()
frame.SetParent(parent)
frame.AddFlag("not_pick")
frame.SetPosition(x - 1, y - 1)
frame.SetSize(w + 2, h + 2)
frame.SetColor(grp.GenerateColor(0.55, 0.42, 0.25, 0.9))
frame.Show()
return bar
# HP 条背景与前景
self.hp_bar_bg = ui.Bar()
self.hp_bar_bg.SetParent(self.player_hud)
self.hp_bar_bg.SetPosition(80, 22)
self.hp_bar_bg.SetSize(210, 14)
self.hp_bar_bg.SetColor(grp.GenerateColor(0.2, 0.05, 0.05, 0.75))
self.hp_bar_bg.Show()
def __BuildUI(self, w, h):
safe_l, safe_t, safe_r, safe_b = self.safe_area
self.hp_bar = ui.Bar()
self.hp_bar.SetParent(self.player_hud)
self.hp_bar.SetPosition(80, 22)
self.hp_bar.SetSize(210, 14)
self.hp_bar.SetColor(grp.GenerateColor(0.85, 0.12, 0.12, 0.95))
self.hp_bar.Show()
# 1. 左上:主角状态
self.player_hud = self.__Container(safe_l + 12, safe_t + 8, 300, self.FACE_DIAMETER + 4)
self.face_disc = widgets.MakeDisc(self.player_hud, 0, 0, self.FACE_DIAMETER, widgets.STYLE_FRAME)
self.face_image = ui.ExpandedImageBox()
self.face_image.SetParent(self.player_hud)
self.face_image.AddFlag("not_pick")
# MP 条背景与前景
self.mp_bar_bg = ui.Bar()
self.mp_bar_bg.SetParent(self.player_hud)
self.mp_bar_bg.SetPosition(80, 40)
self.mp_bar_bg.SetSize(180, 10)
self.mp_bar_bg.SetColor(grp.GenerateColor(0.05, 0.1, 0.25, 0.75))
self.mp_bar_bg.Show()
self.text_name = ui.TextLine()
self.text_name.SetParent(self.player_hud)
self.text_name.AddFlag("not_pick")
self.text_name.SetPosition(self.FACE_DIAMETER + 8, 2)
self.text_name.SetOutline()
self.text_name.SetText("")
self.text_name.Show()
self.mp_bar = ui.Bar()
self.mp_bar.SetParent(self.player_hud)
self.mp_bar.SetPosition(80, 40)
self.mp_bar.SetSize(180, 10)
self.mp_bar.SetColor(grp.GenerateColor(0.15, 0.45, 0.95, 0.95))
self.mp_bar.Show()
gx = self.FACE_DIAMETER + 8
self.hp_bar = self.__Gauge(self.player_hud, gx, 22, self.HP_WIDTH, 12,
grp.GenerateColor(0.20, 0.05, 0.05, 0.75), grp.GenerateColor(0.85, 0.12, 0.12, 0.95))
self.mp_bar = self.__Gauge(self.player_hud, gx, 38, self.SP_WIDTH, 9,
grp.GenerateColor(0.05, 0.10, 0.25, 0.75), grp.GenerateColor(0.15, 0.45, 0.95, 0.95))
self.sp_bar = self.__Gauge(self.player_hud, gx, 51, self.ST_WIDTH, 5,
grp.GenerateColor(0.20, 0.18, 0.05, 0.75), grp.GenerateColor(0.90, 0.80, 0.10, 0.85))
# 体力/耐力条
self.sp_bar = ui.Bar()
self.sp_bar.SetParent(self.player_hud)
self.sp_bar.SetPosition(80, 54)
self.sp_bar.SetSize(150, 6)
self.sp_bar.SetColor(grp.GenerateColor(0.9, 0.8, 0.1, 0.85))
self.sp_bar.Show()
# 2. 右上:入口按钮行 + 菜单面板
self.drawer = ui_mobile_drawer.MobileDrawer(self.interface)
self.drawer.SetParent(self)
self.drawer.Show()
self.drawer.AttachPanel(self)
# ---------------------------------------------------------------------
# 2. 顶部居中:目标血条 (Target HUD)
# ---------------------------------------------------------------------
self.target_hud = ui.Window()
self.target_hud.SetParent(self)
self.target_hud.SetPosition((w - 420) / 2, safe_t + 20)
self.target_hud.SetSize(420, 50)
# 3. 左侧竖排按钮
side = [
("Quest", None, lambda: self.__ToggleCharacter("QUEST")),
("Skill", "d:/ymir work/ui/game/taskbar/mouse_button_skill_01.sub", lambda: self.__ToggleCharacter("SKILL")),
("Emote", None, lambda: self.__ToggleCharacter("EMOTICON")),
("Chat", "d:/ymir work/ui/game/taskbar/chat_button_01.sub", self.__ToggleChat),
]
self.side_buttons = []
top = safe_t + 8 + self.FACE_DIAMETER + 48
for i, (label, icon, event) in enumerate(side):
btn = widgets.RoundButton(self.SIDE_DIAMETER)
btn.SetParent(self)
btn.SetPosition(safe_l + 12, top + i * self.SIDE_STEP)
if not icon or not btn.SetIcon(icon):
btn.SetLabel(label)
btn.SetEvent(event)
btn.Show()
self.side_buttons.append(btn)
self.target_bg = ui.Bar()
self.target_bg.SetParent(self.target_hud)
self.target_bg.SetPosition(0, 18)
self.target_bg.SetSize(420, 16)
self.target_bg.SetColor(grp.GenerateColor(0.2, 0.05, 0.05, 0.75))
self.target_bg.Show()
# 4. 左下:摇杆显示层
self.joystick = ui_mobile_joystick.MobileJoystick(base_x=safe_l + 160, base_y=h - safe_b - 180)
self.joystick.SetParent(self)
self.joystick.Show()
self.target_bar = ui.Bar()
self.target_bar.SetParent(self.target_hud)
self.target_bar.SetPosition(0, 18)
self.target_bar.SetSize(420, 16)
self.target_bar.SetColor(grp.GenerateColor(0.9, 0.1, 0.1, 0.95))
self.target_bar.Show()
# 5. 右下:战斗轮盘
self.combat_wheel = ui_mobile_combat.MobileCombatWheel(origin_x=w - safe_r - 120, origin_y=h - safe_b - 120)
self.combat_wheel.SetParent(self)
self.combat_wheel.Show()
self.target_name = ui.TextLine()
self.target_name.SetParent(self.target_hud)
self.target_name.SetPosition(10, 0)
self.target_name.SetText("Target")
self.target_name.Show()
# 6. 底部:药水栏(第 4 快捷页)与经验条
count = 8
beltWidth = (count - 1) * self.BELT_STEP + self.BELT_DIAMETER
self.quick_belt = self.__Container((w - beltWidth) / 2, h - safe_b - self.BELT_DIAMETER - 10, beltWidth, self.BELT_DIAMETER)
self.quick_slots = []
for i in xrange(count):
slot = widgets.QuickSlotDisc(self.BELT_DIAMETER, globalIndex=self.BELT_PAGE * 8 + i)
slot.SetParent(self.quick_belt)
slot.SetPosition(i * self.BELT_STEP, 0)
slot.Show()
self.quick_slots.append(slot)
self.target_pct = ui.TextLine()
self.target_pct.SetParent(self.target_hud)
self.target_pct.SetPosition(370, 0)
self.target_pct.SetText("100%")
self.target_pct.Show()
self.target_hud.Hide()
self.exp_width = w - safe_l - safe_r
self.exp_bar = self.__Gauge(self, safe_l, h - safe_b - 4, self.exp_width, 3,
grp.GenerateColor(0.05, 0.05, 0.05, 0.6), grp.GenerateColor(0.85, 0.70, 0.25, 0.9))
# ---------------------------------------------------------------------
# 3. 右上角:系统抽屉菜单与导航 (Mobile Drawer)
# ---------------------------------------------------------------------
self.drawer = ui_mobile_drawer.MobileDrawer(self.interface)
self.drawer.SetParent(self)
self.drawer.Show()
def __ToggleCharacter(self, state):
if self.interface:
self.interface.ToggleCharacterWindow(state)
# ---------------------------------------------------------------------
# 4. 左下角:虚拟摇杆 (Mobile Joystick)
# ---------------------------------------------------------------------
self.joystick = ui_mobile_joystick.MobileJoystick(base_x=160, base_y=h - 180)
self.joystick.SetParent(self)
self.joystick.Show()
def __ToggleChat(self):
if self.interface:
self.interface.ToggleChat()
# ---------------------------------------------------------------------
# 5. 右下角:核心战斗轮盘 (Mobile Combat Wheel)
# ---------------------------------------------------------------------
self.combat_wheel = ui_mobile_combat.MobileCombatWheel(origin_x=w - safe_r - 120, origin_y=h - safe_b - 120)
self.combat_wheel.SetParent(self)
self.combat_wheel.Show()
# 由 interfaceModule.ShowDefaultWindows / ShowAllWindows 调用:PC 任务栏隐藏,
# 小地图挪到右上入口行下面,聊天窗抬到药水栏上方。
def AdoptDefaultWindows(self):
interface = self.interface
if not interface:
return
safe_l, safe_t, safe_r, safe_b = self.safe_area
sw = wndMgr.GetScreenWidth()
sh = wndMgr.GetScreenHeight()
for name in ("wndTaskBar", "wndExpandedTaskBar", "wndEnergyBar", "wndExpandedMoneyTaskBar"):
wnd = getattr(interface, name, None)
if wnd:
wnd.Hide()
minimap = getattr(interface, "wndMiniMap", None)
if minimap:
minimap.SetPosition(sw - safe_r - minimap.GetWidth(), safe_t + 8 + self.drawer.GetRowHeight() + 4)
# 任务栏的 HP/SP/经验悬浮提示是独立 TOP_MOST 窗口,平时由任务栏 OnUpdate 隐藏;
# 任务栏不显示时它们会一直挂在最后的鼠标位置
taskbar = getattr(interface, "wndTaskBar", None)
for name in ("tooltipHP", "tooltipSP", "tooltipST", "tooltipEXP", "tooltipGift"):
tip = getattr(taskbar, name, None)
if tip:
tip.Hide()
self.__AdoptGameButtons(getattr(interface, "wndGameButton", None))
chat = getattr(interface, "wndChat", None)
if chat:
chat.SetPosition(sw / 2 - chat.CHAT_WINDOW_WIDTH / 2, sh - safe_b - chat.EDIT_LINE_HEIGHT - self.BELT_DIAMETER - 24)
# ---------------------------------------------------------------------
# 6. 底部居中:药水快捷滑盘 (Quick Belt)
# ---------------------------------------------------------------------
self.quick_belt = ui.Window()
self.quick_belt.SetParent(self)
self.quick_belt.SetPosition((w - 360) / 2, h - safe_b - 70)
self.quick_belt.SetSize(360, 60)
self.quick_belt.Show()
# 由 game.GameWindow 调用(活动图标创建之后):原版 buff 图标放在头像状态栏下面,
# 活动日历图标放在小地图左边
# 原版提示按钮(帮助、加点、任务、礼物、活动入口……)原来贴在 PC 任务栏上方两角,
# 移动端排成左侧按钮列右边的第二列;原来共用一个位置的按钮这里也共用一行
GAME_BUTTON_ROWS = (("HELP",), ("STATUS",), ("SKILL", "QUEST", "BUILD", "EXIT_OBSERVER"), ("GIFT",),
("COMBAT_ZONE", "BOSS_EVENT"), ("METIN_EVENT",))
self.quick_slots = []
for i in range(5):
slot = ui.Bar()
slot.SetParent(self.quick_belt)
slot.SetPosition(i * 70, 0)
slot.SetSize(60, 60)
slot.SetColor(grp.GenerateColor(0.1, 0.1, 0.15, 0.6))
slot.Show()
self.quick_slots.append(slot)
def __AdoptGameButtons(self, wndGameButton):
buttons = getattr(wndGameButton, "gameButtonDict", None)
if not buttons:
return
safe_l, safe_t, safe_r, safe_b = self.safe_area
x = safe_l + 12 + self.SIDE_DIAMETER + 14
top = safe_t + 8 + self.FACE_DIAMETER + 48
for row, names in enumerate(self.GAME_BUTTON_ROWS):
for name in names:
btn = buttons.get(name)
if btn:
btn.SetPosition(x, top + row * self.SIDE_STEP)
def OnUpdate(self):
# 1. 刷新主角状态
cur_hp = player.GetStatus(player.HP)
max_hp = player.GetStatus(player.MAX_HP)
if max_hp > 0:
pct = min(1.0, max(0.0, float(cur_hp) / float(max_hp)))
self.hp_bar.SetSize(int(210 * pct), 14)
def AdoptGameWindows(self, game):
safe_l, safe_t, safe_r, safe_b = self.safe_area
game.affectShower.SetPosition(safe_l + 12 + self.FACE_DIAMETER + 8, safe_t + 8 + 62)
notification = getattr(game, "notificationItem", None)
if notification:
sw = wndMgr.GetScreenWidth()
minimap = getattr(self.interface, "wndMiniMap", None) if self.interface else None
right = sw - safe_r - (minimap.GetWidth() if minimap else 0)
notification.SetPosition(right - notification.GetWidth() - 4, safe_t + 8 + self.drawer.GetRowHeight() + 4)
cur_mp = player.GetStatus(player.SP)
max_mp = player.GetStatus(player.MAX_SP)
if max_mp > 0:
pct = min(1.0, max(0.0, float(cur_mp) / float(max_mp)))
self.mp_bar.SetSize(int(180 * pct), 10)
def __RefreshFace(self):
race = net.GetMainActorRace()
if race == self.race:
return
self.race = race
# 头像与角色窗口同一张表
name = uiCharacter.FACE_IMAGE_DICT.get(race)
if not name:
self.face_image.Hide()
return
try:
self.face_image.LoadImage(name)
except:
self.face_image.Hide()
return
size = max(self.face_image.GetWidth(), self.face_image.GetHeight(), 1)
inner = self.FACE_DIAMETER - 16
scale = float(inner) / float(size)
self.face_image.SetScale(scale, scale)
off = (self.FACE_DIAMETER - int(size * scale)) / 2
self.face_image.SetPosition(off, off)
self.face_image.Show()
cur_sp = player.GetStatus(player.STAMINA)
max_sp = player.GetStatus(player.MAX_STAMINA)
if max_sp > 0:
pct = min(1.0, max(0.0, float(cur_sp) / float(max_sp)))
self.sp_bar.SetSize(int(150 * pct), 6)
def __SetGauge(self, bar, width, height, cur, maximum):
if maximum > 0:
pct = min(1.0, max(0.0, float(cur) / float(maximum)))
bar.SetSize(int(width * pct), height)
# 2. 刷新目标状态
target_vid = player.GetTargetVID()
if target_vid != 0 and chr.GetInstanceType(target_vid) != chr.INSTANCE_TYPE_PLAYER:
self.target_hud.Show()
name = chr.GetNameByVID(target_vid)
self.target_name.SetText(name if name else "Target")
target_hp = chr.GetHP(target_vid) if hasattr(chr, 'GetHP') else 100
target_max_hp = chr.GetMaxHP(target_vid) if hasattr(chr, 'GetMaxHP') else 100
if target_max_hp > 0:
pct = min(1.0, max(0.0, float(target_hp) / float(target_max_hp)))
self.target_bar.SetSize(int(420 * pct), 16)
self.target_pct.SetText("%d%%" % int(pct * 100))
else:
self.target_hud.Hide()
def OnUpdate(self):
# 1. 主角状态
self.__SetGauge(self.hp_bar, self.HP_WIDTH, 12, player.GetStatus(player.HP), player.GetStatus(player.MAX_HP))
self.__SetGauge(self.mp_bar, self.SP_WIDTH, 9, player.GetStatus(player.SP), player.GetStatus(player.MAX_SP))
self.__SetGauge(self.sp_bar, self.ST_WIDTH, 5, player.GetStatus(player.STAMINA), player.GetStatus(player.MAX_STAMINA))
self.__SetGauge(self.exp_bar, self.exp_width, 3,
unsigned32(player.GetStatus(player.EXP)), unsigned32(player.GetStatus(player.NEXT_EXP)))
self.text_name.SetText("Lv.%d %s" % (player.GetStatus(player.LEVEL), player.GetName()))
self.__RefreshFace()
# 3. 子组件状态刷新
if hasattr(self, 'joystick') and self.joystick:
self.joystick.OnUpdate()
if hasattr(self, 'combat_wheel') and self.combat_wheel:
self.combat_wheel.OnUpdate()
# 2. 子组件
self.joystick.OnUpdate()
self.combat_wheel.OnUpdate()
if app.GetGlobalTime() - self.lastBeltRefresh > 500:
self.lastBeltRefresh = app.GetGlobalTime()
for slot in self.quick_slots:
slot.Refresh()
+4 -17
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import ui
import grp
import touch
import ui_mobile_widgets as widgets
class MobileJoystick(ui.Window):
"""
@@ -21,22 +21,9 @@ class MobileJoystick(ui.Window):
self.knob_radius = knob_radius
self.SetSize(radius * 2, radius * 2)
# 外圈底盘
self.base_bar = ui.Bar()
self.base_bar.SetParent(self)
self.base_bar.AddFlag("not_pick")
self.base_bar.SetPosition(0, 0)
self.base_bar.SetSize(radius * 2, radius * 2)
self.base_bar.SetColor(grp.GenerateColor(0.1, 0.1, 0.15, 0.4))
self.base_bar.Show()
# 摇杆头
self.knob = ui.Bar()
self.knob.SetParent(self)
self.knob.AddFlag("not_pick")
self.knob.SetSize(knob_radius * 2, knob_radius * 2)
self.knob.SetColor(grp.GenerateColor(0.8, 0.8, 0.9, 0.6))
self.knob.Show()
# 外圈底盘与摇杆头:原生圆框(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:
+230
View File
@@ -0,0 +1,230 @@
# -*- coding: utf-8 -*-
# 移动端 HUD 的通用控件(docs/MOBILE-ARCHITECTURE.md 第 4 步)。
# 圆形边框由原生 wndMgr.RegisterDisc 用几何绘制(渐变底 + 上亮下暗的立体边),不依赖贴图;
# 图标只用 AVA2 自己的 UI/技能/物品贴图。
import ui
import grp
import wndMgr
import player
import skill
import item
import constInfo
import mouseModule
def Color(r, g, b, a=1.0):
return grp.GenerateColor(r, g, b, a)
# 配色:暗底 + 古铜边,按下变亮;攻击键暗红
STYLE_FRAME = (Color(0.16, 0.14, 0.13, 0.80), Color(0.05, 0.04, 0.04, 0.85), Color(0.85, 0.68, 0.40), Color(0.32, 0.22, 0.12), 3.0)
STYLE_FRAME_DOWN = (Color(0.40, 0.32, 0.22, 0.90), Color(0.12, 0.09, 0.06, 0.90), Color(1.0, 0.85, 0.50), Color(0.45, 0.32, 0.16), 3.0)
STYLE_ATTACK = (Color(0.55, 0.12, 0.08, 0.85), Color(0.18, 0.03, 0.02, 0.90), Color(0.92, 0.74, 0.42), Color(0.36, 0.22, 0.10), 5.0)
STYLE_ATTACK_DOWN = (Color(0.90, 0.30, 0.15, 0.95), Color(0.40, 0.08, 0.04, 0.95), Color(1.0, 0.90, 0.55), Color(0.50, 0.32, 0.14), 5.0)
STYLE_JOY_BASE = (Color(0.10, 0.10, 0.12, 0.25), Color(0.05, 0.05, 0.06, 0.45), Color(0.80, 0.66, 0.42, 0.55), Color(0.30, 0.22, 0.12, 0.55), 3.0)
STYLE_JOY_KNOB = (Color(0.75, 0.66, 0.50, 0.70), Color(0.35, 0.28, 0.18, 0.75), Color(1.0, 0.88, 0.60, 0.85), Color(0.40, 0.30, 0.16, 0.85), 2.0)
COOLDOWN_COLOR = Color(0.0, 0.0, 0.0, 0.55)
class Disc(ui.Window):
"""圆形边框(原生 CDisc)。不接收点击。"""
def __init__(self, layer="UI"):
ui.Window.__init__(self, layer)
self.AddFlag("not_pick")
def __del__(self):
ui.Window.__del__(self)
def RegisterWindow(self, layer):
self.hWnd = wndMgr.RegisterDisc(self, layer)
def SetStyle(self, style):
inner, outer, rimTop, rimBottom, rimWidth = style
wndMgr.SetDiscColors(self.hWnd, inner, outer, rimTop, rimBottom, float(rimWidth))
def SetArc(self, fraction, color=COOLDOWN_COLOR):
wndMgr.SetDiscArc(self.hWnd, float(fraction), color)
def MakeDisc(parent, x, y, diameter, style):
disc = Disc()
disc.SetParent(parent)
disc.SetPosition(x, y)
disc.SetSize(diameter, diameter)
disc.SetStyle(style)
disc.Show()
return disc
class RoundButton(ui.Window):
"""圆形按钮:圆框 + 居中图标(AVA2 贴图)或短文字。按下变亮,松开时在按钮内才触发。"""
def __init__(self, diameter, style=STYLE_FRAME, downStyle=STYLE_FRAME_DOWN):
ui.Window.__init__(self)
self.SetSize(diameter, diameter)
self.diameter = diameter
self.style = style
self.downStyle = downStyle
self.event = None
self.disc = MakeDisc(self, 0, 0, diameter, style)
self.icon = None
self.label = None
def __del__(self):
ui.Window.__del__(self)
def SetIcon(self, fileName, scale=1.0):
icon = ui.ExpandedImageBox()
icon.SetParent(self)
icon.AddFlag("not_pick")
try:
icon.LoadImage(fileName)
except:
return False
if scale != 1.0:
icon.SetScale(scale, scale)
# ExpandedImageBox.SetScale 已把窗口尺寸换成缩放后的大小
w = icon.GetWidth()
h = icon.GetHeight()
icon.SetPosition((self.diameter - w) / 2, (self.diameter - h) / 2)
icon.Show()
self.icon = icon
return True
def SetLabel(self, text):
label = ui.TextLine()
label.SetParent(self)
label.AddFlag("not_pick")
label.SetPosition(self.diameter / 2, self.diameter / 2 - 6)
label.SetHorizontalAlignCenter()
label.SetOutline()
label.SetText(text)
label.Show()
self.label = label
def SetEvent(self, event):
self.event = event
def OnMouseLeftButtonDown(self):
self.disc.SetStyle(self.downStyle)
return True
def OnMouseLeftButtonUp(self):
self.disc.SetStyle(self.style)
if self.IsIn() and self.event:
self.event()
return True
class QuickSlotDisc(ui.Window):
"""一个快捷栏格子:圆框 + 原版 SlotWindow 绘制技能/物品/表情图标、数量和冷却。
slotIndex 为 None 时显示当前快捷页的 localIndex(与 PC 任务栏 1-4/F1-F4 同一份数据);
否则为固定的全局格子(药水栏)。轻点直接使用;手上拖着图标时轻点则放入该格。"""
SLOT_SIZE = 32
def __init__(self, diameter, localIndex=None, globalIndex=None):
ui.Window.__init__(self)
self.AddFlag("not_pick")
self.SetSize(diameter, diameter)
self.localIndex = localIndex
self.globalIndex = globalIndex
self.disc = MakeDisc(self, 0, 0, diameter, STYLE_FRAME)
off = (diameter - self.SLOT_SIZE) / 2
slot = ui.SlotWindow()
slot.SetParent(self)
slot.SetPosition(0, 0)
slot.SetSize(diameter, diameter)
slot.AppendSlot(0, off, off, self.SLOT_SIZE, self.SLOT_SIZE)
slot.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
slot.SetSelectEmptySlotEvent(ui.__mem_func__(self.__OnSelectEmpty))
slot.SetSelectItemSlotEvent(ui.__mem_func__(self.__OnSelectItem))
slot.Show()
self.slot = slot
def __del__(self):
ui.Window.__del__(self)
def GetQuickSlot(self):
if self.globalIndex is not None:
return player.GetGlobalQuickSlot(self.globalIndex)
return player.GetLocalQuickSlot(self.localIndex)
def __Use(self):
if self.globalIndex is not None:
player.RequestUseGlobalQuickSlot(self.globalIndex)
else:
player.RequestUseLocalQuickSlot(self.localIndex)
# uitaskbar.TaskBar.AddQuickSlot,目标换成本格
def __Add(self):
attachedType = mouseModule.mouseController.GetAttachedType()
attachedSlot = mouseModule.mouseController.GetAttachedSlotNumber()
attachedItem = mouseModule.mouseController.GetAttachedItemIndex()
if player.SLOT_TYPE_QUICK_SLOT == attachedType:
if self.globalIndex is not None:
player.RequestMoveGlobalQuickSlotToGlobalQuickSlot(attachedSlot, self.globalIndex)
else:
player.RequestMoveGlobalQuickSlotToLocalQuickSlot(attachedSlot, self.localIndex)
else:
pos = attachedItem if player.SLOT_TYPE_EMOTION == attachedType else attachedSlot
if player.SLOT_TYPE_INVENTORY == attachedType and not item.CanAddToQuickSlotItem(player.GetItemIndex(attachedSlot)):
pos = None
if pos is not None:
if self.globalIndex is not None:
player.RequestAddGlobalQuickSlot(self.globalIndex, attachedType, pos)
else:
player.RequestAddLocalQuickSlot(self.localIndex, attachedType, pos)
mouseModule.mouseController.DeattachObject()
self.Refresh()
def __OnSelectEmpty(self, slotIndex):
if mouseModule.mouseController.isAttached():
self.__Add()
def __OnSelectItem(self, slotIndex):
if mouseModule.mouseController.isAttached():
self.__Add()
else:
self.__Use()
# uitaskbar.TaskBar.RefreshQuickSlot 的单格版本
def Refresh(self):
slot = self.slot
(Type, Position) = self.GetQuickSlot()
if player.SLOT_TYPE_NONE == Type:
slot.ClearSlot(0)
elif player.SLOT_TYPE_INVENTORY == Type:
itemIndex = player.GetItemIndex(Position)
itemCount = player.GetItemCount(Position)
if itemCount <= 1:
itemCount = 0
if constInfo.IS_AUTO_POTION(itemIndex):
if 0 != int(player.GetItemMetinSocket(Position, 0)):
slot.ActivateSlot(0)
else:
slot.DeactivateSlot(0)
slot.SetItemSlot(0, itemIndex, itemCount)
elif player.SLOT_TYPE_SKILL == Type:
skillIndex = player.GetSkillIndex(Position)
if 0 == skillIndex:
slot.ClearSlot(0)
else:
if skill.SKILL_TYPE_GUILD == skill.GetSkillType(skillIndex):
import guild
skillGrade = 0
skillLevel = guild.GetSkillLevel(Position)
else:
skillGrade = player.GetSkillGrade(Position)
skillLevel = player.GetSkillLevel(Position)
slot.SetSkillSlotNew(0, skillIndex, skillGrade, skillLevel)
slot.SetSlotCountNew(0, skillGrade, skillLevel)
if player.IsSkillCoolTime(Position):
(coolTime, elapsedTime) = player.GetSkillCoolTime(Position)
slot.SetSlotCoolTime(0, coolTime, elapsedTime)
if player.IsSkillActive(Position):
slot.ActivateSlot(0)
else:
slot.DeactivateSlot(0)
elif player.SLOT_TYPE_EMOTION == Type:
slot.SetEmotionSlot(0, Position)
slot.SetSlotCount(0, 0)
slot.RefreshSlot()