/*!
__MXSDOC__

[TITLE]
Fume Source Manager

[DESCRIPTION]
Manage Fume Sources 

[USAGE]


[CREATION INFO]


[Category]


[KEYWORDS]

[VERSION HISTORY]
1.1 Baddassedness

[DEPENDENCIES]


[SEE ALSO]


__END__
*/


rollout ObjSrcDup "Source Duplication" width:152 height:392
(
	local _objects = #()
	
	fn fumegrid_filt obj =classof obj == FumeFX
	fn objsrc_filt obj = classof obj == Object_Src
	
	pickbutton btn_fumegrid "Select Fume Grid" pos:[8,24] width:137 height:27 message:"Select FumeGrid" filter:fumegrid_filt autoDisplay:true
	label lbl1 "Fume Grid:   (optional)" pos:[8,8] width:133 height:16
	pickbutton btn_objsrc "Select Object Src" pos:[8,80] width:137 height:27 message:"Select FumeGrid" filter:objsrc_filt autoDisplay:true
	label lbl2 "Object Src to Copy:" pos:[8,64] width:133 height:16
	listbox listbx1 "Objects to be Sources" pos:[8,112] width:136 height:6
	button btn_add "Add Selection to List" pos:[8,216] width:136 height:24
	button btn_doit "Do It!" pos:[8,352] width:136 height:34
	edittext edt_selsetname "Set Name" pos:[8,272] width:136 height:16
	checkbox chk_selset "Add Srcs to Sel. Set:" pos:[17,248] width:128 height:16 checked:true
	colorPicker cp1 "WireColor" pos:[8,296] width:136 height:24 color:(color 255 150 0)
	edittext edt_srcname "SrcName" pos:[8,328] width:136 height:16
	
	fn isValidObj obj = 
	(
		local valid = false
		
		if ( superclassof obj == GeometryClass ) then (
			if ( classof obj != FumeFx ) then (
				valid = true
			)
		)
		valid
	)
	
	on objsrcdup open do
	(
		edt_selsetname.text = "FX_Fume_ObjSrcSet"
	)
	
	on btn_add pressed do
	(
			objSrcDup._objects 	= for obj in selection as array where isValidObj obj collect obj
			listbx1.items 		= for obj in objSrcDup._objects collect obj.name
	)
	
	on btn_doit pressed do
	(
			local src 	= btn_objsrc.object
			local fg 	= btn_fumegrid.object
			srcarray = #()
		
			if ( src != undefined ) then (
				if ( src.object.count != 0 ) then (
					--if ( fg != undefined ) then (
						if ( objSrcDup._objects.count > 0 ) then 
							(
								for obj in objSrcDup._objects do
									(
										SrcCopy 			= copy src
										SrcCopy.pos 		= obj.center 	-- copy and move objectsrc to source object	
										SrcCopy.object 		= #(obj) 		-- selection has to be an array
										SrcCopy.parent 		= obj    		-- parent object src to source object
										SrcCopy.wirecolor 	= cp1.color
										if ( fg != undefined ) then fg.addsource SrcCopy				-- add to fumegrid list
										append srcarray srccopy
										
										if edt_srcname.text != "" then
											( 
												for i in 1 to srcarray.count do
												(Srcarray[i].name = edt_srcname.text + "_0" + i as string)
											)
									)
									
								if chk_selset.checked == true then
									(
										selectionsets[edt_selsetname.text] = srcarray
										selsetarray = #("None")
										for i = 1 to selectionsets.count do
										(
											append selsetarray (getNamedSelSetName i)
										)
										selset.ddl_sel.items = selsetarray
										global objsrcset = undefined
										messageBox "Done! Please select your Selection Set manually until I figure out how to make it work automatically"
									)
							)
						else messageBox "Please Select some Geometry"
					)
					--else messageBox "Fume grid not selected"
				--)
				else messageBox "Object Src needs object picked in order to copy properly"
			)
			else messageBox "Object Source not selected"
		)
)

rollout selSet "Selection Sets" width:160 height:153
(
	dropdownList ddl_sel "Selection Set" pos:[8,8] width:144 height:40 
	label lbl3 "If selected, you don't have to retain your selection in the viewport" pos:[8,56] width:144 height:40
	button btn_refresh "Refresh List" pos:[9,102] width:144 height:30
	
	on selSet open do
	(
		selsetarray = #("None")
		for i = 1 to selectionsets.count do
		(
			append selsetarray (getNamedSelSetName i)
		)
		ddl_sel.items = selsetarray
		global objsrcset = undefined
	)
	
	on ddl_sel selected sel do
	(
		if ddl_sel.selected != "none" then
		(
			global objsrcset = selectionsets[ddl_sel.selected]	
		)
	)
	
	on btn_refresh pressed do
	(
		selsetarray = #("None")
		for i = 1 to selectionsets.count do
		(
			append selsetarray (getNamedSelSetName i)
		)
		ddl_sel.items = selsetarray
		global objsrcset = undefined
	)
)

