fixed some errors, small usability enhancements.
This commit is contained in:
parent
7239784b17
commit
624030165b
@ -77,10 +77,10 @@ class IDArrayBrowser:
|
|||||||
y -= itemhgt + pad
|
y -= itemhgt + pad
|
||||||
|
|
||||||
self.buts = []
|
self.buts = []
|
||||||
|
Draw.BeginAlign()
|
||||||
for i in xrange(len(self.array)):
|
for i in xrange(len(self.array)):
|
||||||
st = ""
|
st = ""
|
||||||
if type(self.array[0]) == type(0.0):
|
if type(self.array[0]) == float:
|
||||||
st = "%.5f" % self.array[i]
|
st = "%.5f" % self.array[i]
|
||||||
else: st = str(self.array[i])
|
else: st = str(self.array[i])
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class IDArrayBrowser:
|
|||||||
if x + cellwid + pad > width:
|
if x + cellwid + pad > width:
|
||||||
x = 0
|
x = 0
|
||||||
y -= itemhgt + pad
|
y -= itemhgt + pad
|
||||||
|
Draw.EndAlign()
|
||||||
def Button(self, bval):
|
def Button(self, bval):
|
||||||
if bval == Button_Back:
|
if bval == Button_Back:
|
||||||
self.parentbrowser.state = State_Normal
|
self.parentbrowser.state = State_Normal
|
||||||
@ -102,12 +102,12 @@ class IDArrayBrowser:
|
|||||||
i = bval - ButStart
|
i = bval - ButStart
|
||||||
st = self.buts[i].val
|
st = self.buts[i].val
|
||||||
n = 0
|
n = 0
|
||||||
if type(self.array[0]) == type(0.0):
|
if type(self.array[0]) == float:
|
||||||
try:
|
try:
|
||||||
n = int(st)
|
n = int(st)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
elif type(self.array[0]) == type(0):
|
elif type(self.array[0]) == int:
|
||||||
try:
|
try:
|
||||||
n = float(st)
|
n = float(st)
|
||||||
except:
|
except:
|
||||||
@ -191,6 +191,7 @@ class IDPropertyBrowser:
|
|||||||
plist.append(p)
|
plist.append(p)
|
||||||
|
|
||||||
#-------do top buttons----------#
|
#-------do top buttons----------#
|
||||||
|
Draw.BeginAlign()
|
||||||
Draw.PushButton("New", Button_New, x, y, 40, 20)
|
Draw.PushButton("New", Button_New, x, y, 40, 20)
|
||||||
x += 40 + pad
|
x += 40 + pad
|
||||||
#do the menu button for all materials
|
#do the menu button for all materials
|
||||||
@ -219,6 +220,8 @@ class IDPropertyBrowser:
|
|||||||
self.idmenu = Draw.Menu(st, Button_TypeMenu, x, y, 100, 20, cur)
|
self.idmenu = Draw.Menu(st, Button_TypeMenu, x, y, 100, 20, cur)
|
||||||
x = self.x
|
x = self.x
|
||||||
y -= self.itemhgt + self.pad
|
y -= self.itemhgt + self.pad
|
||||||
|
Draw.EndAlign()
|
||||||
|
|
||||||
|
|
||||||
#-----------do property items---------#
|
#-----------do property items---------#
|
||||||
i = 0
|
i = 0
|
||||||
@ -232,22 +235,30 @@ class IDPropertyBrowser:
|
|||||||
glColor3f(0, 0, 0)
|
glColor3f(0, 0, 0)
|
||||||
self.DrawBox(GL_LINE_LOOP, x+pad, y, self.width-pad*2, itemhgt)
|
self.DrawBox(GL_LINE_LOOP, x+pad, y, self.width-pad*2, itemhgt)
|
||||||
|
|
||||||
glRasterPos2f(x+pad*2, y+3)
|
glRasterPos2f(x+pad*2, y+5)
|
||||||
Draw.Text(str(k)) #str(self.mousecursor) + " " + str(self.active_item)) #p.name)
|
Draw.Text(str(k)) #str(self.mousecursor) + " " + str(self.active_item)) #p.name)
|
||||||
tlen = Draw.GetStringWidth(str(k))
|
tlen = Draw.GetStringWidth(str(k))
|
||||||
|
|
||||||
if type(p) == type(""):
|
type_p = type(p)
|
||||||
|
if type_p == str:
|
||||||
b = Draw.String("", ButStart+i, x+pad*5+tlen, y, 200, itemhgt, p, strmax)
|
b = Draw.String("", ButStart+i, x+pad*5+tlen, y, 200, itemhgt, p, strmax)
|
||||||
self.buts.append(b)
|
self.buts.append(b)
|
||||||
elif type(p) in [type(0), type(0.0)]:
|
elif type_p in [int, float]:
|
||||||
#only do precision to 5 points on floats
|
#only do precision to 5 points on floats
|
||||||
st = ""
|
st = ""
|
||||||
if type(p) == type(0.0):
|
if type_p == float:
|
||||||
st = "%.5f" % p
|
st = "%.5f" % p
|
||||||
else: st = str(p)
|
else: st = str(p)
|
||||||
b = Draw.String("", ButStart+i, x+pad*5+tlen, y, 75, itemhgt, st, strmax)
|
b = Draw.String("", ButStart+i, x+pad*5+tlen, y, 75, itemhgt, st, strmax)
|
||||||
self.buts.append(b)
|
self.buts.append(b)
|
||||||
else:
|
else:
|
||||||
|
glRasterPos2f(x+pad*2 +tlen+10, y+5)
|
||||||
|
if type_p == Types.IDArrayType:
|
||||||
|
Draw.Text('(array, click to edit)')
|
||||||
|
elif type_p == Types.IDGroupType:
|
||||||
|
Draw.Text('(group, click to edit)')
|
||||||
|
|
||||||
|
|
||||||
self.buts.append(None)
|
self.buts.append(None)
|
||||||
|
|
||||||
Draw.PushButton("Del", ButDelStart+i, x+self.width-35, y, 30, 20)
|
Draw.PushButton("Del", ButDelStart+i, x+self.width-35, y, 30, 20)
|
||||||
@ -301,17 +312,15 @@ class IDPropertyBrowser:
|
|||||||
if self._i == 5:
|
if self._i == 5:
|
||||||
Draw.Draw()
|
Draw.Draw()
|
||||||
self._i = 0
|
self._i = 0
|
||||||
|
|
||||||
plist = []
|
|
||||||
for p in self.group.iteritems():
|
|
||||||
plist.append(p)
|
|
||||||
|
|
||||||
if evt == Draw.LEFTMOUSE and val == 1:
|
if evt == Draw.LEFTMOUSE and val == 1:
|
||||||
|
plist = list(self.group.iteritems())
|
||||||
a = self.active_item
|
a = self.active_item
|
||||||
if a >= 0 and a < len(plist):
|
if a >= 0 and a < len(plist):
|
||||||
p = plist[a]
|
p = plist[a]
|
||||||
|
|
||||||
basictypes = [IDGroupType, type(0.0), type(""), type(0)]
|
basictypes = [IDGroupType, float, str, int]
|
||||||
if type(p[1]) == IDGroupType:
|
if type(p[1]) == IDGroupType:
|
||||||
self.parents.append(self.group)
|
self.parents.append(self.group)
|
||||||
self.group = p[1]
|
self.group = p[1]
|
||||||
@ -375,24 +384,20 @@ class IDPropertyBrowser:
|
|||||||
Draw.Draw()
|
Draw.Draw()
|
||||||
|
|
||||||
if bval >= ButDelStart:
|
if bval >= ButDelStart:
|
||||||
plist = []
|
plist = [p for p in self.group]
|
||||||
for p in self.group:
|
|
||||||
plist.append(p)
|
|
||||||
prop = plist[bval - ButDelStart]
|
prop = plist[bval - ButDelStart]
|
||||||
del self.group[prop]
|
del self.group[prop]
|
||||||
Draw.Draw()
|
Draw.Draw()
|
||||||
|
|
||||||
elif bval >= ButStart:
|
elif bval >= ButStart:
|
||||||
plist = []
|
plist = list(self.group.iteritems())
|
||||||
for p in self.group.iteritems():
|
|
||||||
plist.append(p)
|
|
||||||
|
|
||||||
prop = plist[bval - ButStart]
|
prop = plist[bval - ButStart]
|
||||||
print prop
|
print prop
|
||||||
|
|
||||||
if self.type(prop[1]) == self.type(""):
|
if self.type(prop[1]) == str:
|
||||||
self.group[prop[0]] = self.buts[bval - ButStart].val
|
self.group[prop[0]] = self.buts[bval - ButStart].val
|
||||||
elif self.type(prop[1]) == self.type(0):
|
elif self.type(prop[1]) == int:
|
||||||
i = self.buts[bval - ButStart].val
|
i = self.buts[bval - ButStart].val
|
||||||
try:
|
try:
|
||||||
i = int(i)
|
i = int(i)
|
||||||
@ -401,7 +406,7 @@ class IDPropertyBrowser:
|
|||||||
Draw.Draw()
|
Draw.Draw()
|
||||||
return
|
return
|
||||||
Draw.Draw()
|
Draw.Draw()
|
||||||
elif self.type(prop[1]) == self.type(0.0):
|
elif self.type(prop[1]) == float:
|
||||||
f = self.buts[bval - ButStart].val
|
f = self.buts[bval - ButStart].val
|
||||||
try:
|
try:
|
||||||
f = float(f)
|
f = float(f)
|
||||||
@ -460,7 +465,7 @@ class IDPropertyBrowser:
|
|||||||
elif itype.val:
|
elif itype.val:
|
||||||
self.group[name] = 0 #newProperty("Int", name, 0)
|
self.group[name] = 0 #newProperty("Int", name, 0)
|
||||||
elif atype.val:
|
elif atype.val:
|
||||||
arrfloat = Draw.Create(0)
|
arrfloat = Draw.Create(1)
|
||||||
arrint = Draw.Create(0)
|
arrint = Draw.Create(0)
|
||||||
arrlen = Draw.Create(3)
|
arrlen = Draw.Create(3)
|
||||||
block = []
|
block = []
|
||||||
@ -468,16 +473,16 @@ class IDPropertyBrowser:
|
|||||||
block.append(("Float", arrfloat, "Make a float array"))
|
block.append(("Float", arrfloat, "Make a float array"))
|
||||||
block.append(("Int", arrint, "Make an integer array"))
|
block.append(("Int", arrint, "Make an integer array"))
|
||||||
block.append(("Len", arrlen, 2, 200))
|
block.append(("Len", arrlen, 2, 200))
|
||||||
retval = Blender.Draw.PupBlock("Array Properties", block)
|
|
||||||
|
|
||||||
if retval:
|
if Blender.Draw.PupBlock("Array Properties", block):
|
||||||
tmpl = "Float"
|
|
||||||
if arrfloat.val:
|
if arrfloat.val:
|
||||||
tmpl = 0.0
|
tmpl = 0.0
|
||||||
elif arrint.val:
|
elif arrint.val:
|
||||||
tmpl = 0
|
tmpl = 0
|
||||||
arr = [tmpl for x in xrange(arrlen.val)]
|
else:
|
||||||
self.group[name] = arr
|
return
|
||||||
|
|
||||||
|
self.group[name] = [tmpl] * arrlen.val
|
||||||
|
|
||||||
|
|
||||||
def Go(self):
|
def Go(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user