示例#1
0
    def change(self, event):
        sFit = service.Fit.getInstance()
        mainFrame = gui.mainFrame.MainFrame.getInstance()
        fitID = mainFrame.getActiveFit()

        sFit.addCargo(fitID,
                      self.cargo.item.ID,
                      int(self.input.GetLineText(0)),
                      replace=True)

        wx.PostEvent(mainFrame, GE.FitChanged(fitID=fitID))

        event.Skip()
        self.Destroy()
示例#2
0
    def removeModule(self, modules):
        """Removes a list of modules from the fit"""
        sFit = Fit.getInstance()

        if not isinstance(modules, list):
            modules = [modules]

        positions = [mod.modPosition for mod in modules]
        result = sFit.removeModule(self.activeFitID, positions)

        if result is not None:
            self.slotsChanged()
            ids = {mod.item.ID for mod in modules}
            wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.activeFitID, action="moddel", typeID=ids))
示例#3
0
 def Do(self):
     cmd = CalcToggleCommandFitStatesCommand(
         fitID=self.fitID,
         mainCommandFitID=self.mainCommandFitID,
         commandFitIDs=self.commandFitIDs)
     success = self.internalHistory.submit(cmd)
     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(fitIDs=(self.fitID, )))
     return success
示例#4
0
 def Do(self):
     if self.srcPosition == self.dstPosition:
         return False
     sFit = Fit.getInstance()
     cmd = CalcCloneLocalModuleCommand(fitID=self.fitID,
                                       srcPosition=self.srcPosition,
                                       dstPosition=self.dstPosition)
     success = self.internalHistory.submit(cmd)
     fit = sFit.getFit(self.fitID)
     if cmd.needsGuiRecalc:
         eos.db.flush()
         sFit.recalc(self.fitID)
     self.savedRemovedDummies = sFit.fill(self.fitID)
     eos.db.commit()
     self.savedItemID = fit.modules[self.srcPosition].itemID
     if success and self.savedItemID is not None:
         event = GE.FitChanged(fitIDs=(self.fitID, ),
                               action='modadd',
                               typeID=self.savedItemID)
     else:
         event = GE.FitChanged(fitIDs=(self.fitID, ))
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), event)
     return success
示例#5
0
 def Do(self):
     results = []
     for position in sorted(self.positions, reverse=True):
         cmd = CalcRemoveLocalDroneCommand(fitID=self.fitID,
                                           position=position,
                                           amount=self.amount,
                                           commit=False)
         results.append(self.internalHistory.submit(cmd))
     success = any(results)
     eos.db.commit()
     Fit.getInstance().recalc(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
示例#6
0
 def Do(self):
     info = ModuleInfo(itemID=self.itemID)
     added_modules = 0
     while True:
         cmd = CalcAddLocalModuleCommand(fitID=self.fitID, newModInfo=info)
         if not self.internalHistory.submit(cmd):
             break
         added_modules += 1
     Market.getInstance().storeRecentlyUsed(self.itemID)
     sFit = Fit.getInstance()
     # Only last command decides if we need to recalc here or not
     if cmd.needsGuiRecalc:
         eos.db.flush()
         sFit.recalc(self.fitID)
     self.savedRemovedDummies = sFit.fill(self.fitID)
     eos.db.commit()
     success = added_modules > 0
     wx.PostEvent(
         gui.mainFrame.MainFrame.getInstance(),
         GE.FitChanged(
             fitIDs=(self.fitID, ), action='modadd', typeID=self.itemID)
         if success else GE.FitChanged(fitIDs=(self.fitID, )))
     return success
示例#7
0
文件: clone.py 项目: zwparchman/Pyfa
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     try:
         drone = fit.drones[self.position]
     except IndexError:
         return False
     info = DroneInfo.fromDrone(drone)
     cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=info, forceNewStack=True)
     success = self.internalHistory.submit(cmd)
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
     return success
