Example #1
0
    def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
        m = wx.Menu()
        if "wxMSW" in wx.PlatformInfo:
            bindmenu = rootMenu
        else:
            bindmenu = m

        isNotDefault = self.mod.spoolType is not None and self.mod.spoolAmount is not None
        cycleDefault = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, eos.config.settings['globalDefaultSpoolupPercentage'], True))[0]
        cycleCurrent = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, eos.config.settings['globalDefaultSpoolupPercentage'], False))[0]
        cycleMin = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, 0, True))[0]
        cycleMax = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, 1, True))[0]

        for cycle in range(cycleMin, cycleMax + 1):
            menuId = ContextMenuSingle.nextID()

            # Show default only for current value and when not overriden
            if not isNotDefault and cycle == cycleDefault:
                text = "{} (default)".format(cycle)
            else:
                text = "{}".format(cycle)

            item = wx.MenuItem(m, menuId, text, kind=wx.ITEM_CHECK)
            bindmenu.Bind(wx.EVT_MENU, self.handleSpoolChange, item)
            m.Append(item)
            item.Check(isNotDefault and cycle == cycleCurrent)
            self.cycleMap[menuId] = cycle

        self.resetId = ContextMenuSingle.nextID()
        item = wx.MenuItem(m, self.resetId, "Reset")
        bindmenu.Bind(wx.EVT_MENU, self.handleSpoolChange, item)
        m.Append(item)

        return m
Example #2
0
    def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
        """
        A note on the mainItem 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 mainItem 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
        self.mainItem = mainItem  # dirty hack here

        self.idmap = {}

        for set in sorted(implantSets, key=lambda i: i.name):
            id = ContextMenuSingle.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
Example #3
0
    def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.skillIds = {}
        sub = wx.Menu()

        for skill in self.skills:
            skillItem = wx.MenuItem(sub, ContextMenuSingle.nextID(),
                                    skill.item.name)
            grandSub = wx.Menu()
            skillItem.SetSubMenu(grandSub)
            if skill.learned:
                bitmap = BitmapLoader.getBitmap("lvl%s" % skill.level, "gui")
                if bitmap is not None:
                    skillItem.SetBitmap(bitmap)

            for i in range(-1, 6):
                levelItem = self.addSkill(rootMenu if msw else grandSub, skill,
                                          i)
                grandSub.Append(levelItem)
                if (not skill.learned and i == -1) or (skill.learned
                                                       and skill.level == i):
                    levelItem.Check(True)
            sub.Append(skillItem)

        return sub
Example #4
0
    def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
        """
        A note on the mainItem 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 mainItem 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
        self.mainItem = mainItem  # dirty hack here

        self.idmap = {}

        for set in sorted(implantSets, key=lambda i: i.name):
            id = ContextMenuSingle.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
Example #5
0
    def addEffect(self, menu, ability):
        label = ability.name
        id = ContextMenuSingle.nextID()
        self.effectIds[id] = ability

        menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_CHECK)
        menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
        return menuItem
Example #6
0
    def _addPattern(self, parentMenu, pattern, name):
        id = ContextMenuSingle.nextID()
        self.patternEventMap[id] = pattern
        menuItem = wx.MenuItem(parentMenu, id, name, kind=wx.ITEM_CHECK)
        parentMenu.Bind(wx.EVT_MENU, self.handlePatternSwitch, menuItem)

        checked = self.module.rahPatternOverride is pattern
        return menuItem, checked
Example #7
0
    def addSkill(self, rootMenu, skill, i):
        if i < 0:
            label = _t("Not Learned")
        else:
            label = _t("Level %s") % i

        id = ContextMenuSingle.nextID()
        self.skillIds[id] = (skill, i)
        menuItem = wx.MenuItem(rootMenu, id, label, kind=wx.ITEM_RADIO)
        rootMenu.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
        return menuItem
Example #8
0
    def addSkill(self, rootMenu, skill, i):
        if i < 0:
            label = "Not Learned"
        else:
            label = "Level %s" % i

        id = ContextMenuSingle.nextID()
        self.skillIds[id] = (skill, i)
        menuItem = wx.MenuItem(rootMenu, id, label, kind=wx.ITEM_RADIO)
        rootMenu.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
        return menuItem
