- aspectx wasnt saved in the render preset
- define a preset base class - cleanup some comments and whitespace
This commit is contained in:
@@ -32,12 +32,12 @@ def rna_idprop_ui_get(item, create=True):
|
||||
|
||||
|
||||
def rna_idprop_ui_prop_get(item, prop, create=True):
|
||||
|
||||
|
||||
rna_ui = rna_idprop_ui_get(item, create)
|
||||
|
||||
|
||||
if rna_ui == None:
|
||||
return None
|
||||
|
||||
|
||||
try:
|
||||
return rna_ui[prop]
|
||||
except:
|
||||
@@ -47,7 +47,7 @@ def rna_idprop_ui_prop_get(item, prop, create=True):
|
||||
|
||||
def rna_idprop_ui_prop_clear(item, prop):
|
||||
rna_ui = rna_idprop_ui_get(item, False)
|
||||
|
||||
|
||||
if rna_ui == None:
|
||||
return
|
||||
|
||||
@@ -58,21 +58,21 @@ def rna_idprop_ui_prop_clear(item, prop):
|
||||
|
||||
|
||||
def draw(layout, context, context_member, use_edit = True):
|
||||
|
||||
|
||||
def assign_props(prop, val, key):
|
||||
prop.path = context_member
|
||||
prop.property = key
|
||||
|
||||
|
||||
try:
|
||||
prop.value = str(val)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
rna_item = eval("context." + context_member)
|
||||
|
||||
items = rna_item.items()
|
||||
items.sort()
|
||||
|
||||
|
||||
if use_edit:
|
||||
row = layout.row()
|
||||
props = row.itemO("wm.properties_add", properties=True, text="Add")
|
||||
@@ -83,10 +83,10 @@ def draw(layout, context, context_member, use_edit = True):
|
||||
|
||||
if key == '_RNA_UI':
|
||||
continue
|
||||
|
||||
|
||||
row = layout.row()
|
||||
convert_to_pyobject = getattr(val, "convert_to_pyobject", None)
|
||||
|
||||
|
||||
val_orig = val
|
||||
if convert_to_pyobject:
|
||||
val_draw = val = val.convert_to_pyobject()
|
||||
@@ -101,23 +101,23 @@ def draw(layout, context, context_member, use_edit = True):
|
||||
row = split.row()
|
||||
else:
|
||||
row = box.row()
|
||||
|
||||
|
||||
row.itemL(text=key)
|
||||
|
||||
|
||||
# explicit exception for arrays
|
||||
if convert_to_pyobject and not hasattr(val_orig, "len"):
|
||||
row.itemL(text=val_draw)
|
||||
else:
|
||||
row.itemR(rna_item, '["%s"]' % key, text="")
|
||||
|
||||
|
||||
if use_edit:
|
||||
row = split.row(align=True)
|
||||
prop = row.itemO("wm.properties_edit", properties=True, text="edit")
|
||||
assign_props(prop, val_draw, key)
|
||||
|
||||
|
||||
prop = row.itemO("wm.properties_remove", properties=True, text="", icon='ICON_ZOOMOUT')
|
||||
assign_props(prop, val_draw, key)
|
||||
|
||||
|
||||
|
||||
from bpy.props import *
|
||||
|
||||
@@ -138,14 +138,14 @@ class WM_OT_properties_edit(bpy.types.Operator):
|
||||
'''Internal use (edit a property path)'''
|
||||
bl_idname = "wm.properties_edit"
|
||||
bl_label = "Edit Property!"
|
||||
|
||||
|
||||
path = rna_path
|
||||
property = rna_property
|
||||
value = rna_value
|
||||
min = rna_min
|
||||
max = rna_max
|
||||
description = StringProperty(name="Tip", default="")
|
||||
|
||||
|
||||
# the class instance is not persistant, need to store in the class
|
||||
# not ideal but changes as the op runs.
|
||||
_last_prop = ['']
|
||||
@@ -160,72 +160,72 @@ class WM_OT_properties_edit(bpy.types.Operator):
|
||||
value_eval = eval(value)
|
||||
except:
|
||||
value_eval = value
|
||||
|
||||
|
||||
if type(value_eval) == str:
|
||||
value_eval = '"' + value_eval + '"'
|
||||
|
||||
value_eval = '"' + value_eval + '"'
|
||||
|
||||
# First remove
|
||||
item = eval("context.%s" % path)
|
||||
|
||||
|
||||
rna_idprop_ui_prop_clear(item, prop_old)
|
||||
exec_str = "del item['%s']" % prop_old
|
||||
# print(exec_str)
|
||||
exec(exec_str)
|
||||
|
||||
|
||||
|
||||
|
||||
# Reassign
|
||||
exec_str = "item['%s'] = %s" % (prop, value_eval)
|
||||
# print(exec_str)
|
||||
exec(exec_str)
|
||||
|
||||
|
||||
prop_type = type(item[prop])
|
||||
|
||||
|
||||
prop_ui = rna_idprop_ui_prop_get(item, prop)
|
||||
|
||||
if prop_type in (float, int):
|
||||
|
||||
|
||||
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min)
|
||||
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max)
|
||||
|
||||
|
||||
prop_ui['description'] = self.properties.description
|
||||
|
||||
|
||||
return ('FINISHED',)
|
||||
|
||||
def invoke(self, context, event):
|
||||
|
||||
|
||||
self._last_prop[:] = [self.properties.property]
|
||||
|
||||
|
||||
item = eval("context.%s" % self.properties.path)
|
||||
|
||||
|
||||
# setup defaults
|
||||
prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create
|
||||
if prop_ui:
|
||||
self.properties.min = prop_ui.get("min", -1000000000)
|
||||
self.properties.max = prop_ui.get("max", 1000000000)
|
||||
self.properties.description = prop_ui.get("description", "")
|
||||
|
||||
|
||||
if 0:
|
||||
_message= "PyConsole, press Ctrl+D to unlock the BGE"
|
||||
import sys
|
||||
|
||||
# evaluate commands in current namespace
|
||||
frame= sys._getframe()
|
||||
namespace = frame.f_globals.copy()
|
||||
namespace.update(frame.f_locals)
|
||||
|
||||
import code
|
||||
_message= "PyConsole, press Ctrl+D to unlock the BGE"
|
||||
import sys
|
||||
|
||||
# evaluate commands in current namespace
|
||||
frame= sys._getframe()
|
||||
namespace = frame.f_globals.copy()
|
||||
namespace.update(frame.f_locals)
|
||||
|
||||
import code
|
||||
|
||||
# Autocomp in python, not as comprehensive as IPython
|
||||
import rlcompleter
|
||||
|
||||
|
||||
try: # ick, some pythons dont have this
|
||||
import readline
|
||||
readline.parse_and_bind("tab: complete")
|
||||
readline.parse_and_bind("tab: complete")
|
||||
except:
|
||||
pass
|
||||
|
||||
code.interact(banner=_message, local=namespace)
|
||||
|
||||
|
||||
wm = context.manager
|
||||
wm.invoke_props_popup(self, event)
|
||||
return ('RUNNING_MODAL',)
|
||||
@@ -240,7 +240,7 @@ class WM_OT_properties_add(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
item = eval("context.%s" % self.properties.path)
|
||||
|
||||
|
||||
def unique_name(names):
|
||||
prop = 'prop'
|
||||
prop_new = prop
|
||||
@@ -248,14 +248,14 @@ class WM_OT_properties_add(bpy.types.Operator):
|
||||
while prop_new in names:
|
||||
prop_new = prop + str(i)
|
||||
i+=1
|
||||
|
||||
|
||||
return prop_new
|
||||
|
||||
|
||||
property = unique_name(item.keys())
|
||||
|
||||
|
||||
item[property] = 1.0
|
||||
return ('FINISHED',)
|
||||
|
||||
|
||||
class WM_OT_properties_remove(bpy.types.Operator):
|
||||
'''Internal use (edit a property path)'''
|
||||
bl_idname = "wm.properties_remove"
|
||||
@@ -267,5 +267,5 @@ class WM_OT_properties_remove(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
item = eval("context.%s" % self.properties.path)
|
||||
del item[self.properties.property]
|
||||
return ('FINISHED',)
|
||||
return ('FINISHED',)
|
||||
|
||||
|
Reference in New Issue
Block a user