/******************************************************************************
	NINTENDO NITRO-System Maya Plugin

	File:         NNS_ShowBillboard.mel
	Description:  show billboard
	Date:         2004/11/29
	Author:       T.Endo

	Copyright 2003-2006 Nintendo. All rights reserved.
******************************************************************************/

/******************************************************************************
	show	
******************************************************************************/
global proc nnsShowBillboard_Show(int $billboard_show)
{
	int $node_count = 0;
	select -cl;
	string $xforms[] = `ls -typ transform`;
	for ($xform in $xforms) {
		int $billboard = (`attributeQuery -n $xform -ex "nns_billboard"`) ?
			`getAttr ($xform + ".nns_billboard")` : 0;
		if ($billboard == $billboard_show) {
			select -add $xform;
			++$node_count;
		}
	}

	if ($node_count == 0)
		print "Not found\n";
	else {
		string $msg = "Found: " + $node_count + " transform node";
		if ($node_count >= 2)
			$msg += "s";
		print ($msg + "\n");
	}
}

/******************************************************************************
	main
******************************************************************************/
global proc NNS_ShowBillboard()
{

//-----------------------------------------------------------------------------
// backup selection
	string $sel_bak[] = `ls -sl`;
	string $sel_bak_str;
	for ($sel in $sel_bak)
		$sel_bak_str += ($sel + " ");
	select -cl;
	
//-----------------------------------------------------------------------------
// create window
	int $wd = 400;
	int $ht = 140;
	if (!`window -exists nnsShowBillboard_Win`) {
		string $close_cmd = "deleteUI nnsShowBillboard_Win";
		string $remain_cmd = "if (!`checkBoxGrp -q -v1 nnsShowBillboard_KeepSelecion`) {"
			+ "select -cl;select -ne " + $sel_bak_str + ";}";

		window -t "NITRO Show Billboard" -wh $wd $ht -mxb 0
			nnsShowBillboard_Win;

		columnLayout -adj 1 -cat "both" 4 -cal "center" -rs 15;
			radioButtonGrp -nrb 2 -l ""
				-la2 "Billboard" "Y-Billboard"
				-cw 1 100
				-cc "nnsShowBillboard_Show(`radioButtonGrp -q -sl nnsShowBillboard_Billboard`)"
				nnsShowBillboard_Billboard;
			checkBoxGrp -ncb 1 -l "" -l1 "Keep Selection" -v1 1
				-cw 1 140
				nnsShowBillboard_KeepSelecion;
			button -h 26 -l "Close"
				-c ($remain_cmd + $close_cmd);
		setParent ..;	// columnLayout
	}
	window -e -wh $wd $ht nnsShowBillboard_Win;

//-----------------------------------------------------------------------------
// show window
	showWindow nnsShowBillboard_Win;
}
