mirror of
https://github.com/DarklightGames/io_scene_psk_psa.git
synced 2025-01-19 07:37:22 +01:00
Added human readable errors when bone, material or sequence names cannot be encoded into the Windows-1252 code page
This commit is contained in:
parent
60c7f2125a
commit
8c74987f5b
@ -91,7 +91,11 @@ def build_psa(context: bpy.types.Context, options: PsaBuildOptions) -> Psa:
|
||||
# Build list of PSA bones.
|
||||
for bone in bones:
|
||||
psa_bone = Psa.Bone()
|
||||
psa_bone.name = bytes(bone.name, encoding='windows-1252')
|
||||
|
||||
try:
|
||||
psa_bone.name = bytes(bone.name, encoding='windows-1252')
|
||||
except UnicodeEncodeError:
|
||||
raise RuntimeError(f'Bone name "{bone.name}" contains characters that cannot be encoded in the Windows-1252 codepage')
|
||||
|
||||
try:
|
||||
parent_index = bones.index(bone.parent)
|
||||
@ -165,7 +169,10 @@ def build_psa(context: bpy.types.Context, options: PsaBuildOptions) -> Psa:
|
||||
frame_step = -frame_step
|
||||
|
||||
psa_sequence = Psa.Sequence()
|
||||
psa_sequence.name = bytes(export_sequence.name, encoding='windows-1252')
|
||||
try:
|
||||
psa_sequence.name = bytes(export_sequence.name, encoding='windows-1252')
|
||||
except UnicodeEncodeError:
|
||||
raise RuntimeError(f'Sequence name "{export_sequence.name}" contains characters that cannot be encoded in the Windows-1252 codepage')
|
||||
psa_sequence.frame_count = frame_count
|
||||
psa_sequence.frame_start_index = frame_start_index
|
||||
psa_sequence.fps = frame_count / sequence_duration
|
||||
|
@ -88,7 +88,11 @@ def build_psk(context, options: PskBuildOptions) -> Psk:
|
||||
|
||||
for bone in bones:
|
||||
psk_bone = Psk.Bone()
|
||||
psk_bone.name = bytes(bone.name, encoding='windows-1252')
|
||||
try:
|
||||
psk_bone.name = bytes(bone.name, encoding='windows-1252')
|
||||
except UnicodeEncodeError:
|
||||
raise RuntimeError(
|
||||
f'Bone name "{bone.name}" contains characters that cannot be encoded in the Windows-1252 codepage')
|
||||
psk_bone.flags = 0
|
||||
psk_bone.children_count = 0
|
||||
|
||||
@ -129,7 +133,10 @@ def build_psk(context, options: PskBuildOptions) -> Psk:
|
||||
|
||||
for material_name in material_names:
|
||||
psk_material = Psk.Material()
|
||||
psk_material.name = bytes(material_name, encoding='windows-1252')
|
||||
try:
|
||||
psk_material.name = bytes(material_name, encoding='windows-1252')
|
||||
except UnicodeEncodeError:
|
||||
raise RuntimeError(f'Material name "{material_name}" contains characters that cannot be encoded in the Windows-1252 codepage')
|
||||
psk_material.texture_index = len(psk.materials)
|
||||
psk.materials.append(psk_material)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user