From bbb02094a174f1675917a645c4ab95094e8fb54f Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 26 May 2018 14:47:05 -0400 Subject: [PATCH] Add the ability to export to tracked games --- korman/operators/op_export.py | 5 ++--- korman/properties/prop_world.py | 4 ++++ korman/ui/ui_world.py | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/korman/operators/op_export.py b/korman/operators/op_export.py index 1b7c4b7..49029c3 100644 --- a/korman/operators/op_export.py +++ b/korman/operators/op_export.py @@ -83,8 +83,7 @@ class ExportOperator(bpy.types.Operator): @classmethod def poll(cls, context): - if context.object is not None: - return context.scene.render.engine == "PLASMA_GAME" + return context.scene.render.engine == "PLASMA_GAME" def execute(self, context): # Before we begin, do some basic sanity checking... @@ -132,7 +131,7 @@ class ExportOperator(bpy.types.Operator): if not self.filepath: blend_filepath = context.blend_data.filepath if not blend_filepath: - blend_filepath = "Korman" + blend_filepath = context.scene.world.plasma_age.age_name self.filepath = str(Path(blend_filepath).with_suffix(".age")) context.window_manager.fileselect_add(self) return {"RUNNING_MODAL"} diff --git a/korman/properties/prop_world.py b/korman/properties/prop_world.py index 557a19d..fdcfb95 100644 --- a/korman/properties/prop_world.py +++ b/korman/properties/prop_world.py @@ -191,6 +191,10 @@ class PlasmaAge(bpy.types.PropertyGroup): use_texture_page = BoolProperty(name="Use Textures Page", description="Exports all textures to a dedicated Textures page", default=True) + age_name = StringProperty(name="Age Name", + description="Name of the Age to be used for data files", + default="Korman Age", + options=set()) # Implementation details active_page_index = IntProperty(name="Active Page Index") diff --git a/korman/ui/ui_world.py b/korman/ui/ui_world.py index 58324d4..695449c 100644 --- a/korman/ui/ui_world.py +++ b/korman/ui/ui_world.py @@ -14,6 +14,9 @@ # along with Korman. If not, see . import bpy +from pathlib import Path + +from ..korlib import ConsoleToggler class AgeButtonsPanel: @@ -32,6 +35,7 @@ class PlasmaGamePanel(AgeButtonsPanel, bpy.types.Panel): def draw(self, context): layout = self.layout games = context.world.plasma_games + age = context.world.plasma_age row = layout.row() row.template_list("PlasmaGameList", "games", games, "games", games, @@ -56,6 +60,9 @@ class PlasmaGamePanel(AgeButtonsPanel, bpy.types.Panel): op = row.operator("world.plasma_game_add", icon="FILE_FOLDER", text="Change Path") op.filepath = active_game.path op.game_index = active_game_index + row.operator_context = "EXEC_DEFAULT" + op = row.operator("export.plasma_age", icon="EXPORT") + op.filepath = str((Path(active_game.path) / "dat" / age.age_name).with_suffix(".age")) class PlasmaGameList(bpy.types.UIList): @@ -114,10 +121,26 @@ class PlasmaAgePanel(AgeButtonsPanel, bpy.types.Panel): col = split.column() col.label("Age Settings:") col.prop(age, "seq_prefix", text="ID") + col.prop(age, "age_name", text="") + + layout.separator() + split = layout.split() + + col = split.column() + col.label("Export Settings:") + col.prop(age, "bake_lighting") + cons_ui = col.column() + cons_ui.enabled = ConsoleToggler.is_platform_supported() + cons_ui.prop(age, "verbose") + cons_ui.prop(age, "show_console") + + col = split.column() + col.label("Plasma Settings:") col.prop(age, "age_sdl") col.prop(age, "use_texture_page") + class PlasmaEnvironmentPanel(AgeButtonsPanel, bpy.types.Panel): bl_label = "Plasma Environment"