!!folder: style IGNORERECURSIONS: 1
# themes

if $theme['name'] = '': $theme['name'] = 'Dynamic' & gs 'themes', 'set_dynamic'

!! ------------------------------------------------------------------------------
!! ---------------------------------- Helpers -----------------------------------
!! ------------------------------------------------------------------------------

!! picks an alternating color between table_bg and table_bg_alt
!    use: $temp_bcolor = func('themes', 'alt_color', $temp_bcolor)

!    when you pass blank $temp_bcolor ('') it will return table_bg
!    when you pass $temp_bcolor again it will return table_bg_alt
if $ARGS[0] = 'alt_color':
	$result = iif($ARGS[1] = $theme['table_bg'], $theme['table_bg_alt'], $theme['table_bg'])
end

!! wrapper for above func to use with wardrobe system
!! does the same thing but it sets $temp_bcolor instead of returning a value
!    use: gs 'themes', 'clothing'
if $ARGS[0] = 'clothing':
	$temp_bcolor = func('themes', 'alt_color', $temp_bcolor)
end

!! ------------------------------------------------------------------------------
!! ---------------------------------- Routing -----------------------------------
!! ------------------------------------------------------------------------------
if $ARGS[0] = 'outdoors':
	gs 'themes', 'apply', $ARGS[0]
elseif $ARGS[0] = 'indoors':
	gs 'themes', 'apply', $ARGS[0]
	gs 'indoors'
elseif $ARGS[0] = 'apply':
	if $theme['type'] = 'dynamic':
		gs 'themes', 'apply_dynamic', $ARGS[1]
	else
		gs 'themes', 'apply_static', $ARGS[1]
	end
end

!! ------------------------------------------------------------------------------
!! ----------------------------------- Apply ------------------------------------
!! ------------------------------------------------------------------------------
if $ARGS[0] = 'apply_dynamic':
	if $ARGS[1] = 'indoors':
		theme['is_dark'] = 0

		theme['bcolor'] = rgb(255, 255, 255)
		theme['lcolor'] = rgb(106, 90, 205)

		$theme['bcolor'] = "#FFFFFF"
		$theme['lcolor'] = "#6A5ACD"
	elseif (DayStage = 6) or (DayStage = 1):
		! sunrise or morning
		theme['is_dark'] = 0

		theme['bcolor'] = rgb(210, 210, 255)
		theme['lcolor'] = rgb(40, 40, 255)

		$theme['bcolor'] = "#D2D2FF"
		$theme['lcolor'] = "#2828FF"
	elseif (DayStage = 2):
		! day
		theme['is_dark'] = 0

		theme['bcolor'] = rgb(255, 255, 255)
		theme['lcolor'] = rgb(106, 90, 205)

		$theme['bcolor'] = "#FFFFFF"
		$theme['lcolor'] = "#6A5ACD"
	elseif (DayStage = 3):
		! evening
		theme['is_dark'] = 0

		theme['bcolor'] = rgb(226, 169, 169)
		theme['lcolor'] = rgb(56, 90, 205)

		$theme['bcolor'] = "#E2A9A9"
		$theme['lcolor'] = "#385ACD"
	elseif (DayStage = 4):
		! sunset
		theme['is_dark'] = 1

		theme['bcolor'] = rgb(BColorBase, BColorBase - BColorBase / 4, BColorBase - BColorBase / 4)
		theme['lcolor'] = rgb(110, 200, 200)

		$theme['bcolor'] = func('shortgs', 'rgb_to_hex', bcolor)
		$theme['lcolor'] = "#6EC8C8"
	else
		! Stage 5 - night
		theme['is_dark'] = 1

		theme['bcolor'] = rgb(0, 0, 0)
		theme['lcolor'] = rgb(106, 90, 205)

		$theme['bcolor'] = "#000000"
		$theme['lcolor'] = "#6A5ACD"
	end

	if theme['is_dark'] = 1:
		theme['fcolor'] = rgb(255, 255, 255)
		$theme['fcolor'] = "#FFFFFF"

		theme['table_bg'] = rgb(32, 32, 32)
		theme['table_bg_alt'] = rgb(48, 48, 48)

		$theme['table_bg'] = "#202020"
		$theme['table_bg_alt'] = "#303030"
	else
		theme['fcolor'] = rgb(0, 0, 0)
		$theme['fcolor'] = "#000000"

		theme['table_bg'] = rgb(255, 255, 255)
		theme['table_bg_alt'] = rgb(230, 242, 255)

		$theme['table_bg'] = "#FFFFFF"
		$theme['table_bg_alt'] = "#E6F2FF"
	end

	gs 'themes', 'apply_static'

