// Copyright (C) 1997-2006 Autodesk, Inc., and/or its licensors.
// All rights reserved.
//
// The coded instructions, statements, computer programs, and/or related
// material (collectively the "Data") in these files contain unpublished
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its licensors,
// which is protected by U.S. and Canadian federal copyright law and by
// international treaties.
//
// The Data is provided for use exclusively by You. You have the right to use,
// modify, and incorporate this Data into other products for purposes authorized 
// by the Autodesk software license agreement, without fee.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. AUTODESK
// DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTIES
// INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF NON-INFRINGEMENT,
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ARISING FROM A COURSE 
// OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS
// LICENSORS BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL,
// DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS
// LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.

//
//  Alias Script File
//  MODIFY THIS AT YOUR OWN RISK
//
//  Creation Date:  Feb. 6, 1997
//
//  Description:
//      Project Create/Setup window.
//
//  Input Arguments:
//		None
// 
//  Return Value:
//		None
//

proc string[] np_getTranslatorWidgetMap()
{
	string $map[] =
	{
//		Translator								Widget
		"DXF",									"dxf",
		"DXFexport",							"dxf",
		"IGES",									"iges",
		"IGESexport",							"iges",
		"OBJ",									"obj",
		"OBJexport",							"obj",
		"RIB",									"rib",
		"RIBexport",							"rib",
		"aliasWire",							"wire",
		"animImport",							"anim",
		"animExport",							"anim",
		"EPS",									"eps",
		"Adobe(R) Illustrator(R)",				"illustrator",
		"diskCache",							"diskCache",
		"mayaAscii",							"mayaAscii",
		"mayaBinary",							"mayaBinary"
	};
	if( `about -evalVersion` ) {
		// Not a copy-paste error. Mapping of translator to widget happens to be
		// the same for mayaPLE.
		$map[size($map)] = "mayaPLE";
		$map[size($map)] = "mayaPLE";
	}

	return $map;
}

