refactor BlenderEnumPropHelper
This commit is contained in:
@ -19,26 +19,24 @@ class RawVirtoolsTexture():
|
||||
self.mSaveOptions = kwargs.get('mSaveOptions', RawVirtoolsTexture.cDefaultSaveOptions)
|
||||
self.mVideoFormat = kwargs.get('mVideoFormat', RawVirtoolsTexture.cDefaultVideoFormat)
|
||||
|
||||
# blender enum prop helper defines
|
||||
_g_Helper_CK_TEXTURE_SAVEOPTIONS: UTIL_virtools_types.EnumPropHelper = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS)
|
||||
_g_Helper_VX_PIXELFORMAT: UTIL_virtools_types.EnumPropHelper = UTIL_virtools_types.EnumPropHelper(UTIL_virtools_types.VX_PIXELFORMAT)
|
||||
|
||||
class BBP_PG_virtools_texture(bpy.types.PropertyGroup):
|
||||
|
||||
save_options: bpy.props.EnumProperty(
|
||||
name = "Save Options",
|
||||
description = "When saving a composition textures or sprites can be kept as reference to external files or converted to a given format and saved inside the composition file.",
|
||||
items = UTIL_virtools_types.EnumPropHelper.generate_items(
|
||||
UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS,
|
||||
UTIL_virtools_types.g_Annotation_CK_TEXTURE_SAVEOPTIONS
|
||||
),
|
||||
default = UTIL_virtools_types.EnumPropHelper.to_selection(RawVirtoolsTexture.cDefaultSaveOptions)
|
||||
items = _g_Helper_CK_TEXTURE_SAVEOPTIONS.generate_items(),
|
||||
default = _g_Helper_CK_TEXTURE_SAVEOPTIONS.to_selection(RawVirtoolsTexture.cDefaultSaveOptions)
|
||||
)
|
||||
|
||||
video_format: bpy.props.EnumProperty(
|
||||
name = "Video Format",
|
||||
description = "The desired surface pixel format in video memory.",
|
||||
items = UTIL_virtools_types.EnumPropHelper.generate_items(
|
||||
UTIL_virtools_types.VX_PIXELFORMAT,
|
||||
UTIL_virtools_types.g_Annotation_VX_PIXELFORMAT
|
||||
),
|
||||
default = UTIL_virtools_types.EnumPropHelper.to_selection(RawVirtoolsTexture.cDefaultVideoFormat)
|
||||
items = _g_Helper_VX_PIXELFORMAT.generate_items(),
|
||||
default = _g_Helper_VX_PIXELFORMAT.to_selection(RawVirtoolsTexture.cDefaultVideoFormat)
|
||||
)
|
||||
|
||||
#region Virtools Texture Getter Setter
|
||||
@ -50,15 +48,15 @@ def get_raw_virtools_texture(img: bpy.types.Image) -> RawVirtoolsTexture:
|
||||
props: BBP_PG_virtools_texture = get_virtools_texture(img)
|
||||
rawdata: RawVirtoolsTexture = RawVirtoolsTexture()
|
||||
|
||||
rawdata.mSaveOptions = UTIL_virtools_types.EnumPropHelper.get_selection(UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS, props.save_options)
|
||||
rawdata.mVideoFormat = UTIL_virtools_types.EnumPropHelper.get_selection(UTIL_virtools_types.VX_PIXELFORMAT, props.video_format)
|
||||
rawdata.mSaveOptions = _g_Helper_CK_TEXTURE_SAVEOPTIONS.get_selection(props.save_options)
|
||||
rawdata.mVideoFormat = _g_Helper_VX_PIXELFORMAT.get_selection(props.video_format)
|
||||
return rawdata
|
||||
|
||||
def set_raw_virtools_texture(img: bpy.types.Image, rawdata: RawVirtoolsTexture) -> None:
|
||||
props: BBP_PG_virtools_texture = get_virtools_texture(img)
|
||||
|
||||
props.save_options = UTIL_virtools_types.EnumPropHelper.to_selection(rawdata.mSaveOptions)
|
||||
props.video_format = UTIL_virtools_types.EnumPropHelper.to_selection(rawdata.mVideoFormat)
|
||||
props.save_options = _g_Helper_CK_TEXTURE_SAVEOPTIONS.to_selection(rawdata.mSaveOptions)
|
||||
props.video_format = _g_Helper_VX_PIXELFORMAT.to_selection(rawdata.mVideoFormat)
|
||||
|
||||
#endregion
|
||||
|
||||
|
Reference in New Issue
Block a user