当前位置: 首页>>代码示例>>Python>>正文


Python InternalCommandHistory.submitBatch方法代码示例

本文整理汇总了Python中gui.fitCommands.helpers.InternalCommandHistory.submitBatch方法的典型用法代码示例。如果您正苦于以下问题:Python InternalCommandHistory.submitBatch方法的具体用法?Python InternalCommandHistory.submitBatch怎么用?Python InternalCommandHistory.submitBatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gui.fitCommands.helpers.InternalCommandHistory的用法示例。


在下文中一共展示了InternalCommandHistory.submitBatch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GuiChangeLocalDroneMetasCommand

# 需要导入模块: from gui.fitCommands.helpers import InternalCommandHistory [as 别名]
# 或者: from gui.fitCommands.helpers.InternalCommandHistory import submitBatch [as 别名]
class GuiChangeLocalDroneMetasCommand(wx.Command):

    def __init__(self, fitID, positions, newItemID):
        wx.Command.__init__(self, True, 'Change Local Drone Meta')
        self.internalHistory = InternalCommandHistory()
        self.fitID = fitID
        self.positions = positions
        self.newItemID = newItemID

    def Do(self):
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.fitID)
        results = []
        for position in sorted(self.positions, reverse=True):
            drone = fit.drones[position]
            if drone.itemID == self.newItemID:
                continue
            info = DroneInfo.fromDrone(drone)
            info.itemID = self.newItemID
            cmdRemove = CalcRemoveLocalDroneCommand(
                fitID=self.fitID,
                position=position,
                amount=math.inf)
            cmdAdd = CalcAddLocalDroneCommand(
                fitID=self.fitID,
                droneInfo=info,
                forceNewStack=True,
                ignoreRestrictions=True)
            results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd))
        success = any(results)
        eos.db.flush()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success

    def Undo(self):
        success = self.internalHistory.undoAll()
        eos.db.flush()
        sFit = Fit.getInstance()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success
开发者ID:,项目名称:,代码行数:48,代码来源:

示例2: GuiMergeLocalDroneStacksCommand

# 需要导入模块: from gui.fitCommands.helpers import InternalCommandHistory [as 别名]
# 或者: from gui.fitCommands.helpers.InternalCommandHistory import submitBatch [as 别名]
class GuiMergeLocalDroneStacksCommand(wx.Command):

    def __init__(self, fitID, srcPosition, dstPosition):
        wx.Command.__init__(self, True, 'Merge Local Drone Stacks')
        self.internalHistory = InternalCommandHistory()
        self.fitID = fitID
        self.srcPosition = srcPosition
        self.dstPosition = dstPosition

    def Do(self):
        if self.srcPosition == self.dstPosition:
            return False
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.fitID)
        srcDrone = fit.drones[self.srcPosition]
        dstDrone = fit.drones[self.dstPosition]
        if srcDrone.itemID != dstDrone.itemID:
            return False
        srcAmount = srcDrone.amount
        commands = []
        commands.append(CalcChangeLocalDroneAmountCommand(
            fitID=self.fitID,
            position=self.dstPosition,
            amount=dstDrone.amount + srcAmount))
        commands.append(CalcRemoveLocalDroneCommand(
            fitID=self.fitID,
            position=self.srcPosition,
            amount=srcAmount))
        success = self.internalHistory.submitBatch(*commands)
        eos.db.flush()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success

    def Undo(self):
        success = self.internalHistory.undoAll()
        eos.db.flush()
        sFit = Fit.getInstance()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success
开发者ID:,项目名称:,代码行数:47,代码来源:

示例3: GuiSplitLocalDroneStackCommand

# 需要导入模块: from gui.fitCommands.helpers import InternalCommandHistory [as 别名]
# 或者: from gui.fitCommands.helpers.InternalCommandHistory import submitBatch [as 别名]
class GuiSplitLocalDroneStackCommand(wx.Command):

    def __init__(self, fitID, position, amount):
        wx.Command.__init__(self, True, 'Split Local Drone Stack')
        self.internalHistory = InternalCommandHistory()
        self.fitID = fitID
        self.position = position
        self.amount = amount

    def Do(self):
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.fitID)
        drone = fit.drones[self.position]
        if self.amount >= drone.amount:
            return False
        info = DroneInfo.fromDrone(drone)
        info.amount = self.amount
        info.amountActive = min(self.amount, info.amountActive)
        commands = []
        commands.append(CalcRemoveLocalDroneCommand(
            fitID=self.fitID,
            position=self.position,
            amount=self.amount))
        commands.append(CalcAddLocalDroneCommand(
            fitID=self.fitID,
            droneInfo=info,
            forceNewStack=True,
            ignoreRestrictions=True))
        success = self.internalHistory.submitBatch(*commands)
        eos.db.flush()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success

    def Undo(self):
        success = self.internalHistory.undoAll()
        eos.db.flush()
        sFit = Fit.getInstance()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success
