More converting for command fits

This commit is contained in:
blitzmann
2018-08-03 21:19:51 -04:00
parent 7a1b4b4a1e
commit 3c7f0258df
7 changed files with 18 additions and 26 deletions

View File

@@ -103,18 +103,13 @@ class CommandView(d.Display):
sFit = Fit.getInstance()
row = self.GetFirstSelected()
if row != -1:
sFit.removeCommand(fitID, self.get(row))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
self.mainFrame.command.Submit(cmd.GuiRemoveCommandCommand(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:
# sFit = Fit.getInstance()
# draggedFit = sFit.getFit(fitID)
# sFit.addCommandFit(activeFit, draggedFit)
# wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=activeFit))
self.mainFrame.command.Submit(cmd.GuiAddCommandCommand(activeFit, fitID))
def startDrag(self, event):
@@ -228,5 +223,4 @@ class CommandView(d.Display):
sFit = Fit.getInstance()
thing = self.get(row)
if thing: # thing doesn't exist if it's the dummy value
sFit.removeCommand(fitID, thing)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
self.mainFrame.command.Submit(cmd.GuiRemoveCommandCommand(fitID, thing.ID))

View File

@@ -7,7 +7,7 @@ import gui.mainFrame
import gui.globalEvents as GE
from gui.contextMenu import ContextMenu
from service.settings import ContextMenuSettings
import gui.fitCommands as cmd
class CommandFits(ContextMenu):
# Get list of items that define a command fit
@@ -99,9 +99,7 @@ class CommandFits(ContextMenu):
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
sFit.addCommandFit(fitID, fit)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
self.mainFrame.command.Submit(cmd.GuiAddCommandCommand(fitID, fit.ID))
CommandFits.populateFits(None)

View File

@@ -56,8 +56,8 @@ class ItemRemove(ContextMenu):
elif srcContext in ("projectedFit", "projectedModule", "projectedDrone", "projectedFighter"):
sFit.removeProjected(fitID, selection[0])
elif srcContext == "commandFit":
sFit.removeCommand(fitID, selection[0])
self.mainFrame.command.Submit(cmd.GuiRemoveCommandCommand(fitID, selection[0].ID))
return
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))

View File

@@ -8,7 +8,7 @@ import gui.mainFrame
import gui.globalEvents as GE
from gui.contextMenu import ContextMenu
from gui.builtinViews.emptyView import BlankPage
import gui.fitCommands as cmd
class TabbedFits(ContextMenu):
def __init__(self):
@@ -57,11 +57,10 @@ class TabbedFits(ContextMenu):
fit = self.fitLookup[event.Id]
if self.context == 'commandView':
sFit.addCommandFit(fitID, fit)
self.mainFrame.command.Submit(cmd.GuiAddCommandCommand(fitID, fit.ID))
elif self.context == 'projected':
sFit.project(fitID, fit)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
TabbedFits.register()

View File

@@ -17,7 +17,7 @@ from .events import ImportSelected, SearchSelected, FitSelected, BoosterListUpda
from gui.bitmap_loader import BitmapLoader
from gui.builtinShipBrowser.pfBitmapFrame import PFBitmapFrame
from service.fit import Fit
import gui.fitCommands as cmd
pyfalog = Logger(__name__)
@@ -209,11 +209,8 @@ class FitItem(SFItem.SFBrowserItem):
def OnAddCommandFit(self, event):
activeFit = self.mainFrame.getActiveFit()
if activeFit:
sFit = Fit.getInstance()
commandFit = sFit.getFit(self.fitID)
sFit.addCommandFit(activeFit, commandFit)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=activeFit))
self.mainFrame.additionsPane.select("Command")
if self.mainFrame.command.Submit(cmd.GuiAddCommandCommand(activeFit, self.fitID)):
self.mainFrame.additionsPane.select("Command")
def OnMouseCaptureLost(self, event):
""" Destroy drag information (GH issue #479)"""

View File

@@ -18,12 +18,14 @@ class GuiAddCommandCommand(wx.Command):
def Do(self):
if self.internal_history.Submit(self.cmd):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
self.sFit.recalc(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))
return True

View File

@@ -17,13 +17,15 @@ class GuiRemoveCommandCommand(wx.Command):
def Do(self):
if self.internal_history.Submit(self.cmd):
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))
return True