예제 #1
0
파일: implantSets.py 프로젝트: Sectoid/Pyfa
    def getSubMenu(self, context, selection, rootMenu, i, pitem):
        """
        A note on the selection here: Most context menus act on a fit, so it's easy enough to get the active fit from
        the MainFrame instance. There's never been a reason to get info from another window, so there's not common
        way of doing this. However, we use this context menu within the Character Editor to apply implant sets to a
        character, so we need to access the character editor.

        It is for these reasons that I hijack the selection parameter when calling the menu and pass a pointer to the
        Character Editor. This way we can use it to get current editing character ID and apply the implants.

        It would probably be better to have a function on the MainFrame to get the currently open Character Editor (as
        we do with the item stats window). Eventually... Until then, this long ass note will remain to remind me why
        stupid shit like this is even happening.
        """

        m = wx.Menu()
        bindmenu = rootMenu if "wxMSW" in wx.PlatformInfo else m

        sIS = s_ImplantSets.getInstance()
        implantSets = sIS.getImplantSetList()

        self.context = context
        if len(selection) == 1:
            self.selection = selection[0]  # dirty hack here

        self.idmap = {}

        for set in implantSets:
            id = ContextMenu.nextID()
            mitem = wx.MenuItem(rootMenu, id, set.name)
            bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
            self.idmap[id] = set
            m.Append(mitem)

        return m
예제 #2
0
    def getSubMenu(self, context, selection, rootMenu, i, pitem):
        """
        A note on the selection here: Most context menus act on a fit, so it's easy enough to get the active fit from
        the MainFrame instance. There's never been a reason to get info from another window, so there's not common
        way of doing this. However, we use this context menu within the Character Editor to apply implant sets to a
        character, so we need to access the character editor.

        It is for these reasons that I hijack the selection parameter when calling the menu and pass a pointer to the
        Character Editor. This way we can use it to get current editing character ID and apply the implants.

        It would probably be better to have a function on the MainFrame to get the currently open Character Editor (as
        we do with the item stats window). Eventually... Until then, this long ass note will remain to remind me why
        stupid shit like this is even happening.
        """

        m = wx.Menu()
        bindmenu = rootMenu if "wxMSW" in wx.PlatformInfo else m

        sIS = s_ImplantSets.getInstance()
        implantSets = sIS.getImplantSetList()

        self.context = context
        if len(selection) == 1:
            self.selection = selection[0]  # dirty hack here

        self.idmap = {}

        for set in implantSets:
            id = ContextMenu.nextID()
            mitem = wx.MenuItem(rootMenu, id, set.name)
            bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
            self.idmap[id] = set
            m.Append(mitem)

        return m
예제 #3
0
    def display(self, srcContext, selection):

        sIS = s_ImplantSets.getInstance()
        implantSets = sIS.getImplantSetList()

        if len(implantSets) == 0:
            return False
        return srcContext in ("implantView", "implantEditor")
예제 #4
0
    def display(self, srcContext, mainItem):

        sIS = s_ImplantSets.getInstance()
        implantSets = sIS.getImplantSetList()

        if len(implantSets) == 0:
            return False
        return srcContext in ("implantView", "implantEditor")
예제 #5
0
    def display(self, callingWindow, srcContext):

        sIS = s_ImplantSets.getInstance()
        implantSets = sIS.getImplantSetList()

        if len(implantSets) == 0:
            return False
        return srcContext in ("implantItemMisc", "implantEditor")
예제 #6
0
    def display(self, callingWindow, srcContext):

        self.userImplantSets = UserImplantSets.getInstance().getImplantSetList()
        self.structedImplantSets = PrecalcedImplantSets.getStructuredSets()

        if len(self.userImplantSets) == 0 and len(self.structedImplantSets) == 0:
            return False

        return srcContext in ("implantItemMisc", "implantEditor")
예제 #7
0
파일: implantSets.py 프로젝트: Sectoid/Pyfa
    def display(self, srcContext, selection):
        if not self.settings.get('implantSets'):
            return False

        sIS = s_ImplantSets.getInstance()
        implantSets = sIS.getImplantSetList()

        if len(implantSets) == 0:
            return False

        return srcContext in ("implantView", "implantEditor")
