Exemplo n.º 1
0
 def spawnMenu(self):
     sel = self.GetFirstSelected()
     menu = None
     if sel != -1:
         item = self.get(sel)
         sMkt = service.Market.getInstance()
         if isinstance(item, eos.types.Drone):
             srcContext = "projectedDrone"
             itemContext = sMkt.getCategoryByItem(item.item).name
             context = ((srcContext, itemContext),)
         elif isinstance(item, eos.types.Module):
             modSrcContext = "projectedModule"
             modItemContext = sMkt.getCategoryByItem(item.item).name
             modFullContext = (modSrcContext, modItemContext)
             if item.charge is not None:
                 chgSrcContext = "projectedCharge"
                 chgItemContext = sMkt.getCategoryByItem(item.charge).name
                 chgFullContext = (chgSrcContext, chgItemContext)
                 context = (modFullContext, chgFullContext)
             else:
                 context = (modFullContext,)
         else:
             fitSrcContext = "projectedFit"
             fitItemContext = item.name
             context = ((fitSrcContext, fitItemContext),)
         context = context + (("projected",),)
         menu = ContextMenu.getMenu((item,), *context)
     elif sel == -1:
         fitID = self.mainFrame.getActiveFit()
         if fitID is None:
             return
         context = (("projected",),)
         menu = ContextMenu.getMenu([], *context)
     if menu is not None:
         self.PopupMenu(menu)
Exemplo n.º 2
0
    def spawnMenu(self):
        sel = self.GetFirstSelected()
        menu = None

        sFit = Fit.getInstance()
        fit = sFit.getFit(self.mainFrame.getActiveFit())

        if not fit:
            return

        if sel != -1:
            implant = fit.appliedImplants[sel]

            sMkt = Market.getInstance()
            sourceContext = "implantItem" if fit.implantSource == ImplantLocation.FIT else "implantItemChar"
            itemContext = sMkt.getCategoryByItem(implant.item).name

            menu = ContextMenu.getMenu((implant,), (sourceContext, itemContext))
        elif sel == -1 and fit.implantSource == ImplantLocation.FIT:
            fitID = self.mainFrame.getActiveFit()
            if fitID is None:
                return
            context = (("implantView",),)
            menu = ContextMenu.getMenu([], *context)
        if menu is not None:
            self.PopupMenu(menu)
Exemplo n.º 3
0
    def __init__(self, parent):
        wx.Panel.__init__ (self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.TAB_TRAVERSAL)
        self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))

        pmainSizer = wx.BoxSizer(wx.VERTICAL)

        tree = self.skillTreeListCtrl = wx.gizmos.TreeListCtrl(self, wx.ID_ANY, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT)
        pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5)


        self.imageList = wx.ImageList(16, 16)
        tree.SetImageList(self.imageList)
        self.skillBookImageId = self.imageList.Add(BitmapLoader.getBitmap("skill_small", "gui"))

        tree.AddColumn("Skill")
        tree.AddColumn("Level")
        tree.SetMainColumn(0)

        self.root = tree.AddRoot("Skills")
        tree.SetItemText(self.root, "Levels", 1)

        tree.SetColumnWidth(0, 500)

        self.populateSkillTree()

        tree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.expandLookup)
        tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.scheduleMenu)

        srcContext = "skillItem"
        itemContext = "Skill"
        context = (srcContext, itemContext)
        self.statsMenu = ContextMenu.getMenu(None, context)
        self.levelChangeMenu = ContextMenu.getMenu(None, context) or wx.Menu()
        self.levelChangeMenu.AppendSeparator()
        self.levelIds = {}

        idUnlearned = wx.NewId()
        self.levelIds[idUnlearned] = "Not learned"
        self.levelChangeMenu.Append(idUnlearned, "Unlearn")

        for level in xrange(6):
            id = wx.NewId()
            self.levelIds[id] = level
            self.levelChangeMenu.Append(id, "Level %d" % level)

        self.levelChangeMenu.AppendSeparator()
        self.revertID = wx.NewId()
        self.levelChangeMenu.Append(self.revertID, "Revert")


        self.saveID = wx.NewId()
        self.levelChangeMenu.Append(self.saveID, "Save")

        self.levelChangeMenu.Bind(wx.EVT_MENU, self.changeLevel)
        self.SetSizer(pmainSizer)

        self.Layout()
Exemplo n.º 4
0
    def spawnMenu(self, event):
        item = event.GetItem()
        self.skillTreeListCtrl.Select(item)
        thing = self.skillTreeListCtrl.GetFirstChild(item).IsOk()
        if thing:
            return

        id = self.skillTreeListCtrl.GetItemData(item)[1]
        eveItem = Market.getInstance().getItem(id)

        srcContext = "skillItem"
        itemContext = "Skill"
        context = (srcContext, itemContext)
        menu = ContextMenu.getMenu(eveItem, [eveItem], context)
        char = self.charEditor.entityEditor.getActiveEntity()
        if char.name not in ("All 0", "All 5"):
            menu.AppendSeparator()
            menu.Append(self.idUnlearned, "Unlearn")
            for level in range(6):
                menu.Append(self.idLevels[level], "Level %d" % level)
            # Doesn't make sense to have these menu items here, as they do not revert skill changes
            # done in an editor - because these changes are persisted anyway
            # menu.AppendSeparator()
            # menu.Append(self.revertID, "Revert")
            # menu.Append(self.saveID, "Save")
            menu.Bind(wx.EVT_MENU, self.changeLevel)

        self.PopupMenu(menu)
