feat: add AVA2 minimap buttons and expanded taskbar entries
This commit is contained in:
@@ -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";
|
||||
Reference in New Issue
Block a user