rollout srcparam "Parameters" width:160 height:88
(
	checkbox chk_freeflow "Free Flow" pos:[80,8] width:64 height:16 enabled:true
	spinner spn_IconSize "Icon Size:" pos:[24,32] width:120 height:16 range:[0,100000,0] scale:0.1
	spinner spn_mapchan "Map Channel:" pos:[24,56] width:120 height:16 range:[0,100000,0] scale:1 fieldwidth:30 type:#integer
	
	on srcparam open do 
	( 
		spn_Iconsize.value = 10 
	)
	
	on chk_freeflow changed stat do
	(
		if objsrcset == undefined then
		(
		for obj in selection where classof obj == Object_Src do
			(
				if chk_freeflow.state == false then obj.FreeFlow = off
				if chk_freeflow.state == true then obj.Freeflow = on
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			(
				if chk_freeflow.state == false then obj.FreeFlow = off
				if chk_freeflow.state == true then obj.Freeflow = on
			)
		)
	)
	
	
	on spn_IconSize changed val do
	(
		if objsrcset == undefined then
		(
		for obj in selection where classof obj == Object_Src do obj.iconSize = spn_Iconsize.value
		)
		else 
		(
			for obj in objsrcset where classof obj == Object_Src do obj.iconSize = spn_Iconsize.value
		)
	)
	
	on spn_mapchan changed val do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do obj.mapchannel = spn_mapchan.value
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do obj.mapchannel = spn_mapchan.value
		)
	)
)

 rollout srcfuelparam "Fuel" width:160 height:296
 (
 	radiobuttons rdo_ftype "Type:" pos:[16,88] width:128 height:46 labels:#("Disabled", "Add", "Set") default:3 columns:2
 	button btn_updateftype "Update Fuel Type" pos:[24,136] width:112 height:24
 	spinner spn_famount "Amount" pos:[24,8] width:120 height:16 range:[0,100,0] scale:0.01
 	spinner spn_famountvar "Variation" pos:[24,32] width:120 height:16 range:[0,100,0] scale:0.01
 	button btn_updatefamounts "Update Amounts" pos:[24,56] width:112 height:24
	mapButton btn_fmap "None" pos:[48,232] width:96 height:24
 	label lbl_fmap "Map:" pos:[16,232] width:24 height:24
 	radiobuttons rdo_fmapemit "Map Emission:" pos:[16,168] width:128 height:62 labels:#("Disabled", "Red", "Green", "Blue", "Intensity") default:1 columns:2
 	button brn_updatefmap "Update Fuel Map Info" pos:[16,264] width:128 height:24
 	
 
	 on srcfuelparam open do 
	( 
		spn_famount.value = 100
	)
	 
	on rdo_ftype changed stat do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			(
				if rdo_ftype.state == 1 then obj.fueltype = 0
				if rdo_ftype.state == 2 then obj.fueltype = 1
				if rdo_ftype.state == 3 then obj.fueltype = 2
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			(
				if rdo_ftype.state == 1 then obj.fueltype = 0
				if rdo_ftype.state == 2 then obj.fueltype = 1
				if rdo_ftype.state == 3 then obj.fueltype = 2
			)
		)
	)

	on btn_updateftype pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			(
				if rdo_ftype.state == 1 then obj.fueltype = 0
				if rdo_ftype.state == 2 then obj.fueltype = 1
				if rdo_ftype.state == 3 then obj.fueltype = 2
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			(
				if rdo_ftype.state == 1 then obj.fueltype = 0
				if rdo_ftype.state == 2 then obj.fueltype = 1
				if rdo_ftype.state == 3 then obj.fueltype = 2
			)
		)
	)

 	on spn_famount changed val do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
			obj.Fire___Fuel = random (spn_famount.value - spn_famountvar.value) (spn_famount.value + spn_famountvar.value)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			obj.Fire___Fuel = random (spn_famount.value - spn_famountvar.value) (spn_famount.value + spn_famountvar.value)
		)
 	)
	
	on btn_updatefamounts pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
			obj.Fire___Fuel = random (spn_famount.value - spn_famountvar.value) (spn_famount.value + spn_famountvar.value)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			obj.Fire___Fuel = random (spn_famount.value - spn_famountvar.value) (spn_famount.value + spn_famountvar.value)
		)
 	)
 
	on btn_fmap picked mtl do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
				obj.fuelmap = btn_fmap.map
				btn_fmap.caption = btn_fmap.map as string
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
				obj.fuelmap = btn_fmap.map
				btn_fmap.caption = btn_fmap.map as string
		)			
 	)
	
 	on rdo_fmapemit changed state do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
			(
				if rdo_fmapemit.state == 1 then obj.vcfuel = 0
				if rdo_fmapemit.state == 2 then obj.vcfuel = 1
				if rdo_fmapemit.state == 3 then obj.vcfuel = 2
				if rdo_fmapemit.state == 4 then obj.vcfuel = 3
				if rdo_fmapemit.state == 5 then obj.vcfuel = 4
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			(
				if rdo_fmapemit.state == 1 then obj.vcfuel = 0
				if rdo_fmapemit.state == 2 then obj.vcfuel = 1
				if rdo_fmapemit.state == 3 then obj.vcfuel = 2
				if rdo_fmapemit.state == 4 then obj.vcfuel = 3
				if rdo_fmapemit.state == 5 then obj.vcfuel = 4
			)
		)
	)
 	
	on btn_updatefmap pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
			(
				if rdo_fmapemit.state == 1 then obj.vcfuel = 0
				if rdo_fmapemit.state == 2 then obj.vcfuel = 1
				if rdo_fmapemit.state == 3 then obj.vcfuel = 2
				if rdo_fmapemit.state == 4 then obj.vcfuel = 3
				if rdo_fmapemit.state == 5 then obj.vcfuel = 4
			
				obj.fuelmap = btn_fmap.map
				btn_fmap.caption = btn_fmap.map as string
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			(
				if rdo_fmapemit.state == 1 then obj.vcfuel = 0
				if rdo_fmapemit.state == 2 then obj.vcfuel = 1
				if rdo_fmapemit.state == 3 then obj.vcfuel = 2
				if rdo_fmapemit.state == 4 then obj.vcfuel = 3
				if rdo_fmapemit.state == 5 then obj.vcfuel = 4
			
				obj.fuelmap = btn_fmap.map
				btn_fmap.caption = btn_fmap.map as string
			)
		)
	)
)

