From 22642957cbdd59763d49d9b0c18fee986bb750d8 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Tue, 2 Nov 2010 09:42:44 +0100 Subject: [PATCH 1/4] Update eos --- eos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eos b/eos index 757dc4579..2dc357ce1 160000 --- a/eos +++ b/eos @@ -1 +1 @@ -Subproject commit 757dc45792fb3433dad795f981d27d236e73cfe5 +Subproject commit 2dc357ce1fe4f2bf6f8d337c795f41be371b4555 From 887ad4d9f694b1b496d2f5b194b9ba50f132d083 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Tue, 2 Nov 2010 10:04:21 +0100 Subject: [PATCH 2/4] Prettify the missing skills tooltip a bit by also displaying the item requiring said skills --- eos | 2 +- gui/characterSelection.py | 13 +++++++++---- gui/projectedView.py | 2 +- service/character.py | 5 ++++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/eos b/eos index 2dc357ce1..6f6c3b488 160000 --- a/eos +++ b/eos @@ -1 +1 @@ -Subproject commit 2dc357ce1fe4f2bf6f8d337c795f41be371b4555 +Subproject commit 6f6c3b488044102879fff4358f97f881224e616b diff --git a/gui/characterSelection.py b/gui/characterSelection.py index a17d753e2..3cc0f985c 100644 --- a/gui/characterSelection.py +++ b/gui/characterSelection.py @@ -132,9 +132,14 @@ class CharacterSelection(wx.Panel): def _buildSkillsTooltip(self, reqs, tabulationLevel = 0): tip = "" - for name, info in reqs.iteritems(): - level, more = info - tip += "%s%s: %d\n" % (" " * tabulationLevel, name, level) - tip += self._buildSkillsTooltip(more, tabulationLevel + 1) + if tabulationLevel == 0: + for item, subReqs in reqs.iteritems(): + tip += "%s:\n" % item.name + tip += self._buildSkillsTooltip(subReqs, 1) + else: + for name, info in reqs.iteritems(): + level, more = info + tip += "%s%s: %d\n" % (" " * tabulationLevel, name, level) + tip += self._buildSkillsTooltip(more, tabulationLevel + 1) return tip diff --git a/gui/projectedView.py b/gui/projectedView.py index f6c1a0a17..8e4ca756c 100644 --- a/gui/projectedView.py +++ b/gui/projectedView.py @@ -33,7 +33,7 @@ class ProjectedView(d.Display): "Projected Ammo"] def __init__(self, parent): - d.Display.__init__(self, parent) + d.Display.__init__(self, parent, style = wx.LC_SINGLE_SEL) self.mainFrame.Bind(fv.FIT_CHANGED, self.fitChanged) self.Bind(wx.EVT_LEFT_DOWN, self.click) self.Bind(wx.EVT_RIGHT_DOWN, self.click) diff --git a/service/character.py b/service/character.py index 182b27c05..cc3c237ab 100644 --- a/service/character.py +++ b/service/character.py @@ -146,8 +146,11 @@ class Character(): for thing in itertools.chain(fit.modules, fit.drones, (fit.ship,)): for attr in ("item", "charge"): subThing = getattr(thing, attr, None) + subReqs = {} if subThing is not None: - self._checkRequirements(fit, fit.character, subThing, reqs) + self._checkRequirements(fit, fit.character, subThing, subReqs) + if subReqs: + reqs[subThing] = subReqs return reqs From 2d01d664c5268906255ccc2dfbb6a03a1f9ecb55 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Tue, 2 Nov 2010 10:16:49 +0100 Subject: [PATCH 3/4] Force all additions views to single selection only, they don't handle multiselection at all for now --- gui/boosterView.py | 2 +- gui/droneView.py | 2 +- gui/implantView.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/boosterView.py b/gui/boosterView.py index b86fee5cc..f3be99407 100644 --- a/gui/boosterView.py +++ b/gui/boosterView.py @@ -32,7 +32,7 @@ class BoosterView(d.Display): ] def __init__(self, parent): - d.Display.__init__(self, parent) + d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL) self.mainFrame.Bind(fv.FIT_CHANGED, self.fitChanged) self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem) self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem) diff --git a/gui/droneView.py b/gui/droneView.py index 58841189d..d57af36da 100644 --- a/gui/droneView.py +++ b/gui/droneView.py @@ -35,7 +35,7 @@ class DroneView(d.Display): "attr:maxVelocity",] def __init__(self, parent): - d.Display.__init__(self, parent) + d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL) self.mainFrame.Bind(fv.FIT_CHANGED, self.fitChanged) self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem) self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem) diff --git a/gui/implantView.py b/gui/implantView.py index 55f9210db..530b5a76e 100644 --- a/gui/implantView.py +++ b/gui/implantView.py @@ -31,7 +31,7 @@ class ImplantView(d.Display): "Name"] def __init__(self, parent): - d.Display.__init__(self, parent) + d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL) self.mainFrame.Bind(fv.FIT_CHANGED, self.fitChanged) self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem) self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem) From 412ee42e061fd5be5dd744b6255dbecc1e5b5589 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Tue, 2 Nov 2010 13:41:42 +0100 Subject: [PATCH 4/4] Implement merging of drone stacks via drag'n'drop --- gui/droneView.py | 39 +++++++++++++++++++++++++++++++++++++++ gui/fittingView.py | 28 ++++++++++++++-------------- service/fit.py | 16 ++++++++++++++++ 3 files changed, 69 insertions(+), 14 deletions(-) diff --git a/gui/droneView.py b/gui/droneView.py index d57af36da..3bf099d10 100644 --- a/gui/droneView.py +++ b/gui/droneView.py @@ -26,6 +26,19 @@ import gui.display as d from gui.builtinViewColumns.droneCheckbox import DroneCheckbox from gui.contextMenu import ContextMenu +class DroneViewDrop(wx.PyDropTarget): + def __init__(self, dropFn): + wx.PyDropTarget.__init__(self) + self.dropFn = dropFn + # this is really transferring an EvE itemID + self.dropData = wx.PyTextDataObject() + self.SetDataObject(self.dropData) + + def OnData(self, x, y, t): + if self.GetData(): + self.dropFn(x, y, int(self.dropData.GetText())) + return t + class DroneView(d.Display): DEFAULT_COLS = ["Drone Checkbox", "Drone Name/Amount", @@ -45,6 +58,32 @@ class DroneView(d.Display): else: self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + + self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) + self.SetDropTarget(DroneViewDrop(self.mergeDrones)) + + def startDrag(self, event): + row = event.GetIndex() + if row != -1: + data = wx.PyTextDataObject() + data.SetText(str(self.GetItemData(row))) + + dropSource = wx.DropSource(self) + dropSource.SetData(data) + res = dropSource.DoDragDrop() + + def mergeDrones(self, x, y, itemID): + srcRow = self.FindItemData(-1,itemID) + dstRow, _ = self.HitTest((x, y)) + if srcRow != -1 and dstRow != -1: + self._merge(srcRow, dstRow) + + def _merge(self, src, dst): + sFit = service.Fit.getInstance() + fitID = self.mainFrame.getActiveFit() + if sFit.mergeDrones(fitID, self.drones[src], self.drones[dst]): + wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID)) + DRONE_ORDER = ('Light Scout Drones', 'Medium Scout Drones', 'Heavy Attack Drones', 'Sentry Drones', 'Fighters', 'Fighter Bombers', 'Combat Utility Drones', diff --git a/gui/fittingView.py b/gui/fittingView.py index 9c8f08557..873e19470 100644 --- a/gui/fittingView.py +++ b/gui/fittingView.py @@ -29,6 +29,19 @@ from gui.builtinViewColumns.moduleState import ModuleState FitChanged, FIT_CHANGED = wx.lib.newevent.NewEvent() +class FittingViewDrop(wx.PyDropTarget): + def __init__(self, dropFn): + wx.PyDropTarget.__init__(self) + self.dropFn = dropFn + # this is really transferring an EvE itemID + self.dropData = wx.PyTextDataObject() + self.SetDataObject(self.dropData) + + def OnData(self, x, y, t): + if self.GetData(): + self.dropFn(x, y, int(self.dropData.GetText())) + return t + class FittingView(d.Display): DEFAULT_COLS = ["Module State", "Module Ammo Icon", @@ -42,19 +55,6 @@ class FittingView(d.Display): "Module Ammo", ] - class FittingViewDrop(wx.PyDropTarget): - def __init__(self, dropFn): - wx.PyDropTarget.__init__(self) - self.dropFn = dropFn - # this is really transferring an EvE itemID - self.dropData = wx.PyTextDataObject() - self.SetDataObject(self.dropData) - - def OnData(self, x, y, t): - if self.GetData(): - self.dropFn(x, y, int(self.dropData.GetText())) - return t - def __init__(self, parent): d.Display.__init__(self, parent) self.Show(False) @@ -66,7 +66,7 @@ class FittingView(d.Display): else: self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) - self.SetDropTarget(self.FittingViewDrop(self.swapItems)) + self.SetDropTarget(FittingViewDrop(self.swapItems)) self.activeFitID = None self.Bind(wx.EVT_KEY_UP, self.kbEvent) self.Bind(wx.EVT_LEFT_DOWN, self.click) diff --git a/service/fit.py b/service/fit.py index 4464a6ac5..fcd45208e 100644 --- a/service/fit.py +++ b/service/fit.py @@ -304,6 +304,22 @@ class Fit(object): else: return False + def mergeDrones(self, fitID, d1, d2): + if fitID == None: + return False + + fit = eos.db.getFit(fitID) + if d1.item != d2.item: + return False + + fit.drones.remove(d1) + d2.amount += d1.amount + d2.amountActive += d1.amountActive if d1.amountActive > 0 else -d2.amountActive + eos.db.commit() + fit.clear() + fit.calculateModifiedAttributes() + return True + def splitDrones(self, fit, d, amount, l): total = d.amount active = d.amountActive > 0