예제 #8
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
    def importPatterns(self, event):
        """Event fired when import from clipboard button is clicked"""

        text = fromClipboard()
        if text:
            sIS = ImplantSets.getInstance()
            try:
                sIS.importSets(text)
                self.stNotice.SetLabel("Patterns successfully imported from clipboard")
            except ImportError as e:
                pyfalog.error(e)
                self.stNotice.SetLabel(str(e))
            except Exception as e:
                pyfalog.error(e)
                self.stNotice.SetLabel("Could not import from clipboard: unknown errors")
            finally:
                self.entityEditor.refreshEntityList()
        else:
            self.stNotice.SetLabel("Could not import from clipboard")
예제 #9
0
    def importPatterns(self, event):
        """Event fired when import from clipboard button is clicked"""

        text = fromClipboard()
        if text:
            sIS = ImplantSets.getInstance()
            try:
                sIS.importSets(text)
                self.stNotice.SetLabel("Patterns successfully imported from clipboard")
            except ImportError as e:
                pyfalog.error(e)
                self.stNotice.SetLabel(str(e))
            except Exception as e:
                pyfalog.error(e)
                self.stNotice.SetLabel("Could not import from clipboard: unknown errors")
            finally:
                self.entityEditor.refreshEntityList()
        else:
            self.stNotice.SetLabel("Could not import from clipboard")
예제 #10
0
    def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
        m = wx.Menu()
        bindmenu = rootMenu if "wxMSW" in wx.PlatformInfo else m

        sIS = s_ImplantSets.getInstance()
        implantSets = sIS.getImplantSetList()

        self.context = context
        self.callingWindow = callingWindow

        self.idmap = {}

        for set in sorted(implantSets, key=lambda i: i.name):
            id = ContextMenuUnconditional.nextID()
            mitem = wx.MenuItem(rootMenu, id, set.name)
            bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
            self.idmap[id] = set
            m.Append(mitem)

        return m
예제 #11
0
 def DoRename(self, entity, name):
     sIS = ImplantSets.getInstance()
     sIS.renameSet(entity, name)
예제 #12
0
 def DoCopy(self, entity, name):
     sIS = ImplantSets.getInstance()
     copy = sIS.copySet(entity)
     sIS.renameSet(copy, name)
     return copy
예제 #13
0
 def getEntitiesFromContext(self):
     sIS = ImplantSets.getInstance()
     return sorted(sIS.getImplantSetList(), key=lambda c: c.name)
예제 #14
0
 def DoNew(self, name):
     sIS = ImplantSets.getInstance()
     return sIS.newSet(name)
예제 #15
0
    def removeImplantFromContext(self, implant):
        sIS = ImplantSets.getInstance()
        set_ = self.Parent.entityEditor.getActiveEntity()

        sIS.removeImplant(set_.ID, implant)
예제 #16
0
    def exportPatterns(self, event):
        """Event fired when export to clipboard button is clicked"""

        sIS = ImplantSets.getInstance()
        toClipboard(sIS.exportSets())
        self.stNotice.SetLabel("Sets exported to clipboard")
예제 #17
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
    def removeImplantFromContext(self, implant):
        sIS = ImplantSets.getInstance()
        set_ = self.Parent.entityEditor.getActiveEntity()

        sIS.removeImplant(set_.ID, implant)
예제 #18
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
 def DoNew(self, name):
     sIS = ImplantSets.getInstance()
     return sIS.newSet(name)
예제 #19
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
 def getImplantsFromContext(self):
     sIS = ImplantSets.getInstance()
     set_ = self.Parent.entityEditor.getActiveEntity()
     if set_:
         return sIS.getImplants(set_.ID)
     return []
예제 #20
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
    def exportPatterns(self, event):
        """Event fired when export to clipboard button is clicked"""

        sIS = ImplantSets.getInstance()
        toClipboard(sIS.exportSets())
        self.stNotice.SetLabel("Sets exported to clipboard")