rollout srcsmokeparam "Smoke" width:160 height:296
(
	radiobuttons rdo_stype "Type:" pos:[16,88] width:128 height:46 labels:#("Disabled", "Add", "Set") default:3 columns:2
	button btn_updatestype "Update Smoke Type" pos:[25,136] width:112 height:24
	spinner spn_Samount "Amount" pos:[24,8] width:120 height:16 range:[0,100000,0] scale:0.01
	spinner spn_samountvar "Variation" pos:[24,32] width:120 height:16 range:[0,100000,0] scale:0.01
	button btn_updatesamounts "Update Amounts" pos:[24,56] width:112 height:24
	mapButton btn_smap "None" pos:[48,232] width:96 height:24
	label lbl4 "Map:" pos:[16,232] width:24 height:24
	radiobuttons rdo_smapemit "Map Emission:" pos:[16,168] width:128 height:62 labels:#("Disabled", "Red", "Green", "Blue", "Intensity") default:1 columns:2
	button btn_updatesmap "Update Smoke Map Info" pos:[17,264] width:128 height:24
	
	on srcsmokeparam open do 
	( 
		spn_samount.value = 2
	)
	
	on rdo_stype changed stat do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			(
				if rdo_stype.state == 1 then obj.smoketype = 0
				if rdo_stype.state == 2 then obj.smoketype = 1
				if rdo_stype.state == 3 then obj.smoketype = 2
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			(
				if rdo_stype.state == 1 then obj.smoketype = 0
				if rdo_stype.state == 2 then obj.smoketype = 1
				if rdo_stype.state == 3 then obj.smoketype = 2
			)
		)
	)

	on btn_updatestype pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			(
				if rdo_stype.state == 1 then obj.smoketype = 0
				if rdo_stype.state == 2 then obj.smoketype = 1
				if rdo_stype.state == 3 then obj.smoketype = 2
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			(
				if rdo_stype.state == 1 then obj.smoketype = 0
				if rdo_stype.state == 2 then obj.smoketype = 1
				if rdo_stype.state == 3 then obj.smoketype = 2
			)
		)
	)

	on spn_Samount changed val do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
				obj.Smoke___Density = random (spn_samount.value - spn_samountvar.value) (spn_samount.value + spn_samountvar.value)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
				obj.Smoke___Density = random (spn_samount.value - spn_samountvar.value) (spn_samount.value + spn_samountvar.value)
		)
	)
	
	on btn_updatesamounts pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
				obj.Smoke___Density = random (spn_samount.value - spn_samountvar.value) (spn_samount.value + spn_samountvar.value)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
				obj.Smoke___Density = random (spn_samount.value - spn_samountvar.value) (spn_samount.value + spn_samountvar.value)
		)
	)

	on btn_smap picked texmap do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
				obj.densmap = btn_smap.map
				btn_smap.caption = btn_smap.map as string
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
				obj.densmap = btn_smap.map
				btn_smap.caption = btn_smap.map as string
		)
	)

	on rdo_smapemit changed stat do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
			(
				if rdo_smapemit.state == 1 then obj.vcdens = 0
				if rdo_smapemit.state == 2 then obj.vcdens = 1
				if rdo_smapemit.state == 3 then obj.vcdens = 2
				if rdo_smapemit.state == 4 then obj.vcdens = 3
				if rdo_smapemit.state == 5 then obj.vcdens = 4
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			(
				if rdo_smapemit.state == 1 then obj.vcdens = 0
				if rdo_smapemit.state == 2 then obj.vcdens = 1
				if rdo_smapemit.state == 3 then obj.vcdens = 2
				if rdo_smapemit.state == 4 then obj.vcdens = 3
				if rdo_smapemit.state == 5 then obj.vcdens = 4
			)
		)
	)
	
	on btn_updatesmap pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
			(
				if rdo_smapemit.state == 1 then obj.vcdens = 0
				if rdo_smapemit.state == 2 then obj.vcdens = 1
				if rdo_smapemit.state == 3 then obj.vcdens = 2
				if rdo_smapemit.state == 4 then obj.vcdens = 3
				if rdo_smapemit.state == 5 then obj.vcdens = 4
			
				obj.densmap = btn_smap.map
				btn_smap.caption = btn_smap.map as string
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			(
				if rdo_smapemit.state == 1 then obj.vcdens = 0
				if rdo_smapemit.state == 2 then obj.vcdens = 1
				if rdo_smapemit.state == 3 then obj.vcdens = 2
				if rdo_smapemit.state == 4 then obj.vcdens = 3
				if rdo_smapemit.state == 5 then obj.vcdens = 4
			
				obj.densmap = btn_smap.map
				btn_smap.caption = btn_smap.map as string
			)
		)
	)
)

