Skip to content

Commit

Permalink
Version 0.31 (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustard2 authored Feb 6, 2024
1 parent a1a0faf commit d827e47
Show file tree
Hide file tree
Showing 27 changed files with 285 additions and 309 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "MustardUI",
"description": "Easy-to-use UI for human characters.",
"author": "Mustard",
"version": (0, 30, 3, 11),
"version": (0, 31, 0, 5),
"blender": (4, 0, 0),
"warning": "",
"doc_url": "https://github.com/Mustard2/MustardUI/wiki",
Expand Down
5 changes: 4 additions & 1 deletion configuration/ops_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def execute(self, context):
res, obj = mustardui_active_object(context, config=1)
rig_settings = obj.MustardUI_RigSettings
lattice_settings = obj.MustardUI_LatticeSettings
#armature_settings = obj.MustardUI_ArmatureSettings
tools_settings = obj.MustardUI_ToolsSettings
addon_prefs = context.preferences.addons["MustardUI"].preferences

Expand Down Expand Up @@ -180,6 +179,10 @@ def execute(self, context):

obj.MustardUI_created = True

# Fix for #148 - https://github.com/Mustard2/MustardUI/issues/148
for sec in rig_settings.body_custom_properties_sections:
sec.old_name = sec.name

return {'FINISHED'}


Expand Down
10 changes: 2 additions & 8 deletions custom_properties/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,19 @@ class MustardUI_CustomProperty(bpy.types.PropertyGroup):
# Outfits
# Poll function for the selection of mesh only in pointer properties
def poll_mesh(self, object):

rig_settings = self.id_data.MustardUI_RigSettings

return object.type == 'MESH' and object in [x for x in rig_settings.hair_collection.objects]

# Poll function for the selection of mesh belonging to an outfit in pointer properties
def outfit_switcher_poll_collection(self, object):

rig_settings = self.id_data.MustardUI_RigSettings

return object in [x.collection for x in rig_settings.outfits_collections if
x.collection != None] or object == rig_settings.extras_collection
x.collection is not None] or object == rig_settings.extras_collection

# Poll function for the selection of mesh belonging to an outfit in pointer properties
def outfit_switcher_poll_mesh(self, object):

rig_settings = self.id_data.MustardUI_RigSettings

if self.outfit != None:
if self.outfit is not None:
items = self.outfit.all_objects if rig_settings.outfit_config_subcollections else self.outfit.objects
if object in [x for x in items]:
return object.type == 'MESH'
Expand Down
7 changes: 4 additions & 3 deletions custom_properties/ops_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,19 @@ class MustardUI_Property_Remove(bpy.types.Operator):
@classmethod
def poll(cls, context):
res, obj = mustardui_active_object(context, config=1)
return obj != None
return obj is not None

def execute(self, context):
settings = bpy.context.scene.MustardUI_Settings
res, obj = mustardui_active_object(context, config=1)
uilist, index = mustardui_choose_cp(obj, self.type, context.scene)

addon_prefs = context.preferences.addons["MustardUI"].preferences

if len(uilist) <= index:
return {'FINISHED'}

# Remove custom property and driver
mustardui_clean_prop(obj, uilist, index, settings)
mustardui_clean_prop(obj, uilist, index, addon_prefs)

uilist.remove(index)
index = min(max(0, index - 1), len(uilist) - 1)
Expand Down
5 changes: 5 additions & 0 deletions menu/menu_armature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import bpy

from . import MainPanel
from ..model_selection.active_object import *
from ..warnings.ops_fix_old_UI import check_old_UI
from ..settings.rig import *


Expand Down Expand Up @@ -51,6 +53,9 @@ def draw_with_icon(prop, prop_name, name, icon):
@classmethod
def poll(cls, context):

if check_old_UI():
return False

res, obj = mustardui_active_object(context, config=0)

if obj is not None:
Expand Down
124 changes: 79 additions & 45 deletions menu/menu_body.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import bpy
from . import MainPanel
from ..model_selection.active_object import *
from ..warnings.ops_fix_old_UI import check_old_UI
from ..settings.rig import *
import textwrap

Expand All @@ -21,13 +22,69 @@ def _label_multiline(context, text, parent, icon):
parent.label(text=text_line, icon="BLANK1")