Exemplo n.º 5
0
    def spawnMenu(self):
        if self.activeFitID is None:
            return

        sMkt = service.Market.getInstance()
        selection = []
        sel = self.GetFirstSelected()
        contexts = []

        while sel != -1:
            mod = self.mods[self.GetItemData(sel)]
            if not mod.isEmpty:
                srcContext = "fittingModule"
                itemContext = sMkt.getCategoryByItem(mod.item).name
                fullContext = (srcContext, itemContext)
                if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
                    contexts.append(fullContext)
                if mod.charge is not None:
                    srcContext = "fittingCharge"
                    itemContext = sMkt.getCategoryByItem(mod.charge).name
                    fullContext = (srcContext, itemContext)
                    if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
                        contexts.append(fullContext)

                selection.append(mod)

            sel = self.GetNextSelected(sel)

        contexts.append(("fittingShip", "Ship"))

        menu = ContextMenu.getMenu(selection, *contexts)
        self.PopupMenu(menu)
Exemplo n.º 6
0
    def click(self, event):
        event.Skip()
        row, _ = self.HitTest(event.Position)
        if row != -1:
            item = self.get(row)
            col = self.getColumn(event.Position)
            if col == self.getColIndex(State):
                fitID = self.mainFrame.getActiveFit()
                cFit = service.Fit.getInstance()
                cFit.toggleProjected(fitID, item, "right" if event.Button == 3 else "left")
                wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID))
            elif event.Button == 3:
                if isinstance(item, eos.types.Drone):
                    context = ("projectedDrone",)
                elif isinstance(item, eos.types.Module):
                    if item.charge is not None:
                        context = ("projectedModule", "projectedAmmo")
                    else:
                        context = ("projectedModule",)
                else:
                    context = ("projectedFit",)

                menu = ContextMenu.getMenu((item,), *context)
                if menu is not None:
                    self.PopupMenu(menu)
Exemplo n.º 7
0
    def spawnMenu(self):
        sel = self.GetFirstSelected()
        if sel != -1:
            cFit = service.Fit.getInstance()
            fit = cFit.getFit(self.mainFrame.getActiveFit())

            menu = ContextMenu.getMenu((fit.boosters[sel],), "booster")
            self.PopupMenu(menu)
Exemplo n.º 8
0
    def spawnMenu(self):
        sel = self.GetFirstSelected()
        if sel != -1:
            fighter = self.fighters[sel]

            sMkt = service.Market.getInstance()
            sourceContext = "fighterItem"
            itemContext = sMkt.getCategoryByItem(fighter.item).name
            menu = ContextMenu.getMenu((fighter,), (sourceContext, itemContext))
            self.PopupMenu(menu)
Exemplo n.º 9
0
    def spawnMenu(self):
        context = (("implantEditor",),)
        # f**k good coding practices, passing a pointer to the character editor here for [reasons] =D
        # (see implantSets context class for info)
        menu = ContextMenu.getMenu((self.Parent.Parent,), *context)

        if menu:
            self.PopupMenu(menu)
        else:
            pyfalog.debug("ContextMenu.getMenu returned false do not attempt PopupMenu")
Exemplo n.º 10
0
    def spawnMenu(self, event):
        sel = self.GetFirstSelected()
        if sel != -1:
            sFit = Fit.getInstance()
            item = self.boosters[sel]

            srcContext = "boosterItem"
            itemContext = "Booster"
            menu = ContextMenu.getMenu((item,), (srcContext, itemContext))
            self.PopupMenu(menu)
Exemplo n.º 11
0
    def spawnMenu(self):
        sel = self.GetFirstSelected()
        if sel != -1:
            drone = self.drones[sel]

            sMkt = service.Market.getInstance()
            sourceContext = "droneItem"
            itemContext = sMkt.getCategoryByItem(drone.item).name
            menu = ContextMenu.getMenu((drone,), (sourceContext, itemContext))
            self.PopupMenu(menu)
Exemplo n.º 12
0
 def spawnMenu(self):
     sel = self.GetFirstSelected()
     menu = None
     if sel != -1:
         item = self.get(sel)
         if item is None: return
         sMkt = service.Market.getInstance()
         fitSrcContext = "commandFit"
         fitItemContext = item.name
         context = ((fitSrcContext,fitItemContext),)
         context = context + (("command",),)
         menu = ContextMenu.getMenu((item,), *context)
     elif sel == -1:
         fitID = self.mainFrame.getActiveFit()
         if fitID is None:
             return
         context = (("command",),)
         menu = ContextMenu.getMenu([], *context)
     if menu is not None:
         self.PopupMenu(menu)
Exemplo n.º 13
0
    def spawnMenu(self):
        sel = self.GetFirstSelected()
        if sel != -1:
            sFit = Fit.getInstance()
            fit = sFit.getFit(self.mainFrame.getActiveFit())
            item = fit.boosters[sel]

            srcContext = "boosterItem"
            itemContext = "Booster"
            menu = ContextMenu.getMenu((item,), (srcContext, itemContext))
            self.PopupMenu(menu)
Exemplo n.º 14
0
 def click(self, event):
     event.Skip()
     row, _ = self.HitTest(event.Position)
     if row != -1:
         item = self.get(row)
         col = self.getColumn(event.Position)
         if col == self.getColIndex(State):
             fitID = self.mainFrame.getActiveFit()
             sFit = service.Fit.getInstance()
             sFit.toggleProjected(fitID, item, "right" if event.Button == 3 else "left")
             wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
         elif event.Button == 3:
             sMkt = service.Market.getInstance()
             if isinstance(item, eos.types.Drone):
                 srcContext = "projectedDrone"
                 itemContext = sMkt.getCategoryByItem(item.item).name
                 context = ((srcContext, itemContext),)
             elif isinstance(item, eos.types.Module):
                 modSrcContext = "projectedModule"
                 modItemContext = sMkt.getCategoryByItem(item.item).name
                 modFullContext = (modSrcContext, modItemContext)
                 if item.charge is not None:
                     chgSrcContext = "projectedCharge"
                     chgItemContext = sMkt.getCategoryByItem(item.charge).name
                     chgFullContext = (chgSrcContext, chgItemContext)
                     context = (modFullContext, chgFullContext)
                 else:
                     context = (modFullContext,)
             else:
                 context = (("projectedFit",),)
             menu = ContextMenu.getMenu((item,), *context)
             if menu is not None:
                 self.PopupMenu(menu)
     elif row == -1 and event.Button == 3:
         fitID = self.mainFrame.getActiveFit()
         if fitID is None:
             return
         context = (("projectedNone",),)
         menu = ContextMenu.getMenu([], *context)
         if menu is not None:
             self.PopupMenu(menu)
