Skip to content

Commit

Permalink
total computation + settings
Browse files Browse the repository at this point in the history
  • Loading branch information
petosorus committed May 24, 2017
1 parent cff3d0e commit 1781c6d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 6 deletions.
24 changes: 19 additions & 5 deletions gui/builtinStatsViews/priceViewFull.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from service.price import Price
from service.settings import PriceMenuSettings


class PriceViewFull(StatsView):
Expand All @@ -31,6 +32,7 @@ class PriceViewFull(StatsView):
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
self.settings = PriceMenuSettings.getInstance()

def getHeaderText(self, fit):
return "Price"
Expand All @@ -49,7 +51,7 @@ def populatePanel(self, contentPanel, headerPanel):

gridPrice = wx.GridSizer(2, 3)
contentSizer.Add(gridPrice, 0, wx.EXPAND | wx.ALL, 0)
for _type in ("ship", "fittings", "drones", "cargoBay", "character", "total"):
for _type in ("ship", "fittings", "total", "drones", "cargoBay", "character"):
if _type in "ship":
image = "ship_big"
elif _type in ("fittings", "total"):
Expand Down Expand Up @@ -125,15 +127,28 @@ def refreshPanelPrices(self, fit=None):
for implant in fit.implants:
implant_price += implant.item.price.price

fitting_price = module_price + drone_price + fighter_price + cargo_price + booster_price + implant_price
total_price = ship_price + fitting_price
total_price = 0

if (self.settings.get("ship")):
total_price += ship_price
if(self.settings.get("modules")):
total_price += module_price
if(self.settings.get("drones")):
total_price += drone_price + fighter_price
if(self.settings.get("cargo")):
total_price += cargo_price
if(self.settings.get("character")):
total_price += booster_price + implant_price

self.labelPriceShip.SetLabel("%s ISK" % formatAmount(ship_price, 3, 3, 9, currency=True))
self.labelPriceShip.SetToolTip(wx.ToolTip('{:,.2f}'.format(ship_price)))

self.labelPriceFittings.SetLabel("%s ISK" % formatAmount(module_price, 3, 3, 9, currency=True))
self.labelPriceFittings.SetToolTip(wx.ToolTip('{:,.2f}'.format(module_price)))

self.labelPriceTotal.SetLabel("%s ISK" % formatAmount(total_price, 3, 3, 9, currency=True))
self.labelPriceTotal.SetToolTip(wx.ToolTip('{:,.2f}'.format(total_price)))

self.labelPriceDrones.SetLabel("%s ISK" % formatAmount(drone_price + fighter_price, 3, 3, 9, currency=True))
self.labelPriceDrones.SetToolTip(wx.ToolTip('{:,.2f}'.format(drone_price + fighter_price)))

Expand All @@ -143,8 +158,7 @@ def refreshPanelPrices(self, fit=None):
self.labelPriceCharacter.SetLabel("%s ISK" % formatAmount(booster_price + implant_price, 3, 3, 9, currency=True))
self.labelPriceCharacter.SetToolTip(wx.ToolTip('{:,.2f}'.format(booster_price + implant_price)))

self.labelPriceTotal.SetLabel("%s ISK" % formatAmount(total_price, 3, 3, 9, currency=True))
self.labelPriceTotal.SetToolTip(wx.ToolTip('{:,.2f}'.format(total_price)))


def processPrices(self, prices):
self.refreshPanelPrices(self.fit)
Expand Down
21 changes: 20 additions & 1 deletion gui/builtinStatsViews/priceViewMinimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from service.price import Price
from service.settings import PriceMenuSettings


class PriceViewMinimal(StatsView):
Expand All @@ -31,6 +32,7 @@ class PriceViewMinimal(StatsView):
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
self.settings = PriceMenuSettings.getInstance()

def getHeaderText(self, fit):
return "Price"
Expand Down Expand Up @@ -119,7 +121,24 @@ def refreshPanelPrices(self, fit=None):
for implant in fit.implants:
implant_price += implant.item.price.price

fitting_price = module_price + drone_price + fighter_price + cargo_price + booster_price + implant_price
fitting_price = module_price

total_price = 0

if (self.settings.get("ship")):
total_price += ship_price
if(self.settings.get("modules")):
total_price += module_price
if(self.settings.get("drones")):
total_price += drone_price + fighter_price
if(self.settings.get("cargo")):
total_price += cargo_price
if(self.settings.get("character")):
total_price += booster_price + implant_price




total_price = ship_price + fitting_price

self.labelPriceShip.SetLabel("%s ISK" % formatAmount(ship_price, 3, 3, 9, currency=True))
Expand Down
32 changes: 32 additions & 0 deletions service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,38 @@ def set(self, type, value):
self.serviceStatViewDefaultSettings[type] = value


class PriceMenuSettings(object):
_instance = None

@classmethod
def getInstance(cls):
if cls._instance is None:
cls._instance = PriceMenuSettings()

return cls._instance

def __init__(self):
# mode
# 0 - Do not add to total
# 1 - Add to total
PriceMenuDefaultSettings = {
"ship" : 1,
"modules" : 1,
"drones" : 0,
"cargo" : 0,
"character" : 0
}

self.PriceMenuDefaultSettings = SettingsProvider.getInstance().getSettings("pyfaPriceMenuSettings",
PriceMenuDefaultSettings)

def get(self, type):
return self.PriceMenuDefaultSettings[type]

def set(self, type, value):
self.PriceMenuDefaultSettings[type] = value


class ContextMenuSettings(object):
_instance = None

Expand Down

0 comments on commit 1781c6d

Please sign in to comment.