proc string[] np_getFileRuleWidgets(string $wsName)
{
	// These lines should be visible always
	//
	string $defaults[] =
	{
//		Label							Widget				Default				Current
		(uiRes("m_projectSetup.kObjWidgetScenes")),				"scene",		"scenes",				"",
		(uiRes("m_projectSetup.kRendWidgetImgs")),				"images",		"images",				"",
		(uiRes("m_projectSetup.kRendWidgetSrcImgs")),	"sourceImages",	"sourceimages",			"",
		(uiRes("m_projectSetup.kDiskCache")),				"diskCache",	"data",					"",
		(uiRes("m_projectSetup.kRendWidgetParticles")),		"particles",	"particles",			"",
		(uiRes("m_projectSetup.kRendWidgetRendScene")),	"renderScenes",	"renderScenes",			"",
		(uiRes("m_projectSetup.kRendWidgetDepth")),				"depth",		"renderData/depth",		"",
		(uiRes("m_projectSetup.kRendWidgetIprImgs")),		"iprImages",	"renderData/iprImages",	"",
		(uiRes("m_projectSetup.kTemplateWidget")),			"templates",	"assets",				"",
		(uiRes("m_projectSetup.kRendWidgetClips")),				"clips",		"clips",				"",
		(uiRes("m_projectSetup.kRendWidgetSound")),				"audio",		"sound",				"",
		(uiRes("m_projectSetup.kAdobeIllustrator")), 	"illustrator",		"data",			"",

		// This naming admittedly doesn't make much sense - textures should be
		// shaders, lights should be lights. Since 3dPaint is now using 
		// textures we're going to point both lights and (hypershade-
		// exported) shaders into the 'lights' location (and add a separate
		// 'shaders' location later...)
		//
		(uiRes("m_projectSetup.kRendWidgetShaders")),			"lights",		"renderData/shaders",	"",
		(uiRes("m_projectSetup.kRendWidgetTextures")),		"textures",		"textures",				"",
		(uiRes("m_projectSetup.kRendWidgetMel")),					"mel",			"mel",					"",
		(uiRes("m_projectSetup.kRendWidget3dPaintTex")),"3dPaintTextures",	"3dPaintTextures",	"",

		// We should always use "mentalray" going forward.
		//
		(uiRes("m_projectSetup.kRendWidgetMR")),				"mentalray",	"renderData/mentalray",	"",

		"DXF",											"dxf",				"data",				"",
		"IGES",											"iges",				"data",				"",
		"OBJ",											"obj",				"data",				"",
		"RIB",											"rib",				"data",				"",
		"Wire",											"wire",				"data",				"",
		"Move",											"move",				"data",				"",
		"Anim",											"anim",				"data",				"",
		"EPS",											"eps",				"data",				"",
		"mayaAscii",									"mayaAscii",		"scenes",			"",
		"mayaBinary",									"mayaBinary",		"scenes",			"",

		"MAYA2010 HND2 Exporter",						"MAYA2010 HND2Exporter",					"hnd2",			"",
		"MAYA2010 NNExporter for PlayStation2",			"MAYA2010 NNExporter for PlayStation2",		"nnps2",		"",
		"MAYA2010 NNExporter for GAMECUBE",				"MAYA2010 NNExporter for GAMECUBE",			"nngc",			"",
		"MAYA2010 NNExporter for DirectX G1.1",			"MAYA2010 NNExporter for DirectX G1.1",		"nndxg11",		"",
		"MAYA2010 NNExporter for Lindbergh",			"MAYA2010 NNExporter for Lindbergh",		"nnlb",			"",
		"MAYA2010 NNExporter for PSP",					"MAYA2010 NNExporter for PSP",				"nnpsp",		"",
		"MAYA2010 NNExporter for XBOX360",				"MAYA2010 NNExporter for XBOX360",			"nnxbox360",	"",
		"MAYA2010 NNExporter for DirectX G2.0",			"MAYA2010 NNExporter for DirectX G2.0",		"nndxg2",		"",
		"MAYA2010 NNExporter for PlayStation3",			"MAYA2010 NNExporter for PlayStation3",		"nnps3",		"",
		"MAYA2010 NNExporter for OpenGL ES 1.1",		"MAYA2010 NNExporter for OpenGL ES 1.1",	"nngles11",		"",
		"MAYA2010 NNExporter for OpenGL ES 2.0",		"MAYA2010 NNExporter for OpenGL ES 2.0",	"nngles20",		"",
		"MAYA2010 NNExporter for PS Vita",				"MAYA2010 NNExporter for PS Vita",			"nnvita",		"",

		"MAYA2010 HND2 Importer",						"MAYA2010 HND2 Importer",					"hnd2",			""

	};

	// Only add info for mayaPLE if we have an eval version
	if( `about -evalVersion` ) {
		int $index = size($defaults);
		$defaults[$index] = "mayaPLE";
		$defaults[$index+1] = "mayaPLE";
		$defaults[$index+2] = "scenes";
		$defaults[$index+3] = "";
	}

	// This is a list of translators to completely ignore
	//
	string $ignore[] =
	{
		// In 2009, we explictly add rules for mayaAscii, mayaBinary and mayaPLE,
		// and have them point to the 'scenes' folder
		//"mayaAscii",
		//"mayaBinary",
		//"mayaPLE",
		"directory",
		"plug-in",
		"fluidCache",
		// The following are added by the Data Transfer team and
		// do not require project support.
		"studioImport",
		"DWG_DXF",
		"PTC_DC",
		"SW_DC",
		"STEP_DC",
		"STL_DC",
		"IV_DC",
		"CSB_DC",
		"IGES_DC",
		"DWG_DC",
		"IGESExport",
		"DXFExport",
		"DWGExport",
		"iv2",
		"OpenFlight",
		"vrml2",
		"GE2",
		"STL",
		"rtg",
		"aliasWireExport",

		// The following are either old translator names or
		// were introduced in error during development.  They
		// should be cleaned up.
		//
		"dxf",			// should be DXF
		"iges",			// should be IGES
		"aiff"			// should be audio
	};

	int $i, $j;
	int $found, $skip;
	string $map[] = np_getTranslatorWidgetMap();
	string $widget;

	string $trans[] = `translator -q -l`;

	// If we have a workspace, add the current file rules
	//
	if ($wsName != "")
	{
		string $rules[] = `workspace -q -frl`;

		for ($i = 0; $i < size($rules); ++$i)
		{
			$trans[size($trans)] = $rules[$i];
		}
	}

	for ($i = 0; $i < size($trans); ++$i)
	{
		$widget = $trans[$i];

		$skip = 0;

		// See if this translator should be ignored
		if( stringArrayContains($widget, $ignore) ) {
			continue;
		}

		// Map the translator name to a widget
		//
		for ($j = 0; $j < size($map); $j += 2)
		{
			if ($widget == $map[$j])
			{
				$widget = $map[$j + 1];
				break;
			}
		}

		// See if the translator is already in the list so we
		// don't add it twice.
		//
		for ($j = 0; $j < size($defaults); $j += 4)
		{
			if ($widget == $defaults[$j + 1])
			{
				// Yep, we've seen this one already
				if ($wsName != "")
				{
					$defaults[$j + 3] = `workspace -q -fre $trans[$i]`;
				}
				$skip = 1;
				break;
			}
		}

		if ($skip)
		{
			continue;
		}

		string $defaultLocation = $widget;
		if ( gmatch( $trans[$i], "fur*" ) )
		{
			$defaultLocation = "fur/" + $widget;
		}

		// Having made it this far, add it to the list of widgets
		//
		$defaults[size($defaults)] = $trans[$i];
		$defaults[size($defaults)] = $widget;
		$defaults[size($defaults)] = $defaultLocation;
		if ($wsName == "")
		{
			$defaults[size($defaults)] = "";
		}
		else
		{
			$defaults[size($defaults)] = `workspace -q -fre $trans[$i]`;
		}
	}

	return $defaults;
}

