Rework price stats panel context menu
This commit is contained in:
@@ -3,7 +3,6 @@ import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
@@ -34,4 +33,5 @@ class FactorReload(ContextMenu):
|
||||
sFit = Fit.getInstance()
|
||||
return sFit.serviceFittingOptions["useGlobalForceReload"]
|
||||
|
||||
|
||||
FactorReload.register()
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.globalEvents as GE
|
||||
from service.price import Price
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class PriceClear(ContextMenu):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
if not self.settings.get('priceClear'):
|
||||
return False
|
||||
|
||||
return srcContext in ("priceViewFull", "priceViewMinimal")
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Reset Price Cache"
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
sPrc = Price.getInstance()
|
||||
sPrc.clearPriceCache()
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
|
||||
|
||||
|
||||
PriceClear.register()
|
||||
@@ -1,3 +1,5 @@
|
||||
from abc import abstractmethod, ABCMeta
|
||||
|
||||
import wx
|
||||
|
||||
import gui.globalEvents as GE
|
||||
@@ -6,45 +8,55 @@ from gui.contextMenu import ContextMenu
|
||||
from service.settings import MarketPriceSettings
|
||||
|
||||
|
||||
class PriceOptions(ContextMenu):
|
||||
class ItemGroupPrice(ContextMenu, metaclass=ABCMeta):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = MarketPriceSettings.getInstance()
|
||||
self.optionList = ["Drones", "Cargo", "Character"]
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def label(self):
|
||||
...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def optionName(self):
|
||||
...
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
return srcContext in ("priceViewFull", "priceViewMinimal")
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Include in total"
|
||||
|
||||
def addOption(self, menu, option):
|
||||
label = option
|
||||
id = ContextMenu.nextID()
|
||||
self.optionIds[id] = option
|
||||
menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_CHECK)
|
||||
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.context = context
|
||||
self.optionIds = {}
|
||||
|
||||
sub = wx.Menu()
|
||||
|
||||
for option in self.optionList:
|
||||
menuItem = self.addOption(rootMenu if msw else sub, option)
|
||||
sub.Append(menuItem)
|
||||
menuItem.Check(self.settings.get(option.lower()))
|
||||
|
||||
return sub
|
||||
|
||||
def handleMode(self, event):
|
||||
option = self.optionIds[event.Id]
|
||||
self.settings.set(option.lower(), event.Int)
|
||||
return self.label
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
self.settings.set(self.optionName, not self.settings.get(self.optionName))
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
|
||||
|
||||
@property
|
||||
def checked(self):
|
||||
return self.settings.get(self.optionName)
|
||||
|
||||
PriceOptions.register()
|
||||
|
||||
class DronesPrice(ItemGroupPrice):
|
||||
|
||||
label = 'Drones'
|
||||
optionName = 'drones'
|
||||
|
||||
|
||||
class CargoPrice(ItemGroupPrice):
|
||||
|
||||
label = 'Cargo'
|
||||
optionName = 'cargo'
|
||||
|
||||
|
||||
class ImplantBoosterPrice(ItemGroupPrice):
|
||||
|
||||
label = 'Implants && Boosters'
|
||||
optionName = 'character'
|
||||
|
||||
|
||||
DronesPrice.register()
|
||||
CargoPrice.register()
|
||||
ImplantBoosterPrice.register()
|
||||
|
||||
@@ -208,7 +208,6 @@ from gui.builtinContextMenus import ( # noqa: E402,F401
|
||||
changeAffectingSkills,
|
||||
tacticalMode,
|
||||
targetResists,
|
||||
priceClear,
|
||||
priceOptions,
|
||||
amount,
|
||||
cargoAmmo,
|
||||
|
||||
Reference in New Issue
Block a user