Rework command-related GUI commands
This commit is contained in:
@@ -99,14 +99,14 @@ class CommandView(d.Display):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
row = self.GetFirstSelected()
|
||||
if row != -1:
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCommandCommand(fitID, self.get(row).ID))
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitCommand(fitID, self.get(row).ID))
|
||||
|
||||
def handleDrag(self, type, fitID):
|
||||
# Those are drags coming from pyfa sources, NOT builtin wx drags
|
||||
if type == "fit":
|
||||
activeFit = self.mainFrame.getActiveFit()
|
||||
if activeFit:
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandCommand(activeFit, fitID))
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(activeFit, fitID))
|
||||
|
||||
def startDrag(self, event):
|
||||
row = event.GetIndex()
|
||||
@@ -182,7 +182,7 @@ class CommandView(d.Display):
|
||||
col = self.getColumn(event.Position)
|
||||
if col == self.getColIndex(State):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
self.mainFrame.command.Submit(cmd.GuiToggleCommandCommand(fitID, item.ID))
|
||||
self.mainFrame.command.Submit(cmd.GuiToggleCommandFitStateCommand(fitID, item.ID))
|
||||
|
||||
def spawnMenu(self, event):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
@@ -211,4 +211,4 @@ class CommandView(d.Display):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
thing = self.get(row)
|
||||
if thing: # thing doesn't exist if it's the dummy value
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCommandCommand(fitID, thing.ID))
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitCommand(fitID, thing.ID))
|
||||
|
||||
@@ -98,7 +98,7 @@ class CommandFits(ContextMenu):
|
||||
return
|
||||
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandCommand(fitID, fit.ID))
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID, fit.ID))
|
||||
|
||||
|
||||
CommandFits.populateFits(None)
|
||||
|
||||
@@ -61,7 +61,7 @@ class ItemRemove(ContextMenu):
|
||||
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))
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitCommand(fitID, selection[0].ID))
|
||||
return # the command takes care of the PostEvent
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class TabbedFits(ContextMenu):
|
||||
fit = self.fitLookup[event.Id]
|
||||
|
||||
if self.context == 'commandView':
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandCommand(fitID, fit.ID))
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID, fit.ID))
|
||||
elif self.context == 'projected':
|
||||
self.mainFrame.command.Submit(cmd.GuiAddProjectedCommand(fitID, fit.ID, 'fit'))
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
def OnAddCommandFit(self, event):
|
||||
activeFit = self.mainFrame.getActiveFit()
|
||||
if activeFit:
|
||||
if self.mainFrame.command.Submit(cmd.GuiAddCommandCommand(activeFit, self.fitID)):
|
||||
if self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(activeFit, self.fitID)):
|
||||
self.mainFrame.additionsPane.select("Command")
|
||||
|
||||
def OnMouseCaptureLost(self, event):
|
||||
|
||||
@@ -5,8 +5,10 @@ from .booster.toggleState import GuiToggleBoosterStateCommand
|
||||
from .cargo.add import GuiAddCargoCommand
|
||||
from .cargo.changeAmount import GuiChangeCargoAmount
|
||||
from .cargo.remove import GuiRemoveCargoCommand
|
||||
from .commandFit.add import GuiAddCommandFitCommand
|
||||
from .commandFit.remove import GuiRemoveCommandFitCommand
|
||||
from .commandFit.toggleState import GuiToggleCommandFitStateCommand
|
||||
from .guiAddCharge import GuiModuleAddChargeCommand
|
||||
from .guiAddCommand import GuiAddCommandCommand
|
||||
from .guiAddDrone import GuiAddDroneCommand
|
||||
from .guiAddFighter import GuiAddFighterCommand
|
||||
from .guiAddModule import GuiModuleAddCommand
|
||||
@@ -25,7 +27,6 @@ from .guiModuleToCargo import GuiModuleToCargoCommand
|
||||
from .guiMutaConvert import GuiMutaConvertCommand
|
||||
from .guiMutaRevert import GuiMutaRevertCommand
|
||||
from .guiRebaseItems import GuiRebaseItemsCommand
|
||||
from .guiRemoveCommand import GuiRemoveCommandCommand
|
||||
from .guiRemoveDrone import GuiRemoveDroneCommand
|
||||
from .guiRemoveFighter import GuiRemoveFighterCommand
|
||||
from .guiRemoveModule import GuiModuleRemoveCommand
|
||||
@@ -33,7 +34,6 @@ from .guiRemoveProjected import GuiRemoveProjectedCommand
|
||||
from .guiSetMode import GuiSetModeCommand
|
||||
from .guiSetSpoolup import GuiSetSpoolup
|
||||
from .guiSwapCloneModule import GuiModuleSwapOrCloneCommand
|
||||
from .guiToggleCommand import GuiToggleCommandCommand
|
||||
from .guiToggleDrone import GuiToggleDroneCommand
|
||||
from .guiToggleFighter import GuiToggleFighterCommand
|
||||
from .guiToggleFighterAbility import GuiToggleFighterAbilityCommand
|
||||
|
||||
0
gui/fitCommands/commandFit/__init__.py
Normal file
0
gui/fitCommands/commandFit/__init__.py
Normal file
@@ -1,28 +1,29 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calcCommands.commandFit.add import CalcAddCommandCommand
|
||||
from gui.fitCommands.calcCommands.commandFit.add import CalcAddCommandCommand
|
||||
from gui.fitCommands.helpers import InternalCommandHistory
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class GuiAddCommandCommand(wx.Command):
|
||||
class GuiAddCommandFitCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, commandFitID):
|
||||
wx.Command.__init__(self, True, "")
|
||||
self.internalHistory = wx.CommandProcessor()
|
||||
wx.Command.__init__(self, True, 'Add Command Fit')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.commandFitID = commandFitID
|
||||
|
||||
def Do(self):
|
||||
if self.internalHistory.Submit(CalcAddCommandCommand(self.fitID, self.commandFitID, None)):
|
||||
if self.internalHistory.submit(CalcAddCommandCommand(fitID=self.fitID, commandFitID=self.commandFitID)):
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internalHistory.Commands:
|
||||
self.internalHistory.Undo()
|
||||
success = self.internalHistory.undoAll()
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return success
|
||||
@@ -1,28 +1,29 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calcCommands.commandFit.remove import CalcRemoveCommandCommand
|
||||
from gui.fitCommands.calcCommands.commandFit.remove import CalcRemoveCommandCommand
|
||||
from gui.fitCommands.helpers import InternalCommandHistory
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class GuiRemoveCommandCommand(wx.Command):
|
||||
class GuiRemoveCommandFitCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, commandFitID):
|
||||
wx.Command.__init__(self, True, "")
|
||||
self.internalHistory = wx.CommandProcessor()
|
||||
wx.Command.__init__(self, True, 'Remove Command Fit')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.commandFitID = commandFitID
|
||||
|
||||
def Do(self):
|
||||
if self.internalHistory.Submit(CalcRemoveCommandCommand(self.fitID, self.commandFitID)):
|
||||
if self.internalHistory.submit(CalcRemoveCommandCommand(fitID=self.fitID, commandFitID=self.commandFitID)):
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internalHistory.Commands:
|
||||
self.internalHistory.Undo()
|
||||
success = self.internalHistory.undoAll()
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return success
|
||||
@@ -1,28 +1,29 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calcCommands.commandFit.toggleState import CalcToggleCommandFitStateCommand
|
||||
from gui.fitCommands.calcCommands.commandFit.toggleState import CalcToggleCommandFitStateCommand
|
||||
from gui.fitCommands.helpers import InternalCommandHistory
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class GuiToggleCommandCommand(wx.Command):
|
||||
class GuiToggleCommandFitStateCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, commandFitID):
|
||||
wx.Command.__init__(self, True, "")
|
||||
self.internalHistory = wx.CommandProcessor()
|
||||
wx.Command.__init__(self, True, 'Toggle Command Fit State')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.commandFitID = commandFitID
|
||||
|
||||
def Do(self):
|
||||
if self.internalHistory.Submit(CalcToggleCommandFitStateCommand(self.fitID, self.commandFitID)):
|
||||
if self.internalHistory.submit(CalcToggleCommandFitStateCommand(fitID=self.fitID, commandFitID=self.commandFitID)):
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internalHistory.Commands:
|
||||
self.internalHistory.Undo()
|
||||
success = self.internalHistory.undoAll()
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return success
|
||||
Reference in New Issue
Block a user