Start reworking context menus into several special classes to improve menu handling consistency
This commit is contained in:
@@ -3,12 +3,12 @@ import wx
|
||||
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class AmmoToDmgPattern(ContextMenu):
|
||||
class AmmoToDmgPattern(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -3,12 +3,12 @@ import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import fitCommands as cmd
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class BoosterSideEffects(ContextMenu):
|
||||
class BoosterSideEffects(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -34,7 +34,7 @@ class BoosterSideEffects(ContextMenu):
|
||||
|
||||
def addEffect(self, menu, ability):
|
||||
label = ability.name
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
self.effectIds[id] = ability
|
||||
|
||||
menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_CHECK)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class AddToCargo(ContextMenu):
|
||||
class AddToCargo(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class AddToCargoAmmo(ContextMenu):
|
||||
class AddToCargoAmmo(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
@@ -3,13 +3,13 @@ import wx
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class AddCommandFit(ContextMenu):
|
||||
class AddCommandFit(ContextMenuCombined):
|
||||
|
||||
# Get list of items that define a command fit
|
||||
sMkt = Market.getInstance()
|
||||
@@ -53,7 +53,7 @@ class AddCommandFit(ContextMenu):
|
||||
|
||||
def addFit(self, menu, fit, includeShip=False):
|
||||
label = fit.name if not includeShip else "({}) {}".format(fit.ship.item.name, fit.name)
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
self.fitMenuItemIds[id] = fit
|
||||
menuItem = wx.MenuItem(menu, id, label)
|
||||
menu.Bind(wx.EVT_MENU, self.handleSelection, menuItem)
|
||||
@@ -80,7 +80,7 @@ class AddCommandFit(ContextMenu):
|
||||
typeDict[shipName].append(fit)
|
||||
|
||||
for ship in sorted(typeDict.keys()):
|
||||
shipItem = wx.MenuItem(sub, ContextMenu.nextID(), ship)
|
||||
shipItem = wx.MenuItem(sub, ContextMenuCombined.nextID(), ship)
|
||||
grandSub = wx.Menu()
|
||||
shipItem.SetSubMenu(grandSub)
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ import wx
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.damagePattern import DamagePattern as import_DamagePattern
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class ChangeDamagePattern(ContextMenu):
|
||||
class ChangeDamagePattern(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -56,7 +56,7 @@ class ChangeDamagePattern(ContextMenu):
|
||||
return self.m
|
||||
|
||||
def addPattern(self, rootMenu, pattern):
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
name = getattr(pattern, "_name", pattern.name) if pattern is not None else "No Profile"
|
||||
|
||||
self.patternIds[id] = pattern
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from gui.fitCommands.helpers import droneStackLimit
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class DroneAddStack(ContextMenu):
|
||||
class DroneAddStack(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -5,12 +5,12 @@ import wx
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class DroneSplitStack(ContextMenu):
|
||||
class DroneSplitStack(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
@@ -6,12 +6,12 @@ import wx
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.market import Market
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class AddEnvironmentEffect(ContextMenu):
|
||||
class AddEnvironmentEffect(ContextMenuCombined):
|
||||
|
||||
# CCP doesn't currently provide a mapping between the general Environment, and the specific environment effect
|
||||
# (which can be random when going into Abyssal space). This is how we currently define it:
|
||||
@@ -92,7 +92,7 @@ class AddEnvironmentEffect(ContextMenu):
|
||||
|
||||
def processFlat(data, root, sub):
|
||||
for swData in sorted(data, key=lambda tpl: tpl[2]):
|
||||
wxid = ContextMenu.nextID()
|
||||
wxid = ContextMenuCombined.nextID()
|
||||
swObj, swName, swClass = swData
|
||||
self.idmap[wxid] = (swObj, swName)
|
||||
subItem = wx.MenuItem(sub, wxid, swClass)
|
||||
|
||||
@@ -3,12 +3,12 @@ import wx
|
||||
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class FactorReload(ContextMenu):
|
||||
class FactorReload(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
@@ -3,12 +3,12 @@ import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import fitCommands as cmd
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class FighterAbilities(ContextMenu):
|
||||
class FighterAbilities(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -31,7 +31,7 @@ class FighterAbilities(ContextMenu):
|
||||
|
||||
def addAbility(self, menu, ability):
|
||||
label = ability.name
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
self.abilityIds[id] = ability
|
||||
menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_CHECK)
|
||||
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
|
||||
|
||||
@@ -4,11 +4,11 @@ import wx
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.builtinViews.emptyView import BlankPage
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class AddCurrentlyOpenFit(ContextMenu):
|
||||
class AddCurrentlyOpenFit(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -41,7 +41,7 @@ class AddCurrentlyOpenFit(ContextMenu):
|
||||
if isinstance(page, BlankPage):
|
||||
continue
|
||||
fit = sFit.getFit(page.activeFitID, basic=True)
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
mitem = wx.MenuItem(rootMenu, id, "{}: {}".format(fit.ship.item.name, fit.name))
|
||||
bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
|
||||
self.fitLookup[id] = fit
|
||||
|
||||
@@ -3,11 +3,11 @@ import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui.builtinShipBrowser.events import FitSelected
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class OpenFitInNewTab(ContextMenu):
|
||||
class OpenFitInNewTab(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -4,13 +4,13 @@ import wx
|
||||
import gui.fitCommands as cmd
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.character import Character
|
||||
from service.implantSet import ImplantSets as s_ImplantSets
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class AddImplantSet(ContextMenu):
|
||||
class AddImplantSet(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -56,7 +56,7 @@ class AddImplantSet(ContextMenu):
|
||||
self.idmap = {}
|
||||
|
||||
for set in implantSets:
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
mitem = wx.MenuItem(rootMenu, id, set.name)
|
||||
bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
|
||||
self.idmap[id] = set
|
||||
|
||||
@@ -9,12 +9,12 @@ from eos.saveddata.cargo import Cargo as es_Cargo
|
||||
from eos.saveddata.drone import Drone
|
||||
from eos.saveddata.fighter import Fighter as es_Fighter
|
||||
from eos.saveddata.fit import Fit as es_Fit
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class ChangeItemAmount(ContextMenu):
|
||||
class ChangeItemAmount(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class FillWithItem(ContextMenu):
|
||||
class FillWithItem(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.market import Market
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class JumpToMarketItem(ContextMenu):
|
||||
class JumpToMarketItem(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class ProjectItem(ContextMenu):
|
||||
class ProjectItem(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -2,12 +2,12 @@ import math
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class RemoveItem(ContextMenu):
|
||||
class RemoveItem(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from gui.itemStats import ItemStatsDialog
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class ItemStats(ContextMenu):
|
||||
class ItemStats(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
@@ -3,13 +3,13 @@ import wx
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class ChangeItemToVariation(ContextMenu):
|
||||
class ChangeItemToVariation(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
@@ -119,11 +119,11 @@ class ChangeItemToVariation(ContextMenu):
|
||||
|
||||
if thisgroup != group and context not in ('implantItem', 'boosterItem'):
|
||||
group = thisgroup
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
m.Append(id, '─ %s ─' % group)
|
||||
m.Enable(id, False)
|
||||
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
mitem = wx.MenuItem(rootMenu, id, item.name)
|
||||
bindmenu.Bind(wx.EVT_MENU, self.handleModule, mitem)
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ import gui.mainFrame
|
||||
from eos.const import FittingHardpoint
|
||||
from eos.saveddata.module import Module
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from gui.fitCommands.helpers import getSimilarModPositions
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class ChangeModuleAmmo(ContextMenu):
|
||||
class ChangeModuleAmmo(ContextMenuCombined):
|
||||
|
||||
DAMAGE_TYPES = ("em", "explosive", "kinetic", "thermal")
|
||||
MISSILE_ORDER = ("em", "thermal", "kinetic", "explosive", "mixed")
|
||||
@@ -118,7 +118,7 @@ class ChangeModuleAmmo(ContextMenu):
|
||||
return list(map(self.numericConverter, parts))
|
||||
|
||||
def addCharge(self, menu, charge):
|
||||
id_ = ContextMenu.nextID()
|
||||
id_ = ContextMenuCombined.nextID()
|
||||
name = charge.name if charge is not None else "Empty"
|
||||
self.chargeIds[id_] = charge
|
||||
item = wx.MenuItem(menu, id_, name)
|
||||
@@ -133,7 +133,7 @@ class ChangeModuleAmmo(ContextMenu):
|
||||
|
||||
@staticmethod
|
||||
def addSeperator(m, text):
|
||||
id_ = ContextMenu.nextID()
|
||||
id_ = ContextMenuCombined.nextID()
|
||||
m.Append(id_, '─ %s ─' % text)
|
||||
m.Enable(id_, False)
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class FillWithModule(ContextMenu):
|
||||
class FillWithModule(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from gui.fitCommands import GuiConvertMutatedLocalModuleCommand, GuiRevertMutatedLocalModuleCommand
|
||||
from service.settings import ContextMenuSettings
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class ChangeModuleMutation(ContextMenu):
|
||||
class ChangeModuleMutation(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -42,7 +42,7 @@ class ChangeModuleMutation(ContextMenu):
|
||||
|
||||
for item in mainItem.item.mutaplasmids:
|
||||
label = item.item.name
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
self.eventIDs[id] = (item, mainItem)
|
||||
skillItem = wx.MenuItem(menu, id, label)
|
||||
menu.Bind(wx.EVT_MENU, self.handleMenu, skillItem)
|
||||
|
||||
@@ -5,12 +5,12 @@ import eos.config
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from eos.utils.spoolSupport import SpoolType, SpoolOptions
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.settings import ContextMenuSettings
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class ChangeModuleSpool(ContextMenu):
|
||||
class ChangeModuleSpool(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -50,7 +50,7 @@ class ChangeModuleSpool(ContextMenu):
|
||||
cycleMax = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, 1, True))[0]
|
||||
|
||||
for cycle in range(cycleMin, cycleMax + 1):
|
||||
menuId = ContextMenu.nextID()
|
||||
menuId = ContextMenuCombined.nextID()
|
||||
|
||||
# Show default only for current value and when not overriden
|
||||
if not isNotDefault and cycle == cycleDefault:
|
||||
@@ -64,7 +64,7 @@ class ChangeModuleSpool(ContextMenu):
|
||||
item.Check(isNotDefault and cycle == cycleCurrent)
|
||||
self.cycleMap[menuId] = cycle
|
||||
|
||||
self.resetId = ContextMenu.nextID()
|
||||
self.resetId = ContextMenuCombined.nextID()
|
||||
item = wx.MenuItem(m, self.resetId, "Reset")
|
||||
bindmenu.Bind(wx.EVT_MENU, self.handleSpoolChange, item)
|
||||
m.Append(item)
|
||||
|
||||
@@ -4,11 +4,11 @@ import wx
|
||||
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.settings import MarketPriceSettings
|
||||
|
||||
|
||||
class ItemGroupPrice(ContextMenu, metaclass=ABCMeta):
|
||||
class ItemGroupPrice(ContextMenuCombined, metaclass=ABCMeta):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -3,12 +3,12 @@ import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui.builtinShipBrowser.events import Stage3Selected
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class JumpToShip(ContextMenu):
|
||||
class JumpToShip(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
@@ -3,12 +3,12 @@ import wx
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class ChangeShipTacticalMode(ContextMenu):
|
||||
class ChangeShipTacticalMode(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -32,7 +32,7 @@ class ChangeShipTacticalMode(ContextMenu):
|
||||
|
||||
def addMode(self, menu, mode):
|
||||
label = mode.item.name.rsplit()[-2]
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
self.modeIds[id] = mode
|
||||
menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_RADIO)
|
||||
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
|
||||
|
||||
@@ -5,13 +5,13 @@ import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from eos.saveddata.character import Skill
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.character import Character
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
|
||||
class ChangeAffectingSkills(ContextMenu):
|
||||
class ChangeAffectingSkills(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
@@ -78,7 +78,7 @@ class ChangeAffectingSkills(ContextMenu):
|
||||
else:
|
||||
label = "Level %s" % i
|
||||
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
self.skillIds[id] = (skill, i)
|
||||
menuItem = wx.MenuItem(rootMenu, id, label, kind=wx.ITEM_RADIO)
|
||||
rootMenu.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
|
||||
@@ -90,7 +90,7 @@ class ChangeAffectingSkills(ContextMenu):
|
||||
sub = wx.Menu()
|
||||
|
||||
for skill in self.skills:
|
||||
skillItem = wx.MenuItem(sub, ContextMenu.nextID(), skill.item.name)
|
||||
skillItem = wx.MenuItem(sub, ContextMenuCombined.nextID(), skill.item.name)
|
||||
grandSub = wx.Menu()
|
||||
skillItem.SetSubMenu(grandSub)
|
||||
if skill.learned:
|
||||
|
||||
@@ -6,13 +6,13 @@ import wx
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.contextMenu import ContextMenuCombined
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
from service.targetResists import TargetResists as svc_TargetResists
|
||||
|
||||
|
||||
class TargetResists(ContextMenu):
|
||||
class TargetResists(ContextMenuCombined):
|
||||
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
@@ -43,7 +43,7 @@ class TargetResists(ContextMenu):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
def addPattern(self, rootMenu, pattern):
|
||||
id = ContextMenu.nextID()
|
||||
id = ContextMenuCombined.nextID()
|
||||
name = getattr(pattern, "_name", pattern.name) if pattern is not None else "No Profile"
|
||||
|
||||
self.patternIds[id] = pattern
|
||||
@@ -93,7 +93,7 @@ class TargetResists(ContextMenu):
|
||||
# Items that have a parent
|
||||
for menuName, patterns in list(self.subMenus.items()):
|
||||
# Create parent item for root menu that is simply name of parent
|
||||
item = wx.MenuItem(rootMenu, ContextMenu.nextID(), menuName)
|
||||
item = wx.MenuItem(rootMenu, ContextMenuCombined.nextID(), menuName)
|
||||
|
||||
# Create menu for child items
|
||||
grandSub = wx.Menu()
|
||||
|
||||
@@ -17,14 +17,18 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class ContextMenu(object):
|
||||
class ContextMenu(metaclass=ABCMeta):
|
||||
|
||||
menus = []
|
||||
_ids = [] # [wx.NewId() for x in xrange(200)] # init with decent amount
|
||||
_idxid = -1
|
||||
@@ -81,14 +85,14 @@ class ContextMenu(object):
|
||||
for menuHandler in cls.menus:
|
||||
# loop through registered menus
|
||||
m = menuHandler()
|
||||
if m.display(srcContext, mainItem, selection):
|
||||
if m._baseDisplay(srcContext, mainItem, selection):
|
||||
display_amount += 1
|
||||
texts = m.getText(itemContext, mainItem, selection)
|
||||
texts = m._baseGetText(itemContext, mainItem, selection)
|
||||
|
||||
if isinstance(texts, str):
|
||||
texts = (texts,)
|
||||
|
||||
bitmap = m.getBitmap(srcContext, mainItem, selection)
|
||||
bitmap = m._baseGetBitmap(srcContext, mainItem, selection)
|
||||
multiple = not isinstance(bitmap, wx.Bitmap)
|
||||
for it, text in enumerate(texts):
|
||||
id = cls.nextID()
|
||||
@@ -96,7 +100,7 @@ class ContextMenu(object):
|
||||
rootItem = wx.MenuItem(rootMenu, id, text, kind=wx.ITEM_NORMAL if m.checked is None else wx.ITEM_CHECK)
|
||||
rootMenu.info[id] = (m, fullContext, it)
|
||||
|
||||
sub = m.getSubMenu(srcContext, mainItem, selection, rootMenu, it, rootItem)
|
||||
sub = m._baseGetSubMenu(srcContext, mainItem, selection, rootMenu, it, rootItem)
|
||||
|
||||
if sub is None:
|
||||
# if there is no sub menu, bind the handler to the rootItem
|
||||
@@ -154,19 +158,10 @@ class ContextMenu(object):
|
||||
if not hasattr(selection, "__iter__"):
|
||||
selection = (selection,)
|
||||
|
||||
menuHandler.activate(context, mainItem, selection, i)
|
||||
menuHandler._baseActivate(context, mainItem, selection, i)
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
def display(self, context, mainItem, selection):
|
||||
raise NotImplementedError()
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
return None
|
||||
|
||||
def getSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def nextID(cls):
|
||||
"""
|
||||
@@ -183,19 +178,6 @@ class ContextMenu(object):
|
||||
|
||||
return cls._ids[cls._idxid]
|
||||
|
||||
def getText(self, context, mainItem, selection):
|
||||
"""
|
||||
getText should be implemented in child classes, and should return either
|
||||
a string that will make up a menu item label or a list of strings which
|
||||
will make numerous menu items.
|
||||
|
||||
These menu items will be added to the root menu
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def getBitmap(self, context, mainItem, selection):
|
||||
return None
|
||||
|
||||
@property
|
||||
def checked(self):
|
||||
'''If menu item is toggleable, this should return bool value'''
|
||||
@@ -206,4 +188,188 @@ class ContextMenu(object):
|
||||
'''If menu item is enabled. Allows an item to display, but not be selected'''
|
||||
return True
|
||||
|
||||
@abstractmethod
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
"""
|
||||
getText should be implemented in child classes, and should return either
|
||||
a string that will make up a menu item label or a list of strings which
|
||||
will make numerous menu items.
|
||||
|
||||
These menu items will be added to the root menu
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class ContextMenuUnconditional(ContextMenu, metaclass=ABCMeta):
|
||||
"""
|
||||
Should be used for context menus which do not depend on which item
|
||||
has been clicked and what current selection is.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def display(self, context):
|
||||
raise NotImplementedError
|
||||
|
||||
def getBitmap(self, context):
|
||||
return
|
||||
|
||||
@abstractmethod
|
||||
def getText(self, context):
|
||||
raise NotImplementedError
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
return
|
||||
|
||||
def activate(self, fullContext, i):
|
||||
return
|
||||
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
return self.display(context)
|
||||
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
return self.getBitmap(context)
|
||||
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
return self.getText(context)
|
||||
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return self.getSubMenu(context, rootMenu, i, pitem)
|
||||
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
return self.activate(fullContext, i)
|
||||
|
||||
|
||||
class ContextMenuSingle(ContextMenu, metaclass=ABCMeta):
|
||||
"""
|
||||
Should be used for context menus which depend on
|
||||
which item was clicked, but not on selection.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def display(self, context, mainItem):
|
||||
raise NotImplementedError
|
||||
|
||||
def getBitmap(self, context, mainItem):
|
||||
return
|
||||
|
||||
@abstractmethod
|
||||
def getText(self, context, mainItem):
|
||||
raise NotImplementedError
|
||||
|
||||
def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
|
||||
return
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
return
|
||||
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
return self.display(context, mainItem)
|
||||
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
return self.getBitmap(context, mainItem)
|
||||
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
return self.getText(context, mainItem)
|
||||
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return self.getSubMenu(context, mainItem, rootMenu, i, pitem)
|
||||
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
return self.activate(fullContext, mainItem, i)
|
||||
|
||||
|
||||
class ContextMenuSelection(ContextMenu, metaclass=ABCMeta):
|
||||
"""
|
||||
Should be used for context menus which depend on
|
||||
which items are selected, but not which clicked.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def display(self, context, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
def getBitmap(self, context, selection):
|
||||
return
|
||||
|
||||
@abstractmethod
|
||||
def getText(self, context, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
return
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
return
|
||||
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
return self.display(context, selection)
|
||||
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
return self.getBitmap(context, selection)
|
||||
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
return self.getText(context, selection)
|
||||
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return self.getSubMenu(context, selection, rootMenu, i, pitem)
|
||||
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
return self.activate(fullContext, selection, i)
|
||||
|
||||
|
||||
class ContextMenuCombined(ContextMenu, metaclass=ABCMeta):
|
||||
"""
|
||||
Should be used for context menus which depend on both which
|
||||
item has been clicked and which items are selected.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def display(self, context, mainItem, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
def getBitmap(self, context, mainItem, selection):
|
||||
return
|
||||
|
||||
@abstractmethod
|
||||
def getText(self, context, mainItem, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
def getSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
return
|
||||
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
return self.display(context, mainItem, selection)
|
||||
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
return self.getBitmap(context, mainItem, selection)
|
||||
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
return self.getText(context, mainItem, selection)
|
||||
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return self.getSubMenu(context, mainItem, selection, rootMenu, i, pitem)
|
||||
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
return self.activate(fullContext, mainItem, selection, i)
|
||||
|
||||
|
||||
import gui.builtinContextMenus
|
||||
|
||||
Reference in New Issue
Block a user