Port AVA2 native tracker and item-currency ticket shop

This commit is contained in:
shen
2026-10-18 10:41:51 -07:00
parent 83809631ed
commit 5decc93798
33 changed files with 1850 additions and 17 deletions
@@ -22,4 +22,427 @@ def LoadElementButton(self,window,value,parent):
window.SetListText(value['text'],value['text_x'])
return result
ui.PythonScriptLoader.LoadElementButton=LoadElementButton
# AVA2 tracker list/text primitives and the two original loader branches.
# The existing loader remains unchanged for all other element types.
exec(r"""
class ListBoxNew(Window):
def __del__(self):
Window.__del__(self)
def Destroy(self):
for item in self.itemList:
item.Destroy()
self.itemList=[]
self.scrollBar=None
self.basePos=0
self.scrollLen=0
self.scrollLenExtra=0
self.isHorizontal= 0
def __init__(self, isHorizontal = False):
Window.__init__(self)
self.itemList=[]
self.Destroy()
self.isHorizontal= isHorizontal
def RemoveAllItems(self):
for item in self.itemList:
item.Destroy()
self.itemList=[]
if self.scrollBar:
self.scrollBar.SetPos(0)
self.RefreshAll()
def SetExtraScrollLen(self, extraLen):
self.scrollLenExtra=extraLen
def GetItems(self):
return self.itemList
def AppendItem(self, newItem):
self.itemList.append(newItem)
self.RefreshAll()
def SetScrollBar(self, scrollBar):
scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
self.scrollBar=scrollBar
def OnMouseWheel(self, nLen):
if self.scrollBar:
if self.scrollBar.IsShow():
if nLen > 0:
self.scrollBar.OnUp()
else:
self.scrollBar.OnDown()
return True
return False
def __OnScroll(self):
self.SetBasePos(int(self.scrollBar.GetPos()*self.scrollLen))
def RefreshAll(self):
windowHeight = self.GetHeight()
scrollBar = self.scrollBar
screenSize = 0
for child in self.itemList:
if child.exPos[1]+child.GetHeight() > screenSize:
screenSize = child.exPos[1]+child.GetHeight()
if screenSize > windowHeight:
scrollLen = screenSize-windowHeight
if scrollLen != 0:
scrollLen += self.scrollLenExtra
self.scrollLen = scrollLen
scrollBar.SetMiddleBarSize(float(windowHeight-5)/float(screenSize))
else:
scrollBar.SetMiddleBarSize(1.0)
def Render(self,basePos):
for item in self.itemList:
(ex,ey) = item.exPos
if self.isHorizontal:
item.SetPosition(ex-(basePos), ey)
else:
item.SetPosition(ex, ey-(basePos))
item.OnRender()
def SetBasePos(self, basePos):
if self.basePos == basePos:
return
self.Render(basePos)
self.basePos=basePos
class MultiTextLineNew(Window):
def __del__(self):
Window.__del__(self)
def Destroy(self):
self.textRules = {}
def __init__(self):
Window.__init__(self)
self.Destroy()
self.AddFlag("not_pick")
self.textRules["textRange"] = 15
self.textRules["text"] = ""
self.textRules["textType"] = ""
self.textRules["fontName"] = ""
self.textRules["hexColor"] = 0
self.textRules["fontColor"] = 0
self.textRules["outline"] = 0
def SetTextType(self, textType):
self.textRules["textType"] = textType
self.Refresh()
def SetTextRange(self, textRange):
self.textRules["textRange"] = textRange
self.Refresh()
def SetOutline(self, outline):
self.textRules["outline"] = outline
self.Refresh()
def SetPackedFontColor(self, hexColor):
self.textRules["hexColor"] = hexColor
self.Refresh()
def SetFontColor(self, r, g, b):
self.textRules["fontColor"] =[r, g, b]
self.Refresh()
def SetFontName(self, fontName):
self.textRules["fontName"] = fontName
self.Refresh()
def SetText(self, newText):
self.textRules["text"] = newText
self.Refresh()
def Refresh(self):
textRules = self.textRules
self.children=[]
outline = textRules["outline"]
fontColor = textRules["fontColor"]
hexColor = textRules["hexColor"]
yRange = textRules["textRange"]
fontName = textRules["fontName"]
textType = textRules["textType"].split("#")
totalTextList = textRules["text"].split("#")
(xPosition, yPosition) = (0, 0)
for text in totalTextList:
childText = TextLine()
childText.SetParent(self)
childText.AddFlag("not_pick")
childText.SetPosition(xPosition, yPosition)
if fontName != "":
childText.SetFontName(fontName)
if hexColor != 0:
childText.SetPackedFontColor(hexColor)
if fontColor != 0:
childText.SetFontColor(*fontColor)
if outline:
childText.SetOutline()
self.AddTextType(childText, textType)
childText.SetText(str(text))
childText.Show()
self.children.append(childText)
yPosition+=yRange
self.CheckTexType(self.children, textType, yPosition)
def AddTextType(self, text, typeArg):
if len(typeArg) != 2:
return
_typeDict = {
"vertical":{
"top":text.SetVerticalAlignTop,
"bottom":text.SetVerticalAlignBottom,
"center":text.SetVerticalAlignCenter,
},
"horizontal":{
"top":text.SetHorizontalAlignLeft,
"bottom":text.SetHorizontalAlignRight,
"center":text.SetHorizontalAlignCenter,
},
"all_align":{
"1" : [text.SetHorizontalAlignCenter,text.SetVerticalAlignCenter,text.SetWindowHorizontalAlignCenter,text.SetWindowVerticalAlignCenter],
},
}
(firstToken, secondToken) = tuple(typeArg)
if _typeDict.has_key(firstToken):
textType = _typeDict[firstToken][secondToken] if _typeDict[firstToken].has_key(secondToken) else None
if textType != None:
if isinstance(textType, list):
for rule in textType:
rule()
else:
textType()
def CheckTexType(self, textList, typeArg, yMax):
if len(typeArg) != 2:
return
elif typeArg[1] != "center":
return
width = 0
for text in textList:
if text.GetTextSize()[0] > width:
width = text.GetTextSize()[0]
centerWidth = width / 2
#for text in textList:
# text.SetPosition(centerWidth, text.GetLocalPosition()[1])
self.SetSize(width, yMax)
def LoadChildren(self, parent, dicChildren):
if localeInfo.IsARABIC():
parent.AddFlag( "rtl" )
if True == dicChildren.has_key("style"):
for style in dicChildren["style"]:
parent.AddFlag(style)
if False == dicChildren.has_key("children"):
return False
Index = 0
ChildrenList = dicChildren["children"]
parent.Children = range(len(ChildrenList))
for ElementValue in ChildrenList:
try:
Name = ElementValue["name"]
except KeyError:
Name = ElementValue["name"] = "NONAME"
try:
Type = ElementValue["type"]
except KeyError:
Type = ElementValue["type"] = "window"
if False == self.CheckKeyList(Name, ElementValue, self.DEFAULT_KEY_LIST):
del parent.Children[Index]
continue
if Type == "window":
parent.Children[Index] = ScriptWindow()
parent.Children[Index].SetParent(parent)
self.LoadElementWindow(parent.Children[Index], ElementValue, parent)
elif Type == "button":
parent.Children[Index] = Button()
parent.Children[Index].SetParent(parent)
self.LoadElementButton(parent.Children[Index], ElementValue, parent)
elif Type == "radio_button":
parent.Children[Index] = RadioButton()
parent.Children[Index].SetParent(parent)
self.LoadElementButton(parent.Children[Index], ElementValue, parent)
elif Type == "toggle_button":
parent.Children[Index] = ToggleButton()
parent.Children[Index].SetParent(parent)
self.LoadElementButton(parent.Children[Index], ElementValue, parent)
elif Type == "mark":
parent.Children[Index] = MarkBox()
parent.Children[Index].SetParent(parent)
self.LoadElementMark(parent.Children[Index], ElementValue, parent)
elif Type == "image":
parent.Children[Index] = ImageBox()
parent.Children[Index].SetParent(parent)
self.LoadElementImage(parent.Children[Index], ElementValue, parent)
elif Type == "expanded_image":
parent.Children[Index] = ExpandedImageBox()
parent.Children[Index].SetParent(parent)
self.LoadElementExpandedImage(parent.Children[Index], ElementValue, parent)
elif Type == "ani_image":
parent.Children[Index] = AniImageBox()
parent.Children[Index].SetParent(parent)
self.LoadElementAniImage(parent.Children[Index], ElementValue, parent)
elif Type == "slot":
parent.Children[Index] = SlotWindow()
parent.Children[Index].SetParent(parent)
self.LoadElementSlot(parent.Children[Index], ElementValue, parent)
elif Type == "candidate_list":
parent.Children[Index] = CandidateListBox()
parent.Children[Index].SetParent(parent)
self.LoadElementCandidateList(parent.Children[Index], ElementValue, parent)
elif Type == "grid_table":
parent.Children[Index] = GridSlotWindow()
parent.Children[Index].SetParent(parent)
self.LoadElementGridTable(parent.Children[Index], ElementValue, parent)
elif Type == "text":
parent.Children[Index] = TextLine()
parent.Children[Index].SetParent(parent)
self.LoadElementText(parent.Children[Index], ElementValue, parent)
elif Type == "multi_text":
parent.Children[Index] = MultiTextLineNew()
parent.Children[Index].SetParent(parent)
self.LoadElementText(parent.Children[Index], ElementValue, parent)
elif Type == "listbox_new":
parent.Children[Index] = ListBoxNew()
parent.Children[Index].SetParent(parent)
self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
elif Type == "editline":
parent.Children[Index] = EditLine()
parent.Children[Index].SetParent(parent)
self.LoadElementEditLine(parent.Children[Index], ElementValue, parent)
elif Type == "titlebar":
parent.Children[Index] = TitleBar()
parent.Children[Index].SetParent(parent)
self.LoadElementTitleBar(parent.Children[Index], ElementValue, parent)
elif Type == "horizontalbar":
parent.Children[Index] = HorizontalBar()
parent.Children[Index].SetParent(parent)
self.LoadElementHorizontalBar(parent.Children[Index], ElementValue, parent)
elif Type == "board":
parent.Children[Index] = Board()
parent.Children[Index].SetParent(parent)
self.LoadElementBoard(parent.Children[Index], ElementValue, parent)
elif Type == "board_with_titlebar":
parent.Children[Index] = BoardWithTitleBar()
parent.Children[Index].SetParent(parent)
self.LoadElementBoardWithTitleBar(parent.Children[Index], ElementValue, parent)
elif Type == "thinboard":
parent.Children[Index] = ThinBoard()
parent.Children[Index].SetParent(parent)
self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
elif Type == "box":
parent.Children[Index] = Box()
parent.Children[Index].SetParent(parent)
self.LoadElementBox(parent.Children[Index], ElementValue, parent)
elif Type == "bar":
parent.Children[Index] = Bar()
parent.Children[Index].SetParent(parent)
self.LoadElementBar(parent.Children[Index], ElementValue, parent)
elif Type == "line":
parent.Children[Index] = Line()
parent.Children[Index].SetParent(parent)
self.LoadElementLine(parent.Children[Index], ElementValue, parent)
elif Type == "slotbar":
parent.Children[Index] = SlotBar()
parent.Children[Index].SetParent(parent)
self.LoadElementSlotBar(parent.Children[Index], ElementValue, parent)
elif Type == "gauge":
parent.Children[Index] = Gauge()
parent.Children[Index].SetParent(parent)
self.LoadElementGauge(parent.Children[Index], ElementValue, parent)
elif Type == "scrollbar":
parent.Children[Index] = ScrollBar()
parent.Children[Index].SetParent(parent)
self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
elif Type == "thin_scrollbar":
parent.Children[Index] = ThinScrollBar()
parent.Children[Index].SetParent(parent)
self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
elif Type == "small_thin_scrollbar":
parent.Children[Index] = SmallThinScrollBar()
parent.Children[Index].SetParent(parent)
self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
elif Type == "sliderbar":
parent.Children[Index] = SliderBar()
parent.Children[Index].SetParent(parent)
self.LoadElementSliderBar(parent.Children[Index], ElementValue, parent)
elif Type == "listbox":
parent.Children[Index] = ListBox()
parent.Children[Index].SetParent(parent)
self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
elif Type == "listbox2":
parent.Children[Index] = ListBox2()
parent.Children[Index].SetParent(parent)
self.LoadElementListBox2(parent.Children[Index], ElementValue, parent)
elif Type == "listboxex":
parent.Children[Index] = ListBoxEx()
parent.Children[Index].SetParent(parent)
self.LoadElementListBoxEx(parent.Children[Index], ElementValue, parent)
else:
Index += 1
continue
parent.Children[Index].SetWindowName(Name)
if 0 != self.InsertFunction:
self.InsertFunction(Name, parent.Children[Index])
self.LoadChildren(parent.Children[Index], ElementValue)
Index += 1
PythonScriptLoader.LoadChildren=LoadChildren
del LoadChildren
""",ui.__dict__)
_position=ui.Window.SetPosition
def SetPosition(self,x,y,flag=False):
if flag:self.exPos=(x,y)
_position(self,x,y)
ui.Window.SetPosition=SetPosition
if not hasattr(ui.Window,'GetBottom'):
ui.Window.GetBottom=lambda self:self.GetLocalPosition()[1]+self.GetHeight()
ui.Button.SetRenderingRect=lambda self,l,t,r,b:ui.wndMgr.SetRenderingRect(self.hWnd,l,t,r,b)
_imageEvent=ui.ImageBox.SAFE_SetStringEvent
def SetImageEvent(self,event,func,*args):
if args:
callback=ui.__mem_func__(func)
self.eventDict[event]=lambda:callback(*args)
return
return _imageEvent(self,event,func)
ui.ImageBox.SAFE_SetStringEvent=SetImageEvent
_text=ui.PythonScriptLoader.LoadElementText
def LoadText(self,window,value,parent):
if isinstance(window,ui.MultiTextLineNew):
if 'text_range' in value:window.SetTextRange(value['text_range'])
if 'text_type' in value:window.SetTextType(value['text_type'])
return _text(self,window,value,parent)
ui.PythonScriptLoader.LoadElementText=LoadText
# AVA2 toggle callbacks accept bound arguments, like Button.SAFE_SetEvent.
_toggleUp=ui.ToggleButton.SetToggleUpEvent
_toggleDown=ui.ToggleButton.SetToggleDownEvent
def SetToggleUp(self,func,*args):
return _toggleUp(self,(lambda:func(*args)) if args else func)
def SetToggleDown(self,func,*args):
return _toggleDown(self,(lambda:func(*args)) if args else func)
ui.ToggleButton.SetToggleUpEvent=SetToggleUp
ui.ToggleButton.SetToggleDownEvent=SetToggleDown
)PY";
@@ -0,0 +1,765 @@
// AVA2 native uitrack.py, with platform adapters and source bug fixes documented in AVA2-TRACK.md.
static const char c_szNativeTrackScript[] = R"PY(# -*- coding: utf-8 -*-
import app,chat,constInfo,game,localeInfo,mt_boss,mt_dungeons,net,player,ui,systemSetting
from mt_wiki import B
from mt_biolog import Action
for key,text in {'TRACK_OPEN_SHOP': '门票商店', 'TRACK_DUNGEON_INFORMATION': '副本#信息', 'TRACK_BOSS_INFORMATION': '世界首领#信息', 'TRACK_DUNGEON_NOTICE_INFORMATION': '副本可进入时#提醒我', 'TRACK_BOSS_NOTICE_INFORMATION': '世界首领刷新时#提醒我', 'TRACK_DUNGEON_LEVEL_FIELD': '等级:%d - %d', 'TRACK_BOSS_LEVEL_FIELD': '建议等级:%d - %d', 'TRACK_DUNGEON_PARTY_FIELD': '组队:%s', 'TRACK_BOSS_PARTY_FIELD': '刷新间隔:%s', 'TRACK_DUNGEON_PARTY_NEED': '需要', 'TRACK_DUNGEON_PARTY_NOT_NEED': '不需要', 'TRACK_DUNGEON_COOLDOWN_FIELD': '冷却:%s', 'TRACK_BOSS_COOLDOWN_FIELD': '地图:%s', 'TRACK_STATUS_FIELD': '状态:%s', 'TRACK_STATUS_AVAILABLE': '可进入', 'TRACK_STATUS_ALIVE': '已刷新 频道%d', 'TRACK_DUNGEON_KEY': '副本门票', 'TRACK_TELEPORT': '传送', 'TRACK_WINDOW_TITLE': '[F5] 首领与副本追踪', 'TRACK_DUNGEON_READY': '[副本] %s 现已可以进入', 'TRACK_BOSS_READY': '[世界首领] %s 已刷新', 'TRACK_REENTER': '可重返 ', 'TRACK_UNSYNCED': '正在同步', 'TRACK_UNAVAILABLE': '入口状态暂不可用', 'TRACK_WB_1': '午将军', 'TRACK_WB_2': '酉将军', 'TRACK_WB_3': '丑将军', 'TRACK_WB_4': '戌将军', 'TRACK_WB_5': '辰将军', 'TRACK_WB_1_MAP': '十二生肖神殿', 'DEVILTOWER': '恶魔塔', 'SPIDERBARONESA': '蜘蛛女王巢穴', 'BERANSETAOU': '蓝龙巢穴', 'CATACUMB': '恶魔地下墓穴', 'FLAMEDUNGEON': '赤龙巢穴', 'SNOWDUNGEON': '冰雪地下城', 'HYDRADUNGEON': '船舶防御', 'MELEYDUNGEON': '梅莱龙巢'}.items():setattr(localeInfo,key,player.AutoHuntLocalize(text))
import ui, _weakref, item, nonplayer, localeInfo, app, net, systemSetting, constInfo
IMG_DIR_AVATAR = "d:/ymir work/ui/game/track/avatar/"
#u can just open your want design type ok?
#IMG_DIR = "d:/ymir work/ui/game/track/new_design/"
IMG_DIR = "d:/ymir work/ui/game/track/ymirdesign/"
IS_OLD_WINDOW = IMG_DIR.find("ymirdesign") > 0
def calculateRect(curValue, maxValue):
try:
return -1.0 + float(curValue) / float(maxValue)
except:
return 0.0
def FormatTime(seconds):
if seconds <= 0:
return "0s"
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
d, h = divmod(h, 24)
timeText = ""
if d > 0:
timeText += "{}d ".format(d)
if h > 0:
timeText += "{}h ".format(h)
if m > 0:
timeText += "{}m ".format(m)
if s > 0:
timeText += "{}s ".format(s)
return timeText if timeText != "" else "0s"
class TrackWindow(ui.ScriptWindow):
class TrackItem(ui.ScriptWindow):
def __del__(self):
ui.ScriptWindow.__del__(self)
def Destroy(self):
self.ClearDictionary()
self.__dataDict = {}
def __init__(self, parent, __dataDict):
ui.ScriptWindow.__init__(self)
self.Destroy()
self.SetParent(parent)
self.parent = parent
self.__dataDict = __dataDict
self.__fileName = ""
self.__LoadWindow()
def __LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/track/item_new.py" if not IS_OLD_WINDOW else "uiscript/track/item_old.py")
except:
import exception
exception.Abort("TrackWindow.__LoadWindow.LoadObject")
GetObject = self.GetChild
GetObject("avatar").LoadImage(self.__dataDict["img"])
GetObject("avatar").SetPosition(5, 5)
GetObject("teleport_button").SetEvent(self.__ClickTeleport)
trackType = self.__dataDict["trackType"]
if trackType == 0:
ticketImageList = [GetObject("itemwall{}".format(i)) for i in xrange(3)] if IS_OLD_WINDOW else [GetObject("item{}".format(i)) for i in xrange(3)]
map(lambda x : x.Hide(), ticketImageList)
(ticketList, ticketListLen) = (self.__dataDict["tickets"], len(self.__dataDict["tickets"]))
startX = (self.GetWidth()-114)+35 if ticketListLen == 1 else (self.GetWidth()-114)+15 if ticketListLen == 2 else (self.GetWidth()-114)
for i in xrange(len(ticketList)):
(itemVnum, itemCount) = tuple(ticketList[i])
item.SelectItem(itemVnum)
ticketImage = GetObject("item{}".format(i)) if IS_OLD_WINDOW else ticketImageList[i]
ticketImage.LoadImage(item.GetIconImageFileName())
ticketImage.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OnMouseOverInTicket, itemVnum)
ticketImage.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OnMouseOverOutTicket)
ticketImage.Show()
ticketImageList[i].SetPosition(startX+(i * 32), 40)
ticketImageList[i].Show()
if itemCount > 1:
GetObject("itemcount{}".format(i)).SetText(str(itemCount))
GetObject("itemcount{}".format(i)).Show()
else:
GetObject("itemcount{}".format(i)).Hide()
else:
ticketImageList = ["itemwall{}".format(i) for i in xrange(3)] if IS_OLD_WINDOW else ["item{}".format(i) for i in xrange(3)]
ticketImageList.append("dungeon_key")
for t in ticketImageList:
self.ElementDictionary[t].Hide()
self.ElementDictionary[t].Destroy()
self.ElementDictionary[t]=None
del self.ElementDictionary[t]
#GetObject("name_field").SetText(self.__dataDict["name"] if trackType == 0 else nonplayer.GetMonsterName(self.__dataDict["bossVnum"]))
GetObject("name_field").SetText(self.__dataDict["name"])
GetObject("level_field").SetText((localeInfo.TRACK_DUNGEON_LEVEL_FIELD if trackType == 0 else localeInfo.TRACK_BOSS_LEVEL_FIELD) % (self.__dataDict["level_range"][0], self.__dataDict["level_range"][1]))
GetObject("group_field").SetText((localeInfo.TRACK_DUNGEON_PARTY_FIELD if trackType == 0 else localeInfo.TRACK_BOSS_PARTY_FIELD) % ((localeInfo.TRACK_DUNGEON_PARTY_NOT_NEED if not self.__dataDict["group"] else localeInfo.TRACK_DUNGEON_PARTY_NEED) if trackType == 0 else (FormatTime(self.__dataDict["cooldown"]))))
GetObject("cooldown_field").SetText((localeInfo.TRACK_DUNGEON_COOLDOWN_FIELD if trackType == 0 else localeInfo.TRACK_BOSS_COOLDOWN_FIELD) % (FormatTime(self.__dataDict["cooldown"]) if trackType == 0 else self.__dataDict["mapName"]))
self.__fileName = IMG_DIR+"dungeon_closed.tga"
self.__dataDict["status"] = self.__dataDict.get("status",False) if trackType == 1 else app.GetGlobalTimeStamp() > self.__dataDict["server_cooldown"]
GetObject("status_field").SetText(localeInfo.TRACK_STATUS_FIELD % ("|cFF{}{}".format("6AFF84" if self.__dataDict["status"] else "FF6E79", FormatTime(self.__dataDict["server_cooldown"]-app.GetGlobalTimeStamp()) if not self.__dataDict["status"] else localeInfo.TRACK_STATUS_AVAILABLE if trackType == 0 else (localeInfo.TRACK_STATUS_ALIVE % self.__dataDict["channel"]))))
def OnMouseOverOutTicket(self):
interface = constInfo.GetInterfaceInstance()
if interface:
if interface.tooltipItem:
interface.tooltipItem.HideToolTip()
def OnMouseOverInTicket(self, itemVnum):
interface = constInfo.GetInterfaceInstance()
if interface:
if interface.tooltipItem:
interface.tooltipItem.SetItemToolTip(itemVnum)
def __ClickTeleport(self):
net.SendChatPacket("/track_window teleport {}".format(self.__dataDict["bossVnum"]))
def OnUpdate(self):
if not self.__dataDict.get("synced",False):
self.GetChild("status_field").SetText(localeInfo.TRACK_STATUS_FIELD % localeInfo.TRACK_UNSYNCED)
return
if self.__dataDict.get("unavailable",False):
self.GetChild("status_field").SetText(localeInfo.TRACK_STATUS_FIELD % localeInfo.TRACK_UNAVAILABLE)
return
if not self.__dataDict["status"]:
leftTime = self.__dataDict["server_cooldown"]-app.GetGlobalTimeStamp()
if leftTime <= 1 and self.__dataDict["trackType"] == 0:
self.__dataDict["status"] = True
self.__dataDict["deactiveType"] = 0
if ((systemSetting.GetDungeonTrack() == 1 and self.__dataDict["trackType"] == 0) or (systemSetting.GetBossTrack() == 1 and self.__dataDict["trackType"] == 1)):
game = constInfo.GetGameInstance()
if game != None:
game.BINARY_OnRecvBulkWhisper((localeInfo.TRACK_DUNGEON_READY if self.__dataDict["trackType"] == 0 else localeInfo.TRACK_BOSS_READY) % self.__dataDict["name"])
self.GetChild("status_field").SetText(localeInfo.TRACK_STATUS_FIELD % ("|cFF{}{}".format("6AFF84" if self.__dataDict["status"] else "FF6E79" if self.__dataDict["deactiveType"] == 0 else "FFDC66", (localeInfo.TRACK_REENTER if self.__dataDict["deactiveType"] != 0 else "") + FormatTime(self.__dataDict["server_cooldown"]-app.GetGlobalTimeStamp()) if not self.__dataDict["status"] else localeInfo.TRACK_STATUS_AVAILABLE if self.__dataDict["trackType"] == 0 else (localeInfo.TRACK_STATUS_ALIVE % self.__dataDict["channel"]))))
if self.__dataDict["status"]:
self.GetChild("status_field").SetText(localeInfo.TRACK_STATUS_FIELD % (localeInfo.TRACK_STATUS_AVAILABLE if self.__dataDict["trackType"] == 0 else localeInfo.TRACK_STATUS_ALIVE % self.__dataDict["channel"]))
img = IMG_DIR+"dungeon_available.tga" if self.__dataDict["status"] else IMG_DIR+"dungeon_closed.tga" if self.__dataDict["deactiveType"] == 0 else IMG_DIR+"dungeon_re_enter.tga"
if self.__fileName != img:
self.GetChild("board").LoadImage(img)
self.__fileName = img
else:
if self.__dataDict["status"] and IMG_DIR+"dungeon_available.tga" != self.__fileName:
self.GetChild("board").LoadImage(IMG_DIR+"dungeon_available.tga")
self.__fileName = IMG_DIR+"dungeon_available.tga"
def OnRender(self):
_wy = self.parent.GetGlobalPosition()[1]
_height = self.parent.GetHeight()
for chilname, childItem in self.ElementDictionary.items():
if isinstance(childItem, ui.TextLine):
(_x,_y) = childItem.GetGlobalPosition()
childHeight = childItem.GetHeight()
if _y < _wy:
if childItem.IsShow():
childItem.Hide()
continue
if _y+childHeight > (_wy+_height-20):
if childItem.IsShow():
childItem.Hide()
continue
if not childItem.IsShow():
childItem.Show()
if isinstance(childItem, ui.ToggleButton) or isinstance(childItem, ui.Button) or isinstance(childItem, ui.ExpandedImageBox):
topRender = 0
bottomRender = 0
itsRendered = False
(_x,_y) = childItem.GetGlobalPosition()
childHeight = childItem.GetHeight()
if _y < _wy:
topRender = _y-_wy
itsRendered = True
if _y+childHeight > (_wy+_height-2):
bottomRender = (_wy+_height-2)-(_y+childHeight)
itsRendered = True
if itsRendered:
childItem.SetRenderingRect(0,calculateRect(childHeight-abs(topRender), childHeight),0,calculateRect(childHeight-abs(bottomRender),childHeight))
else:
childItem.SetRenderingRect(0, 0, 0, 0)
def __del__(self):
ui.ScriptWindow.__del__(self)
def Destroy(self):
self.ClearDictionary()
self.__dataDict = {}
self.__trackType = 0
self.__packetSended = False
def __init__(self):
ui.ScriptWindow.__init__(self)
self.Destroy()
self.__LoadWindow()
def __LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/track/window_new.py" if not IS_OLD_WINDOW else "uiscript/track/window_old.py")
except:
import exception
exception.Abort("TrackWindow.__LoadWindow.LoadObject")
GetObject = self.GetChild
if IS_OLD_WINDOW:
GetObject("board").SetCloseEvent(self.Close)
else:
GetObject("close").SetEvent(self.Close)
scrollBar = ScrollBarNew()
scrollBar.SetParent(GetObject("board"))
scrollBar.SetScrollBarSize(452)
scrollBar.SetMiddleBarSize(1.0)
scrollBar.SetPosition(self.GetWidth()-210, 50)
scrollBar.Show()
self.ElementDictionary["scrollBar"] = scrollBar
GetObject("listbox").SetExtraScrollLen(112)
GetObject("listbox").SetScrollBar(_weakref.proxy(scrollBar))
GetObject("dungeon_info").SAFE_SetEvent(self.SetTrackType, 0)
GetObject("worldboss_info").SAFE_SetEvent(self.SetTrackType, 1)
GetObject("open_shop").SAFE_SetEvent(self.OpenShop)
GetObject("dungeon_info_notice").SetToggleUpEvent(self.SetOptions, 0)
GetObject("dungeon_info_notice").SetToggleDownEvent(self.SetOptions, 0)
GetObject("worldboss_info_notice").SetToggleUpEvent(self.SetOptions, 1)
GetObject("worldboss_info_notice").SetToggleDownEvent(self.SetOptions, 1)
# trackType = 0 Dungeon - 1 WorldBoss
self.__dataDict = {
# Dungeon Items
0 : [\
{
"trackType": 0,
"name":localeInfo.DEVILTOWER,
"level_range": [40, 95],
"group": False,
"cooldown": 60 * 60,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"demon_tower.tga",
"tickets": [[25163, 1]],
"bossVnum": 1093,
"status" : False,
"deactiveType" : 0,
},
{
"trackType": 0,
"name": localeInfo.SPIDERBARONESA,
"level_range": [70, 90],
"group": False,
"cooldown": 60 * 60,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"baroness.tga",
"tickets": [[25164, 1]],
"bossVnum": 2092,
"status" : False,
"deactiveType" : 0,
},
{
"trackType": 0,
"name": localeInfo.BERANSETAOU,
"level_range": [75, 105],
"group": False,
"cooldown": 60 * 60,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"beran.tga",
"tickets": [[25165, 3]],
"bossVnum": 2493,
"status" : False,
"deactiveType" : 0,
},
{
"trackType": 0,
"name": localeInfo.CATACUMB,
"level_range": [80, 105],
"group": False,
"cooldown": 60 * 60,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"azrael.tga",
"tickets": [[25166, 1]],
"bossVnum": 2598,
"status" : False,
"deactiveType" : 0,
},
{
"trackType": 0,
"name": localeInfo.FLAMEDUNGEON,
"level_range": [90, 120],
"group": False,
"cooldown": 60 * 60 * 1,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"razador.tga",
"tickets": [[25167, 1]],
"bossVnum": 6091,
"status" : False,
"deactiveType" : 0,
},
{
"trackType": 0,
"name": localeInfo.SNOWDUNGEON,
"level_range": [90, 120],
"group": False,
"cooldown": 60 * 60 * 1,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"nemere.tga",
"tickets": [[25168, 1]],
"bossVnum": 6191,
"status" : False,
"deactiveType" : 0,
},
{
"trackType": 0,
"name": localeInfo.HYDRADUNGEON,
"level_range": [105, 120],
"group": False,
"cooldown": 60 * 60 * 3,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"hidra.tga",
"tickets": [[25169, 1]],
"bossVnum": 9018,
"status" : False,
"deactiveType" : 0,
},
{
"trackType": 0,
"name": localeInfo.MELEYDUNGEON,
"level_range": [110, 120],
"group": True,
"cooldown": 60 * 60 * 3,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"meley.tga",
"tickets": [[25170, 1]],
"bossVnum": 20442,
"status" : False,
"deactiveType" : 0,
},
],
# WorldBoss
1 : [\
{
"name": localeInfo.TRACK_WB_1,
"trackType": 1,
"level_range": [40, 60],
"cooldown": 60 * 60 * 48,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"wu.tga",
"bossVnum": 9844,
"mapName": localeInfo.TRACK_WB_1_MAP,
"channel": 99,
"status" : False,
"regen_id" : 0,
"deactiveType" : 0,
},
{
"name": localeInfo.TRACK_WB_2,
"trackType": 1,
"level_range": [65, 85],
"cooldown": 60 * 60 * 48,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"you.tga",
"bossVnum": 9836,
"mapName": localeInfo.TRACK_WB_1_MAP,
"channel": 99,
"status" : False,
"regen_id" : 1,
"deactiveType" : 0,
},
{
"name": localeInfo.TRACK_WB_3,
"trackType": 1,
"level_range": [80, 100],
"cooldown": 60 * 60 * 48,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"chou.tga",
"bossVnum": 9838,
"mapName": localeInfo.TRACK_WB_1_MAP,
"channel": 99,
"status" : False,
"regen_id" : 2,
"deactiveType" : 0,
},
{
"name": localeInfo.TRACK_WB_4,
"trackType": 1,
"level_range": [95, 115],
"cooldown": 60 * 60 * 48,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"xu.tga",
"bossVnum": 9840,
"mapName": localeInfo.TRACK_WB_1_MAP,
"channel": 99,
"status" : False,
"regen_id" : 3,
"deactiveType" : 0,
},
{
"name": localeInfo.TRACK_WB_5,
"trackType": 1,
"level_range": [105, 120],
"cooldown": 60 * 60 * 48,
"server_cooldown": 0,
"img": IMG_DIR_AVATAR+"chen.tga",
"bossVnum": 9842,
"mapName": localeInfo.TRACK_WB_1_MAP,
"channel": 99,
"status" : False,
"regen_id" : 4,
"deactiveType" : 0,
},
],
}
self.SetTrackType(0)
self.SetCenterPosition()
def SetOptions(self, type):
if type == 0:
systemSetting.SetDungeonTrack(not systemSetting.GetDungeonTrack())
elif type == 1:
systemSetting.SetBossTrack(not systemSetting.GetBossTrack())
self.RefreshOptions()
def RefreshOptions(self):
if systemSetting.GetDungeonTrack():
self.GetChild("dungeon_info_notice").Down()
else:
self.GetChild("dungeon_info_notice").SetUp()
if systemSetting.GetBossTrack():
self.GetChild("worldboss_info_notice").Down()
else:
self.GetChild("worldboss_info_notice").SetUp()
def SetTrackType(self, trackType):
self.__trackType = trackType
btnList = [self.GetChild("dungeon_info"), self.GetChild("worldboss_info")]
btnList[trackType].Down()
btnList[not trackType].SetUp()
self.Refresh()
def Refresh(self):
listbox = self.GetChild("listbox")
listbox.RemoveAllItems()
trackDataList = self.__dataDict[self.__trackType] if self.__dataDict.has_key(self.__trackType) else []
yItemCount = 0
for data in trackDataList:
trackItem = self.TrackItem(_weakref.proxy(listbox), data)
trackItem.SetPosition(0, yItemCount * trackItem.GetHeight(), True)
listbox.AppendItem(trackItem)
trackItem.Show()
yItemCount+=1
listbox.RefreshAll()
def TrackBossInfo(self, bossID, bossLeftTime, bossChannel):
#import chat
#chat.AppendChat(1, "bossId {} leftTime {} channel {}".format(bossID, bossLeftTime, bossChannel))
trackDataList = self.__dataDict[1] if self.__dataDict.has_key(1) else []
for data in trackDataList:
if data["regen_id"] == bossID:
if bossLeftTime == 65535 and data.get("synced",False) and not data.get("status",False) and systemSetting.GetBossTrack():
game=constInfo.GetGameInstance()
if game:game.BINARY_OnRecvBulkWhisper(localeInfo.TRACK_BOSS_READY % data["name"])
data["synced"] = True
data["unavailable"] = bossLeftTime < 0
data["channel"] = bossChannel
data["server_cooldown"] = app.GetGlobalTimeStamp()+bossLeftTime if bossLeftTime != 65535 else 0
data["status"] = False if bossLeftTime != 65535 else True
def TrackDungeonInfo(self, cmdData):
trackDataList = self.__dataDict[0] if self.__dataDict.has_key(0) else []
if len(cmdData) != 0:
cmdTokenList = cmdData[:len(cmdData)-1].split("#")
for cmd in cmdTokenList:
cooldown = cmd.split("|")
if len(cooldown) == 3:
bossVnum = int(cooldown[0])
for data in trackDataList:
if data["bossVnum"] == bossVnum:
data["synced"] = True
data["unavailable"] = int(cooldown[1]) < 0
data["server_cooldown"] = app.GetGlobalTimeStamp()+int(cooldown[1])
data["deactiveType"] = int(cooldown[2])
data["status"] = False
def OpenShop(self):
net.SendChatPacket("/open_shop 12")
def CheckPacket(self):
if not self.__packetSended:
self.__packetSended = True
command = "/track_window load"
trackDataList = self.__dataDict[1] if self.__dataDict.has_key(1) else []
for data in trackDataList:
command += " {}".format(data["regen_id"])
net.SendChatPacket(command)
def Open(self):
self.__packetSended = False
self.Show()
self.SetTop()
if not self.__packetSended:
self.__packetSended = True
command = "/track_window load"
trackDataList = self.__dataDict[1] if self.__dataDict.has_key(1) else []
for data in trackDataList:
command += " {}".format(data["regen_id"])
# import chat
# chat.AppendChat(1, command)
net.SendChatPacket(command)
self.RefreshOptions()
def Close(self):
self.Hide()
return True
def OnPressEscapeKey(self):
return self.Close()
class ScrollBarNew(ui.Window):
SCROLLBAR_WIDTH = 10
SCROLL_BTN_XDIST = 2
SCROLL_BTN_YDIST = 2
class MiddleBar(ui.DragButton):
def __init__(self):
ui.DragButton.__init__(self)
self.AddFlag("movable")
self.SetWindowName("scrollbar_middlebar")
def MakeImage(self):
top = ui.ExpandedImageBox()
top.SetParent(self)
top.LoadImage(IMG_DIR+"scrollbar_ex/scrollbar_top.tga")
top.AddFlag("not_pick")
top.Show()
topScale = ui.ExpandedImageBox()
topScale.SetParent(self)
topScale.SetPosition(0, top.GetHeight())
topScale.LoadImage(IMG_DIR+"scrollbar_ex/scrollbar_scale.tga")
topScale.AddFlag("not_pick")
topScale.Show()
bottom = ui.ExpandedImageBox()
bottom.SetParent(self)
bottom.LoadImage(IMG_DIR+"scrollbar_ex/scrollbar_bottom.tga")
bottom.AddFlag("not_pick")
bottom.Show()
bottomScale = ui.ExpandedImageBox()
bottomScale.SetParent(self)
bottomScale.LoadImage(IMG_DIR+"scrollbar_ex/scrollbar_scale.tga")
bottomScale.AddFlag("not_pick")
bottomScale.Show()
middle = ui.ExpandedImageBox()
middle.SetParent(self)
middle.LoadImage(IMG_DIR+"scrollbar_ex/scrollbar_mid.tga")
middle.AddFlag("not_pick")
middle.Show()
self.top = top
self.topScale = topScale
self.bottom = bottom
self.bottomScale = bottomScale
self.middle = middle
def SetSize(self, height):
minHeight = self.top.GetHeight() + self.bottom.GetHeight() + self.middle.GetHeight()
height = max(minHeight, height)
ui.DragButton.SetSize(self, 10, height)
scale = (height - minHeight) / 2
extraScale = 0
if (height - minHeight) % 2 == 1:
extraScale = 1
self.topScale.SetRenderingRect(0, 0, 0, scale - 1)
self.middle.SetPosition(0, self.top.GetHeight() + scale)
self.bottomScale.SetPosition(0, self.middle.GetBottom())
self.bottomScale.SetRenderingRect(0, 0, 0, scale - 1 + extraScale)
self.bottom.SetPosition(0, height - self.bottom.GetHeight())
def __init__(self):
ui.Window.__init__(self)
self.pageSize = 1
self.curPos = 0.0
self.eventScroll = None
self.eventArgs = None
self.lockFlag = False
self.CreateScrollBar()
self.SetScrollBarSize(0)
self.scrollStep = 0.2
self.SetWindowName("NONAME_ScrollBar")
def __del__(self):
ui.Window.__del__(self)
def CreateScrollBar(self):
topImage = ui.ExpandedImageBox()
topImage.SetParent(self)
topImage.AddFlag("not_pick")
topImage.LoadImage(IMG_DIR+"scrollbar_ex/scroll_top.tga")
topImage.Show()
bottomImage = ui.ExpandedImageBox()
bottomImage.SetParent(self)
bottomImage.AddFlag("not_pick")
bottomImage.LoadImage(IMG_DIR+"scrollbar_ex/scroll_bottom.tga")
bottomImage.Show()
middleImage = ui.ExpandedImageBox()
middleImage.SetParent(self)
middleImage.AddFlag("not_pick")
middleImage.SetPosition(0, topImage.GetHeight())
middleImage.LoadImage(IMG_DIR+"scrollbar_ex/scroll_mid.tga")
middleImage.Show()
self.topImage = topImage
self.bottomImage = bottomImage
self.middleImage = middleImage
middleBar = self.MiddleBar()
middleBar.SetParent(self)
middleBar.SetMoveEvent(ui.__mem_func__(self.OnMove))
middleBar.Show()
middleBar.MakeImage()
middleBar.SetSize(12)
self.middleBar = middleBar
def Destroy(self):
self.eventScroll = None
self.eventArgs = None
def SetScrollEvent(self, event, *args):
self.eventScroll = event
self.eventArgs = args
def SetMiddleBarSize(self, pageScale):
self.middleBar.SetSize(int(pageScale * float(self.GetHeight() - (self.SCROLL_BTN_YDIST*2))))
realHeight = self.GetHeight() - (self.SCROLL_BTN_YDIST*2) - self.middleBar.GetHeight()
self.pageSize = realHeight
def SetScrollBarSize(self, height):
self.SetSize(self.SCROLLBAR_WIDTH, height)
self.pageSize = height - self.SCROLL_BTN_YDIST*2 - self.middleBar.GetHeight()
middleImageScale = float((height - self.SCROLL_BTN_YDIST*2) - self.middleImage.GetHeight()) / float(self.middleImage.GetHeight())
self.middleImage.SetRenderingRect(0, 0, 0, middleImageScale)
self.bottomImage.SetPosition(0, height - self.bottomImage.GetHeight())
self.middleBar.SetRestrictMovementArea(self.SCROLL_BTN_XDIST, self.SCROLL_BTN_YDIST, \
self.middleBar.GetWidth(), height - self.SCROLL_BTN_YDIST * 2)
self.middleBar.SetPosition(self.SCROLL_BTN_XDIST, self.SCROLL_BTN_YDIST)
def SetScrollStep(self, step):
self.scrollStep = step
def OnUp(self):
self.SetPos(self.curPos-self.scrollStep)
def OnDown(self):
self.SetPos(self.curPos+self.scrollStep)
def GetScrollStep(self):
return self.scrollStep
def GetPos(self):
return self.curPos
def OnUp(self):
self.SetPos(self.curPos-self.scrollStep)
def OnDown(self):
self.SetPos(self.curPos+self.scrollStep)
def SetPos(self, pos, moveEvent = True):
pos = max(0.0, pos)
pos = min(1.0, pos)
newPos = float(self.pageSize) * pos
self.middleBar.SetPosition(self.SCROLL_BTN_XDIST, int(newPos) + self.SCROLL_BTN_YDIST)
if moveEvent == True:
self.OnMove()
def OnMove(self):
if self.lockFlag:
return
if 0 == self.pageSize:
return
(xLocal, yLocal) = self.middleBar.GetLocalPosition()
self.curPos = float(yLocal - self.SCROLL_BTN_YDIST) / float(self.pageSize)
if self.eventScroll:
apply(self.eventScroll, self.eventArgs)
def OnMouseLeftButtonDown(self):
(xMouseLocalPosition, yMouseLocalPosition) = self.GetMouseLocalPosition()
newPos = float(yMouseLocalPosition) / float(self.GetHeight())
self.SetPos(newPos)
def LockScroll(self):
self.lockFlag = True
def UnlockScroll(self):
self.lockFlag = False
g_window=None
g_entry=None
g_tick=None
_interface=None
_game=None
constInfo.GetInterfaceInstance=lambda:_interface
constInfo.GetGameInstance=lambda:_game
if not hasattr(game.GameWindow,'BINARY_OnRecvBulkWhisper'):
game.GameWindow.BINARY_OnRecvBulkWhisper=lambda self,text:chat.AppendChat(chat.CHAT_TYPE_INFO,text)
def Toggle(tab=0):
if not g_window:return
if g_window.IsShow() and g_window._TrackWindow__trackType==tab:g_window.Close()
else:g_window.SetTrackType(tab);g_window.Open()
class Entry(Action):
def __init__(self,window):
Action.__init__(self,None,0,0,64,'追踪',lambda:Toggle(1))
self.minimap=_weakref.proxy(window.interface.wndMiniMap)
self.SetWindowName('BossEntry');self.Hide()
def OnUpdate(self):
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+356)
class Tick(ui.Window):
def __init__(self):
ui.Window.__init__(self);self.AddFlag('not_pick');self.Show()
def OnUpdate(self):
if g_window:
for data in g_window._TrackWindow__dataDict.get(0,[]):
if data.get('synced') and not data.get('unavailable') and not data.get('status') and data['server_cooldown']<=app.GetGlobalTimeStamp():
data['status']=True;data['deactiveType']=0
if systemSetting.GetDungeonTrack() and _game:
_game.BINARY_OnRecvBulkWhisper(localeInfo.TRACK_DUNGEON_READY % data['name'])
for card in g_window.GetChild('listbox').GetItems():card.OnUpdate()
_oldOpen=game.GameWindow.Open
_oldClose=game.GameWindow.Close
_oldCommand=game.GameWindow.BINARY_ServerCommand_Run
def Open(self):
global g_window,g_entry,g_tick,_interface,_game
_oldOpen(self)
_interface=self.interface;_game=self
# Retire both custom tracker views and their polling timers.
for module in (mt_boss,mt_dungeons):
if module.g_tick:module.g_tick.Hide();module.g_tick=None
if module.g_window:module.g_window.Destroy();module.g_window=None
if mt_boss.g_entry:mt_boss.g_entry.Hide();mt_boss.g_entry=None
g_window=TrackWindow();g_entry=Entry(self);g_tick=Tick()
mt_boss.g_window=g_window;mt_boss.g_entry=g_entry
g_window.CheckPacket()
def Close(self):
global g_window,g_entry,g_tick,_interface,_game
if g_tick:g_tick.Hide();g_tick=None
if g_entry:g_entry.Hide();g_entry.event=None;g_entry=None
# Original custom Close wrappers must not receive a native TrackWindow.
mt_boss.g_window=None;mt_boss.g_entry=None
if g_window:
g_window.Close();g_window.GetChild('listbox').RemoveAllItems();g_window.Destroy();g_window=None
_interface=None;_game=None
_oldClose(self)
def Command(self,line):
words=line.split()
if words and words[0]=='TrackError':
errors={'unsupported':'不支持此入口','level':'等级不符合传送要求','busy':'当前状态不能传送','unavailable':'服务器尚未开放该地图'}
if len(words)==2:chat.AppendChat(chat.CHAT_TYPE_INFO,player.AutoHuntLocalize(errors.get(words[1],'传送失败')))
return 1
if words and words[0]=='TrackBossInfo':
if g_window and len(words)==4:
try:
boss,left,channel=map(int,words[1:])
if 0<=boss<=65535 and -1<=left<=2147483647 and 0<=channel<=255:
g_window.TrackBossInfo(boss,left,channel)
except (ValueError,OverflowError):pass
return 1
if words and words[0]=='TrackDungeonInfo':
if g_window and len(words)==2:
try:
if all(len(r.split('|'))==3 and r.split('|')[0].isdigit() and (r.split('|')[1].isdigit() or r.split('|')[1]=='-1') and r.split('|')[2] in ('0','1') for r in words[1].rstrip('#').split('#')):
g_window.TrackDungeonInfo(words[1])
except (ValueError,OverflowError):pass
return 1
return _oldCommand(self,line)
game.GameWindow.Open=Open
game.GameWindow.Close=Close
game.GameWindow.BINARY_ServerCommand_Run=Command
mt_boss.Toggle=lambda:Toggle(1)
mt_dungeons.Toggle=lambda:Toggle(0)
)PY";
+6
View File
@@ -1025,6 +1025,9 @@ namespace PythonBoot
#include "DisplayScript.inc"
#include "ChannelScript.inc"
#include "BossScript.inc"
#include "NativeTrackScript.inc"
#include "ShopItemCurrencyScript.inc"
#include "TicketShopScript.inc"
#include "VipScript.inc"
#include "ModelPreviewScript.inc"
#include "BattlePassScript.inc"
@@ -1125,6 +1128,9 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
install_script_module("mt_display", c_szDisplayScript);
install_script_module("mt_channel", c_szChannelScript);
install_script_module("mt_boss", c_szBossScript);
install_script_module("mt_track", c_szNativeTrackScript);
install_script_module("extern_wa_shopitem", c_szShopItemCurrencyScript);
install_script_module("mt_ticket_shop", c_szTicketShopScript);
install_script_module("mt_vip", c_szVipScript);
install_script_module("mt_preview", c_szModelPreviewScript);
install_script_module("mt_battlepass", c_szBattlePassScript);
@@ -0,0 +1,106 @@
// AVA2 extern_wa_shopitem.py; translated strings and runtime capability check.
static const char c_szShopItemCurrencyScript[] = R"PY(# -*- coding: utf-8 -*-
import item
import ui
import shop
import localeInfo
import app
import player
L=player.AutoHuntLocalize
localeInfo.PRICE02=L("数量:%d")
localeInfo.SHOP_NOT_ENOUGH_COUNT=L("兑换所需的道具不足")
#---<UiTooltip Functiones>---#
#----------------------------#
#----------------------------#
def FuncCheckPrice(self,slotIndex,price):
if hasattr(shop,"GetVnumBuy"):
vnum_special = shop.GetVnumBuy(slotIndex)
count_special = shop.GetCountBuy(slotIndex)
if vnum_special != 0:
AppendPriceItem(self,vnum_special,count_special)
else:
self.AppendPrice(price)
else:
self.AppendPrice(price)
def AppendPriceItem(self,vnum_special,count_special):
self.AppendSpace(5)
item.SelectItem(vnum_special)
itemImage = ui.ImageBox()
itemImage.SetParent(self)
itemImage.LoadImage(item.GetIconImageFileName())
itemImage.SetPosition((self.toolTipWidth/2)-10, self.toolTipHeight)
itemImage.Show()
itemName = ui.TextLine()
itemName.SetParent(itemImage)
itemName.SetHorizontalAlignCenter()
itemName.SetPosition(17,itemImage.GetHeight()+6)
itemName.SetText(item.GetItemName())
itemName.Show()
itemCount = ui.TextLine()
itemCount.SetParent(itemImage)
itemCount.SetHorizontalAlignCenter()
itemCount.SetPosition(18,itemImage.GetHeight()+17)
itemCount.SetText(localeInfo.PRICE02 %count_special)
itemCount.Show()
self.toolTipHeight += itemImage.GetHeight()+28
self.childrenList.append(itemImage)
self.childrenList.append(itemName)
self.childrenList.append(itemCount)
self.ResizeToolTip()
#----------------------------#
#----------------------------#
#---<UiTooltip Functiones>---#
#---<LocaleInfo Functiones>--#
#----------------------------#
#----------------------------#
def FuncCheckMsg(slotPos,itemName,itemCount,itemPrice):
if hasattr(shop,"GetVnumBuy"):
vnum_special = shop.GetVnumBuy(slotPos)
count_special = shop.GetCountBuy(slotPos)
if vnum_special == 0:
return localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice))
else:
return DO_YOU_BUY_ITEM_SPECIAL(itemName, itemCount, vnum_special, count_special)
else:
return localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice))
def DO_YOU_BUY_ITEM_SPECIAL(buyItemName, buyItemCount, buyItemVnumSpecial, buyItemSpecialCount):
item.SelectItem(buyItemVnumSpecial)
itemName = item.GetItemName()
if buyItemCount > 1 :
return L("是否兑换 %s ×%d,消耗 %s ×%d?")%(buyItemName,buyItemCount,itemName,buyItemSpecialCount)
else:
return L("是否兑换 %s,消耗 %s ×%d?")%(buyItemName,itemName,buyItemSpecialCount)
#---<LocaleInfo Functiones>--#
#----------------------------#
#----------------------------#
#---<Game Functiones>--#
#----------------------------#
#----------------------------#
def ShopErrorDict(type):
if hasattr(shop,"GetVnumBuy"):
if type == "NOT_ENOUGH_COUNT":
return localeInfo.SHOP_NOT_ENOUGH_COUNT
return localeInfo.SHOP_ERROR_DICT[type]
#---<Game Functiones>--#
#----------------------------#
#----------------------------#
)PY";
@@ -0,0 +1,49 @@
// AVA2 item-currency branches for the existing native ShopDialog / ItemToolTip.
static const char c_szTicketShopScript[] = R"PY(# -*- coding: utf-8 -*-
import constInfo,game,item,localeInfo,player,shop,uiCommon,uiShop,uiToolTip,extern_wa_shopitem
L=player.AutoHuntLocalize
localeInfo.SHOP_ERROR_DICT['NOT_ENOUGH_COUNT']=L('兑换所需的道具不足')
_open=uiShop.ShopDialog.Open
_ask=uiShop.ShopDialog.AskBuyItem
_tooltip=uiToolTip.ItemToolTip.SetShopItem
def Open(self,vid):
_open(self,vid)
if vid==0 and shop.GetVnumBuy(0):
shop.Open(False,False)
self.btnSell.Hide()
def AskBuyItem(self,slotPos):
index=self._ShopDialog__GetRealIndex(slotPos)
if not shop.GetVnumBuy(index):return _ask(self,slotPos)
item.SelectItem(shop.GetItemID(index))
name=item.GetItemName()
question=uiCommon.QuestionDialog()
question.SetText(extern_wa_shopitem.FuncCheckMsg(index,name,shop.GetItemCount(index),shop.GetItemPrice(index)))
question.SetAcceptEvent(lambda:self.AnswerBuyItem(True))
question.SetCancelEvent(lambda:self.AnswerBuyItem(False))
question.Open();question.pos=index
self.itemBuyQuestionDialog=question
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
def SetShopItem(self,index):
if not shop.GetVnumBuy(index):return _tooltip(self,index)
vnum=shop.GetItemID(index)
if not vnum:return
self.ClearToolTip();self.isShopItem=True
sockets=[shop.GetItemMetinSocket(index,i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
attrs=[shop.GetItemAttribute(index,i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
self.AddItemData(vnum,sockets,attrs)
extern_wa_shopitem.FuncCheckPrice(self,index,shop.GetItemPrice(index))
_closeGame=game.GameWindow.Close
def CloseGame(self):
# A disconnect or map transition must not retain the previous server's item prices.
shop.Close()
return _closeGame(self)
game.GameWindow.Close=CloseGame
uiShop.ShopDialog.Open=Open
uiShop.ShopDialog.AskBuyItem=AskBuyItem
uiToolTip.ItemToolTip.SetShopItem=SetShopItem
)PY";