rollout srctempparam "Temperature" width:160 height:296
(
	radiobuttons rdo_ttype "Type:" pos:[16,88] width:128 height:46 labels:#("Disabled", "Add", "Set") default:3 columns:2
	button btn_updatettype "Update Temp Type" pos:[17,136] width:128 height:24
	spinner spn_tamount "Amount" pos:[25,10] width:120 height:16 range:[-100000,100000,0] scale:0.01
	spinner spn_tamountvar "Variation" pos:[24,32] width:120 height:16 range:[0,100000,0] scale:0.01
	button btn_updatetamounts "Update Amounts" pos:[16,56] width:128 height:24
	mapButton btn_tmap "None" pos:[48,232] width:96 height:24
	label lbl7 "Map:" pos:[16,232] width:24 height:24
	radiobuttons rdo_tmapemit "Map Emission:" pos:[16,168] width:128 height:62 labels:#("Disabled", "Red", "Green", "Blue", "Intensity") default:1 columns:2
	button btn_updatetmap "Update Temp Map Info" pos:[17,264] width:128 height:24
	
	on srctempparam open do 
	( 
		spn_tamount.value = 300
	)
	
	on rdo_ttype changed stat do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			(
				if rdo_ttype.state == 1 then obj.temptype = 0
				if rdo_ttype.state == 2 then obj.temptype = 1
				if rdo_ttype.state == 3 then obj.temptype = 2
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			(
				if rdo_ttype.state == 1 then obj.temptype = 0
				if rdo_ttype.state == 2 then obj.temptype = 1
				if rdo_ttype.state == 3 then obj.temptype = 2
			)
		)
	)
	
	on btn_updatettype pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			(
				if rdo_ttype.state == 1 then obj.temptype = 0
				if rdo_ttype.state == 2 then obj.temptype = 1
				if rdo_ttype.state == 3 then obj.temptype = 2
			)
		)
		else
		(
		for obj in objsrcset where classof obj == Object_Src do
			(
				if rdo_ttype.state == 1 then obj.temptype = 0
				if rdo_ttype.state == 2 then obj.temptype = 1
				if rdo_ttype.state == 3 then obj.temptype = 2
			)
		)
	)
	
	on spn_tamount changed val do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			obj.Temperature = random (spn_tamount.value - spn_tamountvar.value) (spn_tamount.value + spn_tamountvar.value)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			obj.Temperature = random (spn_tamount.value - spn_tamountvar.value) (spn_tamount.value + spn_tamountvar.value)
		)
	)
	
	on btn_updatetamounts pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			obj.Temperature = random (spn_tamount.value - spn_tamountvar.value) (spn_tamount.value + spn_tamountvar.value)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			obj.Temperature = random (spn_tamount.value - spn_tamountvar.value) (spn_tamount.value + spn_tamountvar.value)
		)
	)
	
	on btn_tmap picked texmap do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
				obj.tempmap = btn_tmap.map
				btn_tmap.caption = btn_tmap.map as string
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
				obj.tempmap = btn_tmap.map
				btn_tmap.caption = btn_tmap.map as string
		)
	)
	
	on rdo_tmapemit changed stat do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
				(
					if rdo_tmapemit.state == 1 then obj.vctemp = 0
					if rdo_tmapemit.state == 2 then obj.vctemp = 1
					if rdo_tmapemit.state == 3 then obj.vctemp = 2
					if rdo_tmapemit.state == 4 then obj.vctemp = 3
					if rdo_tmapemit.state == 5 then obj.vctemp = 4
				)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
				(
					if rdo_tmapemit.state == 1 then obj.vctemp = 0
					if rdo_tmapemit.state == 2 then obj.vctemp = 1
					if rdo_tmapemit.state == 3 then obj.vctemp = 2
					if rdo_tmapemit.state == 4 then obj.vctemp = 3
					if rdo_tmapemit.state == 5 then obj.vctemp = 4
				)
		)
	)
	
	on btn_updatetmap pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
			(
				if rdo_tmapemit.state == 1 then obj.vctemp = 0
				if rdo_tmapemit.state == 2 then obj.vctemp = 1
				if rdo_tmapemit.state == 3 then obj.vctemp = 2
				if rdo_tmapemit.state == 4 then obj.vctemp = 3
				if rdo_tmapemit.state == 5 then obj.vctemp = 4
			
				obj.tempmap = btn_tmap.map
				btn_tmap.caption = btn_tmap.map as string
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			(
				if rdo_tmapemit.state == 1 then obj.vctemp = 0
				if rdo_tmapemit.state == 2 then obj.vctemp = 1
				if rdo_tmapemit.state == 3 then obj.vctemp = 2
				if rdo_tmapemit.state == 4 then obj.vctemp = 3
				if rdo_tmapemit.state == 5 then obj.vctemp = 4
			
				obj.tempmap = btn_tmap.map
				btn_tmap.caption = btn_tmap.map as string
			)
		)
	)
)