示例#8
0
 def Do(self):
     results = []
     for position in sorted(self.positions, reverse=True):
         cmd = CalcRemoveImplantCommand(fitID=self.fitID, position=position)
         results.append(self.internalHistory.submit(cmd))
     success = any(results)
     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
示例#9
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     cargo = next((c for c in fit.cargo if c.itemID == self.itemID), None)
     if cargo is None:
         return False
     if cargo.itemID == self.newItemID:
         return False
     amount = cargo.amount
     cmdRemove = CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))
     cmdAdd = CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.newItemID, amount=amount))
     success = self.internalHistory.submitBatch(cmdRemove, cmdAdd)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
     return success
示例#10
0
 def Do(self):
     if self.amount > 0:
         cmd = CalcChangeFighterAmountCommand(fitID=self.fitID,
                                              projected=True,
                                              position=self.position,
                                              amount=self.amount)
     else:
         cmd = CalcRemoveProjectedFighterCommand(fitID=self.fitID,
                                                 position=self.position)
     success = self.internalHistory.submit(cmd)
     Fit.getInstance().recalc(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
示例#11
0
 def Do(self):
     sMkt = Market.getInstance()
     results = []
     for itemID in self.itemIDs:
         cmd = CalcRemoveCargoCommand(fitID=self.fitID,
                                      cargoInfo=CargoInfo(itemID=itemID,
                                                          amount=math.inf))
         results.append(self.internalHistory.submit(cmd))
         sMkt.storeRecentlyUsed(itemID)
     success = any(results)
     eos.db.commit()
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitIDs=(self.fitID, )))
     return success
示例#12
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     fighter = fit.fighters[self.position]
     if fighter.itemID == self.newItemID:
         return False
     info = FighterInfo.fromFighter(fighter)
     info.itemID = self.newItemID
     cmdRemove = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=self.position)
     cmdAdd = CalcAddLocalFighterCommand(fitID=self.fitID, fighterInfo=info)
     success = self.internalHistory.submitBatch(cmdRemove, cmdAdd)
     sFit.recalc(fit)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
     return success
示例#13
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     booster = fit.boosters[self.position]
     if booster.itemID == self.newItemID:
         return False
     info = BoosterInfo.fromBooster(booster)
     info.itemID = self.newItemID
     cmd = CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=info)
     success = self.internalHistory.submit(cmd)
     sFit.recalc(fit)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
示例#14
0
    def fitSelected(self, event):
        if self.parent.IsActive(self):
            fitID = event.fitID
            startup = getattr(event, "startup", False)
            self.activeFitID = fitID
            sFit = service.Fit.getInstance()
            self.updateTab()
            if not startup or startup == 2:  # see OpenFitsThread in gui.mainFrame
                self.Show(fitID is not None)
                self.slotsChanged()
                sFit.switchFit(fitID)
                wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))

        event.Skip()
示例#15
0
    def appendItem(self, event):
        if self.parent.IsActive(self):
            itemID = event.itemID
            fitID = self.activeFitID
            if fitID != None:
                sFit = service.Fit.getInstance()
                if sFit.isAmmo(itemID):
                    modules = []
                    sel = self.GetFirstSelected()
                    while sel != -1 and sel not in self.blanks:
                        modules.append(self.mods[self.GetItemData(sel)])
                        sel = self.GetNextSelected(sel)

                    sFit.setAmmo(fitID, itemID, modules)
                    wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
                else:
                    populate = sFit.appendModule(fitID, itemID)
                    if populate is not None:
                        self.slotsChanged()
                        wx.PostEvent(self.mainFrame,
                                     GE.FitChanged(fitID=fitID))

        event.Skip()
示例#16
0
文件: fill.py 项目: SirAngel029/Pyfa
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     mod = fit.modules[self.position]
     self.savedItemID = mod.itemID
     info = ModuleInfo.fromModule(mod)
     added_modules = 0
     while True:
         cmd = CalcAddLocalModuleCommand(fitID=self.fitID,
                                         newModInfo=info,
                                         commit=False)
         if not self.internalHistory.submit(cmd):
             break
         added_modules += 1
     eos.db.commit()
     sFit.recalc(self.fitID)
     success = added_modules > 0
     wx.PostEvent(
         gui.mainFrame.MainFrame.getInstance(),
         GE.FitChanged(
             fitID=self.fitID, action='modadd', typeID=self.savedItemID)
         if success else GE.FitChanged(fitID=self.fitID))
     return success
