Compare commits
1 Commits
v2.65.2.23
...
v2.65.2.24
| Author | SHA1 | Date | |
|---|---|---|---|
| bfd5bbb881 |
@@ -79,6 +79,9 @@ class ItemCompare(wx.Panel):
|
|||||||
self.computedAttrs = {} # Store computed per-second attributes
|
self.computedAttrs = {} # Store computed per-second attributes
|
||||||
self.HighlightOn = wx.Colour(255, 255, 0, wx.ALPHA_OPAQUE)
|
self.HighlightOn = wx.Colour(255, 255, 0, wx.ALPHA_OPAQUE)
|
||||||
self.highlightedNames = []
|
self.highlightedNames = []
|
||||||
|
self.bangBuckColumn = None # Store the column selected for bang/buck calculation
|
||||||
|
self.bangBuckColumnName = None # Store the display name of the selected column
|
||||||
|
self.columnHighlightColour = wx.Colour(173, 216, 230, wx.ALPHA_OPAQUE) # Light blue for column highlight
|
||||||
|
|
||||||
# get a dict of attrName: attrInfo of all unique attributes across all items
|
# get a dict of attrName: attrInfo of all unique attributes across all items
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
@@ -173,6 +176,7 @@ class ItemCompare(wx.Panel):
|
|||||||
|
|
||||||
self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleViewMode)
|
self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleViewMode)
|
||||||
self.Bind(wx.EVT_LIST_COL_CLICK, self.SortCompareCols)
|
self.Bind(wx.EVT_LIST_COL_CLICK, self.SortCompareCols)
|
||||||
|
self.Bind(wx.EVT_LIST_COL_RIGHT_CLICK, self.OnColumnRightClick)
|
||||||
|
|
||||||
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.HighlightRow)
|
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.HighlightRow)
|
||||||
|
|
||||||
@@ -189,6 +193,23 @@ class ItemCompare(wx.Panel):
|
|||||||
self.Thaw()
|
self.Thaw()
|
||||||
event.Skip()
|
event.Skip()
|
||||||
|
|
||||||
|
def OnColumnRightClick(self, event):
|
||||||
|
column = event.GetColumn()
|
||||||
|
# Column 0 is "Item", column len(self.attrs) + 1 is "Price", len(self.attrs) + 2 is "Buck/bang"
|
||||||
|
# Only allow selecting attribute columns (1 to len(self.attrs))
|
||||||
|
if 1 <= column <= len(self.attrs):
|
||||||
|
# If clicking the same column, deselect it
|
||||||
|
if self.bangBuckColumn == column:
|
||||||
|
self.bangBuckColumn = None
|
||||||
|
self.bangBuckColumnName = None
|
||||||
|
else:
|
||||||
|
self.bangBuckColumn = column
|
||||||
|
# Get the display name of the selected column
|
||||||
|
attr_key = list(self.attrs.keys())[column - 1]
|
||||||
|
self.bangBuckColumnName = self.attrs[attr_key].displayName if self.attrs[attr_key].displayName else attr_key
|
||||||
|
self.UpdateList()
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
def SortCompareCols(self, event):
|
def SortCompareCols(self, event):
|
||||||
self.Freeze()
|
self.Freeze()
|
||||||
self.paramList.ClearAll()
|
self.paramList.ClearAll()
|
||||||
@@ -245,6 +266,19 @@ class ItemCompare(wx.Panel):
|
|||||||
# Price
|
# Price
|
||||||
if sort == len(self.attrs) + 1:
|
if sort == len(self.attrs) + 1:
|
||||||
func = lambda i: i.price.price if i.price.price != 0 else float("Inf")
|
func = lambda i: i.price.price if i.price.price != 0 else float("Inf")
|
||||||
|
# Buck/bang
|
||||||
|
elif sort == len(self.attrs) + 2:
|
||||||
|
if self.bangBuckColumn is not None:
|
||||||
|
attr_key = list(self.attrs.keys())[self.bangBuckColumn - 1]
|
||||||
|
if attr_key in self.computedAttrs:
|
||||||
|
computed = self.computedAttrs[attr_key]
|
||||||
|
amountAttr = computed["amountAttr"]
|
||||||
|
durationAttr = computed["durationAttr"]
|
||||||
|
func = lambda i: (i.price.price / (i.attributes[amountAttr].value / (i.attributes[durationAttr].value / 1000.0)) if (amountAttr in i.attributes and durationAttr in i.attributes and i.attributes[durationAttr].value > 0 and (i.attributes[amountAttr].value / (i.attributes[durationAttr].value / 1000.0)) > 0) else float("Inf"))
|
||||||
|
else:
|
||||||
|
func = lambda i: (i.price.price / i.attributes[attr_key].value if (attr_key in i.attributes and i.attributes[attr_key].value > 0) else float("Inf"))
|
||||||
|
else:
|
||||||
|
func = defaultSort
|
||||||
# Something else
|
# Something else
|
||||||
else:
|
else:
|
||||||
self.sortReverse = False
|
self.sortReverse = False
|
||||||
@@ -257,12 +291,22 @@ class ItemCompare(wx.Panel):
|
|||||||
|
|
||||||
for i, attr in enumerate(self.attrs.keys()):
|
for i, attr in enumerate(self.attrs.keys()):
|
||||||
name = self.attrs[attr].displayName if self.attrs[attr].displayName else attr
|
name = self.attrs[attr].displayName if self.attrs[attr].displayName else attr
|
||||||
|
# Add indicator if this column is selected for bang/buck calculation
|
||||||
|
if self.bangBuckColumn == i + 1:
|
||||||
|
name = "► " + name
|
||||||
self.paramList.InsertColumn(i + 1, name)
|
self.paramList.InsertColumn(i + 1, name)
|
||||||
self.paramList.SetColumnWidth(i + 1, 120)
|
self.paramList.SetColumnWidth(i + 1, 120)
|
||||||
|
|
||||||
self.paramList.InsertColumn(len(self.attrs) + 1, _t("Price"))
|
self.paramList.InsertColumn(len(self.attrs) + 1, _t("Price"))
|
||||||
self.paramList.SetColumnWidth(len(self.attrs) + 1, 60)
|
self.paramList.SetColumnWidth(len(self.attrs) + 1, 60)
|
||||||
|
|
||||||
|
# Add Buck/bang column header
|
||||||
|
buckBangHeader = _t("Buck/bang")
|
||||||
|
if self.bangBuckColumnName:
|
||||||
|
buckBangHeader = _t("Buck/bang ({})").format(self.bangBuckColumnName)
|
||||||
|
self.paramList.InsertColumn(len(self.attrs) + 2, buckBangHeader)
|
||||||
|
self.paramList.SetColumnWidth(len(self.attrs) + 2, 80)
|
||||||
|
|
||||||
toHighlight = []
|
toHighlight = []
|
||||||
|
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
@@ -303,6 +347,27 @@ class ItemCompare(wx.Panel):
|
|||||||
|
|
||||||
# Add prices
|
# Add prices
|
||||||
self.paramList.SetItem(i, len(self.attrs) + 1, formatAmount(item.price.price, 3, 3, 9, currency=True) if item.price.price else "")
|
self.paramList.SetItem(i, len(self.attrs) + 1, formatAmount(item.price.price, 3, 3, 9, currency=True) if item.price.price else "")
|
||||||
|
|
||||||
|
# Add buck/bang values
|
||||||
|
if self.bangBuckColumn is not None and item.price.price and item.price.price > 0:
|
||||||
|
attr_key = list(self.attrs.keys())[self.bangBuckColumn - 1]
|
||||||
|
if attr_key in self.computedAttrs:
|
||||||
|
computed = self.computedAttrs[attr_key]
|
||||||
|
amountAttr = computed["amountAttr"]
|
||||||
|
durationAttr = computed["durationAttr"]
|
||||||
|
if amountAttr in item.attributes and durationAttr in item.attributes:
|
||||||
|
amountValue = item.attributes[amountAttr].value
|
||||||
|
durationValue = item.attributes[durationAttr].value
|
||||||
|
perSecondValue = amountValue / (durationValue / 1000.0) if durationValue > 0 else 0
|
||||||
|
if perSecondValue > 0:
|
||||||
|
buckBangValue = item.price.price / perSecondValue
|
||||||
|
self.paramList.SetItem(i, len(self.attrs) + 2, formatAmount(buckBangValue, 3, 3, 9, currency=True))
|
||||||
|
elif attr_key in item.attributes:
|
||||||
|
attrValue = item.attributes[attr_key].value
|
||||||
|
if attrValue > 0:
|
||||||
|
buckBangValue = item.price.price / attrValue
|
||||||
|
self.paramList.SetItem(i, len(self.attrs) + 2, formatAmount(buckBangValue, 3, 3, 9, currency=True))
|
||||||
|
|
||||||
if item.name in self.highlightedNames:
|
if item.name in self.highlightedNames:
|
||||||
toHighlight.append(i)
|
toHighlight.append(i)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user