macroScript CopySelKeyTypes category:"Bobo_s Tools"
(


--COPY SELECTED KEY TYPES (aka SET KEY TYPES)
--Version 0.2
--Started: 09/24/99
--Edited:  09/30/99
--by Borislav Petrov
--http://gfxcentral.com/bobo/
------------------------------


global ckt2_floater

global subanims_array
local copy_in = 1
local copy_out = 1
local user_in = 1
local user_out = 1
local picked_key = false

rollout ckt_roll "SetKeyTypes"
(
button get_source "GET TYPE FROM SELECTED KEY" width:240 align:#center
dropdownlist s_in "In Tangent" items:#("Smooth","Linear","Step","Fast","Slow","Custom") width:80 across:3 align:#left enabled:false
checkbutton user_type "User Type" align:#center height:40 highlightColor:(color 200 255 200)
dropdownlist s_out "Out Tangent" items:#("Smooth","Linear","Step","Fast","Slow","Custom") width:80 align:#right enabled:false
button assign_types "ASSIGN TYPES TO SELECTED KEYS" width:240 align:#center enabled:false

on user_type changed state do
(
s_in.enabled = state
s_out.enabled = state
if picked_key then assign_types.enabled = true else assign_types.enabled = state 

if state then
	(
	s_in.selection =  user_in
	s_out.selection = user_out
	)
	else
	(
	s_in.selection =  copy_in
	s_out.selection = copy_out
	)
)

on s_in selected itm do
(
user_in = itm
)

on s_out selected itm do
(
user_out = itm
)


on get_source pressed do
(
(
subanims_array = $* as array

i = 0
while i < subanims_array.count do
(
i +=1
for j = 1 to subanims_array[i].numsubs do
	(
	append subanims_array subanims_array[i][j]
	)
)

found_index = 0
for i = 2 to subanims_array.count do
(
try
(
if subanims_array[i].isAnimated  then  
	(
	for k = 1 to subanims_array[i].keys.count do
		(
		if isKeySelected subanims_array[i].controller k then
			(
			if found_index == 0 then 
				(
				found_index = i
				found_key = k
				)
				else
				(
				found_index = -1
				exit
				)
			)	
		)
	)	
)
catch()
)
if found_index == -1 then 
	(
	messagebox "Please select only one Key!"
	)
if found_index > 0 then	
	(
	itt = (subanims_array[found_index].keys[found_key].inTangentType )
	ott = (subanims_array[found_index].keys[found_key].outTangentType )
	itv = (subanims_array[found_index].keys[found_key].inTangent)
	otv = (subanims_array[found_index].keys[found_key].outTangent)

try
(
		case itt of
		(
		#smooth: s_in.selection = 1
		#linear: s_in.selection = 2
		#step: s_in.selection = 3
		#fast: s_in.selection = 4
		#slow: s_in.selection = 5
		#custom: s_in.selection = 6
		)
		case ott of
		(
		#smooth: s_out.selection = 1
		#linear: s_out.selection = 2
		#step: s_out.selection = 3
		#fast: s_out.selection = 4
		#slow: s_out.selection = 5
		#custom: s_out.selection = 6
		)
		copy_in = s_in.selection
		copy_out = s_out.selection
		picked_key = true
		assign_types.enabled = true
)
catch()	

)
)--end if
)--end on


on assign_types pressed do
(

subanims_array = $* as array

i = 0
while i < subanims_array.count do
(
i +=1
for j = 1 to subanims_array[i].numsubs do
	(
	append subanims_array subanims_array[i][j]
	)
)

for i = 2 to subanims_array.count do
(
try
(
if subanims_array[i].isAnimated  then  
	(
	for k = 1 to subanims_array[i].keys.count do
		(
		if isKeySelected subanims_array[i].controller k then
			(
			
			if user_type.checked then
			(
			
			case s_in.selection of
			(
			1: uitt = #smooth
			2: uitt = #linear
			3: uitt = #step
			4: uitt = #fast
			5: uitt = #slow
			6: uitt = #custom
			)
		
			case s_out.selection of
			(
			1: uott = #smooth
			2: uott = #linear
			3: uott = #step
			4: uott = #fast
			5: uott = #slow
			6: uott = #custom
			)
			(subanims_array[i].keys[k].inTangentType ) = uitt
			(subanims_array[i].keys[k].outTangentType ) = uott 

			)
			else
			(
			
			(subanims_array[i].keys[k].inTangentType ) = itt
			(subanims_array[i].keys[k].outTangentType ) = ott 
			(subanims_array[i].keys[k].inTangent) = itv 
			(subanims_array[i].keys[k].outTangent) = otv 
			)
			)	
		)
	)	
)
catch()
)
)

)--end rollout


if ckt2_floater != undefined then closerolloutfloater ckt2_floater
ckt2_floater = newrolloutfloater "SetKeyTypes" 300 165 100 100
addrollout ckt_roll ckt2_floater


)