Skip to content

Commit

Permalink
Fix (un)register bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-Noble committed Sep 7, 2016
1 parent a9ab1ef commit dd3725d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
38 changes: 30 additions & 8 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,16 @@ def draw(self, context):
row.operator(SCENE_OT_cm_stop.bl_idname, icon_value=cicon('stop_sim'))
else:
row.operator(SCENE_OT_cm_stop.bl_idname, icon='CANCEL')

row = layout.row()
row.separator()

row = layout.row()
if context.scene.show_utilities == False:
row.prop(context.scene, "show_utilities", icon="RIGHTARROW", text="Utilities")
else:
row.prop(context.scene, "show_utilities", icon="TRIA_DOWN", text="Utilities")

box = layout.box()
row = box.row()
row.prop(scene, "nodeTreeType")
Expand Down Expand Up @@ -276,7 +276,7 @@ def draw(self, context):
layout = self.layout
scene = context.scene
preferences = context.user_preferences.addons[__package__].preferences

row = layout.row()
row.label("Group name")
row.label("Number | origin")
Expand All @@ -291,7 +291,7 @@ def draw(self, context):
layout.prop(scene, "cm_view_details", icon='RIGHTARROW')
else:
layout.prop(scene, "cm_view_details", icon='TRIA_DOWN')

box = layout.box()

index = scene.cm_groups_index
Expand Down Expand Up @@ -347,7 +347,18 @@ def draw(self, context):
def register():
register_icons()
addon_updater_ops.register(bl_info)
bpy.utils.register_module(__name__)
cm_prefs.register()

bpy.utils.register_class(SCENE_UL_group)
bpy.utils.register_class(SCENE_UL_agent_type)
bpy.utils.register_class(SCENE_OT_cm_groups_reset)
bpy.utils.register_class(SCENE_OT_cm_agent_add)
bpy.utils.register_class(SCENE_OT_cm_agent_add_selected)
bpy.utils.register_class(SCENE_OT_cm_start)
bpy.utils.register_class(SCENE_OT_cm_stop)
bpy.utils.register_class(SCENE_PT_CrowdMaster)
bpy.utils.register_class(SCENE_PT_CrowdMasterAgents)
bpy.utils.register_class(SCENE_PT_CrowdMasterManualAgents)

global action_register
from .cm_actions import action_register
Expand All @@ -369,7 +380,7 @@ def register():
global cm_generation
from . import cm_generation
cm_generation.register()

global cm_utilities
from . import cm_utilities
cm_utilities.register()
Expand All @@ -385,7 +396,17 @@ def initialise():

def unregister():
unregister_icons()
bpy.utils.unregister_module(__name__)

bpy.utils.unregister_class(SCENE_UL_group)
bpy.utils.unregister_class(SCENE_UL_agent_type)
bpy.utils.unregister_class(SCENE_OT_cm_groups_reset)
bpy.utils.unregister_class(SCENE_OT_cm_agent_add)
bpy.utils.unregister_class(SCENE_OT_cm_agent_add_selected)
bpy.utils.unregister_class(SCENE_OT_cm_start)
bpy.utils.unregister_class(SCENE_OT_cm_stop)
bpy.utils.unregister_class(SCENE_PT_CrowdMaster)
bpy.utils.unregister_class(SCENE_PT_CrowdMasterAgents)
bpy.utils.unregister_class(SCENE_PT_CrowdMasterManualAgents)

action_unregister()
event_unregister()
Expand All @@ -396,6 +417,7 @@ def unregister():
cm_bpyNodes.unregister()
cm_generation.unregister()
cm_utilities.unregister()
cm_prefs.unregister()

if __name__ == "__main__":
register()
2 changes: 1 addition & 1 deletion cm_blenderData.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def registerTypes():

def unregisterAllTypes():
bpy.utils.unregister_class(agent_entry)
bpy.utils.register_class(agent_type_entry)
bpy.utils.unregister_class(agent_type_entry)
bpy.utils.unregister_class(group_entry)

bpy.utils.unregister_class(manual_props)
26 changes: 17 additions & 9 deletions cm_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class CMPreferences(AddonPreferences):
# bl_idname = "CrowdMaster"
bl_idname = __package__
scriptdir = bpy.path.abspath(os.path.dirname(__file__))

auto_check_update = BoolProperty(
name = "Auto-check for Update",
description = "If enabled, auto-check for updates using an interval",
default = False,
)

updater_intrval_months = IntProperty(
name='Months',
description = "Number of months between checking for updates",
Expand All @@ -54,25 +54,25 @@ class CMPreferences(AddonPreferences):
min=0,
max=59
)

use_custom_icons = BoolProperty(
name = "Use Custom Icons",
description = "Chose whether to use the custom icons that come with the addon or not.",
default = True,
)

show_debug_options = BoolProperty(
name = "Show Debug Options",
description = "Chose whether to show the debug options in the interface. This also enables debug mode.",
default = True,
)

play_animation = BoolProperty(
name = "Start Animation Automatically",
description = "Start and stop the animation automatically when the start and stop sim buttons are pressed.",
default = True,
)

prefs_tab_items = [
("GEN", "General Settings", "General settings for the addon."),
("UPDATE", "Addon Update Settings", "Settings for the addon updater.") ]
Expand All @@ -85,15 +85,15 @@ def draw(self, context):

row = layout.row()
row.prop(preferences, "prefs_tab", expand = True)

if preferences.prefs_tab == "GEN":
row = layout.row()
row.prop(preferences, 'use_custom_icons', icon_value=cicon('plug'))
if preferences.use_custom_icons == True:
row.prop(preferences, 'show_debug_options', icon_value=cicon('code'))
else:
row.prop(preferences, 'show_debug_options', icon='RECOVER_AUTO')

row = layout.row()
if preferences.use_custom_icons == True:
row.prop(preferences, 'play_animation', icon_value=cicon('shuffle'))
Expand All @@ -103,7 +103,15 @@ def draw(self, context):
if preferences.prefs_tab == "UPDATE":
row = layout.row()
addon_updater_ops.update_settings_ui(self,context)

row = layout.row()
row.scale_y = 1.25
row.operator("scene.cm_save_prefs", icon='SAVE_PREFS')

def register():
bpy.utils.register_class(CMSavePrefs)
bpy.utils.register_class(CMPreferences)

def unregister():
bpy.utils.unregister_class(CMSavePrefs)
bpy.utils.unregister_class(CMPreferences)

0 comments on commit dd3725d

Please sign in to comment.