From a44ec58aaa6a5202b8df53aa2db160c80a0e32cb Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Sun, 5 Sep 2010 09:55:37 +0200 Subject: [PATCH] More work on the drone pane, more specificly, a pwetty + & - button (not working yet) and a bit of polish on the columns --- eos | 2 +- gui/builtinViewColumns/attributeDisplay.py | 2 +- gui/builtinViewColumns/display.py | 4 +- gui/droneView.py | 44 ++++++++++++++++++-- icons/less_small.png | Bin 0 -> 215 bytes icons/more_small.png | Bin 0 -> 332 bytes util.py | 46 ++++++++++----------- 7 files changed, 68 insertions(+), 30 deletions(-) create mode 100644 icons/less_small.png create mode 100644 icons/more_small.png diff --git a/eos b/eos index 262fde396..a87155ebf 160000 --- a/eos +++ b/eos @@ -1 +1 @@ -Subproject commit 262fde396e8f174ade270a3b1472ce44a10624da +Subproject commit a87155ebf8aaf845c7419860940d9f1e7a121b00 diff --git a/gui/builtinViewColumns/attributeDisplay.py b/gui/builtinViewColumns/attributeDisplay.py index a1b60b979..e63415bec 100644 --- a/gui/builtinViewColumns/attributeDisplay.py +++ b/gui/builtinViewColumns/attributeDisplay.py @@ -54,7 +54,7 @@ class AttributeDisplay(ViewColumn): def getText(self, mod): attr = mod.getModifiedItemAttr(self.info.name) if attr: - return shorten(attr, 3, 0, 0) + return (shorten(attr, 3, 0, 3)) else: return "" diff --git a/gui/builtinViewColumns/display.py b/gui/builtinViewColumns/display.py index 8e314ab90..b650c4ae4 100644 --- a/gui/builtinViewColumns/display.py +++ b/gui/builtinViewColumns/display.py @@ -94,8 +94,8 @@ class Display(wx.ListCtrl): for i, col in enumerate(self.activeColumns): if not col.resized: - self.SetColumnWidth(i, wx.LIST_AUTOSIZE) - if self.GetColumnWidth(i) < 40: + self.SetColumnWidth(i, col.size) + if self.GetColumnWidth(i) < 40 and col.size == wx.LIST_AUTOSIZE: self.SetColumnWidth(i, 40) for sel in selection: diff --git a/gui/droneView.py b/gui/droneView.py index 47a5ff952..e726aa034 100644 --- a/gui/droneView.py +++ b/gui/droneView.py @@ -21,16 +21,21 @@ import wx import controller import gui.mainFrame +from gui import bitmapLoader import gui.fittingView as fv import gui.marketBrowser as mb import gui.builtinViewColumns.display as d +from gui.builtinViewColumns import registerColumn +from gui.viewColumn import ViewColumn class DroneView(d.Display): - DEFAULT_COLS = ["Drone Name/Amount", + DEFAULT_COLS = ["Activate Drone", + "Deactivate Drone", + "Drone Name/Amount", "Drone DPS", "Max range", "attr:trackingSpeed", - "attr:maxVelocity"] + "attr:maxVelocity",] def __init__(self, parent): d.Display.__init__(self, parent) @@ -42,7 +47,7 @@ class DroneView(d.Display): cFit = controller.Fit.getInstance() fit = cFit.getFit(event.fitID) - self.populate(fit.drones) + self.populate(fit.drones if fit is not None else None) def addItem(self, event): cFit = controller.Fit.getInstance() @@ -59,3 +64,36 @@ class DroneView(d.Display): cFit.removeDrone(fitID, self.GetItemData(row)) wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID)) + +class DroneMore(ViewColumn): + name = "Activate Drone" + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + bitmap = bitmapLoader.getBitmap("more_small", "icons") + self.moreId = fittingView.imageList.Add(bitmap) + self.size = 16 + self.columnText = "" + + def getText(self, drone): + return "" + + def getImageId(self, mod): + return self.moreId + +class DroneLess(ViewColumn): + name = "Deactivate Drone" + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + bitmap = bitmapLoader.getBitmap("less_small", "icons") + self.lessId = fittingView.imageList.Add(bitmap) + self.size = 16 + self.columnText = "" + + def getText(self, drone): + return "" + + def getImageId(self, mod): + return self.lessId + +registerColumn(DroneMore) +registerColumn(DroneLess) diff --git a/icons/less_small.png b/icons/less_small.png new file mode 100644 index 0000000000000000000000000000000000000000..e1e61f2a758ba3cbdae4bbff06f7eb2c462c3932 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`^E_P~Lo9mVPB7#;6d>S|?zlQX zdDWCmRSvlW%}*3|cByajjJj>|jO|nR2m5pHZbhncG=)`uH8>-k@KpW8^@jq7)@gLv zdOn-8d6kyuvMHNZ6|GD7oF_DK*Sh}P+i}Y>nLKCBoIP`54d3AfvDa;X?aOC)a+5VQ zbnfX*dnUEaJa|`8NrAK6y~nWkaRoy`{HME27K|L+r&tP@1?=Z-{^TCle>&)aezvhJ P(4`EXu6{1-oD!M<8OK)) literal 0 HcmV?d00001 diff --git a/icons/more_small.png b/icons/more_small.png new file mode 100644 index 0000000000000000000000000000000000000000..d470d33662ba24cb7dbd09268a4c8a7a01537a76 GIT binary patch literal 332 zcmV-S0ki&zP)tcX7)va1$v890N|$ECm-yFx0&E zT^9!neE~PU+r8&-?%~`E|Gqk2pwkJ$Fzh+!L`2-Lm7^#!^ZER3GMU^12R@$m0ZJ*I zrs>gYwK@h4eY{|&34*RMCUVX>V@y8`LzGgjPIu7JXmmQ8&2H9t%>6pYb{k(AtIDzxn3@pC%~)EQ5P5k7r^Co zI+ej-@B&y!T literal 0 HcmV?d00001 diff --git a/util.py b/util.py index d0344cd6c..99dacd203 100644 --- a/util.py +++ b/util.py @@ -1,33 +1,33 @@ -def shorten(val, prec=4, lowest=0, highest=0): - - def process(val, prec): - # Check if we have no integer and some fraction after bunch of zeroes, - # counting these zeros in process - shiftFraction, integersNumber = 0, 0 - if int(val) == 0 and val != 0: - while val < 0.1**(shiftFraction+1): - shiftFraction += 1 - else: - while abs(val) >= 10**(integersNumber): - integersNumber +=1 - # We want to show at least (prec) significant numbers in any cases - roundFactor = prec + shiftFraction - integersNumber - # But we don't want to round integers - if roundFactor < 0: roundFactor = 0 - val = round(val, roundFactor) - # Strip trailing zero for integers and convert to string - result = str(val)[-2:] == '.0' and str(val)[:-2] or str(val) - return result - +def shorten(val, prec=4, lowest=0, highest=0, unit = True): if abs(val) >= 1000 and highest >= 3: suffixmap = {3 : "k", 6 : "M", 9 : "G"} for key in sorted(suffixmap, reverse = True): if val >= 10**key and key <= highest: - return u"{0}{1}".format(process(val/float(10**key), prec), suffixmap[key]) + return u"{0}{1}".format(process(val/float(10**key), prec), suffixmap[key] if unit else "") elif abs(val) < 1 and val != 0 and lowest <= -3: suffixmap = {-6 : u'\u03bc', -3 : "m"} for key in sorted(suffixmap, reverse = False): if val < 10**(key+3) and key >= lowest: - return u"{0}{1}".format(process(val/float(10**key), prec), suffixmap[key]) + return u"{0}{1}".format(process(val/float(10**key), prec), suffixmap[key] if unit else "") else: return u"{0}".format(process(val, prec)) + + +def process(val, prec): + # Check if we have no integer and some fraction after bunch of zeroes, + # counting these zeros in process + shiftFraction, integersNumber = 0, 0 + if int(val) == 0 and val != 0: + while val < 0.1**(shiftFraction+1): + shiftFraction += 1 + else: + while abs(val) >= 10**(integersNumber): + integersNumber +=1 + # We want to show at least (prec) significant numbers in any cases + roundFactor = prec + shiftFraction - integersNumber + # But we don't want to round integers + if roundFactor < 0: roundFactor = 0 + val = round(val, roundFactor) + # Strip trailing zero for integers and convert to string + result = str(val)[-2:] == '.0' and str(val)[:-2] or str(val) + return result