// 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:  Aug 28, 1998
//
//
//  Description:
//      This implements the "Texture" submenu on the modeling menubar.
//

global proc
SubdRequestUVSetName (string $title, string $cmd, string $version, string $args[])
//
//	Procedure Name:
//		SubdRequestUVSetName
//
//	Description:
//		Helper method to ask the user for a new UV set name and then call
//	a command with the name as the final argument.  The command will be
//	called like: $cmd $version $args "uvSetName"
//
//  Input Arguments:
//		string $title			The title for the dialog box
//		string $cmd				The command to issue
//		string $version			Version to pass onto the command
//		string $args			Arguments to pass onto the command
//
//  Return Value:
//      None.
//
{
	string $ok		= (uiRes("m_SubdTextureMenu.kOK"));
	string $cancel	= (uiRes("m_SubdTextureMenu.kCancel"));
	string $response = `promptDialog
		-title $title
		-message (uiRes("m_SubdTextureMenu.kUVSetName")) 
		-text "uvSet"
		-button $ok 
		-button $cancel 
		-defaultButton $ok 
		-cancelButton $cancel 
		-dismissString $cancel`;
	if ($response == $ok) {
		string $name = `promptDialog -query -text`;
		string $execute = ($cmd + " \"" + $version + "\" {");
		string $comma = "";
		for ($arg in $args) {
			$execute += ($comma + "\"" + $arg + "\"");
			$comma = ", ";
		}
		$execute += ("} \"" + $name + "\"");
		eval ($execute);
	}
}