开发者ID:,项目名称:,代码行数:47,代码来源:

示例4: GuiChangeProjectedDroneMetasCommand

# 需要导入模块: from gui.fitCommands.helpers import InternalCommandHistory [as 别名]
# 或者: from gui.fitCommands.helpers.InternalCommandHistory import submitBatch [as 别名]
class GuiChangeProjectedDroneMetasCommand(wx.Command):

    def __init__(self, fitID, itemIDs, newItemID):
        wx.Command.__init__(self, True, 'Change Projected Drone Metas')
        self.internalHistory = InternalCommandHistory()
        self.fitID = fitID
        self.itemIDs = itemIDs
        self.newItemID = newItemID

    def Do(self):
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.fitID)
        results = []
        for itemID in self.itemIDs:
            drone = next((pd for pd in fit.projectedDrones if pd.itemID == itemID), None)
            if drone is None:
                continue
            if drone.itemID == self.newItemID:
                continue
            info = DroneInfo.fromDrone(drone)
            info.itemID = self.newItemID
            cmdRemove = CalcRemoveProjectedDroneCommand(fitID=self.fitID, itemID=itemID, amount=math.inf)
            cmdAdd = CalcAddProjectedDroneCommand(fitID=self.fitID, droneInfo=info)
            results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd))
        success = any(results)
        eos.db.flush()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success

    def Undo(self):
        success = self.internalHistory.undoAll()
        eos.db.flush()
        sFit = Fit.getInstance()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success
开发者ID:,项目名称:,代码行数:43,代码来源:

示例5: GuiChangeProjectedModuleMetasCommand

# 需要导入模块: from gui.fitCommands.helpers import InternalCommandHistory [as 别名]
# 或者: from gui.fitCommands.helpers.InternalCommandHistory import submitBatch [as 别名]
class GuiChangeProjectedModuleMetasCommand(wx.Command):

    def __init__(self, fitID, positions, newItemID):
        wx.Command.__init__(self, True, 'Change Projected Module Metas')
        self.internalHistory = InternalCommandHistory()
        self.fitID = fitID
        self.positions = positions
        self.newItemID = newItemID

    def Do(self):
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.fitID)
        results = []
        for position in sorted(self.positions, reverse=True):
            module = fit.projectedModules[position]
            if module.itemID == self.newItemID:
                continue
            info = ModuleInfo.fromModule(module)
            info.itemID = self.newItemID
            cmdRemove = CalcRemoveProjectedModuleCommand(fitID=self.fitID, position=position)
            cmdAdd = CalcAddProjectedModuleCommand(fitID=self.fitID, modInfo=info)
            results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd))
        success = any(results)
        eos.db.flush()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success

    def Undo(self):
        success = self.internalHistory.undoAll()
        eos.db.flush()
        sFit = Fit.getInstance()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success
开发者ID:,项目名称:,代码行数:41,代码来源:

示例6: GuiChangeCargoMetasCommand

# 需要导入模块: from gui.fitCommands.helpers import InternalCommandHistory [as 别名]
# 或者: from gui.fitCommands.helpers.InternalCommandHistory import submitBatch [as 别名]
class GuiChangeCargoMetasCommand(wx.Command):

    def __init__(self, fitID, itemIDs, newItemID):
        wx.Command.__init__(self, True, 'Change Cargo Metas')
        self.internalHistory = InternalCommandHistory()
        self.fitID = fitID
        self.itemIDs = itemIDs
        self.newItemID = newItemID

    def Do(self):
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.fitID)
        results = []
        for itemID in self.itemIDs:
            if itemID == self.newItemID:
                continue
            cargo = next((c for c in fit.cargo if c.itemID == itemID), None)
            if cargo is None:
                continue
            amount = cargo.amount
            cmdRemove = CalcRemoveCargoCommand(
                fitID=self.fitID,
                cargoInfo=CargoInfo(itemID=itemID, amount=math.inf))
            cmdAdd = CalcAddCargoCommand(
                fitID=self.fitID,
                cargoInfo=CargoInfo(itemID=self.newItemID, amount=amount))
            results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd))
        success = any(results)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success

    def Undo(self):
        success = self.internalHistory.undoAll()
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success
开发者ID:,项目名称:,代码行数:39,代码来源:

