From c8d59ef5f4170a0788fe8edd171d2d65dc611a05 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sat, 21 Sep 2024 22:59:14 +0800 Subject: [PATCH] feat: update PyBMap dependency. - update PyBMap dependency. - use BMap 0.2 instead of old one. - change default encoding name string according to the change of LibCmo changes. --- bbp_ng/PyBMap/bmap.py | 12 ++++++++---- bbp_ng/UTIL_ioport_shared.py | 12 ++++++------ bbp_ng/UTIL_virtools_types.py | 11 ++++------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bbp_ng/PyBMap/bmap.py b/bbp_ng/PyBMap/bmap.py index 5926c8b..8d79def 100644 --- a/bbp_ng/PyBMap/bmap.py +++ b/bbp_ng/PyBMap/bmap.py @@ -78,12 +78,13 @@ elif sys.platform.startswith('darwin'): else: _g_BMapLibName = "BMap.bin" +_g_BMapLibPath: str = os.path.join(os.path.dirname(__file__), _g_BMapLibName) + _g_BMapModule: ctypes.CDLL | None = None try: - _g_BMapModule = ctypes.cdll.LoadLibrary( - os.path.join(os.path.dirname(__file__), _g_BMapLibName) - ) + _g_BMapModule = ctypes.cdll.LoadLibrary(_g_BMapLibPath) except: + print(f'Fail to load native BMap dynamic library file "{_g_BMapLibPath}".') _g_BMapModule = None def is_bmap_available() -> bool: @@ -107,6 +108,8 @@ def _create_bmap_func(fct_name: str, fct_params: list[typing.Any]) -> typing.Cal #region Function Defines +##### GENERATED FUNCTIONS BEGIN ##### + ## BMInit # @return True if no error, otherwise False. BMInit = _create_bmap_func('BMInit', []) @@ -781,5 +784,6 @@ BM3dObject_GetVisibility = _create_bmap_func('BM3dObject_GetVisibility', [bm_voi # @return True if no error, otherwise False. BM3dObject_SetVisibility = _create_bmap_func('BM3dObject_SetVisibility', [bm_void_p, bm_CKID, bm_bool]) -#endregion +##### GENERATED FUNCTIONS END ##### +#endregion diff --git a/bbp_ng/UTIL_ioport_shared.py b/bbp_ng/UTIL_ioport_shared.py index ceffa5a..5d18ece 100644 --- a/bbp_ng/UTIL_ioport_shared.py +++ b/bbp_ng/UTIL_ioport_shared.py @@ -128,28 +128,28 @@ class ImportParams(): items = _g_EnumHelper_ConflictStrategy.generate_items(), description = "Define how to process texture name conflict", default = _g_EnumHelper_ConflictStrategy.to_selection(ConflictStrategy.Current), - ) + ) # type: ignore material_conflict_strategy: bpy.props.EnumProperty( name = "Material Name Conflict", items = _g_EnumHelper_ConflictStrategy.generate_items(), description = "Define how to process material name conflict", default = _g_EnumHelper_ConflictStrategy.to_selection(ConflictStrategy.Rename), - ) + ) # type: ignore mesh_conflict_strategy: bpy.props.EnumProperty( name = "Mesh Name Conflict", items = _g_EnumHelper_ConflictStrategy.generate_items(), description = "Define how to process mesh name conflict", default = _g_EnumHelper_ConflictStrategy.to_selection(ConflictStrategy.Rename), - ) + ) # type: ignore object_conflict_strategy: bpy.props.EnumProperty( name = "Object Name Conflict", items = _g_EnumHelper_ConflictStrategy.generate_items(), description = "Define how to process object name conflict", default = _g_EnumHelper_ConflictStrategy.to_selection(ConflictStrategy.Rename), - ) + ) # type: ignore def draw_import_params(self, layout: bpy.types.UILayout) -> None: layout.label(text = 'Object Name Conflict') @@ -188,7 +188,7 @@ class ExportParams(): ('COLLECTION', "Collection", "Export a collection", 'OUTLINER_COLLECTION', 0), ('OBJECT', "Object", "Export an object", 'OBJECT_DATA', 1), ), - ) + ) # type: ignore def draw_export_params(self, layout: bpy.types.UILayout) -> None: # make prop expand horizontaly, not vertical. @@ -221,7 +221,7 @@ class VirtoolsParams(): name = "Encodings", description = "The encoding list used by Virtools engine to resolve object name. Use `;` to split multiple encodings", default = UTIL_virtools_types.g_PyBMapDefaultEncoding - ) + ) # type: ignore def draw_virtools_params(self, layout: bpy.types.UILayout) -> None: layout.label(text = 'Encodings') diff --git a/bbp_ng/UTIL_virtools_types.py b/bbp_ng/UTIL_virtools_types.py index 6dd045f..e393f89 100644 --- a/bbp_ng/UTIL_virtools_types.py +++ b/bbp_ng/UTIL_virtools_types.py @@ -227,12 +227,9 @@ def virtools_name_regulator(name: str | None) -> str: ## Default Encoding for PyBMap # Use semicolon split each encodings. Support Western European and Simplified Chinese in default. -g_PyBMapDefaultEncoding: str -if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): - # See: https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers - g_PyBMapDefaultEncoding = "1252;936" -else: - # See: https://www.gnu.org/software/libiconv/ - g_PyBMapDefaultEncoding = "CP1252;CP936" +# Since LibCmo 0.2, the encoding name of LibCmo become universal encoding which is platfoorm independent. +# So no need set it according to different platform. +# Use universal encoding name (like Python). +g_PyBMapDefaultEncoding: str = 'cp1252;gb2312' #endregion