From 53c5073749d1f61fd5eccd827b1efd1369f6c5f3 Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Fri, 20 Aug 2021 09:56:16 -0400 Subject: [PATCH 1/5] Add new Plasma Material properties and UI Start of Plasma Material Panel additions --- korman/exporter/material.py | 2 +- korman/properties/__init__.py | 2 ++ korman/properties/prop_material.py | 28 ++++++++++++++++++++++ korman/ui/__init__.py | 1 + korman/ui/ui_material.py | 38 ++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 korman/properties/prop_material.py create mode 100644 korman/ui/ui_material.py diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 36feec2..4f7b4d8 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -1401,7 +1401,7 @@ class MaterialConverter: state = layer.state is_waveset = bo.plasma_modifiers.water_basic.enabled - if bo.data.show_double_sided: + if bm.plasma_material.plasma_double_sided: if is_waveset: self._report.warn("FORCING single sided--this is a waveset (are you insane?)") else: diff --git a/korman/properties/__init__.py b/korman/properties/__init__.py index 9980638..c249296 100644 --- a/korman/properties/__init__.py +++ b/korman/properties/__init__.py @@ -19,6 +19,7 @@ from .prop_anim import * from .prop_camera import * from .prop_image import * from .prop_lamp import * +from .prop_material import * from . import modifiers from .prop_object import * from .prop_scene import * @@ -32,6 +33,7 @@ def register(): bpy.types.Camera.plasma_camera = bpy.props.PointerProperty(type=PlasmaCamera) bpy.types.Image.plasma_image = bpy.props.PointerProperty(type=PlasmaImage) bpy.types.Lamp.plasma_lamp = bpy.props.PointerProperty(type=PlasmaLamp) + byp.types.Material.plasma_material = bpy.Props.PointerProperty(type=PlasmaMaterial) bpy.types.Object.plasma_net = bpy.props.PointerProperty(type=PlasmaNet) bpy.types.Object.plasma_object = bpy.props.PointerProperty(type=PlasmaObject) bpy.types.Scene.plasma_scene = bpy.props.PointerProperty(type=PlasmaScene) diff --git a/korman/properties/prop_material.py b/korman/properties/prop_material.py new file mode 100644 index 0000000..46f36a9 --- /dev/null +++ b/korman/properties/prop_material.py @@ -0,0 +1,28 @@ +# This file is part of Korman. +# +# Korman is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Korman is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Korman. If not, see . + +import bpy +from bpy.props import * + +from .. import idprops + +class PlasmaMaterial(bpy.types.PropertyGroup): + bl_name = "material.plasma_material" + + plasma_double_sided = BoolProperty(name="Double Sided", + description="Sets this material as double sided (formerly TWOSIDE)", + default=False) + + diff --git a/korman/ui/__init__.py b/korman/ui/__init__.py index d5a2ac6..92e54fa 100644 --- a/korman/ui/__init__.py +++ b/korman/ui/__init__.py @@ -18,6 +18,7 @@ from .ui_camera import * from .ui_image import * from .ui_lamp import * from .ui_list import * +from .ui_material import * from .ui_menus import * from .ui_modifiers import * from .ui_object import * diff --git a/korman/ui/ui_material.py b/korman/ui/ui_material.py new file mode 100644 index 0000000..0cdddef --- /dev/null +++ b/korman/ui/ui_material.py @@ -0,0 +1,38 @@ +# This file is part of Korman. +# +# Korman is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Korman is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Korman. If not, see . + +import bpy + +from . import ui_list + +class MaterialButtonsPanel: + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "material" + + +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") + From 3bf842aa603c869011fe65bbb75aad77f32aa886 Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Fri, 20 Aug 2021 10:02:55 -0400 Subject: [PATCH 2/5] Adjust Toolbox Buttons Adjusts the Toolbox Double Sided Button Operators to use new material panel toggle for double sided. --- korman/operators/op_toolbox.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/korman/operators/op_toolbox.py b/korman/operators/op_toolbox.py index a5ffb64..1f608dd 100644 --- a/korman/operators/op_toolbox.py +++ b/korman/operators/op_toolbox.py @@ -176,31 +176,31 @@ class PlasmaToggleAllPlasmaObjectsOperator(ToolboxOperator, bpy.types.Operator): class PlasmaToggleDoubleSidedOperator(ToolboxOperator, bpy.types.Operator): bl_idname = "mesh.plasma_toggle_double_sided" bl_label = "Toggle All Double Sided" - bl_description = "Toggles all meshes to be double sided" + bl_description = "Toggles all materials to be double sided (NOT RECOMMENDED)" enable = BoolProperty(name="Enable", description="Enable Double Sided") def execute(self, context): enable = self.enable - for mesh in bpy.data.meshes: - mesh.show_double_sided = enable + for mat in bpy.data.materials: + mat.plasma_material.plasma_double_sided = enable return {"FINISHED"} class PlasmaToggleDoubleSidedSelectOperator(ToolboxOperator, bpy.types.Operator): bl_idname = "mesh.plasma_toggle_double_sided_selected" bl_label = "Toggle Selected Double Sided" - bl_description = "Toggles selected meshes double sided value" + bl_description = "Toggles selected meshes' material(s) double sided value" @classmethod def poll(cls, context): return super().poll(context) and hasattr(bpy.context, "selected_objects") def execute(self, context): - mesh_list = [i.data for i in context.selected_objects if i.type == "MESH"] - enable = not all((mesh.show_double_sided for mesh in mesh_list)) - for mesh in mesh_list: - mesh.show_double_sided = enable + 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)) + for mat in mat_list: + mat.plasma_material.plasma_double_sided = enable return {"FINISHED"} From ae85b03fb1bf8edbdee6bd962422e0211bd0a3ca Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Fri, 20 Aug 2021 11:18:32 -0400 Subject: [PATCH 3/5] 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") From 0bdd42204e36414c6895fa0462713890cdfd4f7e Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn Date: Fri, 20 Aug 2021 16:26:23 -0400 Subject: [PATCH 4/5] Further Updates to Toolbox and Panel Added suggestions from Hoikas --- korman/exporter/material.py | 2 +- korman/operators/op_toolbox.py | 6 +++--- korman/properties/prop_material.py | 4 ++-- korman/ui/ui_material.py | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 4f7b4d8..b624836 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -1401,7 +1401,7 @@ class MaterialConverter: state = layer.state is_waveset = bo.plasma_modifiers.water_basic.enabled - if bm.plasma_material.plasma_double_sided: + if bm.plasma_material.double_sided: if is_waveset: self._report.warn("FORCING single sided--this is a waveset (are you insane?)") else: diff --git a/korman/operators/op_toolbox.py b/korman/operators/op_toolbox.py index 52fd861..827b6ad 100644 --- a/korman/operators/op_toolbox.py +++ b/korman/operators/op_toolbox.py @@ -174,7 +174,7 @@ class PlasmaToggleAllPlasmaObjectsOperator(ToolboxOperator, bpy.types.Operator): class PlasmaToggleDoubleSidedOperator(ToolboxOperator, bpy.types.Operator): - bl_idname = "mat.plasma_toggle_double_sided" + bl_idname = "material.plasma_toggle_double_sided" bl_label = "Toggle All Double Sided" bl_description = "Toggles all materials to be double sided" @@ -188,7 +188,7 @@ class PlasmaToggleDoubleSidedOperator(ToolboxOperator, bpy.types.Operator): class PlasmaToggleDoubleSidedSelectOperator(ToolboxOperator, bpy.types.Operator): - bl_idname = "mat.plasma_toggle_double_sided_selected" + bl_idname = "material.plasma_toggle_double_sided_selected" bl_label = "Toggle Selected Double Sided" bl_description = "Toggles selected meshes' material(s) double sided value" @@ -197,7 +197,7 @@ class PlasmaToggleDoubleSidedSelectOperator(ToolboxOperator, bpy.types.Operator) return super().poll(context) and hasattr(bpy.context, "selected_objects") def execute(self, context): - mat_list = [i.data for i in context.selected_objects if i.type == "MATERIAL"] + mat_list = [slot.material for slot in itertools.chain.from_iterable((i.material_slots for i in context.selected_objects)) if slot and slot.material] enable = not all((mat.plasma_mat.plasma_double_sided for mat in mat_list)) for mat in mat_list: mat.plasma_mat.plasma_double_sided = enable diff --git a/korman/properties/prop_material.py b/korman/properties/prop_material.py index e1ea28d..7d82208 100644 --- a/korman/properties/prop_material.py +++ b/korman/properties/prop_material.py @@ -19,9 +19,9 @@ from bpy.props import * from .. import idprops class PlasmaMaterial(bpy.types.PropertyGroup): - bl_idname = "mat.plasma_mat" + bl_idname = "material.plasma_material" - plasma_double_sided = BoolProperty(name="Double Sided", + 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 db460d2..adf5d44 100644 --- a/korman/ui/ui_material.py +++ b/korman/ui/ui_material.py @@ -31,12 +31,12 @@ class PlasmaMaterialPanel(MaterialButtonsPanel, bpy.types.Panel): bl_label = "Plasma Material Options" def draw(self, context): - mat, slot = context.material, getattr(context, "material_slot", None) - mat_props = mat.plasma_mat + mat = context.material + mat_props = mat.plasma_material layout = self.layout split = layout.split() col = split.column() sub = col.column() - col.prop(mat_props, "plasma_double_sided") + col.prop(mat_props, "double_sided") From 37229c911747115bdfa9bdf536ee0346fc80ae72 Mon Sep 17 00:00:00 2001 From: Patrick Dulebohn <40325124+DoobesURU@users.noreply.github.com> Date: Wed, 25 Aug 2021 10:54:34 -0400 Subject: [PATCH 5/5] Apply suggestions from Hoikas' code review Puts in suggestions from Hoikas. Co-authored-by: Adam Johnson --- korman/operators/op_toolbox.py | 6 +++--- korman/properties/prop_material.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/korman/operators/op_toolbox.py b/korman/operators/op_toolbox.py index 827b6ad..9574d66 100644 --- a/korman/operators/op_toolbox.py +++ b/korman/operators/op_toolbox.py @@ -183,7 +183,7 @@ class PlasmaToggleDoubleSidedOperator(ToolboxOperator, bpy.types.Operator): def execute(self, context): enable = self.enable for mat in bpy.data.materials: - mat.plasma_mat.plasma_double_sided = enable + mat.plasma_material.double_sided = enable return {"FINISHED"} @@ -198,9 +198,9 @@ class PlasmaToggleDoubleSidedSelectOperator(ToolboxOperator, bpy.types.Operator) def execute(self, context): mat_list = [slot.material for slot in itertools.chain.from_iterable((i.material_slots for i in context.selected_objects)) if slot and slot.material] - enable = not all((mat.plasma_mat.plasma_double_sided for mat in mat_list)) + enable = not all((mat.plasma_material.double_sided for mat in mat_list)) for mat in mat_list: - mat.plasma_mat.plasma_double_sided = enable + mat.plasma_material.double_sided = enable return {"FINISHED"} diff --git a/korman/properties/prop_material.py b/korman/properties/prop_material.py index 7d82208..eeb742d 100644 --- a/korman/properties/prop_material.py +++ b/korman/properties/prop_material.py @@ -22,6 +22,6 @@ class PlasmaMaterial(bpy.types.PropertyGroup): bl_idname = "material.plasma_material" double_sided = BoolProperty(name="Double Sided", - description="Sets this material as double sided (formerly TWOSIDE)", - default=False) + description="Sets this material as double sided (formerly TWOSIDE)", + default=False)