Exemplo n.º 15
0
    def spawnMenu(self):
        sel = self.GetFirstSelected()
        if sel != -1:
            sFit = service.Fit.getInstance()
            fit = sFit.getFit(self.mainFrame.getActiveFit())
            implant = fit.implants[sel]

            sMkt = service.Market.getInstance()
            sourceContext = "implantItem"
            itemContext = sMkt.getCategoryByItem(implant.item).name

            menu = ContextMenu.getMenu((implant,), (sourceContext, itemContext))
            self.PopupMenu(menu)
Exemplo n.º 16
0
    def spawnMenu(self):
        sel = self.GetFirstSelected()
        if sel != -1:
            cFit = service.Fit.getInstance()
            fit = cFit.getFit(self.mainFrame.getActiveFit())
            cargo = fit.cargo[sel]

            sMkt = service.Market.getInstance()
            sourceContext = "cargoItem"
            itemContext = sMkt.getCategoryByItem(cargo.item).name

            menu = ContextMenu.getMenu((cargo,), (sourceContext, itemContext))
            self.PopupMenu(menu)
Exemplo n.º 17
0
    def contextMenu(self, event):
        # Check if something is selected, if so, spawn the menu for it
        sel = self.GetFirstSelected()
        if sel == -1:
            return

        item = self.active[sel]

        sMkt = self.sMkt
        sourceContext = "marketItemGroup" if self.marketBrowser.searchMode is False else "marketItemMisc"
        itemContext = sMkt.getCategoryByItem(item).name

        menu = ContextMenu.getMenu((item,), (sourceContext, itemContext))
        self.PopupMenu(menu)
Exemplo n.º 18
0
    def spawnMenu(self):
        if self.activeFitID is None:
            return

        sMkt = service.Market.getInstance()
        selection = []
        sel = self.GetFirstSelected()
        contexts = []

        while sel != -1 and sel not in self.blanks:
            mod = self.mods[self.GetItemData(sel)]

            # Test if this is a mode, which is a special snowflake of a Module
            if isinstance(mod, Mode):
                srcContext = "fittingMode"

                itemContext = "Tactical Mode"
                fullContext = (srcContext, itemContext)
                if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
                    contexts.append(fullContext)

                selection.append(mod)

            elif not mod.isEmpty:
                srcContext = "fittingModule"
                itemContext = sMkt.getCategoryByItem(mod.item).name
                fullContext = (srcContext, itemContext)
                if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
                    contexts.append(fullContext)


                if mod.charge is not None:
                    srcContext = "fittingCharge"
                    itemContext = sMkt.getCategoryByItem(mod.charge).name
                    fullContext = (srcContext, itemContext)
                    if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
                        contexts.append(fullContext)

                selection.append(mod)

            sel = self.GetNextSelected(sel)

        sFit = service.Fit.getInstance()
        fit = sFit.getFit(self.activeFitID)

        contexts.append(("fittingShip", "Ship" if not fit.isStructure else "Citadel"))

        menu = ContextMenu.getMenu(selection, *contexts)
        self.PopupMenu(menu)
Exemplo n.º 19
0
    def spawnMenu(self, item):
        self.affectedBy.SelectItem(item)

        stuff = self.affectedBy.GetPyData(item)
        # String is set as data when we are dealing with attributes, not stuff containers
        if stuff is None or isinstance(stuff, basestring):
            return
        contexts = []

        # Skills are different in that they don't have itemModifiedAttributes,
        # which is needed if we send the container to itemStats dialog. So
        # instead, we send the item.
        type = stuff.__class__.__name__
        contexts.append(("itemStats", type))
        menu = ContextMenu.getMenu(stuff if type != "Skill" else stuff.item, *contexts)
        self.PopupMenu(menu)
Exemplo n.º 20
0
 def spawnMenu(self, event):
     selection = self.getSelectedCommandFits()
     clickedPos = self.getRowByAbs(event.Position)
     mainCommandFit = None
     if clickedPos != -1:
         try:
             mainCommandFit = self.fits[clickedPos]
         except IndexError:
             pass
     contexts = []
     if mainCommandFit is not None:
         contexts.append(('commandFit', 'Command Fit'))
     contexts.append(('commandView',))
     menu = ContextMenu.getMenu(mainCommandFit, selection, *contexts)
     if menu:
         self.PopupMenu(menu)
Exemplo n.º 21
0
    def contextMenu(self, event):
        #Check if something is selected, if so, spawn the menu for it
        sel = self.GetFirstSelected()
        if sel == -1:
            return

        item = self.active[sel]
        # We were searching, this means that our results come from the worker thread
        # Refetch items, else it'll try to reuse the object fetched in the other thread
        # Which makes it go BOOM CRACK DOOM
        if self.searching:
            sMarket = service.Market.getInstance()
            item = sMarket.getItem(item.ID)

        menu = ContextMenu.getMenu((item,), "item" if self.searching is False else "itemSearch")
        self.PopupMenu(menu)
Exemplo n.º 22
0
 def spawnMenu(self, event):
     selection = self.getSelectedFighters()
     clickedPos = self.getRowByAbs(event.Position)
     mainFighter = None
     if clickedPos != -1:
         try:
             fighter = self.fighters[clickedPos]
         except IndexError:
             pass
         else:
             if fighter in self.original:
                 mainFighter = fighter
     sourceContext = "fighterItem"
     itemContext = None if mainFighter is None else Market.getInstance().getCategoryByItem(mainFighter.item).name
     menu = ContextMenu.getMenu(mainFighter, selection, (sourceContext, itemContext))
     if menu:
         self.PopupMenu(menu)
