----------------------------------------------------------------------
-- Set Paths v0.3
-- Author: Jason Hayes
-- Description: Writes to the 3dsmax.ini file and sets it to whatever
--				directories you have entered.
----------------------------------------------------------------------
macroscript Set_Paths category:"FaceMn Tools" buttonText:"Set Paths"
(

if setPaths != undefined then
(
	closeRolloutFloater setPaths
)

setPaths = newRolloutFloater "Set Paths v0.3" 500 302


-- ## GET LOCAL MAX DIRECTORY ##
getMaxRoot = getDir #maxroot
maxINI = getMaxRoot + "3dsmax.ini" as string


-- ## DECLARE PROJECT VARIABLES ##
origin = "Origin"


-- ##################################### MAIN ROLLOUT ###################################
rollout mainRollout ""
(
local getScenes = getINISetting maxINI "Directories" "Scenes"
local getExport = getINISetting maxINI "Directories" "Export"
local getImages = getINISetting maxINI "Directories" "Images"
local getImport = getINISetting maxINI "Directories" "Import"
local getScripts = getINISetting maxINI "Directories" "Scripts"
local getMatLib = getINISetting maxINI "Directories" "Materials"

label lab_scenes "Scenes" pos:[5,8]
label lab_images "Images" pos:[6,30]
label lab_import "Import" pos:[6,52]
label lab_export "Export" pos:[6,74]
label lab_scripts "Scripts" pos:[5,96]
label lab_matLib "MatLib"	pos:[5,118]

edittext et_scenes "" text:getScenes	fieldWidth:350	pos:[49,7]
edittext et_images "" text:getImages	fieldWidth:350	pos:[49,29]
edittext et_import "" text:getImport	fieldWidth:350	pos:[49,51]
edittext et_export "" text:getExport	fieldWidth:350	pos:[49,73]
edittext et_scripts "" text:getScripts	fieldWidth:350	pos:[49,95]
edittext et_matLib "" text:getMatLib	fieldWidth:350	pos:[49,117]

button browse_scenes "Browse"	height:18	pos:[405,7]
button browse_images "Browse"	height:18	pos:[405,29]
button browse_import "Browse"	height:18	pos:[405,51]
button browse_export "Browse"	height:18	pos:[405,73]
button browse_scripts "Browse"	height:18	pos:[405,95]
button browse_matLib "Browse"	height:18	pos:[405,117]




group "Optional"
(
dropDownList ddl "Pick from a Project" width:120 pos:[30,160] items:#("",origin) 
)

button btn_set "Set Paths" width:120 

--################################# EVENTS #####################################
on browse_scenes pressed do
(
	scenesPath = getSavePath() as string
	et_scenes.text = scenesPath
)

on browse_images pressed do
(
	imagesPath = getSavePath() as string
	et_images.text = imagesPath
)

on browse_import pressed do
(
	importPath = getSavePath() as string
	et_import.text = importPath
)

on browse_export pressed do
(
	exportPath = getSavePath() as string
	et_export.text = exportPath
)

on browse_scripts pressed do
(
	theScriptsPath = getSavePath() as string
	et_scripts.text = theScriptsPath
)

on browse_matLib pressed do
(
	matLibPath = getSavePath() as string
	et_matLib.text = matLibPath
)

on ddl selected i do
(
	if ddl.items[i] == origin then
	(
		et_scenes.text = "Q:\Origin\Wearables\Clothing"
		et_images.text = "Q:\Origin\Wearables\Clothing\Images"
		et_import.text = "Q:\Origin\Wearables"
		et_export.text = "Q:\Origin\Wearables\Exported"
	)
)

on btn_set pressed do
(
	scenes_array = et_scenes.text
	images_array = et_images.text
	import_array = et_import.text
	export_array = et_export.text
	scripts_array = et_scripts.text
	matLib_array = et_matLib.text
	
	setINISetting maxINI "Directories" "Scenes" scenes_array
	setINISetting maxINI "Directories" "Images" images_array
	setINISetting maxINI "Directories" "Import" import_array
	setINISetting maxINI "Directories" "Export" export_array
	setINISetting maxINI "Directories" "Scripts" scripts_array
	setINISetting maxINI "Directories" "Materials" matLib_array
	
	messageBox "You must restart MAX for the new paths to take effect." title:"Set Paths"
)
)--end rollout
-- ################################### ADD ROLLOUT ################################
addrollout mainRollout setPaths
)--end macroscript