rollout srcturbparam "Turbulence" width:160 height:120
(
	spinner spn_turbamount "Amount:" pos:[24,8] width:120 height:16 range:[0,1,0] scale:0.01
	spinner spn_turbscale "Scale:" pos:[24,32] width:120 height:16 range:[0,100000,0] scale:0.1
	spinner spn_turbframes "Frames:" pos:[24,56] width:120 height:16 range:[0,100000,0] scale:0.01
	button btn_updateturbamounts "Update Turbulence" pos:[16,80] width:128 height:32
	
	on srcturbparam open do
	(
		spn_turbamount.value = .5
		spn_turbscale.value = 10
		spn_turbframes.value = 3
	)
		
	on spn_turbamount changed val do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
				obj.turbulence = spn_turbamount.value
		)
		else 
		(
			for obj in objsrcset where classof obj == Object_Src do 
				obj.turbulence = spn_turbamount.value
		)
	)
	
	on spn_turbscale changed val do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
				obj.turbulencescale = spn_turbscale.value
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			obj.turbulencescale = spn_turbscale.value
		)
	)
	
	on spn_turbframes changed val do
	(
		if objsrcset == underfined then
		(
			for obj in selection where classof obj == Object_Src do 
			obj.turbulenceframes = spn_turbframes.value
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			obj.turbulenceframes = spn_turbframes.value
		)
	)
	
	on btn_updateturbamounts pressed do
	(
		if objsrcset == underfined then
		(
			for obj in selection where classof obj == Object_Src do 
			(
				obj.turbulence = spn_turbamount.value
				obj.turbulencescale = spn_turbscale.value
				obj.turbulenceframes = spn_turbframes.value
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
			(
				obj.turbulence = spn_turbamount.value
				obj.turbulencescale = spn_turbscale.value
				obj.turbulenceframes = spn_turbframes.value
			)
		)
	)
	
)