global proc np_resetDefaults ( )
//
//	Description:
//		Fill in the project defaults.
//
{
	string	$fileRuleWidgets[] = np_getFileRuleWidgets("");

	int		$listSize;
	int		$index;

	$listSize = size($fileRuleWidgets);

	for ($index = 0; $index < $listSize; $index += 4)
	{
		string $name = "np_FileLocation" + $fileRuleWidgets[$index + 1];
		$name = substituteAllString($name, " ", "_");
		$name = substituteAllString($name, ".", "_");
		string $value = $fileRuleWidgets[$index + 2];
		textFieldGrp -e -fileName $value $name;
	}
}


global proc int np_createNewProjectCallback ( )
//
//	Description:
//		Create a new workspace and generate all of the
//		sub directories under it using the user defined defaults.
//
//	Returns true if the project was created OK.
//			false otherwise.
//
//	Notes:
//		This has the side effect of setting the workspace to the
//		newly created workspace.
//
{
	string $pathSep = ":";
	if (`about -nt`) {
		$pathSep = ";";
	}

	string $shortWSName; 
	string $wsLocation;
	string $wsRootDir;
	string $project;

	$shortWSName = `textFieldGrp -q -text ("np_wsName0")`;
	$wsLocation = `textFieldGrp -q -fileName ("wsLocation0")`;
//	$wsRootDir = `textFieldGrp -q -fileName ("wsRootDir0")`;

	int $locationSize = size($wsLocation);
	string $ok = (uiRes("m_projectSetup.kOk"));
	if ($shortWSName == "") {
		confirmDialog -message (uiRes("m_projectSetup.kNoProjectNameGiven")) 
			-button $ok -defaultButton $ok -parent newProjectWindow;
		return false;
	}	
	if ($locationSize <= 0) {
		confirmDialog -message (uiRes("m_projectSetup.kNoProjectLocationGiven")) 
			-button $ok -defaultButton $ok -parent newProjectWindow;
		return false;
	}	

	if (match("/$", $wsLocation) != "/") {
		$project = $wsLocation + "/" + $shortWSName;
	} else {
		$project = $wsLocation + $shortWSName;
	}

	string $message;
	string $displayMsg;
	// Verify that it doesn't exist.
	if (`file -q -ex ($project + "/workspace.mel")`) {
		// Then the project exists.
		$message = (uiRes("m_projectSetup.kProjectExist"));
		$displayMsg =`format -s $project $message`;
		confirmDialog -message $displayMsg 
			-button $ok -defaultButton $ok -parent newProjectWindow;
		return false;
	}

	workspace -cr $project;

	if (!(`file -q -ex $project`)) {
		$message = (uiRes("m_projectSetup.kProjectCreationFailed"));
		$displayMsg =`format -s $project $message`;
		confirmDialog -message $displayMsg 
			-button $ok -defaultButton $ok -parent newProjectWindow;
		return false;
	}	

	// Open the project
	//
	workspace -o $project;

	// Call the edit callback to set all the values and create
	// necessary directories
	//
	np_editProjectCallback();

	// Reset the prefs for the browser with project specific stuff.
	//
	np_resetBrowserPrefs;

	addRecentProject( $project );

	return true;
}

