From: <au...@us...> - 2011-06-06 00:23:44
|
Revision: 8855 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8855&view=rev Author: auria Date: 2011-06-06 00:23:38 +0000 (Mon, 06 Jun 2011) Log Message: ----------- Made texture preview more robust Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-06 00:09:38 UTC (rev 8854) +++ media/trunk/blender_25/stk_panel.py 2011-06-06 00:23:38 UTC (rev 8855) @@ -719,7 +719,10 @@ context.scene['selected_image'] = self.value global preview_texture - preview_texture.image = bpy.data.images[self.value] + if self.value in bpy.data.images: + preview_texture.image = bpy.data.images[self.value] + else: + preview_texture.image = None if self.value in bpy.data.images: createProperties(bpy.data.images[self.value], STK_MATERIAL_PROPERTIES) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-07 01:48:31
|
Revision: 8858 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8858&view=rev Author: auria Date: 2011-06-07 01:48:25 +0000 (Tue, 07 Jun 2011) Log Message: ----------- Removed unused 'ambient_color' property in panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-07 01:43:04 UTC (rev 8857) +++ media/trunk/blender_25/stk_panel.py 2011-06-07 01:48:25 UTC (rev 8858) @@ -465,7 +465,6 @@ ('sky_type', StkEnumProperty( id='sky_type', name='Sky Type', default='dome', contextLevel=CONTEXT_SCENE, values=SKY_TYPES)), ('arena', StkBoolProperty( id='arena', name='Battle Arena', default="false", contextLevel=CONTEXT_SCENE)), ('fog', StkBoolProperty( id='fog', name='Fog', default='false', contextLevel=CONTEXT_SCENE, subproperties=FOG_PROPERTIES)), - ('ambient_color', StkColorProperty( id='ambient_color', name="Ambient Color", default="255 255 255", contextLevel=CONTEXT_SCENE)), ('camera_far', StkFloatProperty( id='camera_far', name='Camera Far Clip', default=1000.0)), (k[0], StkIntProperty( id=k[0], name=kk[0], default=2)), (k[1], StkFloatProperty( id=k[1], name=kk[1], default=1.1)), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-12 16:06:54
|
Revision: 8887 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8887&view=rev Author: auria Date: 2011-06-12 16:06:47 +0000 (Sun, 12 Jun 2011) Log Message: ----------- Add picker to 'activate' proeprty Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-12 15:30:10 UTC (rev 8886) +++ media/trunk/blender_25/stk_panel.py 2011-06-12 16:06:47 UTC (rev 8887) @@ -61,6 +61,51 @@ self.default = default +class StkObjectReferenceProperty(StkProperty): + + def __init__(self, id, name, contextLevel, default, filter): + super(StkObjectReferenceProperty, self).__init__(id, name, default) + + class SelectObjectOperator(bpy.types.Operator): + bl_idname = "scene.stk_select_object_" + id + bl_label = "Select Object Operator" + + m_id = id + m_context_level = contextLevel + + # name of the object to select + name = bpy.props.StringProperty() + + def execute(self, context): + object = getObject(context, self.m_context_level) + object[self.m_id] = self.name + return {'FINISHED'} + + bpy.utils.register_class(SelectObjectOperator) + + class ObjectPickerMenu(bpy.types.Menu): + m_filter = filter + bl_idname = "screen.stk_object_menu_" + id + bl_label = ("SuperTuxKart Object Picker Menu (" + id + ")") + m_property_id = id + + def draw(self, context): + objects = context.scene.objects + + layout = self.layout + for object in objects: + if self.m_filter(object): + text = object.name + object_id = object.name + if 'name' in object: + text = text + " (" + object["name"] + ")" + object_id = object["name"] + layout.operator("scene.stk_select_object_"+self.m_property_id, text=text).name=object_id + layout.operator("scene.stk_select_object_"+self.m_property_id, text="Lap").name="lap" + + + bpy.utils.register_class(ObjectPickerMenu) + def createProperties(object, props): for p in props.keys(): @@ -370,7 +415,7 @@ 'billboard' : StkEnumChoice('Billboard', {}), 'check' : StkEnumChoice('Checkline', {'name' : StkProperty(id='name', name="Name", default=""), - 'activate' : StkProperty(id='activate', name="Activate", default="") + 'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check') #'toggle' : Stkproperty("Toggle"), #'inner_radius' : StkFloatProperty("Color radius"), #'color' : @@ -617,7 +662,13 @@ if curr_value in curr.values and len(curr.values[curr_value].subproperties) > 0: box = layout.box() self.recursivelyAddProperties(curr.values[curr_value].subproperties, box, obj) - + + elif isinstance(curr, StkObjectReferenceProperty): + + if curr.id in obj: + row.prop(obj, '["' + curr.id + '"]', text="") + row.menu("screen.stk_object_menu_" + curr.id, text="", icon='TRIA_DOWN') + else: # String or int or float property (Blender chooses the correct widget from the type of the ID-property) if curr.id in obj: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-12 16:09:46
|
Revision: 8888 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8888&view=rev Author: auria Date: 2011-06-12 16:09:40 +0000 (Sun, 12 Jun 2011) Log Message: ----------- Add picker to 'activate' proeprty Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-12 16:06:47 UTC (rev 8887) +++ media/trunk/blender_25/stk_panel.py 2011-06-12 16:09:40 UTC (rev 8888) @@ -427,7 +427,8 @@ contextLevel=CONTEXT_OBJECT) }), 'maindriveline' : StkEnumChoice('Driveline (main)', - {'activate' : StkProperty(id='activate', name="Activate", default="") + {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check') + }), 'fixed' : StkEnumChoice('End Camera (Fixed)', camera_properties), 'ahead' : StkEnumChoice('End Camera (Look Ahead)', camera_properties), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-12 16:58:03
|
Revision: 8889 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8889&view=rev Author: auria Date: 2011-06-12 16:57:57 +0000 (Sun, 12 Jun 2011) Log Message: ----------- Remove refresh button in image proeprty panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-12 16:09:40 UTC (rev 8888) +++ media/trunk/blender_25/stk_panel.py 2011-06-12 16:57:57 UTC (rev 8889) @@ -721,9 +721,46 @@ preview_texture.type = 'IMAGE' preview_texture = bpy.data.textures[-1] preview_texture.use_preview_alpha = True +preview_texture = bpy.data.textures[-1] import os +class ImagePickerMenu(bpy.types.Menu): + bl_idname = "scene.stk_image_menu" + bl_label = "SuperTuxKart Image Menu" + + def draw(self, context): + objects = context.scene.objects + + layout = self.layout + for curr in bpy.data.images: + layout.operator("scene.stk_select_image", text=curr.name).name=curr.name + +bpy.utils.register_class(ImagePickerMenu) + +class STK_SelectImage(bpy.types.Operator): + bl_idname = ("scene.stk_select_image") + bl_label = ("STK Object :: select image") + + name = bpy.props.StringProperty() + + def execute(self, context): + global selected_image + context.scene['selected_image'] = self.name + + global preview_texture + if self.name in bpy.data.images: + preview_texture.image = bpy.data.images[self.name] + else: + preview_texture.image = None + + if self.name in bpy.data.images: + createProperties(bpy.data.images[self.name], STK_MATERIAL_PROPERTIES) + + return {'FINISHED'} + +bpy.utils.register_class(STK_SelectImage) + class SuperTuxKartImagePanel(bpy.types.Panel, PanelBase): bl_label = "SuperTuxKart Image Properties" bl_space_type = "PROPERTIES" @@ -731,83 +768,21 @@ bl_context = "scene" m_current_image = '' - m_previous_texture_list = [] - m_list = [ ("None", "None", "None") ] - - def __init__(self): - - the_list = self.m_list - - class STK_RefreshImageList(bpy.types.Operator): - - bl_idname = ("screen.stk_refresh_image_list") - bl_label = ("STK refresh image list") - - global preview_texture - self.layout.template_preview(preview_texture, show_buttons=True) - - def execute(self, context): - the_list = [ ("None", "None", "None") ] - for curr in bpy.data.images: - filename = os.path.basename(curr.filepath) - the_list.append( (curr.name, filename, filename) ) - print("Refreshed list :",the_list) - - global selected_image - global preview_texture - if 'selected_image' not in context.scene['selected_image'] and len(bpy.data.images) > 0: - preview_texture.image = bpy.data.images[0] - context.scene['selected_image'] = preview_texture.image.name - createProperties(preview_texture.image, STK_MATERIAL_PROPERTIES) - - context.region.tag_redraw() - - class STK_SelectImage(bpy.types.Operator): - bl_idname = ("screen.stk_select_image") - bl_label = ("STK Object :: select image") - - # FIXME: this value needs to be updatable, not static - value = bpy.props.EnumProperty(attr="values", name="values", default="None", - items=the_list) - - def execute(self, context): - - #obj = context.object - #obj["type"] = "" - global selected_image - context.scene['selected_image'] = self.value - - global preview_texture - if self.value in bpy.data.images: - preview_texture.image = bpy.data.images[self.value] - else: - preview_texture.image = None - - if self.value in bpy.data.images: - createProperties(bpy.data.images[self.value], STK_MATERIAL_PROPERTIES) - - context.region.tag_redraw() - - return {'FINISHED'} - - bpy.utils.register_class(STK_SelectImage) - return {'FINISHED'} - - bpy.utils.register_class(STK_RefreshImageList) - - def draw(self, context): layout = self.layout row = layout.row() - label = "Select Image" + global preview_texture + layout.template_preview(preview_texture, show_buttons=True) + + label = "Select an image" if 'selected_image' in context.scene: label = context.scene['selected_image'] - self.m_op_name = "screen.stk_select_image" - row.operator_menu_enum(self.m_op_name, property="value", text=label) - row.operator("screen.stk_refresh_image_list", text="Refresh", icon="FILE_REFRESH") + self.m_op_name = "scene.stk_image_menu" + row.label(label) + row.menu(self.m_op_name, text="", icon="TRIA_DOWN") obj = getObject(context, CONTEXT_MATERIAL) if obj is not None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-12 17:58:54
|
Revision: 8896 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8896&view=rev Author: auria Date: 2011-06-12 17:58:47 +0000 (Sun, 12 Jun 2011) Log Message: ----------- reorder checkloine properties in panel, to have name on top Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-12 17:55:11 UTC (rev 8895) +++ media/trunk/blender_25/stk_panel.py 2011-06-12 17:58:47 UTC (rev 8896) @@ -413,13 +413,13 @@ {'' : StkEnumChoice('None', {}), 'banana' : StkEnumChoice('Banana', {}), 'billboard' : StkEnumChoice('Billboard', {}), - 'check' : StkEnumChoice('Checkline', - {'name' : StkProperty(id='name', name="Name", default=""), - 'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check') + 'check' : StkEnumChoice('Checkline', OrderedDict([ + ('name' , StkProperty(id='name', name="Name", default="")), + ('activate', StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check')) #'toggle' : Stkproperty("Toggle"), #'inner_radius' : StkFloatProperty("Color radius"), #'color' : - }), + ])), 'driveline' : StkEnumChoice('Driveline (additional)', {'invisible' : StkBoolProperty(id='invisible', name="Invisible", default="false", contextLevel=CONTEXT_OBJECT), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-12 18:13:17
|
Revision: 8897 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8897&view=rev Author: auria Date: 2011-06-12 18:13:11 +0000 (Sun, 12 Jun 2011) Log Message: ----------- Make image preview in panel more robust Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-12 17:58:47 UTC (rev 8896) +++ media/trunk/blender_25/stk_panel.py 2011-06-12 18:13:11 UTC (rev 8897) @@ -713,15 +713,18 @@ # ==== IMAGE PANEL ==== +def createPreviewTexture(): + global preview_texture + bpy.ops.texture.new() + preview_texture = bpy.data.textures[-1] + preview_texture.name = "STKPreviewTexture" + preview_texture = bpy.data.textures["STKPreviewTexture"] + preview_texture.type = 'IMAGE' + preview_texture = bpy.data.textures["STKPreviewTexture"] + preview_texture.use_preview_alpha = True + preview_texture = bpy.data.textures["STKPreviewTexture"] -bpy.ops.texture.new() -preview_texture = bpy.data.textures[-1] -preview_texture.name = "STKPreviewTexture" -preview_texture = bpy.data.textures[-1] -preview_texture.type = 'IMAGE' -preview_texture = bpy.data.textures[-1] -preview_texture.use_preview_alpha = True -preview_texture = bpy.data.textures[-1] +createPreviewTexture() import os @@ -773,9 +776,14 @@ layout = self.layout row = layout.row() - global preview_texture - layout.template_preview(preview_texture, show_buttons=True) + #global preview_texture + #layout.template_preview(preview_texture, show_buttons=True) + if "STKPreviewTexture" in bpy.data.textures: + layout.template_preview(bpy.data.textures["STKPreviewTexture"]) + else: + layout.label("Sorry, no image preview available") + label = "Select an image" if 'selected_image' in context.scene: label = context.scene['selected_image'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-18 15:54:28
|
Revision: 8951 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8951&view=rev Author: auria Date: 2011-06-18 15:54:21 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Add a couple missing properties to the panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-18 15:43:54 UTC (rev 8950) +++ media/trunk/blender_25/stk_panel.py 2011-06-18 15:54:21 UTC (rev 8951) @@ -482,7 +482,10 @@ ('sky_texture' , StkProperty(id='sky_texture', name='Sky Texture', default="")), ('sky_horizontal' , StkIntProperty(id='sky_horizontal', name='Horizontal Definition', default=20)), ('sky_vertical' , StkIntProperty(id='sky_vertical', name='Vertical Definition', default=20)), - ('sky_texture_percent', StkFloatProperty(id='sky_texture_percent', name='Sky Texture Percent', default=1.0))])), + ('sky_texture_percent', StkFloatProperty(id='sky_texture_percent', name='Sky Texture Percent', default=1.0)), + ('sky_sphere_percent' , StkFloatProperty(id='sky_sphere_percent', name='Sky Sphere Percent', default=1.3)), + ('sky_speed_x' , StkFloatProperty(id='sky_speed_x', name='Sky Speed X', default=0.0)), + ('sky_speed_y' , StkFloatProperty(id='sky_speed_y', name='Sky Speed Y', default=0.0))])), 'simple' : StkEnumChoice('Plain color', {'sky_color' : StkColorProperty(id="sky_color", name="Sky Color", default="77 104 255", contextLevel=CONTEXT_SCENE)}) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-18 16:39:23
|
Revision: 8952 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8952&view=rev Author: auria Date: 2011-06-18 16:39:17 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Simplify panel code (remove duplicated function) Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-18 15:54:21 UTC (rev 8951) +++ media/trunk/blender_25/stk_panel.py 2011-06-18 16:39:17 UTC (rev 8952) @@ -12,6 +12,8 @@ "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/", "category": "Object"} +# TODO: verify properties have the right type : isinstance(bpy.data.scenes[0]['sky_speed_x'], float) + import bpy from collections import OrderedDict import getpass @@ -264,18 +266,6 @@ m_property_id = id m_super_self = super_self - def createProperties(self, object, props): - for p in props.keys(): - - if not p in object: - # create property by setting default value - v = props[p].default - object[p] = v - - if isinstance(props[p], StkEnumProperty): - if v in props[p].values: - self.createProperties(object, props[p].values[v].subproperties) - def execute(self, context): # Set the property @@ -298,7 +288,7 @@ # If sub-properties are needed, create them if object[self.m_property_id] == "true": - self.createProperties(object, self.m_super_self.subproperties) + createProperties(object, self.m_super_self.subproperties) return {'FINISHED'} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-18 16:46:06
|
Revision: 8953 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8953&view=rev Author: auria Date: 2011-06-18 16:45:59 +0000 (Sat, 18 Jun 2011) Log Message: ----------- Add some type checking to properties in the panel; especially useful when converting from 2.4 to 2.5 since we used to use string properties everywhere, but now we use int or float properties Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-18 16:39:17 UTC (rev 8952) +++ media/trunk/blender_25/stk_panel.py 2011-06-18 16:45:59 UTC (rev 8953) @@ -12,8 +12,6 @@ "tracker_url": "https://sourceforge.net/apps/trac/supertuxkart/", "category": "Object"} -# TODO: verify properties have the right type : isinstance(bpy.data.scenes[0]['sky_speed_x'], float) - import bpy from collections import OrderedDict import getpass @@ -120,6 +118,29 @@ if isinstance(props[p], StkEnumProperty): if v in props[p].values: createProperties(object, props[p].values[v].subproperties) + + # check the property has the right type + elif isinstance(props[p], StkFloatProperty) : + + if not isinstance(object[p], float): + try: + object[p] = float(object[p]) + except: + object[p] = props[p].default + + elif isinstance(props[p], StkIntProperty): + + if not isinstance(object[p], int): + try: + object[p] = int(object[p]) + except: + object[p] = props[p].default + + elif isinstance(props[p], StkProperty) and not isinstance(object[p], str): + try: + object[p] = str(object[p]) + except: + object[p] = props[p].default #! An enum property class StkEnumProperty(StkProperty): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-19 17:32:33
|
Revision: 8960 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8960&view=rev Author: auria Date: 2011-06-19 17:32:27 +0000 (Sun, 19 Jun 2011) Log Message: ----------- Name skybox textures in panel: Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-19 17:31:16 UTC (rev 8959) +++ media/trunk/blender_25/stk_panel.py 2011-06-19 17:32:27 UTC (rev 8960) @@ -483,12 +483,12 @@ SKY_TYPES = { 'none' : StkEnumChoice('None', {}), 'box' : StkEnumChoice('Box', OrderedDict([ - ('sky_texture1' , StkProperty(id='sky_texture1', name='Sky Texture 1', default="")), - ('sky_texture2' , StkProperty(id='sky_texture2', name='Sky Texture 2', default="")), - ('sky_texture3' , StkProperty(id='sky_texture3', name='Sky Texture 3', default="")), - ('sky_texture4' , StkProperty(id='sky_texture4', name='Sky Texture 4', default="")), - ('sky_texture5' , StkProperty(id='sky_texture5', name='Sky Texture 5', default="")), - ('sky_texture6' , StkProperty(id='sky_texture6', name='Sky Texture 6', default=""))])), + ('sky_texture2' , StkProperty(id='sky_texture2', name='Sky Texture Top', default="")), + ('sky_texture3' , StkProperty(id='sky_texture3', name='Sky Texture Bottom', default="")), + ('sky_texture4' , StkProperty(id='sky_texture4', name='Sky Texture East', default="")), + ('sky_texture5' , StkProperty(id='sky_texture5', name='Sky Texture West', default="")), + ('sky_texture1' , StkProperty(id='sky_texture1', name='Sky Texture North', default="")), + ('sky_texture6' , StkProperty(id='sky_texture6', name='Sky Texture South', default=""))])), 'dome' : StkEnumChoice('Dome', OrderedDict([ ('sky_texture' , StkProperty(id='sky_texture', name='Sky Texture', default="")), ('sky_horizontal' , StkIntProperty(id='sky_horizontal', name='Horizontal Definition', default=20)), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-19 21:56:23
|
Revision: 8980 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8980&view=rev Author: auria Date: 2011-06-19 21:56:16 +0000 (Sun, 19 Jun 2011) Log Message: ----------- Improve texture preview in panel (works much more often now) Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-19 21:11:36 UTC (rev 8979) +++ media/trunk/blender_25/stk_panel.py 2011-06-19 21:56:16 UTC (rev 8980) @@ -729,15 +729,10 @@ # ==== IMAGE PANEL ==== def createPreviewTexture(): - global preview_texture bpy.ops.texture.new() - preview_texture = bpy.data.textures[-1] - preview_texture.name = "STKPreviewTexture" - preview_texture = bpy.data.textures["STKPreviewTexture"] - preview_texture.type = 'IMAGE' - preview_texture = bpy.data.textures["STKPreviewTexture"] - preview_texture.use_preview_alpha = True - preview_texture = bpy.data.textures["STKPreviewTexture"] + bpy.data.textures[-1].name = "STKPreviewTexture" + bpy.data.textures["STKPreviewTexture"].type = 'IMAGE' + bpy.data.textures["STKPreviewTexture"].use_preview_alpha = True createPreviewTexture() @@ -766,11 +761,16 @@ global selected_image context.scene['selected_image'] = self.name - global preview_texture - if self.name in bpy.data.images: - preview_texture.image = bpy.data.images[self.name] + if "STKPreviewTexture" not in bpy.data.textures: + createPreviewTexture() + + if "STKPreviewTexture" in bpy.data.textures: + if self.name in bpy.data.images: + bpy.data.textures["STKPreviewTexture"].image = bpy.data.images[self.name] + else: + bpy.data.textures["STKPreviewTexture"].image = None else: - preview_texture.image = None + print("STK Panel : can't create preview texture!") if self.name in bpy.data.images: createProperties(bpy.data.images[self.name], STK_MATERIAL_PROPERTIES) @@ -791,9 +791,6 @@ layout = self.layout row = layout.row() - #global preview_texture - #layout.template_preview(preview_texture, show_buttons=True) - if "STKPreviewTexture" in bpy.data.textures: layout.template_preview(bpy.data.textures["STKPreviewTexture"]) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-19 23:39:17
|
Revision: 8987 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8987&view=rev Author: auria Date: 2011-06-19 23:39:09 +0000 (Sun, 19 Jun 2011) Log Message: ----------- Split image menu on several columns so it's still usable when there are a lot of textures Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-19 22:47:34 UTC (rev 8986) +++ media/trunk/blender_25/stk_panel.py 2011-06-19 23:39:09 UTC (rev 8987) @@ -746,9 +746,16 @@ objects = context.scene.objects layout = self.layout - for curr in bpy.data.images: - layout.operator("scene.stk_select_image", text=curr.name).name=curr.name + row = layout.row() + col = row.column() + for i,curr in enumerate(bpy.data.images): + + if (i % 20 == 0): + col = row.column() + + col.operator("scene.stk_select_image", text=curr.name).name=curr.name + bpy.utils.register_class(ImagePickerMenu) class STK_SelectImage(bpy.types.Operator): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-06-26 00:14:53
|
Revision: 9074 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9074&view=rev Author: auria Date: 2011-06-26 00:14:47 +0000 (Sun, 26 Jun 2011) Log Message: ----------- Add kart support to panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-06-25 23:53:23 UTC (rev 9073) +++ media/trunk/blender_25/stk_panel.py 2011-06-26 00:14:47 UTC (rev 9074) @@ -145,13 +145,16 @@ #! An enum property class StkEnumProperty(StkProperty): + def getOperatorName(self): + return self.operator_name + #! @param name User-visible name for this property #! @param values A dictionnary of type { 'value' : StkEnumChoice(...) } #! @note The first value will be used by default - def __init__(self, id, name, values, contextLevel, default): + def __init__(self, id, name, values, contextLevel, default, unique_prefix=""): super(StkEnumProperty, self).__init__(id, name, default) self.values = values - + self.operator_name = "screen.stk_set_" + unique_prefix + id default_value = default values_for_blender_unsorted = [] @@ -167,8 +170,8 @@ value = bpy.props.EnumProperty(attr="values", name="values", default=default_value, items=values_for_blender) - bl_idname = ("screen.stk_set_"+id) - bl_label = ("SuperTuxKart set "+id) + bl_idname = ("screen.stk_set_" + unique_prefix + id) + bl_label = ("SuperTuxKart set " + unique_prefix + id) m_property_id = id m_items_val = values_for_blender @@ -187,7 +190,7 @@ # If sub-properties are needed, create them if self.value in self.m_values: createProperties(object, self.m_values[self.value].subproperties) - + return {'FINISHED'} bpy.utils.register_class(STK_SetComboValue) @@ -468,10 +471,10 @@ ('speed' , StkFloatProperty('speed', "Waves Speed", 200.0)), ('length', StkFloatProperty('length', "Waves Length", 10.0)) ])) - }, contextLevel=CONTEXT_OBJECT, default='') + }, contextLevel=CONTEXT_OBJECT, default='', unique_prefix="track_") -STK_PER_OBJECT_PROPERTIES = OrderedDict([ +STK_PER_OBJECT_TRACK_PROPERTIES = OrderedDict([ ('type' , type), ('enable_anim_texture', StkBoolProperty(id='enable_anim_texture', name='Use animated Texture', default="false", contextLevel=CONTEXT_OBJECT, subproperties={'anim_texture' : StkProperty(id='anim_texture', name='Texture to animate', default=""), @@ -480,6 +483,15 @@ })) ]) +STK_PER_OBJECT_KART_PROPERTIES = OrderedDict([ + ('type' , StkEnumProperty('type', "Type", OrderedDict([ ('' , StkEnumChoice('None', {})), + ('wheel' , StkEnumChoice('Wheel', {})), + ('ignore', StkEnumChoice('Ignore', {})) + ]), + contextLevel=CONTEXT_OBJECT, default='', unique_prefix="kart_") + ) + ]) + SKY_TYPES = { 'none' : StkEnumChoice('None', {}), 'box' : StkEnumChoice('Box', OrderedDict([ @@ -673,7 +685,7 @@ if curr_value in curr.values: label = curr.values[curr_value].name - row.operator_menu_enum("screen.stk_set_"+id, property="value", text=label) + row.operator_menu_enum(curr.getOperatorName(), property="value", text=label) if curr_value in curr.values and len(curr.values[curr_value].subproperties) > 0: box = layout.box() @@ -701,14 +713,20 @@ layout = self.layout - if "is_stk_track" not in context.scene or context.scene["is_stk_track"] != "true": - layout.label("(Not a SuperTuxKart track)") - return + is_track = ("is_stk_track" in context.scene and context.scene["is_stk_track"] == "true") + is_kart = ("is_stk_kart" in context.scene and context.scene["is_stk_kart"] == "true") + + if not is_track and not is_kart: + layout.label("(Not a SuperTuxKart scene)") + return obj = context.object if obj is not None: - self.recursivelyAddProperties(STK_PER_OBJECT_PROPERTIES, layout, obj) + if is_track: + self.recursivelyAddProperties(STK_PER_OBJECT_TRACK_PROPERTIES, layout, obj) + if is_kart: + self.recursivelyAddProperties(STK_PER_OBJECT_KART_PROPERTIES, layout, obj) # ==== SCENE PANEL ==== @@ -750,10 +768,10 @@ col = row.column() for i,curr in enumerate(bpy.data.images): - + if (i % 20 == 0): col = row.column() - + col.operator("scene.stk_select_image", text=curr.name).name=curr.name bpy.utils.register_class(ImagePickerMenu) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-07-01 01:57:29
|
Revision: 9121 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9121&view=rev Author: auria Date: 2011-07-01 01:57:22 +0000 (Fri, 01 Jul 2011) Log Message: ----------- Add documentation to the panel through tooltips, with mixed results. Works great with checkboxes and combinable enums; works partially with combos; doesn't work at all for ints/floats/strings Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-07-01 00:47:23 UTC (rev 9120) +++ media/trunk/blender_25/stk_panel.py 2011-07-01 01:57:22 UTC (rev 9121) @@ -49,9 +49,10 @@ #! @param name User-visible name for this property #! @param subproperties A dictionary of type { 'name' : StkProperty(...) }. Contains the # properties that are to be shown when this enum item is selected - def __init__(self, name, subproperties): + def __init__(self, name, subproperties, docs="(No documentation was defined for this item)"): self.name = name self.subproperties = subproperties + self.__doc__ = docs #! The base class for all properties class StkProperty: @@ -63,12 +64,14 @@ class StkObjectReferenceProperty(StkProperty): - def __init__(self, id, name, contextLevel, default, filter): + def __init__(self, id, name, contextLevel, default, filter, docs="Select an object"): super(StkObjectReferenceProperty, self).__init__(id, name, default) + self.docs = docs class SelectObjectOperator(bpy.types.Operator): bl_idname = "scene.stk_select_object_" + id bl_label = "Select Object Operator" + __doc__ = docs m_id = id m_context_level = contextLevel @@ -151,10 +154,11 @@ #! @param name User-visible name for this property #! @param values A dictionnary of type { 'value' : StkEnumChoice(...) } #! @note The first value will be used by default - def __init__(self, id, name, values, contextLevel, default, unique_prefix=""): + def __init__(self, id, name, values, contextLevel, default, unique_prefix="", docs="(No documentation for this item)"): super(StkEnumProperty, self).__init__(id, name, default) self.values = values self.operator_name = "screen.stk_set_" + unique_prefix + id + self.docs = docs default_value = default values_for_blender_unsorted = [] @@ -172,6 +176,7 @@ bl_idname = ("screen.stk_set_" + unique_prefix + id) bl_label = ("SuperTuxKart set " + unique_prefix + id) + __doc__ = docs m_property_id = id m_items_val = values_for_blender @@ -218,6 +223,7 @@ bl_idname = ("screen.stk_set_"+id+"_"+curr) bl_label = ("SuperTuxKart set "+id+" = " + curr) + __doc__ = values[curr].__doc__ + "" m_property_id = id m_items_val = values_for_blender @@ -252,17 +258,19 @@ class StkFloatProperty(StkProperty): #! @param name User-visible name for this property - def __init__(self, id, name, default=0.0): + def __init__(self, id, name, default=0.0, docs="(No documentation defined for this element)"): super(StkFloatProperty, self).__init__(id, name, default) self.default + self.__doc__ = docs #! An integer property class StkIntProperty(StkProperty): #! @param name User-visible name for this property - def __init__(self, id, name, default=0): + def __init__(self, id, name, default=0, docs="(No documentation defined for this element)"): super(StkIntProperty, self).__init__(id, name, default) + self.__doc__ = docs #! A boolean property class StkBoolProperty(StkProperty): @@ -271,20 +279,19 @@ box = True #! A floating-point property - def __init__(self, id, name, contextLevel, default="false", subproperties={}, box = True): + def __init__(self, id, name, contextLevel, default="false", subproperties={}, box = True, docs="(No documentation defined for this element)"): super(StkBoolProperty, self).__init__(id, name, default) self.box = box self.subproperties = subproperties - super_self = self # Create operator for this bool class STK_ToggleBoolValue(bpy.types.Operator): - bl_idname = ("screen.stk_toggle_bool_"+id) bl_label = ("SuperTuxKart toggle "+id) + __doc__ = docs m_context_level = contextLevel m_property_id = id @@ -322,7 +329,7 @@ class StkColorProperty(StkProperty): #! A floating-point property - def __init__(self, id, name, contextLevel, default="255 255 255"): + def __init__(self, id, name, contextLevel, default="255 255 255", docs="(No documentation defined for this item)"): super(StkColorProperty, self).__init__(id, name, default) #! Color picker operator (TODO: this operator is mostly for backwards compatibility with our @@ -331,6 +338,7 @@ class Apply_Color_Operator(bpy.types.Operator): bl_idname = ("screen.apply_color_"+id) bl_label = ("Apply Color") + __doc__ = docs property_id = id @@ -404,8 +412,8 @@ object_properties = OrderedDict([ ('name' , StkProperty('name', "Name", "")), ('interaction', StkEnumProperty('interaction', "Interaction", - {'ghost' : StkEnumChoice("Ghost", {}), - 'static' : StkEnumChoice("Static (wont move)", {}), + {'ghost' : StkEnumChoice("Ghost", {}, docs="This object will be non-physical (player can drive through it)"), + 'static' : StkEnumChoice("Static (wont move)", {}, docs="This object will stay in place, if the user drives on this object they will 'hit a wall'"), 'move' : StkEnumChoice("Movable by player", {'mass' : StkFloatProperty(id='mass', name="Mass (kg)", default=100.0), 'shape' : StkEnumProperty(id='shape', name="Shape", contextLevel=CONTEXT_OBJECT, @@ -418,61 +426,60 @@ 'box' : StkEnumChoice("Box", {}), 'sphere' : StkEnumChoice("Sphere", {}) }, default='box') - }) - }, contextLevel=CONTEXT_OBJECT, default='static')) + }, docs="The player will be able to move this object around by pushing it") + }, contextLevel=CONTEXT_OBJECT, default='static', docs="How this object should interact with other objects in the physics engine")) ]) # The 'type' property type = StkEnumProperty('type', "Type", - {'' : StkEnumChoice('None', {}), - 'banana' : StkEnumChoice('Banana', {}), - 'billboard' : StkEnumChoice('Billboard', {}), + {'' : StkEnumChoice('None', {}, docs="Nothing special about this object"), + 'banana' : StkEnumChoice('Banana', {}, docs="A banana object that needs to be avoided (apply to an Empty)"), + 'billboard' : StkEnumChoice('Billboard', {}, docs="A flat quad that will always face the camera"), 'check' : StkEnumChoice('Checkline', OrderedDict([ ('name' , StkProperty(id='name', name="Name", default="")), - ('activate', StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check')) + ('activate', StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check', docs="Which check structure to activate when crossing this checkline")) #'toggle' : Stkproperty("Toggle"), #'inner_radius' : StkFloatProperty("Color radius"), #'color' : - ])), + ]), docs="A checkline that the player must cross (used to forbid shortcuts)"), 'driveline' : StkEnumChoice('Driveline (additional)', {'invisible' : StkBoolProperty(id='invisible', name="Invisible", default="false", - contextLevel=CONTEXT_OBJECT), + contextLevel=CONTEXT_OBJECT, docs="If checked, this path will not appear in the minimap"), 'ai_ignore' : StkBoolProperty(id='ai_ignore', name="Ignored by AIs", default="false", - contextLevel=CONTEXT_OBJECT) - }), + contextLevel=CONTEXT_OBJECT, docs="If checked, AIs will not drive on this path") + }, docs="Driveline used to mark an alternate path"), 'maindriveline' : StkEnumChoice('Driveline (main)', - {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check') - + {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check', docs="Which check structure to activate when crossing the lap line") }), - 'fixed' : StkEnumChoice('End Camera (Fixed)', camera_properties), - 'ahead' : StkEnumChoice('End Camera (Look Ahead)', camera_properties), - 'ignore' : StkEnumChoice('Ignore', {}), - 'item' : StkEnumChoice('Item (Gift Box)', {}), + 'fixed' : StkEnumChoice('End Camera (Fixed)', camera_properties, docs="An end camera that stays in place"), + 'ahead' : StkEnumChoice('End Camera (Look Ahead)', camera_properties, docs="An end camera that follows the kart"), + 'ignore' : StkEnumChoice('Ignore', {}, docs="An object that is not exported and will not appear in-game"), + 'item' : StkEnumChoice('Item (Gift Box)', {}, docs="A gift box containing a random collectible (apply to an Empty)"), 'lap' : StkEnumChoice('Lap line', - {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check') + {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check', docs="Which check structure to activate when crossing the lap line") #'toggle' : Stkproperty("Toggle"), #'inner_radius' : StkFloatProperty("Color radius"), #'color' : - }), - 'nitro_big' : StkEnumChoice('Nitro (big)', {}), - 'nitro_small' : StkEnumChoice('Nitro (small)', {}), - 'object' : StkEnumChoice('Object', object_properties), + }, docs="An extension to the factory lap line"), + 'nitro_big' : StkEnumChoice('Nitro (big)', {}, docs="A big nitro collectible (apply to an Empty)"), + 'nitro_small' : StkEnumChoice('Nitro (small)', {}, docs="A small nitro collectible (apply to an Empty)"), + 'object' : StkEnumChoice('Object', object_properties, docs="An (animatable) object that is exported to a separate model file"), 'particle_emitter' : StkEnumChoice('Particle Emitter', {'kind' : StkProperty(id='kind', name="Particle File", default="smoke.xml") - }), - 'start' : StkEnumChoice('Start position', {'start_index' : StkIntProperty('start_index', "Start Index", 1)}), + }, docs="To be applied to an empty; particles will be emitted from this point"), + 'start' : StkEnumChoice('Start position', {'start_index' : StkIntProperty('start_index', "Start Index", 1)}, docs="A start position for karts in battle mode (only useful if this track is an arena)"), 'sun' : StkEnumChoice('Sun', - {'ambient' : StkColorProperty('ambient', "Ambient Color", contextLevel=CONTEXT_OBJECT), - 'diffuse' : StkColorProperty('diffuse', "Diffuse Color", contextLevel=CONTEXT_OBJECT), - 'specular' : StkColorProperty('specular', "Specular Color", contextLevel=CONTEXT_OBJECT) - }), + {'ambient' : StkColorProperty('ambient', "Ambient Color", contextLevel=CONTEXT_OBJECT, docs="Click here to pick an ambient color"), + 'diffuse' : StkColorProperty('diffuse', "Diffuse Color", contextLevel=CONTEXT_OBJECT, docs="Click here to pick a diffuse color"), + 'specular' : StkColorProperty('specular', "Specular Color", contextLevel=CONTEXT_OBJECT, docs="Click here to pick a specular color") + }, docs="Set on a sun; used to specify intensity, direction and color of the ambient light in the track"), 'water' : StkEnumChoice('Water', OrderedDict([ ('name' , StkProperty(id='name', name="Name", default="")), ('height', StkFloatProperty('height', "Waves Height", 1.0)), ('speed' , StkFloatProperty('speed', "Waves Speed", 200.0)), ('length', StkFloatProperty('length', "Waves Length", 10.0)) - ])) - }, contextLevel=CONTEXT_OBJECT, default='', unique_prefix="track_") + ]), docs="Animate the mesh with waves") + }, contextLevel=CONTEXT_OBJECT, default='', unique_prefix="track_", docs="SuperTuxKart Object Type") STK_PER_OBJECT_TRACK_PROPERTIES = OrderedDict([ @@ -481,7 +488,7 @@ subproperties={'anim_texture' : StkProperty(id='anim_texture', name='Texture to animate', default=""), 'anim_dx' : StkFloatProperty(id='anim_dx', name='Animation X Speed', default=0.0), 'anim_dy' : StkFloatProperty(id='anim_dy', name='Animation Y Speed', default=0.0) - })) + }, docs="Make a texture on this object move")) ]) STK_PER_OBJECT_KART_PROPERTIES = OrderedDict([ @@ -489,7 +496,7 @@ ('wheel' , StkEnumChoice('Wheel', {})), ('ignore', StkEnumChoice('Ignore', {})) ]), - contextLevel=CONTEXT_OBJECT, default='', unique_prefix="kart_") + contextLevel=CONTEXT_OBJECT, default='', unique_prefix="kart_", docs="Supertuxkart Object Type") ) ]) @@ -515,7 +522,7 @@ } -FOG_PROPERTIES = {'fog_color' : StkColorProperty(id='fog_color', name='Fog Color', default="0 0 0", contextLevel=CONTEXT_SCENE), +FOG_PROPERTIES = {'fog_color' : StkColorProperty(id='fog_color', name='Fog Color', default="0 0 0", contextLevel=CONTEXT_SCENE, docs="Click here to pick the color of the fog"), 'fog_start' : StkFloatProperty(id='fog_start', name='Fog Start', default=50.0), 'fog_end' : StkFloatProperty(id='fog_end', name='Fog End', default=300.0) } @@ -535,15 +542,15 @@ ('designer', StkProperty( id='designer', name='Designer', default=getpass.getuser())), ('music', StkProperty( id='music', name='Music', default='kart_grand_prix.music')), ('screenshot', StkProperty( id='screenshot', name='Screenshot', default='screenshot.jpg')), - ('sky_type', StkEnumProperty( id='sky_type', name='Sky Type', default='dome', contextLevel=CONTEXT_SCENE, values=SKY_TYPES)), - ('arena', StkBoolProperty( id='arena', name='Battle Arena', default="false", contextLevel=CONTEXT_SCENE)), - ('fog', StkBoolProperty( id='fog', name='Fog', default='false', contextLevel=CONTEXT_SCENE, subproperties=FOG_PROPERTIES)), + ('sky_type', StkEnumProperty( id='sky_type', name='Sky Type', default='dome', contextLevel=CONTEXT_SCENE, values=SKY_TYPES, docs="The type of sky")), + ('arena', StkBoolProperty( id='arena', name='Battle Arena', default="false", contextLevel=CONTEXT_SCENE, docs="Whether this scene is a battle arena")), + ('fog', StkBoolProperty( id='fog', name='Fog', default='false', contextLevel=CONTEXT_SCENE, subproperties=FOG_PROPERTIES, docs="Whether to enable fog in the track")), ('camera_far', StkFloatProperty( id='camera_far', name='Camera Far Clip', default=1000.0)), (k[0], StkIntProperty( id=k[0], name=kk[0], default=2)), (k[1], StkFloatProperty( id=k[1], name=kk[1], default=1.1)), (k[2], StkFloatProperty( id=k[2], name=kk[2], default=1.1)), (k[3], StkFloatProperty( id=k[3], name=kk[3], default=1.1)), - ('weather', StkEnumProperty( id='weather', name='Weather', default='none', contextLevel=CONTEXT_SCENE, values=WEATHER)) + ('weather', StkEnumProperty( id='weather', name='Weather', default='none', contextLevel=CONTEXT_SCENE, values=WEATHER, docs="The weather effect to use in this track")) ]) COMPOSITING_VALUES = {'none' : StkEnumChoice("None", {}), @@ -564,7 +571,8 @@ PARTICLE_PROPERTIES = { 'particle_base' : StkProperty( id='particle_base', name="Particles file", default="smoke.xml"), 'particle_condition' : StkCombinableEnumProperty( id='particle_condition', name="Use particles when...", default="skid", - contextLevel=CONTEXT_MATERIAL, values={'skid' : StkEnumChoice('Skid',{}), 'drive' : StkEnumChoice('Drive',{})}) + contextLevel=CONTEXT_MATERIAL, values={'skid' : StkEnumChoice('Skid',{}, docs="Use particle when skidding"), + 'drive' : StkEnumChoice('Drive',{}, docs="Use particles during regular driving")}) } long_names = ['zipper_max_speed_increase', "Zipper max speed increase", 'zipper_fade_out_time', "Zipper fade out time"] @@ -589,25 +597,25 @@ ]) STK_MATERIAL_PROPERTIES = OrderedDict([ - ('light', StkBoolProperty( id='light', name="Affected by lights", default="true", contextLevel=CONTEXT_MATERIAL)), - ('backface_culling', StkBoolProperty( id='backface_culling', name="Backface Culling", default="true", contextLevel=CONTEXT_MATERIAL)), - ('below_surface', StkBoolProperty( id='below_surface', name="Below Surface", default="false", contextLevel=CONTEXT_MATERIAL)), - ('compositing', StkEnumProperty( id='compositing', name="Compsiting Type", default='none', contextLevel=CONTEXT_MATERIAL, values=COMPOSITING_VALUES)), - ('clampu', StkBoolProperty( id='clampu', name="Clamp texture horizontally", default="false", contextLevel=CONTEXT_MATERIAL)), - ('clampv', StkBoolProperty( id='clampv', name="Clamp texture vertically", default="false", contextLevel=CONTEXT_MATERIAL)), - ('disable_z_write', StkBoolProperty( id='disable_z_write', name="Disable writing to Z-buffer",default="false", contextLevel=CONTEXT_MATERIAL)), - ('use_slowdown', StkBoolProperty( id='use_slowdown', name="Enable Slowdown", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SLOWDOWN_PROPERTIES)), - ('falling_effect', StkBoolProperty( id='falling_effect', name="Falling Effect", default="false", contextLevel=CONTEXT_MATERIAL)), + ('light', StkBoolProperty( id='light', name="Affected by lights", default="true", contextLevel=CONTEXT_MATERIAL, docs="Whether this material is affected by lgihts and shadows")), + ('backface_culling', StkBoolProperty( id='backface_culling', name="Backface Culling", default="true", contextLevel=CONTEXT_MATERIAL, docs="If checked, this material will only be visible on the side of the normal")), + ('below_surface', StkBoolProperty( id='below_surface', name="Below Surface", default="false", contextLevel=CONTEXT_MATERIAL, docs="Used for the terrain under shallow water where you can drive")), + ('compositing', StkEnumProperty( id='compositing', name="Compsiting Type", default='none', contextLevel=CONTEXT_MATERIAL, values=COMPOSITING_VALUES, docs="How to composite this texture with what is behind it")), + ('clampu', StkBoolProperty( id='clampu', name="Clamp texture horizontally", default="false", contextLevel=CONTEXT_MATERIAL, docs="if checked, this texture will not be repeated horizontally (if the UV texturing goes beyond the texture bounds)")), + ('clampv', StkBoolProperty( id='clampv', name="Clamp texture vertically", default="false", contextLevel=CONTEXT_MATERIAL, docs="if checked, this texture will not be repeated vertically (if the UV texturing goes beyond the texture bounds)")), + ('disable_z_write', StkBoolProperty( id='disable_z_write', name="Disable writing to Z-buffer",default="false", contextLevel=CONTEXT_MATERIAL, docs="disable writing to the Z buffer (useful for materials with transparency, if irrlicht fails to do proper alpha sorting, in order not to hide what is behind)")), + ('use_slowdown', StkBoolProperty( id='use_slowdown', name="Enable Slowdown", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SLOWDOWN_PROPERTIES, docs="Whether to slow down the kart when driving on this material")), + ('falling_effect', StkBoolProperty( id='falling_effect', name="Falling Effect", default="false", contextLevel=CONTEXT_MATERIAL, docs="Whether this material is the bottom of a pit (then camera will look down at kart falling when over it)")), ('graphical_effect', StkEnumProperty( id='graphical_effect', name="Graphical Effect", default='none', contextLevel=CONTEXT_MATERIAL, values=GFX_VALUES)), - ('high_adhesion', StkBoolProperty( id='high_adhesion', name="High tires adhesion", default="false", contextLevel=CONTEXT_MATERIAL)), - ('ignore', StkBoolProperty( id='ignore', name="Ignore (ghost material)", default="false", contextLevel=CONTEXT_MATERIAL)), + ('high_adhesion', StkBoolProperty( id='high_adhesion', name="High tires adhesion", default="false", contextLevel=CONTEXT_MATERIAL, docs="If checked, karts will have good grip on this surface and not slip, even at angles")), + ('ignore', StkBoolProperty( id='ignore', name="Ignore (ghost material)", default="false", contextLevel=CONTEXT_MATERIAL, docs="Drive through this texture like it didn't exist (good for smoke, etc.)")), ('mask', StkProperty( id='mask', name="Mask image", default="")), - ('particle', StkBoolProperty( id='particle', name="Particle effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=PARTICLE_PROPERTIES)), - ('use_sfx', StkBoolProperty( id='use_sfx', name="Play sound effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SFX_PROPERTIES)), - ('reset', StkBoolProperty( id='reset', name="Reset kart", default="false", contextLevel=CONTEXT_MATERIAL)), - ('sphere', StkBoolProperty( id='sphere', name="Sphere mapping", default="false", contextLevel=CONTEXT_MATERIAL)), - ('surface', StkBoolProperty( id='surface', name="Surface", default="false", contextLevel=CONTEXT_MATERIAL)), - ('zipper', StkBoolProperty( id='zipper', name="Zipper (speed boost)", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=ZIPPER_PROPERTIES)) + ('particle', StkBoolProperty( id='particle', name="Particle effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=PARTICLE_PROPERTIES, docs="Whether to emit particles (e.g. smoke) when driving on this surface")), + ('use_sfx', StkBoolProperty( id='use_sfx', name="Play sound effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SFX_PROPERTIES, docs="Whether to play a sound when driving on this surface")), + ('reset', StkBoolProperty( id='reset', name="Reset kart", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether to rescue kart if it ends up on this surface")), + ('sphere', StkBoolProperty( id='sphere', name="Sphere mapping", default="false", contextLevel=CONTEXT_MATERIAL, docs="use sphere mapping on this object (mainly used to simulate a reflection effect)")), + ('surface', StkBoolProperty( id='surface', name="Surface", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether this material is the surface of a water area")), + ('zipper', StkBoolProperty( id='zipper', name="Zipper (speed boost)", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=ZIPPER_PROPERTIES, docs="Whether to get a speed boost when driving on this surface")) ]) ENGINE_SOUNDS = {'large' : StkEnumChoice("Large", {}), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-07-01 02:07:17
|
Revision: 9122 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9122&view=rev Author: auria Date: 2011-07-01 02:07:11 +0000 (Fri, 01 Jul 2011) Log Message: ----------- Document a few more properties in the panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-07-01 01:57:22 UTC (rev 9121) +++ media/trunk/blender_25/stk_panel.py 2011-07-01 02:07:11 UTC (rev 9122) @@ -518,7 +518,7 @@ ('sky_speed_x' , StkFloatProperty(id='sky_speed_x', name='Sky Speed X', default=0.0)), ('sky_speed_y' , StkFloatProperty(id='sky_speed_y', name='Sky Speed Y', default=0.0))])), 'simple' : StkEnumChoice('Plain color', - {'sky_color' : StkColorProperty(id="sky_color", name="Sky Color", default="77 104 255", contextLevel=CONTEXT_SCENE)}) + {'sky_color' : StkColorProperty(id="sky_color", name="Sky Color", default="77 104 255", contextLevel=CONTEXT_SCENE, docs="Click here to select the color of the sky")}) } @@ -592,7 +592,7 @@ ('sfx_max_speed' , StkFloatProperty( id='sfx_max_speed', name="Maximum kart speed", default=0.0)), ('sfx_min_pitch' , StkFloatProperty( id='sfx_min_pitch', name="Sound pitch at min speed", default=0.8)), ('sfx_max_pitch' , StkFloatProperty( id='sfx_max_pitch', name="Sound pitch at max speed", default=1.2)), - ('sfx_positional', StkBoolProperty( id='sfx_positional', name="Positional sound effect", default="true", contextLevel=CONTEXT_MATERIAL)), + ('sfx_positional', StkBoolProperty( id='sfx_positional', name="Positional sound effect", default="true", contextLevel=CONTEXT_MATERIAL, docs="If true, the sound will get dimmer when far from camera, and with panning; if false, it's heard at centered pan and at full volume")), ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1)) ]) @@ -606,7 +606,7 @@ ('disable_z_write', StkBoolProperty( id='disable_z_write', name="Disable writing to Z-buffer",default="false", contextLevel=CONTEXT_MATERIAL, docs="disable writing to the Z buffer (useful for materials with transparency, if irrlicht fails to do proper alpha sorting, in order not to hide what is behind)")), ('use_slowdown', StkBoolProperty( id='use_slowdown', name="Enable Slowdown", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SLOWDOWN_PROPERTIES, docs="Whether to slow down the kart when driving on this material")), ('falling_effect', StkBoolProperty( id='falling_effect', name="Falling Effect", default="false", contextLevel=CONTEXT_MATERIAL, docs="Whether this material is the bottom of a pit (then camera will look down at kart falling when over it)")), - ('graphical_effect', StkEnumProperty( id='graphical_effect', name="Graphical Effect", default='none', contextLevel=CONTEXT_MATERIAL, values=GFX_VALUES)), + ('graphical_effect', StkEnumProperty( id='graphical_effect', name="Graphical Effect", default='none', contextLevel=CONTEXT_MATERIAL, values=GFX_VALUES, docs="Select a special graphical effect")), ('high_adhesion', StkBoolProperty( id='high_adhesion', name="High tires adhesion", default="false", contextLevel=CONTEXT_MATERIAL, docs="If checked, karts will have good grip on this surface and not slip, even at angles")), ('ignore', StkBoolProperty( id='ignore', name="Ignore (ghost material)", default="false", contextLevel=CONTEXT_MATERIAL, docs="Drive through this texture like it didn't exist (good for smoke, etc.)")), ('mask', StkProperty( id='mask', name="Mask image", default="")), @@ -636,9 +636,9 @@ SCENE_PROPS = {'is_stk_track' : StkBoolProperty(id='is_stk_track', name='Is a SuperTuxKart track', default='false', contextLevel=CONTEXT_SCENE, - subproperties=STK_TRACK_WIDE_PROPERTIES, box=False), + subproperties=STK_TRACK_WIDE_PROPERTIES, box=False, docs="Check this if this blender file is a SuperTuxKart track"), 'is_stk_kart' : StkBoolProperty(id='is_stk_kart', name='Is a SuperTuxKart kart', default='false', contextLevel=CONTEXT_SCENE, - subproperties=STK_KART_PROPERTIES, box=False)} + subproperties=STK_KART_PROPERTIES, box=False, docs="Check this if this blender file is a SuperTuxKart kart")} # ==== PANEL BASE ==== class PanelBase: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-07-03 00:00:54
|
Revision: 9133 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9133&view=rev Author: auria Date: 2011-07-03 00:00:48 +0000 (Sun, 03 Jul 2011) Log Message: ----------- Allow setting 'none' obejct type Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-07-02 06:25:14 UTC (rev 9132) +++ media/trunk/blender_25/stk_panel.py 2011-07-03 00:00:48 UTC (rev 9133) @@ -163,8 +163,9 @@ values_for_blender_unsorted = [] for curr_val in values.keys(): - curr_obj = values[curr_val] - values_for_blender_unsorted.append( (curr_val, curr_obj.name, curr_obj.name) ) + if len(curr_val) > 0: + curr_obj = values[curr_val] + values_for_blender_unsorted.append( (curr_val, curr_obj.name, curr_obj.name) ) values_for_blender = sorted(values_for_blender_unsorted, key=lambda k: k[1]) @@ -433,6 +434,7 @@ # The 'type' property type = StkEnumProperty('type', "Type", {'' : StkEnumChoice('None', {}, docs="Nothing special about this object"), + 'none' : StkEnumChoice('None', {}, docs="Nothing special about this object"), 'banana' : StkEnumChoice('Banana', {}, docs="A banana object that needs to be avoided (apply to an Empty)"), 'billboard' : StkEnumChoice('Billboard', {}, docs="A flat quad that will always face the camera"), 'check' : StkEnumChoice('Checkline', OrderedDict([ @@ -479,7 +481,7 @@ ('speed' , StkFloatProperty('speed', "Waves Speed", 200.0)), ('length', StkFloatProperty('length', "Waves Length", 10.0)) ]), docs="Animate the mesh with waves") - }, contextLevel=CONTEXT_OBJECT, default='', unique_prefix="track_", docs="SuperTuxKart Object Type") + }, contextLevel=CONTEXT_OBJECT, default='none', unique_prefix="track_", docs="SuperTuxKart Object Type") STK_PER_OBJECT_TRACK_PROPERTIES = OrderedDict([ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-07-03 00:37:39
|
Revision: 9134 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9134&view=rev Author: auria Date: 2011-07-03 00:37:33 +0000 (Sun, 03 Jul 2011) Log Message: ----------- Minor tweaks to material panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-07-03 00:00:48 UTC (rev 9133) +++ media/trunk/blender_25/stk_panel.py 2011-07-03 00:37:33 UTC (rev 9134) @@ -837,8 +837,8 @@ label = context.scene['selected_image'] self.m_op_name = "scene.stk_image_menu" - row.label(label) - row.menu(self.m_op_name, text="", icon="TRIA_DOWN") + #row.label(label) + row.menu(self.m_op_name, text=label) obj = getObject(context, CONTEXT_MATERIAL) if obj is not None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-07-03 00:41:39
|
Revision: 9135 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9135&view=rev Author: auria Date: 2011-07-03 00:41:33 +0000 (Sun, 03 Jul 2011) Log Message: ----------- Minor tweaks to checkboxes in the panel, to make more room for labels Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-07-03 00:37:33 UTC (rev 9134) +++ media/trunk/blender_25/stk_panel.py 2011-07-03 00:41:33 UTC (rev 9135) @@ -651,16 +651,20 @@ curr = properties[id] row = layout.row() - row.label(text=curr.name) if isinstance(curr, StkBoolProperty): + + split = row.split(0.8) + + split.label(text=curr.name) + state = "false" icon = 'CHECKBOX_DEHLT' if id in obj: state = obj[id] if state == "true": icon = 'CHECKBOX_HLT' - row.operator("screen.stk_toggle_bool_"+id, text=" ", icon=icon, emboss=False) + split.operator("screen.stk_toggle_bool_"+id, text=" ", icon=icon, emboss=False) if state == "true": if len(curr.subproperties) > 0: @@ -671,12 +675,15 @@ self.recursivelyAddProperties(curr.subproperties, layout, obj) elif isinstance(curr, StkColorProperty): + row.label(text=curr.name) if curr.id in obj: row.prop(obj, '["' + curr.id + '"]', text="") row.operator("screen.apply_color_"+curr.id, text="", icon='COLOR') elif isinstance(curr, StkCombinableEnumProperty): + row.label(text=curr.name) + if curr.id in obj: curr_val = obj[curr.id] @@ -687,6 +694,9 @@ row.operator("screen.stk_set_"+id+"_"+value_id, text=curr.values[value_id].name, icon=icon) elif isinstance(curr, StkEnumProperty): + + row.label(text=curr.name) + if id in obj: curr_value = obj[id] else: @@ -703,12 +713,16 @@ self.recursivelyAddProperties(curr.values[curr_value].subproperties, box, obj) elif isinstance(curr, StkObjectReferenceProperty): + + row.label(text=curr.name) - if curr.id in obj: + if curr.id in obj: row.prop(obj, '["' + curr.id + '"]', text="") row.menu("screen.stk_object_menu_" + curr.id, text="", icon='TRIA_DOWN') else: + row.label(text=curr.name) + # String or int or float property (Blender chooses the correct widget from the type of the ID-property) if curr.id in obj: row.prop(obj, '["' + curr.id + '"]', text="") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-07-08 00:09:49
|
Revision: 9191 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9191&view=rev Author: auria Date: 2011-07-08 00:09:42 +0000 (Fri, 08 Jul 2011) Log Message: ----------- Fixed kart panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-07-07 22:51:24 UTC (rev 9190) +++ media/trunk/blender_25/stk_panel.py 2011-07-08 00:09:42 UTC (rev 9191) @@ -168,11 +168,11 @@ values_for_blender_unsorted.append( (curr_val, curr_obj.name, curr_obj.name) ) values_for_blender = sorted(values_for_blender_unsorted, key=lambda k: k[1]) - + # Create operator for this combo class STK_SetComboValue(bpy.types.Operator): - value = bpy.props.EnumProperty(attr="values", name="values", default=default_value, + value = bpy.props.EnumProperty(attr="values", name="values", default=default_value + "", items=values_for_blender) bl_idname = ("screen.stk_set_" + unique_prefix + id) @@ -495,10 +495,11 @@ STK_PER_OBJECT_KART_PROPERTIES = OrderedDict([ ('type' , StkEnumProperty('type', "Type", OrderedDict([ ('' , StkEnumChoice('None', {})), + ('none' , StkEnumChoice('None', {})), ('wheel' , StkEnumChoice('Wheel', {})), ('ignore', StkEnumChoice('Ignore', {})) ]), - contextLevel=CONTEXT_OBJECT, default='', unique_prefix="kart_", docs="Supertuxkart Object Type") + contextLevel=CONTEXT_OBJECT, default='none', unique_prefix="kart_", docs="Supertuxkart Object Type") ) ]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-31 00:27:56
|
Revision: 9682 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9682&view=rev Author: auria Date: 2011-08-31 00:27:49 +0000 (Wed, 31 Aug 2011) Log Message: ----------- Update panel with more tooltips (figured partly how they work :)), plus set some min and max values Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-08-31 00:03:59 UTC (rev 9681) +++ media/trunk/blender_25/stk_panel.py 2011-08-31 00:27:49 UTC (rev 9682) @@ -49,29 +49,31 @@ #! @param name User-visible name for this property #! @param subproperties A dictionary of type { 'name' : StkProperty(...) }. Contains the # properties that are to be shown when this enum item is selected - def __init__(self, name, subproperties, docs="(No documentation was defined for this item)"): + def __init__(self, name, subproperties, doc="(No documentation was defined for this item)"): self.name = name self.subproperties = subproperties - self.__doc__ = docs + self.__doc__ = doc + self.doc = doc #! The base class for all properties class StkProperty: - def __init__(self, id, name, default): + def __init__(self, id, name, default, doc="(No documentation was defined for this item)"): self.name = name self.id = id self.default = default + self.doc = doc class StkObjectReferenceProperty(StkProperty): - def __init__(self, id, name, contextLevel, default, filter, docs="Select an object"): + def __init__(self, id, name, contextLevel, default, filter, doc="Select an object"): super(StkObjectReferenceProperty, self).__init__(id, name, default) - self.docs = docs + self.doc = doc class SelectObjectOperator(bpy.types.Operator): bl_idname = "scene.stk_select_object_" + id bl_label = "Select Object Operator" - __doc__ = docs + __doc__ = doc m_id = id m_context_level = contextLevel @@ -110,11 +112,33 @@ bpy.utils.register_class(ObjectPickerMenu) def createProperties(object, props): + + if not "_RNA_UI" in object: + object["_RNA_UI"] = {} + for p in props.keys(): + rna_ui_dict = {} + try: + rna_ui_dict["description"] = props[p].doc + except: + pass + + try: + if p.min is not None: rna_ui_dict["min"] = props[p].min + except: + pass + + try: + if p.max is not None: rna_ui_dict["max"] = props[p].max + except: + pass + + object["_RNA_UI"][p] = rna_ui_dict + if not p in object: - # create property by setting default value + # create property by setting default value v = props[p].default object[p] = v @@ -154,11 +178,11 @@ #! @param name User-visible name for this property #! @param values A dictionnary of type { 'value' : StkEnumChoice(...) } #! @note The first value will be used by default - def __init__(self, id, name, values, contextLevel, default, unique_prefix="", docs="(No documentation for this item)"): + def __init__(self, id, name, values, contextLevel, default, unique_prefix="", doc="(No documentation for this item)"): super(StkEnumProperty, self).__init__(id, name, default) self.values = values self.operator_name = "screen.stk_set_" + unique_prefix + id - self.docs = docs + self.doc = doc default_value = default values_for_blender_unsorted = [] @@ -177,7 +201,7 @@ bl_idname = ("screen.stk_set_" + unique_prefix + id) bl_label = ("SuperTuxKart set " + unique_prefix + id) - __doc__ = docs + __doc__ = doc m_property_id = id m_items_val = values_for_blender @@ -259,19 +283,23 @@ class StkFloatProperty(StkProperty): #! @param name User-visible name for this property - def __init__(self, id, name, default=0.0, docs="(No documentation defined for this element)"): + def __init__(self, id, name, default=0.0, doc="(No documentation defined for this element)", min = None, max = None): super(StkFloatProperty, self).__init__(id, name, default) self.default - self.__doc__ = docs + self.doc = doc + self.min = min + self.max = max #! An integer property class StkIntProperty(StkProperty): #! @param name User-visible name for this property - def __init__(self, id, name, default=0, docs="(No documentation defined for this element)"): + def __init__(self, id, name, default=0, doc="(No documentation defined for this element)", min=None, max=None): super(StkIntProperty, self).__init__(id, name, default) - self.__doc__ = docs + self.doc = doc + self.min = min + self.max = max #! A boolean property class StkBoolProperty(StkProperty): @@ -280,11 +308,12 @@ box = True #! A floating-point property - def __init__(self, id, name, contextLevel, default="false", subproperties={}, box = True, docs="(No documentation defined for this element)"): + def __init__(self, id, name, contextLevel, default="false", subproperties={}, box = True, doc="(No documentation defined for this element)"): super(StkBoolProperty, self).__init__(id, name, default) self.box = box self.subproperties = subproperties + self.doc = doc super_self = self # Create operator for this bool @@ -292,7 +321,7 @@ bl_idname = ("screen.stk_toggle_bool_"+id) bl_label = ("SuperTuxKart toggle "+id) - __doc__ = docs + __doc__ = doc m_context_level = contextLevel m_property_id = id @@ -330,7 +359,7 @@ class StkColorProperty(StkProperty): #! A floating-point property - def __init__(self, id, name, contextLevel, default="255 255 255", docs="(No documentation defined for this item)"): + def __init__(self, id, name, contextLevel, default="255 255 255", doc="(No documentation defined for this item)"): super(StkColorProperty, self).__init__(id, name, default) #! Color picker operator (TODO: this operator is mostly for backwards compatibility with our @@ -339,7 +368,7 @@ class Apply_Color_Operator(bpy.types.Operator): bl_idname = ("screen.apply_color_"+id) bl_label = ("Apply Color") - __doc__ = docs + __doc__ = doc property_id = id @@ -411,12 +440,13 @@ # Property when type="object" object_properties = OrderedDict([ - ('name' , StkProperty('name', "Name", "")), + ('name' , StkProperty('name', "Name", "", doc="Name of this object (objects with the same name are exported as a single file)")), ('interaction', StkEnumProperty('interaction', "Interaction", - {'ghost' : StkEnumChoice("Ghost", {}, docs="This object will be non-physical (player can drive through it)"), - 'static' : StkEnumChoice("Static (wont move)", {}, docs="This object will stay in place, if the user drives on this object they will 'hit a wall'"), + {'ghost' : StkEnumChoice("Ghost", {}, doc="This object will be non-physical (player can drive through it)"), + 'static' : StkEnumChoice("Static (wont move)", {}, + doc="This object will stay in place, if the user drives on this object they will 'hit a wall'"), 'move' : StkEnumChoice("Movable by player", - {'mass' : StkFloatProperty(id='mass', name="Mass (kg)", default=100.0), + {'mass' : StkFloatProperty(id='mass', name="Mass (kg)", default=100.0, min=0.0, doc="How heavy the object is"), 'shape' : StkEnumProperty(id='shape', name="Shape", contextLevel=CONTEXT_OBJECT, values={'coneX' : StkEnumChoice("Cone (X)", {}), 'coneY' : StkEnumChoice("Cone (Y)", {}), @@ -426,84 +456,105 @@ 'cylinderZ' : StkEnumChoice("Cylinder (Z)", {}), 'box' : StkEnumChoice("Box", {}), 'sphere' : StkEnumChoice("Sphere", {}) - }, default='box') - }, docs="The player will be able to move this object around by pushing it") - }, contextLevel=CONTEXT_OBJECT, default='static', docs="How this object should interact with other objects in the physics engine")) + }, default='box', doc="Shape to use in the physics engine to repreent this object") + }, doc="The player will be able to move this object around by pushing it") + }, + contextLevel=CONTEXT_OBJECT, default='static', + doc="How this object should interact with other objects in the physics engine") + ) ]) # The 'type' property type = StkEnumProperty('type', "Type", - {'' : StkEnumChoice('None', {}, docs="Nothing special about this object"), - 'none' : StkEnumChoice('None', {}, docs="Nothing special about this object"), - 'banana' : StkEnumChoice('Banana', {}, docs="A banana object that needs to be avoided (apply to an Empty)"), - 'billboard' : StkEnumChoice('Billboard', {}, docs="A flat quad that will always face the camera"), + {'' : StkEnumChoice('None', {}, doc="Nothing special about this object"), + 'none' : StkEnumChoice('None', {}, doc="Nothing special about this object"), + 'banana' : StkEnumChoice('Banana', {}, doc="A banana object that needs to be avoided (apply to an Empty)"), + 'billboard' : StkEnumChoice('Billboard', {}, doc="A flat quad that will always face the camera"), 'check' : StkEnumChoice('Checkline', OrderedDict([ - ('name' , StkProperty(id='name', name="Name", default="")), - ('activate', StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check', docs="Which check structure to activate when crossing this checkline")) + ('name' , StkProperty(id='name', name="Name", default="", doc="Name of the checkline")), + ('activate', StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, + filter=lambda self, o : 'type' in o and o['type'] == 'check', + doc="Which check structure to activate when crossing this checkline")) #'toggle' : Stkproperty("Toggle"), #'inner_radius' : StkFloatProperty("Color radius"), #'color' : - ]), docs="A checkline that the player must cross (used to forbid shortcuts)"), + ]), doc="A checkline that the player must cross (used to forbid shortcuts)"), 'driveline' : StkEnumChoice('Driveline (additional)', {'invisible' : StkBoolProperty(id='invisible', name="Invisible", default="false", - contextLevel=CONTEXT_OBJECT, docs="If checked, this path will not appear in the minimap"), + contextLevel=CONTEXT_OBJECT, doc="If checked, this path will not appear in the minimap"), 'ai_ignore' : StkBoolProperty(id='ai_ignore', name="Ignored by AIs", default="false", - contextLevel=CONTEXT_OBJECT, docs="If checked, AIs will not drive on this path") - }, docs="Driveline used to mark an alternate path"), + contextLevel=CONTEXT_OBJECT, doc="If checked, AIs will not drive on this path") + }, doc="Driveline used to mark an alternate path"), 'maindriveline' : StkEnumChoice('Driveline (main)', - {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check', docs="Which check structure to activate when crossing the lap line") + {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, + filter=lambda self, o : 'type' in o and o['type'] == 'check', + doc="Which check structure to activate when crossing the lap line") }), - 'fixed' : StkEnumChoice('End Camera (Fixed)', camera_properties, docs="An end camera that stays in place"), - 'ahead' : StkEnumChoice('End Camera (Look Ahead)', camera_properties, docs="An end camera that follows the kart"), - 'ignore' : StkEnumChoice('Ignore', {}, docs="An object that is not exported and will not appear in-game"), - 'item' : StkEnumChoice('Item (Gift Box)', {}, docs="A gift box containing a random collectible (apply to an Empty)"), + 'fixed' : StkEnumChoice('End Camera (Fixed)', camera_properties, doc="An end camera that stays in place"), + 'ahead' : StkEnumChoice('End Camera (Look Ahead)', camera_properties, doc="An end camera that follows the kart"), + 'ignore' : StkEnumChoice('Ignore', {}, doc="An object that is not exported and will not appear in-game"), + 'item' : StkEnumChoice('Item (Gift Box)', {}, doc="A gift box containing a random collectible (apply to an Empty)"), 'lap' : StkEnumChoice('Lap line', - {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check', docs="Which check structure to activate when crossing the lap line") + {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, + filter=lambda self, o : 'type' in o and o['type'] == 'check', + doc="Which check structure to activate when crossing the lap line") #'toggle' : Stkproperty("Toggle"), #'inner_radius' : StkFloatProperty("Color radius"), #'color' : - }, docs="An extension to the factory lap line"), + }, doc="An extension to the factory lap line"), 'lod_instance' : StkEnumChoice('LOD Instance', - {'lod_name' : StkProperty( id='lod_name', name="LOD Group Name", default="SomeModel") - }, docs="A LOD (level-of-detail) instance, will display either of the LOD Models in this LOD group at this location"), + {'lod_name' : StkProperty( id='lod_name', name="LOD Group Name", default="SomeModel", + doc="Name of the LOD group this object is an instance of") + }, doc="A LOD (level-of-detail) instance, will display either of the LOD Models in this LOD group at this location"), 'lod_model' : StkEnumChoice('LOD Model', - {'lod_distance' : StkFloatProperty( id='lod_distance', name="Distance", default=60.0), - 'lod_name' : StkProperty( id='lod_name', name="LOD Group Name", default="SomeModel"), - 'name' : StkProperty( id='name', name="Model Filename", default="") - }, docs="A LOD (level-of-detail) model (this model will not be visible in game, only LOD instances will)"), - 'nitro_big' : StkEnumChoice('Nitro (big)', {}, docs="A big nitro collectible (apply to an Empty)"), - 'nitro_small' : StkEnumChoice('Nitro (small)', {}, docs="A small nitro collectible (apply to an Empty)"), - 'object' : StkEnumChoice('Object', object_properties, docs="An (animatable) object that is exported to a separate model file"), + {'lod_distance' : StkFloatProperty( id='lod_distance', name="Distance", default=60.0, min=0.0, max=5000.0, + doc="Distance from the camera at which this level of detail starts being used"), + 'lod_name' : StkProperty( id='lod_name', name="LOD Group Name", default="SomeModel", + doc="Name of the LOD group this object is part of"), + 'name' : StkProperty( id='name', name="Model Filename", default="", + doc="Name of the model to export") + }, doc="A LOD (level-of-detail) model (this model will not be visible in game, only LOD instances will)"), + 'nitro_big' : StkEnumChoice('Nitro (big)', {}, doc="A big nitro collectible (apply to an Empty)"), + 'nitro_small' : StkEnumChoice('Nitro (small)', {}, doc="A small nitro collectible (apply to an Empty)"), + 'object' : StkEnumChoice('Object', object_properties, doc="An (animatable) object that is exported to a separate model file"), 'particle_emitter' : StkEnumChoice('Particle Emitter', {'kind' : StkProperty(id='kind', name="Particle File", default="smoke.xml") - }, docs="To be applied to an empty; particles will be emitted from this point"), - 'start' : StkEnumChoice('Start position', {'start_index' : StkIntProperty('start_index', "Start Index", 1)}, docs="A start position for karts in battle mode (only useful if this track is an arena)"), + }, doc="To be applied to an empty; particles will be emitted from this point"), + 'start' : StkEnumChoice('Start position', subproperties={'start_index' : StkIntProperty('start_index', "Start Index", 1, + doc="Start position index for battle mode")}, + doc="A start position for karts in battle mode (only useful if this track is an arena)"), 'sfx_emitter' : StkEnumChoice('Sound Emitter', OrderedDict([ - ('sfx_filename' , StkProperty( id='sfx_filename', name="Sound File", default="some_file.ogg")), - ('sfx_volume' , StkFloatProperty( id='sfx_volume', name="Sound volume", default=1.0)), - ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1))]), - docs="A sound will be heard when close to this point"), + ('sfx_filename' , StkProperty( id='sfx_filename', name="Sound File", default="some_file.ogg", + doc="Filename of the sound to play")), + ('sfx_volume' , StkFloatProperty( id='sfx_volume', name="Sound volume", default=1.0, min=0.0, max=1.0)), + ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1, min=0.0, max=5.0, + doc="How fast this osund decays when going farther from the emission point"))]), + doc="A sound will be heard when close to this point"), 'sun' : StkEnumChoice('Sun', - {'ambient' : StkColorProperty('ambient', "Ambient Color", contextLevel=CONTEXT_OBJECT, docs="Click here to pick an ambient color"), - 'diffuse' : StkColorProperty('diffuse', "Diffuse Color", contextLevel=CONTEXT_OBJECT, docs="Click here to pick a diffuse color"), - 'specular' : StkColorProperty('specular', "Specular Color", contextLevel=CONTEXT_OBJECT, docs="Click here to pick a specular color") - }, docs="Set on a sun; used to specify intensity, direction and color of the ambient light in the track"), + {'ambient' : StkColorProperty('ambient', "Ambient Color", contextLevel=CONTEXT_OBJECT, + doc="Click here to pick an ambient color"), + 'diffuse' : StkColorProperty('diffuse', "Diffuse Color", contextLevel=CONTEXT_OBJECT, + doc="Click here to pick a diffuse color"), + 'specular' : StkColorProperty('specular', "Specular Color", contextLevel=CONTEXT_OBJECT, + doc="Click here to pick a specular color") + }, doc="Set on a sun; used to specify intensity, direction and color of the ambient light in the track"), 'water' : StkEnumChoice('Water', OrderedDict([ - ('name' , StkProperty(id='name', name="Name", default="")), - ('height', StkFloatProperty('height', "Waves Height", 1.0)), - ('speed' , StkFloatProperty('speed', "Waves Speed", 200.0)), - ('length', StkFloatProperty('length', "Waves Length", 10.0)) - ]), docs="Animate the mesh with waves") - }, contextLevel=CONTEXT_OBJECT, default='none', unique_prefix="track_", docs="SuperTuxKart Object Type") + ('name' , StkProperty(id='name', name="Name", default="", doc="Name of the model to export")), + ('height', StkFloatProperty('height', "Waves Height", default=1.0, min=0.0, doc="Height of the waves")), + ('speed' , StkFloatProperty('speed', "Waves Speed", default=200.0, min=0.0, max=500.0, doc="Speed of the waves")), + ('length', StkFloatProperty('length', "Waves Length", default=10.0, min=0.0, doc="Length of the waves")) + ]), doc="Animate the mesh with waves") + }, contextLevel=CONTEXT_OBJECT, default='none', unique_prefix="track_", doc="SuperTuxKart Object Type") STK_PER_OBJECT_TRACK_PROPERTIES = OrderedDict([ ('type' , type), ('enable_anim_texture', StkBoolProperty(id='enable_anim_texture', name='Use animated Texture', default="false", contextLevel=CONTEXT_OBJECT, - subproperties={'anim_texture' : StkProperty(id='anim_texture', name='Texture to animate', default=""), - 'anim_dx' : StkFloatProperty(id='anim_dx', name='Animation X Speed', default=0.0), - 'anim_dy' : StkFloatProperty(id='anim_dy', name='Animation Y Speed', default=0.0) - }, docs="Make a texture on this object move")) + subproperties={'anim_texture' : StkProperty(id='anim_texture', name='Texture to animate', default="", + doc="Filename of the texture to animate"), + 'anim_dx' : StkFloatProperty(id='anim_dx', name='Animation X Speed', default=0.0, min=0.0), + 'anim_dy' : StkFloatProperty(id='anim_dy', name='Animation Y Speed', default=0.0, min=0.0) + }, doc="Make a texture on this object move")) ]) STK_PER_OBJECT_KART_PROPERTIES = OrderedDict([ @@ -512,12 +563,12 @@ ('wheel' , StkEnumChoice('Wheel', {})), ('ignore', StkEnumChoice('Ignore', {})) ]), - contextLevel=CONTEXT_OBJECT, default='none', unique_prefix="kart_", docs="Supertuxkart Object Type") + contextLevel=CONTEXT_OBJECT, default='none', unique_prefix="kart_", doc="Supertuxkart Object Type") ) ]) SKY_TYPES = { - 'none' : StkEnumChoice('None', {}), + 'none' : StkEnumChoice('None', {}, doc="No sky (useful for indoor scenes)"), 'box' : StkEnumChoice('Box', OrderedDict([ ('sky_texture2' , StkProperty(id='sky_texture2', name='Sky Texture Top', default="")), ('sky_texture3' , StkProperty(id='sky_texture3', name='Sky Texture Bottom', default="")), @@ -534,13 +585,18 @@ ('sky_speed_x' , StkFloatProperty(id='sky_speed_x', name='Sky Speed X', default=0.0)), ('sky_speed_y' , StkFloatProperty(id='sky_speed_y', name='Sky Speed Y', default=0.0))])), 'simple' : StkEnumChoice('Plain color', - {'sky_color' : StkColorProperty(id="sky_color", name="Sky Color", default="77 104 255", contextLevel=CONTEXT_SCENE, docs="Click here to select the color of the sky")}) + {'sky_color' : StkColorProperty(id="sky_color", name="Sky Color", default="77 104 255", contextLevel=CONTEXT_SCENE, + doc="Click here to select the color of the sky")}, + doc="A plain-color sky") } -FOG_PROPERTIES = {'fog_color' : StkColorProperty(id='fog_color', name='Fog Color', default="0 0 0", contextLevel=CONTEXT_SCENE, docs="Click here to pick the color of the fog"), - 'fog_start' : StkFloatProperty(id='fog_start', name='Fog Start', default=50.0), - 'fog_end' : StkFloatProperty(id='fog_end', name='Fog End', default=300.0) +FOG_PROPERTIES = {'fog_color' : StkColorProperty(id='fog_color', name='Fog Color', default="0 0 0", contextLevel=CONTEXT_SCENE, + doc="Click here to pick the color of the fog"), + 'fog_start' : StkFloatProperty(id='fog_start', name='Fog Start', default=50.0, min=0.0, max=1000.0, + doc="Distance from camera at which fog starts dimming objects"), + 'fog_end' : StkFloatProperty(id='fog_end', name='Fog End', default=300.0, min=0.0, max=1000.0, + doc="Distance from camera at which fog is so dense you can't see a thing") } WEATHER = {'none' : StkEnumChoice("None",{}), @@ -553,51 +609,66 @@ kk = ['Karts per row on start', 'Start Forwards Distance', 'Start Sidewards Distance', 'Start upwards distance'] STK_TRACK_WIDE_PROPERTIES = OrderedDict([ - ('name', StkProperty( id='name', name='Name', default='My New Track')), - ('groups', StkProperty( id='groups', name='Groups', default='standard')), - ('designer', StkProperty( id='designer', name='Designer', default=getpass.getuser())), - ('music', StkProperty( id='music', name='Music', default='kart_grand_prix.music')), - ('screenshot', StkProperty( id='screenshot', name='Screenshot', default='screenshot.jpg')), - ('sky_type', StkEnumProperty( id='sky_type', name='Sky Type', default='dome', contextLevel=CONTEXT_SCENE, values=SKY_TYPES, docs="The type of sky")), - ('arena', StkBoolProperty( id='arena', name='Battle Arena', default="false", contextLevel=CONTEXT_SCENE, docs="Whether this scene is a battle arena")), - ('fog', StkBoolProperty( id='fog', name='Fog', default='false', contextLevel=CONTEXT_SCENE, subproperties=FOG_PROPERTIES, docs="Whether to enable fog in the track")), - ('camera_far', StkFloatProperty( id='camera_far', name='Camera Far Clip', default=1000.0)), + ('name', StkProperty( id='name', name='Name', default='My New Track', + doc="Name of the track")), + ('groups', StkProperty( id='groups', name='Groups', default='standard', + doc="Tabs in track selection screen this track appears under")), + ('designer', StkProperty( id='designer', name='Designer', default=getpass.getuser(), + doc="Name of the person that made this track")), + ('music', StkProperty( id='music', name='Music', default='kart_grand_prix.music', + doc="Music played in this track")), + ('screenshot', StkProperty( id='screenshot', name='Screenshot', default='screenshot.jpg', + doc="Name of the file that contains a screenshot of this tracj")), + ('sky_type', StkEnumProperty( id='sky_type', name='Sky Type', default='dome', + contextLevel=CONTEXT_SCENE, values=SKY_TYPES, doc="The type of sky")), + ('arena', StkBoolProperty( id='arena', name='Battle Arena', default="false", + contextLevel=CONTEXT_SCENE, doc="Whether this scene is a battle arena")), + ('fog', StkBoolProperty( id='fog', name='Fog', default='false', + contextLevel=CONTEXT_SCENE, subproperties=FOG_PROPERTIES, doc="Whether to enable fog in the track")), + ('camera_far', StkFloatProperty( id='camera_far', name='Camera Far Clip', default=1000.0, + doc="Distance from camera at which objects are clipped (no more visible)")), (k[0], StkIntProperty( id=k[0], name=kk[0], default=2)), (k[1], StkFloatProperty( id=k[1], name=kk[1], default=1.1)), (k[2], StkFloatProperty( id=k[2], name=kk[2], default=1.1)), (k[3], StkFloatProperty( id=k[3], name=kk[3], default=1.1)), - ('weather', StkEnumProperty( id='weather', name='Weather', default='none', contextLevel=CONTEXT_SCENE, values=WEATHER, docs="The weather effect to use in this track")) + ('weather', StkEnumProperty( id='weather', name='Weather', default='none', + contextLevel=CONTEXT_SCENE, values=WEATHER, doc="The weather effect to use in this track")) ]) COMPOSITING_VALUES = {'none' : StkEnumChoice("None", {}), - 'blend' : StkEnumChoice("Alpha Blend", {}), - 'test' : StkEnumChoice("Alpha Test", {}), - 'additive' : StkEnumChoice("Additive Blending", {}) + 'blend' : StkEnumChoice("Alpha Blend", {}, + doc="Use transparency on this texture, using the alpha channel or a specified external mask"), + 'test' : StkEnumChoice("Alpha Test", {}, + doc="Use fully-opaque-or-fully-transparent transparency on this texture, using the alpha channel or a specified external mask"), + 'additive' : StkEnumChoice("Additive Blending", {}, + doc="Brighten up anything under by adding the current color on top (useful for fire or light)") } GFX_VALUES = {'none' : StkEnumChoice("None", {}), 'water' : StkEnumChoice("Water Splash", {}) } - + SLOWDOWN_PROPERTIES = { - 'slowdown_time' : StkFloatProperty( id="slowdown_time", name="Slowdown Time (seconds)", default=1.0 ), - 'max_speed' : StkFloatProperty( id="max_speed", name="Maximum Speed (fraction)", default=1.0 ) + 'slowdown_time' : StkFloatProperty( id="slowdown_time", name="Slowdown Time (seconds)", default=1.0, min=0.0, max=10.0, + doc="Time it takes for speed to drop to its low point when driving here" ), + 'max_speed' : StkFloatProperty( id="max_speed", name="Maximum Speed (fraction)", default=1.0, min=0.0, max=1.0, + doc="Fraction of the maximum speed can be reached when driving here" ) } PARTICLE_PROPERTIES = { 'particle_base' : StkProperty( id='particle_base', name="Particles file", default="smoke.xml"), 'particle_condition' : StkCombinableEnumProperty( id='particle_condition', name="Use particles when...", default="skid", - contextLevel=CONTEXT_MATERIAL, values={'skid' : StkEnumChoice('Skid',{}, docs="Use particle when skidding"), - 'drive' : StkEnumChoice('Drive',{}, docs="Use particles during regular driving")}) + contextLevel=CONTEXT_MATERIAL, values={'skid' : StkEnumChoice('Skid',{}, doc="Use particle when skidding"), + 'drive' : StkEnumChoice('Drive',{}, doc="Use particles during regular driving")}) } long_names = ['zipper_max_speed_increase', "Zipper max speed increase", 'zipper_fade_out_time', "Zipper fade out time"] ZIPPER_PROPERTIES = { - 'zipper_duration' : StkFloatProperty( id='zipper_duration', name="Zipper duration", default=3.5), - long_names[0] : StkFloatProperty( id=long_names[0], name=long_names[1], default=15.0), - long_names[2] : StkFloatProperty( id=long_names[2], name=long_names[3], default=3.0), - 'zipper_speed_gain' : StkFloatProperty( id='zipper_speed_gain', name="Zipper speed gain", default=4.5) + 'zipper_duration' : StkFloatProperty( id='zipper_duration', name="Zipper duration", default=3.5, min=0.0, max=10.0), + long_names[0] : StkFloatProperty( id=long_names[0], name=long_names[1], default=15.0, min=0.0, max=25.0), + long_names[2] : StkFloatProperty( id=long_names[2], name=long_names[3], default=3.0, min=0.0, max=10.0), + 'zipper_speed_gain' : StkFloatProperty( id='zipper_speed_gain', name="Zipper speed gain", default=4.5, min=0.0, max=10.0) } # TODO: only enable rolloff if positional is checked @@ -606,10 +677,14 @@ ('sfx_filename' , StkProperty( id='sfx_filename', name="Sound File", default="some_file.ogg")), ('sfx_min_speed' , StkFloatProperty( id='sfx_min_speed', name="Minimum kart speed", default=0.0)), ('sfx_max_speed' , StkFloatProperty( id='sfx_max_speed', name="Maximum kart speed", default=0.0)), - ('sfx_min_pitch' , StkFloatProperty( id='sfx_min_pitch', name="Sound pitch at min speed", default=0.8)), - ('sfx_max_pitch' , StkFloatProperty( id='sfx_max_pitch', name="Sound pitch at max speed", default=1.2)), - ('sfx_positional', StkBoolProperty( id='sfx_positional', name="Positional sound effect", default="true", contextLevel=CONTEXT_MATERIAL, docs="If true, the sound will get dimmer when far from camera, and with panning; if false, it's heard at centered pan and at full volume")), - ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1)) + ('sfx_min_pitch' , StkFloatProperty( id='sfx_min_pitch', name="Sound pitch at min speed", default=0.8, min=0.1, max=3.0, + doc="Pitch of the sound when the kart is going slowly (1.0 is no change, < 1.0 is lower pitch, > 1.0 is higher pitch)")), + ('sfx_max_pitch' , StkFloatProperty( id='sfx_max_pitch', name="Sound pitch at max speed", default=1.2, min=0.1, max=3.0, + doc="Pitch of the sound when the kart is going fastly (1.0 is no change, < 1.0 is lower pitch, > 1.0 is higher pitch)")), + ('sfx_positional', StkBoolProperty( id='sfx_positional', name="Positional sound effect", default="true", contextLevel=CONTEXT_MATERIAL, + doc="If true, the sound will get dimmer when far from camera, and with panning; if false, it's heard at centered pan and at full volume")), + ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1, min=0.0, max=5.0, + doc="Speed at which the sound fades out as you stand further from the sound emitter")) ]) CRASH_RESET_PROPERTIES = OrderedDict([ @@ -617,26 +692,46 @@ ]) STK_MATERIAL_PROPERTIES = OrderedDict([ - ('light', StkBoolProperty( id='light', name="Affected by lights", default="true", contextLevel=CONTEXT_MATERIAL, docs="Whether this material is affected by lgihts and shadows")), - ('backface_culling', StkBoolProperty( id='backface_culling', name="Backface Culling", default="true", contextLevel=CONTEXT_MATERIAL, docs="If checked, this material will only be visible on the side of the normal")), - ('below_surface', StkBoolProperty( id='below_surface', name="Below Surface", default="false", contextLevel=CONTEXT_MATERIAL, docs="Used for the terrain under shallow water where you can drive")), - ('compositing', StkEnumProperty( id='compositing', name="Compsiting Type", default='none', contextLevel=CONTEXT_MATERIAL, values=COMPOSITING_VALUES, docs="How to composite this texture with what is behind it")), - ('clampu', StkBoolProperty( id='clampu', name="Clamp texture horizontally", default="false", contextLevel=CONTEXT_MATERIAL, docs="if checked, this texture will not be repeated horizontally (if the UV texturing goes beyond the texture bounds)")), - ('clampv', StkBoolProperty( id='clampv', name="Clamp texture vertically", default="false", contextLevel=CONTEXT_MATERIAL, docs="if checked, this texture will not be repeated vertically (if the UV texturing goes beyond the texture bounds)")), - ('disable_z_write', StkBoolProperty( id='disable_z_write', name="Disable writing to Z-buffer",default="false", contextLevel=CONTEXT_MATERIAL, docs="disable writing to the Z buffer (useful for materials with transparency, if irrlicht fails to do proper alpha sorting, in order not to hide what is behind)")), - ('use_slowdown', StkBoolProperty( id='use_slowdown', name="Enable Slowdown", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SLOWDOWN_PROPERTIES, docs="Whether to slow down the kart when driving on this material")), - ('falling_effect', StkBoolProperty( id='falling_effect', name="Falling Effect", default="false", contextLevel=CONTEXT_MATERIAL, docs="Whether this material is the bottom of a pit (then camera will look down at kart falling when over it)")), - ('graphical_effect', StkEnumProperty( id='graphical_effect', name="Graphical Effect", default='none', contextLevel=CONTEXT_MATERIAL, values=GFX_VALUES, docs="Select a special graphical effect")), - ('high_adhesion', StkBoolProperty( id='high_adhesion', name="High tires adhesion", default="false", contextLevel=CONTEXT_MATERIAL, docs="If checked, karts will have good grip on this surface and not slip, even at angles")), - ('ignore', StkBoolProperty( id='ignore', name="Ignore (ghost material)", default="false", contextLevel=CONTEXT_MATERIAL, docs="Drive through this texture like it didn't exist (good for smoke, etc.)")), - ('mask', StkProperty( id='mask', name="Mask image", default="")), - ('particle', StkBoolProperty( id='particle', name="Particle effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=PARTICLE_PROPERTIES, docs="Whether to emit particles (e.g. smoke) when driving on this surface")), - ('use_sfx', StkBoolProperty( id='use_sfx', name="Play sound effect", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=SFX_PROPERTIES, docs="Whether to play a sound when driving on this surface")), - ('reset', StkBoolProperty( id='reset', name="Reset kart (on drive)", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether to rescue kart if it ends up [driving] on this surface")), - ('crash_reset', StkBoolProperty( id='crash_reset', name="Reset kart (on touch)", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=CRASH_RESET_PROPERTIES, docs="whether to rescue kart if it touches/hits this material in any way")), - ('sphere', StkBoolProperty( id='sphere', name="Sphere mapping", default="false", contextLevel=CONTEXT_MATERIAL, docs="use sphere mapping on this object (mainly used to simulate a reflection effect)")), - ('surface', StkBoolProperty( id='surface', name="Surface", default="false", contextLevel=CONTEXT_MATERIAL, docs="whether this material is the surface of a water area")), - ('zipper', StkBoolProperty( id='zipper', name="Zipper (speed boost)", default="false", contextLevel=CONTEXT_MATERIAL, subproperties=ZIPPER_PROPERTIES, docs="Whether to get a speed boost when driving on this surface")) + ('light', StkBoolProperty( id='light', name="Affected by lights", default="true", contextLevel=CONTEXT_MATERIAL, + doc="Whether this material is affected by lgihts and shadows")), + ('backface_culling', StkBoolProperty( id='backface_culling', name="Backface Culling", default="true", contextLevel=CONTEXT_MATERIAL, + doc="If checked, this material will only be visible on the side of the normal")), + ('below_surface', StkBoolProperty( id='below_surface', name="Below Surface", default="false", contextLevel=CONTEXT_MATERIAL, + doc="Used for the terrain under shallow water where you can drive")), + ('compositing', StkEnumProperty( id='compositing', name="Compsiting Type", default='none', contextLevel=CONTEXT_MATERIAL, + values=COMPOSITING_VALUES, doc="How to composite this texture with what is behind it")), + ('clampu', StkBoolProperty( id='clampu', name="Clamp texture horizontally", default="false", contextLevel=CONTEXT_MATERIAL, + doc="if checked, this texture will not be repeated horizontally (if the UV texturing goes beyond the texture bounds)")), + ('clampv', StkBoolProperty( id='clampv', name="Clamp texture vertically", default="false", contextLevel=CONTEXT_MATERIAL, + doc="if checked, this texture will not be repeated vertically (if the UV texturing goes beyond the texture bounds)")), + ('disable_z_write', StkBoolProperty( id='disable_z_write', name="Disable writing to Z-buffer",default="false", contextLevel=CONTEXT_MATERIAL, + doc="disable writing to the Z buffer (useful for materials with transparency, if irrlicht fails to do proper alpha sorting, in order not to hide what is behind)")), + ('use_slowdown', StkBoolProperty( id='use_slowdown', name="Enable Slowdown", default="false", contextLevel=CONTEXT_MATERIAL, + subproperties=SLOWDOWN_PROPERTIES, doc="Whether to slow down the kart when driving on this material")), + ('falling_effect', StkBoolProperty( id='falling_effect', name="Falling Effect", default="false", contextLevel=CONTEXT_MATERIAL, + doc="Whether this material is the bottom of a pit (then camera will look down at kart falling when over it)")), + ('graphical_effect', StkEnumProperty( id='graphical_effect', name="Graphical Effect", default='none', contextLevel=CONTEXT_MATERIAL, + values=GFX_VALUES, doc="Select a special graphical effect")), + ('high_adhesion', StkBoolProperty( id='high_adhesion', name="High tires adhesion", default="false", contextLevel=CONTEXT_MATERIAL, + doc="If checked, karts will have good grip on this surface and not slip, even at angles")), + ('ignore', StkBoolProperty( id='ignore', name="Ignore (ghost material)", default="false", contextLevel=CONTEXT_MATERIAL, + doc="Drive through this texture like it didn't exist (good for smoke, etc.)")), + ('mask', StkProperty( id='mask', name="Mask image", default="", + doc="Greyscale image containing the alpha channel (transparency) for this image")), + ('particle', StkBoolProperty( id='particle', name="Particle effect", default="false", contextLevel=CONTEXT_MATERIAL, + subproperties=PARTICLE_PROPERTIES, doc="Whether to emit particles (e.g. smoke) when driving on this surface")), + ('use_sfx', StkBoolProperty( id='use_sfx', name="Play sound effect", default="false", contextLevel=CONTEXT_MATERIAL, + subproperties=SFX_PROPERTIES, doc="Whether to play a sound when driving on this surface")), + ('reset', StkBoolProperty( id='reset', name="Reset kart (on drive)", default="false", contextLevel=CONTEXT_MATERIAL, + doc="whether to rescue kart if it ends up [driving] on this surface")), + ('crash_reset', StkBoolProperty( id='crash_reset', name="Reset kart (on touch)", default="false", contextLevel=CONTEXT_MATERIAL, + subproperties=CRASH_RESET_PROPERTIES, doc="whether to rescue kart if it touches/hits this material in any way")), + ('sphere', StkBoolProperty( id='sphere', name="Sphere mapping", default="false", contextLevel=CONTEXT_MATERIAL, + doc="use sphere mapping on this object (mainly used to simulate a reflection effect)")), + ('surface', StkBoolProperty( id='surface', name="Surface", default="false", contextLevel=CONTEXT_MATERIAL, + doc="whether this material is the surface of a water area")), + ('zipper', StkBoolProperty( id='zipper', name="Zipper (speed boost)", default="false", contextLevel=CONTEXT_MATERIAL, + subproperties=ZIPPER_PROPERTIES, doc="Whether to get a speed boost when driving on this surface")) ]) ENGINE_SOUNDS = {'large' : StkEnumChoice("Large", {}), @@ -647,19 +742,27 @@ STK_KART_PROPERTIES = OrderedDict([ ('name', StkProperty( id='name', name='Name', default='My New Kart')), ('group', StkProperty( id='group', name='Group', default='standard')), - ('icon', StkProperty( id='icon', name='Icon', default='icon.png')), - ('minimap_icon', StkProperty( id='minimap_icon', name='Minimap Icon', default='icon.png')), - ('shadow', StkProperty( id='shadow', name='Shadow', default='generic_shadow.png')), - ('color', StkColorProperty( id='color', name="Color", default="255 255 255", contextLevel=CONTEXT_SCENE)), - ('center_shift', StkFloatProperty( id='center_shift', name="Gravity Center Shift", default=0.0)), - ('engine_sfx', StkEnumProperty( id='engine_sfx', name='Engine sound', default='large', contextLevel=CONTEXT_SCENE, values=ENGINE_SOUNDS)) + ('icon', StkProperty( id='icon', name='Icon', default='icon.png', + doc="Filename of the icon to display in the kart selection screen")), + ('minimap_icon', StkProperty( id='minimap_icon', name='Minimap Icon', default='icon.png', + doc="Filename of the icon to display on the minimap")), + ('shadow', StkProperty( id='shadow', name='Shadow', default='generic_shadow.png', + doc="Filename of the file containing the shadow of this kart")), + ('color', StkColorProperty( id='color', name="Color", default="255 255 255", contextLevel=CONTEXT_SCENE, + doc="Color used to highlight the kart's icon in the interface")), + ('center_shift', StkFloatProperty( id='center_shift', name="Gravity Center Shift", default=0.0, + doc="Can be used to lower the gravity center of the kart if it topples over too easily")), + ('engine_sfx', StkEnumProperty( id='engine_sfx', name='Engine sound', default='large', contextLevel=CONTEXT_SCENE, + values=ENGINE_SOUNDS)) ]) SCENE_PROPS = {'is_stk_track' : StkBoolProperty(id='is_stk_track', name='Is a SuperTuxKart track', default='false', contextLevel=CONTEXT_SCENE, - subproperties=STK_TRACK_WIDE_PROPERTIES, box=False, docs="Check this if this blender file is a SuperTuxKart track"), + subproperties=STK_TRACK_WIDE_PROPERTIES, box=False, + doc="Check this if this blender file is a SuperTuxKart track"), 'is_stk_kart' : StkBoolProperty(id='is_stk_kart', name='Is a SuperTuxKart kart', default='false', contextLevel=CONTEXT_SCENE, - subproperties=STK_KART_PROPERTIES, box=False, docs="Check this if this blender file is a SuperTuxKart kart")} + subproperties=STK_KART_PROPERTIES, box=False, + doc="Check this if this blender file is a SuperTuxKart kart")} # ==== PANEL BASE ==== class PanelBase: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-31 00:47:05
|
Revision: 9683 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9683&view=rev Author: auria Date: 2011-08-31 00:46:58 +0000 (Wed, 31 Aug 2011) Log Message: ----------- Add support for min and max values in properties Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-08-31 00:27:49 UTC (rev 9682) +++ media/trunk/blender_25/stk_panel.py 2011-08-31 00:46:58 UTC (rev 9683) @@ -118,24 +118,6 @@ for p in props.keys(): - rna_ui_dict = {} - try: - rna_ui_dict["description"] = props[p].doc - except: - pass - - try: - if p.min is not None: rna_ui_dict["min"] = props[p].min - except: - pass - - try: - if p.max is not None: rna_ui_dict["max"] = props[p].max - except: - pass - - object["_RNA_UI"][p] = rna_ui_dict - if not p in object: # create property by setting default value @@ -169,6 +151,31 @@ except: object[p] = props[p].default + + rna_ui_dict = {} + try: + rna_ui_dict["description"] = props[p].doc + except: + pass + + try: + if props[p].min is not None: + rna_ui_dict["min"] = props[p].min + rna_ui_dict["soft_min"] = rops[p].min + except: + pass + + try: + if props[p].max is not None: + rna_ui_dict["max"] = props[p].max + rna_ui_dict["soft_max"] = props[p].max + except: + pass + + print(p,"~~>",rna_ui_dict) + object["_RNA_UI"][p] = rna_ui_dict + + #! An enum property class StkEnumProperty(StkProperty): @@ -527,7 +534,7 @@ ('sfx_filename' , StkProperty( id='sfx_filename', name="Sound File", default="some_file.ogg", doc="Filename of the sound to play")), ('sfx_volume' , StkFloatProperty( id='sfx_volume', name="Sound volume", default=1.0, min=0.0, max=1.0)), - ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1, min=0.0, max=5.0, + ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1, min=0.0, max=2.5, doc="How fast this osund decays when going farther from the emission point"))]), doc="A sound will be heard when close to this point"), 'sun' : StkEnumChoice('Sun', @@ -683,7 +690,7 @@ doc="Pitch of the sound when the kart is going fastly (1.0 is no change, < 1.0 is lower pitch, > 1.0 is higher pitch)")), ('sfx_positional', StkBoolProperty( id='sfx_positional', name="Positional sound effect", default="true", contextLevel=CONTEXT_MATERIAL, doc="If true, the sound will get dimmer when far from camera, and with panning; if false, it's heard at centered pan and at full volume")), - ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1, min=0.0, max=5.0, + ('sfx_rolloff' , StkFloatProperty( id='sfx_rolloff', name="Rolloff rate", default=0.1, min=0.0, max=2.5, doc="Speed at which the sound fades out as you stand further from the sound emitter")) ]) @@ -847,7 +854,10 @@ # String or int or float property (Blender chooses the correct widget from the type of the ID-property) if curr.id in obj: - row.prop(obj, '["' + curr.id + '"]', text="") + if "min" in dir(curr) and "max" in dir(curr): + row.prop(obj, '["' + curr.id + '"]', text="", slider=True) + else: + row.prop(obj, '["' + curr.id + '"]', text="") # ==== OBJECT PANEL ==== class SuperTuxKartObjectPanel(bpy.types.Panel, PanelBase): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-31 00:53:14
|
Revision: 9684 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9684&view=rev Author: auria Date: 2011-08-31 00:53:08 +0000 (Wed, 31 Aug 2011) Log Message: ----------- More improvements to self-documentation in the panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-08-31 00:46:58 UTC (rev 9683) +++ media/trunk/blender_25/stk_panel.py 2011-08-31 00:53:08 UTC (rev 9684) @@ -587,10 +587,15 @@ ('sky_texture' , StkProperty(id='sky_texture', name='Sky Texture', default="")), ('sky_horizontal' , StkIntProperty(id='sky_horizontal', name='Horizontal Definition', default=20)), ('sky_vertical' , StkIntProperty(id='sky_vertical', name='Vertical Definition', default=20)), - ('sky_texture_percent', StkFloatProperty(id='sky_texture_percent', name='Sky Texture Percent', default=1.0)), - ('sky_sphere_percent' , StkFloatProperty(id='sky_sphere_percent', name='Sky Sphere Percent', default=1.3)), - ('sky_speed_x' , StkFloatProperty(id='sky_speed_x', name='Sky Speed X', default=0.0)), - ('sky_speed_y' , StkFloatProperty(id='sky_speed_y', name='Sky Speed Y', default=0.0))])), + ('sky_texture_percent', StkFloatProperty(id='sky_texture_percent', name='Sky Texture Percent', default=1.0, min=0.0, max=1.0, + doc="How much of the height of the texture is used")), + ('sky_sphere_percent' , StkFloatProperty(id='sky_sphere_percent', name='Sky Sphere Percent', default=1.3, min=0.0, max=2.0, + doc="1.0 : half-sphere; 2.0 : full sphere")), + ('sky_speed_x' , StkFloatProperty(id='sky_speed_x', name='Sky Speed X', default=0.0, min=0.0, max=10.0, + doc="Speed at which the sky moves horizontally")), + ('sky_speed_y' , StkFloatProperty(id='sky_speed_y', name='Sky Speed Y', default=0.0, min=0.0, max=10.0, + doc="Speed at which the sky moves vertically")) + ])), 'simple' : StkEnumChoice('Plain color', {'sky_color' : StkColorProperty(id="sky_color", name="Sky Color", default="77 104 255", contextLevel=CONTEXT_SCENE, doc="Click here to select the color of the sky")}, @@ -854,7 +859,7 @@ # String or int or float property (Blender chooses the correct widget from the type of the ID-property) if curr.id in obj: - if "min" in dir(curr) and "max" in dir(curr): + if "min" in dir(curr) and "max" in dir(curr) and curr.min is not None and curr.max is not None: row.prop(obj, '["' + curr.id + '"]', text="", slider=True) else: row.prop(obj, '["' + curr.id + '"]', text="") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-08-31 21:06:35
|
Revision: 9685 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9685&view=rev Author: auria Date: 2011-08-31 21:06:28 +0000 (Wed, 31 Aug 2011) Log Message: ----------- Make panel code more flexible, better documented, and extend LOD to now offer a dropdown with LOD-group choices Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-08-31 00:53:08 UTC (rev 9684) +++ media/trunk/blender_25/stk_panel.py 2011-08-31 21:06:28 UTC (rev 9685) @@ -33,7 +33,6 @@ return None -# ==== TYPE OPERATORS ==== class STK_TypeUnset(bpy.types.Operator): bl_idname = ("screen.stk_unset_type") bl_label = ("STK Object :: unset type") @@ -43,74 +42,11 @@ obj["type"] = "" return {'FINISHED'} -#! @see StkEnumProperty -class StkEnumChoice: - - #! @param name User-visible name for this property - #! @param subproperties A dictionary of type { 'name' : StkProperty(...) }. Contains the - # properties that are to be shown when this enum item is selected - def __init__(self, name, subproperties, doc="(No documentation was defined for this item)"): - self.name = name - self.subproperties = subproperties - self.__doc__ = doc - self.doc = doc - -#! The base class for all properties -class StkProperty: - def __init__(self, id, name, default, doc="(No documentation was defined for this item)"): - self.name = name - self.id = id - self.default = default - self.doc = doc - - -class StkObjectReferenceProperty(StkProperty): - - def __init__(self, id, name, contextLevel, default, filter, doc="Select an object"): - super(StkObjectReferenceProperty, self).__init__(id, name, default) - self.doc = doc - - class SelectObjectOperator(bpy.types.Operator): - bl_idname = "scene.stk_select_object_" + id - bl_label = "Select Object Operator" - __doc__ = doc - - m_id = id - m_context_level = contextLevel - - # name of the object to select - name = bpy.props.StringProperty() - - def execute(self, context): - object = getObject(context, self.m_context_level) - object[self.m_id] = self.name - return {'FINISHED'} - - bpy.utils.register_class(SelectObjectOperator) - - class ObjectPickerMenu(bpy.types.Menu): - m_filter = filter - bl_idname = "screen.stk_object_menu_" + id - bl_label = ("SuperTuxKart Object Picker Menu (" + id + ")") - m_property_id = id - - def draw(self, context): - objects = context.scene.objects - - layout = self.layout - for object in objects: - if self.m_filter(object): - text = object.name - object_id = object.name - if 'name' in object: - text = text + " (" + object["name"] + ")" - object_id = object["name"] - layout.operator("scene.stk_select_object_"+self.m_property_id, text=text).name=object_id - layout.operator("scene.stk_select_object_"+self.m_property_id, text="Lap").name="lap" - - - bpy.utils.register_class(ObjectPickerMenu) - +# ------------------------------------------------------------------------------ +#! Utility function, creates all properties in a given object +#! +#! object the object to create properties in +#! props a list of properties to create def createProperties(object, props): if not "_RNA_UI" in object: @@ -172,11 +108,128 @@ except: pass - print(p,"~~>",rna_ui_dict) object["_RNA_UI"][p] = rna_ui_dict +# ------------------------------------------------------------------------------ +#! The base class for all properties. +#! If you use this property directly (and not a subclass), you get a simple text box +class StkProperty: + def __init__(self, id, name, default, doc="(No documentation was defined for this item)"): + self.name = name + self.id = id + self.default = default + self.doc = doc + + +# ------------------------------------------------------------------------------ +#! A text field where you can type a reference to another object (or a property +#! of another object) with an optional dropdown button to see current choices +#! +#! id the id of the blender id-property +#! name user-visible name +#! contextLevel object, scene, material level? +#! default default value for this property +#! filter a lambda taking arguments "self" and "object", and that returns +#! parameter 'object' is to be displayed in the dropdown of this property +#! doc documentation to show in the tooltip +#! static_objects items to append to the menu unconditionally (a list of tuples of +#! form 'id', 'visible name') +#! unique_id_suffix if the blender id-property name is not unique, you can append a +#! custom suffix here to make sure the 2 same-name properties each have +#! their own dropdown (e.g. 'activate' for a checkline object and +#! 'activate' for a lapline) +#! obj_identifier a lambda taking arguments "self" and "object", and that returns +#! the id (value) of an object that should be put in this property when +#! the object is selected +#! obj_text a lambda taking arguments "self" and "object", and that returns +#! the user-visible string to apear in the dropdown for an object +class StkObjectReferenceProperty(StkProperty): + + def __init__(self, id, name, contextLevel, default, filter, doc="Select an object", + static_objects=[], unique_id_suffix = "", + obj_identifier=lambda self, obj: obj.name, + obj_text=lambda self, obj: (obj.name + (" (" + obj["name"] + ")") if "name" in obj else "")): + super(StkObjectReferenceProperty, self).__init__(id, name, default) + self.doc = doc + self.unique_id_suffix = unique_id_suffix + + print("CTOR ",id + unique_id_suffix," static_objects = ", static_objects) + + class SelectObjectOperator(bpy.types.Operator): + bl_idname = "scene.stk_select_object_" + id + unique_id_suffix + bl_label = "Select Object Operator" + __doc__ = doc + + m_id = id + m_context_level = contextLevel + + # name of the object to select + name = bpy.props.StringProperty() + + def execute(self, context): + object = getObject(context, self.m_context_level) + object[self.m_id] = self.name + return {'FINISHED'} + + bpy.utils.register_class(SelectObjectOperator) + + class ObjectPickerMenu(bpy.types.Menu): + m_filter = filter + m_obj_identifier = obj_identifier + m_obj_text = obj_text + m_static_objects = static_objects + bl_idname = "screen.stk_object_menu_" + id + unique_id_suffix + bl_label = ("SuperTuxKart Object Picker Menu (" + id + unique_id_suffix + ")") + m_property_id = id + unique_id_suffix + + def draw(self, context): + objects = context.scene.objects + + seen_objs = {} + + layout = self.layout + for object in objects: + if self.m_filter(object): + text = self.m_obj_text(object) + object_id = self.m_obj_identifier(object) + + if object_id is not None and object_id not in seen_objs: + layout.operator("scene.stk_select_object_"+self.m_property_id, text=text).name = object_id + seen_objs[object_id] = True + + print(self.bl_idname," :: self.m_static_objects =", self.m_static_objects) + for curr in self.m_static_objects: + layout.operator("scene.stk_select_object_"+self.m_property_id, text=curr[1]).name=curr[0] + + + bpy.utils.register_class(ObjectPickerMenu) + +# ------------------------------------------------------------------------------ +#! One entry in a StkEnumProperty +class StkEnumChoice: + + #! @param name User-visible name for this property + #! @param subproperties A dictionary of type { 'name' : StkProperty(...) }. Contains the + # properties that are to be shown when this enum item is selected + def __init__(self, name, subproperties, doc="(No documentation was defined for this item)"): + self.name = name + self.subproperties = subproperties + self.__doc__ = doc + self.doc = doc + +# ------------------------------------------------------------------------------ #! An enum property +#! +#! id the id of the blender id-property +#! name user-visible name +#! values the choices offered by this enum, as a list of 'StkEnumChoice' objects +#! contextLevel object, scene, material level? +#! default default value for this property +#! unique_prefix if the blender id-property name is not unique, you can prepend a +#! custom prefix here to make sure the 2 same-name properties each have +#! their own dropdown (e.g. 'activate' for a checkline object and +#! 'activate' for a lapline) class StkEnumProperty(StkProperty): def getOperatorName(self): @@ -232,7 +285,16 @@ bpy.utils.register_class(STK_SetComboValue) -#! A combinable enum property +# ------------------------------------------------------------------------------ +#! A combinable enum property (each value can be checked or unchecked, and +#! several values can be selected at once. gives a text property containing +#! the IDs of the selected values, separated by spaces) +#! +#! id the id of the blender id-property +#! name user-visible name +#! values the choices offered by this enum, as a list of 'StkEnumChoice' objects +#! contextLevel object, scene, material level? +#! default default value for this property class StkCombinableEnumProperty(StkProperty): #! @param name User-visible name for this property @@ -285,8 +347,17 @@ return {'FINISHED'} bpy.utils.register_class(STK_SetEnumComboValue) - + + +# ------------------------------------------------------------------------------ #! A floating-point property +#! +#! id the id of the blender id-property +#! name user-visible name +#! default default value for this property +#! doc documentation shown to the user in a tooltip +#! min minimum accepted value +#! max maximum accepted value class StkFloatProperty(StkProperty): #! @param name User-visible name for this property @@ -298,7 +369,15 @@ self.max = max +# ------------------------------------------------------------------------------ #! An integer property +#! +#! id the id of the blender id-property +#! name user-visible name +#! default default value for this property +#! doc documentation shown to the user in a tooltip +#! min minimum accepted value +#! max maximum accepted value class StkIntProperty(StkProperty): #! @param name User-visible name for this property @@ -308,7 +387,19 @@ self.min = min self.max = max -#! A boolean property + +# ------------------------------------------------------------------------------ +#! A boolean property (appears as a checkbox) +#! +#! id the id of the blender id-property +#! name user-visible name +#! contextLevel object, scene, material level? +#! default default value for this property +#! subproperties a map of format {id : StkProperty} that specifies subproperties +#! to activate when this checkbox is checked +#! box if True, the properties from 'subproperties' are displayed in +#! a box +#! doc documentation shown to the user in a tooltip class StkBoolProperty(StkProperty): # (self, id, name, values, default): @@ -362,7 +453,15 @@ bpy.utils.register_class(STK_ToggleBoolValue) + +# ------------------------------------------------------------------------------ #! A color property +#! +#! id the id of the blender id-property +#! name user-visible name +#! contextLevel object, scene, material level? +#! default default value for this property +#! doc documentation shown to the user in a tooltip class StkColorProperty(StkProperty): #! A floating-point property @@ -445,6 +544,11 @@ camera_properties = {'start' : StkFloatProperty(id='start', name="Start Sphere Radius", default=10.0) } + +# ------------------------------------------------------------------------------ +# THE PROPERTIES +# ------------------------------------------------------------------------------ + # Property when type="object" object_properties = OrderedDict([ ('name' , StkProperty('name', "Name", "", doc="Name of this object (objects with the same name are exported as a single file)")), @@ -479,7 +583,8 @@ 'billboard' : StkEnumChoice('Billboard', {}, doc="A flat quad that will always face the camera"), 'check' : StkEnumChoice('Checkline', OrderedDict([ ('name' , StkProperty(id='name', name="Name", default="", doc="Name of the checkline")), - ('activate', StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, + ('activate', StkObjectReferenceProperty(id='activate', unique_id_suffix="_checkline", name="Activate", default="", + contextLevel=CONTEXT_OBJECT, static_objects=[("lap","Lap")], filter=lambda self, o : 'type' in o and o['type'] == 'check', doc="Which check structure to activate when crossing this checkline")) #'toggle' : Stkproperty("Toggle"), @@ -493,7 +598,8 @@ contextLevel=CONTEXT_OBJECT, doc="If checked, AIs will not drive on this path") }, doc="Driveline used to mark an alternate path"), 'maindriveline' : StkEnumChoice('Driveline (main)', - {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, + {'activate' : StkObjectReferenceProperty(id='activate', unique_id_suffix="_maindriveline", name="Activate", default="", + contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check', doc="Which check structure to activate when crossing the lap line") }), @@ -502,7 +608,8 @@ 'ignore' : StkEnumChoice('Ignore', {}, doc="An object that is not exported and will not appear in-game"), 'item' : StkEnumChoice('Item (Gift Box)', {}, doc="A gift box containing a random collectible (apply to an Empty)"), 'lap' : StkEnumChoice('Lap line', - {'activate' : StkObjectReferenceProperty(id='activate', name="Activate", default="", contextLevel=CONTEXT_OBJECT, + {'activate' : StkObjectReferenceProperty(id='activate', unique_id_suffix="_lap", name="Activate", default="", + contextLevel=CONTEXT_OBJECT, filter=lambda self, o : 'type' in o and o['type'] == 'check', doc="Which check structure to activate when crossing the lap line") #'toggle' : Stkproperty("Toggle"), @@ -510,8 +617,12 @@ #'color' : }, doc="An extension to the factory lap line"), 'lod_instance' : StkEnumChoice('LOD Instance', - {'lod_name' : StkProperty( id='lod_name', name="LOD Group Name", default="SomeModel", - doc="Name of the LOD group this object is an instance of") + {'lod_name' : StkObjectReferenceProperty( id='lod_name', name="LOD Group Name", default="SomeModel", + doc="Name of the LOD group this object is an instance of", + contextLevel=CONTEXT_OBJECT, + filter=lambda self, o: "lod_name" in o, + obj_identifier=lambda self, o : o["lod_name"], + obj_text=lambda self, o : o["lod_name"]) }, doc="A LOD (level-of-detail) instance, will display either of the LOD Models in this LOD group at this location"), 'lod_model' : StkEnumChoice('LOD Model', {'lod_distance' : StkFloatProperty( id='lod_distance', name="Distance", default=60.0, min=0.0, max=5000.0, @@ -852,7 +963,7 @@ if curr.id in obj: row.prop(obj, '["' + curr.id + '"]', text="") - row.menu("screen.stk_object_menu_" + curr.id, text="", icon='TRIA_DOWN') + row.menu("screen.stk_object_menu_" + curr.id + curr.unique_id_suffix, text="", icon='TRIA_DOWN') else: row.label(text=curr.name) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-09-01 15:47:01
|
Revision: 9702 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9702&view=rev Author: auria Date: 2011-09-01 15:46:54 +0000 (Thu, 01 Sep 2011) Log Message: ----------- Minor improvements to docs in panel Modified Paths: -------------- media/trunk/blender_25/stk_panel.py Modified: media/trunk/blender_25/stk_panel.py =================================================================== --- media/trunk/blender_25/stk_panel.py 2011-09-01 14:56:17 UTC (rev 9701) +++ media/trunk/blender_25/stk_panel.py 2011-09-01 15:46:54 UTC (rev 9702) @@ -205,6 +205,7 @@ bpy.utils.register_class(ObjectPickerMenu) + # ------------------------------------------------------------------------------ #! One entry in a StkEnumProperty class StkEnumChoice: @@ -215,9 +216,9 @@ def __init__(self, name, subproperties, doc="(No documentation was defined for this item)"): self.name = name self.subproperties = subproperties - self.__doc__ = doc self.doc = doc + # ------------------------------------------------------------------------------ #! An enum property #! @@ -317,8 +318,10 @@ bl_idname = ("screen.stk_set_"+id+"_"+curr) bl_label = ("SuperTuxKart set "+id+" = " + curr) - __doc__ = values[curr].__doc__ + "" + if values[curr].doc is not None: + __doc__ = values[curr].doc + "" + m_property_id = id m_items_val = values_for_blender m_values = values @@ -779,7 +782,8 @@ } PARTICLE_PROPERTIES = { - 'particle_base' : StkProperty( id='particle_base', name="Particles file", default="smoke.xml"), + 'particle_base' : StkProperty( id='particle_base', name="Particles file", default="smoke.xml", + doc="Name of the XML file containing the description of particles to use on this terrain"), 'particle_condition' : StkCombinableEnumProperty( id='particle_condition', name="Use particles when...", default="skid", contextLevel=CONTEXT_MATERIAL, values={'skid' : StkEnumChoice('Skid',{}, doc="Use particle when skidding"), 'drive' : StkEnumChoice('Drive',{}, doc="Use particles during regular driving")}) @@ -1029,7 +1033,7 @@ import os -class ImagePickerMenu(bpy.types.Menu): +class ImagePickerMenu(bpy.types.Menu): bl_idname = "scene.stk_image_menu" bl_label = "SuperTuxKart Image Menu" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |