Пример #1
0
    def __init__(self, fitID, thing):
        wx.Command.__init__(self, True, "Projected Add")
        self.mainFrame = gui.mainFrame.MainFrame.getInstance()
        self.sFit = Fit.getInstance()
        self.internal_history = wx.CommandProcessor()
        self.fitID = fitID
        fit = self.sFit.getFit(fitID)

        if isinstance(thing, Drone):
            self.data = fit.projectedDrones.index(thing)
            self.type = 'drone'
        elif isinstance(thing, Module):
            # todo: projected stuff should be wrapped in a projected class wrapper for easier maintainence
            if thing.item.group.name in Module.SYSTEM_GROUPS:
                self.type = 'env'
                self.data = thing.itemID
            else:
                self.type = 'module'
                self.data = fit.projectedModules.index(thing)
        elif isinstance(thing, Fighter):
            self.data = fit.projectedFighters.index(thing)
            self.type = 'fighter'
        else:
            # todo: fix!
            self.data = thing.ID
            self.type = 'fit'
Пример #2
0
 def __init__(self, fitID, mode):
     wx.Command.__init__(self, True, "Mode Set")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.internal_history = wx.CommandProcessor()
     self.fitID = fitID
     self.mode = mode
Пример #3
0
 def __init__(self, fitID, newName):
     wx.Command.__init__(self, True)
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.fitID = fitID
     self.newName = newName
     self.internal_history = wx.CommandProcessor()
Пример #4
0
 def __init__(self, fitID, position):
     wx.Command.__init__(self, True, "Module Remove")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.fitID = fitID
     self.position = position
     self.internal_history = wx.CommandProcessor()
Пример #5
0
 def __init__(self, fitID, itemID):
     wx.Command.__init__(self, True, "Fighter Add")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.internal_history = wx.CommandProcessor()
     self.fitID = fitID
     self.itemID = itemID
Пример #6
0
 def __init__(self, fitID, source):
     wx.Command.__init__(self, True, "Implant Source Change")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.internal_history = wx.CommandProcessor()
     self.fitID = fitID
     self.source = source
Пример #7
0
 def __init__(self, fitID, id, type='item'):
     wx.Command.__init__(self, True, "Projected Add")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.internal_history = wx.CommandProcessor()
     self.fitID = fitID
     self.id = id
     self.type = type
Пример #8
0
    def __init__(self, binary: Optional[bytes] = None) -> None:
        if binary is None:
            self._binary = bytearray()
        else:
            self._binary = bytearray(binary)

        self.on_binary_changed = BinaryChangedCallbackList()
        self.command_processor = wx.CommandProcessor()
Пример #9
0
 def __init__(self, fitID, itemID, modules):
     wx.Command.__init__(self, True, "Module Charge Add")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.internal_history = wx.CommandProcessor()
     self.fitID = fitID
     self.itemID = itemID
     self.positions = [mod.modPosition for mod in modules]
Пример #10
0
 def __init__(self, fitID, position, amount=1):
     wx.Command.__init__(self, True, "")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.fitID = fitID
     self.position = position
     self.amount = amount
     self.internal_history = wx.CommandProcessor()
Пример #11
0
 def __init__(self, fitID, itemID, amount=1, replace=False):
     wx.Command.__init__(self, True, "Cargo Add")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.internal_history = wx.CommandProcessor()
     self.fitID = fitID
     self.itemID = itemID
     self.amount = amount
     self.replace = replace
Пример #12
0
 def __init__(self, fitID, module, spoolupType, spoolupAmount):
     wx.Command.__init__(self, True, "Booster Add")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.internal_history = wx.CommandProcessor()
     self.fitID = fitID
     self.position = module.modPosition
     self.spoolType = spoolupType
     self.spoolupAmount = spoolupAmount
Пример #13
0
 def __init__(self, fitID, srcPosition, dstPosition, clone=False):
     wx.Command.__init__(self, True, "Module State Change")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.fitID = fitID
     self.srcPosition = srcPosition
     self.dstPosition = dstPosition
     self.clone = clone
     self.internal_history = wx.CommandProcessor()
Пример #14
0
 def __init__(self, fitID, moduleIdx, cargoIdx, copy=False):
     wx.Command.__init__(self, True, "Module State Change")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.fitID = fitID
     self.moduleIdx = moduleIdx
     self.cargoIdx = cargoIdx
     self.copy = copy
     self.internal_history = wx.CommandProcessor()
Пример #15
0
 def __init__(self, fitID, baseMod, modules, click):
     # todo: instead of modules, needs to be positions. Dead objects are a thing
     wx.Command.__init__(self, True, "Module State Change")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.fitID = fitID
     self.baseMod = baseMod
     self.modules = modules
     self.click = click
     self.internal_history = wx.CommandProcessor()
Пример #16
0
 def __init__(self, fitID, baseItem, mutaItem, attrMap):
     wx.Command.__init__(
         self, True,
         "Mutated Module Import: {} {} {}".format(baseItem, mutaItem,
                                                  attrMap))
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.sFit = Fit.getInstance()
     self.fitID = fitID
     self.baseItem = baseItem
     self.mutaItem = mutaItem
     self.attrMap = attrMap
     self.internal_history = wx.CommandProcessor()
