Browse Source

Clean up

pull/1/head
Anne Marije v/d Meer 12 years ago
parent
commit
916ae79833
  1. 8
      korman/__init__.py
  2. 21
      korman/exporter.py
  3. 5
      korman/operators/op_export.py
  4. 2
      korman/operators/op_world.py
  5. 1
      korman/properties/__init__.py
  6. 1
      korman/properties/prop_object.py
  7. 12
      korman/properties/prop_world.py
  8. 4
      korman/render.py
  9. 1
      korman/ui/ui_object.py
  10. 1
      korman/ui/ui_world.py

8
korman/__init__.py

@ -20,14 +20,15 @@ from . import operators, properties, ui
bl_info = { bl_info = {
"name": "Korman", "name": "Korman",
"author": "Guild of Writers", "author": "Guild of Writers",
"blender": (2, 67, 0), # I can't be bothered to support old stuff "blender": (2, 67, 0), # I can't be bothered to support old stuff
"location": "File > Import-Export", "location": "File > Import-Export",
"description": "Exporter for Cyan Worlds' Plasma Engine", "description": "Exporter for Cyan Worlds' Plasma Engine",
"warning": "alpha", "warning": "alpha",
"category": "System", # Eventually, we will hide some of the default "category": "System", # Eventually, we will hide some of the default
# Blender panels (think materials) # Blender panels (think materials)
} }
def register(): def register():
"""Registers all Blender operators and GUI items in Korman""" """Registers all Blender operators and GUI items in Korman"""
@ -38,6 +39,7 @@ def register():
operators.register() operators.register()
properties.register() properties.register()
def unregister(): def unregister():
"""Unregisters all Blender operators and GUI items""" """Unregisters all Blender operators and GUI items"""
bpy.utils.unregister_module(__name__) bpy.utils.unregister_module(__name__)

21
korman/exporter.py

@ -17,6 +17,7 @@ import bpy
import os.path import os.path
from PyHSPlasma import * from PyHSPlasma import *
class ExportError(Exception): class ExportError(Exception):
def __init__(self, value="Undefined Export Error"): def __init__(self, value="Undefined Export Error"):
super(Exception, self).__init__(value) super(Exception, self).__init__(value)
@ -24,7 +25,7 @@ class ExportError(Exception):
class Exporter: class Exporter:
def __init__(self, op): def __init__(self, op):
self._op = op # Blender operator self._op = op # Blender operator
# This stuff doesn't need to be static # This stuff doesn't need to be static
self._nodes = {} self._nodes = {}
@ -40,14 +41,13 @@ class Exporter:
location = self._pages[bl.plasma_object.page] location = self._pages[bl.plasma_object.page]
self.mgr.AddObject(location, pl) self.mgr.AddObject(location, pl)
node = self._nodes[location] node = self._nodes[location]
if node: # All objects must be in the scene node if node: # All objects must be in the scene node
if isinstance(pl, plSceneObject): if isinstance(pl, plSceneObject):
f = node.addSceneObject f = node.addSceneObject
else: else:
f = node.addPoolObject f = node.addPoolObject
f(pl.key) f(pl.key)
@property @property
def age_name(self): def age_name(self):
return os.path.splitext(os.path.split(self._op.filepath)[1])[0] return os.path.splitext(os.path.split(self._op.filepath)[1])[0]
@ -100,11 +100,11 @@ class Exporter:
self._collect_objects() self._collect_objects()
# Step 2: Collect some age information # Step 2: Collect some age information
self._grab_age_info() # World Props -> plAgeInfo self._grab_age_info() # World Props -> plAgeInfo
for page in bpy.context.scene.world.plasma_age.pages: for page in bpy.context.scene.world.plasma_age.pages:
self._create_page(page.name, page.seq_suffix) self._create_page(page.name, page.seq_suffix)
self._sanity_check_pages() self._sanity_check_pages()
self._generate_builtins() # Creates BuiltIn and Textures self._generate_builtins() # Creates BuiltIn and Textures
# Step 3: Export all the things! # Step 3: Export all the things!
self._export_scene_objects() self._export_scene_objects()
@ -123,7 +123,7 @@ class Exporter:
age = bpy.context.scene.world.plasma_age age = bpy.context.scene.world.plasma_age
self._age_info = plAgeInfo() self._age_info = plAgeInfo()
self._age_info.dayLength = age.day_length self._age_info.dayLength = age.day_length
self._age_info.lingerTime = 180 # this is fairly standard self._age_info.lingerTime = 180 # this is fairly standard
self._age_info.name = self.age_name self._age_info.name = self.age_name
self._age_info.seqPrefix = age.seq_prefix self._age_info.seqPrefix = age.seq_prefix
self._age_info.startDateTime = age.start_time self._age_info.startDateTime = age.start_time
@ -152,7 +152,8 @@ class Exporter:
def _generate_builtins(self): def _generate_builtins(self):
# Find the highest two available negative suffixes for BuiltIn and Textures # Find the highest two available negative suffixes for BuiltIn and Textures
# This should generally always resolve to -2 and -1 # This should generally always resolve to -2 and -1
suffixes = []; _s = -1 suffixes = []
_s = -1
while len(suffixes) != 2: while len(suffixes) != 2:
for location in self._pages.values(): for location in self._pages.values():
if location.page == _s: if location.page == _s:
@ -166,7 +167,7 @@ class Exporter:
builtin = self._create_page("BuiltIn", suffixes[1], True) builtin = self._create_page("BuiltIn", suffixes[1], True)
pfm = plPythonFileMod("VeryVerySpecialPythonFileMod") pfm = plPythonFileMod("VeryVerySpecialPythonFileMod")
pfm.filename = self.age_name pfm.filename = self.age_name
self.mgr.AddObject(builtin, pfm) # add_object has lots of overhead self.mgr.AddObject(builtin, pfm) # add_object has lots of overhead
sdlhook = plSceneObject("AgeSDLHook") sdlhook = plSceneObject("AgeSDLHook")
sdlhook.addModifier(pfm.key) sdlhook.addModifier(pfm.key)
self.mgr.AddObject(builtin, sdlhook) self.mgr.AddObject(builtin, sdlhook)
@ -176,7 +177,7 @@ class Exporter:
textures = self._create_page("Textures", suffixes[0], True) textures = self._create_page("Textures", suffixes[0], True)
self._pages["Textures"] = textures self._pages["Textures"] = textures
else: else:
self._pages["Textures"] = None # probably easier than looping to find it self._pages["Textures"] = None # probably easier than looping to find it
def _export_scene_objects(self): def _export_scene_objects(self):
for bl_obj in self._objects: for bl_obj in self._objects:
@ -211,7 +212,7 @@ class Exporter:
def _write_pages(self): def _write_pages(self):
dir = os.path.split(self._op.filepath)[0] dir = os.path.split(self._op.filepath)[0]
for name, loc in self._pages.items(): for name, loc in self._pages.items():
page = self.mgr.FindPage(loc) # not cached because it's C++ owned page = self.mgr.FindPage(loc) # not cached because it's C++ owned
# I know that plAgeInfo has its own way of doing this, but we'd have # I know that plAgeInfo has its own way of doing this, but we'd have
# to do some looping and stuff. This is easier. # to do some looping and stuff. This is easier.
if self.version <= pvMoul: if self.version <= pvMoul:

