Skip to content

Commit

Permalink
unified RetargetBase.has_settings;
Browse files Browse the repository at this point in the history
  • Loading branch information
mechanic-kharkiv committed Apr 15, 2024
1 parent 3aaf4da commit b775c12
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@

class RetargetBase():
def has_settings(self):
for k in self.keys():
if k == 'name':
if hasattr(self, "_order"):
_items = ((k, self.bl_rna.properties[k]) for k in self._order)
else:
_items = self.bl_rna.properties.items()
for sub_value_attr, sub_prop in _items:
if (sub_value_attr in ("rna_type", "name") or sub_prop.is_hidden):
continue
v = getattr(self, k, None)
v = getattr(self, sub_value_attr)
if v:
if hasattr(sub_prop, "default") and sub_prop.default == v:
continue
if hasattr(v, "has_settings"):
if not v.has_settings():
continue
Expand Down Expand Up @@ -143,14 +149,15 @@ class RetargetSettings(RetargetBase, PropertyGroup):
name="Last used preset", description="Preset from which the settings were loaded from (or saved to).",
options={'SKIP_SAVE','HIDDEN'}) # base name, not a full path

def has_settings(self):
for setting in (self.spine, self.left_arm, self.left_arm_ik, self.left_fingers,
self.right_arm, self.right_arm_ik, self.right_fingers,
self.left_leg, self.left_leg_ik, self.right_leg, self.right_leg_ik):
if setting.has_settings():
return True

return False
#TODO: if face, root, etc is *really* excluded from has_settings just uncomment this override here
# def has_settings(self):
# for setting in (self.spine, self.left_arm, self.left_arm_ik, self.left_fingers,
# self.right_arm, self.right_arm_ik, self.right_fingers,
# self.left_leg, self.left_leg_ik, self.right_leg, self.right_leg_ik):
# if setting.has_settings():
# return True
#
# return False


def register_classes():
Expand Down

0 comments on commit b775c12

Please sign in to comment.