Skip to content

Commit

Permalink
Move remaining panel to ui.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lampysprites committed Sep 15, 2022
1 parent 7b494cf commit 9d4ce53
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 70 deletions.
70 changes: 1 addition & 69 deletions animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,72 +104,4 @@ def execute(self, context):
addon.state.action_preview_enabled = False
scene.use_preview_range = False
bpy.msgbus.clear_by_owner(_msgbus_anim_data_callback_owner)
return {'FINISHED'}


class SB_PT_animation(bpy.types.Panel):
bl_idname = "SB_PT_animation"
bl_label = "Animation"
bl_category = "Pribambase"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"


def draw(self, context):
layout = self.layout

if context.active_object and context.active_object.type == 'MESH':
obj = context.active_object

# Info
if next((False for img in bpy.data.images if img.sb_props.sheet), True):
layout.row().label(text="No synced animations", icon='INFO')

if not obj.material_slots:
layout.row().label(text="No material", icon='INFO')

if obj.sb_props.animation:
layout.row().label(text=obj.sb_props.animation.name, icon='IMAGE_DATA')

try:
drivers = obj.modifiers["UV Frame (Pribambase)"].object_to.animation_data.drivers
if not next((True for d in drivers if d.data_path == "location")):
layout.row().label(text="Driver curve not found", icon='ERROR')
except KeyError:
layout.row().label(text="UVWarp not found", icon='ERROR')
except AttributeError:
layout.row().label(text="Driver not found", icon='ERROR')

if "pribambase_frame" not in obj:
layout.row().label(text="Property not found", icon='ERROR')
else:
row = layout.split(factor=.33)
row.label(text="None", icon='IMAGE_DATA')
row.operator("pribambase.spritesheet_rig", icon='ADD', text="Animate")

row = layout.row()
row.enabled = bool("pribambase_frame" in obj and obj.sb_props.animation)
if "pribambase_frame" in obj:
row.prop(obj, '["pribambase_frame"]', text="Frame")
else:
row.prop(addon.state, "frame_stub", text="Frame")

row = layout.row(align=True)
row.enabled = bool(obj.animation_data)

sub = row.column()
sub.enabled = bool(obj.sb_props.animation)
sub.prop(obj.sb_props, "animation_tag_setter", text="Tag")

if addon.state.action_preview_enabled:
active_picked = (context.active_object == addon.state.action_preview)
row.operator("pribambase.action_preview_set", icon='EYEDROPPER', text="", depress=active_picked)
row.operator("pribambase.action_preview_clear", icon='PREVIEW_RANGE', text="", depress=True)
else:
row.operator("pribambase.action_preview_set", icon='PREVIEW_RANGE', text="")

if obj.sb_props.animation:
layout.row().operator("pribambase.spritesheet_unrig", icon='TRASH')

else:
layout.label(text="Select a mesh")
return {'FINISHED'}
70 changes: 69 additions & 1 deletion ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,72 @@ def draw(self, context):
layout.operator("pribambase.sprite_replace", icon='FILE_REFRESH' if connected else 'UNLINKED')
layout.separator()
layout.operator("pribambase.sprite_make_animated")
layout.operator("pribambase.uv_send", icon='UV_VERTEXSEL' if connected else 'UNLINKED')
layout.operator("pribambase.uv_send", icon='UV_VERTEXSEL' if connected else 'UNLINKED')


class SB_PT_animation(bpy.types.Panel):
bl_idname = "SB_PT_animation"
bl_label = "Animation"
bl_category = "Pribambase"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"


def draw(self, context):
layout = self.layout

if context.active_object and context.active_object.type == 'MESH':
obj = context.active_object

# Info
if next((False for img in bpy.data.images if img.sb_props.sheet), True):
layout.row().label(text="No synced animations", icon='INFO')

if not obj.material_slots:
layout.row().label(text="No material", icon='INFO')

if obj.sb_props.animation:
layout.row().label(text=obj.sb_props.animation.name, icon='IMAGE_DATA')

try:
drivers = obj.modifiers["UV Frame (Pribambase)"].object_to.animation_data.drivers
if not next((True for d in drivers if d.data_path == "location")):
layout.row().label(text="Driver curve not found", icon='ERROR')
except KeyError:
layout.row().label(text="UVWarp not found", icon='ERROR')
except AttributeError:
layout.row().label(text="Driver not found", icon='ERROR')

if "pribambase_frame" not in obj:
layout.row().label(text="Property not found", icon='ERROR')
else:
row = layout.split(factor=.33)
row.label(text="None", icon='IMAGE_DATA')
row.operator("pribambase.spritesheet_rig", icon='ADD', text="Animate")

row = layout.row()
row.enabled = bool("pribambase_frame" in obj and obj.sb_props.animation)
if "pribambase_frame" in obj:
row.prop(obj, '["pribambase_frame"]', text="Frame")
else:
row.prop(addon.state, "frame_stub", text="Frame")

row = layout.row(align=True)
row.enabled = bool(obj.animation_data)

sub = row.column()
sub.enabled = bool(obj.sb_props.animation)
sub.prop(obj.sb_props, "animation_tag_setter", text="Tag")

if addon.state.action_preview_enabled:
active_picked = (context.active_object == addon.state.action_preview)
row.operator("pribambase.action_preview_set", icon='EYEDROPPER', text="", depress=active_picked)
row.operator("pribambase.action_preview_clear", icon='PREVIEW_RANGE', text="", depress=True)
else:
row.operator("pribambase.action_preview_set", icon='PREVIEW_RANGE', text="")

if obj.sb_props.animation:
layout.row().operator("pribambase.spritesheet_unrig", icon='TRASH')

else:
layout.label(text="Select a mesh")

0 comments on commit 9d4ce53

Please sign in to comment.