Exemplo n.º 23
0
 def spawnMenu(self, event):
     selection = self.getSelectedBoosters()
     clickedPos = self.getRowByAbs(event.Position)
     mainBooster = None
     if clickedPos != -1:
         try:
             booster = self.boosters[clickedPos]
         except IndexError:
             pass
         else:
             if booster in self.original:
                 mainBooster = booster
     sourceContext = "boosterItem"
     itemContext = None if mainBooster is None else "Booster"
     menu = ContextMenu.getMenu(mainBooster, selection, (sourceContext, itemContext))
     if menu:
         self.PopupMenu(menu)
Exemplo n.º 24
0
    def spawnMenu(self, event):
        fitID = self.mainFrame.getActiveFit()
        if fitID is None:
            return

        if self.getColumn(self.screenToClientFixed(event.Position)) == self.getColIndex(State):
            return

        clickedPos = self.getRowByAbs(event.Position)
        mainItem = self.get(clickedPos)

        contexts = []
        if mainItem is not None:
            sMkt = Market.getInstance()

            if isinstance(mainItem, EosModule):
                modSrcContext = 'projectedModule'
                modItemContext = 'Projected Item'
                modFullContext = (modSrcContext, modItemContext)
                contexts.append(modFullContext)
                if mainItem.charge is not None:
                    chargeSrcContext = 'projectedCharge'
                    chargeItemContext = sMkt.getCategoryByItem(mainItem.charge).name
                    chargeFullContext = (chargeSrcContext, chargeItemContext)
                    contexts.append(chargeFullContext)
            elif isinstance(mainItem, EosDrone):
                srcContext = 'projectedDrone'
                itemContext = 'Projected Item'
                droneFullContext = (srcContext, itemContext)
                contexts.append(droneFullContext)
            elif isinstance(mainItem, EosFighter):
                srcContext = 'projectedFighter'
                itemContext = 'Projected Item'
                fighterFullContext = (srcContext, itemContext)
                contexts.append(fighterFullContext)
            else:
                fitSrcContext = 'projectedFit'
                fitItemContext = 'Projected Item'
                fitFullContext = (fitSrcContext, fitItemContext)
                contexts.append(fitFullContext)
        contexts.append(('projected',))

        selection = self.getSelectedProjectors()
        menu = ContextMenu.getMenu(mainItem, selection, *contexts)
        if menu is not None:
            self.PopupMenu(menu)
Exemplo n.º 25
0
 def spawnMenu(self, event):
     selection = self.getSelectedCargos()
     clickedPos = self.getRowByAbs(event.Position)
     mainCargo = None
     if clickedPos != -1:
         try:
             cargo = self.cargo[clickedPos]
         except IndexError:
             pass
         else:
             if cargo in self.original:
                 mainCargo = cargo
     sourceContext = "cargoItem"
     itemContext = None if mainCargo is None else Market.getInstance().getCategoryByItem(mainCargo.item).name
     menu = ContextMenu.getMenu(mainCargo, selection, (sourceContext, itemContext))
     if menu:
         self.PopupMenu(menu)
Exemplo n.º 26
0
    def spawnMenu(self, event):
        clickedPos = self.getRowByAbs(event.Position)
        self.ensureSelection(clickedPos)

        selection = self.getSelectedBoosters()
        mainBooster = None
        if clickedPos != -1:
            try:
                booster = self.boosters[clickedPos]
            except IndexError:
                pass
            else:
                if booster in self.original:
                    mainBooster = booster
        itemContext = None if mainBooster is None else "Booster"
        menu = ContextMenu.getMenu(self, mainBooster, selection, ("boosterItem", itemContext), ("boosterItemMisc", itemContext))
        if menu:
            self.PopupMenu(menu)
Exemplo n.º 27
0
    def spawnMenu(self, event):
        clickedPos = self.getRowByAbs(event.Position)
        self.ensureSelection(clickedPos)

        mainDrone = None
        if clickedPos != -1:
            try:
                drone = self.drones[clickedPos]
            except IndexError:
                pass
            else:
                if drone in self.original:
                    mainDrone = drone
        selection = self.getSelectedDrones()
        itemContext = None if mainDrone is None else Market.getInstance().getCategoryByItem(mainDrone.item).name
        menu = ContextMenu.getMenu(self, mainDrone, selection, ("droneItem", itemContext), ("droneItemMisc", itemContext))
        if menu:
            self.PopupMenu(menu)
Exemplo n.º 28
0
    def spawnMenu(self, event):
        item, _ = self.affectedBy.HitTest(self.ScreenToClient(event.Position))
        self.affectedBy.SelectItem(item)

        stuff = self.affectedBy.GetItemData(item)
        # String is set as data when we are dealing with attributes, not stuff containers
        if stuff is None or isinstance(stuff, str):
            return
        contexts = []

        # Skills are different in that they don't have itemModifiedAttributes,
        # which is needed if we send the container to itemStats dialog. So
        # instead, we send the item.
        type_ = stuff.__class__.__name__
        contexts.append(("itemStats", type_))
        stuff = stuff if type_ != "Skill" else stuff.item
        menu = ContextMenu.getMenu(stuff, (stuff,), *contexts)
        self.PopupMenu(menu)
Exemplo n.º 29
0
    def spawnMenu(self):
        fitID = self.mainFrame.getActiveFit()
        if fitID is None:
            return

        sel = self.GetFirstSelected()
        context = ()
        item = self.get(sel)

        if item is not None:
            fitSrcContext = "commandFit"
            fitItemContext = item.name
            context = ((fitSrcContext, fitItemContext),)

        context += (("commandView",),)
        menu = ContextMenu.getMenu((item,) if item is not None else [], *context)
        if menu is not None:
            self.PopupMenu(menu)