def draw_section(context, layout, obj, settings, rig_settings, custom_props, section, draw_sub = True):
if rig_settings.body_custom_properties_name_order:
custom_properties_section = sorted([x for x in custom_props if
x.section == section.name and not x.hidden and (
not x.advanced if not settings.advanced else True)],
key=lambda x: x.name)
else:
custom_properties_section = [x for x in custom_props if
x.section == section.name and not x.hidden and (
not x.advanced if not settings.advanced else True)]
if len(custom_properties_section) > 0 and (
not section.advanced or (section.advanced and settings.advanced)) and draw_sub:
box = layout.box()
row = box.row(align=False)
if section.collapsable:
row.prop(section, "collapsed",
icon="TRIA_DOWN" if not section.collapsed else "TRIA_RIGHT",
icon_only=True,
emboss=False)
if section.icon != "" and section.icon != "NONE":
row.label(text=section.name, icon=section.icon)
else:
row.label(text=section.name)
if not section.collapsed:
if section.description != "":
box2 = box.box()
_label_multiline(context=context, text=section.description, parent=box2,
icon=section.description_icon)
for prop in custom_properties_section:
row = box.row()
if rig_settings.body_custom_properties_icons:
row.label(text=prop.name, icon=prop.icon if prop.icon != "NONE" else "DOT")
else:
row.label(text=prop.name)
if not prop.is_animatable:
try:
row.prop(eval(prop.rna), prop.path, text="")
except:
row.prop(settings, 'custom_properties_error_nonanimatable', icon="ERROR", text="",
icon_only=True, emboss=False)
else:
if prop.prop_name in obj.keys():
row.prop(obj, '["' + prop.prop_name + '"]', text="")
else:
row.prop(settings, 'custom_properties_error', icon="ERROR", text="", icon_only=True,
emboss=False)

return box, not section.collapsed

return layout, False


class PANEL_PT_MustardUI_Body(MainPanel, bpy.types.Panel):
bl_idname = "PANEL_PT_MustardUI_Body"
bl_label = "Body"
bl_options = {"DEFAULT_CLOSED"}

@classmethod
def poll(cls, context):

if check_old_UI():
return False

res, arm = mustardui_active_object(context, config=0)

if arm is not None:
Expand Down Expand Up @@ -148,52 +205,29 @@ def draw(self, context):
row.prop(settings, 'custom_properties_error', icon="ERROR", text="", icon_only=True,
emboss=False)

sec_num = len(rig_settings.body_custom_properties_sections)
id = 0
for section in rig_settings.body_custom_properties_sections:
if rig_settings.body_custom_properties_name_order:
custom_properties_section = sorted([x for x in custom_props if
x.section == section.name and not x.hidden and (
not x.advanced if not settings.advanced else True)],
key=lambda x: x.name)
else:
custom_properties_section = [x for x in custom_props if
x.section == section.name and not x.hidden and (
not x.advanced if not settings.advanced else True)]
if len(custom_properties_section) > 0 and (
not section.advanced or (section.advanced and settings.advanced)):
box = layout.box()
row = box.row(align=False)
if section.collapsable:
row.prop(section, "collapsed",
icon="TRIA_DOWN" if not section.collapsed else "TRIA_RIGHT",
icon_only=True,
emboss=False)
if section.icon != "" and section.icon != "NONE":
row.label(text=section.name, icon=section.icon)
else:
row.label(text=section.name)
if not section.collapsed:
if section.description != "":
box2 = box.box()
_label_multiline(context=context, text=section.description, parent=box2,
icon=section.description_icon)
for prop in custom_properties_section:
row = box.row()
if rig_settings.body_custom_properties_icons:
row.label(text=prop.name, icon=prop.icon if prop.icon != "NONE" else "DOT")
else:
row.label(text=prop.name)
if not prop.is_animatable:
try:
row.prop(eval(prop.rna), prop.path, text="")
except:
row.prop(settings, 'custom_properties_error_nonanimatable', icon="ERROR", text="",
icon_only=True, emboss=False)
else:
if prop.prop_name in obj.keys():
row.prop(obj, '["' + prop.prop_name + '"]', text="")
else:
row.prop(settings, 'custom_properties_error', icon="ERROR", text="", icon_only=True,
emboss=False)

# Subsections are drawn inside standard sections
if section.is_subsection:
continue

# Draw main section
sublayout, subcollapse = draw_section(context, layout, obj, settings, rig_settings, custom_props, section)

# Draw subsections if available
id = id + 1
if id >= sec_num:
break

subsec = rig_settings.body_custom_properties_sections[id]
while subsec.is_subsection:
draw_section(context, sublayout, obj, settings, rig_settings, custom_props, subsec, subcollapse)
id = id + 1
if id >= sec_num:
break
subsec = rig_settings.body_custom_properties_sections[id]

# Geometry nodes as sections
gnm = [x for x in rig_settings.model_body.modifiers if x.type == "NODES"]
Expand Down
88 changes: 47 additions & 41 deletions menu/menu_configure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import bpy
from . import MainPanel
from ..model_selection.active_object import *
from ..warnings.ops_fix_old_UI import check_old_UI


class PANEL_PT_MustardUI_InitPanel(MainPanel, bpy.types.Panel):
Expand All @@ -11,6 +12,9 @@ class PANEL_PT_MustardUI_InitPanel(MainPanel, bpy.types.Panel):

@classmethod
def poll(cls, context):
if check_old_UI():
return False