Example #9
0
    def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
        if mainItem.isMutated:
            return None

        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.skillIds = {}
        sub = wx.Menu()

        menu = rootMenu if msw else sub

        for mutaplasmid in mainItem.item.mutaplasmids:
            id = ContextMenuSingle.nextID()
            self.eventIDs[id] = (mutaplasmid, mainItem)
            mItem = wx.MenuItem(menu, id, mutaplasmid.shortName)
            menu.Bind(wx.EVT_MENU, self.handleMenu, mItem)
            sub.Append(mItem)

        return sub
Example #10
0
    def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
        if mainItem.isMutated:
            return None

        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.skillIds = {}
        sub = wx.Menu()

        menu = rootMenu if msw else sub

        for item in mainItem.item.mutaplasmids:
            label = item.item.name
            id = ContextMenuSingle.nextID()
            self.eventIDs[id] = (item, mainItem)
            skillItem = wx.MenuItem(menu, id, label)
            menu.Bind(wx.EVT_MENU, self.handleMenu, skillItem)
            sub.Append(skillItem)

        return sub
Example #11
0
    def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
        if mainItem.isMutated:
            return None

        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.skillIds = {}
        sub = wx.Menu()

        menu = rootMenu if msw else sub

        for item in mainItem.item.mutaplasmids:
            label = item.item.name
            id = ContextMenuSingle.nextID()
            self.eventIDs[id] = (item, mainItem)
            skillItem = wx.MenuItem(menu, id, label)
            menu.Bind(wx.EVT_MENU, self.handleMenu, skillItem)
            sub.Append(skillItem)

        return sub
Example #12
0
    def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
        msw = True if "wxMSW" in wx.PlatformInfo else False
        self.skillIds = {}
        sub = wx.Menu()

        for skill in self.skills:
            skillItem = wx.MenuItem(sub, ContextMenuSingle.nextID(), skill.item.name)
            grandSub = wx.Menu()
            skillItem.SetSubMenu(grandSub)
            if skill.learned:
                bitmap = BitmapLoader.getBitmap("lvl%s" % skill.level, "gui")
                if bitmap is not None:
                    skillItem.SetBitmap(bitmap)

            for i in range(-1, 6):
                levelItem = self.addSkill(rootMenu if msw else grandSub, skill, i)
                grandSub.Append(levelItem)
                if (not skill.learned and i == -1) or (skill.learned and skill.level == i):
                    levelItem.Check(True)
            sub.Append(skillItem)

        return sub
Example #13
0
    def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
        m = wx.Menu()
        if "wxMSW" in wx.PlatformInfo:
            bindmenu = rootMenu
        else:
            bindmenu = m

        isNotDefault = self.mod.spoolType is not None and self.mod.spoolAmount is not None
        cycleDefault = self.mod.getSpoolData(spoolOptions=SpoolOptions(
            SpoolType.SPOOL_SCALE,
            eos.config.settings['globalDefaultSpoolupPercentage'], True))[0]
        cycleCurrent = self.mod.getSpoolData(spoolOptions=SpoolOptions(
            SpoolType.SPOOL_SCALE,
            eos.config.settings['globalDefaultSpoolupPercentage'], False))[0]
        cycleMin = self.mod.getSpoolData(
            spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 0, True))[0]
        cycleMax = self.mod.getSpoolData(
            spoolOptions=SpoolOptions(SpoolType.SPOOL_SCALE, 1, True))[0]
        cycleTotalMin = min(cycleDefault, cycleCurrent, cycleMin)
        cycleTotalMax = max(cycleDefault, cycleCurrent, cycleMax)

        def findCycles(val1, val2):
            # Try to compose list of 21 steps max (0-20)
            maxSteps = 20
            valDiff = val2 - val1
            valScale = valDiff / maxSteps
            minStep = math.ceil(round(valScale, 9))
            maxStep = math.floor(round(valDiff / 4, 9))
            # Check steps from smallest to highest and see if we can go from min value
            # to max value using those
            for currentStep in range(minStep, maxStep + 1):
                if valDiff % currentStep == 0:
                    return set(range(val1, val2 + currentStep, currentStep))
            # Otherwise just split range in halves and go both ends using min values
            else:
                cycles = set()
                while val2 >= val1:
                    cycles.add(val1)
                    cycles.add(val2)
                    val1 += minStep
                    val2 -= minStep
                return cycles

        self.cycleMap = {}
        cyclesToShow = findCycles(cycleMin, cycleMax)
        for cycle in range(cycleTotalMin, cycleTotalMax + 1):
            menuId = ContextMenuSingle.nextID()

            # Show default only for current value and when not overriden
            if not isNotDefault and cycle == cycleDefault:
                text = "{} (default)".format(cycle)
            # Always show current selection and stuff which we decided to show via the cycles function
            elif cycle == cycleCurrent or cycle in cyclesToShow:
                text = "{}".format(cycle)
            # Ignore the rest to not have very long menu
            else:
                continue

            item = wx.MenuItem(m, menuId, text, kind=wx.ITEM_CHECK)
            bindmenu.Bind(wx.EVT_MENU, self.handleSpoolChange, item)
            m.Append(item)
            item.Check(isNotDefault and cycle == cycleCurrent)
            self.cycleMap[menuId] = cycle

        self.resetId = ContextMenuSingle.nextID()
        item = wx.MenuItem(m, self.resetId, "Reset")
        bindmenu.Bind(wx.EVT_MENU, self.handleSpoolChange, item)
        m.Append(item)

        return m