Exemplo n.º 30
0
    def spawnMenu(self, event):
        fitID = self.mainFrame.getActiveFit()
        if fitID is None:
            return

        sel = self.GetFirstSelected()
        context = ()
        item = self.get(sel)

        if item is not None:
            fitSrcContext = "commandFit"
            fitItemContext = item.name
            context = ((fitSrcContext, fitItemContext),)

        context += (("commandView",),)
        menu = ContextMenu.getMenu((item,) if item is not None else [], *context)
        if menu is not None:
            self.PopupMenu(menu)
Exemplo n.º 31
0
    def spawnMenu(self, event):
        clickedPos = self.getRowByAbs(event.Position)
        self.ensureSelection(clickedPos)

        selection = self.getSelectedFighters()
        mainFighter = None
        if clickedPos != -1:
            try:
                fighter = self.fighters[clickedPos]
            except IndexError:
                pass
            else:
                if fighter in self.original:
                    mainFighter = fighter
        itemContext = None if mainFighter is None else Market.getInstance().getCategoryByItem(mainFighter.item).name
        menu = ContextMenu.getMenu(self, mainFighter, selection, ("fighterItem", itemContext), ("fighterItemMisc", itemContext))
        if menu:
            self.PopupMenu(menu)
Exemplo n.º 32
0
    def spawnMenu(self, event):
        clickedPos = self.getRowByAbs(event.Position)
        self.ensureSelection(clickedPos)

        selection = self.getSelectedCommandFits()
        mainCommandFit = None
        if clickedPos != -1:
            try:
                mainCommandFit = self.fits[clickedPos]
            except IndexError:
                pass
        contexts = []
        if mainCommandFit is not None:
            contexts.append(('commandFit', 'Command Fit'))
        contexts.append(('commandView', ))
        menu = ContextMenu.getMenu(self, mainCommandFit, selection, *contexts)
        if menu:
            self.PopupMenu(menu)
Exemplo n.º 33
0
    def spawnMenu(self, event):
        fitID = self.mainFrame.getActiveFit()
        if fitID is None:
            return

        if self.getColumn(self.ScreenToClient(event.Position)) == self.getColIndex(State):
            return

        sel = self.GetFirstSelected()
        context = ()
        item = self.get(sel)

        if item is not None:
            sMkt = Market.getInstance()

            if isinstance(item, es_Drone):
                srcContext = "projectedDrone"
                itemContext = sMkt.getCategoryByItem(item.item).name
                context = ((srcContext, itemContext),)
            elif isinstance(item, es_Fighter):
                srcContext = "projectedFighter"
                itemContext = sMkt.getCategoryByItem(item.item).name
                context = ((srcContext, itemContext),)
            elif isinstance(item, es_Module):
                modSrcContext = "projectedModule"
                modItemContext = sMkt.getCategoryByItem(item.item).name
                modFullContext = (modSrcContext, modItemContext)
                if item.charge is not None:
                    chgSrcContext = "projectedCharge"
                    chgItemContext = sMkt.getCategoryByItem(item.charge).name
                    chgFullContext = (chgSrcContext, chgItemContext)
                    context = (modFullContext, chgFullContext)
                else:
                    context = (modFullContext,)
            else:
                fitSrcContext = "projectedFit"
                fitItemContext = "Fit"
                context = ((fitSrcContext, fitItemContext),)

        context += (("projected",),)
        menu = ContextMenu.getMenu((item,) if item is not None else [], *context)

        if menu is not None:
            self.PopupMenu(menu)
Exemplo n.º 34
0
 def spawnMenu(self, event):
     selection = self.getSelectedCargos()
     clickedPos = self.getRowByAbs(event.Position)
     mainCargo = None
     if clickedPos != -1:
         try:
             cargo = self.cargo[clickedPos]
         except IndexError:
             pass
         else:
             if cargo in self.original:
                 mainCargo = cargo
     sourceContext = "cargoItem"
     itemContext = None if mainCargo is None else Market.getInstance(
     ).getCategoryByItem(mainCargo.item).name
     menu = ContextMenu.getMenu(mainCargo, selection,
                                (sourceContext, itemContext))
     if menu:
         self.PopupMenu(menu)
Exemplo n.º 35
0
    def spawnMenu(self):
        if self.activeFitID is None:
            return
        cFit = service.Fit.getInstance()
        selection = []
        sel = self.GetFirstSelected()
        contexts = []
        if sel != -1:
            mod = self.mods[self.GetItemData(sel)]
            if not mod.isEmpty:
                contexts.append("module")
                if mod.charge is not None and "ammo" not in contexts:
                    contexts.append("ammo")

                selection.append(mod)

        contexts.append("ship")

        menu = ContextMenu.getMenu(selection, *contexts)
        self.PopupMenu(menu)
Exemplo n.º 36
0
 def spawnMenu(self, event):
     selection = self.getSelectedImplants()
     clickedPos = self.getRowByAbs(event.Position)
     mainImplant = None
     if clickedPos != -1:
         try:
             implant = self.implants[clickedPos]
         except IndexError:
             pass
         else:
             if implant in self.original:
                 mainImplant = implant
     fitID = self.mainFrame.getActiveFit()
     fit = Fit.getInstance().getFit(fitID)
     sourceContext1 = "implantItem" if fit.implantSource == ImplantLocation.FIT else "implantItemChar"
     sourceContext2 = "implantView" if fit.implantSource == ImplantLocation.FIT else "implantViewChar"
     itemContext = None if mainImplant is None else Market.getInstance().getCategoryByItem(mainImplant.item).name
     menu = ContextMenu.getMenu(mainImplant, selection, (sourceContext1, itemContext), (sourceContext2, itemContext))
     if menu:
         self.PopupMenu(menu)
