Merge branch 'master' of evefit.org:pyfa

This commit is contained in:
Lucas Thode
2010-10-28 08:14:23 -05:00
19 changed files with 1303 additions and 420 deletions

2
eos

Submodule eos updated: 5be0cf5592...5b7f8eaf71

View File

@@ -26,7 +26,8 @@ def getStaticBitmap(name, parent, location):
static.SetBitmap(getBitmap(name,location))
return static
locationMap = {"pack": os.path.join(config.staticPath, "icons")}
locationMap = {"pack": os.path.join(config.staticPath, "icons"),
"ships": os.path.join(config.staticPath, "icons/ships")}
def getBitmap(name,location):
icon = getImage(name, location)
@@ -35,8 +36,13 @@ def getBitmap(name,location):
def getImage(name, location):
if location in locationMap:
location = locationMap[location]
path = os.path.join(location, "icon%s.png" % name)
if location == "pack":
location = locationMap[location]
path = os.path.join(location, "icon%s.png" % name)
else:
location = locationMap[location]
path = os.path.join(location, "%s.png" % name)
else:
location = os.path.join(config.path, location)
path = os.path.join(location, name + ".png")

View File

@@ -27,8 +27,9 @@ from gui.contextMenu import ContextMenu
class BoosterView(d.Display):
DEFAULT_COLS = ["Activity Checkbox",
"attr:boosterness",
"Name",
"attr:boosterness"]
]
def __init__(self, parent):
d.Display.__init__(self, parent)

View File

@@ -103,10 +103,10 @@ class FirepowerViewFull(StatsView):
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
stats = (("labelFullDpsWeapon", lambda: fit.weaponDPS, 3, 0, 9, "%s DPS",None),
("labelFullDpsDrone", lambda: fit.droneDPS, 3, 0, 9, "%s DPS", None),
("labelFullVolleyTotal", lambda: fit.weaponVolley, 3, 0, 9, "%s", "Volley: %.1f"),
("labelFullDpsTotal", lambda: fit.totalDPS, 3, 0, 9, "%s", None))
stats = (("labelFullDpsWeapon", lambda: fit.weaponDPS, 3, 0, 0, "%s DPS",None),
("labelFullDpsDrone", lambda: fit.droneDPS, 3, 0, 0, "%s DPS", None),
("labelFullVolleyTotal", lambda: fit.weaponVolley, 3, 0, 0, "%s", "Volley: %.1f"),
("labelFullDpsTotal", lambda: fit.totalDPS, 3, 0, 0, "%s", None))
counter = 0
for labelName, value, prec, lowest, highest, valueFormat, altFormat in stats:

View File

@@ -78,7 +78,7 @@ class TargetingMiscViewFull(StatsView):
labels = (("Speed", "Speed", "m/s"),
("Align time", "AlignTime", "s"),
("Signature", "SigRadius", "m"),
#("Warp Speed", "WarpSpeed", "au/s"),
("Warp Speed", "WarpSpeed", "AU/s"),
("Cargo", "Cargo", u"m\u00B3"))
for header, labelShort, unit in labels:
@@ -105,7 +105,7 @@ class TargetingMiscViewFull(StatsView):
("labelFullSpeed", lambda: fit.ship.getModifiedItemAttr("maxVelocity"), 3, 0, 0, "m/s"),
("labelFullAlignTime", lambda: fit.alignTime, 3, 0, 0, "s"),
("labelFullSigRadius", lambda: fit.ship.getModifiedItemAttr("signatureRadius"), 3, 0, 9, ""),
#("labelFullWarpSpeed", lambda: fit.warpSpeed, 3, 0, 0, "au/s"),
("labelFullWarpSpeed", lambda: fit.warpSpeed, 3, 0, 0, "AU/s"),
("labelFullCargo", lambda: fit.extraAttributes["capacity"], 3, 0, 9, u"m\u00B3"))
counter = 0
for labelName, value, prec, lowest, highest, unit in stats:

View File

@@ -34,7 +34,12 @@ class ModulePrice(ViewColumn):
def getText(self, mod):
return False if mod.item is not None else ""
if mod.item is None:
return ""
sMarket = service.Market.getInstance()
price = sMarket.getPriceNow(mod.item.ID).price
return formatAmount(price, 3, 3, 9) if price is not None else False
def delayedText(self, mod, display, colItem):
def callback(requests):

View File

@@ -286,7 +286,9 @@ class ItemView(d.Display):
self.items = items if items is not None else self.items
self.usedMetas = usedMetas if usedMetas is not None else self.usedMetas
self.update(self.items)
sMarket = service.Market.getInstance()
self.update(sMarket.filterItems(self.items))
#Gray out empty toggles
self.toggleButtons(self.usedMetas)

File diff suppressed because it is too large Load Diff

BIN
icons/faccept_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 781 B

BIN
icons/fforward_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

