[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4154] contrib/py/scripts/addons/ space_view3d_quickPrefs.py: Code refactor, update for API changes in registration & template lists

Sean Olson seanolson at gmail.com
Wed Jan 9 02:38:38 CET 2013


Revision: 4154
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4154
Author:   liquidape
Date:     2013-01-09 01:38:37 +0000 (Wed, 09 Jan 2013)
Log Message:
-----------
Code refactor, update for API changes in registration & template lists

Modified Paths:
--------------
    contrib/py/scripts/addons/space_view3d_quickPrefs.py

Modified: contrib/py/scripts/addons/space_view3d_quickPrefs.py
===================================================================
--- contrib/py/scripts/addons/space_view3d_quickPrefs.py	2013-01-08 06:38:02 UTC (rev 4153)
+++ contrib/py/scripts/addons/space_view3d_quickPrefs.py	2013-01-09 01:38:37 UTC (rev 4154)
@@ -19,8 +19,8 @@
 bl_info = {
     "name": "QuickPrefs",
     "author": "Sean Olson",
-    "version": (2,1),
-    "blender": (2, 64, 0),
+    "version": (2,2),
+    "blender": (2, 66, 0),
     "location": "3DView->Properties Panel (N-Key)",
     "description": "Add often changed User Preference options to Properties panel.",
     "warning": "",
@@ -36,7 +36,17 @@
 from bpy.types import Menu, Panel
 from rna_prop_ui import PropertyPanel
 from bpy.app.handlers import persistent
+from bpy.props import (
+                       BoolProperty,
+                       EnumProperty,
+                       FloatProperty,
+                       CollectionProperty, 
+                       IntProperty,
+                       StringProperty, 
+                       PointerProperty
+                       )
 
+
 import bpy_extras
 
 #Global Variables
@@ -55,20 +65,20 @@
 #import all grabs all files in the given directory and imports them
 @persistent
 def gllightpreset_importall():
-    path = bpy.context.scene.gllightpreset_importdirectory
+    path = bpy.context.scene.quickprefs.gllightpreset_importdirectory
     directorylisting = os.listdir(path)
 
     for infile in directorylisting:
-        if not os.path.isdir(infile):           #check if the file is a directory
-            if '.preset' in infile:                     #check that this is a .preset file
-                thefile=os.path.join(path, infile)      #join the filename with the path
+        if not os.path.isdir(infile):                       #check if the file is a directory
+            if '.preset' in infile:                           #check that this is a .preset file
+                thefile=os.path.join(path, infile)       #join the filename with the path
                 gllightpreset_importsingle(thefile)     #import it!
        
 #import single takes a given filename and imports it
 def gllightpreset_importsingle(filename):
     
     if not os.path.isdir(filename):           #check if the file is a directory
-        if '.preset' in filename:               #check to make sure this is a preset file
+        if '.preset' in filename:              #check to make sure this is a preset file
             readfile=open(filename, 'r')
             
             name=readfile.readline()
@@ -175,12 +185,12 @@
 #Export all exports the entire contents of your presets list to the given file    
 @persistent     
 def gllightpreset_exportall(context):
-   for i in range(len(bpy.context.scene.gllightpreset)):
+   for i in range(len(bpy.context.scene.quickprefs.gllightpreset)):
         gllightpreset_exportsingle(i, True)
              
     
 def gllightpreset_exportsingle(index, multiimport):
-    scn=bpy.context.scene
+    scn=bpy.context.scene.quickprefs
     name=scn.gllightpreset[index].name
     
     illuminatedBool0=scn.gllightpreset[index].illuminated0
@@ -279,7 +289,7 @@
 ##########################################
 
 def gllightpreset_addPresets():
-    print('in addPresets')
+  
     system=bpy.context.user_preferences.system
   
     system.solid_lights[0].use=True
@@ -443,7 +453,7 @@
     system.solid_lights[2].specular_color = (0.0, 0.0, 0.0)
     gllightpreset_add("Yellow Clay")
     gllightpreset_save()
-    print('exit addpresets')
+    
 ##########################################
 ####### LightPreset Functions #######
 ##########################################
@@ -465,7 +475,7 @@
     recursive=False
     
 def gllightpreset_checkname(name):
-    collection=bpy.context.scene.gllightpreset
+    collection=bpy.context.scene.quickprefs.gllightpreset
     if name=="": name="Preset"
 
     if not name in collection:
@@ -484,7 +494,7 @@
     return "Preset.???"
     
 def gllightpreset_rename(old, new):
-    for o in bpy.context.scene.objects:
+    for o in bpy.context.scene.quickprefs.objects:
         if o.get("gllightpreset", "Default")==old:
             o.gllightpreset=new
 
@@ -494,78 +504,82 @@
     if recursive==True: return
     recursive=True
 
-    scene=bpy.context.scene
-    if scene.gllightpreset_index > len(scene.gllightpreset)-1:
-        scene.gllightpreset_index = len(scene.gllightpreset)-1
+    scn=bpy.context.scene.quickprefs
+    
+    if scn.gllightpreset_index > len(scn.gllightpreset)-1:
+        scn.gllightpreset_index = len(scn.gllightpreset)-1
 
     recursive=False
 
 def gllightpreset_add(name=""):
     global renaming
     renaming=False
+    
+    scn=bpy.context.scene.quickprefs
 
-    entry=bpy.context.scene.gllightpreset.add()
-    bpy.context.scene['gllightpreset_index']=len(bpy.context.scene.gllightpreset)-1
+    entry=scn.gllightpreset.add()
+    bpy.context.scene.quickprefs['gllightpreset_index']=len(scn.gllightpreset)-1
     entry.name=gllightpreset_checkname(name)
     
     renaming=True
     gllightpreset_save()
        
 def gllightpreset_delete():
-    index=bpy.context.scene.gllightpreset_index
-    name=bpy.context.scene.gllightpreset[index].name
+    scn=bpy.context.scene
+    index=scn.quickprefs.gllightpreset_index
+    name=scn.quickprefs.gllightpreset[index].name
     
-    for o in bpy.context.scene.objects:
+    for o in scn.objects:
         if o.get("gllightpreset", "Default")==name:
             o.gllightpreset="Default"
     
-    bpy.context.scene.gllightpreset.remove(index)
+    scn.quickprefs.gllightpreset.remove(index)
    
     
 def gllightpreset_save():
-    index=bpy.context.scene.gllightpreset_index
-    name=bpy.context.scene.gllightpreset[index].name
+    index=bpy.context.scene.quickprefs.gllightpreset_index
+    name=bpy.context.scene.quickprefs.gllightpreset[index].name
     
-    bpy.context.scene.gllightpreset[index].illuminated0 = bpy.context.user_preferences.system.solid_lights[0].use
-    bpy.context.scene.gllightpreset[index].illuminated1 = bpy.context.user_preferences.system.solid_lights[1].use
-    bpy.context.scene.gllightpreset[index].illuminated2 = bpy.context.user_preferences.system.solid_lights[2].use
+    bpy.context.scene.quickprefs.gllightpreset[index].illuminated0 = bpy.context.user_preferences.system.solid_lights[0].use
+    bpy.context.scene.quickprefs.gllightpreset[index].illuminated1 = bpy.context.user_preferences.system.solid_lights[1].use
+    bpy.context.scene.quickprefs.gllightpreset[index].illuminated2 = bpy.context.user_preferences.system.solid_lights[2].use
     
-    bpy.context.scene.gllightpreset[index].direction0 = bpy.context.user_preferences.system.solid_lights[0].direction
-    bpy.context.scene.gllightpreset[index].direction1 = bpy.context.user_preferences.system.solid_lights[1].direction
-    bpy.context.scene.gllightpreset[index].direction2 = bpy.context.user_preferences.system.solid_lights[2].direction
+    bpy.context.scene.quickprefs.gllightpreset[index].direction0 = bpy.context.user_preferences.system.solid_lights[0].direction
+    bpy.context.scene.quickprefs.gllightpreset[index].direction1 = bpy.context.user_preferences.system.solid_lights[1].direction
+    bpy.context.scene.quickprefs.gllightpreset[index].direction2 = bpy.context.user_preferences.system.solid_lights[2].direction
     
-    bpy.context.scene.gllightpreset[index].diffuse0 = bpy.context.user_preferences.system.solid_lights[0].diffuse_color
-    bpy.context.scene.gllightpreset[index].diffuse1 = bpy.context.user_preferences.system.solid_lights[1].diffuse_color
-    bpy.context.scene.gllightpreset[index].diffuse2 = bpy.context.user_preferences.system.solid_lights[2].diffuse_color
+    bpy.context.scene.quickprefs.gllightpreset[index].diffuse0 = bpy.context.user_preferences.system.solid_lights[0].diffuse_color
+    bpy.context.scene.quickprefs.gllightpreset[index].diffuse1 = bpy.context.user_preferences.system.solid_lights[1].diffuse_color
+    bpy.context.scene.quickprefs.gllightpreset[index].diffuse2 = bpy.context.user_preferences.system.solid_lights[2].diffuse_color
     
-    bpy.context.scene.gllightpreset[index].specular0 = bpy.context.user_preferences.system.solid_lights[0].specular_color
-    bpy.context.scene.gllightpreset[index].specular1 = bpy.context.user_preferences.system.solid_lights[1].specular_color
-    bpy.context.scene.gllightpreset[index].specular2 = bpy.context.user_preferences.system.solid_lights[2].specular_color
+    bpy.context.scene.quickprefs.gllightpreset[index].specular0 = bpy.context.user_preferences.system.solid_lights[0].specular_color
+    bpy.context.scene.quickprefs.gllightpreset[index].specular1 = bpy.context.user_preferences.system.solid_lights[1].specular_color
+    bpy.context.scene.quickprefs.gllightpreset[index].specular2 = bpy.context.user_preferences.system.solid_lights[2].specular_color
         
 #select the current light    
 def gllightpreset_select():
-    index=bpy.context.scene.gllightpreset_index
-    name=bpy.context.scene.gllightpreset[index].name
+    index=bpy.context.scene.quickprefs.gllightpreset_index
+    name=bpy.context.scene.quickprefs.gllightpreset[index].name
     
-    bpy.context.user_preferences.system.solid_lights[0].use=bpy.context.scene.gllightpreset[index].illuminated0
-    bpy.context.user_preferences.system.solid_lights[1].use=bpy.context.scene.gllightpreset[index].illuminated1
-    bpy.context.user_preferences.system.solid_lights[2].use=bpy.context.scene.gllightpreset[index].illuminated2
+    bpy.context.user_preferences.system.solid_lights[0].use=bpy.context.scene.quickprefs.gllightpreset[index].illuminated0
+    bpy.context.user_preferences.system.solid_lights[1].use=bpy.context.scene.quickprefs.gllightpreset[index].illuminated1
+    bpy.context.user_preferences.system.solid_lights[2].use=bpy.context.scene.quickprefs.gllightpreset[index].illuminated2
     
-    bpy.context.user_preferences.system.solid_lights[0].direction=bpy.context.scene.gllightpreset[index].direction0
-    bpy.context.user_preferences.system.solid_lights[1].direction=bpy.context.scene.gllightpreset[index].direction1
-    bpy.context.user_preferences.system.solid_lights[2].direction=bpy.context.scene.gllightpreset[index].direction2

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list