elseif $ARGS[0] = 'apply_static':
	bcolor = theme['bcolor']
	fcolor = theme['fcolor']
	lcolor = theme['lcolor']

	$bcolor = $theme['bcolor']
	$fcolor = $theme['fcolor']
	$lcolor = $theme['lcolor']

	fsize = theme['fsize']
	$fname = $theme['fname']

elseif $ARGS[0] = 'reset':
	killvar 'theme'
	killvar '$theme'

	killvar 'bcolor'
	killvar 'fcolor'
	killvar 'lcolor'

	killvar '$bcolor'
	killvar '$fcolor'
	killvar '$lcolor'

	fsize = 12
	$fname = 'Tahoma'

	theme['is_dark'] = 0
end

!! ------------------------------------------------------------------------------
!! ----------------------------------- Themes -----------------------------------
!! ------------------------------------------------------------------------------
if $ARGS[0] = 'set_dynamic':
	gs 'themes', 'reset'
	$theme['name'] = 'Dynamic'
	$theme['type'] = 'dynamic'

	gs 'themes', 'default_palette'

	theme['fsize'] = 12
	$theme['fname'] = 'Tahoma'

elseif $ARGS[0] = 'set_white':
	gs 'themes', 'reset'
	$theme['name'] = 'White'
	$theme['type'] = 'static'
	theme['is_dark'] = 0

	gs 'themes', 'default_palette'

	theme['bcolor'] = rgb(255, 255, 255)
	theme['fcolor'] = rgb(0, 0, 0)
	theme['lcolor'] = rgb(106, 90, 205)

	$theme['bcolor'] = "#FFFFFF"
	$theme['fcolor'] = "#000000"
	$theme['lcolor'] = "#6A5ACD"

	theme['fsize'] = 12
	$theme['fname'] = 'Tahoma'

	theme['table_bg'] = rgb(255, 255, 255)
	theme['table_bg_alt'] = rgb(230, 242, 255)

	$theme['table_bg'] = "#FFFFFF"
	$theme['table_bg_alt'] = "#E6F2FF"

elseif $ARGS[0] = 'set_black':
	gs 'themes', 'reset'
	$theme['name'] = 'Black'
	$theme['type'] = 'static'
	theme['is_dark'] = 1

	gs 'themes', 'default_palette'

	theme['bcolor'] = rgb(0, 0, 0)
	theme['fcolor'] = rgb(255, 255, 255)
	theme['lcolor'] = rgb(90, 180, 200)

	$theme['bcolor'] = "#000000"
	$theme['fcolor'] = "#FFFFFF"
	$theme['lcolor'] = "#5AB4C8"

	theme['fsize'] = 12
	$theme['fname'] = 'Tahoma'

	theme['table_bg'] = rgb(32, 32, 32)
	theme['table_bg_alt'] = rgb(48, 48, 48)

	$theme['table_bg'] = "#202020"
	$theme['table_bg_alt'] = "#303030"

elseif $ARGS[0] = 'set_gray':
	gs 'themes', 'reset'
	$theme['name'] = 'Modern Grey'
	$theme['type'] = 'static'
	theme['is_dark'] = 1

	gs 'themes', 'default_palette'

	theme['bcolor'] = rgb(20, 20, 20)
	theme['fcolor'] = rgb(255, 255, 255)
	theme['lcolor'] = rgb(90, 180, 200)

	$theme['bcolor'] = "#141414"
	$theme['fcolor'] = "#FFFFFF"
	$theme['lcolor'] = "#5AB4C8"

	theme['fsize'] = 12
	$theme['fname'] = 'Tahoma'

	theme['table_bg'] = rgb(32, 32, 32)
	theme['table_bg_alt'] = rgb(48, 48, 48)

	$theme['table_bg'] = "#202020"
	$theme['table_bg_alt'] = "#303030"

