Implant and cargo conversions
This commit is contained in:
@@ -9,7 +9,7 @@ from service.fit import Fit
|
||||
from eos.saveddata.cargo import Cargo as es_Cargo
|
||||
from eos.saveddata.fighter import Fighter as es_Fighter
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
|
||||
class ChangeAmount(ContextMenu):
|
||||
def __init__(self):
|
||||
@@ -45,7 +45,8 @@ class ChangeAmount(ContextMenu):
|
||||
cleanInput = re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip())
|
||||
|
||||
if isinstance(thing, es_Cargo):
|
||||
sFit.addCargo(fitID, thing.item.ID, int(float(cleanInput)), replace=True)
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCargoCommand(fitID, thing.item.ID, int(float(cleanInput)), replace=True))
|
||||
return # no need for post event here
|
||||
elif isinstance(thing, es_Fit):
|
||||
sFit.changeAmount(fitID, thing, int(float(cleanInput)))
|
||||
elif isinstance(thing, es_Fighter):
|
||||
|
||||
@@ -4,7 +4,7 @@ import gui.globalEvents as GE
|
||||
import wx
|
||||
from service.settings import ContextMenuSettings
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
|
||||
class CargoAmmo(ContextMenu):
|
||||
def __init__(self):
|
||||
@@ -28,13 +28,10 @@ class CargoAmmo(ContextMenu):
|
||||
return "Add {0} to Cargo (x1000)".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
sFit = Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
typeID = int(selection[0].ID)
|
||||
sFit.addCargo(fitID, typeID, 1000)
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCargoCommand(fitID, typeID, 1000))
|
||||
self.mainFrame.additionsPane.select("Cargo")
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
CargoAmmo.register()
|
||||
|
||||
@@ -45,7 +45,8 @@ class ItemRemove(ContextMenu):
|
||||
elif srcContext == "fighterItem":
|
||||
sFit.removeFighter(fitID, fit.fighters.index(selection[0]))
|
||||
elif srcContext == "implantItem":
|
||||
sFit.removeImplant(fitID, fit.implants.index(selection[0]))
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveImplantCommand(fitID, fit.implants.index(selection[0])))
|
||||
return # the command takes care of the PostEvent
|
||||
elif srcContext == "boosterItem":
|
||||
sFit.removeBooster(fitID, fit.boosters.index(selection[0]))
|
||||
elif srcContext == "cargoItem":
|
||||
|
||||
@@ -15,7 +15,7 @@ from eos.saveddata.drone import Drone
|
||||
from eos.saveddata.fighter import Fighter
|
||||
from eos.saveddata.implant import Implant
|
||||
from eos.saveddata.cargo import Cargo
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
|
||||
class MetaSwap(ContextMenu):
|
||||
def __init__(self):
|
||||
@@ -183,16 +183,18 @@ class MetaSwap(ContextMenu):
|
||||
elif isinstance(selected_item, Implant):
|
||||
for idx, implant_stack in enumerate(fit.implants):
|
||||
if implant_stack is selected_item:
|
||||
sFit.removeImplant(fitID, idx, False)
|
||||
sFit.addImplant(fitID, item.ID, True)
|
||||
break
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveImplantCommand(fitID, idx))
|
||||
self.mainFrame.command.Submit(cmd.GuiAddImplantCommand(fitID, item.ID))
|
||||
return
|
||||
|
||||
elif isinstance(selected_item, Cargo):
|
||||
for idx, cargo_stack in enumerate(fit.cargo):
|
||||
if cargo_stack is selected_item:
|
||||
# todo: make a command to change varieance of all items, or maybe per item type, which would
|
||||
# utilize the two fitting commands that we need to remove then add?
|
||||
sFit.removeCargo(fitID, idx)
|
||||
sFit.addCargo(fitID, item.ID, cargo_stack.amount, True)
|
||||
break
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCargoCommand(fitID, item.ID, cargo_stack.amount, True))
|
||||
return # don't need the post event
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user