2023-10-14 11:48:41 +08:00
import bpy
2023-11-29 22:12:04 +08:00
import os , typing
2026-03-20 14:50:05 +08:00
from dataclasses import dataclass
from dataclasses import field as datafield
2025-07-18 14:10:49 +08:00
from . import UTIL_naming_convention
2023-10-14 11:48:41 +08:00
2026-03-20 14:50:05 +08:00
@dataclass
2023-10-14 11:48:41 +08:00
class RawPreferences ( ) :
2026-03-20 14:50:05 +08:00
mBallanceTextureFolder : str = datafield ( default = " " )
mNoComponentCollection : str = datafield ( default = " " )
2023-10-14 11:48:41 +08:00
def has_valid_blc_tex_folder ( self ) - > bool :
return os . path . isdir ( self . mBallanceTextureFolder )
2026-03-20 14:50:05 +08:00
DEFAULT_RAW_PREFERENCES = RawPreferences ( )
2023-10-14 11:48:41 +08:00
class BBPPreferences ( bpy . types . AddonPreferences ) :
bl_idname = __package__
ballance_texture_folder : bpy . props . StringProperty (
name = " Ballance Texture Folder " ,
description = " The path to folder which will be used by this plugin to get external Ballance texture. " ,
2025-01-11 21:36:11 +08:00
subtype = ' DIR_PATH ' ,
2026-03-20 14:50:05 +08:00
default = DEFAULT_RAW_PREFERENCES . mBallanceTextureFolder ,
2025-01-11 21:36:11 +08:00
translation_context = ' BBPPreferences/property '
2024-12-30 17:53:42 +08:00
) # type: ignore
2023-10-14 11:48:41 +08:00
no_component_collection : bpy . props . StringProperty (
name = " No Component Collection " ,
2025-01-11 21:36:11 +08:00
description = " When importing, it is the name of collection where objects store will not be saved as component. When exporting, all forced no component objects will be stored in this name represented collection " ,
2026-03-20 14:50:05 +08:00
default = DEFAULT_RAW_PREFERENCES . mNoComponentCollection ,
2025-01-11 21:36:11 +08:00
translation_context = ' BBPPreferences/property '
2024-12-30 17:53:42 +08:00
) # type: ignore
2023-10-14 11:48:41 +08:00
def draw ( self , context ) :
2025-01-11 21:36:11 +08:00
layout : bpy . types . UILayout = self . layout
2023-10-14 11:48:41 +08:00
row = layout . row ( )
col = row . column ( )
2025-01-12 15:15:29 +08:00
col . label ( text = " Ballance Texture Folder " , text_ctxt = ' BBPPreferences/draw ' )
2023-10-14 11:48:41 +08:00
col . prop ( self , " ballance_texture_folder " , text = " " )
2025-01-12 15:15:29 +08:00
col . label ( text = " No Component Collection " , text_ctxt = ' BBPPreferences/draw ' )
2023-10-14 11:48:41 +08:00
col . prop ( self , " no_component_collection " , text = " " )
def get_preferences ( ) - > BBPPreferences :
return bpy . context . preferences . addons [ __package__ ] . preferences
def get_raw_preferences ( ) - > RawPreferences :
pref : BBPPreferences = get_preferences ( )
rawdata : RawPreferences = RawPreferences ( )
rawdata . mBallanceTextureFolder = pref . ballance_texture_folder
rawdata . mNoComponentCollection = pref . no_component_collection
return rawdata
def register ( ) - > None :
bpy . utils . register_class ( BBPPreferences )
def unregister ( ) - > None :
bpy . utils . unregister_class ( BBPPreferences )