-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathinsuranceViewFull.py
More file actions
101 lines (81 loc) · 4.6 KB
/
insuranceViewFull.py
File metadata and controls
101 lines (81 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import wx
from gui.statsView import StatsView
from gui.utils.numberFormatter import formatAmount
from service.insurance import Insurance
from service.settings import InsuranceMenuSettings
class InsuranceViewFull(StatsView):
name = "insuranceViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
self.insuranceLevels = None
self.settings = InsuranceMenuSettings.getInstance()
self.displayColumns = self.getDisplayColumns(self.settings)
def getDisplayColumns(self, settings):
return {'cost': self.settings.get("cost"), 'payout': self.settings.get("payout"), 'difference': self.settings.get("difference")}
''' Future use when repopulate can be called during runtime, might need rewrite from changing displayColumns from list to dict
def settingsDiffer(self, settings):
newColumns = self.getDisplayColumns(settings)
if self.displayColumns == newColumns:
return False
self.displayColumns = newColumns
return True
'''
def getHeaderText(self, fit):
return "Insurance"
def newBoxText(self, grid, contentPanel, text):
box = wx.BoxSizer(wx.VERTICAL)
grid.Add(box, 0, wx.ALIGN_TOP)
box.Add(wx.StaticText(contentPanel, wx.ID_ANY, text), 0, wx.ALIGN_CENTER)
def newBoxLabel(self, grid, contentPanel, labeltype, label):
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0.00 ISK")
setattr(self, "labelInsurance{}{}".format(labeltype, label), lbl)
box = wx.BoxSizer(wx.VERTICAL)
grid.Add(box, 0, wx.ALIGN_TOP)
box.Add(lbl, 0, wx.ALIGN_LEFT)
def populatePanel(self, contentPanel, headerPanel):
contentSizer = contentPanel.GetSizer()
self.panel = contentPanel
self.headerPanel = headerPanel
columnCount = sum(self.displayColumns.values()) + 1
gridInsuranceValues = wx.GridSizer(6, columnCount, 0, 0)
contentSizer.Add(gridInsuranceValues, 0, wx.EXPAND | wx.ALL, 0)
self.newBoxText(gridInsuranceValues, contentPanel, "Level")
if (self.settings.get("cost")):
self.newBoxText(gridInsuranceValues, contentPanel, "Cost")
if (self.settings.get("payout")):
self.newBoxText(gridInsuranceValues, contentPanel, "Payout")
if (self.settings.get("difference")):
self.newBoxText(gridInsuranceValues, contentPanel, "Difference")
for level in ["Basic", "Bronze", "Silver", "Gold", "Platinum"]:
self.newBoxText(gridInsuranceValues, contentPanel, level)
if (self.settings.get("cost")):
self.newBoxLabel(gridInsuranceValues, contentPanel, "Cost", level)
if (self.settings.get("payout")):
self.newBoxLabel(gridInsuranceValues, contentPanel, "Payout", level)
if (self.settings.get("difference")):
self.newBoxLabel(gridInsuranceValues, contentPanel, "Difference", level)
def refreshPanel(self, fit):
if fit is not None:
sInsurance = Insurance.getInstance()
self.insuranceLevels = sInsurance.getInsurance(fit.ship.item.ID)
# Currently populate is only called on init from statsPane.py, so a restart is required for repopulate
# Could also create the 6 different configurations and enable/disable, but it looks like work is being
# done to add runtime repopulation of panels, so I'm going to just require restart for column view change
# to take effect, and then enable this function when the changes for runtime repopulation go live
# if self.settingsDiffer(self.settings):
# self.populatePanel(self.panel, self.headerPanel, True)
self.refreshInsurancePanelPrices()
self.panel.Layout()
def refreshInsurancePanelPrices(self):
if self.insuranceLevels:
for index, label in enumerate(["Basic", "Bronze", "Silver", "Gold", "Platinum"]):
cost = self.insuranceLevels[index].get('cost')
payout = self.insuranceLevels[index].get('payout')
if self.displayColumns["cost"]:
getattr(self, "labelInsuranceCost%s" % label).SetLabel("%s ISK" % formatAmount(cost, 3, 3, 9, currency=True))
if self.displayColumns["payout"]:
getattr(self, "labelInsurancePayout%s" % label).SetLabel("%s ISK" % formatAmount(payout, 3, 3, 9, currency=True))
if self.displayColumns["difference"]:
getattr(self, "labelInsuranceDifference%s" % label).SetLabel("%s ISK" % formatAmount(payout - cost, 3, 3, 9, currency=True))
InsuranceViewFull.register()