Browse Source

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.
pull/9/head
Adam Johnson 10 years ago
parent
commit
3e51091501
  1. 1
      korman/operators/__init__.py
  2. 50
      korman/operators/op_toolbox.py
  3. 3
      korman/ui/__init__.py
  4. 38
      korman/ui/ui_toolbox.py

1
korman/operators/__init__.py

@ -16,6 +16,7 @@
from . import op_export as exporter from . import op_export as exporter
from . import op_lightmap as lightmap from . import op_lightmap as lightmap
from . import op_modifier as modifier from . import op_modifier as modifier
from . import op_toolbox as toolbox
from . import op_world as world from . import op_world as world
def register(): def register():

50
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 <http://www.gnu.org/licenses/>.
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"}

3
korman/ui/__init__.py

@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>. # along with Korman. If not, see <http://www.gnu.org/licenses/>.
from .ui_object import *
from .ui_modifiers import * from .ui_modifiers import *
from .ui_object import *
from .ui_toolbox import *
from .ui_world import * from .ui_world import *

38
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 <http://www.gnu.org/licenses/>.
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")
Loading…
Cancel
Save