/*
	Copyright 2011 (ThiSpawn on gamedeception.com).

	This file is part of Riot File Translator Plug-in for AutoDesk Maya.

	Autodesk Maya's lib is under :
	Copyright 1995, 2006, 2008 Autodesk, Inc. All rights reserved.

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful, 
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

global proc int RiotFileSknImportOptions ( string $parent, 
									string $action,
									string $initialSettings, 
									string $resultCallback )
{
	int 	$result;
	string 	$currentOptions;
	string 	$optionList[];
	string 	$optionBreakDown[];
	int		$index;
	
	if ($action == "post") {
		setUITemplate -pushTemplate DefaultTemplate;
		setParent $parent;

		columnLayout -adj true multiObjCol;
			
			checkBoxGrp -label "Import skeleton" -value1 on // -ncb 1  -l1 "" 
				-cc1 "SknImportupdateOptions" 
				cbSknImportSkl;
				
			checkBoxGrp -label "Template unused bones" -value1 on // -ncb 1 -value1 off -l1 "" 
				-cc1 "SknImportupdateOptions" 
				cbSknTemplateUnusedBones;
				
			separator -style "in";
			
			checkBoxGrp -label "Import and lock normals" -value1 on // -ncb 1 -value1 off -l1 "" 
				-cc1 "SknImportupdateOptions" 
				cbSknNormals;
				
			separator -style "in";

			columnLayout -columnAttach "left" 10;
				picture SknHelpPicture;

		$currentOptions = "embeded_default_options";

		SknImportupdateOptions();

		setUITemplate -popTemplate;
		$result = 1;
	}
	else if ($action == "query")
	{
		string $importSkl = `checkBoxGrp -query -value1 cbSknImportSkl`;
		$currentOptions = "";
		$currentOptions += ("importSkl=" + $importSkl);
		$currentOptions += ";";
		
		if ($importSkl == "1")
		{
			$currentOptions += ("template=" + `checkBoxGrp -query -value1 cbSknTemplateUnusedBones`);
			$currentOptions += ";";
		}
		
		$currentOptions += ("normals=" + `checkBoxGrp -query -value1 cbSknNormals`);
		$currentOptions += ";";

		eval($resultCallback + " \"" + $currentOptions + "\"");
		$result = 1;
	}
	else
	{
		$result = 0;
	}

	return $result;
}

global proc SknImportupdateOptions() 
{
	int $doImportSkl = `checkBoxGrp -q -value1 cbSknImportSkl`;
	int $doTemplate = `checkBoxGrp -q -value1 cbSknTemplateUnusedBones`;
	int $doNormals = `checkBoxGrp -q -value1 cbSknNormals`;
	
	checkBoxGrp -edit -enable ($doImportSkl == 1) cbSknTemplateUnusedBones;
	
	string $helpPicture = "SKIMP";
	
	if ($doImportSkl == 1)
	{
		$helpPicture += "Skl";
		if ($doTemplate == 1)
		{
			$helpPicture += "Template";
		}	
	}
		
	if ($doNormals == 1)
		$helpPicture += "Normals";

	$helpPicture += ".png";

	picture -e -image (languageResourcePath($helpPicture)) -visible yes SknHelpPicture;
}
