From 97839a20f5c6e519c85b98e4d9741f8ce7be56de Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 11:42:00 +0300 Subject: [PATCH 1/9] Made item stats attributes name more human readable + value formatting --- gui/itemStats.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 4a641ca91..ce81eb462 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -22,7 +22,8 @@ import wx.gizmos import gui.mainFrame import bitmapLoader import sys -import random + +from util import formatAmount class ItemStatsDialog(wx.Dialog): counter = 0 @@ -146,8 +147,8 @@ class ItemParams (wx.Panel): names.sort() for name in names: - index = self.paramList.InsertStringItem(sys.maxint, name) - self.paramList.SetStringItem(index, 1, str(attrs[name]) if stuff is not None else str(attrs[name].value)) + index = self.paramList.InsertStringItem(sys.maxint, attrs[name].displayName.capitalize()) + self.paramList.SetStringItem(index, 1, str(attrs[name]) if stuff is not None else str(formatAmount(attrs[name].value, 3, 0, 0))) self.Layout() From 0adf72548dbff5cd3f72274375cfcddb05309146 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 11:56:51 +0300 Subject: [PATCH 2/9] Small itemstats window placement improvement --- gui/itemStats.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gui/itemStats.py b/gui/itemStats.py index ce81eb462..40a0c6052 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -62,7 +62,10 @@ class ItemStatsDialog(wx.Dialog): dlgsize = self.GetSize() psize = parent.GetSize() ppos = parent.GetPosition() + ItemStatsDialog.counter += 1 + self.dlgOrder = ItemStatsDialog.counter + counter = ItemStatsDialog.counter dlgStep = 30 if counter * dlgStep > ppos.x+psize.width-dlgsize.x or counter * dlgStep > ppos.y+psize.height-dlgsize.y: @@ -77,6 +80,9 @@ class ItemStatsDialog(wx.Dialog): self.Bind(wx.EVT_CLOSE, self.closeEvent) def closeEvent(self, event): + + if self.dlgOrder==ItemStatsDialog.counter: + ItemStatsDialog.counter -= 1 self.Destroy() event.Skip() From 9216fb69bbdbe19009943a50375a193571dcf6b7 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 12:48:17 +0300 Subject: [PATCH 3/9] Make use of mixins.listctrl in itemstats listctrls to get things pretty --- gui/itemStats.py | 61 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 40a0c6052..b460f6eba 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -22,6 +22,8 @@ import wx.gizmos import gui.mainFrame import bitmapLoader import sys +import wx.lib.mixins.listctrl as listmix + from util import formatAmount @@ -103,10 +105,12 @@ class ItemStatsContainer ( wx.Panel ): self.params = ItemParams(self.nbContainer, stuff, item) self.reqs = ItemRequirements(self.nbContainer, stuff, item) self.effects = ItemEffects(self.nbContainer, stuff, item) + self.affectedby = ItemAffectedBy(self.nbContainer, stuff, item) self.nbContainer.AddPage(self.desc, "Description") self.nbContainer.AddPage(self.params, "Attributes") self.nbContainer.AddPage(self.reqs, "Requirements") self.nbContainer.AddPage(self.effects, "Effects") + self.nbContainer.AddPage(self.affectedby, "Affected by") self.SetSizer(mainSizer) self.Layout() @@ -114,6 +118,17 @@ class ItemStatsContainer ( wx.Panel ): def __del__( self ): pass +########################################################################### +## Class AutoListCtrl +########################################################################### + +class AutoListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin): + + def __init__(self, parent, ID, pos=wx.DefaultPosition, + size=wx.DefaultSize, style=0): + wx.ListCtrl.__init__(self, parent, ID, pos, size, style) + listmix.ListCtrlAutoWidthMixin.__init__(self) + ########################################################################### ## Class ItemDescription @@ -139,15 +154,15 @@ class ItemParams (wx.Panel): wx.Panel.__init__ (self, parent) mainSizer = wx.BoxSizer( wx.VERTICAL ) - self.paramList = wx.ListCtrl(self, wx.ID_ANY, + self.paramList = AutoListCtrl(self, wx.ID_ANY, style = wx.LC_HRULES | wx.LC_NO_HEADER |wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) mainSizer.Add( self.paramList, 1, wx.ALL|wx.EXPAND, 0 ) self.SetSizer( mainSizer ) self.paramList.InsertColumn(0,"Attribute") self.paramList.InsertColumn(1,"Value") - self.paramList.SetColumnWidth(0,300) - self.paramList.SetColumnWidth(1,165) + self.paramList.SetColumnWidth(1,200) + self.paramList.setResizeColumn(1) attrs = stuff.itemModifiedAttributes if stuff is not None else item.attributes names = list(attrs.iterkeys()) names.sort() @@ -206,7 +221,7 @@ class ItemEffects (wx.Panel): wx.Panel.__init__ (self, parent) mainSizer = wx.BoxSizer( wx.VERTICAL ) - self.effectList = wx.ListCtrl(self, wx.ID_ANY, + self.effectList = AutoListCtrl(self, wx.ID_ANY, style = wx.LC_HRULES | #wx.LC_NO_HEADER | wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) @@ -216,9 +231,14 @@ class ItemEffects (wx.Panel): self.effectList.InsertColumn(0,"Name") self.effectList.InsertColumn(1,"Description") self.effectList.InsertColumn(2,"Implemented") + self.effectList.SetColumnWidth(0,155) + self.effectList.SetColumnWidth(1,235) - self.effectList.SetColumnWidth(2,90) + self.effectList.setResizeColumn(1) + + self.effectList.SetColumnWidth(2,80) + effects = item.effects names = list(effects.iterkeys()) names.sort() @@ -232,3 +252,34 @@ class ItemEffects (wx.Panel): implemented = "No" self.effectList.SetStringItem(index, 2, implemented) self.Layout() + + +########################################################################### +## Class ItemAffectedBy +########################################################################### + + +class ItemAffectedBy (wx.Panel): + def __init__(self, parent, stuff, item): + wx.Panel.__init__ (self, parent) + mainSizer = wx.BoxSizer( wx.VERTICAL ) + + self.effectList = AutoListCtrl(self, wx.ID_ANY, + style = wx.LC_HRULES | + wx.LC_NO_HEADER | + wx.LC_REPORT |wx.LC_SINGLE_SEL | + #wx.LC_VRULES | + wx.NO_BORDER) + mainSizer.Add( self.effectList, 1, wx.ALL|wx.EXPAND, 0 ) + self.SetSizer( mainSizer ) + + self.effectList.InsertColumn(0,"Name") + self.effectList.setResizeColumn(0) + effects = item.effects + names = list(effects.iterkeys()) + names.sort() + + for name in names: + index = self.effectList.InsertStringItem(sys.maxint, name) + + self.Layout() From b5c58d8fe307bbba8d415a4422c1ebbf8a715d27 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 13:14:13 +0300 Subject: [PATCH 4/9] Make use of mixins.listctrl.ListRowHighlighter in itemstats listctrls to get things even more prettier --- gui/itemStats.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index b460f6eba..334139e95 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -122,12 +122,13 @@ class ItemStatsContainer ( wx.Panel ): ## Class AutoListCtrl ########################################################################### -class AutoListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin): +class AutoListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ListRowHighlighter): def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0): wx.ListCtrl.__init__(self, parent, ID, pos, size, style) listmix.ListCtrlAutoWidthMixin.__init__(self) + listmix.ListRowHighlighter.__init__(self, mode = 1) ########################################################################### @@ -155,7 +156,8 @@ class ItemParams (wx.Panel): mainSizer = wx.BoxSizer( wx.VERTICAL ) self.paramList = AutoListCtrl(self, wx.ID_ANY, - style = wx.LC_HRULES | wx.LC_NO_HEADER |wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) + style = #wx.LC_HRULES | + wx.LC_NO_HEADER |wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) mainSizer.Add( self.paramList, 1, wx.ALL|wx.EXPAND, 0 ) self.SetSizer( mainSizer ) @@ -222,7 +224,8 @@ class ItemEffects (wx.Panel): mainSizer = wx.BoxSizer( wx.VERTICAL ) self.effectList = AutoListCtrl(self, wx.ID_ANY, - style = wx.LC_HRULES | + style = + #wx.LC_HRULES | #wx.LC_NO_HEADER | wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) mainSizer.Add( self.effectList, 1, wx.ALL|wx.EXPAND, 0 ) @@ -265,7 +268,8 @@ class ItemAffectedBy (wx.Panel): mainSizer = wx.BoxSizer( wx.VERTICAL ) self.effectList = AutoListCtrl(self, wx.ID_ANY, - style = wx.LC_HRULES | + style = + #wx.LC_HRULES | wx.LC_NO_HEADER | wx.LC_REPORT |wx.LC_SINGLE_SEL | #wx.LC_VRULES | From d0f97a22583a15b90489837815a4525006fff379 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 13:23:27 +0300 Subject: [PATCH 5/9] Use headers in all itemstats listctrls --- gui/itemStats.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 334139e95..a1e4bd631 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -157,7 +157,8 @@ class ItemParams (wx.Panel): self.paramList = AutoListCtrl(self, wx.ID_ANY, style = #wx.LC_HRULES | - wx.LC_NO_HEADER |wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) + #wx.LC_NO_HEADER | + wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER) mainSizer.Add( self.paramList, 1, wx.ALL|wx.EXPAND, 0 ) self.SetSizer( mainSizer ) @@ -270,7 +271,7 @@ class ItemAffectedBy (wx.Panel): self.effectList = AutoListCtrl(self, wx.ID_ANY, style = #wx.LC_HRULES | - wx.LC_NO_HEADER | + #wx.LC_NO_HEADER | wx.LC_REPORT |wx.LC_SINGLE_SEL | #wx.LC_VRULES | wx.NO_BORDER) From 2644591eadb0d99348bfe91d6a09195449bd1e91 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 13:39:44 +0300 Subject: [PATCH 6/9] Small visual bug fix in itemstats --- gui/itemStats.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index a1e4bd631..1e04cba2f 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -128,7 +128,7 @@ class AutoListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ListRowH size=wx.DefaultSize, style=0): wx.ListCtrl.__init__(self, parent, ID, pos, size, style) listmix.ListCtrlAutoWidthMixin.__init__(self) - listmix.ListRowHighlighter.__init__(self, mode = 1) + listmix.ListRowHighlighter.__init__(self) ########################################################################### @@ -173,7 +173,7 @@ class ItemParams (wx.Panel): for name in names: index = self.paramList.InsertStringItem(sys.maxint, attrs[name].displayName.capitalize()) self.paramList.SetStringItem(index, 1, str(attrs[name]) if stuff is not None else str(formatAmount(attrs[name].value, 3, 0, 0))) - + self.paramList.RefreshRows() self.Layout() @@ -255,6 +255,8 @@ class ItemEffects (wx.Panel): else: implemented = "No" self.effectList.SetStringItem(index, 2, implemented) + + self.effectList.RefreshRows() self.Layout() @@ -287,4 +289,5 @@ class ItemAffectedBy (wx.Panel): for name in names: index = self.effectList.InsertStringItem(sys.maxint, name) + self.effectList.RefreshRows() self.Layout() From 0fd98a0f440210f7b5cb7c4f8712c7a1126775c1 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 13:58:23 +0300 Subject: [PATCH 7/9] Using attr.displayName resulted in a crash when viewing a ship stats (itemModifiedAttributes objects don't have displayName property ???), removed. Made sure we format values when viewing a ship stats --- gui/itemStats.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 1e04cba2f..c3042ac4c 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -49,7 +49,7 @@ class ItemStatsDialog(wx.Dialog): if item.icon is not None: self.SetIcon(wx.IconFromBitmap(bitmapLoader.getBitmap(item.icon.iconFile, "pack"))) - self.SetTitle("Item Stats: %s" % item.name) + self.SetTitle("Stats: %s" % item.name) self.SetMinSize((500, 300)) self.SetSize((500, 300)) @@ -171,8 +171,8 @@ class ItemParams (wx.Panel): names.sort() for name in names: - index = self.paramList.InsertStringItem(sys.maxint, attrs[name].displayName.capitalize()) - self.paramList.SetStringItem(index, 1, str(attrs[name]) if stuff is not None else str(formatAmount(attrs[name].value, 3, 0, 0))) + index = self.paramList.InsertStringItem(sys.maxint, name) + self.paramList.SetStringItem(index, 1, str(formatAmount(attrs[name], 3, 0, 0)) if stuff is not None else str(formatAmount(attrs[name].value, 3, 0, 0))) self.paramList.RefreshRows() self.Layout() From c5ded5e65d1ae8293accca7e0ca75dbd195f8fef Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 14:13:18 +0300 Subject: [PATCH 8/9] Allow itemstats dlg window to be resized within certain boundaries --- gui/itemStats.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index c3042ac4c..55e877d68 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -34,7 +34,9 @@ class ItemStatsDialog(wx.Dialog): gui.mainFrame.MainFrame.getInstance(), wx.ID_ANY, title="Item stats", #style=wx.FRAME_FLOAT_ON_PARENT | wx.DEFAULT_FRAME_STYLE) - style = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.SYSTEM_MENU ) + style = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX| + wx.DEFAULT_FRAME_STYLE| + wx.SYSTEM_MENU ) empty = getattr(victim, "isEmpty", False) if empty: @@ -51,9 +53,9 @@ class ItemStatsDialog(wx.Dialog): self.SetIcon(wx.IconFromBitmap(bitmapLoader.getBitmap(item.icon.iconFile, "pack"))) self.SetTitle("Stats: %s" % item.name) - self.SetMinSize((500, 300)) + self.SetMinSize((300, 200)) self.SetSize((500, 300)) - self.SetMaxSize((500, 300)) + self.SetMaxSize((500, -1)) self.mainSizer = wx.BoxSizer(wx.VERTICAL) self.container = ItemStatsContainer(self, victim, item) self.mainSizer.Add(self.container, 1, wx.EXPAND) @@ -164,7 +166,7 @@ class ItemParams (wx.Panel): self.paramList.InsertColumn(0,"Attribute") self.paramList.InsertColumn(1,"Value") - self.paramList.SetColumnWidth(1,200) + self.paramList.SetColumnWidth(1,100) self.paramList.setResizeColumn(1) attrs = stuff.itemModifiedAttributes if stuff is not None else item.attributes names = list(attrs.iterkeys()) From 4c7b612cefd024612441eba238a7e1a0a5b2c811 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Wed, 6 Oct 2010 14:26:02 +0300 Subject: [PATCH 9/9] Use correct window flags in itemstats --- gui/itemStats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 55e877d68..6618e5b81 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -35,7 +35,8 @@ class ItemStatsDialog(wx.Dialog): wx.ID_ANY, title="Item stats", #style=wx.FRAME_FLOAT_ON_PARENT | wx.DEFAULT_FRAME_STYLE) style = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX| - wx.DEFAULT_FRAME_STYLE| + wx.MAXIMIZE_BOX| + wx.RESIZE_BORDER| wx.SYSTEM_MENU ) empty = getattr(victim, "isEmpty", False)