Rework implant UI commands

This commit is contained in:
DarkPhoenix
2019-04-14 15:36:30 +03:00
parent e6599d1a40
commit a829efa7ff
10 changed files with 107 additions and 111 deletions

View File

@@ -218,7 +218,7 @@ class ImplantDisplay(d.Display):
col = self.getColumn(event.Position)
if col == self.getColIndex(State):
fitID = self.mainFrame.getActiveFit()
self.mainFrame.command.Submit(cmd.GuiToggleImplantCommand(fitID, row))
self.mainFrame.command.Submit(cmd.GuiToggleImplantStateCommand(fitID, row))
def spawnMenu(self, event):
sel = self.GetFirstSelected()

View File

@@ -7,14 +7,12 @@ from .guiAddCharge import GuiModuleAddChargeCommand
from .guiAddCommand import GuiAddCommandCommand
from .guiAddDrone import GuiAddDroneCommand
from .guiAddFighter import GuiAddFighterCommand
from .guiAddImplant import GuiAddImplantCommand
from .guiAddModule import GuiModuleAddCommand
from .guiAddProjected import GuiAddProjectedCommand
from .guiCargoToModule import GuiCargoToModuleCommand
from .guiChangeCargoQty import GuiChangeCargoQty
from .guiChangeDroneQty import GuiChangeDroneQty
from .guiChangeFighterQty import GuiChangeFighterQty
from .guiChangeImplantLocation import GuiChangeImplantLocation
from .guiChangeProjectedDroneQty import GuiChangeProjectedDroneQty
from .guiChangeProjectedFighterAmount import GuiChangeProjectedFighterAmount
from .guiChangeProjectedFitQty import GuiChangeProjectedFitQty
@@ -30,7 +28,6 @@ from .guiRemoveCargo import GuiRemoveCargoCommand
from .guiRemoveCommand import GuiRemoveCommandCommand
from .guiRemoveDrone import GuiRemoveDroneCommand
from .guiRemoveFighter import GuiRemoveFighterCommand
from .guiRemoveImplant import GuiRemoveImplantCommand
from .guiRemoveModule import GuiModuleRemoveCommand
from .guiRemoveProjected import GuiRemoveProjectedCommand
from .guiSetMode import GuiSetModeCommand
@@ -40,6 +37,9 @@ from .guiToggleCommand import GuiToggleCommandCommand
from .guiToggleDrone import GuiToggleDroneCommand
from .guiToggleFighter import GuiToggleFighterCommand
from .guiToggleFighterAbility import GuiToggleFighterAbilityCommand
from .guiToggleImplant import GuiToggleImplantCommand
from .guiToggleModuleState import GuiModuleStateChangeCommand
from .guiToggleProjected import GuiToggleProjectedCommand
from .implant.add import GuiAddImplantCommand
from .implant.changeLocation import GuiChangeImplantLocation
from .implant.remove import GuiRemoveImplantCommand
from .implant.toggleState import GuiToggleImplantStateCommand

View File

@@ -1,36 +0,0 @@
import wx
from service.fit import Fit
import gui.mainFrame
from eos.const import ImplantLocation
from gui import globalEvents as GE
from gui.fitCommands.helpers import ImplantInfo
from .calcCommands.implant.add import CalcAddImplantCommand
from .calcCommands.implant.changeLocation import CalcChangeImplantLocationCommand
class GuiAddImplantCommand(wx.Command):
def __init__(self, fitID, itemID):
wx.Command.__init__(self, True, "Implant Add")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.internal_history = wx.CommandProcessor()
self.fitID = fitID
self.itemID = itemID
def Do(self):
if (
self.internal_history.Submit(CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=self.itemID))) and
self.internal_history.Submit(CalcChangeImplantLocationCommand(self.fitID, ImplantLocation.FIT))
):
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internal_history.Commands:
self.internal_history.Undo()
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -1,30 +0,0 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calcCommands.implant.changeLocation import CalcChangeImplantLocationCommand
class GuiChangeImplantLocation(wx.Command):
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 Do(self):
if self.internal_history.Submit(CalcChangeImplantLocationCommand(self.fitID, self.source)):
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internal_history.Commands:
self.internal_history.Undo()
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True

View File

@@ -1,30 +0,0 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calcCommands.implant.toggleState import CalcToggleImplantStateCommand
class GuiToggleImplantCommand(wx.Command):
def __init__(self, fitID, position):
wx.Command.__init__(self, True, "")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.internal_history = wx.CommandProcessor()
self.fitID = fitID
self.position = position
def Do(self):
if self.internal_history.Submit(CalcToggleImplantStateCommand(self.fitID, self.position)):
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internal_history.Commands:
self.internal_history.Undo()
self.sFit.recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True

View File

View File

@@ -0,0 +1,34 @@
import wx
import gui.mainFrame
from eos.const import ImplantLocation
from gui import globalEvents as GE
from gui.fitCommands.calcCommands.implant.add import CalcAddImplantCommand
from gui.fitCommands.calcCommands.implant.changeLocation import CalcChangeImplantLocationCommand
from gui.fitCommands.helpers import ImplantInfo, InternalCommandHistory
from service.fit import Fit
class GuiAddImplantCommand(wx.Command):
def __init__(self, fitID, itemID):
wx.Command.__init__(self, True, 'Add Implant')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.itemID = itemID
def Do(self):
if (
self.internalHistory.submit(CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=self.itemID))) and
self.internalHistory.submit(CalcChangeImplantLocationCommand(fitID=self.fitID, source=ImplantLocation.FIT))
):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success

View File

@@ -0,0 +1,29 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calcCommands.implant.changeLocation import CalcChangeImplantLocationCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiChangeImplantLocation(wx.Command):
def __init__(self, fitID, source):
wx.Command.__init__(self, True, 'Change Implant Location')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.source = source
def Do(self):
if self.internalHistory.submit(CalcChangeImplantLocationCommand(fitID=self.fitID, source=self.source)):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success

View File

@@ -3,28 +3,28 @@ from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calcCommands.implant.remove import CalcRemoveImplantCommand
from gui.fitCommands.helpers import InternalCommandHistory
from gui.fitCommands.calcCommands.implant.remove import CalcRemoveImplantCommand
class GuiRemoveImplantCommand(wx.Command):
def __init__(self, fitID, position):
wx.Command.__init__(self, True, "")
wx.Command.__init__(self, True, 'Remove Implant')
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.internal_history = wx.CommandProcessor()
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
def Do(self):
if self.internal_history.Submit(CalcRemoveImplantCommand(self.fitID, self.position)):
self.sFit.recalc(self.fitID)
if self.internalHistory.submit(CalcRemoveImplantCommand(fitID=self.fitID, position=self.position)):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
for _ in self.internal_history.Commands:
self.internal_history.Undo()
self.sFit.recalc(self.fitID)
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
return success

View File

@@ -0,0 +1,29 @@
import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calcCommands.implant.toggleState import CalcToggleImplantStateCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiToggleImplantStateCommand(wx.Command):
def __init__(self, fitID, position):
wx.Command.__init__(self, True, 'Toggle Implant State')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
def Do(self):
if self.internalHistory.submit(CalcToggleImplantStateCommand(fitID=self.fitID, position=self.position)):
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return True
return False
def Undo(self):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success