Browse Source

Make the Advanced Logic modifier smarter

You can now attach many node trees to this modifier and specify which
versions of the game they should export for. Handy!
pull/10/head
Adam Johnson 10 years ago
parent
commit
5d33ca7abb
  1. 6
      korman/operators/op_export.py
  2. 38
      korman/properties/modifiers/logic.py
  3. 25
      korman/ui/modifiers/logic.py

6
korman/operators/op_export.py

@ -21,7 +21,7 @@ import pstats
from .. import exporter from .. import exporter
from ..properties.prop_world import PlasmaAge from ..properties.prop_world import PlasmaAge
from ..properties.modifiers.logic import game_versions
class ExportOperator(bpy.types.Operator): class ExportOperator(bpy.types.Operator):
"""Exports ages for Cyan Worlds' Plasma Engine""" """Exports ages for Cyan Worlds' Plasma Engine"""
@ -44,9 +44,7 @@ class ExportOperator(bpy.types.Operator):
"version": (EnumProperty, {"name": "Version", "version": (EnumProperty, {"name": "Version",
"description": "Version of the Plasma Engine to target", "description": "Version of the Plasma Engine to target",
"default": "pvPots", # This should be changed when moul is easier 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), "items": game_versions}),
("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)]}),
} }
# This wigs out and very bad things happen if it's not directly on the operator... # This wigs out and very bad things happen if it's not directly on the operator...

38
korman/properties/modifiers/logic.py

@ -18,6 +18,28 @@ from bpy.props import *
from PyHSPlasma import * from PyHSPlasma import *
from .base import PlasmaModifierProperties 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): class PlasmaAdvancedLogic(PlasmaModifierProperties):
pl_id = "advanced_logic" pl_id = "advanced_logic"
@ -27,19 +49,25 @@ class PlasmaAdvancedLogic(PlasmaModifierProperties):
bl_description = "Plasma Logic Nodes" bl_description = "Plasma Logic Nodes"
bl_icon = "NODETREE" 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): def created(self, obj):
self.display_name = "Advanced Logic" self.display_name = "Advanced Logic"
def export(self, exporter, bo, so): def export(self, exporter, bo, so):
tree = bpy.data.node_groups[self.tree_name] version = exporter.mgr.getVer()
tree.export(exporter, bo, so) 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 @property
def requires_actor(self): def requires_actor(self):
tree = bpy.data.node_groups[self.tree_name] for i in self.logic_groups:
return tree.requires_actor if i.node_tree.requires_actor:
return True
return False
class PlasmaSpawnPoint(PlasmaModifierProperties): class PlasmaSpawnPoint(PlasmaModifierProperties):

25
korman/ui/modifiers/logic.py

@ -15,8 +15,31 @@
import bpy 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): 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): def spawnpoint(modifier, layout, context):
layout.label(text="Avatar faces negative Y.") layout.label(text="Avatar faces negative Y.")

Loading…
Cancel
Save