1
0
mirror of https://github.com/DarklightGames/io_scene_psk_psa.git synced 2024-11-23 22:40:59 +01:00

Moved things around for packaging on Blender extensions

This commit is contained in:
Colin Basnett 2024-05-27 14:56:37 -07:00
parent a47b4a1e04
commit fdb74ef7d0
36 changed files with 93 additions and 70 deletions

View File

@ -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

63
blender_manifest.toml Normal file
View File

@ -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 <cmbasnett@gmail.com>"
# 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",
]

View File

@ -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()

View File

@ -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:

View File

@ -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.

View File

@ -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):

View File

@ -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):

View File

@ -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]:

View File

@ -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):

View File

@ -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):

View File

@ -1,6 +1,6 @@
from typing import List
from ..data import *
from ..shared.data import *
class Psk(object):

View File

@ -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):

View File

@ -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()

View File

@ -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:

View File

@ -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

0
shared/__init__.py Normal file
View File