Change booster removal commands to support multi-selection

This commit is contained in:
DarkPhoenix
2019-04-25 17:56:53 +03:00
parent 7b564f1f53
commit 29c29469c6
7 changed files with 69 additions and 48 deletions

View File

@@ -48,6 +48,7 @@ class BoosterViewDrop(wx.DropTarget):
class BoosterView(d.Display):
DEFAULT_COLS = [
"State",
"attr:boosterness",
@@ -162,8 +163,8 @@ class BoosterView(d.Display):
fitID = self.mainFrame.getActiveFit()
if booster in self.original:
position = self.original.index(booster)
self.mainFrame.command.Submit(cmd.GuiRemoveBoosterCommand(
fitID=fitID, position=position))
self.mainFrame.command.Submit(cmd.GuiRemoveBoostersCommand(
fitID=fitID, positions=[position]))
def click(self, event):
event.Skip()

View File

@@ -226,35 +226,33 @@ class ImplantDisplay(d.Display):
def click(self, event):
fitID = self.mainFrame.getActiveFit()
fit = Fit.getInstance().getFit(fitID)
if fit.implantLocation != ImplantLocation.FIT:
event.Skip()
return
mainRow, _ = self.HitTest(event.Position)
if mainRow != -1:
col = self.getColumn(event.Position)
if col == self.getColIndex(State):
fitID = self.mainFrame.getActiveFit()
try:
mainImplant = self.implants[mainRow]
except IndexError:
return
if mainImplant in self.original:
mainPosition = self.original.index(mainImplant)
positions = []
for row in self.getSelectedRows():
try:
implant = self.implants[row]
except IndexError:
continue
if implant in self.original:
positions.append(self.original.index(implant))
if mainPosition not in positions:
positions = [mainPosition]
self.mainFrame.command.Submit(cmd.GuiToggleImplantStatesCommand(
fitID=fitID,
mainPosition=mainPosition,
positions=positions))
return
if fit.implantLocation == ImplantLocation.FIT:
mainRow, _ = self.HitTest(event.Position)
if mainRow != -1:
col = self.getColumn(event.Position)
if col == self.getColIndex(State):
fitID = self.mainFrame.getActiveFit()
try:
mainImplant = self.implants[mainRow]
except IndexError:
return
if mainImplant in self.original:
mainPosition = self.original.index(mainImplant)
positions = []
for row in self.getSelectedRows():
try:
implant = self.implants[row]
except IndexError:
continue
if implant in self.original:
positions.append(self.original.index(implant))
if mainPosition not in positions:
positions = [mainPosition]
self.mainFrame.command.Submit(cmd.GuiToggleImplantStatesCommand(
fitID=fitID,
mainPosition=mainPosition,
positions=positions))
return
event.Skip()
def spawnMenu(self, event):