コード例 #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
ファイル: implantSetAdd.py プロジェクト: pyfa-org/Pyfa
    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
ファイル: implantSetAdd.py プロジェクト: MiserereM/pyfa_zh
    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
ファイル: implantSetApply.py プロジェクト: zzwpower/Pyfa
    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
ファイル: setEditor.py プロジェクト: zwparchman/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")
コード例 #10
0
ファイル: implantSetApply.py プロジェクト: xmb666/Pyfa
    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)