diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bddac0..e822d2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +1.6.3 + + +- add buttons to load manually environnement namespace + 1.6.2 - disable keymap register for breakdowner on background diff --git a/__init__.py b/__init__.py index a036201..7c27027 100755 --- a/__init__.py +++ b/__init__.py @@ -15,7 +15,7 @@ bl_info = { "name": "GP toolbox", "description": "Set of tools for Grease Pencil in animation production", "author": "Samuel Bernou, Christophe Seux", -"version": (1, 6, 2), +"version": (1, 6, 3), "blender": (2, 91, 0), "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "warning": "", @@ -195,6 +195,7 @@ class GPTB_prefs(bpy.types.AddonPreferences): description="Path to brushes containing the blends holding the brushes", default="//", maxlen=0, subtype='DIR_PATH')#, update = set_palette_path + ## namespace separator : StringProperty( name="Separator", description="Character delimiter to use for detecting namespace (prefix), default is '_', space if nothing specified", @@ -210,6 +211,12 @@ class GPTB_prefs(bpy.types.AddonPreferences): description="List of suffixes (two capital letters) available for layers(ex: OL,UL)", default="", maxlen=0) + # use_env_namespace : BoolProperty( + # name="Use Project namespace", + # description="Ovewrite prefix/suffix with Project values defined in environnement at startup\n(key 'PREFIXES and SUFFIXES')", + # default=True, + # ) + show_prefix_buttons : BoolProperty( name="Show Prefix Buttons", description="Show prefix and suffix buttons above layer stack", @@ -343,14 +350,19 @@ class GPTB_prefs(bpy.types.AddonPreferences): ## render output subbox.prop(self, 'output_path') - ## render output + ## namespace subbox = box.box() subbox.label(text='Namespace:') subbox.prop(self, 'separator') subbox.prop(self, 'show_prefix_buttons', text='Use Prefixes Toggles') if self.show_prefix_buttons: - subbox.prop(self, 'prefixes') - subbox.prop(self, 'suffixes') + # subbox.prop(self, 'use_env_namespace') + row = subbox.row() + row.prop(self, 'prefixes') + row.operator('prefs.reset_gp_toolbox_env', text='', icon='LOOP_BACK').mode = 'PREFIXES' + row = subbox.row() + row.prop(self, 'suffixes') + row.operator('prefs.reset_gp_toolbox_env', text='', icon='LOOP_BACK').mode = 'SUFFIXES' ### TODO add render settings @@ -488,6 +500,7 @@ def set_env_properties(): if prefs.use_env_brushes: prefs.brush_path = brushes if brushes else prefs.brush_path + # if prefs.use_env_namespace: prefix_list = os.getenv('PREFIXES') prefs.prefixes = prefix_list if prefix_list else prefs.prefixes @@ -497,6 +510,34 @@ def set_env_properties(): separator = os.getenv('SEPARATOR') prefs.separator = separator if separator else prefs.separator + +class GPTB_set_env_settings(bpy.types.Operator): + """manually reset prefs from project environnement setttings""" + bl_idname = "prefs.reset_gp_toolbox_env" + bl_label = "Reset prefs from project environnement settings (if any)" + + mode : bpy.props.StringProperty(default='ALL', options={'SKIP_SAVE'}) # 'HIDDEN', + + def execute(self, context): + prefs = get_addon_prefs() + if self.mode == 'ALL': + set_env_properties() + elif self.mode == 'PREFIXES': + prefix_list = os.getenv('PREFIXES') + if not prefix_list: + self.report({'ERROR'}, 'No prefix preset to load from project environnement') + return {'CANCELLED'} + prefs.prefixes = prefix_list if prefix_list else prefs.prefixes + + elif self.mode == 'SUFFIXES': + suffix_list = os.getenv('SUFFIXES') + if not suffix_list: + self.report({'ERROR'}, 'No suffix preset to load from project environnement') + return {'CANCELLED'} + prefs.suffixes = suffix_list if suffix_list else prefs.suffixes + return {'FINISHED'} + + ### --- REGISTER --- # class GP_PG_ToolsSettings(bpy.types.PropertyGroup) : @@ -506,6 +547,7 @@ def set_env_properties(): classes = ( GP_PG_FixSettings, GP_PG_ToolsSettings, +GPTB_set_env_settings, GPTB_prefs, GPT_OT_auto_tint_gp_layers, )