From ae85b03fb1bf8edbdee6bd962422e0211bd0a3ca Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Fri, 20 Aug 2021 11:18:32 -0400 Subject: [PATCH] Fixes to Panel and Toolbox More adjustments to get the dang thing working --- korman/operators/op_toolbox.py | 12 ++++++------ korman/properties/prop_material.py | 9 ++++----- korman/ui/ui_material.py | 26 +++++++++++++++----------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/korman/operators/op_toolbox.py b/korman/operators/op_toolbox.py index 1f608dd..52fd861 100644 --- a/korman/operators/op_toolbox.py +++ b/korman/operators/op_toolbox.py @@ -174,21 +174,21 @@ class PlasmaToggleAllPlasmaObjectsOperator(ToolboxOperator, bpy.types.Operator): class PlasmaToggleDoubleSidedOperator(ToolboxOperator, bpy.types.Operator): - bl_idname = "mesh.plasma_toggle_double_sided" + bl_idname = "mat.plasma_toggle_double_sided" bl_label = "Toggle All Double Sided" - bl_description = "Toggles all materials to be double sided (NOT RECOMMENDED)" + bl_description = "Toggles all materials to be double sided" enable = BoolProperty(name="Enable", description="Enable Double Sided") def execute(self, context): enable = self.enable for mat in bpy.data.materials: - mat.plasma_material.plasma_double_sided = enable + mat.plasma_mat.plasma_double_sided = enable return {"FINISHED"} class PlasmaToggleDoubleSidedSelectOperator(ToolboxOperator, bpy.types.Operator): - bl_idname = "mesh.plasma_toggle_double_sided_selected" + bl_idname = "mat.plasma_toggle_double_sided_selected" bl_label = "Toggle Selected Double Sided" bl_description = "Toggles selected meshes' material(s) double sided value" @@ -198,9 +198,9 @@ class PlasmaToggleDoubleSidedSelectOperator(ToolboxOperator, bpy.types.Operator) def execute(self, context): mat_list = [i.data for i in context.selected_objects if i.type == "MATERIAL"] - enable = not all((mat.plasma_material.plasma_double_sided for mat in mat_list)) + enable = not all((mat.plasma_mat.plasma_double_sided for mat in mat_list)) for mat in mat_list: - mat.plasma_material.plasma_double_sided = enable + mat.plasma_mat.plasma_double_sided = enable return {"FINISHED"} diff --git a/korman/properties/prop_material.py b/korman/properties/prop_material.py index 46f36a9..e1ea28d 100644 --- a/korman/properties/prop_material.py +++ b/korman/properties/prop_material.py @@ -19,10 +19,9 @@ from bpy.props import * from .. import idprops class PlasmaMaterial(bpy.types.PropertyGroup): - bl_name = "material.plasma_material" + bl_idname = "mat.plasma_mat" - plasma_double_sided = BoolProperty(name="Double Sided", - description="Sets this material as double sided (formerly TWOSIDE)", - default=False) - + plasma_double_sided = BoolProperty(name="Double Sided", + description="Sets this material as double sided (formerly TWOSIDE)", + default=False) diff --git a/korman/ui/ui_material.py b/korman/ui/ui_material.py index 0cdddef..db460d2 100644 --- a/korman/ui/ui_material.py +++ b/korman/ui/ui_material.py @@ -19,20 +19,24 @@ from . import ui_list class MaterialButtonsPanel: bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "material" + bl_region_type = "WINDOW" + bl_context = "material" + + @classmethod + def poll(cls, context): + return context.material and context.scene.render.engine == "PLASMA_GAME" class PlasmaMaterialPanel(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Plasma Material Options" - def draw(self, context): - material = context.material, getattr(context, "material_slot", None) - mat_props = material.plasma_material - layout = self.layout - - split = layout.split() - col = split.column() - sub = col.column() - col.prop(mat_props, "plasma_double_sided") + def draw(self, context): + mat, slot = context.material, getattr(context, "material_slot", None) + mat_props = mat.plasma_mat + layout = self.layout + + split = layout.split() + col = split.column() + sub = col.column() + col.prop(mat_props, "plasma_double_sided")