From 13f49f31017f40c137f16183780e1c706598ab2a Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 26 Dec 2012 01:25:53 +0000 Subject: BGE: Adding a maxJumps to the character controller to adjust how many jumps a character can perform before having to touch the ground. By default this is set to 1, which means a character can only jump once before having to touch the ground again. Setting this to 2 allows for double jumping. --- doc/python_api/rst/bge.types.rst | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'doc') diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index 470e1c56bac..ae03debb4f8 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -3749,6 +3749,12 @@ Types :type: float + .. attribute:: maxJumps + + The maximum number of jumps a character can perform before having to touch the ground. By default this is set to 1. 2 allows for a double jump, etc. + + :type: int + .. method:: jump() The character jumps based on it's jump speed. -- cgit v1.2.3 From 18f134304c0c6181668a0a8c22289fcaeb472432 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 29 Dec 2012 10:22:19 +0000 Subject: BGE: Adding a jumpCount to KX_CharacterWrapper. This can be used to have different logic for a single jump versus a double jump. For example, a different animation for the second jump. --- doc/python_api/rst/bge.types.rst | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'doc') diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index ae03debb4f8..a86272ddf5c 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -3755,6 +3755,12 @@ Types :type: int + .. attribute:: jumpCount + + The current jump count. This can be used to have different logic for a single jump versus a double jump. For example, a different animation for the second jump. + + :type: int + .. method:: jump() The character jumps based on it's jump speed. -- cgit v1.2.3 From 4ed4be1fc225e714e21445b82fa129c26552d449 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 29 Dec 2012 11:07:31 +0000 Subject: example use of addon preferences. --- .../examples/bpy.types.AddonPreferences.1.py | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 doc/python_api/examples/bpy.types.AddonPreferences.1.py (limited to 'doc') diff --git a/doc/python_api/examples/bpy.types.AddonPreferences.1.py b/doc/python_api/examples/bpy.types.AddonPreferences.1.py new file mode 100644 index 00000000000..08de6f4f5a9 --- /dev/null +++ b/doc/python_api/examples/bpy.types.AddonPreferences.1.py @@ -0,0 +1,70 @@ +bl_info = { + "name": "Example Addon Preferences", + "author": "Your Name Here", + "version": (1, 0), + "blender": (2, 65, 0), + "location": "SpaceBar Search -> Addon Preferences Example", + "description": "Example Addon", + "warning": "", + "wiki_url": "", + "tracker_url": "", + "category": "Object"} + + +import bpy +from bpy.types import Operator, AddonPreferences +from bpy.props import StringProperty, IntProperty, BoolProperty + + +class ExampleAddonPreferences(AddonPreferences): + bl_idname = __name__ + + filepath = StringProperty( + name="Example File Path", + subtype='FILE_PATH', + ) + number = IntProperty( + name="Example Number", + default=4, + ) + boolean = BoolProperty( + name="Example Boolean", + default=False, + ) + + def draw(self, context): + layout = self.layout + layout.label(text="This is a preferences view for our addon") + layout.prop(self, "filepath") + layout.prop(self, "number") + layout.prop(self, "boolean") + + +class OBJECT_OT_addon_prefs_example(Operator): + """Display example preferences""" + bl_idname = "object.addon_prefs_example" + bl_label = "Addon Preferences Example" + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + user_preferences = context.user_preferences + addon_prefs = user_preferences.addons[__name__].preferences + + info = ("Path: %s, Number: %d, Boolean %r" % + (addon_prefs.filepath, addon_prefs.number, addon_prefs.boolean)) + + self.report({'INFO'}, info) + print(info) + + return {'FINISHED'} + + +# Registration +def register(): + bpy.utils.register_class(OBJECT_OT_addon_prefs_example) + bpy.utils.register_class(ExampleAddonPreferences) + + +def unregister(): + bpy.utils.unregister_class(OBJECT_OT_addon_prefs_example) + bpy.utils.unregister_class(ExampleAddonPreferences) -- cgit v1.2.3 From e9c7aaaa3ccd83ee0bb6076f1f9fb2ac5653187f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 29 Dec 2012 18:25:03 +0000 Subject: patch [#33609] Syntax highlighting for OSL in Text Editor from Patrick Boelens (senshi). with modifications to split it into its own function. also added C style multi-line comment support /* ... */ I've left out the part of this patch that sets the language in the space, since I think this might be better stored in the text block. For now it simply uses OSL syntax highlighting when the extension is '.osl'. --- doc/python_api/sphinx_doc_gen.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'doc') diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 441a6c04efe..af6ddac937e 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -612,6 +612,10 @@ def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True): ''' function or class method to sphinx ''' + + if type(py_func) == type(bpy.types.Space.draw_handler_add): + return + arg_str = inspect.formatargspec(*inspect.getargspec(py_func)) if not is_class: -- cgit v1.2.3 From 9b9da2820bc68e11e7ccbc1941b038863cbb4e62 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 5 Jan 2013 11:14:35 +0000 Subject: Adding some example for new UIList... --- doc/python_api/examples/bpy.types.UIList.py | 89 +++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 doc/python_api/examples/bpy.types.UIList.py (limited to 'doc') diff --git a/doc/python_api/examples/bpy.types.UIList.py b/doc/python_api/examples/bpy.types.UIList.py new file mode 100644 index 00000000000..f2017e3883d --- /dev/null +++ b/doc/python_api/examples/bpy.types.UIList.py @@ -0,0 +1,89 @@ +""" +Basic UIList Example ++++++++++++++++++++ +This script is the UIList subclass used to show material slots, with a bunch of additional commentaries. + +Notice the name of the class, this naming convention is similar as the one for panels or menus. + +.. note:: + + UIList subclasses must be registered for blender to use them. +""" +import bpy + + +class MATERIAL_UL_matslots_example(bpy.types.UIList): + # The draw_item function is called for each item of the collection that is visible in the list. + # data is the RNA object containing the collection, + # item is the current drawn item of the collection, + # icon is the "computed" icon for the item (as an integer, because some objects like materials or textures + # have custom icons ID, which are not available as enum items). + # active_data is the RNA object containing the active property for the collection (i.e. integer pointing to the + # active item of the collection). + # active_propname is the name of the active property (use 'getattr(active_data, active_propname)'). + # index is index of the current item in the collection. + def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): + ob = data + slot = item + ma = slot.material + # draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code. + if self.layout_type in {'DEFAULT', 'COMPACT'}: + # You should always start your row layout by a label (icon + text), this will also make the row easily + # selectable in the list! + # We use icon_value of label, as our given icon is an integer value, not an enum ID. + layout.label(ma.name if ma else "", icon_value=icon) + # And now we can add other UI stuff... + # Here, we add nodes info if this material uses (old!) shading nodes. + if ma and not context.scene.render.use_shading_nodes: + manode = ma.active_node_material + if manode: + # The static method UILayout.icon returns the integer value of the icon ID "computed" for the given + # RNA object. + layout.label("Node %s" % manode.name, icon_value=layout.icon(manode)) + elif ma.use_nodes: + layout.label("Node ") + else: + layout.label("") + # 'GRID' layout type should be as compact as possible (typically a single icon!). + elif self.layout_type in {'GRID'}: + layout.alignment = 'CENTER' + layout.label("", icon_value=icon) + + +# And now we can use this list everywhere in Blender. Here is a small example panel. +class UIListPanelExample(bpy.types.Panel): + """Creates a Panel in the Object properties window""" + bl_label = "UIList Panel" + bl_idname = "OBJECT_PT_ui_list_example" + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "object" + + def draw(self, context): + layout = self.layout + + obj = context.object + + # template_list now takes two new args. + # The first one is the identifier of the registered UIList to use (if you want only the default list, + # with no custom draw code, use "UI_UL_list"). + layout.template_list("MATERIAL_UL_matslots_example", "", obj, "material_slots", obj, "active_material_index") + + # The second one can usually be left as an empty string. It's an additional ID used to distinguish lists in case you + # use the same list several times in a given area. + layout.template_list("MATERIAL_UL_matslots_example", "compact", obj, "material_slots", + obj, "active_material_index", type='COMPACT') + + +def register(): + bpy.utils.register_class(MATERIAL_UL_matslots_example) + bpy.utils.register_class(UIListPanelExample) + + +def unregister(): + bpy.utils.unregister_class(MATERIAL_UL_matslots_example) + bpy.utils.unregister_class(UIListPanelExample) + + +if __name__ == "__main__": + register() \ No newline at end of file -- cgit v1.2.3