elseif $ARGS[0] = 'set_custom':
	gs 'themes', 'reset'
	gs 'themes', 'check_custom_vars'
	$theme['name'] = 'Custom'
	$theme['type'] = $custom_theme['type']
	theme['is_dark'] = val($custom_theme['is_dark'])

	theme['bcolor'] = custom_theme['bcolor']
	theme['fcolor'] = custom_theme['fcolor']
	theme['lcolor'] = custom_theme['lcolor']

	$theme['bcolor'] = func('shortgs', 'rgb_to_hex', theme['bcolor'])
	$theme['fcolor'] = func('shortgs', 'rgb_to_hex', theme['fcolor'])
	$theme['lcolor'] = func('shortgs', 'rgb_to_hex', theme['lcolor'])

	theme['fsize'] = custom_theme['fsize']
	$theme['fname'] = $custom_theme['fname']
	
	theme['table_bg'] = custom_theme['table_bg']
	theme['table_bg_alt'] = custom_theme['table_bg_alt']

	$theme['table_bg'] = func('shortgs', 'rgb_to_hex', theme['table_bg'])
	$theme['table_bg_alt'] = func('shortgs', 'rgb_to_hex', theme['table_bg_alt'])
end

if $ARGS[0] = 'check_custom_vars':
	if $custom_theme['type'] = '': $custom_theme['type'] = 'static'
	if $custom_theme['is_dark'] = '': $custom_theme['is_dark'] = str(1)

	if custom_theme['bcolor'] = 0: custom_theme['bcolor'] = rgb(20, 20, 20)
	if custom_theme['fcolor'] = 0: custom_theme['fcolor'] = rgb(255, 255, 255)
	if custom_theme['lcolor'] = 0: custom_theme['lcolor'] = rgb(90, 180, 200)

	if custom_theme['fsize'] = 0: custom_theme['fsize'] = 12
	if $custom_theme['fname'] = '': $custom_theme['fname'] = 'Tahoma'

	if custom_theme['table_bg'] = '': custom_theme['table_bg'] = rgb(32, 32, 32)
	if custom_theme['table_bg_alt'] = '': custom_theme['table_bg_alt'] = rgb(48, 48, 48)
end

if $ARGS[0] = 'default_palette':
	exit
	theme['base03']  = rgb(0, 43, 54)
	theme['base02']  = rgb(7, 54, 66)
	theme['base01']  = rgb(88, 110, 117)
	theme['base00']  = rgb(101, 123, 131)
	theme['base0']   = rgb(131, 148, 150)
	theme['base1']   = rgb(147, 161, 161)
	theme['base2']   = rgb(238, 232, 213)
	theme['base3']   = rgb(253, 246, 227)
	theme['yellow']  = rgb(181, 137, 0)
	theme['orange']  = rgb(203, 75, 22)
	theme['red']     = rgb(220, 50, 47)
	theme['magenta'] = rgb(211, 54, 130)
	theme['violet']  = rgb(108, 113, 196)
	theme['blue']    = rgb(38, 139, 210)
	theme['cyan']    = rgb(42, 161, 152)
	theme['green']   = rgb(133, 153, 0)

	$theme['base03']  = "#002b36"
	$theme['base02']  = "#073642"
	$theme['base01']  = "#586e75"
	$theme['base00']  = "#657b83"
	$theme['base0']   = "#839496"
	$theme['base1']   = "#93a1a1"
	$theme['base2']   = "#eee8d5"
	$theme['base3']   = "#fdf6e3"
	$theme['yellow']  = "#b58900"
	$theme['orange']  = "#cb4b16"
	$theme['red']     = "#dc322f"
	$theme['magenta'] = "#d33682"
	$theme['violet']  = "#6c71c4"
	$theme['blue']    = "#268bd2"
	$theme['cyan']    = "#2aa198"
	$theme['green']   = "#859900"
end

--- themes ---------------------------------