Example #14
0
 def _addCategory(self, parentMenu, name):
     id = ContextMenuSingle.nextID()
     menuItem = wx.MenuItem(parentMenu, id, name)
     parentMenu.Bind(wx.EVT_MENU, self.handlePatternSwitch, menuItem)
     return menuItem
Example #15
0
    def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
        m = wx.Menu()
        if "wxMSW" in wx.PlatformInfo:
            bindmenu = rootMenu
        else:
            bindmenu = m

        isNotDefault = self.mod.spoolType is not None and self.mod.spoolAmount is not None
        cycleDefault = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, eos.config.settings['globalDefaultSpoolupPercentage'], True))[0]
        cycleCurrent = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, eos.config.settings['globalDefaultSpoolupPercentage'], False))[0]
        cycleMin = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, 0, True))[0]
        cycleMax = self.mod.getSpoolData(spoolOptions=SpoolOptions(SpoolType.SCALE, 1, True))[0]
        cycleTotalMin = min(cycleDefault, cycleCurrent, cycleMin)
        cycleTotalMax = max(cycleDefault, cycleCurrent, cycleMax)

        def findCycles(val1, val2):
            # Try to compose list of 21 steps max (0-20)
            maxSteps = 20
            valDiff = val2 - val1
            valScale = valDiff / maxSteps
            minStep = math.ceil(round(valScale, 9))
            maxStep = math.floor(round(valDiff / 4, 9))
            # Check steps from smallest to highest and see if we can go from min value
            # to max value using those
            for currentStep in range(minStep, maxStep + 1):
                if valDiff % currentStep == 0:
                    return set(range(val1, val2 + currentStep, currentStep))
            # Otherwise just split range in halves and go both ends using min values
            else:
                cycles = set()
                while val2 >= val1:
                    cycles.add(val1)
                    cycles.add(val2)
                    val1 += minStep
                    val2 -= minStep
                return cycles

        cyclesToShow = findCycles(cycleMin, cycleMax)
        for cycle in range(cycleTotalMin, cycleTotalMax + 1):
            menuId = ContextMenuSingle.nextID()

            # Show default only for current value and when not overriden
            if not isNotDefault and cycle == cycleDefault:
                text = "{} (default)".format(cycle)
            # Always show current selection and stuff which we decided to show via the cycles function
            elif cycle == cycleCurrent or cycle in cyclesToShow:
                text = "{}".format(cycle)
            # Ignore the rest to not have very long menu
            else:
                continue

            item = wx.MenuItem(m, menuId, text, kind=wx.ITEM_CHECK)
            bindmenu.Bind(wx.EVT_MENU, self.handleSpoolChange, item)
            m.Append(item)
            item.Check(isNotDefault and cycle == cycleCurrent)
            self.cycleMap[menuId] = cycle

        self.resetId = ContextMenuSingle.nextID()
        item = wx.MenuItem(m, self.resetId, "Reset")
        bindmenu.Bind(wx.EVT_MENU, self.handleSpoolChange, item)
        m.Append(item)

        return m