global proc int np_editProjectCallback ( )
//
//  Description:
//      Update the project setup using the user supplied information.
//
//  Note:
//      Old directories won't be removed because of the update however
//      they may become unused.
//
{
global string $gProjectSetupWorkspace;

	string $pathSep = ":";
	if (`about -nt`) {
		$pathSep = ";";
	}

	// Make sure we go to the project root directory before
	// creating any new directories.
	//
	string	$origDir = `workspace -q -dir`;
	workspace -dir `workspace -q -rd`;

	string	$fileRuleWidgets[];
	string	$fileRuleMap[];

	$fileRuleWidgets = np_getFileRuleWidgets($gProjectSetupWorkspace);
	$fileRuleMap     = np_getTranslatorWidgetMap();

    int     $index;
    int     $listSize;
	string	$locations[];

	$listSize = size($fileRuleWidgets);

	for ($index = 0; $index < $listSize; $index += 4)
	{
		string $frtype = $fileRuleWidgets[$index + 1];
		string $name  = "np_FileLocation" + $frtype;
		string $value;
		int $j, $found;

		$value = `textFieldGrp -q -fileName $name`;

		$found = 0;
		for ($j = 0; $j < size($fileRuleMap); $j += 2)
		{
			if ($frtype == $fileRuleMap[$j + 1])
			{
				$found = 1;
				workspace -fr $fileRuleMap[$j] $value;
			}
		}

		if (!$found)
		{
			workspace -fr $frtype $value;
		}

		if ($value != "")
		{
			if (tokenize($value, $pathSep, $locations) > 0)
			{
				workspace -cr $locations[0];
			}
		}
	}

	workspace -u;
    workspace -s;

	// Restore the original directory
	//
	workspace -dir $origDir;

	// If the browser is up then we must reset it.
	//

	if (`window -ex projectViewerWindow`) {
		pv_resetWorkspace;	// Force the layout to be redone.
	}

	return true;
}