Exemplo n.º 37
0
    def spawnMenu(self):
        if self.activeFitID is None:
            return
        cFit = service.Fit.getInstance()
        selection = []
        sel = self.GetFirstSelected()
        contexts = []
        if sel != -1:
            mod = self.mods[self.GetItemData(sel)]
            if not mod.isEmpty:
                contexts.append("module")
                if mod.charge is not None and "ammo" not in contexts:
                    contexts.append("ammo")

                selection.append(mod)

        contexts.append("ship")

        menu = ContextMenu.getMenu(selection, *contexts)
        self.PopupMenu(menu)
Exemplo n.º 38
0
    def spawnMenu(self):
        fitID = self.mainFrame.getActiveFit()
        if fitID is None:
            return

        sel = self.GetFirstSelected()
        context = ()
        item = self.get(sel)

        if item is not None:
            sMkt = Market.getInstance()

            if isinstance(item, es_Drone):
                srcContext = "projectedDrone"
                itemContext = sMkt.getCategoryByItem(item.item).name
                context = ((srcContext, itemContext),)
            elif isinstance(item, es_Fighter):
                srcContext = "projectedFighter"
                itemContext = sMkt.getCategoryByItem(item.item).name
                context = ((srcContext, itemContext),)
            elif isinstance(item, es_Module):
                modSrcContext = "projectedModule"
                modItemContext = sMkt.getCategoryByItem(item.item).name
                modFullContext = (modSrcContext, modItemContext)
                if item.charge is not None:
                    chgSrcContext = "projectedCharge"
                    chgItemContext = sMkt.getCategoryByItem(item.charge).name
                    chgFullContext = (chgSrcContext, chgItemContext)
                    context = (modFullContext, chgFullContext)
                else:
                    context = (modFullContext,)
            else:
                fitSrcContext = "projectedFit"
                fitItemContext = item.name
                context = ((fitSrcContext, fitItemContext),)

        context += (("projected",),)
        menu = ContextMenu.getMenu((item,) if item is not None else [], *context)

        if menu is not None:
            self.PopupMenu(menu)
Exemplo n.º 39
0
    def spawnMenu(self, event):
        clickedPos = self.getRowByAbs(event.Position)
        self.ensureSelection(clickedPos)

        selection = self.getSelectedCargos()
        mainCargo = None
        if clickedPos != -1:
            try:
                cargo = self.cargo[clickedPos]
            except IndexError:
                pass
            else:
                if cargo in self.original:
                    mainCargo = cargo
        itemContext = None if mainCargo is None else Market.getInstance(
        ).getCategoryByItem(mainCargo.item).displayName
        menu = ContextMenu.getMenu(self, mainCargo, selection,
                                   ("cargoItem", itemContext),
                                   ("cargoItemMisc", itemContext))
        if menu:
            self.PopupMenu(menu)
Exemplo n.º 40
0
    def spawnMenu(self, event):
        item = event.GetItem()
        self.skillTreeListCtrl.Select(item)
        thing = self.skillTreeListCtrl.GetFirstChild(item).IsOk()
        if thing:
            return

        id = self.skillTreeListCtrl.GetItemData(item)[1]
        eveItem = Market.getInstance().getItem(id)

        srcContext = "skillItem"
        itemContext = "Skill"
        context = (srcContext, itemContext)
        menu = ContextMenu.getMenu(self, eveItem, [eveItem], context)
        char = self.charEditor.entityEditor.getActiveEntity()
        if char.name not in ("All 0", "All 5"):
            menu.AppendSeparator()
            menu.Append(self.idUnlearned, "Unlearn")
            for level in range(6):
                menu.Append(self.idLevels[level], "Level %d" % level)
            menu.Bind(wx.EVT_MENU, self.changeLevel)

        self.PopupMenu(menu)
Exemplo n.º 41
0
    def spawnMenu(self):
        if self.activeFitID is None:
            return

        sMkt = service.Market.getInstance()
        selection = []
        sel = self.GetFirstSelected()
        contexts = []

        while sel != -1 and sel not in self.blanks:
            mod = self.mods[self.GetItemData(sel)]
            if not mod.isEmpty:
                srcContext = "fittingModule"
                itemContext = sMkt.getCategoryByItem(mod.item).name
                fullContext = (srcContext, itemContext)
                if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
                    contexts.append(fullContext)
                if mod.charge is not None:
                    srcContext = "fittingCharge"
                    itemContext = sMkt.getCategoryByItem(mod.charge).name
                    fullContext = (srcContext, itemContext)
                    if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
                        contexts.append(fullContext)

                selection.append(mod)

            sel = self.GetNextSelected(sel)

        sFit = service.Fit.getInstance()
        fit = sFit.getFit(self.activeFitID)

        contexts.append(
            ("fittingShip", "Ship" if not fit.isStructure else "Citadel"))

        menu = ContextMenu.getMenu(selection, *contexts)
        self.PopupMenu(menu)
Exemplo n.º 42
0
 def onAttackerContext(self, event):
     menu = ContextMenu.getMenu(None, ("graphAttacker", ))
     if menu is not None:
         self.fitList.fitList.PopupMenu(menu)
