diff --git a/korman/operators/op_export.py b/korman/operators/op_export.py index ded0414..024f913 100644 --- a/korman/operators/op_export.py +++ b/korman/operators/op_export.py @@ -21,7 +21,7 @@ import pstats from .. import exporter from ..properties.prop_world import PlasmaAge - +from ..properties.modifiers.logic import game_versions class ExportOperator(bpy.types.Operator): """Exports ages for Cyan Worlds' Plasma Engine""" @@ -44,9 +44,7 @@ class ExportOperator(bpy.types.Operator): "version": (EnumProperty, {"name": "Version", "description": "Version of the Plasma Engine to target", "default": "pvPots", # This should be changed when moul is easier to target! - "items": [("pvPrime", "Ages Beyond Myst (63.11)", "Targets the original Uru (Live) game", 2), - ("pvPots", "Path of the Shell (63.12)", "Targets the most recent offline expansion pack", 1), - ("pvMoul", "Myst Online: Uru Live (70)", "Targets the most recent online game", 0)]}), + "items": game_versions}), } # This wigs out and very bad things happen if it's not directly on the operator... diff --git a/korman/properties/modifiers/logic.py b/korman/properties/modifiers/logic.py index d622c5f..9ee7dd3 100644 --- a/korman/properties/modifiers/logic.py +++ b/korman/properties/modifiers/logic.py @@ -18,6 +18,28 @@ from bpy.props import * from PyHSPlasma import * from .base import PlasmaModifierProperties +from ...exporter import ExportError + +game_versions = [("pvPrime", "Ages Beyond Myst (63.11)", "Targets the original Uru (Live) game"), + ("pvPots", "Path of the Shell (63.12)", "Targets the most recent offline expansion pack"), + ("pvMoul", "Myst Online: Uru Live (70)", "Targets the most recent online game")] + +class PlasmaVersionedNodeTree(bpy.types.PropertyGroup): + name = StringProperty(name="Name") + version = EnumProperty(name="Version", + description="Plasma versions this node tree exports under", + items=game_versions, + options={"ENUM_FLAG"}, + default=set(list(zip(*game_versions))[0])) + node_tree_name = StringProperty(name="Node Tree", + description="Node Tree to export") + + @property + def node_tree(self): + try: + return bpy.data.node_groups[self.node_tree_name] + except KeyError: + raise ExportError("Node Tree {} does not exist!".format(self.node_tree_name)) class PlasmaAdvancedLogic(PlasmaModifierProperties): pl_id = "advanced_logic" @@ -27,19 +49,25 @@ class PlasmaAdvancedLogic(PlasmaModifierProperties): bl_description = "Plasma Logic Nodes" bl_icon = "NODETREE" - tree_name = StringProperty(name="Node Tree", description="Plasma Logic Nodes") + logic_groups = CollectionProperty(type=PlasmaVersionedNodeTree) + active_group_index = IntProperty(options={"HIDDEN"}) def created(self, obj): self.display_name = "Advanced Logic" def export(self, exporter, bo, so): - tree = bpy.data.node_groups[self.tree_name] - tree.export(exporter, bo, so) + version = exporter.mgr.getVer() + for i in self.logic_groups: + our_versions = [globals()[j] for j in i.version] + if version in our_versions: + i.node_tree.export(exporter, bo, so) @property def requires_actor(self): - tree = bpy.data.node_groups[self.tree_name] - return tree.requires_actor + for i in self.logic_groups: + if i.node_tree.requires_actor: + return True + return False class PlasmaSpawnPoint(PlasmaModifierProperties): diff --git a/korman/ui/modifiers/logic.py b/korman/ui/modifiers/logic.py index e6cad98..70f53f9 100644 --- a/korman/ui/modifiers/logic.py +++ b/korman/ui/modifiers/logic.py @@ -15,8 +15,31 @@ import bpy +class LogicListUI(bpy.types.UIList): + def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0): + layout.prop(item, "name", emboss=False, text="", icon="NODETREE") + def advanced_logic(modifier, layout, context): - layout.prop_search(modifier, "tree_name", bpy.data, "node_groups", icon="NODETREE") + row = layout.row() + row.template_list("LogicListUI", "logic_groups", modifier, "logic_groups", modifier, "active_group_index", + rows=2, maxrows=3) + col = row.column(align=True) + op = col.operator("object.plasma_modifier_collection_add", icon="ZOOMIN", text="") + op.modifier = modifier.pl_id + op.collection = "logic_groups" + op.name_prefix = "Logic" + op.name_prop = "name" + op = col.operator("object.plasma_modifier_collection_remove", icon="ZOOMOUT", text="") + op.modifier = modifier.pl_id + op.collection = "logic_groups" + op.index = modifier.active_group_index + + # Modify the loop points + if modifier.logic_groups: + logic = modifier.logic_groups[modifier.active_group_index] + row = layout.row() + row.prop_menu_enum(logic, "version") + row.prop_search(logic, "node_tree_name", bpy.data, "node_groups", icon="NODETREE", text="") def spawnpoint(modifier, layout, context): layout.label(text="Avatar faces negative Y.")