@@ -34,6 +34,7 @@ def __init__(self, parent, marketBrowser):
3434 self .filteredStore = set ()
3535 self .sMkt = marketBrowser .sMkt
3636 self .sFit = Fit .getInstance ()
37+ self .sAmmo = Ammo .getInstance ()
3738
3839 self .marketBrowser = marketBrowser
3940 self .marketView = marketBrowser .marketView
@@ -53,6 +54,7 @@ def __init__(self, parent, marketBrowser):
5354 self .Bind (wx .EVT_LIST_ITEM_ACTIVATED , self .itemActivated )
5455 self .Bind (wx .EVT_LIST_BEGIN_DRAG , self .startDrag )
5556
57+ # the "charges for active fitting" needs to listen to fitting changes
5658 self .mainFrame .Bind (GE .FIT_CHANGED , self .selectedFittingChanged )
5759
5860 self .active = []
@@ -134,22 +136,28 @@ def getChargesForActiveFit(self):
134136 if fitId is None :
135137 return set ()
136138
137- sAmmo = Ammo .getInstance ()
138139 fit = self .sFit .getFit (fitId )
140+
141+ # use a set so we only add one entry for each charge
139142 items = set ()
140143 for mod in fit .modules :
141- charges = sAmmo .getModuleFlatAmmo (mod )
144+ charges = self . sAmmo .getModuleFlatAmmo (mod )
142145 for charge in charges :
143146 items .add (charge )
144147 return items
145148
146149 def selectedFittingChanged (self , event ):
150+ # skip the event so the other handlers also get called
147151 event .Skip ()
148152 activeFitID = self .mainFrame .getActiveFit ()
153+
154+ # if it was not the active fitting that was changed, do not do anything
149155 if activeFitID is not None and activeFitID not in event .fitIDs :
150156 return
151157
152158 items = self .getChargesForActiveFit ()
159+
160+ # update the UI
153161 self .updateItemStore (items )
154162 self .filterItemStore ()
155163
0 commit comments