示例#17
0
 def Do(self):
     cmd = CalcToggleFighterAbilityStatesCommand(
         fitID=self.fitID,
         projected=False,
         mainPosition=self.mainPosition,
         positions=self.positions,
         effectID=self.effectID)
     success = self.internalHistory.submit(cmd)
     sFit = Fit.getInstance()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
示例#18
0
    def activate(self, fullContext, selection, i):

        srcContext = fullContext[0]
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        fit = sFit.getFit(fitID)

        if srcContext == "fittingModule":
            modules = [module for module in selection if module is not None]
            self.mainFrame.command.Submit(
                cmd.GuiModuleRemoveCommand(fitID, modules))
            return  # the command takes care of the PostEvent
        elif srcContext in ("fittingCharge", "projectedCharge"):
            self.mainFrame.command.Submit(
                cmd.GuiModuleAddChargeCommand(fitID, None, selection))
            return
        elif srcContext == "droneItem":
            self.mainFrame.command.Submit(
                cmd.GuiRemoveDroneCommand(fitID,
                                          fit.drones.index(selection[0])))
            return
        elif srcContext == "fighterItem":
            self.mainFrame.command.Submit(
                cmd.GuiRemoveFighterCommand(fitID,
                                            fit.fighters.index(selection[0])))
            return  # the command takes care of the PostEvent
        elif srcContext == "implantItem":
            self.mainFrame.command.Submit(
                cmd.GuiRemoveImplantCommand(fitID,
                                            fit.implants.index(selection[0])))
            return  # the command takes care of the PostEvent
        elif srcContext == "boosterItem":
            self.mainFrame.command.Submit(
                cmd.GuiRemoveBoosterCommand(fitID,
                                            fit.boosters.index(selection[0])))
            return  # the command takes care of the PostEvent
        elif srcContext == "cargoItem":
            self.mainFrame.command.Submit(
                cmd.GuiRemoveCargoCommand(fitID, selection[0].itemID))
            return  # the command takes care of the PostEvent
        elif srcContext in ("projectedFit", "projectedModule",
                            "projectedDrone", "projectedFighter"):
            self.mainFrame.command.Submit(
                cmd.GuiRemoveProjectedCommand(fitID, selection[0]))
            return  # the command takes care of the PostEvent
        elif srcContext == "commandFit":
            self.mainFrame.command.Submit(
                cmd.GuiRemoveCommandCommand(fitID, selection[0].ID))
            return  # the command takes care of the PostEvent
        wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
示例#19
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     implant = fit.implants[self.position]
     if implant.itemID == self.newItemID:
         return False
     info = ImplantInfo.fromImplant(implant)
     info.itemID = self.newItemID
     cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=info)
     success = self.internalHistory.submit(cmd)
     sFit.recalc(fit)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
示例#20
0
    def onCBGlobalColorBySlot(self, event):
        # todo: maybe create a SettingChanged event that we can fire, and have other things hook into, instead of having the preference panel itself handle the
        # updating of things related to settings.
        self.sFit.serviceFittingOptions[
            "colorFitBySlot"] = self.cbFitColorSlots.GetValue()
        fitID = self.mainFrame.getActiveFit()
        self.sFit.refreshFit(fitID)

        iView = self.mainFrame.marketBrowser.itemView
        if iView.active:
            iView.update(iView.active)

        wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
        event.Skip()
示例#21
0
 def Do(self):
     cmd = CalcChangeLocalDroneMutationCommand(
         fitID=self.fitID,
         position=self.position,
         mutation=self.mutation,
         oldMutation=self.oldMutation)
     success = self.internalHistory.submit(cmd)
     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(fitIDs=(self.fitID,)))
     return success
