Add a jump to market group context menu entry
This commit is contained in:
@@ -1 +1 @@
|
||||
__all__ = ["moduleAmmoPicker", "itemStats", "damagePattern"]
|
||||
__all__ = ["moduleAmmoPicker", "itemStats", "damagePattern", "marketJump"]
|
||||
|
||||
19
gui/builtinContextMenus/marketJump.py
Normal file
19
gui/builtinContextMenus/marketJump.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.itemStats import ItemStatsDialog
|
||||
import gui.mainFrame
|
||||
import service
|
||||
|
||||
class MarketJump(ContextMenu):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, context, selection):
|
||||
return context in ("module", "ammo", "itemSearch")
|
||||
|
||||
def getText(self, context, selection):
|
||||
return "Jump to %s Market Group" % (context.capitalize() if context != "itemSearch" else "Item")
|
||||
|
||||
def activate(self, context, selection, i):
|
||||
self.mainFrame.marketBrowser.jump(selection[0])
|
||||
|
||||
MarketJump.register()
|
||||
@@ -129,6 +129,25 @@ class MarketBrowser(wx.Panel):
|
||||
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def jump(self, item):
|
||||
mg = item.marketGroup
|
||||
jumpList = []
|
||||
while mg is not None:
|
||||
jumpList.append(mg.ID)
|
||||
mg = mg.parent
|
||||
|
||||
item = self.marketRoot
|
||||
for i in range(len(jumpList) -1, -1, -1):
|
||||
target = jumpList[i]
|
||||
child, cookie = self.marketView.GetFirstChild(item)
|
||||
while self.marketView.GetItemPyData(child) != target:
|
||||
child, cookie = self.marketView.GetNextChild(child, cookie)
|
||||
|
||||
item = child
|
||||
self.marketView.Expand(item)
|
||||
|
||||
self.marketView.SelectItem(item)
|
||||
|
||||
def addMarketViewImage(self, iconFile):
|
||||
if iconFile is None:
|
||||
return -1
|
||||
|
||||
Reference in New Issue
Block a user