More work on the drone pane, more specificly, a pwetty + & - button (not working yet) and a bit of polish on the columns

This commit is contained in:
cncfanatics
2010-09-05 09:55:37 +02:00
parent c05ae0c87c
commit a44ec58aaa
7 changed files with 68 additions and 30 deletions

2
eos

Submodule eos updated: 262fde396e...a87155ebf8

View File

@@ -54,7 +54,7 @@ class AttributeDisplay(ViewColumn):
def getText(self, mod): def getText(self, mod):
attr = mod.getModifiedItemAttr(self.info.name) attr = mod.getModifiedItemAttr(self.info.name)
if attr: if attr:
return shorten(attr, 3, 0, 0) return (shorten(attr, 3, 0, 3))
else: else:
return "" return ""

View File

@@ -94,8 +94,8 @@ class Display(wx.ListCtrl):
for i, col in enumerate(self.activeColumns): for i, col in enumerate(self.activeColumns):
if not col.resized: if not col.resized:
self.SetColumnWidth(i, wx.LIST_AUTOSIZE) self.SetColumnWidth(i, col.size)
if self.GetColumnWidth(i) < 40: if self.GetColumnWidth(i) < 40 and col.size == wx.LIST_AUTOSIZE:
self.SetColumnWidth(i, 40) self.SetColumnWidth(i, 40)
for sel in selection: for sel in selection:

View File

@@ -21,16 +21,21 @@ import wx
import controller import controller
import gui.mainFrame import gui.mainFrame
from gui import bitmapLoader
import gui.fittingView as fv import gui.fittingView as fv
import gui.marketBrowser as mb import gui.marketBrowser as mb
import gui.builtinViewColumns.display as d import gui.builtinViewColumns.display as d
from gui.builtinViewColumns import registerColumn
from gui.viewColumn import ViewColumn
class DroneView(d.Display): class DroneView(d.Display):
DEFAULT_COLS = ["Drone Name/Amount", DEFAULT_COLS = ["Activate Drone",
"Deactivate Drone",
"Drone Name/Amount",
"Drone DPS", "Drone DPS",
"Max range", "Max range",
"attr:trackingSpeed", "attr:trackingSpeed",
"attr:maxVelocity"] "attr:maxVelocity",]
def __init__(self, parent): def __init__(self, parent):
d.Display.__init__(self, parent) d.Display.__init__(self, parent)
@@ -42,7 +47,7 @@ class DroneView(d.Display):
cFit = controller.Fit.getInstance() cFit = controller.Fit.getInstance()
fit = cFit.getFit(event.fitID) fit = cFit.getFit(event.fitID)
self.populate(fit.drones) self.populate(fit.drones if fit is not None else None)
def addItem(self, event): def addItem(self, event):
cFit = controller.Fit.getInstance() cFit = controller.Fit.getInstance()
@@ -59,3 +64,36 @@ class DroneView(d.Display):
cFit.removeDrone(fitID, self.GetItemData(row)) cFit.removeDrone(fitID, self.GetItemData(row))
wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID)) 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)

BIN
icons/less_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

BIN
icons/more_small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

46
util.py
View File

@@ -1,33 +1,33 @@
def shorten(val, prec=4, lowest=0, highest=0): def shorten(val, prec=4, lowest=0, highest=0, unit = True):
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
if abs(val) >= 1000 and highest >= 3: if abs(val) >= 1000 and highest >= 3:
suffixmap = {3 : "k", 6 : "M", 9 : "G"} suffixmap = {3 : "k", 6 : "M", 9 : "G"}
for key in sorted(suffixmap, reverse = True): for key in sorted(suffixmap, reverse = True):
if val >= 10**key and key <= highest: 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: elif abs(val) < 1 and val != 0 and lowest <= -3:
suffixmap = {-6 : u'\u03bc', -3 : "m"} suffixmap = {-6 : u'\u03bc', -3 : "m"}
for key in sorted(suffixmap, reverse = False): for key in sorted(suffixmap, reverse = False):
if val < 10**(key+3) and key >= lowest: 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: else:
return u"{0}".format(process(val, prec)) 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