BIN
icons/fit_add_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

BIN
icons/fit_delete_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

BIN
icons/fit_rename_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

BIN
icons/freset_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

BIN
icons/frewind_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

BIN
icons/fsearch_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

BIN
icons/fshipbk_big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -31,13 +31,13 @@ class Fit(object):
cls.instance = Fit()
return cls.instance
def getAllFits(self):
fits = eos.db.getFitList()
names = []
for fit in fits:
names.append((fit.ID, fit.name))
return names
@@ -53,10 +53,10 @@ class Fit(object):
fit = eos.db.getFit(fitID)
return fit.modules[pos]
def newFit(self, shipID, name):
def newFit(self, shipID, name=None):
fit = eos.types.Fit()
fit.ship = eos.types.Ship(eos.db.getItem(shipID))
fit.name = name
fit.name = name if name is not None else "New %s" % fit.ship.item.name
fit.damagePattern = DamagePattern.getInstance().getDamagePattern("Uniform")
eos.db.save(fit)
fit.calculateModifiedAttributes()
@@ -95,6 +95,14 @@ class Fit(object):
fit.calculateModifiedAttributes()
return fit
def searchFits(self, name):
results = eos.db.searchFits(name)
fits = []
for fit in results:
fits.append((fit.ID, fit.name, fit.ship.item.ID, fit.ship.item.name))
return fits
def addImplant(self, fitID, itemID):
if fitID is None:
return False
@@ -160,7 +168,11 @@ class Fit(object):
except ValueError:
return False
if m.item.category.name == "Subsystem":
fit.modules.freeSlot(m.getModifiedItemAttr("subSystemSlot"))
if m.fits(fit):
numSlots = len(fit.modules)
fit.modules.append(m)
if m.isValidState(State.ACTIVE):
@@ -168,6 +180,7 @@ class Fit(object):
fit.clear()
fit.calculateModifiedAttributes()
self.checkStates(fit, m)
fit.fill()
eos.db.commit()
@@ -184,6 +197,7 @@ class Fit(object):
fit.modules.toDummy(position)
fit.clear()
fit.calculateModifiedAttributes()
self.checkStates(fit, None)
fit.fill()
eos.db.commit()
return numSlots != len(fit.modules)
@@ -335,7 +349,7 @@ class Fit(object):
def exportXml(self, *fitIDs):
fits = map(lambda id: eos.db.getFit(id), fitIDs)
return eos.types.Fit.exportXml(*fits)
def backupFits(self, path):
allFits = map(lambda x: x[0], self.getAllFits())
backedUpFits = self.exportXml(*allFits)
@@ -362,6 +376,13 @@ class Fit(object):
return IDs
def checkStates(self, fit, base):
for mod in fit.modules:
if mod != base:
if not mod.canHaveState(mod.state):
mod.state = State.ONLINE
def toggleModulesState(self, fitID, base, modules, click):
proposedState = self.__getProposedState(base, click)
if proposedState != base.state:
@@ -372,6 +393,8 @@ class Fit(object):
eos.db.commit()
fit = eos.db.getFit(fitID)
self.checkStates(fit, base)
fit.clear()
fit.calculateModifiedAttributes()

View File

@@ -165,14 +165,6 @@ class Market():
def searchItems(self, name, callback):
self.searchWorkerThread.scheduleSearch(name, callback)
def searchFits(self, name):
results = eos.db.searchFits(name)
fits = []
for fit in results:
fits.append((fit.ID, fit.name, fit.ship.item.name))
return fits
def getImplantTree(self):
return self.getChildren(27)
@@ -228,6 +220,15 @@ class Market():
def isMetaIdActive(self, meta):
return meta in self.activeMetas
def filterItems(self, items):
filtered = []
activeMetas = self.activeMetas
for it in items:
if (it.metaGroup.ID if it.metaGroup is not None else 1) in activeMetas:
filtered.append(it)
return filtered
def getMetaName(self, metaId):
for name, ids in self.META_MAP.items():
for id in ids:
@@ -255,19 +256,26 @@ class Market():
return list(l), populatedMetas
def getPriceNow(self, typeID):
price = self.priceCache.get(typeID)
if price is None:
try:
price = eos.db.getPrice(typeID)
except NoResultFound:
price = eos.types.Price(typeID)
eos.db.saveddata_session.add(price)
self.priceCache[typeID] = price
return price
def getPricesNow(self, typeIDs):
return map(self.getPrice, typeIDs)
def getPrices(self, typeIDs, callback):
requests = []
for typeID in typeIDs:
price = self.priceCache.get(typeID)
if price is None:
try:
price = eos.db.getPrice(typeID)
except NoResultFound:
price = eos.types.Price(typeID)
eos.db.saveddata_session.add(price)
self.priceCache[typeID] = price
price = self.getPriceNow(typeID)
requests.append(price)
def cb():