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:
2
eos
2
eos
Submodule eos updated: 262fde396e...a87155ebf8
@@ -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 ""
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
BIN
icons/less_small.png
Normal file
BIN
icons/less_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 215 B |
BIN
icons/more_small.png
Normal file
BIN
icons/more_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 332 B |
46
util.py
46
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
|
||||
|
||||
Reference in New Issue
Block a user