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'
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
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()
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()
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
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
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
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()
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]
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()
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
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
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()
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()
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()
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()
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()
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
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)
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), ), )
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()
def getCommandProcessor(cls, fitID): if fitID not in cls.processors: cls.processors[fitID] = wx.CommandProcessor() return cls.processors[fitID]
def __init__(self): self.__buffer = wx.CommandProcessor()