80 lines
2.4 KiB
Python
80 lines
2.4 KiB
Python
import bpy
|
|
from .panels import update_panel
|
|
from . import fn
|
|
class AW_OT_open_addon_prefs(bpy.types.Operator):
|
|
bl_idname = "autowalk.open_addon_prefs"
|
|
bl_label = "Open Addon Prefs"
|
|
bl_description = "Open user preferences window in addon tab and prefill the search with addon name"
|
|
bl_options = {"REGISTER", "INTERNAL"}
|
|
|
|
def execute(self, context):
|
|
fn.open_addon_prefs()
|
|
return {'FINISHED'}
|
|
|
|
class AW_addon_prefs(bpy.types.AddonPreferences):
|
|
## can be just __name__ if prefs are in the __init__ mainfile
|
|
# Else need the splitext '__name__ = addonname.subfile' (or use a static name)
|
|
bl_idname = __name__.split('.')[0] # or with: os.path.splitext(__name__)[0]
|
|
|
|
category : bpy.props.StringProperty(
|
|
name="Category",
|
|
description="Choose a name for the category of the panel",
|
|
default="Walk",
|
|
update=update_panel)
|
|
|
|
# some_bool_prop to display in the addon pref
|
|
debug : bpy.props.IntProperty(
|
|
name='Debug',
|
|
default=0,
|
|
description="Enable Debug prints\n\
|
|
0 = no prints\n\
|
|
1 = basic\n\
|
|
2 = full prints",
|
|
)
|
|
|
|
tgt_bone : bpy.props.StringProperty(
|
|
name="Constrained Pose bone name", default='world',
|
|
description="name of the bone that suppose to hold the constraint")
|
|
|
|
|
|
""" default_forward_axis : bpy.props.EnumProperty(
|
|
name='Forward Axis',
|
|
default='TRACK_NEGATIVE_Y', # Modifier default is FORWARD_X
|
|
description='Axis that points forward along the path',
|
|
items=(
|
|
('FORWARD_X', 'X', ''),
|
|
('FORWARD_Y', 'Y', ''),
|
|
('FORWARD_Z', 'Z', ''),
|
|
('TRACK_NEGATIVE_X', '-X', ''),
|
|
('TRACK_NEGATIVE_Y', '-Y', ''),
|
|
('TRACK_NEGATIVE_Z', '-Z', ''),
|
|
),
|
|
)
|
|
"""
|
|
|
|
def draw(self, context):
|
|
layout = self.layout
|
|
layout.use_property_split = True
|
|
|
|
box = layout.box()
|
|
box.prop(self, "category")
|
|
|
|
box = layout.box()
|
|
box.label(text='Curve creation parameters:')
|
|
box.prop(self, "tgt_bone")
|
|
# box.prop(self, "default_forward_axis", text='Default Forward Axis')
|
|
|
|
layout.prop(self, "debug")
|
|
|
|
classes = (
|
|
AW_addon_prefs,
|
|
AW_OT_open_addon_prefs,
|
|
)
|
|
|
|
def register():
|
|
for cls in classes:
|
|
bpy.utils.register_class(cls)
|
|
|
|
def unregister():
|
|
for cls in reversed(classes):
|
|
bpy.utils.unregister_class(cls) |