5
korman/operators/op_export.py

@ -17,6 +17,7 @@ import bpy
import os, os.path import os, os.path
from .. import exporter from .. import exporter
class ExportOperator(bpy.types.Operator): class ExportOperator(bpy.types.Operator):
"""Exports ages for Cyan Worlds' Plasma Engine""" """Exports ages for Cyan Worlds' Plasma Engine"""
@ -28,7 +29,7 @@ class ExportOperator(bpy.types.Operator):
version = bpy.props.EnumProperty( version = bpy.props.EnumProperty(
name="Version", 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=[ items=[
("pvPrime", "Ages Beyond Myst (63.11)", "Targets the original Uru (Live) game", 2), ("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), ("pvPots", "Path of the Shell (63.12)", "Targets the most recent offline expansion pack", 1),
@ -91,5 +92,7 @@ def menu_cb(self, context):
if context.scene.render.engine == "PLASMA_GAME": if context.scene.render.engine == "PLASMA_GAME":
self.layout.operator_context = "INVOKE_DEFAULT" self.layout.operator_context = "INVOKE_DEFAULT"
self.layout.operator(ExportOperator.bl_idname, text="Plasma Age (.age)") self.layout.operator(ExportOperator.bl_idname, text="Plasma Age (.age)")
def register(): def register():
bpy.types.INFO_MT_file_export.append(menu_cb) bpy.types.INFO_MT_file_export.append(menu_cb)

2
korman/operators/op_world.py

@ -15,11 +15,13 @@
import bpy import bpy
class AgeOperator: class AgeOperator:
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.scene.render.engine == "PLASMA_GAME" return context.scene.render.engine == "PLASMA_GAME"
class PageAddOperator(AgeOperator, bpy.types.Operator): class PageAddOperator(AgeOperator, bpy.types.Operator):
bl_idname = "world.plasma_page_add" bl_idname = "world.plasma_page_add"
bl_label = "Add Page" bl_label = "Add Page"

1
korman/properties/__init__.py

@ -18,6 +18,7 @@ import bpy
from .prop_object import * from .prop_object import *
from .prop_world import * from .prop_world import *
def register(): def register():
bpy.types.Object.plasma_object = PointerProperty(type=PlasmaObject) bpy.types.Object.plasma_object = PointerProperty(type=PlasmaObject)
bpy.types.World.plasma_age = PointerProperty(type=PlasmaAge) bpy.types.World.plasma_age = PointerProperty(type=PlasmaAge)

1
korman/properties/prop_object.py

@ -16,6 +16,7 @@
import bpy import bpy
from bpy.props import * from bpy.props import *
class PlasmaObject(bpy.types.PropertyGroup): class PlasmaObject(bpy.types.PropertyGroup):
def _enabled(self, context): def _enabled(self, context):
# This makes me sad # This makes me sad

12
korman/properties/prop_world.py

@ -17,6 +17,7 @@ import bpy
from bpy.props import * from bpy.props import *
from PyHSPlasma import * from PyHSPlasma import *
class PlasmaFni(bpy.types.PropertyGroup): class PlasmaFni(bpy.types.PropertyGroup):
bl_idname = "world.plasma_fni" bl_idname = "world.plasma_fni"
@ -29,10 +30,10 @@ class PlasmaFni(bpy.types.PropertyGroup):
("linear", "Linear", "Linear Fog"), ("linear", "Linear", "Linear Fog"),
("exp2", "Exponential", "Exponential Fog"), ("exp2", "Exponential", "Exponential Fog"),
("none", "None", "Use fog from the previous age") ("none", "None", "Use fog from the previous age")
]) ])
fog_start = FloatProperty(name="Start", fog_start = FloatProperty(name="Start",
description="", description="",
default= -1500.0) default=-1500.0)
fog_end = FloatProperty(name="End", fog_end = FloatProperty(name="End",
description="", description="",
default=20000.0) default=20000.0)
@ -49,6 +50,7 @@ class PlasmaFni(bpy.types.PropertyGroup):
soft_min=100, soft_min=100,
min=1) min=1)
class PlasmaPage(bpy.types.PropertyGroup): class PlasmaPage(bpy.types.PropertyGroup):
def _check_suffix(self, context): def _check_suffix(self, context):
"""Verifies that a suffix change does not conflict""" """Verifies that a suffix change does not conflict"""
@ -95,8 +97,8 @@ class PlasmaPage(bpy.types.PropertyGroup):
update=_rename_page) update=_rename_page)
seq_suffix = IntProperty(name="ID", seq_suffix = IntProperty(name="ID",
description="A numerical ID for this page", description="A numerical ID for this page",
soft_min=0, # Negatives indicate global--advanced users only soft_min=0, # Negatives indicate global--advanced users only
default=0, # The add operator will autogen a default default=0, # The add operator will autogen a default
update=_check_suffix) update=_check_suffix)
auto_load = BoolProperty(name="Auto Load", auto_load = BoolProperty(name="Auto Load",
description="Load this page on link-in", description="Load this page on link-in",
@ -128,7 +130,7 @@ class PlasmaAge(bpy.types.PropertyGroup):
min=0) min=0)
seq_prefix = IntProperty(name="Sequence Prefix", seq_prefix = IntProperty(name="Sequence Prefix",
description="A unique numerical ID for this age", description="A unique numerical ID for this age",
soft_min=0, # Negative indicates global--advanced users only soft_min=0, # Negative indicates global--advanced users only
default=100) default=100)
pages = CollectionProperty(name="Pages", pages = CollectionProperty(name="Pages",
description="Registry pages for this age", description="Registry pages for this age",

4
korman/render.py

@ -15,6 +15,7 @@
import bpy import bpy
class PlasmaRenderEngine(bpy.types.RenderEngine): class PlasmaRenderEngine(bpy.types.RenderEngine):
bl_idname = "PLASMA_GAME" bl_idname = "PLASMA_GAME"
@ -28,6 +29,7 @@ properties_material.MATERIAL_PT_context_material.COMPAT_ENGINES.add("PLASMA_GAME
properties_material.MATERIAL_PT_preview.COMPAT_ENGINES.add("PLASMA_GAME") properties_material.MATERIAL_PT_preview.COMPAT_ENGINES.add("PLASMA_GAME")
del properties_material del properties_material
@classmethod @classmethod
def _new_poll(cls, context): def _new_poll(cls, context):
"""Nifty replacement for naughty built-in Blender poll()s""" """Nifty replacement for naughty built-in Blender poll()s"""
@ -36,6 +38,8 @@ def _new_poll(cls, context):
else: else:
# Dear god you better save the old poll... # Dear god you better save the old poll...
return cls._old_poll(cls, context) return cls._old_poll(cls, context)
def _swap_poll(cls): def _swap_poll(cls):
cls._old_poll = cls.poll cls._old_poll = cls.poll
cls.poll = _new_poll cls.poll = _new_poll

1
korman/ui/ui_object.py

@ -15,6 +15,7 @@
import bpy import bpy
class ObjectButtonsPanel: class ObjectButtonsPanel:
bl_space_type = "PROPERTIES" bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW" bl_region_type = "WINDOW"

1
korman/ui/ui_world.py

@ -15,6 +15,7 @@
import bpy import bpy
class AgeButtonsPanel: class AgeButtonsPanel:
bl_space_type = "PROPERTIES" bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW" bl_region_type = "WINDOW"

Loading…
Cancel
Save