Exemplo n.º 43
0
    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.DefaultSize,
                          style=wx.TAB_TRAVERSAL)
        self.charEditor = self.Parent.Parent  # first parent is Notebook, second is Character Editor
        self.SetBackgroundColour(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))

        pmainSizer = wx.BoxSizer(wx.VERTICAL)

        tree = self.skillTreeListCtrl = wx.gizmos.TreeListCtrl(
            self, wx.ID_ANY, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT)
        pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5)

        self.imageList = wx.ImageList(16, 16)
        tree.SetImageList(self.imageList)
        self.skillBookImageId = self.imageList.Add(
            BitmapLoader.getBitmap("skill_small", "gui"))

        tree.AddColumn("Skill")
        tree.AddColumn("Level")
        tree.SetMainColumn(0)

        self.root = tree.AddRoot("Skills")
        tree.SetItemText(self.root, "Levels", 1)

        tree.SetColumnWidth(0, 500)

        self.populateSkillTree()

        tree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.expandLookup)
        tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.scheduleMenu)

        # bind the Character selection event
        self.charEditor.entityEditor.Bind(wx.EVT_CHOICE,
                                          self.populateSkillTree)
        self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree)

        srcContext = "skillItem"
        itemContext = "Skill"
        context = (srcContext, itemContext)
        self.statsMenu = ContextMenu.getMenu(None, context)
        self.levelChangeMenu = ContextMenu.getMenu(None, context) or wx.Menu()
        self.levelChangeMenu.AppendSeparator()
        self.levelIds = {}

        idUnlearned = wx.NewId()
        self.levelIds[idUnlearned] = "Not learned"
        self.levelChangeMenu.Append(idUnlearned, "Unlearn")

        for level in xrange(6):
            id = wx.NewId()
            self.levelIds[id] = level
            self.levelChangeMenu.Append(id, "Level %d" % level)

        self.levelChangeMenu.AppendSeparator()
        self.revertID = wx.NewId()
        self.levelChangeMenu.Append(self.revertID, "Revert")

        self.saveID = wx.NewId()
        self.levelChangeMenu.Append(self.saveID, "Save")

        self.levelChangeMenu.Bind(wx.EVT_MENU, self.changeLevel)
        self.SetSizer(pmainSizer)

        self.Layout()
Exemplo n.º 44
0
 def spawnMenu(self):
     context = (("implantEditor", ), )
     # f**k good coding practices, passing a pointer to the character editor here for [reasons] =D
     # (see implantSets context class for info)
     menu = ContextMenu.getMenu((self.Parent.Parent, ), *context)
     self.PopupMenu(menu)
Exemplo n.º 45
0
 def contextMenuHandler(self, event):
     viewName = self.graphFrame.getView().internalName
     menu = ContextMenu.getMenu(self, None, None, (viewName, ))
     if menu is not None:
         self.PopupMenu(menu)
     event.Skip()
Exemplo n.º 46
0
    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.DefaultSize,
                          style=wx.TAB_TRAVERSAL)
        self.charEditor = self.Parent.Parent  # first parent is Notebook, second is Character Editor
        self.SetBackgroundColour(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))

        pmainSizer = wx.BoxSizer(wx.VERTICAL)

        hSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.clonesChoice = wx.Choice(self, wx.ID_ANY, style=0)
        i = self.clonesChoice.Append("Omega Clone", None)
        self.clonesChoice.SetSelection(i)
        hSizer.Add(self.clonesChoice, 5, wx.ALL | wx.EXPAND, 5)

        self.searchInput = PlaceholderTextCtrl(self,
                                               wx.ID_ANY,
                                               placeholder="Search...")
        hSizer.Add(self.searchInput, 1, wx.ALL | wx.EXPAND, 5)
        self.searchInput.Bind(wx.EVT_TEXT, self.delaySearch)

        sChar = Character.getInstance()
        self.alphaClones = sChar.getAlphaCloneList()
        char = self.charEditor.entityEditor.getActiveEntity()

        for clone in self.alphaClones:
            i = self.clonesChoice.Append(clone.alphaCloneName, clone.ID)
            if clone.ID == char.alphaCloneID:
                self.clonesChoice.SetSelection(i)

        self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged)

        self.clonesChoice.SetToolTip(
            wx.ToolTip(
                "Setting an Alpha clone does not replace the character's skills, but rather caps them to Alpha levels."
            ))

        pmainSizer.Add(hSizer, 0, wx.EXPAND | wx.ALL, 5)

        # Set up timer for skill search
        self.searchTimer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.populateSkillTreeSkillSearch,
                  self.searchTimer)

        tree = self.skillTreeListCtrl = wx.gizmos.TreeListCtrl(
            self, wx.ID_ANY, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT)
        pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5)

        self.imageList = wx.ImageList(16, 16)
        tree.SetImageList(self.imageList)
        self.skillBookImageId = self.imageList.Add(
            BitmapLoader.getBitmap("skill_small", "gui"))

        tree.AddColumn("Skill")
        tree.AddColumn("Level")
        tree.SetMainColumn(0)

        self.root = tree.AddRoot("Skills")
        tree.SetItemText(self.root, "Levels", 1)

        tree.SetColumnWidth(0, 500)

        self.btnSecStatus = wx.Button(
            self, wx.ID_ANY, "Sec Status: {0:.2f}".format(char.secStatus
                                                          or 0.0))
        self.btnSecStatus.Bind(wx.EVT_BUTTON, self.onSecStatus)

        self.populateSkillTree()

        tree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.expandLookup)
        tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.scheduleMenu)

        bSizerButtons = wx.BoxSizer(wx.HORIZONTAL)

        bSizerButtons.Add(self.btnSecStatus, 0, wx.ALL, 5)
        pmainSizer.Add(bSizerButtons, 0, wx.EXPAND, 5)

        # bind the Character selection event
        self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged)
        self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree)

        srcContext = "skillItem"
        itemContext = "Skill"
        context = (srcContext, itemContext)
        self.statsMenu = ContextMenu.getMenu(None, context)
        self.levelChangeMenu = ContextMenu.getMenu(None, context) or wx.Menu()
        self.levelChangeMenu.AppendSeparator()
        self.levelIds = {}

        idUnlearned = wx.NewId()
        self.levelIds[idUnlearned] = "Not learned"
        self.levelChangeMenu.Append(idUnlearned, "Unlearn")

        for level in xrange(6):
            id = wx.NewId()
            self.levelIds[id] = level
            self.levelChangeMenu.Append(id, "Level %d" % level)

        self.levelChangeMenu.AppendSeparator()
        self.revertID = wx.NewId()
        self.levelChangeMenu.Append(self.revertID, "Revert")

        self.saveID = wx.NewId()
        self.levelChangeMenu.Append(self.saveID, "Save")

        self.levelChangeMenu.Bind(wx.EVT_MENU, self.changeLevel)
        self.SetSizer(pmainSizer)

        self.Layout()
