From 3e51091501fe92eacce49d12e86287a930147535 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 28 Jun 2015 20:15:18 -0400 Subject: [PATCH] Implement useful toolbox utils for PyPRP porting As requested by Doobes, we now have buttons that enable Plasma Object on everything and all Textures. These are mostly useful for the case of updating from PyPRP, which was opt-out and totally ignored the checked-ness of Textures. --- korman/operators/__init__.py | 1 + korman/operators/op_toolbox.py | 50 ++++++++++++++++++++++++++++++++++ korman/ui/__init__.py | 3 +- korman/ui/ui_toolbox.py | 38 ++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 korman/operators/op_toolbox.py create mode 100644 korman/ui/ui_toolbox.py diff --git a/korman/operators/__init__.py b/korman/operators/__init__.py index f0c38fe..65305c0 100644 --- a/korman/operators/__init__.py +++ b/korman/operators/__init__.py @@ -16,6 +16,7 @@ from . import op_export as exporter from . import op_lightmap as lightmap from . import op_modifier as modifier +from . import op_toolbox as toolbox from . import op_world as world def register(): diff --git a/korman/operators/op_toolbox.py b/korman/operators/op_toolbox.py new file mode 100644 index 0000000..3e52d3a --- /dev/null +++ b/korman/operators/op_toolbox.py @@ -0,0 +1,50 @@ +# 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 + +class ToolboxOperator: + @classmethod + def poll(cls, context): + return context.scene.render.engine == "PLASMA_GAME" + + +class PlasmaEnablePlasmaObjectOperator(ToolboxOperator, bpy.types.Operator): + bl_idname = "object.plasma_enable_all_objects" + bl_label = "Plasma Objects" + bl_description = "Marks all Objects as Plasma Objects for exporting" + + def execute(self, context): + for i in bpy.data.objects: + i.plasma_object.enabled = True + return {"FINISHED"} + + +class PlasmaEnableTexturesOperator(ToolboxOperator, bpy.types.Operator): + bl_idname = "texture.plasma_enable_all_textures" + bl_label = "Textures" + bl_description = "Ensures that all Textures are enabled" + + def execute(self, context): + for mesh in bpy.data.meshes: + for material in mesh.materials: + if material is None: + continue + + for slot in material.texture_slots: + if slot is None: + continue + slot.use = True + return {"FINISHED"} diff --git a/korman/ui/__init__.py b/korman/ui/__init__.py index 1416d1e..0c04b5e 100644 --- a/korman/ui/__init__.py +++ b/korman/ui/__init__.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU General Public License # along with Korman. If not, see . -from .ui_object import * from .ui_modifiers import * +from .ui_object import * +from .ui_toolbox import * from .ui_world import * diff --git a/korman/ui/ui_toolbox.py b/korman/ui/ui_toolbox.py new file mode 100644 index 0000000..af25c12 --- /dev/null +++ b/korman/ui/ui_toolbox.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 + +class ToolboxPanel: + bl_category = "Tools" + bl_space_type = "VIEW_3D" + bl_region_type = "TOOLS" + + @classmethod + def poll(cls, context): + return context.object and context.scene.render.engine == "PLASMA_GAME" + + +class PlasmaToolboxPanel(ToolboxPanel, bpy.types.Panel): + bl_context = "objectmode" + bl_label = "Plasma" + + def draw(self, context): + layout = self.layout + col = layout.column(align=True) + + col.label("Enable All:") + col.operator("object.plasma_enable_all_objects", icon="OBJECT_DATA") + col.operator("texture.plasma_enable_all_textures", icon="TEXTURE")