proc np_showSetup ( string $wsFullName, string $parent, int $bUseDefaults, int $bEditable ) 
//
//	Description:
//		Display the setup information for either the specified workspace
//	 	or the preference defaults.
//
//	Parameters:
//		$wsFullName		- the full name of the workspace.
//		$parent			- the parent controlLayout.
//		$bUseDefaults	- Fill with defaults.
//		$bEditable		- if true then make the fields editable.
//
{
	string $np_wsRuleList = ("np_wsRuleList");
	string $itemList[];
	int $listSize;
	int $listSize2;
	int $index;
	int $index2;
	string $curTypeRules[];
	string $curObjectRules[];
	string $curRenderRules[];
	string $tmpString;			// Multi use string.
	int $bFound;
	string $curLocation;
	int $justFill;
	string $tfgName;
	int	$useWorkspace = $wsFullName != "";

	string $fileRuleWidgets[] = np_getFileRuleWidgets($wsFullName);

	if (`columnLayout -ex $np_wsRuleList`) {
		// The window is already filled in so just replace contents.
		$justFill = 1;
	} else {
		$justFill = 0;
	}
	
	setParent $parent;
	
	if( !$justFill ) {
		columnLayout -adj true $np_wsRuleList;
	}
	// All project directories
	
	if (!$justFill) {
		frameLayout -borderVisible true -borderStyle "etchedIn"
			-collapsable true -collapse false 
			-label (uiRes("m_projectSetup.kShowSetupProjLocLbl"))
			("ProjectDataLocations_Defaults_F");
		columnLayout ("ProjectDataLocations_Defaults_L");
	}

	$listSize = size($fileRuleWidgets);
	for ($index = 0; $index < $listSize; $index += 4)
	{
		string $label = $fileRuleWidgets[$index];
		string $name  = "np_FileLocation" + $fileRuleWidgets[$index + 1];
		$name = substituteAllString($name, " ", "_");
		$name = substituteAllString($name, ".", "_");
		string $value = $fileRuleWidgets[$index + 3];

		if ($justFill) {
			textFieldGrp -e -fileName $value $name;
		} else {
/* Modify for 	MAYA2010 NNExporter
			textFieldGrp -editable $bEditable -fileName $value -label $label $name;
*/

			textFieldGrp -editable $bEditable -fileName $value -label $label -cw2 250 250 $name;
		}
	}
	setParent $np_wsRuleList;
}

global proc int np_setNewLocation( string $path, string $type )
{
	string $wsLocationCtl = ("wsLocation0");

	// All we do on a successful browse is set the control in the
	// 'New Project' window - if user accepts this choice all the
	// workspace stuff will be set up at that point
	if ( `textFieldButtonGrp -ex $wsLocationCtl` )
	{
		textFieldButtonGrp -e -fi $path $wsLocationCtl;
		return true;
	}

	// If we got here, then the user may have either accepted the
	// new project settings from the New Project window, or cancelled
	// the New Project window. In either case, the following should
	// be valid:
	string $wsDir = `workspace -q -fn`;
	if ( `file -q -ex $wsDir` )
		workspace -dir $wsDir;

	return false;
}

global proc np_browseForNewLocation()
{
	string $wsDir;
	string $wsLocationCtl = ("wsLocation0");

	if ( `textFieldButtonGrp -ex $wsLocationCtl` )
	{
		$wsDir = `textFieldButtonGrp -q -fi $wsLocationCtl`;
		// Have to set the workspace dir so the fileBrowser knows
		// where to start looking
		if ( `file -q -ex $wsDir` )
			workspace -dir $wsDir;
	}

	string $selectLocation = (uiRes("m_projectSetup.kSelectLocation"));
	fileBrowser "np_setNewLocation" $selectLocation "" 4;
}

