WIP: MaterialX addon #104594
@ -35,10 +35,16 @@ from . import logging
|
|||||||
log = logging.Log("__init__")
|
log = logging.Log("__init__")
|
||||||
|
|
||||||
|
|
||||||
|
register_classes, unregister_classes = bpy.utils.register_classes_factory([
|
||||||
|
node_tree.MxNodeTree,
|
||||||
|
preferences.AddonPreferences,
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
log("register")
|
log("register")
|
||||||
bpy.utils.register_class(preferences.AddonPreferences)
|
|
||||||
bpy.utils.register_class(node_tree.MxNodeTree)
|
register_classes()
|
||||||
nodes.register()
|
nodes.register()
|
||||||
matlib.register()
|
matlib.register()
|
||||||
material.register()
|
material.register()
|
||||||
@ -46,8 +52,8 @@ def register():
|
|||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
log("unregister")
|
log("unregister")
|
||||||
|
|
||||||
|
material.unregister()
|
||||||
matlib.unregister()
|
matlib.unregister()
|
||||||
nodes.unregister()
|
nodes.unregister()
|
||||||
material.unregister()
|
unregister_classes()
|
||||||
bpy.utils.unregister_class(node_tree.MxNodeTree)
|
|
||||||
bpy.utils.unregister_class(preferences.AddonPreferences)
|
|
||||||
|
@ -11,6 +11,7 @@ from bpy_extras.io_utils import ImportHelper, ExportHelper
|
|||||||
|
|
||||||
from ..node_tree import MxNodeTree
|
from ..node_tree import MxNodeTree
|
||||||
from .. import utils
|
from .. import utils
|
||||||
|
from ..preferences import addon_preferences
|
||||||
|
|
||||||
from ..utils import logging
|
from ..utils import logging
|
||||||
log = logging.Log('nodes.ui')
|
log = logging.Log('nodes.ui')
|
||||||
@ -194,9 +195,7 @@ class NODES_PT_dev(bpy.types.Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
# TODO: enable
|
return addon_preferences().dev_tools
|
||||||
# return config.show_dev_settings
|
|
||||||
return True
|
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
@ -3,12 +3,38 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from .utils import with_prefix
|
from . import logging, ADDON_ALIAS
|
||||||
|
|
||||||
|
|
||||||
class AddonPreferences(bpy.types.AddonPreferences):
|
class AddonPreferences(bpy.types.AddonPreferences):
|
||||||
bl_idname = with_prefix('AddonPreferences')
|
bl_idname = ADDON_ALIAS
|
||||||
|
|
||||||
|
def update_log_level(self, context):
|
||||||
|
logging.logger.setLevel(self.log_level)
|
||||||
|
|
||||||
|
dev_tools: bpy.props.BoolProperty(
|
||||||
|
name="Developer Tools",
|
||||||
|
description="Enable developer tools",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
log_level: bpy.props.EnumProperty(
|
||||||
|
name="Log Level",
|
||||||
|
description="Select logging level",
|
||||||
|
items=(('DEBUG', "Debug", "Log level DEBUG"),
|
||||||
|
('INFO', "Info", "Log level INFO"),
|
||||||
|
('WARNING', "Warning", "Log level WARN"),
|
||||||
|
('ERROR', "Error", "Log level ERROR"),
|
||||||
|
('CRITICAL', "Critical", "Log level CRITICAL")),
|
||||||
|
default='INFO',
|
||||||
|
update=update_log_level,
|
||||||
|
)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.label(text="MaterialX addon preferences")
|
col = layout.column()
|
||||||
|
col.prop(self, "dev_tools")
|
||||||
|
col.prop(self, "log_level")
|
||||||
|
|
||||||
|
|
||||||
|
def addon_preferences():
|
||||||
|
return bpy.context.preferences.addons[ADDON_ALIAS].preferences
|
||||||
|
@ -16,7 +16,7 @@ log = logging.Log('utils')
|
|||||||
|
|
||||||
|
|
||||||
ADDON_ROOT_DIR = Path(__file__).parent
|
ADDON_ROOT_DIR = Path(__file__).parent
|
||||||
ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_ALIAS}", create=True))
|
ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_ALIAS}_data", create=True))
|
||||||
|
|
||||||
MX_LIBS_FOLDER = "libraries"
|
MX_LIBS_FOLDER = "libraries"
|
||||||
MX_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER
|
MX_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER
|
||||||
|
Loading…
Reference in New Issue
Block a user