Merge branch 'commandRefactor' of https://bitbucket.org/blitzmann/pyfa-playground into commandRefactor
This commit is contained in:
@@ -35,7 +35,7 @@ class DevTools(wx.Dialog):
|
||||
|
||||
def __init__(self, parent):
|
||||
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="Damage Pattern Editor", size=wx.Size(400, 240))
|
||||
|
||||
self.mainFrame = parent
|
||||
self.block = False
|
||||
self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
|
||||
|
||||
@@ -56,13 +56,19 @@ class DevTools(wx.Dialog):
|
||||
self.fitTest = wx.Button(self, wx.ID_ANY, "Test fits", wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
mainSizer.Add(self.fitTest, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
|
||||
|
||||
self.fitTest .Bind(wx.EVT_BUTTON, self.fit_test)
|
||||
self.fitTest.Bind(wx.EVT_BUTTON, self.fit_test)
|
||||
|
||||
self.cmdPrint = wx.Button(self, wx.ID_ANY, "Command Print", wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
mainSizer.Add(self.cmdPrint, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
|
||||
|
||||
self.cmdPrint.Bind(wx.EVT_BUTTON, self.cmd_print)
|
||||
|
||||
self.SetSizer(mainSizer)
|
||||
|
||||
self.Layout()
|
||||
self.CenterOnParent()
|
||||
self.Show()
|
||||
print(parent)
|
||||
|
||||
def objects_by_id(self, evt):
|
||||
input = self.id_get.GetValue()
|
||||
@@ -81,6 +87,11 @@ class DevTools(wx.Dialog):
|
||||
else:
|
||||
print(None)
|
||||
|
||||
def cmd_print(self, evt):
|
||||
print("="*20)
|
||||
for x in self.mainFrame.command.GetCommands():
|
||||
print("{}{} {}".format("==> " if x == self.mainFrame.command.GetCurrentCommand() else "", x.GetName(), x))
|
||||
|
||||
def gc_collect(self, evt):
|
||||
print(gc.collect())
|
||||
print(gc.get_debug())
|
||||
|
||||
@@ -12,18 +12,17 @@ class GuiAddBoosterCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitAddBoosterCommand(fitID, itemID)
|
||||
self.itemID = itemID
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitAddBoosterCommand(self.fitID, self.itemID)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for x in self.internal_history.Commands:
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
|
||||
@@ -12,18 +12,19 @@ class GuiAddCargoCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitAddCargoCommand(fitID, itemID, amount, replace)
|
||||
self.itemID = itemID
|
||||
self.amount = amount
|
||||
self.replace = replace
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitAddCargoCommand(self.fitID, self.itemID, self.amount, self.replace)):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for x in self.internal_history.Commands:
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ class GuiModuleAddChargeCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitSetChargeCommand(fitID, [mod.modPosition for mod in modules], itemID)
|
||||
self.itemID = itemID
|
||||
self.positions = [mod.modPosition for mod in modules]
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitSetChargeCommand(self.fitID, self.positions, self.itemID)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
@@ -12,11 +12,10 @@ class GuiAddCommandCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitAddCommandCommand(fitID, commandFitID)
|
||||
self.commandFitID = commandFitID
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitAddCommandCommand(self.fitID, self.commandFitID)):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
self.sFit.recalc(self.fitID)
|
||||
return True
|
||||
|
||||
@@ -15,8 +15,7 @@ class GuiAddFighterCommand(wx.Command):
|
||||
self.itemID = itemID
|
||||
|
||||
def Do(self):
|
||||
cmd = FitAddFighterCommand(self.fitID, self.itemID)
|
||||
if self.internal_history.Submit(cmd):
|
||||
if self.internal_history.Submit(FitAddFighterCommand(self.fitID, self.itemID)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
@@ -25,6 +24,7 @@ class GuiAddFighterCommand(wx.Command):
|
||||
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
|
||||
|
||||
|
||||
@@ -12,18 +12,19 @@ class GuiAddImplantCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitAddImplantCommand(fitID, itemID)
|
||||
self.itemID = itemID
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitAddImplantCommand(self.fitID, self.itemID)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for x in self.internal_history.Commands:
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
|
||||
@@ -71,5 +71,6 @@ class GuiCargoToModuleCommand(wx.Command):
|
||||
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
|
||||
|
||||
@@ -46,7 +46,6 @@ class GuiMetaSwapCommand(wx.Command):
|
||||
elif context == 'droneItem':
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
def Do(self):
|
||||
for cmds in self.data:
|
||||
for cmd in cmds:
|
||||
@@ -57,7 +56,7 @@ class GuiMetaSwapCommand(wx.Command):
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
for x in self.internal_history.Commands:
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
|
||||
@@ -67,5 +67,6 @@ class GuiModuleToCargoCommand(wx.Command):
|
||||
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
|
||||
|
||||
@@ -12,18 +12,17 @@ class GuiRemoveBoosterCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitRemoveBoosterCommand(fitID, position)
|
||||
self.position = position
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitRemoveBoosterCommand(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 x in self.internal_history.Commands:
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
|
||||
@@ -12,18 +12,17 @@ class GuiRemoveCargoCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitRemoveCargoCommand(fitID, itemID, stack=True)
|
||||
self.itemID = itemID
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitRemoveCargoCommand(self.fitID, self.itemID, stack=True)):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for x in self.internal_history.Commands:
|
||||
for _ in self.internal_history.GetCommands():
|
||||
self.internal_history.Undo()
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
|
||||
@@ -12,11 +12,10 @@ class GuiRemoveCommandCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitRemoveCommandCommand(fitID, commandFitID)
|
||||
self.commandFitID = commandFitID
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitRemoveCommandCommand(self.fitID, self.commandFitID)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
@@ -12,18 +12,17 @@ class GuiRemoveImplantCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitRemoveImplantCommand(fitID, position)
|
||||
self.position = position
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitRemoveImplantCommand(self.fitID, self.position)):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for x in self.internal_history.Commands:
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
|
||||
from .helpers import ModuleInfoCache
|
||||
from .calc.fitRemoveModule import FitRemoveModuleCommand
|
||||
|
||||
|
||||
@@ -12,11 +12,10 @@ class GuiSetModeCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitSetModeCommand(fitID, mode)
|
||||
self.mode = mode
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitSetModeCommand(self.fitID, self.mode)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
@@ -42,5 +42,9 @@ class GuiModuleSwapOrCloneCommand(wx.Command):
|
||||
pyfalog.debug("{} Undo()".format(self))
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
|
||||
if self.clone:
|
||||
self.sFit.recalc(self.fitID)
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
@@ -12,11 +12,10 @@ class GuiToggleCommandCommand(wx.Command):
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitToggleCommandCommand(fitID, commandFitID)
|
||||
self.commandFitID = commandFitID
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitToggleCommandCommand(self.fitID, self.commandFitID)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
@@ -17,10 +17,9 @@ class GuiModuleStateChangeCommand(wx.Command):
|
||||
self.modules = modules
|
||||
self.click = click
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.cmd = FitChangeStatesCommand(self.fitID, self.baseMod, self.modules, self.click)
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
if self.internal_history.Submit(FitChangeStatesCommand(self.fitID, self.baseMod, self.modules, self.click)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user