global proc np_setupNewInfo ( )
{
	string  $parent = "wsSetupInfo";

	string $wsLocationCtl = ("wsLocation0");
	string $np_wsNameCtl = ("np_wsName0");
	string $wsScrollCtl = ("wsScroll0");
	int $enabled = 1;
	
	button -e -enable $enabled acceptSetup;
	
	if (!`textFieldButtonGrp -ex $np_wsNameCtl`) {
		string $currentDir = "";
		// Check for environment variable first
		$currentDir = getenv("MAYA_PROJECTS_DIR");
		if(size($currentDir) == 0) {
			// Environment var is not set, so check for option var now
			if(`optionVar -ex "ProjectsDir"`) {
				$currentDir = `optionVar -q "ProjectsDir"`;
			}
			if(size($currentDir) == 0) {
				// Option var is not set too. Get the root directory of the current workspace
				$currentDir = dirname( `workspace -q -fn` );
			}
		}
		setParent $parent;
			textFieldButtonGrp -editable $enabled 
				-label (uiRes("m_projectSetup.kSetupNewInfoNameLbl"))
				-text (uiRes("m_projectSetup.kSetupNewInfoNameTxt"))
				-buttonLabel (uiRes("m_projectSetup.kSetupNewInfoHelpLbl"))
				-buttonCommand "showHelp NewProject"
				$np_wsNameCtl;
			textFieldButtonGrp -editable $enabled 
				-label (uiRes("m_projectSetup.kSetupNewInfoLocLbl"))
				-fileName $currentDir 
				-bl (uiRes("m_projectSetup.kSetupNewInfoBrowseLbl"))
				-bc np_browseForNewLocation $wsLocationCtl;
			scrollLayout -cr true $wsScrollCtl;
				np_showSetup ( "", $wsScrollCtl, 0, $enabled);

/* Modify for MAYA2010 NNExporter
		formLayout -e 
			-af $wsLocationCtl left 0 
			-af $wsLocationCtl right 0 
			-ac $wsLocationCtl top 0 $np_wsNameCtl
			-af $np_wsNameCtl left 0 
			-af $np_wsNameCtl right 0 
			-af $np_wsNameCtl top 5  
			-af $wsScrollCtl left 0 
			-af $wsScrollCtl right 0 
			-af $wsScrollCtl bottom 0 
			-ac $wsScrollCtl top 3 $wsLocationCtl  
				$parent;
*/
		formLayout -e
			-af $wsLocationCtl left 15
			-af $wsLocationCtl right 0
			-ac $wsLocationCtl top 0 $np_wsNameCtl
			-af $np_wsNameCtl left 15
			-af $np_wsNameCtl right 0
			-af $np_wsNameCtl top 5
			-af $wsScrollCtl left 0
			-af $wsScrollCtl right 0
			-af $wsScrollCtl bottom 0
			-ac $wsScrollCtl top 3 $wsLocationCtl
				$parent;
	}
}

global proc np_setupEditInfo ( )
{
	string  $parent = "wsSetupInfo";

	string $wsLocationCtl = ("wsLocation0");
	string $np_wsNameCtl = ("np_wsName0");
	string $wsScrollCtl = ("wsScroll0");
	
	button -e -enable 1 acceptSetup;
	
	if (!`textFieldGrp -ex $np_wsNameCtl`) {
		string $workspace = `workspace -q -fn`;		// Get the current WS name.
		string $wsLocation = dirname( $workspace );
		string $wsName = basename( $workspace, "" );

		setParent $parent;
			textFieldButtonGrp -label (uiRes("m_projectSetup.kSetupEditInfoNameLbl"))
				-editable false
				-text $wsName
				-buttonLabel (uiRes("m_projectSetup.kSetupEditInfoHelpLbl"))
				-buttonCommand "showHelp EditProject"
				$np_wsNameCtl;
			textFieldGrp -label (uiRes("m_projectSetup.kSetupEditInfoLocLbl"))
				-editable false 
				-fileName $wsLocation 
				$wsLocationCtl;

			scrollLayout -cr true $wsScrollCtl;
				np_showSetup ( $workspace, $wsScrollCtl, 0, 1);
		
		formLayout -e 
			-af $wsLocationCtl left 0 
			-af $wsLocationCtl right 0 
			-ac $wsLocationCtl top 0 $np_wsNameCtl
			-af $np_wsNameCtl left 0 
			-af $np_wsNameCtl right 0 
			-af $np_wsNameCtl top 5 
			-af $wsScrollCtl left 0 
			-af $wsScrollCtl right 0 
			-af $wsScrollCtl bottom 0 
			-ac $wsScrollCtl top 3 $wsLocationCtl
			$parent;
	}
}


