button manual load environnement namespace

1.6.3
gpv2
Pullusb 2021-09-07 15:41:54 +02:00
parent 1017c01668
commit 9d26ed4085
2 changed files with 51 additions and 4 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
1.6.3
<!-- - abort :: add checkbox to prevent from loading project environnement namespace -->
- add buttons to load manually environnement namespace
1.6.2 1.6.2
- disable keymap register for breakdowner on background - disable keymap register for breakdowner on background

View File

@ -15,7 +15,7 @@ bl_info = {
"name": "GP toolbox", "name": "GP toolbox",
"description": "Set of tools for Grease Pencil in animation production", "description": "Set of tools for Grease Pencil in animation production",
"author": "Samuel Bernou, Christophe Seux", "author": "Samuel Bernou, Christophe Seux",
"version": (1, 6, 2), "version": (1, 6, 3),
"blender": (2, 91, 0), "blender": (2, 91, 0),
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
"warning": "", "warning": "",
@ -195,6 +195,7 @@ class GPTB_prefs(bpy.types.AddonPreferences):
description="Path to brushes containing the blends holding the brushes", description="Path to brushes containing the blends holding the brushes",
default="//", maxlen=0, subtype='DIR_PATH')#, update = set_palette_path default="//", maxlen=0, subtype='DIR_PATH')#, update = set_palette_path
## namespace
separator : StringProperty( separator : StringProperty(
name="Separator", name="Separator",
description="Character delimiter to use for detecting namespace (prefix), default is '_', space if nothing specified", 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)", description="List of suffixes (two capital letters) available for layers(ex: OL,UL)",
default="", maxlen=0) 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( show_prefix_buttons : BoolProperty(
name="Show Prefix Buttons", name="Show Prefix Buttons",
description="Show prefix and suffix buttons above layer stack", description="Show prefix and suffix buttons above layer stack",
@ -343,14 +350,19 @@ class GPTB_prefs(bpy.types.AddonPreferences):
## render output ## render output
subbox.prop(self, 'output_path') subbox.prop(self, 'output_path')
## render output ## namespace
subbox = box.box() subbox = box.box()
subbox.label(text='Namespace:') subbox.label(text='Namespace:')
subbox.prop(self, 'separator') subbox.prop(self, 'separator')
subbox.prop(self, 'show_prefix_buttons', text='Use Prefixes Toggles') subbox.prop(self, 'show_prefix_buttons', text='Use Prefixes Toggles')
if self.show_prefix_buttons: if self.show_prefix_buttons:
subbox.prop(self, 'prefixes') # subbox.prop(self, 'use_env_namespace')
subbox.prop(self, 'suffixes') 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 ### TODO add render settings
@ -488,6 +500,7 @@ def set_env_properties():
if prefs.use_env_brushes: if prefs.use_env_brushes:
prefs.brush_path = brushes if brushes else prefs.brush_path prefs.brush_path = brushes if brushes else prefs.brush_path
# if prefs.use_env_namespace:
prefix_list = os.getenv('PREFIXES') prefix_list = os.getenv('PREFIXES')
prefs.prefixes = prefix_list if prefix_list else prefs.prefixes prefs.prefixes = prefix_list if prefix_list else prefs.prefixes
@ -497,6 +510,34 @@ def set_env_properties():
separator = os.getenv('SEPARATOR') separator = os.getenv('SEPARATOR')
prefs.separator = separator if separator else prefs.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 --- ### --- REGISTER ---
# class GP_PG_ToolsSettings(bpy.types.PropertyGroup) : # class GP_PG_ToolsSettings(bpy.types.PropertyGroup) :
@ -506,6 +547,7 @@ def set_env_properties():
classes = ( classes = (
GP_PG_FixSettings, GP_PG_FixSettings,
GP_PG_ToolsSettings, GP_PG_ToolsSettings,
GPTB_set_env_settings,
GPTB_prefs, GPTB_prefs,
GPT_OT_auto_tint_gp_layers, GPT_OT_auto_tint_gp_layers,
) )