Merge branch 'price-system-selection' of git://github.com/petosorus/Pyfa into petosorus-price-system-selection
Conflicts: gui/builtinPreferenceViews/pyfaGeneralPreferences.py gui/builtinStatsViews/priceViewFull.py service/fit.py service/price.py
This commit is contained in:
@@ -8,7 +8,8 @@ import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
from service.settings import SettingsProvider
|
||||
from service.fit import Fit
|
||||
|
||||
from service.price import Price
|
||||
from service.market import Market
|
||||
|
||||
class PFGeneralPref(PreferenceView):
|
||||
title = "General"
|
||||
@@ -80,6 +81,11 @@ class PFGeneralPref(PreferenceView):
|
||||
wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
mainSizer.Add(self.cbOpenFitInNew, 0, wx.ALL | wx.EXPAND, 5)
|
||||
|
||||
self.chPriceSystem = wx.Choice( panel, choices=Price.systemsList.keys())
|
||||
mainSizer.Add( self.chPriceSystem, 0, wx.ALL|wx.EXPAND, 5)
|
||||
|
||||
defCharSizer = wx.BoxSizer( wx.HORIZONTAL )
|
||||
|
||||
wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
self.sFit = Fit.getInstance()
|
||||
@@ -97,6 +103,7 @@ class PFGeneralPref(PreferenceView):
|
||||
self.cbGaugeAnimation.SetValue(self.sFit.serviceFittingOptions["enableGaugeAnimation"])
|
||||
self.cbExportCharges.SetValue(self.sFit.serviceFittingOptions["exportCharges"])
|
||||
self.cbOpenFitInNew.SetValue(self.sFit.serviceFittingOptions["openFitInNew"])
|
||||
self.chPriceSystem.SetStringSelection(self.sFit.serviceFittingOptions["priceSystem"])
|
||||
|
||||
self.cbGlobalChar.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalCharStateChange)
|
||||
self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange)
|
||||
@@ -111,6 +118,7 @@ class PFGeneralPref(PreferenceView):
|
||||
self.cbGaugeAnimation.Bind(wx.EVT_CHECKBOX, self.onCBGaugeAnimation)
|
||||
self.cbExportCharges.Bind(wx.EVT_CHECKBOX, self.onCBExportCharges)
|
||||
self.cbOpenFitInNew.Bind(wx.EVT_CHECKBOX, self.onCBOpenFitInNew)
|
||||
self.chPriceSystem.Bind(wx.EVT_CHOICE, self.onPriceSelection)
|
||||
|
||||
self.cbRackLabels.Enable(self.sFit.serviceFittingOptions["rackSlots"] or False)
|
||||
|
||||
@@ -182,5 +190,20 @@ class PFGeneralPref(PreferenceView):
|
||||
def getImage(self):
|
||||
return BitmapLoader.getBitmap("prefs_settings", "gui")
|
||||
|
||||
def onPriceSelection(self, event):
|
||||
system = self.chPriceSystem.GetString(self.chPriceSystem.GetSelection())
|
||||
Price.currentSystemId = Price.systemsList.get(system)
|
||||
self.sFit.serviceFittingOptions["priceSystem"] = system
|
||||
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = self.sFit.getFit(fitID)
|
||||
|
||||
sMkt = Market.getInstance()
|
||||
typeIDs = Price.fitItemsList(fit)
|
||||
sMkt.getPrices(typeIDs, Price.invalidPrices)
|
||||
|
||||
self.sFit.refreshFit(fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
PFGeneralPref.register()
|
||||
|
||||
@@ -23,6 +23,7 @@ from gui.statsView import StatsView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
from service.market import Market
|
||||
from service.price import Price
|
||||
|
||||
|
||||
class PriceViewFull(StatsView):
|
||||
@@ -71,25 +72,12 @@ class PriceViewFull(StatsView):
|
||||
setattr(self, "labelPrice%s" % type.capitalize(), lbl)
|
||||
hbox.Add(lbl, 0, wx.ALIGN_LEFT)
|
||||
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
if fit is not None:
|
||||
self.fit = fit
|
||||
# Compose a list of all the data we need & request it
|
||||
typeIDs = [fit.ship.item.ID]
|
||||
|
||||
for mod in fit.modules:
|
||||
if not mod.isEmpty:
|
||||
typeIDs.append(mod.itemID)
|
||||
|
||||
for drone in fit.drones:
|
||||
typeIDs.append(drone.itemID)
|
||||
|
||||
for fighter in fit.fighters:
|
||||
if fighter.amountActive > 0:
|
||||
typeIDs.append(fighter.itemID)
|
||||
|
||||
for cargo in fit.cargo:
|
||||
typeIDs.append(cargo.itemID)
|
||||
typeIDs = Price.fitItemsList(fit)
|
||||
|
||||
sMkt = Market.getInstance()
|
||||
sMkt.getPrices(typeIDs, self.processPrices)
|
||||
|
||||
@@ -69,8 +69,7 @@ class Fit(object):
|
||||
"showMarketShortcuts": False,
|
||||
"enableGaugeAnimation": True,
|
||||
"exportCharges": True,
|
||||
"openFitInNew": False,
|
||||
}
|
||||
"priceSystem": "Jita"}
|
||||
|
||||
self.serviceFittingOptions = SettingsProvider.getInstance().getSettings(
|
||||
"pyfaServiceFittingOptions", serviceFittingDefaultOptions)
|
||||
|
||||
@@ -30,6 +30,21 @@ TIMEOUT = 15 * 60 # Network timeout delay for connection issues, 15 minutes
|
||||
|
||||
|
||||
class Price(object):
|
||||
systemsList = {
|
||||
"Jita": 30000142,
|
||||
"Amarr": 30002187,
|
||||
"Dodixie": 30002659,
|
||||
"Rens": 30002510,
|
||||
"Hek": 30002053
|
||||
}
|
||||
|
||||
currentSystemId = ""
|
||||
|
||||
@classmethod
|
||||
def invalidPrices(self, prices):
|
||||
for price in prices:
|
||||
price.time = 0
|
||||
|
||||
@classmethod
|
||||
def fetchPrices(cls, prices):
|
||||
"""Fetch all prices passed to this method"""
|
||||
@@ -65,7 +80,7 @@ class Price(object):
|
||||
|
||||
# Base request URL
|
||||
baseurl = "https://eve-central.com/api/marketstat"
|
||||
data.append(("usesystem", 30000142)) # Use Jita for market
|
||||
data.append(("usesystem", Price.currentSystemId)) # Use Jita for market
|
||||
|
||||
for typeID in toRequest: # Add all typeID arguments
|
||||
data.append(("typeid", typeID))
|
||||
@@ -113,3 +128,27 @@ class Price(object):
|
||||
priceobj = priceMap[typeID]
|
||||
priceobj.time = time.time() + REREQUEST
|
||||
priceobj.failed = True
|
||||
|
||||
@classmethod
|
||||
def fitItemsList(self, fit):
|
||||
# Compose a list of all the data we need & request it
|
||||
typeIDs = []
|
||||
typeIDs.append(fit.ship.item.ID)
|
||||
|
||||
for mod in fit.modules:
|
||||
if not mod.isEmpty:
|
||||
typeIDs.append(mod.itemID)
|
||||
|
||||
for drone in fit.drones:
|
||||
for _ in xrange(drone.amount):
|
||||
typeIDs.append(drone.itemID)
|
||||
|
||||
for fighter in fit.fighters:
|
||||
for _ in xrange(fighter.amountActive):
|
||||
typeIDs.append(fighter.itemID)
|
||||
|
||||
for cargo in fit.cargo:
|
||||
for _ in xrange(cargo.amount):
|
||||
typeIDs.append(cargo.itemID)
|
||||
|
||||
return typeIDs
|
||||
Reference in New Issue
Block a user