示例7: GuiLocalModuleToCargoCommand

# 需要导入模块: from gui.fitCommands.helpers import InternalCommandHistory [as 别名]
# 或者: from gui.fitCommands.helpers.InternalCommandHistory import submitBatch [as 别名]
class GuiLocalModuleToCargoCommand(wx.Command):

    def __init__(self, fitID, modPosition, cargoItemID, copy):
        wx.Command.__init__(self, True, 'Local Module to Cargo')
        self.internalHistory = InternalCommandHistory()
        self.fitID = fitID
        self.srcModPosition = modPosition
        self.dstCargoItemID = cargoItemID
        self.copy = copy
        self.removedModItemID = None
        self.addedModItemID = None
        self.savedRemovedDummies = None

    def Do(self):
        fit = Fit.getInstance().getFit(self.fitID)
        srcMod = fit.modules[self.srcModPosition]
        if srcMod.isEmpty:
            return False
        srcModItemID = srcMod.itemID
        dstCargo = next((c for c in fit.cargo if c.itemID == self.dstCargoItemID), None)
        success = False
        # Attempt to swap if we're moving our module onto a module in the cargo hold
        if not self.copy and dstCargo is not None and dstCargo.item.isModule:
            if srcModItemID == self.dstCargoItemID:
                return False
            srcModSlot = srcMod.slot
            newModInfo = ModuleInfo.fromModule(srcMod, unmutate=True)
            newModInfo.itemID = self.dstCargoItemID
            srcModChargeItemID = srcMod.chargeID
            srcModChargeAmount = srcMod.numCharges
            commands = []
            commands.append(CalcRemoveCargoCommand(
                fitID=self.fitID,
                cargoInfo=CargoInfo(itemID=self.dstCargoItemID, amount=1)))
            commands.append(CalcAddCargoCommand(
                fitID=self.fitID,
                # We cannot put mutated items to cargo, so use unmutated item ID
                cargoInfo=CargoInfo(itemID=ModuleInfo.fromModule(srcMod, unmutate=True).itemID, amount=1)))
            cmdReplace = CalcReplaceLocalModuleCommand(
                fitID=self.fitID,
                position=self.srcModPosition,
                newModInfo=newModInfo,
                unloadInvalidCharges=True)
            commands.append(cmdReplace)
            # Submit batch now because we need to have updated info on fit to keep going
            success = self.internalHistory.submitBatch(*commands)
            newMod = fit.modules[self.srcModPosition]
            # Process charge changes if module is moved to proper slot
            if newMod.slot == srcModSlot:
                # If we had to unload charge, add it to cargo
                if cmdReplace.unloadedCharge and srcModChargeItemID is not None:
                    cmdAddCargoCharge = CalcAddCargoCommand(
                        fitID=self.fitID,
                        cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=srcModChargeAmount))
                    success = self.internalHistory.submit(cmdAddCargoCharge)
                # If we did not unload charge and there still was a charge, see if amount differs and process it
                elif not cmdReplace.unloadedCharge and srcModChargeItemID is not None:
                    # How many extra charges do we need to take from cargo
                    extraChargeAmount = newMod.numCharges - srcModChargeAmount
                    if extraChargeAmount > 0:
                        cmdRemoveCargoExtraCharge = CalcRemoveCargoCommand(
                            fitID=self.fitID,
                            cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=extraChargeAmount))
                        # Do not check if operation was successful or not, we're okay if we have no such
                        # charges in cargo
                        self.internalHistory.submit(cmdRemoveCargoExtraCharge)
                    elif extraChargeAmount < 0:
                        cmdAddCargoExtraCharge = CalcAddCargoCommand(
                            fitID=self.fitID,
                            cargoInfo=CargoInfo(itemID=srcModChargeItemID, amount=abs(extraChargeAmount)))
                        success = self.internalHistory.submit(cmdAddCargoExtraCharge)
                if success:
                    # Store info to properly send events later
                    self.removedModItemID = srcModItemID
                    self.addedModItemID = self.dstCargoItemID
            # If drag happened to module which cannot be fit into current slot - consider it as failure
            else:
                success = False
            # And in case of any failures, cancel everything to try to do move instead
            if not success:
                self.internalHistory.undoAll()
        # Just dump module and its charges into cargo when copying or moving to cargo
        if not success:
            commands = []
            commands.append(CalcAddCargoCommand(
                fitID=self.fitID,
                cargoInfo=CargoInfo(itemID=ModuleInfo.fromModule(srcMod, unmutate=True).itemID, amount=1)))
            if srcMod.chargeID is not None:
                commands.append(CalcAddCargoCommand(
                    fitID=self.fitID,
                    cargoInfo=CargoInfo(itemID=srcMod.chargeID, amount=srcMod.numCharges)))
            if not self.copy:
                commands.append(CalcRemoveLocalModulesCommand(
                    fitID=self.fitID,
                    positions=[self.srcModPosition]))
            success = self.internalHistory.submitBatch(*commands)
        eos.db.flush()
        sFit = Fit.getInstance()
        sFit.recalc(self.fitID)
        self.savedRemovedDummies = sFit.fill(self.fitID)
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例8: GuiRebaseItemsCommand

