feat: add AVA2 minimap buttons and expanded taskbar entries

This commit is contained in:
shen
2026-10-17 16:40:54 -07:00
parent 3efa607908
commit e446ae8449
18 changed files with 504 additions and 22 deletions
+1 -1
View File
@@ -400,7 +400,7 @@ _command=game.GameWindow.BINARY_ServerCommand_Run
def Open(self):
global g_window,g_entry
_open(self);g_pass.waiting=None;g_pass.unsupported=False;g_pass.Clear()
g_window=BattlePassWindow(g_pass);g_entry=Entry(self)
g_window=BattlePassWindow(g_pass);g_entry=None
keys=getattr(self,'onPressKeyDict',None)
if keys is not None and app.DIK_F6 not in keys:keys[app.DIK_F6]=lambda:Toggle()
+1 -2
View File
@@ -443,8 +443,7 @@ def Open(self):
global g_window,g_entry
_open(self)
g_window=BiologWindow()
g_entry=Entry(self)
g_entry.nextTick=0
g_entry=None
def Close(self):
global g_window,g_entry
+14 -8
View File
@@ -1,5 +1,5 @@
// PORT: AVA2 uitrack world-boss tab, read-only. The server's boss regens (own channel plus the shared core) come
// from the MTF1 'bosses' query; the original regen timers stay authoritative. AVA2's teleport button is left out.
// PORT: AVA2 uitrack world-boss tab. The server's boss regens (own channel plus the shared core) come
// from the MTF1 'bosses' query; the original regen timers stay authoritative. Direct travel is wired to PortTrackTravel.
// See docs/AVA2-BOSS.md.
static const char c_szBossScript[] = R"PY(# -*- coding: utf-8 -*-
import app
@@ -124,10 +124,11 @@ class BossWindow(ui.Window):
self.tracker=tracker;self.pending=False;self.generation=0;self.nextQuery=0;self.page=0;self.dimensions=None
self.heading=Text(self,18,18,'世界Boss',0xffffd68b)
self.closeButton=Action(self,0,6,60,'关闭',self.Hide)
self.refreshButton=Action(self,18,48,80,'刷新',self.Query)
self.prevButton=Action(self,110,48,72,'上一页',lambda:self.Turn(-1))
self.nextButton=Action(self,194,48,72,'下一页',lambda:self.Turn(1))
self.status=Text(self,280,54,'',0xffc3b7a1)
self.dungeonButton=Action(self,18,48,100,'副本信息',self.OpenDungeon)
self.refreshButton=Action(self,124,48,70,'刷新',self.Query)
self.prevButton=Action(self,200,48,70,'上一页',lambda:self.Turn(-1))
self.nextButton=Action(self,276,48,70,'下一页',lambda:self.Turn(1))
self.status=Text(self,354,54,'',0xffc3b7a1)
self.lines=[Text(self,18,0,'',0xffefdfc3) for i in range(PAGE)]
self.details=[Text(self,30,0,'',0xffb2aa9a) for i in range(PAGE)]
self.remindButtons=[Action(self,0,0,92,'',lambda i=i:self.Remind(i)) for i in range(PAGE)]
@@ -135,7 +136,12 @@ class BossWindow(ui.Window):
self.note=Text(self,18,0,'提醒:Boss 刷新后在聊天框提示;以服务器刷新为准。',0xffb2aa9a)
self.Reflow();self.Hide()
def Buttons(self):return [self.closeButton,self.refreshButton,self.prevButton,self.nextButton]+self.remindButtons+self.travelButtons
def OpenDungeon(self):
import mt_dungeons
self.Hide()
mt_dungeons.Toggle()
def Buttons(self):return [self.closeButton,self.dungeonButton,self.refreshButton,self.prevButton,self.nextButton]+self.remindButtons+self.travelButtons
def Open(self):
self.Reflow();self.SetCenterPosition();self.Show();self.SetTop();self.Query()
@@ -233,7 +239,7 @@ class ReminderTick(ui.Window):
class Entry(Action):
def __init__(self,window):
Action.__init__(self,None,0,0,64,'Boss',Toggle)
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('BossEntry');self.OnUpdate()
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('BossEntry');self.OnUpdate();self.Hide()
def OnUpdate(self):
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+356)
+1 -1
View File
@@ -171,7 +171,7 @@ class ChannelWindow(ui.Window):
class Entry(Action):
def __init__(self,window):
Action.__init__(self,None,0,0,64,'换线',Toggle)
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('ChannelEntry');self.OnUpdate()
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('ChannelEntry');self.OnUpdate();self.Hide()
def OnUpdate(self):
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+304)
+1 -1
View File
@@ -118,7 +118,7 @@ class DisplayWindow(ui.Window):
class Entry(Action):
def __init__(self,window):
Action.__init__(self,None,0,0,64,'显示',Toggle)
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('DisplayEntry');self.OnUpdate()
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('DisplayEntry');self.OnUpdate();self.Hide()
def OnUpdate(self):
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+252)
+10 -4
View File
@@ -26,9 +26,10 @@ class DungeonWindow(ui.Window):
self.lastTick=app.GetTime();self.reminder=None;self.tab=0;self.dimensions=None;self.stale=True
self.heading=Text(self,18,18,'副本信息',0xffffd68b)
self.closeButton=Action(self,0,6,60,'关闭',self.Hide)
self.lairButton=Action(self,18,52,150,'龙穴',lambda:self.Select(0))
self.weeklyButton=Action(self,180,52,150,'龙穴周任务',lambda:self.Select(1))
self.refreshButton=Action(self,342,52,80,'刷新',self.Query)
self.lairButton=Action(self,18,52,110,'龙穴',lambda:self.Select(0))
self.weeklyButton=Action(self,134,52,130,'龙穴周任务',lambda:self.Select(1))
self.bossButton=Action(self,270,52,120,'世界Boss',self.OpenBoss)
self.refreshButton=Action(self,396,52,70,'刷新',self.Query)
self.status=Text(self,18,108,'正在读取任务状态')
self.rows=[Text(self,24,142+32*i,'',0xffefdfc3) for i in range(6)]
self.remindButton=Action(self,18,0,146,'到期提醒:关',self.Remind)
@@ -103,6 +104,11 @@ class DungeonWindow(ui.Window):
import mt_boss
mt_boss.Travel(2493)
def OpenBoss(self):
import mt_boss
self.Hide()
mt_boss.Toggle()
def Entry(self):
if self.values is None or self.stale:return
v=self.values
@@ -159,7 +165,7 @@ class DungeonWindow(ui.Window):
def Destroy(self):
self.generation+=1;self.reminder=None;self.values=None;self.Hide()
for b in (self.closeButton,self.lairButton,self.weeklyButton,self.refreshButton,self.remindButton,self.entryButton,self.travelButton):b.event=None
for b in (self.closeButton,self.lairButton,self.weeklyButton,self.bossButton,self.refreshButton,self.remindButton,self.entryButton,self.travelButton):b.event=None
class ReminderTick(ui.Window):
@@ -0,0 +1,295 @@
// PORT: AVA2 minimap outer ring buttons (dungeon, battlepass, biolog) with tooltips and fold synchronization.
static const char c_szMinimapOuterRingScript[] = R"PY(# -*- coding: utf-8 -*-
import app
import game
import ui
import weakref
import wndMgr
import mt_dungeons
import mt_battlepass
import mt_biolog
class MapTextToolTip(ui.Window):
def __init__(self):
ui.Window.__init__(self)
textLine = ui.TextLine()
textLine.SetParent(self)
textLine.SetOutline()
textLine.SetHorizontalAlignRight()
textLine.Show()
self.textLine = textLine
def __del__(self):
if hasattr(ui.Window, '__del__'):
ui.Window.__del__(self)
def SetText(self, text):
self.textLine.SetText(text)
def SetTooltipPosition(self, PosX, PosY):
self.textLine.SetPosition(PosX - 5, PosY)
def SetTextColor(self, TextColor):
self.textLine.SetPackedFontColor(TextColor)
class MinimapOuterRing(object):
def __init__(self, gameWindow):
self.game = weakref.proxy(gameWindow)
self.minimap = None
self.btnDungeon = None
self.btnBattlePass = None
self.btnBiolog = None
self.tipDungeon = None
self.tipBattlePass = None
self.tipBiolog = None
self.hooked = False
self.Attach()
def Attach(self):
interface = getattr(self.game, 'interface', None)
if not interface:
return
wndMiniMap = getattr(interface, 'wndMiniMap', None)
if not wndMiniMap:
return
openWindow = getattr(wndMiniMap, 'OpenWindow', None)
if not openWindow:
return
self.minimap = weakref.proxy(wndMiniMap)
# 1. Dungeon info button: (-10, 40)
btnDungeon = ui.Button()
btnDungeon.SetParent(openWindow)
btnDungeon.SetUpVisual("d:/ymir work/ui/game/minimapa/dungeon_0.tga")
btnDungeon.SetOverVisual("d:/ymir work/ui/game/minimapa/dungeon_1.tga")
btnDungeon.SetDownVisual("d:/ymir work/ui/game/minimapa/dungeon_2.tga")
btnDungeon.SetPosition(-10, 40)
btnDungeon.SetEvent(mt_dungeons.Toggle)
btnDungeon.Show()
self.btnDungeon = btnDungeon
tipDungeon = MapTextToolTip()
tipDungeon.SetText("[F5] 副本信息")
tipDungeon.Hide()
self.tipDungeon = tipDungeon
# 2. Battle pass button: (0, 80)
btnBattlePass = ui.Button()
btnBattlePass.SetParent(openWindow)
btnBattlePass.SetUpVisual("d:/ymir work/ui/game/battle_pass/battlepass_icon_0.tga")
btnBattlePass.SetOverVisual("d:/ymir work/ui/game/battle_pass/battlepass_icon_1.tga")
btnBattlePass.SetDownVisual("d:/ymir work/ui/game/battle_pass/battlepass_icon_2.tga")
btnBattlePass.SetPosition(0, 80)
btnBattlePass.SetEvent(mt_battlepass.Toggle)
btnBattlePass.Show()
self.btnBattlePass = btnBattlePass
tipBattlePass = MapTextToolTip()
tipBattlePass.SetText("[F6] 战斗通行证")
tipBattlePass.Hide()
self.tipBattlePass = tipBattlePass
# 3. Biologist button: (15, 105)
btnBiolog = ui.Button()
btnBiolog.SetParent(openWindow)
btnBiolog.SetUpVisual("d:/ymir work/ui/game/minimapa/biolog_0.tga")
btnBiolog.SetOverVisual("d:/ymir work/ui/game/minimapa/biolog_1.tga")
btnBiolog.SetDownVisual("d:/ymir work/ui/game/minimapa/biolog_2.tga")
btnBiolog.SetPosition(15, 105)
btnBiolog.SetEvent(mt_biolog.Toggle)
btnBiolog.Show()
self.btnBiolog = btnBiolog
tipBiolog = MapTextToolTip()
tipBiolog.SetText("[F7] 生物学家")
tipBiolog.Hide()
self.tipBiolog = tipBiolog
# 4. Channel switcher button over ServerInfo text: (10, 134)
channel_toggle = None
try:
import mt_channel
channel_toggle = mt_channel.Toggle
except ImportError:
pass
if channel_toggle:
btnChannel = ui.Button()
btnChannel.SetParent(openWindow)
btnChannel.SetPosition(10, 134)
btnChannel.SetSize(116, 20)
btnChannel.SetEvent(channel_toggle)
btnChannel.Show()
self.btnChannel = btnChannel
tipChannel = MapTextToolTip()
tipChannel.SetText("[F8] 点击换线")
tipChannel.Hide()
self.tipChannel = tipChannel
# 5. Expanded taskbar injection for Switchbot & Wiki
wndExpandedTaskBar = getattr(interface, 'wndExpandedTaskBar', None)
if wndExpandedTaskBar:
board = getattr(wndExpandedTaskBar, 'expandedTaskBarBoard', None)
if board and not getattr(wndExpandedTaskBar, '_injected_ava2', False):
wndExpandedTaskBar._injected_ava2 = True
wndExpandedTaskBar.SetSize(111, 37)
board.SetSize(111, 37)
btnSwitch = ui.Button()
btnSwitch.SetParent(board)
btnSwitch.SetUpVisual("d:/ymir work/ui/game/new_inventory/switch_0.tga")
btnSwitch.SetOverVisual("d:/ymir work/ui/game/new_inventory/switch_1.tga")
btnSwitch.SetDownVisual("d:/ymir work/ui/game/new_inventory/switch_2.tga")
btnSwitch.SetPosition(37, 0)
if hasattr(btnSwitch, 'SetToolTipText'):
btnSwitch.SetToolTipText("自动洗练")
btnSwitch.SetEvent(lambda: interface.ToggleSwitchbotWindow())
btnSwitch.Show()
wndExpandedTaskBar.btnSwitchbot = btnSwitch
try:
import mt_wiki
wiki_toggle = mt_wiki.Toggle
except ImportError:
wiki_toggle = None
if wiki_toggle:
btnWiki = ui.Button()
btnWiki.SetParent(board)
btnWiki.SetUpVisual("d:/ymir work/ui/game/new_inventory/wiki_0.tga")
btnWiki.SetOverVisual("d:/ymir work/ui/game/new_inventory/wiki_1.tga")
btnWiki.SetDownVisual("d:/ymir work/ui/game/new_inventory/wiki_2.tga")
btnWiki.SetPosition(74, 0)
if hasattr(btnWiki, 'SetToolTipText'):
btnWiki.SetToolTipText("游戏百科")
btnWiki.SetEvent(wiki_toggle)
btnWiki.Show()
wndExpandedTaskBar.btnWiki = btnWiki
self.UpdateTooltipPositions()
# Keyboard shortcuts F5, F6, F7, F8
keys = getattr(self.game, 'onPressKeyDict', None)
if keys is not None:
if hasattr(app, 'DIK_F5') and app.DIK_F5 not in keys:
keys[app.DIK_F5] = mt_dungeons.Toggle
if hasattr(app, 'DIK_F6') and app.DIK_F6 not in keys:
keys[app.DIK_F6] = mt_battlepass.Toggle
if hasattr(app, 'DIK_F7') and app.DIK_F7 not in keys:
keys[app.DIK_F7] = mt_biolog.Toggle
if hasattr(app, 'DIK_F8') and app.DIK_F8 not in keys and channel_toggle:
keys[app.DIK_F8] = channel_toggle
# Hook minimap Show/Hide/OnUpdate for outer ring sync
if not self.hooked:
self.hooked = True
orig_hide = wndMiniMap.HideMiniMap
orig_show = wndMiniMap.ShowMiniMap
orig_update = wndMiniMap.OnUpdate
def OnHide():
orig_hide()
self.OnHide()
def OnShow():
orig_show()
self.OnShow()
def OnUpdate():
orig_update()
self.OnUpdate()
wndMiniMap.HideMiniMap = OnHide
wndMiniMap.ShowMiniMap = OnShow
wndMiniMap.OnUpdate = OnUpdate
def UpdateTooltipPositions(self):
if self.btnDungeon and self.tipDungeon:
gx, gy = self.btnDungeon.GetGlobalPosition()
self.tipDungeon.SetTooltipPosition(gx, gy + 4)
if self.btnBattlePass and self.tipBattlePass:
gx, gy = self.btnBattlePass.GetGlobalPosition()
self.tipBattlePass.SetTooltipPosition(gx, gy + 2)
if self.btnBiolog and self.tipBiolog:
gx, gy = self.btnBiolog.GetGlobalPosition()
self.tipBiolog.SetTooltipPosition(gx, gy + 2)
if getattr(self, 'btnChannel', None) and getattr(self, 'tipChannel', None):
gx, gy = self.btnChannel.GetGlobalPosition()
self.tipChannel.SetTooltipPosition(gx + 120, gy)
def OnHide(self):
if self.btnDungeon: self.btnDungeon.Hide()
if self.btnBattlePass: self.btnBattlePass.Hide()
if self.btnBiolog: self.btnBiolog.Hide()
if getattr(self, 'btnChannel', None): self.btnChannel.Hide()
if self.tipDungeon: self.tipDungeon.Hide()
if self.tipBattlePass: self.tipBattlePass.Hide()
if self.tipBiolog: self.tipBiolog.Hide()
if getattr(self, 'tipChannel', None): self.tipChannel.Hide()
def OnShow(self):
if self.btnDungeon: self.btnDungeon.Show()
if self.btnBattlePass: self.btnBattlePass.Show()
if self.btnBiolog: self.btnBiolog.Show()
if getattr(self, 'btnChannel', None): self.btnChannel.Show()
def OnUpdate(self):
self.UpdateTooltipPositions()
if self.btnDungeon and self.btnDungeon.IsShow() and self.btnDungeon.IsIn():
self.tipDungeon.Show()
else:
if self.tipDungeon: self.tipDungeon.Hide()
if self.btnBattlePass and self.btnBattlePass.IsShow() and self.btnBattlePass.IsIn():
self.tipBattlePass.Show()
else:
if self.tipBattlePass: self.tipBattlePass.Hide()
if self.btnBiolog and self.btnBiolog.IsShow() and self.btnBiolog.IsIn():
self.tipBiolog.Show()
else:
if self.tipBiolog: self.tipBiolog.Hide()
btnChan = getattr(self, 'btnChannel', None)
tipChan = getattr(self, 'tipChannel', None)
if btnChan and btnChan.IsShow() and btnChan.IsIn():
if tipChan: tipChan.Show()
else:
if tipChan: tipChan.Hide()
def Destroy(self):
self.OnHide()
self.btnDungeon = None
self.btnBattlePass = None
self.btnBiolog = None
self.btnChannel = None
self.tipDungeon = None
self.tipBattlePass = None
self.tipBiolog = None
self.tipChannel = None
self.minimap = None
g_ring = None
_open = game.GameWindow.Open
_close = game.GameWindow.Close
def Open(self):
global g_ring
_open(self)
g_ring = MinimapOuterRing(self)
def Close(self):
global g_ring
if g_ring:
g_ring.Destroy()
g_ring = None
_close(self)
game.GameWindow.Open = Open
game.GameWindow.Close = Close
)PY";
+1 -1
View File
@@ -144,7 +144,7 @@ class PickupWindow(ui.Window):
class Entry(Action):
def __init__(self,window):
Action.__init__(self,None,0,0,64,'拾取',Toggle)
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('PickupEntry');self.OnUpdate()
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('PickupEntry');self.OnUpdate();self.Hide()
def OnUpdate(self):
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+200)
+2
View File
@@ -1037,6 +1037,7 @@ namespace PythonBoot
#include "PendantScript.inc"
#include "RingsScript.inc"
#include "ItemActionsScript.inc"
#include "MinimapOuterRingScript.inc"
#ifdef MT_HAS_MESHPORT
#include "MeshPortScript.inc"
#endif
@@ -1135,6 +1136,7 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
install_script_module("mt_pendant", c_szPendantScript);
install_script_module("mt_rings", c_szRingsScript);
install_script_module("mt_item_actions", c_szItemActionsScript);
install_script_module("mt_minimap_buttons", c_szMinimapOuterRingScript);
if (g_touch_input)
install_script_module("mt_mobile_hud", c_szMobileHUDScript);
}
+1 -1
View File
@@ -1853,7 +1853,7 @@ class Entry(Action):
# taskbar nor a free F9 (auto hunt), so the button stays next to the minimap, where touch can reach it.
def __init__(self,window):
Action.__init__(self,None,0,0,64,'洗练',lambda:window.interface.ToggleSwitchbotWindow())
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('SwitchbotEntry');self.OnUpdate()
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('SwitchbotEntry');self.OnUpdate();self.Hide()
def OnUpdate(self):
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+148)
+1 -1
View File
@@ -130,7 +130,7 @@ class VipWindow(ui.Window):
class Entry(Action):
def __init__(self,window):
Action.__init__(self,None,0,0,64,'VIP',Toggle)
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('VipEntry');self.OnUpdate()
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('VipEntry');self.OnUpdate();self.Hide()
def OnUpdate(self):
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+408)
+1 -1
View File
@@ -355,7 +355,7 @@ class WikiWindow(ui.Window):
class Entry(Action):
def __init__(self,window):
Action.__init__(self,None,0,0,64,'百科',Toggle)
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('WikiEntry');self.OnUpdate()
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('WikiEntry');self.OnUpdate();self.Hide()
def OnUpdate(self):
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+96)