import c4d
from ssp_utils_c4d_version import *
from ssp_utils_image import *

####################################################################################################
# Plugin IDs #######################################################################################
####################################################################################################
PLUGIN_NAME = 'C4D Tabs'
PLUGIN_TOOLTIP = 'C4D Tabs - Switch Between Projects Like a Ninja\n[Ctrl+Click] Quick Switch Menu.'

PLUGIN_NAME_OPTIONS = 'C4D Tabs Options'
PLUGIN_TOOLTIP_OPTIONS = 'Configure C4D Tabs'

PLUGIN_VERSION  = '1.3'
PLUGIN_ID               = 1055322
PLUGIN_ID_MESSAGEDATA   = 1055323
PLUGIN_ID_COREMESSAGE   = 1055325
PLUGIN_ID_PREFS         = 1055324
PLUGIN_ID_COREMESSAGE_2 = 1055326
PLUGIN_ID_OPTIONS       = 1055439

PLUGIN_ID_MANAGER       = PLUGIN_ID

PLUGIN_IDS_SWITCH = [ 1057079, 1057080, 1057081, 1057082, 1057083,
                      1057084, 1057085, 1057086, 1057087, 1057088
                    ]

REGISTER_SHORTCUTS_GLOBALLY = True

SWITCH_DEFAULT_QUALIFIER_L0 = c4d.QSHIFT | c4d.QCTRL | c4d.QALT
#SWITCH_DEFAULT_KEY_OLD = [ c4d.KEY_F1, c4d.KEY_F2, c4d.KEY_F3, c4d.KEY_F4, c4d.KEY_F5,
#                           c4d.KEY_F6, c4d.KEY_F7, c4d.KEY_F8, c4d.KEY_F9, c4d.KEY_F10
#                         ]
SWITCH_DEFAULT_KEY_L0 = ord('S')
SWITCH_DEFAULT_KEY_SELECT = [ ord('1'), ord('2'), ord('3'), ord('4'), ord('5'),
                              ord('6'), ord('7'), ord('8'), ord('9'), ord('0'),
                            ]

PLUGIN_NAME_SWITCH      = '{0} - Scene #{1}'
PLUGIN_TOOLTIP_SWITCH   = '{0} - Switch to Scene #{1}'



URL_3DTOALL = "https://www.3dtoall.com"

SUBID_COREMESSAGE_UPDATE                 = 1000
SUBID_COREMESSAGE_CHANGE_DESIGN          = 1001
SUBID_COREMESSAGE_REDRAW_THUMBS          = 1002
SUBID_COREMESSAGE_THUMB_RENDER_FINISHED  = 1003
SUBID_COREMESSAGE_CHANGE_SESSIONS        = 1004
SUBID_COREMESSAGE_CHANGE_THUMB_INTERVAL  = 1005
SUBID_COREMESSAGE_CHANGE_MENU_BUTTONS    = 1006
SUBID_COREMESSAGE_CLOSE_SSP              = 1007

# from res:
try:
    # TODO Andreas: Check with Maxon, how to reliably access resource symbols...
    SSPPREFERENCES_MAIN_GROUP = c4d.SSPPREFERENCES_MAIN_GROUP
except:
    SSPPREFERENCES_MAIN_GROUP = 999


####################################################################################################
# Constants ########################################################################################
####################################################################################################
# NOTE: Only three sizes allowed since size gets toggled by BitmapButton
THUMB_RESOLUTIONS = [[50, 50, 'Small', None], [108, 108, 'Medium', None], [200, 200, 'Large', None]] # have largest resolution last, it's used for preview render
# THUMB_RENDER_RESOLUTION larger sizes reduce influence of wireframes
THUMB_RENDER_RESOLUTION = [THUMB_RESOLUTIONS[-1][0], THUMB_RESOLUTIONS[-1][1]] # supposed to be equal or larger than largest thumb res
NAME_THUMB_CAM = '{0} Thumb Cam'.format(PLUGIN_NAME)
NAME_THUMB_RENDERDATA = '{0} Thumbnails'.format(PLUGIN_NAME)


####################################################################################################
# Default values for options #######################################################################
####################################################################################################
DEFAULT_PLUGIN_ENABLED = True
DEFAULT_START_SESSION = 10000 # <1000: Stored sessions, # 10000: None, 10001: Current
DEFAULT_ASK_REOPEN = True
DEFAULT_ASK_SESSION_SWITCH = True
DEFAULT_MENU_FILES_ENABLED = True
DEFAULT_MENU_SCENES_ENABLED = True
DEFAULT_TABS_ENABLED = False
DEFAULT_COMBO_ENABLED = True
DEFAULT_LARGE_COMBO = False
DEFAULT_THUMB_ENABLED = True
DEFAULT_PREV_NEXT_BUTTONS_ENABLED = True
DEFAULT_DESIGN_BUTTONS_ENABLED = True
DEFAULT_POPUP_MODE = False
DEFAULT_SHOW_SHORTCUTS = True
DEFAULT_THUMB_MODE_RENDER = True # TODO Andreas: CURRENTLY ALWAYS TRUE, PREVIEW MODE GOT DISABLED # False: preview images, True: rendered thumbs
DEFAULT_THUMB_SIZE = 0 # index into THUMB_RESOLUTIONS
if c4d.GetC4DVersion() >= 22000:
    DEFAULT_THUMB_FILTER = True
else:
    DEFAULT_THUMB_FILTER = False