# 需要导入模块: from gui.fitCommands.helpers import InternalCommandHistory [as 别名]
# 或者: from gui.fitCommands.helpers.InternalCommandHistory import submitBatch [as 别名]
class GuiRebaseItemsCommand(wx.Command):

    def __init__(self, fitID, rebaseMap):
        wx.Command.__init__(self, True, 'Rebase Items')
        self.internalHistory = InternalCommandHistory()
        self.fitID = fitID
        self.rebaseMap = rebaseMap

    def Do(self):
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.fitID)
        for mod in fit.modules:
            if mod.itemID in self.rebaseMap:
                cmd = CalcRebaseItemCommand(
                    fitID=self.fitID,
                    containerName='modules',
                    position=fit.modules.index(mod),
                    itemID=self.rebaseMap[mod.itemID])
                self.internalHistory.submit(cmd)
            if mod.chargeID in self.rebaseMap:
                cmd = CalcChangeModuleChargesCommand(
                    fitID=self.fitID,
                    projected=False,
                    chargeMap={fit.modules.index(mod): self.rebaseMap[mod.chargeID]})
                self.internalHistory.submit(cmd)
        for containerName in ('drones', 'fighters', 'implants', 'boosters'):
            container = getattr(fit, containerName)
            for obj in container:
                if obj.itemID in self.rebaseMap:
                    cmd = CalcRebaseItemCommand(
                        fitID=self.fitID,
                        containerName=containerName,
                        position=container.index(obj),
                        itemID=self.rebaseMap[obj.itemID])
                    self.internalHistory.submit(cmd)
        # Need to process cargo separately as we want to merge items when needed,
        # e.g. FN iron and CN iron into single stack of CN iron
        for cargo in fit.cargo:
            if cargo.itemID in self.rebaseMap:
                amount = cargo.amount
                cmdRemove = CalcRemoveCargoCommand(
                    fitID=self.fitID,
                    cargoInfo=CargoInfo(itemID=cargo.itemID, amount=amount))
                cmdAdd = CalcAddCargoCommand(
                    fitID=self.fitID,
                    cargoInfo=CargoInfo(itemID=self.rebaseMap[cargo.itemID], amount=amount))
                self.internalHistory.submitBatch(cmdRemove, cmdAdd)
        eos.db.flush()
        sFit.recalc(fit)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return len(self.internalHistory) > 0

    def Undo(self):
        sFit = Fit.getInstance()
        success = self.internalHistory.undoAll()
        eos.db.flush()
        sFit.recalc(self.fitID)
        sFit.fill(self.fitID)
        eos.db.commit()
        wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
        return success
开发者ID:,项目名称:,代码行数:65,代码来源:


注:本文中的gui.fitCommands.helpers.InternalCommandHistory.submitBatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。