Exemplo n.º 47
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
                          style=wx.TAB_TRAVERSAL)
        self.charEditor = self.Parent.Parent  # first parent is Notebook, second is Character Editor
        self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))

        pmainSizer = wx.BoxSizer(wx.VERTICAL)

        hSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.clonesChoice = wx.Choice(self, wx.ID_ANY, style=0)
        i = self.clonesChoice.Append("Omega Clone", None)
        self.clonesChoice.SetSelection(i)
        hSizer.Add(self.clonesChoice, 5, wx.ALL | wx.EXPAND, 5)

        self.searchInput = PlaceholderTextCtrl(self, wx.ID_ANY, placeholder="Search...")
        hSizer.Add(self.searchInput, 1, wx.ALL | wx.EXPAND, 5)
        self.searchInput.Bind(wx.EVT_TEXT, self.delaySearch)

        sChar = Character.getInstance()
        self.alphaClones = sChar.getAlphaCloneList()
        char = self.charEditor.entityEditor.getActiveEntity()

        for clone in self.alphaClones:
            i = self.clonesChoice.Append(clone.alphaCloneName, clone.ID)
            if clone.ID == char.alphaCloneID:
                self.clonesChoice.SetSelection(i)

        self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged)

        self.clonesChoice.SetToolTip(
            wx.ToolTip("Setting an Alpha clone does not replace the character's skills, but rather caps them to Alpha levels."))

        pmainSizer.Add(hSizer, 0, wx.EXPAND | wx.ALL, 5)

        # Set up timer for skill search
        self.searchTimer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.populateSkillTreeSkillSearch, self.searchTimer)

        tree = self.skillTreeListCtrl = TreeListCtrl(self, wx.ID_ANY, style=wx.dataview.TL_DEFAULT_STYLE)
        pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5)

        self.imageList = wx.ImageList(16, 16)
        tree.SetImageList(self.imageList)
        self.skillBookImageId = self.imageList.Add(wx.Icon(BitmapLoader.getBitmap("skill_small", "gui")))
        self.skillBookDirtyImageId = self.imageList.Add(wx.Icon(BitmapLoader.getBitmap("skill_small_red", "gui")))

        tree.AppendColumn("Skill")
        tree.AppendColumn("Level")
        # tree.SetMainColumn(0)

        self.root = tree.GetRootItem()
        # self.root = tree.AppendItem(root, "Skills")
        #
        # tree.SetItemText(self.root, 1, "Levels")

        # tree.SetColumnWidth(0, 300)

        self.btnSecStatus = wx.Button(self, wx.ID_ANY, "Sec Status: {0:.2f}".format(char.secStatus or 0.0))
        self.btnSecStatus.Bind(wx.EVT_BUTTON, self.onSecStatus)

        self.populateSkillTree()

        tree.Bind(wx.dataview.EVT_TREELIST_ITEM_EXPANDING, self.expandLookup)
        tree.Bind(wx.dataview.EVT_TREELIST_ITEM_CONTEXT_MENU, self.scheduleMenu)

        bSizerButtons = wx.BoxSizer(wx.HORIZONTAL)

        bSizerButtons.Add(self.btnSecStatus, 0, wx.ALL, 5)

        bSizerButtons.AddStretchSpacer()

        importExport = (("Import", wx.ART_FILE_OPEN, "from"),
                        ("Export", wx.ART_FILE_SAVE_AS, "to"))

        for name, art, direction in importExport:
            bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON)
            btn = wx.BitmapButton(self, wx.ID_ANY, bitmap)

            btn.SetMinSize(btn.GetSize())
            btn.SetMaxSize(btn.GetSize())

            btn.Layout()
            setattr(self, "{}Btn".format(name.lower()), btn)
            btn.Enable(True)
            btn.SetToolTip("%s skills %s clipboard" % (name, direction))
            bSizerButtons.Add(btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_RIGHT | wx.ALL, 5)
            btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Skills".format(name.lower())))

        pmainSizer.Add(bSizerButtons, 0, wx.EXPAND, 5)

        # bind the Character selection event
        self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged)
        self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree)

        srcContext = "skillItem"
        itemContext = "Skill"
        context = (srcContext, itemContext)
        self.statsMenu = ContextMenu.getMenu(None, context)
        self.levelChangeMenu = ContextMenu.getMenu(None, context) or wx.Menu()
        self.levelChangeMenu.AppendSeparator()
        self.levelIds = {}

        idUnlearned = wx.NewId()
        self.levelIds[idUnlearned] = "Not learned"
        self.levelChangeMenu.Append(idUnlearned, "Unlearn")

        for level in range(6):
            id = wx.NewId()
            self.levelIds[id] = level
            self.levelChangeMenu.Append(id, "Level %d" % level)

        self.levelChangeMenu.AppendSeparator()
        self.revertID = wx.NewId()
        self.levelChangeMenu.Append(self.revertID, "Revert")

        self.saveID = wx.NewId()
        self.levelChangeMenu.Append(self.saveID, "Save")

        self.levelChangeMenu.Bind(wx.EVT_MENU, self.changeLevel)
        self.SetSizer(pmainSizer)

        self.Layout()
Exemplo n.º 48
0
 def OnShowPopup(self, event):
     pos = event.GetPosition()
     pos = self.ScreenToClient(pos)
     contexts = [("baseShip", "Ship Basic")]
     menu = ContextMenu.getMenu(self.baseItem, *contexts)
     self.PopupMenu(menu, pos)
Exemplo n.º 49
0
        def handler(event):
            menu = ContextMenu.getMenu(None, (viewName,))
            if menu is not None:
                contentPanel.PopupMenu(menu)

            event.Skip()