global proc SubdTextureMenu (string $parent, int $creator, string $selectCmd)
//
//	Procedure Name:
//		SubdTextureMenu
//
//	Description:
//		Helper method to generate the menu items for the texture menus
//
//  Input Arguments:
//		string $parent			The name of the parent widget
//		int $creator			Which creator is calling this
//			Current known creators
//				0	Edit Polygons->Textures
//				1	Relationship Editor->Edit->Create UV Set
//		string $selectCmd		The command to issue to determine which objects
//									to affect
//
//  Return Value:
//      None.
//
{
	setParent -m $parent;

//	string $prefix = ($creator == 0 ? "" : "SubdRequestUVSetName \"Create Planar Mapping\" ");
	string $prefix = ($creator == 0 ? "" : "SubdRequestUVSetName \"Create Planar Mapping\" ");
	string $cmd = $prefix + "performSubdProjectionArgList";
	string $version = "\"1\"";
	string $args0 = ("{\"0\", \"Planar\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $args1 = ("{\"1\", \"Planar\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $args2 = ("{\"2\", \"Planar\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $suffix = ($creator == 0 ? " \"\"" : "");

	string $dmc = "performSubdProjectionArgList \"1\" {\"2\", \"Planar\", \"ls -sl\", \"0\"} \"\";";
	string $c = ($cmd + " " + $version + " " + $args0 + $suffix);
	string $planarItem1 = (uiRes("m_SubdTextureMenu.kPlanarOption1"));
	string $planarItem2 = (uiRes("m_SubdTextureMenu.kPlanarOption2"));  
	menuItem
		-label ($creator == 1 ? $planarItem1 : $planarItem2)
		-ecr true 
		-i "polyPlanProj.xpm"
		-dmc $dmc 
		-annotation (uiRes("m_SubdTextureMenu.kCreatePlanarAnnot")) 
		-c $c planarMappingItem;
	string $c = ($cmd + " " + $version + " " + $args1 + $suffix);
	menuItem -optionBox 1  
		-i "polyPlanProj.xpm"
		-annotation (uiRes("m_SubdTextureMenu.kPlanarMappingOptionsAnnot"))  
		-ecr false -c $c planarMappingOptionItem;	
/*	
	string $prefix = ($creator == 0 ? "" : "SubdRequestUVSetName \"Create Cylindrical Mapping\" ");
	string $cmd = $prefix + "performPolyProjectionArgList";
	string $version = "\"1\"";
	string $args0 = ("{\"0\", \"Cylindrical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $args1 = ("{\"1\", \"Cylindrical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $args2 = ("{\"2\", \"Cylindrical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $suffix = ($creator == 0 ? " \"\"" : "");
	string $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Cylindrical\", \"ls -sl\", \"0\"} \"\";";
	string $c = ($cmd + " " + $version + " " + $args0 + $suffix);
	string $cylindricalItem1 = (uiRes("m_SubdTextureMenu.kCylindricalItem1"));
	string $cylindricalItem2 = (uiRes("m_SubdTextureMenu.kCylindricalItem2"));
	menuItem
		-label ($creator == 1 ? $cylindricalItem1 : $cylindricalItem2)
		-ecr true 
		-i "polyCylProj.xpm"
		-dmc $dmc 
		-annotation (uiRes("m_SubdTextureMenu.kCreateCylindricalProjectionAnnot")) 
		-c $c cylindricMappingItem;
	string $c = ($cmd + " " + $version + " " + $args1 + $suffix);
	menuItem -optionBox 1 
		-i "polyCylProj.xpm"
		-annotation (uiRes("m_SubdTextureMenu.kCylindricalMappingOptionsAnnot"))  
		-ecr false -c $c cylindricMappingOptionItem;
	
	string $prefix = ($creator == 0 ? "" : "SubdRequestUVSetName \"Create Spherical Mapping\" ");
	string $cmd = $prefix + "performPolyProjectionArgList";
	string $version = "\"1\"";
	string $args0 = ("{\"0\", \"Spherical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $args1 = ("{\"1\", \"Spherical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $args2 = ("{\"2\", \"Spherical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}");
	string $suffix = ($creator == 0 ? " \"\"" : "");
	string $c = ($cmd + " " + $version + " " + $args0 + $suffix);
	string $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Spherical\", \"ls -sl\", \"0\"} \"\";";
	string $spericalItem1 = (uiRes("m_SubdTextureMenu.kSpericalItem1"));
	string $spericalItem2 = (uiRes("m_SubdTextureMenu.kSpericalItem2"));
	menuItem
		-label ($creator == 1 ? $spericalItem1 : $spericalItem2)
		-ecr true 
		-i "polySphereProj.xpm"
		-dmc $dmc
		-annotation (uiRes("m_SubdTextureMenu.kCreateSphericProjectionAnnot")) 
		-c $c sphericMappingItem;
	string $c = ($cmd + " " + $version + " " + $args1 + $suffix);
	menuItem -ob 1 
		-i "polySphereProj.xpm"
		-annotation (uiRes("m_SubdTextureMenu.kSphericalMappingOptionsAnnot"))  
		-ecr false -c $c sphericMappingOptionItem;

	//////////////////////////////////////////////////////////////////////
	menuItem -divider true;

	if ($creator != 1) {
		menuItem -label (uiRes("m_SubdTextureMenu.kMapUVBorder"))   -ecr true
			-i "polyMapUVBorder.xpm"
			-annotation (uiRes("m_SubdTextureMenu.kMapTextureAnnot")) 
			-ddc "performPolyUntangleUV map 1"
			-dmc "performPolyUntangleUV map 2"
			-c	 "MapUVBorder" mapUVBorderItem;
		menuItem -optionBox 1 -i "polyMapUVBorder.xpm" 
				-annotation (uiRes("m_SubdTextureMenu.kMapUVBorderOptionsAnnot"))  
				-ecr false 
				-c "performPolyUntangleUV map 1" mapUVBorderOptionItem;

		menuItem -label (uiRes("m_SubdTextureMenu.kRelaxUVs"))   -ecr true
			-i "polyRelaxUVShell.xpm"
			-annotation (uiRes("m_SubdTextureMenu.kRelaxSelectedUVsAnnot")) 
			-ddc "performPolyUntangleUV relax 1"
			-dmc "performPolyUntangleUV relax 2"
			-c	 "RelaxUVShell" relaxUVShellItem;
		menuItem -optionBox 1 -i "polyRelaxUVShell.xpm" 
			-annotation (uiRes("m_SubdTextureMenu.kRelaxUVsOptionsAnnot"))  
			-ecr false 
			-c "performPolyUntangleUV relax 1" relaxUVShellOptionItem;

	}
*/

	menuItem -label (uiRes("m_SubdTextureMenu.kAutomaticMapping")) 
		-annotation (uiRes("m_SubdTextureMenu.kSelectFacesAnnot")) 
		-c "performSubdAutoProj 0" -i "polyAutoProj.xpm" ;
	menuItem -optionBox 1
		-annotation (uiRes("m_SubdTextureMenu.kAutomaticProjectionAnnot")) 
		-c "performSubdAutoProj 1" -ecr false -i "polyAutoProj.xpm";

	//////////////////////////////////////////////////////////////////////
	if ($creator != 1) {
		// menuItem -divider true;


		menuItem -label (uiRes("m_SubdTextureMenu.kLayoutUVs")) 
			-annotation (uiRes("m_SubdTextureMenu.kSelectFacesUVAnnot")) 
			-c "performSubdLayoutUV 0" -i "polyLayoutUV.xpm";
		menuItem -optionBox 1
			-annotation (uiRes("m_SubdTextureMenu.kLayoutUVsOptionsAnnot")) 
			-c "performSubdLayoutUV 1" -ecr false -i "polyLayoutUV.xpm";
	}
}