Пример #17
0
    def __init__(self, fitID, modules):
        """
        Handles removing modules from fit.modules,

        :param fitID: The fit ID that we are modifying
        :param modules: A list of Module objects that we are attempting to remove.
        """
        wx.Command.__init__(self, True, "Module Remove")
        self.mainFrame = gui.mainFrame.MainFrame.getInstance()
        self.sFit = Fit.getInstance()
        self.fitID = fitID
        self.modCache = [
            ModuleInfoCache(mod.modPosition, mod.item.ID, mod.state,
                            mod.charge, mod.baseItemID, mod.mutaplasmidID)
            for mod in modules if not mod.isEmpty
        ]
        self.internal_history = wx.CommandProcessor()
Пример #18
0
    def __init__(self, fitID, itemID, position=None):
        """
        Handles adding an item, usually a module, to the Fitting Window.

        :param fitID: The fit ID that we are modifying
        :param itemID: The item that is to be added to the Fitting View. If this turns out to be a charge, we attempt to
                       set the charge on the underlying module (requires position)
        :param position: Optional. The position in fit.modules that we are attempting to set the item to
        """
        wx.Command.__init__(self, True, "Module Add: {}".format(itemID))
        self.mainFrame = gui.mainFrame.MainFrame.getInstance()
        self.sFit = Fit.getInstance()
        self.fitID = fitID
        self.itemID = itemID
        self.internal_history = wx.CommandProcessor()
        self.position = position
        self.old_mod = None
Пример #19
0
    def test_cmdproc3(self):
        class MyCommand(wx.Command):
            def __init__(self, *args, **kw):
                wx.Command.__init__(self, *args, **kw)
                self.value = False

            def Do(self):
                self.value = True
                return True

            def Undo(self):
                self.value = False
                return True

            def CanUndo(self):
                return True

        cmdproc = wx.CommandProcessor()
        for name in 'one two three four five'.split():
            cmd = MyCommand(name=name)
            cmdproc.Submit(cmd)

        cmds = cmdproc.GetCommands()
        self.assertEqual(len(cmds), 5)
        self.assertEqual([x.value for x in cmds], [True] * 5)

        self.assertTrue(cmdproc.CanUndo())
        self.assertFalse(cmdproc.CanRedo())

        cmdproc.Undo()
        cmdproc.Undo()
        self.assertEqual([x.value for x in cmds], [True] * 3 + [False] * 2)

        self.assertTrue(cmdproc.CanRedo())
        cmdproc.Redo()
        cmdproc.Redo()
        self.assertEqual([x.value for x in cmds], [True] * 5)

        cmdproc.Undo()
        cmdproc.Undo()
        cmdproc.Submit(MyCommand(name='NewCmd'))
        self.assertEqual(len(cmds), 4)
Пример #20
0
    def __init__(self, fitID, context, itemID, selection: list):
        wx.Command.__init__(self, True, "Meta Swap")
        self.mainFrame = gui.mainFrame.MainFrame.getInstance()
        self.sFit = Fit.getInstance()
        self.internal_history = wx.CommandProcessor()
        self.fitID = fitID
        self.itemID = itemID
        self.context = context
        self.data = []
        fit = self.sFit.getFit(fitID)

        if context == 'fittingModule':
            for x in selection:
                self.data.append(((FitReplaceModuleCommand, fitID,
                                   fit.modules.index(x), itemID), ), )
        elif context == 'implantItem':
            for x in selection:
                idx = fit.implants.index(x)
                self.data.append(((FitRemoveImplantCommand, fitID, idx),
                                  (FitAddImplantCommand, fitID, itemID)))
        elif context == 'boosterItem':
            for x in selection:
                idx = fit.boosters.index(x)
                self.data.append(((FitRemoveBoosterCommand, fitID, idx),
                                  (FitAddBoosterCommand, fitID, itemID)))
        elif context == 'cargoItem':
            for x in selection:
                self.data.append(
                    ((FitRemoveCargoCommand, fitID, x.itemID, 1, True),
                     (FitAddCargoCommand, fitID, itemID, x.amount)))
        elif context == 'fighterItem':
            for x in selection:
                self.data.append(
                    ((FitRemoveFighterCommand, fitID, fit.fighters.index(x)),
                     (FitAddFighterCommand, fitID, itemID)))
        elif context == 'droneItem':
            for x in selection:
                self.data.append(((FitChangeDroneVariationCommand, fitID,
                                   fit.drones.index(x), itemID), ), )
Пример #21
0
 def __init__(self, fitID, rebaseMap):
     wx.Command.__init__(self, True, "Mass Rebase Item")
     self.mainFrame = gui.mainFrame.MainFrame.getInstance()
     self.fitID = fitID
     self.rebaseMap = rebaseMap
     self.internal_history = wx.CommandProcessor()
Пример #22
0
 def getCommandProcessor(cls, fitID):
     if fitID not in cls.processors:
         cls.processors[fitID] = wx.CommandProcessor()
     return cls.processors[fitID]
Пример #23
0
 def __init__(self):
     self.__buffer = wx.CommandProcessor()