From fdb74ef7d0aaa4607d7a9ae52e2e872068dacf40 Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Mon, 27 May 2024 14:56:37 -0700 Subject: [PATCH] Moved things around for packaging on Blender extensions --- io_scene_psk_psa/__init__.py => __init__.py | 23 ++----- blender_manifest.toml | 63 +++++++++++++++++++ build.py | 41 ------------ {io_scene_psk_psa/psa => psa}/__init__.py | 0 {io_scene_psk_psa/psa => psa}/builder.py | 2 +- {io_scene_psk_psa/psa => psa}/config.py | 0 {io_scene_psk_psa/psa => psa}/data.py | 2 +- .../psa => psa}/export/__init__.py | 0 .../psa => psa}/export/operators.py | 2 +- .../psa => psa}/export/properties.py | 2 +- {io_scene_psk_psa/psa => psa}/export/ui.py | 0 .../psa => psa}/import_/__init__.py | 0 .../psa => psa}/import_/operators.py | 0 .../psa => psa}/import_/properties.py | 14 +++++ {io_scene_psk_psa/psa => psa}/import_/ui.py | 0 {io_scene_psk_psa/psa => psa}/importer.py | 0 {io_scene_psk_psa/psa => psa}/reader.py | 0 {io_scene_psk_psa/psa => psa}/writer.py | 2 +- {io_scene_psk_psa/psk => psk}/__init__.py | 0 {io_scene_psk_psa/psk => psk}/builder.py | 2 +- {io_scene_psk_psa/psk => psk}/data.py | 2 +- .../psk => psk}/export/__init__.py | 0 .../psk => psk}/export/operators.py | 2 +- .../psk => psk}/export/properties.py | 2 +- {io_scene_psk_psa/psk => psk}/export/ui.py | 0 .../psk => psk}/import_/__init__.py | 0 .../psk => psk}/import_/operators.py | 0 {io_scene_psk_psa/psk => psk}/importer.py | 2 +- {io_scene_psk_psa/psk => psk}/properties.py | 0 {io_scene_psk_psa/psk => psk}/reader.py | 0 {io_scene_psk_psa/psk => psk}/ui.py | 0 {io_scene_psk_psa/psk => psk}/writer.py | 2 +- shared/__init__.py | 0 {io_scene_psk_psa => shared}/data.py | 0 {io_scene_psk_psa => shared}/helpers.py | 0 {io_scene_psk_psa => shared}/types.py | 0 36 files changed, 93 insertions(+), 70 deletions(-) rename io_scene_psk_psa/__init__.py => __init__.py (87%) create mode 100644 blender_manifest.toml delete mode 100644 build.py rename {io_scene_psk_psa/psa => psa}/__init__.py (100%) rename {io_scene_psk_psa/psa => psa}/builder.py (99%) rename {io_scene_psk_psa/psa => psa}/config.py (100%) rename {io_scene_psk_psa/psa => psa}/data.py (98%) rename {io_scene_psk_psa/psa => psa}/export/__init__.py (100%) rename {io_scene_psk_psa/psa => psa}/export/operators.py (99%) rename {io_scene_psk_psa/psa => psa}/export/properties.py (99%) rename {io_scene_psk_psa/psa => psa}/export/ui.py (100%) rename {io_scene_psk_psa/psa => psa}/import_/__init__.py (100%) rename {io_scene_psk_psa/psa => psa}/import_/operators.py (100%) rename {io_scene_psk_psa/psa => psa}/import_/properties.py (92%) rename {io_scene_psk_psa/psa => psa}/import_/ui.py (100%) rename {io_scene_psk_psa/psa => psa}/importer.py (100%) rename {io_scene_psk_psa/psa => psa}/reader.py (100%) rename {io_scene_psk_psa/psa => psa}/writer.py (95%) rename {io_scene_psk_psa/psk => psk}/__init__.py (100%) rename {io_scene_psk_psa/psk => psk}/builder.py (99%) rename {io_scene_psk_psa/psk => psk}/data.py (99%) rename {io_scene_psk_psa/psk => psk}/export/__init__.py (100%) rename {io_scene_psk_psa/psk => psk}/export/operators.py (99%) rename {io_scene_psk_psa/psk => psk}/export/properties.py (96%) rename {io_scene_psk_psa/psk => psk}/export/ui.py (100%) rename {io_scene_psk_psa/psk => psk}/import_/__init__.py (100%) rename {io_scene_psk_psa/psk => psk}/import_/operators.py (100%) rename {io_scene_psk_psa/psk => psk}/importer.py (99%) rename {io_scene_psk_psa/psk => psk}/properties.py (100%) rename {io_scene_psk_psa/psk => psk}/reader.py (100%) rename {io_scene_psk_psa/psk => psk}/ui.py (100%) rename {io_scene_psk_psa/psk => psk}/writer.py (97%) create mode 100644 shared/__init__.py rename {io_scene_psk_psa => shared}/data.py (100%) rename {io_scene_psk_psa => shared}/helpers.py (100%) rename {io_scene_psk_psa => shared}/types.py (100%) diff --git a/io_scene_psk_psa/__init__.py b/__init__.py similarity index 87% rename from io_scene_psk_psa/__init__.py rename to __init__.py index ab2587b..d99ab81 100644 --- a/io_scene_psk_psa/__init__.py +++ b/__init__.py @@ -1,11 +1,11 @@ from bpy.app.handlers import persistent bl_info = { - 'name': 'PSK/PSA Importer/Exporter', + 'name': 'Unreal PSK/PSA Importer/Exporter', 'author': 'Colin Basnett, Yurii Ti', - 'version': (7, 0, 0), - 'blender': (4, 1, 0), - 'description': 'PSK/PSA Import/Export (.psk/.psa)', + 'version': (7, 1, 0), + 'blender': (4, 2, 0), + 'description': 'Unreal PSK/PSA Import/Export (.psk/.psa)', 'warning': '', 'doc_url': 'https://github.com/DarklightGames/io_scene_psk_psa', 'tracker_url': 'https://github.com/DarklightGames/io_scene_psk_psa/issues', @@ -45,14 +45,7 @@ if 'bpy' in locals(): importlib.reload(psa_import_ui) else: # if i remove this line, it can be enabled just fine - from . import data as psx_data - from . import helpers as psx_helpers - from . import types as psx_types - from .psk import data as psk_data - from .psk import reader as psk_reader - from .psk import writer as psk_writer - from .psk import builder as psk_builder - from .psk import importer as psk_importer + from .shared import types as psx_types from .psk import properties as psk_properties from .psk import ui as psk_ui from .psk.export import properties as psk_export_properties @@ -60,12 +53,6 @@ else: from .psk.export import ui as psk_export_ui from .psk.import_ import operators as psk_import_operators - from .psa import data as psa_data - from .psa import config as psa_config - from .psa import reader as psa_reader - from .psa import writer as psa_writer - from .psa import builder as psa_builder - from .psa import importer as psa_importer from .psa.export import properties as psa_export_properties from .psa.export import operators as psa_export_operators from .psa.export import ui as psa_export_ui diff --git a/blender_manifest.toml b/blender_manifest.toml new file mode 100644 index 0000000..be9e864 --- /dev/null +++ b/blender_manifest.toml @@ -0,0 +1,63 @@ +schema_version = "1.0.0" + +# Example of manifest file for a Blender extension +# Change the values according to your extension +id = "io_scene_psk_psa" +version = "7.1.0" +name = "Unreal PSK/PSA Importer/Exporter" +tagline = "Import and export PSK/PSA files used in Unreal Engine" +maintainer = "Colin Basnett " +# Supported types: "add-on", "theme" +type = "add-on" + +# Optional: add-ons can list which resources they will require: +# * "files" (for access of any filesystem operations) +# * "network" (for internet access) +# * "clipboard" (to read and/or write the system clipboard) +# * "camera" (to capture photos and videos) +# * "microphone" (to capture audio) +permissions = ["files"] + +# Optional link to documentation, support, source files, etc +website = "https://github.com/DarklightGames/io_scene_psk_psa/" + +# Optional list defined by Blender and server, see: +# https://docs.blender.org/manual/en/dev/extensions/tags.html +tags = ["Game Engine", "Import-Export"] + +blender_version_min = "4.2.0" +# Optional: maximum supported Blender version +# blender_version_max = "5.1.0" + +# License conforming to https://spdx.org/licenses/ (use "SPDX: prefix) +# https://docs.blender.org/manual/en/dev/extensions/licenses.html +license = [ + "SPDX:MIT", +] +# Optional: required by some licenses. +# copyright = [ +# "2002-2024 Developer Name", +# "1998 Company Name", +# ] + +# Optional list of supported platforms. If omitted, the extension will be available in all operating systems. +# platforms = ["windows-amd64", "macos-arm64", "linux-x86_64"] +# Other supported platforms: "windows-arm64", "macos-x86_64" + +# Optional: bundle 3rd party Python modules. +# https://docs.blender.org/manual/en/dev/extensions/python_wheels.html +# wheels = [ +# "./wheels/hexdump-3.3-py3-none-any.whl", +# "./wheels/jsmin-3.0.1-py3-none-any.whl" +# ] + +# Optional: build setting. +# https://docs.blender.org/manual/en/dev/extensions/command_line_arguments.html#command-line-args-extension-build +[build] +paths_exclude_pattern = [ + "/.git/", + "__pycache__/", + "/venv/", + "/.github/", + ".gitignore", +] diff --git a/build.py b/build.py deleted file mode 100644 index 4a2ff87..0000000 --- a/build.py +++ /dev/null @@ -1,41 +0,0 @@ -import os -import subprocess -from fnmatch import fnmatch -from zipfile import ZipFile, ZIP_DEFLATED - -ignore_patterns = [ - '*/__pycache__/*', - '*/.git/*', - '*/.github/*', - '*/.idea/*', - '*/venv/*', - '*/.gitignore', - '*/.gitattributes', - '*/build/*', - '*/build.py', -] - - -def zipdir(path, zip_file: ZipFile): - for root, dirs, files in os.walk(path): - for file in files: - if file != zip_file.filename and not any(fnmatch(os.path.join(root, file), pattern) for pattern in ignore_patterns): - zip_file.write(os.path.join(root, file)) - -# Get the branch name. -branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('utf-8').strip() - -# Get the most recent tag. -tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).decode('utf-8').strip() - -# Create a zip file of the current directory. - -zip_path = f'./build/io_scene_psk_psa-{branch}-{tag}.zip' - -# Check that the directory exists, if it doesn't, create it. -if not os.path.exists('./build'): - os.makedirs('./build') - -zipf = ZipFile(zip_path, 'w', ZIP_DEFLATED) -zipdir('.', zipf) -zipf.close() diff --git a/io_scene_psk_psa/psa/__init__.py b/psa/__init__.py similarity index 100% rename from io_scene_psk_psa/psa/__init__.py rename to psa/__init__.py diff --git a/io_scene_psk_psa/psa/builder.py b/psa/builder.py similarity index 99% rename from io_scene_psk_psa/psa/builder.py rename to psa/builder.py index f46d517..d9997a4 100644 --- a/io_scene_psk_psa/psa/builder.py +++ b/psa/builder.py @@ -3,7 +3,7 @@ from typing import Optional from bpy.types import Armature, Bone, Action, PoseBone from .data import * -from ..helpers import * +from ..shared.helpers import * class PsaBuildSequence: diff --git a/io_scene_psk_psa/psa/config.py b/psa/config.py similarity index 100% rename from io_scene_psk_psa/psa/config.py rename to psa/config.py diff --git a/io_scene_psk_psa/psa/data.py b/psa/data.py similarity index 98% rename from io_scene_psk_psa/psa/data.py rename to psa/data.py index 776d244..b881ae6 100644 --- a/io_scene_psk_psa/psa/data.py +++ b/psa/data.py @@ -2,7 +2,7 @@ import typing from collections import OrderedDict from typing import List -from ..data import * +from ..shared.data import * ''' Note that keys are not stored within the Psa object. diff --git a/io_scene_psk_psa/psa/export/__init__.py b/psa/export/__init__.py similarity index 100% rename from io_scene_psk_psa/psa/export/__init__.py rename to psa/export/__init__.py diff --git a/io_scene_psk_psa/psa/export/operators.py b/psa/export/operators.py similarity index 99% rename from io_scene_psk_psa/psa/export/operators.py rename to psa/export/operators.py index 6115774..b7c970b 100644 --- a/io_scene_psk_psa/psa/export/operators.py +++ b/psa/export/operators.py @@ -11,7 +11,7 @@ from bpy_types import Operator from .properties import PSA_PG_export, PSA_PG_export_action_list_item, filter_sequences from ..builder import build_psa, PsaBuildSequence, PsaBuildOptions from ..writer import write_psa -from ...helpers import populate_bone_collection_list, get_nla_strips_in_frame_range +from ...shared.helpers import populate_bone_collection_list, get_nla_strips_in_frame_range def is_action_for_armature(armature: Armature, action: Action): diff --git a/io_scene_psk_psa/psa/export/properties.py b/psa/export/properties.py similarity index 99% rename from io_scene_psk_psa/psa/export/properties.py rename to psa/export/properties.py index b92802f..22e6824 100644 --- a/io_scene_psk_psa/psa/export/properties.py +++ b/psa/export/properties.py @@ -7,7 +7,7 @@ from bpy.props import BoolProperty, PointerProperty, EnumProperty, FloatProperty StringProperty from bpy.types import PropertyGroup, Object, Action, AnimData, Context -from ...types import PSX_PG_bone_collection_list_item +from ...shared.types import PSX_PG_bone_collection_list_item def psa_export_property_group_animation_data_override_poll(_context, obj): diff --git a/io_scene_psk_psa/psa/export/ui.py b/psa/export/ui.py similarity index 100% rename from io_scene_psk_psa/psa/export/ui.py rename to psa/export/ui.py diff --git a/io_scene_psk_psa/psa/import_/__init__.py b/psa/import_/__init__.py similarity index 100% rename from io_scene_psk_psa/psa/import_/__init__.py rename to psa/import_/__init__.py diff --git a/io_scene_psk_psa/psa/import_/operators.py b/psa/import_/operators.py similarity index 100% rename from io_scene_psk_psa/psa/import_/operators.py rename to psa/import_/operators.py diff --git a/io_scene_psk_psa/psa/import_/properties.py b/psa/import_/properties.py similarity index 92% rename from io_scene_psk_psa/psa/import_/properties.py rename to psa/import_/properties.py index e66f7e1..665d98f 100644 --- a/io_scene_psk_psa/psa/import_/properties.py +++ b/psa/import_/properties.py @@ -89,6 +89,20 @@ class PSA_PG_import(PropertyGroup): soft_max=60.0, step=100, ) + compression_ratio_source: EnumProperty(name='Compression Ratio Source', items=( + ('ACTION', 'Action', 'The compression ratio is sourced from the action metadata', 'ACTION', 0), + ('CUSTOM', 'Custom', 'The compression ratio is set to a custom value', 1), + )) + compression_ratio_custom: FloatProperty( + default=1.0, + name='Custom Compression Ratio', + description='The compression ratio to apply to the imported sequences', + options=empty_set, + min=0.0, + soft_min=0.0, + soft_max=1.0, + step=0.0625, + ) def filter_sequences(pg: PSA_PG_import, sequences) -> List[int]: diff --git a/io_scene_psk_psa/psa/import_/ui.py b/psa/import_/ui.py similarity index 100% rename from io_scene_psk_psa/psa/import_/ui.py rename to psa/import_/ui.py diff --git a/io_scene_psk_psa/psa/importer.py b/psa/importer.py similarity index 100% rename from io_scene_psk_psa/psa/importer.py rename to psa/importer.py diff --git a/io_scene_psk_psa/psa/reader.py b/psa/reader.py similarity index 100% rename from io_scene_psk_psa/psa/reader.py rename to psa/reader.py diff --git a/io_scene_psk_psa/psa/writer.py b/psa/writer.py similarity index 95% rename from io_scene_psk_psa/psa/writer.py rename to psa/writer.py index 64fea60..a451108 100644 --- a/io_scene_psk_psa/psa/writer.py +++ b/psa/writer.py @@ -2,7 +2,7 @@ from ctypes import Structure, sizeof from typing import Type from .data import Psa -from ..data import Section +from ..shared.data import Section def write_section(fp, name: bytes, data_type: Type[Structure] = None, data: list = None): diff --git a/io_scene_psk_psa/psk/__init__.py b/psk/__init__.py similarity index 100% rename from io_scene_psk_psa/psk/__init__.py rename to psk/__init__.py diff --git a/io_scene_psk_psa/psk/builder.py b/psk/builder.py similarity index 99% rename from io_scene_psk_psa/psk/builder.py rename to psk/builder.py index 05d1654..661f141 100644 --- a/io_scene_psk_psa/psk/builder.py +++ b/psk/builder.py @@ -7,7 +7,7 @@ from bpy.types import Armature, Material from .data import * from .properties import triangle_type_and_bit_flags_to_poly_flags -from ..helpers import * +from ..shared.helpers import * class PskInputObjects(object): diff --git a/io_scene_psk_psa/psk/data.py b/psk/data.py similarity index 99% rename from io_scene_psk_psa/psk/data.py rename to psk/data.py index 03bd49a..a060229 100644 --- a/io_scene_psk_psa/psk/data.py +++ b/psk/data.py @@ -1,6 +1,6 @@ from typing import List -from ..data import * +from ..shared.data import * class Psk(object): diff --git a/io_scene_psk_psa/psk/export/__init__.py b/psk/export/__init__.py similarity index 100% rename from io_scene_psk_psa/psk/export/__init__.py rename to psk/export/__init__.py diff --git a/io_scene_psk_psa/psk/export/operators.py b/psk/export/operators.py similarity index 99% rename from io_scene_psk_psa/psk/export/operators.py rename to psk/export/operators.py index 5c4e5df..04d5d39 100644 --- a/io_scene_psk_psa/psk/export/operators.py +++ b/psk/export/operators.py @@ -4,7 +4,7 @@ from bpy_extras.io_utils import ExportHelper from ..builder import build_psk, PskBuildOptions, get_psk_input_objects from ..writer import write_psk -from ...helpers import populate_bone_collection_list +from ...shared.helpers import populate_bone_collection_list def is_bone_filter_mode_item_available(context, identifier): diff --git a/io_scene_psk_psa/psk/export/properties.py b/psk/export/properties.py similarity index 96% rename from io_scene_psk_psa/psk/export/properties.py rename to psk/export/properties.py index 536ca62..111cbf0 100644 --- a/io_scene_psk_psa/psk/export/properties.py +++ b/psk/export/properties.py @@ -1,7 +1,7 @@ from bpy.props import EnumProperty, CollectionProperty, IntProperty, BoolProperty, PointerProperty from bpy.types import PropertyGroup, Material -from ...types import PSX_PG_bone_collection_list_item +from ...shared.types import PSX_PG_bone_collection_list_item empty_set = set() diff --git a/io_scene_psk_psa/psk/export/ui.py b/psk/export/ui.py similarity index 100% rename from io_scene_psk_psa/psk/export/ui.py rename to psk/export/ui.py diff --git a/io_scene_psk_psa/psk/import_/__init__.py b/psk/import_/__init__.py similarity index 100% rename from io_scene_psk_psa/psk/import_/__init__.py rename to psk/import_/__init__.py diff --git a/io_scene_psk_psa/psk/import_/operators.py b/psk/import_/operators.py similarity index 100% rename from io_scene_psk_psa/psk/import_/operators.py rename to psk/import_/operators.py diff --git a/io_scene_psk_psa/psk/importer.py b/psk/importer.py similarity index 99% rename from io_scene_psk_psa/psk/importer.py rename to psk/importer.py index ddeeab5..de8ddc7 100644 --- a/io_scene_psk_psa/psk/importer.py +++ b/psk/importer.py @@ -8,7 +8,7 @@ from mathutils import Quaternion, Vector, Matrix from .data import Psk from .properties import poly_flags_to_triangle_type_and_bit_flags -from ..helpers import rgb_to_srgb, is_bdk_addon_loaded +from ..shared.helpers import rgb_to_srgb, is_bdk_addon_loaded class PskImportOptions: diff --git a/io_scene_psk_psa/psk/properties.py b/psk/properties.py similarity index 100% rename from io_scene_psk_psa/psk/properties.py rename to psk/properties.py diff --git a/io_scene_psk_psa/psk/reader.py b/psk/reader.py similarity index 100% rename from io_scene_psk_psa/psk/reader.py rename to psk/reader.py diff --git a/io_scene_psk_psa/psk/ui.py b/psk/ui.py similarity index 100% rename from io_scene_psk_psa/psk/ui.py rename to psk/ui.py diff --git a/io_scene_psk_psa/psk/writer.py b/psk/writer.py similarity index 97% rename from io_scene_psk_psa/psk/writer.py rename to psk/writer.py index 5dae319..ff94b90 100644 --- a/io_scene_psk_psa/psk/writer.py +++ b/psk/writer.py @@ -2,7 +2,7 @@ from ctypes import Structure, sizeof from typing import Type from .data import Psk -from ..data import Section, Vector3 +from ..shared.data import Section, Vector3 MAX_WEDGE_COUNT = 65536 MAX_POINT_COUNT = 4294967296 diff --git a/shared/__init__.py b/shared/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/io_scene_psk_psa/data.py b/shared/data.py similarity index 100% rename from io_scene_psk_psa/data.py rename to shared/data.py diff --git a/io_scene_psk_psa/helpers.py b/shared/helpers.py similarity index 100% rename from io_scene_psk_psa/helpers.py rename to shared/helpers.py diff --git a/io_scene_psk_psa/types.py b/shared/types.py similarity index 100% rename from io_scene_psk_psa/types.py rename to shared/types.py