예제 #21
0
    def __init__(self, parent, dataToAdd=None):
        super().__init__(parent,
                         id=wx.ID_ANY,
                         title=_t("Implant Set Editor"),
                         resizeable=True,
                         size=wx.Size(950, 500)
                         if "wxGTK" in wx.PlatformInfo else wx.Size(850, 420))

        self.block = False
        self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)

        mainSizer = wx.BoxSizer(wx.VERTICAL)

        self.entityEditor = ImplantSetEntityEditor(self)
        mainSizer.Add(self.entityEditor, 0, wx.ALL | wx.EXPAND, 2)

        self.sl = wx.StaticLine(self)
        mainSizer.Add(self.sl, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)

        self.iview = ImplantSetEditorView(self)
        mainSizer.Add(self.iview, 1, wx.ALL | wx.EXPAND, 5)

        self.slfooter = wx.StaticLine(self)
        mainSizer.Add(self.slfooter, 0, wx.EXPAND | wx.TOP, 5)

        footerSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.stNotice = wx.StaticText(self, wx.ID_ANY, "")
        self.stNotice.Wrap(-1)
        footerSizer.Add(self.stNotice, 1, wx.BOTTOM | wx.TOP | wx.LEFT, 5)

        importExport = ((_t("Import implant sets from clipboard"),
                         wx.ART_FILE_OPEN, "Import"),
                        (_t("Export implant sets to clipboard"),
                         wx.ART_FILE_SAVE_AS, "Export"))

        for tooltip, art, attr 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, attr, btn)
            btn.Enable(True)
            btn.SetToolTip(tooltip)
            footerSizer.Add(btn, 0)

        mainSizer.Add(footerSizer, 0, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(mainSizer)
        self.Layout()

        if dataToAdd:
            name, implants = dataToAdd
            newSet = self.entityEditor.DoNew(name)
            ImplantSets.getInstance().addImplants(
                newSet.ID, *[i.item.ID for i in implants])
            self.entityEditor.refreshEntityList(newSet)
            wx.PostEvent(self.entityEditor.entityChoices,
                         wx.CommandEvent(wx.wxEVT_COMMAND_CHOICE_SELECTED))
        elif not self.entityEditor.checkEntitiesExist():
            self.Close()
            return

        self.Bind(wx.EVT_CHOICE, self.entityChanged)
        self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent)

        self.Import.Bind(wx.EVT_BUTTON, self.importPatterns)
        self.Export.Bind(wx.EVT_BUTTON, self.exportPatterns)

        self.SetMinSize(self.GetSize())
        self.CenterOnParent()
예제 #22
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
 def DoCopy(self, entity, name):
     sIS = ImplantSets.getInstance()
     copy = sIS.copySet(entity)
     sIS.renameSet(copy, name)
     return copy
예제 #23
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
 def DoRename(self, entity, name):
     sIS = ImplantSets.getInstance()
     sIS.renameSet(entity, name)
예제 #24
0
 def DoDelete(self, entity):
     sIS = ImplantSets.getInstance()
     sIS.deleteSet(entity)
예제 #25
0
    def addImplantToContext(self, item):
        sIS = ImplantSets.getInstance()
        set_ = self.Parent.entityEditor.getActiveEntity()

        sIS.addImplant(set_.ID, item.ID)
예제 #26
0
 def getImplantsFromContext(self):
     sIS = ImplantSets.getInstance()
     set_ = self.Parent.entityEditor.getActiveEntity()
     if set_:
         return sIS.getImplants(set_.ID)
     return []
예제 #27
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
 def getEntitiesFromContext(self):
     sIS = ImplantSets.getInstance()
     return sorted(sIS.getImplantSetList(), key=lambda c: c.name)
예제 #28
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
 def DoDelete(self, entity):
     sIS = ImplantSets.getInstance()
     sIS.deleteSet(entity)
예제 #29
0
파일: setEditor.py 프로젝트: Sectoid/Pyfa
    def addImplantToContext(self, item):
        sIS = ImplantSets.getInstance()
        set_ = self.Parent.entityEditor.getActiveEntity()

        sIS.addImplant(set_.ID, item.ID)