import c4d
from ssp_utils_c4d_version import *
from ssp_ids import *
from ssp_utils_pref import *
from ssp_utils import *
from ssp_dialog_manage_sessions import CommandManageSessions


####################################################################################################
# Class PreferenceDataSSP ##########################################################################
####################################################################################################
if c4d.GetC4DVersion() >= 19000:
    class PreferenceDataSSP(c4d.plugins.PreferenceData):

        def InitPrefValue(self, description, id, dtype, bcWorldPrefs, default):
            self.InitPreferenceValue(id, default, description, c4d.DescID(c4d.DescLevel(id, dtype, 0)), bcWorldPrefs)


        def Init(self, node, description=None):
            bcWorldPrefs = GetWorldPrefs()

            self.InitPrefValue(description, BCID_BOOL_PREF_PLUGIN_ENABLED, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_PLUGIN_ENABLED)
            self.InitPrefValue(description, BCID_INT32_PREF_START_SESSION, c4d.DTYPE_LONG, bcWorldPrefs, DEFAULT_START_SESSION)
            self.InitPrefValue(description, BCID_BOOL_PREF_ASK_REOPEN, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_ASK_REOPEN)
            self.InitPrefValue(description, BCID_BOOL_PREF_ASK_SESSION_SWITCH, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_ASK_SESSION_SWITCH)
            self.InitPrefValue(description, BCID_BOOL_PREF_MENU_FILES_ENABLED, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_MENU_FILES_ENABLED)
            self.InitPrefValue(description, BCID_BOOL_PREF_MENU_SCENES_ENABLED, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_MENU_SCENES_ENABLED)
            self.InitPrefValue(description, BCID_BOOL_PREF_COMBO_ENABLED, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_COMBO_ENABLED)
            self.InitPrefValue(description, BCID_BOOL_PREF_LARGE_COMBO, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_LARGE_COMBO)
            self.InitPrefValue(description, BCID_BOOL_PREF_TABS_ENABLED, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_TABS_ENABLED)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_ENABLED, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_ENABLED)
            self.InitPrefValue(description, BCID_BOOL_PREF_PREV_NEXT_BUTTONS_ENABLED, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_PREV_NEXT_BUTTONS_ENABLED)
            self.InitPrefValue(description, BCID_BOOL_PREF_DESIGN_BUTTONS_ENABLED, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_DESIGN_BUTTONS_ENABLED)
            self.InitPrefValue(description, BCID_BOOL_PREF_POPUP_MODE, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_POPUP_MODE)
            self.InitPrefValue(description, BCID_BOOL_PREF_SHOW_SHORTCUTS, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_SHOW_SHORTCUTS)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_MODE_RENDER, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_MODE_RENDER)
            self.InitPrefValue(description, BCID_INT32_PREF_THUMB_SIZE, c4d.DTYPE_LONG, bcWorldPrefs, DEFAULT_THUMB_SIZE)
            self.InitPrefValue(description, BCID_INT32_PREF_THUMB_ASPECT_RATIO, c4d.DTYPE_LONG, bcWorldPrefs, DEFAULT_THUMB_ASPECT_RATIO)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_FILTER, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_FILTER)
            self.InitPrefValue(description, BCID_INT32_PREF_THUMB_UPDATES, c4d.DTYPE_LONG, bcWorldPrefs, DEFAULT_THUMB_UPDATES)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_TITLE, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_TITLE)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_HIDE_ACTIVE, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_HIDE_ACTIVE)
            self.InitPrefValue(description, BCID_INT32_PREF_THUMB_FADE_ACTIVE, c4d.DTYPE_LONG, bcWorldPrefs, DEFAULT_THUMB_FADE_ACTIVE)
            self.InitPrefValue(description, BCID_INT32_PREF_THUMB_MARKER_ID, c4d.DTYPE_LONG, bcWorldPrefs, DEFAULT_THUMB_MARKER_ID)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_OVERLAY_LT, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_OVERLAY_LT)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_OVERLAY_RT, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_OVERLAY_RT)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_OVERLAY_LB, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_OVERLAY_LB)
            self.InitPrefValue(description, BCID_BOOL_PREF_THUMB_OVERLAY_RB, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_THUMB_OVERLAY_RB)
            self.InitPrefValue(description, BCID_COLOR_PREF_THUMB_MARKER_COLOR, c4d.DTYPE_COLOR, bcWorldPrefs, DEFAULT_THUMB_MARKER_COLOR)
            self.InitPrefValue(description, BCID_COLOR_PREF_THUMB_LABEL_COLOR, c4d.DTYPE_COLOR, bcWorldPrefs, DEFAULT_THUMB_LABEL_COLOR)
            #self.InitPrefValue(description, BCID_INT32_PREF_RELOAD_LAYOUT, c4d.DTYPE_LONG, bcWorldPrefs, DEFAULT_RELOAD_LAYOUT)
            self.InitPrefValue(description, BCID_BOOL_PREF_NEW_PROJECT, c4d.DTYPE_BOOL, bcWorldPrefs, DEFAULT_NEW_PROJECT)

            return True


        def GetDDescriptionCreateCheckbox(self, node, description, descId, name, parentId, valDefault=True):
            bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_BOOL)

            bc.SetString(c4d.DESC_NAME, name)
            bc.SetString(c4d.DESC_SHORT_NAME, name)
            bc.SetInt32(c4d.DESC_DEFAULT, valDefault)
            bc.SetInt32(c4d.DESC_ANIMATE, False)
            bc.SetBool(c4d.DESC_REMOVEABLE, False)

            result = description.SetParameter(descId, bc, parentId)
            if not result:
                print('{0} ERROR: FAILED TO CREATE CHECKBOX: {1}'.format(PLUGIN_NAME, name))

            return result


        def GetDDescriptionCreateCombo(self, node, description, descId, name, parentId, bcContent, valDefault=0):
            bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)

            bc.SetString(c4d.DESC_NAME, name)
            bc.SetString(c4d.DESC_SHORT_NAME, name)
            bc.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_CYCLE)
            bc.SetInt32(c4d.DESC_DEFAULT, valDefault)
            bc.SetInt32(c4d.DESC_ANIMATE, False)
            bc.SetBool(c4d.DESC_REMOVEABLE, False)
            bc.SetContainer(c4d.DESC_CYCLE, bcContent)

            result = description.SetParameter(descId, bc, parentId)
            if not result:
                print('{0} ERROR: FAILED TO CREATE COMBO: {1}'.format(PLUGIN_NAME, name))

            return result


        def GetDDescriptionCreateGroup(self, description, groupDescId, name, parentId, numColumns=1, defaultOpen=True):
            bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_GROUP)

            bc.SetString(c4d.DESC_NAME, name)
            bc.SetInt32(c4d.DESC_COLUMNS, numColumns)

            if defaultOpen:
                bc.SetInt32(c4d.DESC_DEFAULT, -1)

            return description.SetParameter(groupDescId, bc, c4d.DescID(c4d.DescLevel(parentId)))


        def GetDDescriptionCreateLong(self, description, descId, name, parentId, unit=c4d.DESC_UNIT_INT, valDefault=50, valMin=0, valMax=100, step=1, slider=True, sliderMin=0, sliderMax=100):
            bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)

            bc.SetString(c4d.DESC_NAME, name)
            bc.SetString(c4d.DESC_SHORT_NAME, name)

            if slider:
                bc.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_LONGSLIDER)
                bc.SetInt32(c4d.DESC_MINSLIDER, sliderMin)
                bc.SetInt32(c4d.DESC_MAXSLIDER, sliderMax)

            else:
                bc.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_LONG)

            bc.SetInt32(c4d.DESC_DEFAULT, valDefault)
            bc.SetInt32(c4d.DESC_MIN, valMin)
            bc.SetInt32(c4d.DESC_MAX, valMax)
            bc.SetInt32(c4d.DESC_STEP, step)
            bc.SetInt32(c4d.DESC_UNIT, unit)
            bc.SetInt32(c4d.DESC_ANIMATE, False)
            bc.SetBool(c4d.DESC_REMOVEABLE, False)

            return description.SetParameter(descId, bc, parentId)


        def GetDDescriptionCreateButton(self, description, descId, name, parentId):
            bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_BUTTON)

            bc.SetString(c4d.DESC_NAME, name)
            bc.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_BUTTON)

            return description.SetParameter(descId, bc, c4d.DescID(c4d.DescLevel(parentId)))


        def GetDDescriptionCreateColor(self, description, descId, name, parentId, valDefault=c4d.Vector(1.0, 0.0, 1.0)):
            bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_COLOR)

            bc.SetString(c4d.DESC_NAME, name)
            bc.SetVector(c4d.DESC_DEFAULT, valDefault)
            bc.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_COLOR)

            return description.SetParameter(descId, bc, c4d.DescID(c4d.DescLevel(parentId)))


        def GetDDescriptionCreateComboStartSession(self, node, description, descId):
            bc = c4d.BaseContainer()

            bc.SetString(10000, 'None')
            bc.SetString(10001, '(Last Opened Projects)')

            sessions = SessionGetSessions()

            for idxSession, nameSession in enumerate(sessions):
                bc.SetString(idxSession, nameSession)

            return self.GetDDescriptionCreateCombo(node, description, descId, 'Start Session', ID_GROUP_PREF_SESSION, bc, valDefault=DEFAULT_START_SESSION)


        def GetDDescriptionCreateComboThumbSize(self, node, description, descId):
            bc = c4d.BaseContainer()

            bc.SetString(0, 'Small')
            bc.SetString(1, 'Medium')
            bc.SetString(2, 'Large')

            return self.GetDDescriptionCreateCombo(node, description, descId, 'Size', ID_GROUP_PREF_THUMB, bc, valDefault=DEFAULT_THUMB_SIZE)


        def GetDDescriptionCreateComboThumbAspectRatio(self, node, description, descId):
            bc = c4d.BaseContainer()

            bc.SetString(0, 'Square')
            bc.SetString(1, 'Viewport')
            bc.SetString(2, 'Viewport Safe Frame')

            return self.GetDDescriptionCreateCombo(node, description, descId, 'Aspect Ratio', ID_GROUP_PREF_THUMB, bc, valDefault=DEFAULT_THUMB_ASPECT_RATIO)


        def GetDDescriptionCreateComboThumbInterval(self, node, description, descId):
            bc = c4d.BaseContainer()

            bc.SetString(0, 'No Automatic Updates')
            bc.SetString(1, 'Scene Switch')
            bc.SetString(60000, '1 Minute')
            bc.SetString(300000, '5 Minutes')
            bc.SetString(600000, '10 Minutes')
            bc.SetString(900000, '15 Minutes')
            #bc.SetString(5000, '5 Seconds (use with Rendered off, only)')
            #bc.SetString(15000, '15 Seconds (use with Rendered off, only)')

            return self.GetDDescriptionCreateCombo(node, description, descId, 'Update every...', ID_GROUP_PREF_THUMB, bc, valDefault=DEFAULT_THUMB_UPDATES)


        def GetDDescriptionCreateComboOverlay(self, node, description, descId):
            bc = c4d.BaseContainer()

            bc.SetString(0, 'No Overlay')
            bc.SetString(0xF, 'All Corners')
            bc.SetString(0x1, 'Left/Top')
            bc.SetString(0x2, 'Right/Top')
            bc.SetString(0x4, 'Left/Bottom')
            bc.SetString(0x8, 'Right/Bottom')

            return self.GetDDescriptionCreateCombo(node, description, descId, 'Active Scene Overlay', ID_GROUP_PREF_ACTIVE_SCENE, bc, valDefault=DEFAULT_THUMB_OVERLAY)


        def GetDDescriptionCreateComboThumbMarker(self, node, description, descId):
            availableMarker = GetAvailableMarker()

            bc = c4d.BaseContainer()

            for marker in availableMarker.values():
                bc.SetString(marker[2], marker[0])

            return self.GetDDescriptionCreateCombo(node, description, descId, 'Active Scene Marker', ID_GROUP_PREF_ACTIVE_SCENE, bc, valDefault=DEFAULT_THUMB_MARKER_ID)


        #def GetDDescriptionCreateComboReloadLayout(self, node, description, descId):
        #    InitAvailableLayouts()
        #    bc = c4d.BaseContainer()
        #    bc.SetString(0, 'None')
        #    bc.SetString(1, 'Just reopen dialog')
        #    for idLayout, layout in g_layouts.iteritems():
        #        bc.SetString(idLayout, layout[0])
        #    return self.GetDDescriptionCreateCombo(node, description, descId, 'Behaviour When Reloading Python Plugins', SSPPREFERENCES_MAIN_GROUP, bc, valDefault=DEFAULT_RELOAD_LAYOUT)


        def GetDDescription_GroupSession(self, node, description, singleId):
            descIdGroupSession = c4d.DescID(c4d.DescLevel(ID_GROUP_PREF_SESSION, c4d.DTYPE_GROUP, node.GetType()))
            if singleId is None or descIdGroupSession.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateGroup(description, descIdGroupSession, 'Session', SSPPREFERENCES_MAIN_GROUP):
                    return False

            descIdStartSession = c4d.DescID(c4d.DescLevel(BCID_INT32_PREF_START_SESSION, c4d.DTYPE_LONG, node.GetType()))
            if singleId is None or descIdStartSession.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateComboStartSession(node, description, descIdStartSession):
                    return False

            descIdReopen = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_ASK_REOPEN, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdReopen.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdReopen, 'Ask Before Reopen on Startup ', ID_GROUP_PREF_SESSION, valDefault=DEFAULT_ASK_REOPEN):
                    return False

            descIdSessionSwitch = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_ASK_SESSION_SWITCH, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdSessionSwitch.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdSessionSwitch, 'Ask Before Switching Session ', ID_GROUP_PREF_SESSION, valDefault=DEFAULT_ASK_SESSION_SWITCH):
                    return False

            descIdManageSession = c4d.DescID(c4d.DescLevel(ID_BUTTON_PREF_MANAGE_SESSIONS, c4d.DTYPE_BUTTON, node.GetType()))
            if singleId is None or descIdManageSession.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateButton(description, descIdManageSession, 'Manage Sessions...', ID_GROUP_PREF_SESSION):
                    return False

            return True


        def GetDDescription_GroupDesign(self, node, description, singleId):
            descIdGroupDesign = c4d.DescID(c4d.DescLevel(ID_GROUP_PREF_DESIGN, c4d.DTYPE_GROUP, node.GetType()))
            if singleId is None or descIdGroupDesign.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateGroup(description, descIdGroupDesign, 'Design - Menu Bar', SSPPREFERENCES_MAIN_GROUP):
                    return False

            descIdEnableMenuFiles = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_MENU_FILES_ENABLED, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdEnableMenuFiles.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdEnableMenuFiles, 'Show Menu', ID_GROUP_PREF_DESIGN, valDefault=DEFAULT_MENU_FILES_ENABLED):
                    return False

            descIdEnableMenuScenes = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_MENU_SCENES_ENABLED, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdEnableMenuScenes.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdEnableMenuScenes, 'Show Projects ', ID_GROUP_PREF_DESIGN, valDefault=DEFAULT_MENU_SCENES_ENABLED):
                    return False

            descIdPrevNextButtonsEnabled = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_PREV_NEXT_BUTTONS_ENABLED, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdPrevNextButtonsEnabled.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdPrevNextButtonsEnabled, 'Show Prev/Next/+ Buttons (Restarts Dialog)', ID_GROUP_PREF_DESIGN, valDefault=DEFAULT_PREV_NEXT_BUTTONS_ENABLED):
                    return False

            descIdDesignButtonsEnabled = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_DESIGN_BUTTONS_ENABLED, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdDesignButtonsEnabled.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdDesignButtonsEnabled, 'Show Design Buttons (Restarts Dialog)', ID_GROUP_PREF_DESIGN, valDefault=DEFAULT_DESIGN_BUTTONS_ENABLED):
                    return False

            return True


        def GetDDescription_GroupDesignProject(self, node, description, singleId):
            descIdGroupDesignProject = c4d.DescID(c4d.DescLevel(ID_GROUP_PREF_DESIGN_PROJECT, c4d.DTYPE_GROUP, node.GetType()))
            if singleId is None or descIdGroupDesignProject.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateGroup(description, descIdGroupDesignProject, 'Design - Project Selection', SSPPREFERENCES_MAIN_GROUP):
                    return False

            descIdComboEnabled = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_COMBO_ENABLED, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdComboEnabled.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdComboEnabled, 'Show Dropdown', ID_GROUP_PREF_DESIGN_PROJECT, valDefault=DEFAULT_COMBO_ENABLED):
                    return False

            descIdThumbsEnabled = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_ENABLED, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdThumbsEnabled.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbsEnabled, 'Show Thumbnails', ID_GROUP_PREF_DESIGN_PROJECT, valDefault=DEFAULT_THUMB_ENABLED):
                    return False

            descIdTabsEnabled = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_TABS_ENABLED, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdTabsEnabled.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdTabsEnabled, 'Show Tabs', ID_GROUP_PREF_DESIGN_PROJECT, valDefault=DEFAULT_TABS_ENABLED):
                    return False

            return True


        def GetDDescription_GroupDesignExtra(self, node, description, singleId):
            descIdGroupDesignExtra = c4d.DescID(c4d.DescLevel(ID_GROUP_PREF_DESIGN_EXTRA, c4d.DTYPE_GROUP, node.GetType()))
            if singleId is None or descIdGroupDesignExtra.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateGroup(description, descIdGroupDesignExtra, 'Design - Advanced Settings', SSPPREFERENCES_MAIN_GROUP, defaultOpen=False):
                    return False

            descIdNewProject = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_NEW_PROJECT, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdNewProject.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdNewProject, 'New Project Option', ID_GROUP_PREF_DESIGN_EXTRA, valDefault=DEFAULT_NEW_PROJECT):
                    return False

            descIdComboLarge = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_LARGE_COMBO, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdComboLarge.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdComboLarge, 'Large Dropdown', ID_GROUP_PREF_DESIGN_EXTRA, valDefault=DEFAULT_LARGE_COMBO):
                    return False

            descIdPopupMode = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_POPUP_MODE, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdPopupMode.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdPopupMode, 'Close Dialog After Project Selection', ID_GROUP_PREF_DESIGN_EXTRA, valDefault=DEFAULT_POPUP_MODE):
                    return False

            descIdShowShortcuts = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_SHOW_SHORTCUTS, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdShowShortcuts.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdShowShortcuts, 'Show Project Index in Menus', ID_GROUP_PREF_DESIGN_EXTRA, valDefault=DEFAULT_SHOW_SHORTCUTS):
                    return False

            return True


        def GetDDescription_GroupThumbnails(self, node, description, singleId):
            descIdGroupThumb = c4d.DescID(c4d.DescLevel(ID_GROUP_PREF_THUMB, c4d.DTYPE_GROUP, node.GetType()))
            if singleId is None or descIdGroupThumb.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateGroup(description, descIdGroupThumb, 'Thumbnails', SSPPREFERENCES_MAIN_GROUP, defaultOpen=False):
                    return False

            #descIdThumbModeRender = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_MODE_RENDER, c4d.DTYPE_BOOL, node.GetType()))
            #if singleId is None or descIdThumbModeRender.IsPartOf(singleId)[0]:
            #    if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbModeRender, 'Rendered', ID_GROUP_PREF_THUMB, valDefault=DEFAULT_THUMB_MODE_RENDER):
            #        return False
            descIdThumbSize = c4d.DescID(c4d.DescLevel(BCID_INT32_PREF_THUMB_SIZE, c4d.DTYPE_LONG, node.GetType()))
            if singleId is None or descIdThumbSize.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateComboThumbSize(node, description, descIdThumbSize):
                    return False

            descIdThumbAspectRatio = c4d.DescID(c4d.DescLevel(BCID_INT32_PREF_THUMB_ASPECT_RATIO, c4d.DTYPE_LONG, node.GetType()))
            if singleId is None or descIdThumbAspectRatio.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateComboThumbAspectRatio(node, description, descIdThumbAspectRatio):
                    return False

            if c4d.GetC4DVersion() >= 22000:
                descIdThumbFilter = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_FILTER, c4d.DTYPE_BOOL, node.GetType()))
                if singleId is None or descIdThumbFilter.IsPartOf(singleId)[0]:
                    if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbFilter, 'Filter HUD, Axis, Handles,...', ID_GROUP_PREF_THUMB, valDefault=DEFAULT_THUMB_FILTER):
                        return False

            descIdThumbInterval = c4d.DescID(c4d.DescLevel(BCID_INT32_PREF_THUMB_UPDATES, c4d.DTYPE_LONG, node.GetType()))
            if singleId is None or descIdThumbInterval.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateComboThumbInterval(node, description, descIdThumbInterval):
                    return False

            descIdThumbTitle = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_TITLE, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdThumbTitle.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbTitle, 'Show Scene Name', ID_GROUP_PREF_THUMB, valDefault=DEFAULT_THUMB_TITLE):
                    return False

            return True


        def GetDDescription_GroupActiveScene(self, node, description, singleId):
            descIdGroupActiveScene = c4d.DescID(c4d.DescLevel(ID_GROUP_PREF_ACTIVE_SCENE, c4d.DTYPE_GROUP, node.GetType()))
            if singleId is None or descIdGroupActiveScene.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateGroup(description, descIdGroupActiveScene, 'Thumbnail - Active Project', SSPPREFERENCES_MAIN_GROUP, defaultOpen=False):
                    return False

            descIdThumbHideActive = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_HIDE_ACTIVE, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdThumbHideActive.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbHideActive, 'Hide Active Scene', ID_GROUP_PREF_ACTIVE_SCENE, valDefault=DEFAULT_THUMB_HIDE_ACTIVE):
                    return False

            descIdThumbFadeActive = c4d.DescID(c4d.DescLevel(BCID_INT32_PREF_THUMB_FADE_ACTIVE, c4d.DTYPE_LONG, node.GetType()))
            if singleId is None or descIdThumbFadeActive.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateLong(description, descIdThumbFadeActive, 'Fade Active Scene', ID_GROUP_PREF_ACTIVE_SCENE, valDefault=DEFAULT_THUMB_FADE_ACTIVE):
                    return False

            descIdThumbMarker = c4d.DescID(c4d.DescLevel(BCID_INT32_PREF_THUMB_MARKER_ID, c4d.DTYPE_LONG, node.GetType()))
            if singleId is None or descIdThumbMarker.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateComboThumbMarker(node, description, descIdThumbMarker):
                    return False

            # Subgroup: Active Scene Overlay
            descIdGroupThumbOverlay = c4d.DescID(c4d.DescLevel(ID_GROUP_PREF_THUMB_OVERLAY, c4d.DTYPE_GROUP, node.GetType()))
            if singleId is None or descIdGroupThumbOverlay.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateGroup(description, descIdGroupThumbOverlay, '', ID_GROUP_PREF_ACTIVE_SCENE, numColumns=2):
                    return False

            descIdThumbOverlayLT = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_OVERLAY_LT, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdThumbOverlayLT.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbOverlayLT, 'Marker Left/Top', ID_GROUP_PREF_THUMB_OVERLAY, valDefault=DEFAULT_THUMB_OVERLAY_LT):
                    return False

            descIdThumbOverlayRT = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_OVERLAY_RT, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdThumbOverlayRT.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbOverlayRT, 'Marker Right/Top', ID_GROUP_PREF_THUMB_OVERLAY, valDefault=DEFAULT_THUMB_OVERLAY_RT):
                    return False

            descIdThumbOverlayLB = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_OVERLAY_LB, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdThumbOverlayLB.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbOverlayLB, 'Marker Left/Bottom', ID_GROUP_PREF_THUMB_OVERLAY, valDefault=DEFAULT_THUMB_OVERLAY_LB):
                    return False

            descIdThumbOverlayRB = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_OVERLAY_RB, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdThumbOverlayRB.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbOverlayRB, 'Marker Right/Bottom', ID_GROUP_PREF_THUMB_OVERLAY, valDefault=DEFAULT_THUMB_OVERLAY_RB):
                    return False

            descIdThumbOverlayText = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_THUMB_OVERLAY_LABEL, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdThumbOverlayText.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdThumbOverlayText, 'Active Label', ID_GROUP_PREF_THUMB_OVERLAY, valDefault=DEFAULT_THUMB_OVERLAY_LABEL):
                    return False

            # Subgroup: Active Scene Overlay Colors
            descIdGroupOverlayColors = c4d.DescID(c4d.DescLevel(ID_GROUP_PREF_OVERLAY_COLORS, c4d.DTYPE_GROUP, node.GetType()))
            if singleId is None or descIdGroupOverlayColors.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateGroup(description, descIdGroupOverlayColors, '', ID_GROUP_PREF_ACTIVE_SCENE, numColumns=2):
                    return False

            descIdThumbMarkerColor = c4d.DescID(c4d.DescLevel(BCID_COLOR_PREF_THUMB_MARKER_COLOR, c4d.DTYPE_COLOR, node.GetType()))
            if singleId is None or descIdThumbMarkerColor.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateColor(description, descIdThumbMarkerColor, 'Marker Color', ID_GROUP_PREF_OVERLAY_COLORS, valDefault=DEFAULT_THUMB_MARKER_COLOR):
                    return False

            descIdThumbLabelColor = c4d.DescID(c4d.DescLevel(BCID_COLOR_PREF_THUMB_LABEL_COLOR, c4d.DTYPE_COLOR, node.GetType()))
            if singleId is None or descIdThumbLabelColor.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateColor(description, descIdThumbLabelColor, 'Label Color', ID_GROUP_PREF_OVERLAY_COLORS, valDefault=DEFAULT_THUMB_LABEL_COLOR):
                    return False

            return True


        def GetDDescription(self, node, description, flags):
            if not description.LoadDescription('ssppreferences'):
                print('{0} ERROR: Failed to load Description'.format(PLUGIN_NAME))
                return False

            if flags & c4d.DESCFLAGS_DESC_NEEDDEFAULTVALUE:
                self.Init(node, description)

            singleId = description.GetSingleDescID()

            descIdEnablePlugin = c4d.DescID(c4d.DescLevel(BCID_BOOL_PREF_PLUGIN_ENABLED, c4d.DTYPE_BOOL, node.GetType()))
            if singleId is None or descIdEnablePlugin.IsPartOf(singleId)[0]:
                if not self.GetDDescriptionCreateCheckbox(node, description, descIdEnablePlugin, 'Enable {0}'.format(PLUGIN_NAME), SSPPREFERENCES_MAIN_GROUP, valDefault=DEFAULT_PLUGIN_ENABLED):
                    return False

            #descIdOpenSSP = c4d.DescID(c4d.DescLevel(ID_BUTTON_PREF_OPEN_SSP, c4d.DTYPE_BUTTON, node.GetType()))
            #if singleId is None or descIdOpenSSP.IsPartOf(singleId)[0]:
            #    if not self.GetDDescriptionCreateButton(description, descIdOpenSSP, 'Open {0}'.format(PLUGIN_NAME), SSPPREFERENCES_MAIN_GROUP):
            #        return False

            if not self.GetDDescription_GroupSession(node, description, singleId):
                return False

            if not self.GetDDescription_GroupDesign(node, description, singleId):
                return False

            if not self.GetDDescription_GroupDesignProject(node, description, singleId):
                return False

            if not self.GetDDescription_GroupDesignExtra(node, description, singleId):
                return False

            if not self.GetDDescription_GroupThumbnails(node, description, singleId):
                return False

            if not self.GetDDescription_GroupActiveScene(node, description, singleId):
                return False

            #descIdReloadLayout = c4d.DescID(c4d.DescLevel(BCID_INT32_PREF_RELOAD_LAYOUT, c4d.DTYPE_LONG, node.GetType()))
            #if singleId is None or descIdReloadLayout.IsPartOf(singleId)[0]:
            #    if not self.GetDDescriptionCreateComboReloadLayout(node, description, descIdReloadLayout):
            #        return False

            return True, flags | c4d.DESCFLAGS_DESC_LOADED


        def SetDParameter(self, node, id, data, flags):
            bc = GetWorldPrefs()

            paramID = id[0].id
            if paramID == BCID_BOOL_PREF_PLUGIN_ENABLED:
                bc.SetBool(paramID, data)

                if data == False:
                    c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CLOSE_SSP)

            elif paramID == BCID_INT32_PREF_START_SESSION:
                bc.SetInt32(paramID, data)

            elif paramID == BCID_BOOL_PREF_ASK_REOPEN:
                bc.SetBool(paramID, data)

            elif paramID == BCID_BOOL_PREF_ASK_SESSION_SWITCH:
                bc.SetBool(paramID, data)

            elif paramID == BCID_BOOL_PREF_POPUP_MODE:
                bc.SetBool(paramID, data)

            elif paramID == BCID_BOOL_PREF_MENU_FILES_ENABLED:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_BOOL_PREF_MENU_SCENES_ENABLED:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_BOOL_PREF_COMBO_ENABLED:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_BOOL_PREF_LARGE_COMBO:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_BOOL_PREF_TABS_ENABLED:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_BOOL_PREF_THUMB_ENABLED:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_BOOL_PREF_PREV_NEXT_BUTTONS_ENABLED:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_MENU_BUTTONS)

            elif paramID == BCID_BOOL_PREF_DESIGN_BUTTONS_ENABLED:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_MENU_BUTTONS)

            elif paramID == BCID_BOOL_PREF_SHOW_SHORTCUTS:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_BOOL_PREF_THUMB_MODE_RENDER:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_INT32_PREF_THUMB_SIZE:
                bc.SetInt32(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_INT32_PREF_THUMB_ASPECT_RATIO:
                bc.SetInt32(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_BOOL_PREF_THUMB_FILTER:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            elif paramID == BCID_INT32_PREF_THUMB_UPDATES:
                bc.SetInt32(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_THUMB_INTERVAL)

            elif paramID == BCID_BOOL_PREF_THUMB_TITLE:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_BOOL_PREF_THUMB_HIDE_ACTIVE:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_INT32_PREF_THUMB_FADE_ACTIVE:
                bc.SetInt32(paramID, data)
                # Event is send in MSG_DESCRIPTION_CHECKUPDATE, because otherwise we won't get a reliable event from slider changes

            elif paramID == BCID_INT32_PREF_THUMB_MARKER_ID:
                bc.SetInt32(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_COLOR_PREF_THUMB_MARKER_COLOR:
                bc.SetVector(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_COLOR_PREF_THUMB_LABEL_COLOR:
                bc.SetVector(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LT:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_RT:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LB:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_RB:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LABEL:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            elif paramID == BCID_BOOL_PREF_NEW_PROJECT:
                bc.SetBool(paramID, data)
                c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_CHANGE_DESIGN)

            #elif paramID == BCID_INT32_PREF_RELOAD_LAYOUT:
            #    bc.SetInt32(paramID, data)

            return True, flags | c4d.DESCFLAGS_SET_PARAM_SET


        def GetDParameter(self, node, id, flags):
            bc = GetWorldPrefs()

            paramID = id[0].id

            if paramID == BCID_BOOL_PREF_PLUGIN_ENABLED:
                return True, bc.GetBool(paramID, DEFAULT_PLUGIN_ENABLED), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_INT32_PREF_START_SESSION:
                return True, bc.GetInt32(paramID, DEFAULT_START_SESSION), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_ASK_REOPEN:
                return True, bc.GetBool(paramID, DEFAULT_ASK_REOPEN), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_ASK_SESSION_SWITCH:
                return True, bc.GetBool(paramID, DEFAULT_ASK_SESSION_SWITCH), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_MENU_FILES_ENABLED:
                return True, bc.GetBool(paramID, DEFAULT_MENU_FILES_ENABLED), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_MENU_SCENES_ENABLED:
                return True, bc.GetBool(paramID, DEFAULT_MENU_SCENES_ENABLED), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_COMBO_ENABLED:
                return True, bc.GetBool(paramID, DEFAULT_COMBO_ENABLED), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_LARGE_COMBO:
                return True, bc.GetBool(paramID, DEFAULT_LARGE_COMBO), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_TABS_ENABLED:
                return True, bc.GetBool(paramID, DEFAULT_TABS_ENABLED), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_ENABLED:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_ENABLED), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_PREV_NEXT_BUTTONS_ENABLED:
                return True, bc.GetBool(paramID, DEFAULT_DESIGN_BUTTONS_ENABLED), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_DESIGN_BUTTONS_ENABLED:
                return True, bc.GetBool(paramID, DEFAULT_DESIGN_BUTTONS_ENABLED), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_POPUP_MODE:
                return True, bc.GetBool(paramID, DEFAULT_POPUP_MODE), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_SHOW_SHORTCUTS:
                return True, bc.GetBool(paramID, DEFAULT_SHOW_SHORTCUTS), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_MODE_RENDER:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_MODE_RENDER), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_INT32_PREF_THUMB_SIZE:
                return True, bc.GetInt32(paramID, DEFAULT_THUMB_SIZE), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_INT32_PREF_THUMB_ASPECT_RATIO:
                return True, bc.GetInt32(paramID, DEFAULT_THUMB_ASPECT_RATIO), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_FILTER:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_FILTER), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_INT32_PREF_THUMB_UPDATES:
                return True, bc.GetInt32(paramID, DEFAULT_THUMB_UPDATES), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_TITLE:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_TITLE), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_HIDE_ACTIVE:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_HIDE_ACTIVE), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_INT32_PREF_THUMB_FADE_ACTIVE:
                return True, bc.GetInt32(paramID, DEFAULT_THUMB_FADE_ACTIVE), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_INT32_PREF_THUMB_MARKER_ID:
                return True, bc.GetInt32(paramID, DEFAULT_THUMB_MARKER_ID), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_COLOR_PREF_THUMB_MARKER_COLOR:
                return True, bc.GetVector(paramID, DEFAULT_THUMB_MARKER_COLOR), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_COLOR_PREF_THUMB_LABEL_COLOR:
                return True, bc.GetVector(paramID, DEFAULT_THUMB_LABEL_COLOR), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LT:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_OVERLAY_LT), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_RT:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_OVERLAY_RT), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LB:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_OVERLAY_LB), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_RB:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_OVERLAY_RB), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LABEL:
                return True, bc.GetBool(paramID, DEFAULT_THUMB_OVERLAY_LABEL), flags | c4d.DESCFLAGS_GET_PARAM_GET

            elif paramID == BCID_BOOL_PREF_NEW_PROJECT:
                return True, bc.GetBool(paramID, DEFAULT_NEW_PROJECT), flags | c4d.DESCFLAGS_GET_PARAM_GET

            #elif paramID == BCID_INT32_PREF_RELOAD_LAYOUT:
            #    return True, bc.GetInt32(paramID), flags | c4d.DESCFLAGS_GET_PARAM_GET

            return False


        def GetDEnabling(self, node, id, t_data, flags, itemdesc):
            pluginEnabled = GetPrefPluginEnabled()
            thumbRenderMode = GetPrefThumbModeRender()

            paramID = id[0].id

            if paramID == BCID_INT32_PREF_START_SESSION:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_ASK_REOPEN:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_ASK_SESSION_SWITCH:
                return pluginEnabled

            elif paramID == ID_BUTTON_PREF_MANAGE_SESSIONS:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_MENU_FILES_ENABLED:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_MENU_SCENES_ENABLED:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_COMBO_ENABLED:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_LARGE_COMBO:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_TABS_ENABLED:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_ENABLED:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_PREV_NEXT_BUTTONS_ENABLED:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_DESIGN_BUTTONS_ENABLED:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_POPUP_MODE:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_SHOW_SHORTCUTS:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_MODE_RENDER:
                return pluginEnabled

            elif paramID == BCID_INT32_PREF_THUMB_SIZE:
                return pluginEnabled

            elif paramID == BCID_INT32_PREF_THUMB_ASPECT_RATIO:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_FILTER:
                return pluginEnabled and thumbRenderMode

            elif paramID == BCID_INT32_PREF_THUMB_UPDATES:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_TITLE:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_HIDE_ACTIVE:
                return pluginEnabled

            elif paramID == BCID_INT32_PREF_THUMB_FADE_ACTIVE:
                return pluginEnabled

            elif paramID == BCID_INT32_PREF_THUMB_MARKER_ID:
                return pluginEnabled

            elif paramID == BCID_COLOR_PREF_THUMB_MARKER_COLOR:
                return pluginEnabled

            elif paramID == BCID_COLOR_PREF_THUMB_LABEL_COLOR:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LT:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_RT:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LB:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_RB:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_THUMB_OVERLAY_LABEL:
                return pluginEnabled

            elif paramID == BCID_BOOL_PREF_LARGE_COMBO:
                return pluginEnabled

            #elif paramID == BCID_INT32_PREF_RELOAD_LAYOUT:
            #    return pluginEnabled

            return True


        def Message(self, node, type, data):
            if type == c4d.MSG_DESCRIPTION_COMMAND:
                id = data['id'][0].id

                if id == ID_BUTTON_PREF_MANAGE_SESSIONS:
                    CommandManageSessions(fromPrefs=True)

                #elif id == ID_BUTTON_PREF_OPEN_SSP:
                #    c4d.CallCommand(PLUGIN_ID)

            elif type == c4d.MSG_DESCRIPTION_CHECKUPDATE:
                id = data['descid'][0].id

                if id == BCID_INT32_PREF_THUMB_FADE_ACTIVE:
                    c4d.SpecialEventAdd(PLUGIN_ID_COREMESSAGE, p1=SUBID_COREMESSAGE_REDRAW_THUMBS)

            return True