global proc string np_displayWSSetup ( string $parent, int $mode )
//
//	Parameters:
//		$parent		- the parent control layout.
//		$mode		- 1 == new project
//					  2 == edit project.
//
{
	setParent $parent;		

	string $callback;

	if ($mode == 1) {
		$callback = "if (np_createNewProjectCallback()) deleteUI newProjectWindow;";
	} else if ($mode == 2) {
		$callback = "np_editProjectCallback;deleteUI newProjectWindow";
	}

	int $numDivisions = 100;
	formLayout -nd $numDivisions WSsetupForm;
		formLayout setupControlArea;
			button	-label (uiRes("m_projectSetup.kDisplayWSAcceptLbl"))
					-width 110 -c $callback acceptSetup;
			if ($mode == 1) {
				button	-label (uiRes("m_projectSetup.kDisplayWSDefaultsLbl"))
						-width 110 -c "np_resetDefaults" defaultSetup;
			}
			button	-label (uiRes("m_projectSetup.kDisplayWSCancelLbl"))
					-width 110 -c "deleteUI newProjectWindow;" cancelSetup;
			
			formLayout -e 
				-af acceptSetup "left" 5
				-af acceptSetup "bottom" 5
				-an acceptSetup "top"
				-af cancelSetup "bottom" 5
				-af cancelSetup "right" 5
				-an cancelSetup "top"
				setupControlArea;

			// Only have the "Use Defaults" button in "new" mode since the
			// user shouldn't be making radical changes to a created project.
			//
			if ($mode == 1) {
				formLayout -e 
					-ap acceptSetup "right" 0 33
					-af defaultSetup top 0 
					-ac defaultSetup left 5 acceptSetup
					-ap defaultSetup right 0 66
					-af defaultSetup bottom 5
					-ac cancelSetup "left" 5 defaultSetup
					setupControlArea;
			} else {
				formLayout -e 
					-ap acceptSetup "right" 3 50
					-ac cancelSetup "left" 5 acceptSetup
					setupControlArea;
			}

							
		setParent WSsetupForm;
		
		formLayout wsSetupInfo;
	
		formLayout -e -af wsSetupInfo top 0 -af wsSetupInfo left 0
						-af wsSetupInfo right 0
						-ac wsSetupInfo bottom 5 setupControlArea
						-af setupControlArea left 0 -af setupControlArea right 0
						-af setupControlArea bottom 0
						-an setupControlArea top
						WSsetupForm;
	
	if ($mode == 1) {
		np_setupNewInfo;	// Draw the first tab.
	} if ($mode == 2) {
		np_setupEditInfo;
	}
	
	return "WSsetupForm";
}

global proc projectSetup ( int $mode )
//
//	Description:
//		Edit a new project if $mode = 2.
//		Display a new project setup window if $mode = 1.
//		Display the defaults if $mode = 0.  - defunct
//
{
global string $gProjectSetupWorkspace;

	if (!`window -ex newProjectWindow`) {
/* Modify for MAYA2010 NNExporter
		window	-iconName (uiRes("m_projectSetup.kProjSetupWkSpcProjectLbl"))
				-wh 450 510 newProjectWindow;
*/
		window	-iconName (uiRes("m_projectSetup.kProjSetupWkSpcProjectLbl"))
				-wh 300 510 newProjectWindow;
			tabLayout -tv false windowLayout;
				columnLayout dummyTab;
	} else {
		// remove the children 
		string $childList[] = `tabLayout -q -ca windowLayout`;
		int $numChildren = size($childList);
		int $child;

		for ($child = 0; $child < $numChildren; $child++) {
			deleteUI $childList[$child];
		}

		setParent windowLayout;
		columnLayout dummyTab;	// Make the dummy display tab.
	}

	if ($mode == 2) {
		// remember the current workspace (we need it for editing)
		//
		$gProjectSetupWorkspace = `workspace -query -fullName`;
		window -e -title (uiRes("m_projectSetup.kProjSetupWkSpcEditProjectLbl")) 
				newProjectWindow;
		tabLayout -e -st dummyTab windowLayout;
		string $newTab = `np_displayWSSetup windowLayout $mode`;
		tabLayout -e -st $newTab windowLayout;
	} else if ($mode == 1) {
		// set the "current" workspace to nothing since there is none
		//
		$gProjectSetupWorkspace = "";
		window -e -title (uiRes("m_projectSetup.kProjSetupWkSpcNewProjectLbl")) 
				newProjectWindow;
		tabLayout -e -st dummyTab windowLayout;
		string $newTab = `np_displayWSSetup windowLayout $mode`;
		tabLayout -e -st $newTab windowLayout;
	}

	showWindow newProjectWindow;
}
