refactor. and finish basic of adding component

This commit is contained in:
2023-12-07 21:28:23 +08:00
parent ae9a848864
commit ebb22c9ec1
6 changed files with 475 additions and 392 deletions

View File

@ -5,16 +5,13 @@ from . import UTIL_naming_convension
class RawPreferences():
cBallanceTextureFolder: typing.ClassVar[str] = ""
cNoComponentCollection: typing.ClassVar[str] = ""
cDefaultNamingConvention: typing.ClassVar[UTIL_naming_convension.NamingConvention] = UTIL_naming_convension._EnumPropHelper.get_default_naming_identifier()
mBallanceTextureFolder: str
mNoComponentCollection: str
mDefaultNamingConvention: UTIL_naming_convension.NamingConvention
def __init__(self, **kwargs):
self.mBallanceTextureFolder = kwargs.get("mBallanceTextureFolder", "")
self.mNoComponentCollection = kwargs.get("mNoComponentCollection", "")
self.mDefaultNamingConvention = kwargs.get('mDefaultNamingConvention', UTIL_naming_convension._EnumPropHelper.get_default_naming_identifier())
def has_valid_blc_tex_folder(self) -> bool:
return os.path.isdir(self.mBallanceTextureFolder)
@ -34,13 +31,6 @@ class BBPPreferences(bpy.types.AddonPreferences):
description = "(Import) The object which stored in this collectiion will not be saved as component. (Export) All forced no component objects will be stored in this collection",
default = RawPreferences.cNoComponentCollection,
)
default_naming_convention: bpy.props.EnumProperty(
name = "Default Naming Convention",
description = "The default naming convention when creating objects, import and export BM files.",
items = UTIL_naming_convension._EnumPropHelper.generate_items(),
default = UTIL_naming_convension._EnumPropHelper.to_selection(RawPreferences.cDefaultNamingConvention),
)
def draw(self, context):
layout = self.layout
@ -51,8 +41,6 @@ class BBPPreferences(bpy.types.AddonPreferences):
col.prop(self, "ballance_texture_folder", text = "")
col.label(text = "No Component Collection")
col.prop(self, "no_component_collection", text = "")
col.label(text = "Default Naming Convention")
col.prop(self, "default_naming_convention", text = "")
def get_preferences() -> BBPPreferences:
return bpy.context.preferences.addons[__package__].preferences
@ -63,7 +51,6 @@ def get_raw_preferences() -> RawPreferences:
rawdata.mBallanceTextureFolder = pref.ballance_texture_folder
rawdata.mNoComponentCollection = pref.no_component_collection
rawdata.mDefaultNamingConvention = UTIL_naming_convension._EnumPropHelper.get_selection(pref.default_naming_convention)
return rawdata