Merge branch 'master' of evefit.org:pyfa

This commit is contained in:
HomeWorld
2010-11-02 15:05:08 +02:00
9 changed files with 87 additions and 24 deletions

2
eos

Submodule eos updated: 757dc45792...6f6c3b4880

View File

@@ -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)

View File

@@ -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

View File

@@ -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",
@@ -35,7 +48,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)
@@ -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',

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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