res, arm = mustardui_active_object(context, config=1)
addon_prefs = context.preferences.addons["MustardUI"].preferences
return res and addon_prefs.developer
Expand Down Expand Up @@ -99,56 +103,57 @@ def draw(self, context):
box.label(text="Sections", icon="LINENUMBERS_OFF")
box.prop(rig_settings, "body_enable_geometry_nodes_support")
if len(arm.MustardUI_CustomProperties) > 0:
if len(rig_settings.body_custom_properties_sections) == 0:
box.operator('mustardui.body_addsection')
else:
row = box.row()
row.template_list("MUSTARDUI_UL_Section_UIList", "The_List", rig_settings,
"body_custom_properties_sections", scene,
"mustardui_section_uilist_index")
col = row.column()
col2 = col.column(align=True)
col2.operator('mustardui.body_assign_to_section', text="", icon="PRESET")
col.separator()
col2 = col.column(align=True)
col2.operator('mustardui.section_add', text="", icon="ADD")
col2.operator('mustardui.body_deletesection', text="", icon="REMOVE")
col.separator()
col2 = col.column(align=True)
opup = col2.operator('mustardui.section_switch', icon="TRIA_UP", text="")
opup.direction = "UP"
opdown = col2.operator('mustardui.section_switch', icon="TRIA_DOWN", text="")
opdown.direction = "DOWN"

row = box.row()
row.template_list("MUSTARDUI_UL_Section_UIList", "The_List", rig_settings,
"body_custom_properties_sections", scene,
"mustardui_section_uilist_index")
col = row.column()
col2 = col.column(align=True)
col2.operator('mustardui.body_assign_to_section', text="", icon="PRESET")
col.separator()
col2 = col.column(align=True)
col2.operator('mustardui.section_add', text="", icon="ADD")
col2.operator('mustardui.body_deletesection', text="", icon="REMOVE")
col.separator()
col2 = col.column(align=True)
opup = col2.operator('mustardui.section_switch', icon="TRIA_UP", text="")
opup.direction = "UP"
opdown = col2.operator('mustardui.section_switch', icon="TRIA_DOWN", text="")
opdown.direction = "DOWN"
if scene.mustardui_section_uilist_index > -1:
sec = rig_settings.body_custom_properties_sections[scene.mustardui_section_uilist_index]

if scene.mustardui_section_uilist_index > -1:
sec = rig_settings.body_custom_properties_sections[scene.mustardui_section_uilist_index]
row = box.row()
row.label(text="Icon")
row.scale_x = row_scale
row.prop(sec, "icon", text="")

row = box.row()
row.label(text="Icon")
row.scale_x = row_scale
row.prop(sec, "icon", text="")
col = box.column(align=True)

col = box.column(align=True)
row = col.row()
row.label(text="Description")
row.scale_x = row_scale
row.prop(sec, "description", text="")

row = col.row()
row.label(text="Description")
row.scale_x = row_scale
row.prop(sec, "description", text="")
row = col.row()
row.enabled = sec.description != ""
row.label(text="Icon")
row.scale_x = row_scale
row.prop(sec, "description_icon", text="")

row = col.row()
row.enabled = sec.description != ""
row.label(text="Icon")
row.scale_x = row_scale
row.prop(sec, "description_icon", text="")
col = box.column(align=True)
row = col.row()
row.enabled = scene.mustardui_section_uilist_index != 0
row.prop(sec, "is_subsection")

col = box.column(align=True)
col = box.column(align=True)

row = col.row()
row.prop(sec, "advanced")
row = col.row()
row.prop(sec, "advanced")

row = col.row()
row.prop(sec, "collapsable")
row = col.row()
row.prop(sec, "collapsable")

# Outfits Settings
row = layout.row(align=False)
Expand Down Expand Up @@ -199,6 +204,7 @@ def draw(self, context):
col.prop(rig_settings, "outfits_enable_global_subsurface")
col.prop(rig_settings, "outfits_enable_global_smoothcorrection")
col.prop(rig_settings, "outfits_enable_global_shrinkwrap")
col.prop(rig_settings, "outfits_enable_global_surfacedeform")
col.prop(rig_settings, "outfits_enable_global_mask")
col.prop(rig_settings, "outfits_enable_global_solidify")
col.prop(rig_settings, "outfits_enable_global_triangulate")
Expand Down
4 changes: 4 additions & 0 deletions menu/menu_hair.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from . import MainPanel
from .misc import mustardui_custom_properties_print
from ..model_selection.active_object import *
from ..warnings.ops_fix_old_UI import check_old_UI
from ..settings.rig import *


Expand All @@ -13,6 +14,9 @@ class PANEL_PT_MustardUI_Hair(MainPanel, bpy.types.Panel):
@classmethod
def poll(cls, context):

if check_old_UI():
return False

res, arm = mustardui_active_object(context, config=0)

if arm is not None:
Expand Down
Loading

0 comments on commit d827e47

Please sign in to comment.