More work on the spoolup gui, including support for commands and some other nicities (recalc fit when changing, load the input with previous)

This commit is contained in:
blitzmann
2019-01-10 23:13:22 -05:00
parent 436bee1e85
commit c645c089dd
4 changed files with 76 additions and 6 deletions

View File

@@ -4,6 +4,8 @@ from gui.contextMenu import ContextMenu
from service.settings import ContextMenuSettings
import wx
from eos.utils.spoolSupport import SpoolType
import gui.fitCommands as cmd
class SpoolUp(ContextMenu):
def __init__(self):
@@ -47,10 +49,8 @@ class SpoolUp(ContextMenu):
if type is None:
amount = None
thing.spoolType = type
thing.spoolAmount = amount
break
self.mainFrame.command.Submit(cmd.GuiSetSpoolup(fitID, thing, type, amount))
return
SpoolUp.register()
@@ -106,6 +106,7 @@ class SpoolUpChanger(wx.Dialog):
bSizer3.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0, wx.EXPAND)
bSizer1.Add(bSizer3, 0, wx.ALL | wx.EXPAND, 10)
self.input.SetValue(module.spoolAmount or 0)
self.input.SetFocus()
self.input.Bind(wx.EVT_TEXT_ENTER, self.processEnter)
self.SetSizer(bSizer1)
@@ -113,8 +114,7 @@ class SpoolUpChanger(wx.Dialog):
self.Fit()
def spoolTypeChanged(self, evt):
if evt.ClientData is None:
self.input.Enable(False)
self.input.Enable(evt.ClientData is not None)
self.spoolDesc.SetLabel(self.spoolTypes[evt.ClientData][1])
self.Layout()

View File

@@ -34,3 +34,4 @@ from .guiToggleDrone import GuiToggleDroneCommand
from .guiFitRename import GuiFitRenameCommand
from .guiChangeImplantLocation import GuiChangeImplantLocation
from .guiImportMutatedModule import GuiImportMutatedModuleCommand
from .guiSetSpoolup import GuiSetSpoolup

View File

@@ -0,0 +1,37 @@
import wx
import eos.db
from logbook import Logger
from eos.saveddata.booster import Booster
pyfalog = Logger(__name__)
class FitSetSpoolupCommand(wx.Command):
def __init__(self, fitID, position, spoolType, spoolAmount):
wx.Command.__init__(self, True)
self.fitID = fitID
self.position = position
self.spoolType = spoolType
self.spoolAmount = spoolAmount
self.projected = False # todo: get this to work with projected modules? Is that a thing?
self.cache = None
def Do(self):
return self.__set(self.spoolType, self.spoolAmount)
def Undo(self):
if self.cache:
self.__set(*self.cache)
return True
def __set(self, type, amount):
fit = eos.db.getFit(self.fitID)
source = fit.modules if not self.projected else fit.projectedModules
mod = source[self.position]
self.cache = mod.spoolType, mod.spoolAmount
mod.spoolType = type
mod.spoolAmount = amount
eos.db.commit()
return True

View File

@@ -0,0 +1,32 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calc.fitSetSpoolup import FitSetSpoolupCommand
class GuiSetSpoolup(wx.Command):
def __init__(self, fitID, module, spoolupType, spoolupAmount):
wx.Command.__init__(self, True, "Booster Add")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.internal_history = wx.CommandProcessor()
self.fitID = fitID
self.position = module.modPosition
self.spoolType = spoolupType
self.spoolupAmount = spoolupAmount
def Do(self):
if self.internal_history.Submit(FitSetSpoolupCommand(self.fitID, self.position, self.spoolType, self.spoolupAmount)):
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