rollout srcvelparam "Velocity" width:160 height:184
(
	spinner spn_objvel "Object's:" pos:[25,8] width:120 height:16 range:[0,100000,0] scale:0.1
	spinner spn_extravel "Extra:" pos:[25,32] width:120 height:16 range:[0,100000,0] scale:0.1
	mapButton btn_vmap "None" pos:[49,120] width:96 height:24
	label lbl_vmap "Map:" pos:[17,120] width:24 height:24
	radiobuttons rdo_vmapemit "Map Emission:" pos:[17,56] width:128 height:62 labels:#("Disabled", "Red", "Green", "Blue", "Intensity") default:5 columns:2
	button btn_updatevmap "UpdateVel Map Info" pos:[17,152] width:128 height:24
	
	on srcvelparam open do
	(
		spn_objvel.value = 1
		spn_extravel.value = .1
	)
	
	on spn_objvel changed val do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
				obj.Object_Velocity = spn_objvel.value
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
				obj.Object_Velocity = spn_objvel.value
		)
	)
	
	on spn_extravel changed val do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do 
				obj.Extra_Velocity = spn_extravel.value
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do 
				obj.Extra_Velocity = spn_extravel.value
		)
	)
		
	on btn_vmap picked mtl do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
				obj.extravelmap = btn_vmap.map
				btn_vmap.caption = btn_vmap.map as string
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
				obj.extravelmap = btn_vmap.map
				btn_vmap.caption = btn_vmap.map as string
		)			
	)
	
	on rdo_vmapemit changed stat do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			(
				if rdo_vmapemit.state == 1 then obj.vccol = 0
				if rdo_vmapemit.state == 2 then obj.vccol = 1
				if rdo_vmapemit.state == 3 then obj.vccol = 2
				if rdo_vmapemit.state == 4 then obj.vccol = 3
				if rdo_vmapemit.state == 5 then obj.vccol = 4
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			(
				if rdo_vmapemit.state == 1 then obj.vccol = 0
				if rdo_vmapemit.state == 2 then obj.vccol = 1
				if rdo_vmapemit.state == 3 then obj.vccol = 2
				if rdo_vmapemit.state == 4 then obj.vccol = 3
				if rdo_vmapemit.state == 5 then obj.vccol = 4
			)
		)			
	)
	
	on btn_updatevmap pressed  do
	(
		if objsrcset == undefined then
		(
			for obj in selection where classof obj == Object_Src do
			(
				if rdo_vmapemit.state == 1 then obj.vccol = 0
				if rdo_vmapemit.state == 2 then obj.vccol = 1
				if rdo_vmapemit.state == 3 then obj.vccol = 2
				if rdo_vmapemit.state == 4 then obj.vccol = 3
				if rdo_vmapemit.state == 5 then obj.vccol = 4
			
				obj.extravelmap = btn_vmap.map
				btn_vmap.caption = btn_vmap.map as string
			)
		)
		else
		(
			for obj in objsrcset where classof obj == Object_Src do
			(
				if rdo_vmapemit.state == 1 then obj.vccol = 0
				if rdo_vmapemit.state == 2 then obj.vccol = 1
				if rdo_vmapemit.state == 3 then obj.vccol = 2
				if rdo_vmapemit.state == 4 then obj.vccol = 3
				if rdo_vmapemit.state == 5 then obj.vccol = 4
			
				obj.extravelmap = btn_vmap.map
				btn_vmap.caption = btn_vmap.map as string
			)
		)
	)
)

sourcemgrfloater = newrolloutfloater "Source Manager" 170 600
addrollout objsrcdup sourcemgrfloater
addrollout selset sourcemgrfloater
addrollout srcparam sourcemgrfloater
addrollout srcfuelparam sourcemgrfloater
addrollout srctempparam sourcemgrfloater
addrollout srcsmokeparam sourcemgrfloater
addrollout srcvelparam sourcemgrfloater
addrollout srcturbparam sourcemgrfloater