DEFAULT_THUMB_UPDATES = 1 # 0: no updates, 1: on scene switch, otherwise value in seconds
DEFAULT_THUMB_HIDE_ACTIVE = False
DEFAULT_THUMB_MARKER_ID = MyHash('marker_corner_triangle.png')
DEFAULT_THUMB_OVERLAY_LT = True
DEFAULT_THUMB_OVERLAY_RT = True
DEFAULT_THUMB_OVERLAY_LB = True
DEFAULT_THUMB_OVERLAY_RB = True
DEFAULT_THUMB_OVERLAY_LABEL = True
DEFAULT_THUMB_MARKER_COLOR = c4d.Vector(236.0, 135.0, 45.0) / 255.0
DEFAULT_THUMB_LABEL_COLOR = c4d.Vector(236.0, 135.0, 45.0) / 255.0
DEFAULT_THUMB_TITLE = False
DEFAULT_THUMB_FADE_ACTIVE = 90 # 0: No fade, 100: Only background
#DEFAULT_RELOAD_LAYOUT = 0 # 0: None, 1: Reopen dialog, hash value: layout
DEFAULT_THUMB_ASPECT_RATIO = 0 # 0: Square, 1: Viewport, 2: Viewport Safe Frame
DEFAULT_NEW_PROJECT = True

ENABLE_THUMB_COMMANDS = False

####################################################################################################
# World Pref IDs ###################################################################################
####################################################################################################
BCID_A                                 = 101
BCID_B                                 = 102
BCID_BC_SCENES                         = 1000
BCID_BC_SCENES_FAVORITES               = 1001
BCID_BC_SCENES_REOPEN                  = 1002
BCID_BC_SCENES_NAMES                   = 1003
BCID_BC_SCENES_IS_SAVED                = 1004
BCID_BC_SCENES_IS_ACTIVE               = 1005
BCID_STRING_SESSION_NAME               = 1006 # only in sessions containe

BCID_INT32_PREF_THUMB_SIZE             = 2001
BCID_BOOL_PREF_ASK_REOPEN              = 2002
BCID_BOOL_PREF_PLUGIN_ENABLED          = 2003
#BCID_BOOL_PREF_MENU_ENABLED            = 2004
BCID_INT32_PREF_START_SESSION          = 2005
BCID_BOOL_PREF_ASK_SESSION_SWITCH      = 2007
BCID_BOOL_PREF_POPUP_MODE              = 2008
ID_BUTTON_PREF_MANAGE_SESSIONS         = 2009
BCID_BOOL_PREF_THUMB_FILTER            = 2010
BCID_INT32_PREF_THUMB_UPDATES          = 2011
BCID_BOOL_PREF_THUMB_MODE_RENDER       = 2012
BCID_BOOL_PREF_THUMB_ENABLED           = 2013
BCID_BOOL_PREF_THUMB_HIDE_ACTIVE       = 2014
BCID_BOOL_PREF_TABS_ENABLED            = 2015
BCID_BOOL_PREF_COMBO_ENABLED           = 2016
BCID_BOOL_PREF_THUMB_TITLE             = 2018
BCID_BOOL_PREF_DESIGN_BUTTONS_ENABLED  = 2019
BCID_INT32_PREF_THUMB_MARKER_ID        = 2020
BCID_INT32_PREF_THUMB_FADE_ACTIVE      = 2021
BCID_BOOL_PREF_THUMB_OVERLAY_LT        = 2022
BCID_BOOL_PREF_THUMB_OVERLAY_RT        = 2023
BCID_BOOL_PREF_THUMB_OVERLAY_LB        = 2024
BCID_BOOL_PREF_THUMB_OVERLAY_RB        = 2025
BCID_BOOL_PREF_THUMB_OVERLAY_LABEL     = 2026
#BCID_INT32_PREF_RELOAD_LAYOUT          = 2027
BCID_INT32_PREF_THUMB_ASPECT_RATIO     = 2028
#ID_BUTTON_PREF_OPEN_SSP                = 2029
BCID_BOOL_PREF_MENU_FILES_ENABLED      = 2030
BCID_BOOL_PREF_MENU_SCENES_ENABLED     = 2031
BCID_BOOL_PREF_PREV_NEXT_BUTTONS_ENABLED = 2032
BCID_BOOL_PREF_LARGE_COMBO             = 2033
BCID_BOOL_PREF_SHOW_SHORTCUTS          = 2034
BCID_COLOR_PREF_THUMB_MARKER_COLOR     = 2035
BCID_COLOR_PREF_THUMB_LABEL_COLOR      = 2036
BCID_BOOL_PREF_NEW_PROJECT             = 2037

ID_GROUP_PREF_SESSION                  = 2500
ID_GROUP_PREF_DESIGN                   = 2501
ID_GROUP_PREF_THUMB                    = 2502
ID_GROUP_PREF_ACTIVE_SCENE             = 2503
ID_GROUP_PREF_THUMB_OVERLAY            = 2504
ID_GROUP_PREF_DESIGN_PROJECT           = 2505
ID_GROUP_PREF_DESIGN_EXTRA             = 2506
ID_GROUP_PREF_OVERLAY_COLORS           = 2507

BCID_BC_SESSIONS                       = 3000

BCSESSIONS_NUM_SESSIONS       = 0
BCSESSIONS_SESSION_OFFSET     = 10000

ID_BASE_SESSION_MENU          = 10000