示例#22
0
 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
示例#23
0
文件: metaSwap.py 项目: a-tal/Pyfa
    def handleModule(self, event):
        item = self.moduleLookup.get(event.Id, None)
        if item is None:
            event.Skip()
            return

        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()
        fit = sFit.getFit(fitID)

        for mod in self.selection:
            pos = fit.modules.index(mod)
            sFit.changeModule(fitID, pos, item.ID)

        wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
示例#24
0
    def swapCargo(self, x, y, srcIdx):
        '''Swap a module from cargo to fitting window'''
        mstate = wx.GetMouseState()

        dstRow, _ = self.HitTest((x, y))
        if dstRow != -1 and dstRow not in self.blanks:
            module = self.mods[dstRow]

            sFit = service.Fit.getInstance()
            sFit.moveCargoToModule(self.mainFrame.getActiveFit(),
                                   module.position, srcIdx,
                                   mstate.CmdDown() and module.isEmpty)

            wx.PostEvent(self.mainFrame,
                         GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
示例#25
0
 def Do(self):
     cmd = CalcChangeModuleSpoolCommand(fitID=self.fitID,
                                        projected=True,
                                        position=self.position,
                                        spoolType=self.spoolType,
                                        spoolAmount=self.spoolAmount)
     success = self.internalHistory.submit(cmd)
     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(fitIDs=(self.fitID, )))
     return success
示例#26
0
    def addItem(self, event):
        sFit = Fit.getInstance()
        fitID = self.mainFrame.getActiveFit()

        fit = sFit.getFit(fitID)

        if fit.isStructure:
            return

        trigger = sFit.addImplant(fitID, event.itemID)
        if trigger:
            wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
            self.mainFrame.additionsPane.select("Implants")

        event.Skip()
示例#27
0
    def handleListDrag(self, x, y, data):
        """
        Handles dragging of items from various pyfa displays which support it

        data is list with two indices:
            data[0] is hard-coded str of originating source
            data[1] is typeID or index of data we want to manipulate
        """
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.mainFrame.getActiveFit())

        if data[0] == "projected":
            # if source is coming from projected, we are trying to combine drones.
            self.mergeDrones(x, y, int(data[1]))
        elif data[0] == "fitting":
            dstRow, _ = self.HitTest((x, y))
            # Gather module information to get position
            module = fit.modules[int(data[1])]
            sFit.project(fit.ID, module.item.ID)
            wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fit.ID))
        elif data[0] == "market":
            sFit = Fit.getInstance()
            sFit.project(fit.ID, int(data[1]))
            wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fit.ID))
示例#28
0
文件: cargoView.py 项目: w9jds/Pyfa
    def handleListDrag(self, x, y, data):
        """
        Handles dragging of items from various pyfa displays which support it

        data is list with two indices:
            data[0] is hard-coded str of originating source
            data[1] is typeID or index of data we want to manipulate
        """

        if data[0] == "fitting":
            self.swapModule(x, y, int(data[1]))
        elif data[0] == "market":
            sFit = Fit.getInstance()
            sFit.addCargo(self.mainFrame.getActiveFit(), int(data[1]), 1)
            wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
 def Do(self):
     if self.amount > 0:
         cmd = CalcChangeCargoAmountCommand(fitID=self.fitID,
                                            cargoInfo=CargoInfo(
                                                itemID=self.itemID,
                                                amount=self.amount))
     else:
         cmd = CalcRemoveCargoCommand(fitID=self.fitID,
                                      cargoInfo=CargoInfo(
                                          itemID=self.itemID,
                                          amount=math.inf))
     success = self.internalHistory.submit(cmd)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
示例#30
0
 def Do(self):
     cmd = CalcAddProjectedDroneCommand(fitID=self.fitID,
                                        droneInfo=DroneInfo(
                                            itemID=self.itemID,
                                            amount=1,
                                            amountActive=1))
     success = self.internalHistory.submit(cmd)
     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