Browse Source

Add plImageLibMods.

pull/115/head
Joseph Davies 6 years ago
parent
commit
eb75794996
Signed by untrusted user: Deledrius
GPG Key ID: 28ACC6E8D2B24B8A
  1. 32
      korman/properties/modifiers/gui.py
  2. 19
      korman/ui/modifiers/gui.py

32
korman/properties/modifiers/gui.py

@ -59,6 +59,38 @@ journal_pfms = {
}, },
} }
class ImageLibraryItem(bpy.types.PropertyGroup):
image = bpy.props.PointerProperty(name="Image Item",
description="Image stored for export.",
type=bpy.types.Image,
options=set())
enabled = bpy.props.BoolProperty(name="Enabled",
description="Specifies whether this image will be stored during export.",
default=True,
options=set())
class PlasmaImageLibraryModifier(PlasmaModifierProperties):
pl_id = "imagelibmod"
bl_category = "GUI"
bl_label = "Image Library"
bl_description = "A collection of images to be stored for later use"
bl_icon = "RENDERLAYERS"
images = CollectionProperty(name="Images", type=ImageLibraryItem, options=set())
active_image_index = IntProperty(options={"HIDDEN"})
def export(self, exporter, bo, so):
if self.images:
ilmod = exporter.mgr.find_create_object(plImageLibMod, so=so, name=self.key_name)
for item in self.images:
if item.image and item.enabled:
exporter.mesh.material.export_prepared_image(owner=ilmod, image=item.image, allowed_formats={"JPG", "PNG"}, extension="hsm")
class PlasmaJournalBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz): class PlasmaJournalBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz):
pl_id = "journalbookmod" pl_id = "journalbookmod"

19
korman/ui/modifiers/gui.py

@ -14,6 +14,25 @@
# along with Korman. If not, see <http://www.gnu.org/licenses/>. # along with Korman. If not, see <http://www.gnu.org/licenses/>.
import bpy import bpy
from pathlib import Path
from . import ui_list
class ImageListUI(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):
if item.image is None:
layout.label("[No Image Specified]", icon="ERROR")
else:
layout.label(str(Path(item.image.name).with_suffix(".hsm")), icon_value=item.image.preview.icon_id)
layout.prop(item, "enabled", text="")
def imagelibmod(modifier, layout, context):
ui_list.draw_modifier_list(layout, "ImageListUI", modifier, "images", "active_image_index", rows=3, maxrows=6)
if modifier.images:
row = layout.row(align=True)
row.template_ID(modifier.images[modifier.active_image_index], "image", open="image.open")
def journalbookmod(modifier, layout, context): def journalbookmod(modifier, layout, context):
layout.prop_menu_enum(modifier, "versions") layout.prop_menu_enum(modifier, "versions")

Loading…
Cancel
Save