Transfer of the price dropbox in the preferences pane.
Moving of the modules list compiling from priceview to price service.
This commit is contained in:
@@ -6,7 +6,7 @@ from gui.bitmapLoader import BitmapLoader
|
||||
import gui.mainFrame
|
||||
import service
|
||||
import gui.globalEvents as GE
|
||||
|
||||
from service import Price
|
||||
|
||||
class PFGeneralPref ( PreferenceView):
|
||||
title = "General"
|
||||
@@ -65,6 +65,9 @@ class PFGeneralPref ( PreferenceView):
|
||||
self.cbExportCharges = wx.CheckBox( panel, wx.ID_ANY, u"Export loaded charges", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
mainSizer.Add( self.cbExportCharges, 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 )
|
||||
|
||||
self.sFit = service.Fit.getInstance()
|
||||
@@ -81,6 +84,7 @@ class PFGeneralPref ( PreferenceView):
|
||||
self.cbMarketShortcuts.SetValue(self.sFit.serviceFittingOptions["showMarketShortcuts"] or False)
|
||||
self.cbGaugeAnimation.SetValue(self.sFit.serviceFittingOptions["enableGaugeAnimation"])
|
||||
self.cbExportCharges.SetValue(self.sFit.serviceFittingOptions["exportCharges"])
|
||||
self.chPriceSystem.SetStringSelection("Jita")
|
||||
|
||||
self.cbGlobalChar.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalCharStateChange)
|
||||
self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange)
|
||||
@@ -94,6 +98,7 @@ class PFGeneralPref ( PreferenceView):
|
||||
self.cbMarketShortcuts.Bind(wx.EVT_CHECKBOX, self.onCBShowShortcuts)
|
||||
self.cbGaugeAnimation.Bind(wx.EVT_CHECKBOX, self.onCBGaugeAnimation)
|
||||
self.cbExportCharges.Bind(wx.EVT_CHECKBOX, self.onCBExportCharges)
|
||||
self.chPriceSystem.Bind(wx.EVT_CHOICE, self.onPriceSelection)
|
||||
|
||||
self.cbRackLabels.Enable(self.sFit.serviceFittingOptions["rackSlots"] or False)
|
||||
|
||||
@@ -162,4 +167,23 @@ class PFGeneralPref ( PreferenceView):
|
||||
def getImage(self):
|
||||
return BitmapLoader.getBitmap("prefs_settings", "gui")
|
||||
|
||||
def onPriceSelection(self, event):
|
||||
Price.currentSystemId = Price.systemsList.get(
|
||||
self.chPriceSystem.GetString(self.chPriceSystem.GetSelection())
|
||||
)
|
||||
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = sFit.getFit(fitID)
|
||||
|
||||
sMkt = service.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()
|
||||
|
||||
@@ -25,7 +25,6 @@ from gui.bitmapLoader import BitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
import service
|
||||
from service import Price
|
||||
import gui.globalEvents as GE
|
||||
|
||||
|
||||
class PriceViewFull(StatsView):
|
||||
@@ -74,55 +73,12 @@ class PriceViewFull(StatsView):
|
||||
setattr(self, "labelPrice%s" % type.capitalize(), lbl)
|
||||
hbox.Add(lbl, 0, wx.ALIGN_LEFT)
|
||||
|
||||
self.priceChoice = wx.Choice(contentPanel, choices=Price.systemsList.keys())
|
||||
contentSizer.Add(self.priceChoice)
|
||||
self.priceChoice.SetStringSelection("Jita")
|
||||
self.priceChoice.Bind(wx.EVT_CHOICE, self.priceSelection)
|
||||
|
||||
def priceSelection(self, event):
|
||||
Price.currentSystemId = Price.systemsList.get(self.priceChoice.GetString(self.priceChoice.GetSelection()))
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
sFit = service.Fit.getInstance()
|
||||
fit = sFit.getFit(mainFrame.getActiveFit())
|
||||
|
||||
typeIDs = self.fitItemsList(fit)
|
||||
|
||||
sMkt = service.Market.getInstance()
|
||||
sMkt.getPrices(typeIDs, Price.invalidPrices)
|
||||
|
||||
self.refreshPanel(fit)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
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
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
if fit is not None:
|
||||
self.fit = fit
|
||||
|
||||
typeIDs = self.fitItemsList(fit)
|
||||
typeIDs = Price.fitItemsList(fit)
|
||||
|
||||
sMkt = service.Market.getInstance()
|
||||
sMkt.getPrices(typeIDs, self.processPrices)
|
||||
|
||||
@@ -127,3 +127,27 @@ class Price():
|
||||
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