Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //EDIT by ALPHATT - functional maya 2013-x64
- // Copyright (C) 1997-2011 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.
- //
- // Creation Date: Nov 17 1996
- //
- // Procedure Name:
- // FileMenu
- //
- // Description:
- // This procedure creates the main menubar File menu.
- //
- // Input Arguments:
- // None
- //
- // Return Value:
- // None.
- //
- global proc forceSavePreferences()
- // Removed for Maya 3.0 but could still be on people's shelves
- {
- warning (uiRes("m_FileMenu.kForceSavePrefs"));
- }
- global proc FileMenu_SaveItem()
- //
- // If the current file is named, save it. If it
- // is still untitled, then bring up the Save As
- // dialog.
- //
- {
- string $sceneName = `file -q -sceneName`;
- // Get the name of the scene File.
- if ( size($sceneName) == 0 ) {
- // Then the name can't be set.
- projectViewer SaveAs;
- // bug fix 89970 file save
- } else if ((`file -q -amf`) || (`file -q -ex` == 0)) {
- int $incrementalSave = false;
- if(`optionVar -exists isIncrementalSaveEnabled`)
- $incrementalSave = `optionVar -q isIncrementalSaveEnabled`;
- if ( $incrementalSave ) {
- // Save the scene using the Incremental Save feature.
- //
- incrementalSaveScene;
- } else {
- string $compressedSave = 0;
- string $preserveName = 0;
- string $cmd = "file -save";
- if(`optionVar -exists isCompressedSaveEnabled`)
- $compressedSave = `optionVar -q isCompressedSaveEnabled`;
- if ($compressedSave == 1 )
- {
- $cmd = $cmd + " -compress";
- }
- if(`optionVar -exists isCompressedPreserveName`)
- $preserveName = `optionVar -q isCompressedPreserveName`;
- if ($preserveName == 1 )
- {
- $cmd = $cmd + " -preserveName";
- }
- evalEcho($cmd);
- }
- } else {
- warning (uiRes("m_FileMenu.kNoChangesToSave"));
- }
- }
- global proc buildRecentProjectsMenu()
- {
- string $RecentProjectsList[];
- string $localList[];
- int $i;
- int $nNumItems;
- int $nNumItemsToBeRemoved;
- int $RecentProjectsMaxSize;
- if (!`optionVar -exists "RecentProjectsList"`) return;
- // get the list
- $RecentProjectsList = `optionVar -query "RecentProjectsList"`;
- $nNumItems = size($RecentProjectsList);
- $RecentProjectsMaxSize = `optionVar -query "RecentProjectsMaxSize"`;
- // check if there are too many items in the list
- if ($RecentProjectsMaxSize < $nNumItems)
- {
- //if so, truncate the list
- $nNumItemsToBeRemoved = $nNumItems - $RecentProjectsMaxSize;
- //Begin removing items from the head of the array (least recent project in the list)
- for ($i = 0; $i < $nNumItemsToBeRemoved; $i++)
- {
- optionVar -removeFromArray "RecentProjectsList" 0;
- }
- $RecentProjectsList = `optionVar -query "RecentProjectsList"`;
- $nNumItems = size($RecentProjectsList);
- }
- // first, check if we are the same.
- $localList = `menu -query -itemArray FileMenuRecentProjectItems`;
- if ($nNumItems == size($localList))
- {
- for ($i = 0; $i < $nNumItems; $i++)
- {
- string $label = `menuItem -query -label $localList[$i]`;
- if ($label != toNativePath($RecentProjectsList[$nNumItems-$i-1]))
- break;
- }
- if ($i == $nNumItems) return;
- }
- // we are not the same, so start over.
- menu -edit -deleteAllItems FileMenuRecentProjectItems;
- setParent -menu FileMenuRecentProjectItems;
- for ($i = 0; $i < $nNumItems; $i++)
- {
- string $cmd = "setProject \"" + $RecentProjectsList[$nNumItems-$i-1] + "\"";
- string $label = toNativePath($RecentProjectsList[$nNumItems-$i-1]);
- menuItem -label $label -command $cmd;
- }
- }
- global proc openRecentFile( string $file, string $fileType )
- {
- global string $gv_operationMode;
- $gv_operationMode = "Open";
- pv_performAction($file, $fileType);
- checkForUnknownNodes();
- }
- global proc buildRecentFileMenu(string $parentMenu)
- {
- string $RecentFilesList[];
- string $RecentFilesTypeList[];
- string $localList[];
- int $i;
- int $nNumItems;
- int $nNumItemsToBeRemoved;
- int $RecentFilesMaxSize;
- if (!`optionVar -exists "RecentFilesList"`) return;
- // get the list
- $RecentFilesList = `optionVar -query "RecentFilesList"`;
- $nNumItems = size($RecentFilesList);
- $RecentFilesMaxSize = `optionVar -query "RecentFilesMaxSize"`;
- // check if there are too many items in the list
- if ($RecentFilesMaxSize < $nNumItems)
- {
- //if so, truncate the list
- $nNumItemsToBeRemoved = $nNumItems - $RecentFilesMaxSize;
- //Begin removing items from the head of the array (least recent file in the list)
- for ($i = 0; $i < $nNumItemsToBeRemoved; $i++)
- {
- optionVar -removeFromArray "RecentFilesList" 0;
- }
- $RecentFilesList = `optionVar -query "RecentFilesList"`;
- $nNumItems = size($RecentFilesList);
- }
- // The RecentFilesTypeList optionVar may not exist since it was
- // added after the RecentFilesList optionVar. If it doesn't exist,
- // we create it and initialize it with a guest at the file type
- if ($nNumItems > 0 )
- {
- if ( !`optionVar -exists "RecentFilesTypeList"`)
- {
- initRecentFilesTypeList( $RecentFilesList );
- }
- $RecentFilesTypeList = `optionVar -query "RecentFilesTypeList"`;
- }
- // first, check if we are the same.
- $localList = `menu -query -itemArray $parentMenu`;
- if ($nNumItems == size($localList))
- {
- for ($i = 0; $i < $nNumItems; $i++)
- {
- string $label = `menuItem -query -label $localList[$i]`;
- if ($label != toNativePath($RecentFilesList[$nNumItems-$i-1]))
- break;
- }
- if ($i == $nNumItems) return;
- }
- // we are not the same, so start over.
- menu -edit -deleteAllItems $parentMenu;
- setParent -menu $parentMenu;
- for ($i = 0; $i < $nNumItems; $i++)
- {
- string $cmd = ( "openRecentFile(\"" + $RecentFilesList[$nNumItems-$i-1] + "\", " +
- "\"" + $RecentFilesTypeList[$nNumItems-$i-1] + "\")" );
- string $label = toNativePath($RecentFilesList[$nNumItems-$i-1]);
- menuItem -label $label -command $cmd;
- }
- }
- //
- // Procedure Name:
- // buildIncrementalSaveMenu
- //
- // Description:
- // Build the sub menu in the file menu that lists the recent incremental
- // backups that exist for the current scene
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- global proc buildIncrementalSaveMenu()
- {
- string $scenePath = `file -q -sceneName`;
- if ( size( $scenePath ) == 0 ) return;
- string $pathInfo[] = incrementalSaveProcessPath( $scenePath );
- string $scenePath = $pathInfo[0];
- string $sceneExtension = $pathInfo[2];
- string $sceneNamePrefix = $pathInfo[3];
- string $incrementDirName = $pathInfo[5] + "/";
- string $incrementDirPath = $scenePath + $incrementDirName;
- // Get a list of all files in the backup directory
- //
- string $existingIncrements[] = `getFileList
- -folder $incrementDirPath
- -filespec ($sceneNamePrefix + ".*" + $sceneExtension)`;
- // Make sure that they are sorted
- //
- $existingIncrements = sort( $existingIncrements );
- int $numIncrementals = `optionVar -q "RecentBackupsMaxSize"`;
- // Build the menu
- //
- int $last = size( $existingIncrements );
- int $first = max( 0, $last - $numIncrementals );
- menu -e -deleteAllItems FileMenuRecentBackupItems;
- setParent -menu FileMenuRecentBackupItems;
- for ( $i = $first; $i < $last; $i++ ) {
- string $cmd = "file -f -open \"" + $incrementDirPath + $existingIncrements[$i] + "\"";
- string $sceneName = `match "[^/]+$" $existingIncrements[$i]`;
- menuItem -l $sceneName -c $cmd;
- }
- }
- //
- // Procedure Name:
- // hasIncrementalSaves
- //
- // Description:
- // Returns true if the current file has some automatic backups
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- global proc int hasIncrementalSaves()
- {
- int $result = 0;
- string $scenePath = `file -q -sceneName`;
- if ( size( $scenePath ) > 0 ) {
- string $pathInfo[] = incrementalSaveProcessPath( $scenePath );
- string $scenePath = $pathInfo[0];
- string $sceneExtension = $pathInfo[2];
- string $sceneNamePrefix = $pathInfo[3];
- string $incrementDirName = $pathInfo[5] + "/";
- string $incrementDirPath = $scenePath + $incrementDirName;
- // Get a list of all files in the backup directory
- //
- string $existingIncrements[] = `getFileList
- -folder $incrementDirPath
- -filespec ($sceneNamePrefix + ".*" + $sceneExtension)`;
- $result = ( size( $existingIncrements ) > 0 );
- }
- return $result;
- }
- //
- // Procedure Name:
- // checkMainFileMenu
- //
- // Description:
- // Disables or enables the recent files, backups, and projects
- // menus depending on whether they have contents.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- global proc checkMainFileMenu()
- {
- $enable = false;
- if (`optionVar -exists "RecentFilesList"`)
- {
- if (`optionVar -arraySize "RecentFilesList"` > 0) $enable = 1;
- }
- menuItem -e -enable $enable FileMenuRecentFileItems;
- $enable = hasIncrementalSaves();
- menuItem -e -enable $enable FileMenuRecentBackupItems;
- $enable = false;
- if (`optionVar -exists "RecentProjectsList"`)
- {
- if (`optionVar -arraySize "RecentProjectsList"` > 0) {
- $enable = true;
- }
- }
- menuItem -e -enable $enable FileMenuRecentProjectItems;
- // Create "Send To" menu items for one-click
- // interop with available applications.
- //
- buildSendToSubMenus;
- }
- global proc buildFileMenu()
- {
- global string $gMainFileMenu;
- if( `menu -q -ni $gMainFileMenu` != 0 ) {
- //
- // Menu is built already - just return
- //
- return;
- }
- menu -e -postMenuCommand checkMainFileMenu $gMainFileMenu;
- int $dimWhenNoSelect = 0;
- setParent -m $gMainFileMenu;
- menuItem -label (uiRes("m_FileMenu.kNewScene"))
- -annotation (getRunTimeCommandAnnotation("NewScene" ))
- -command ("NewScene") newProject;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("NewSceneOptions"))
- -command ("NewSceneOptions")
- newFileOptions;
- menuItem -label (uiRes("m_FileMenu.kOpenScene"))
- -annotation (getRunTimeCommandAnnotation("OpenScene"))
- -command ("OpenScene") openProject;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("OpenSceneOptions"))
- -command ("OpenSceneOptions")
- openFileOptions;
- menuItem -divider true;
- menuItem -label (uiRes("m_FileMenu.kSave"))
- -annotation (getRunTimeCommandAnnotation("SaveScene"))
- -command ("SaveScene") saveItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("SaveSceneOptions"))
- -command ("SaveSceneOptions")
- saveOptions;
- menuItem -l (uiRes("m_FileMenu.kSaveAs"))
- -annotation (getRunTimeCommandAnnotation("SaveSceneAs"))
- -command ("SaveSceneAs") saveAsItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("SaveSceneAsOptions"))
- -command ("SaveSceneAsOptions")
- saveAsOptions;
- menuItem -label (uiRes("m_FileMenu.kArchive"))
- -annotation (getRunTimeCommandAnnotation("ArchiveScene"))
- -command ("ArchiveScene") archiveItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("ArchiveSceneOptions"))
- -command ("ArchiveSceneOptions")
- archiveSceneOptions;
- menuItem -ecr false -label (uiRes("m_FileMenu.kSavePrefs"))
- -annotation (getRunTimeCommandAnnotation("SavePreferences"))
- -command ("SavePreferences");
- menuItem -divider true;
- menuItem -l (uiRes("m_FileMenu.kOptimize"))
- -annotation (getRunTimeCommandAnnotation("OptimizeScene"))
- -command ("OptimizeScene") cleanUpProject;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("OptimizeSceneOptions"))
- -command ("OptimizeSceneOptions")
- cleanUpSceneOptions;
- menuItem -divider true;
- menuItem -label (uiRes("m_FileMenu.kImport"))
- -annotation (getRunTimeCommandAnnotation("Import"))
- -command ("Import") importFileItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("ImportOptions"))
- -command ("ImportOptions")
- importFileOptions;
- menuItem -label (uiRes("m_FileMenu.kExportAll"))
- -annotation (getRunTimeCommandAnnotation("Export"))
- -command ("Export") exportAllFileItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("ExportOptions"))
- -command ("ExportOptions")
- exportAllFileOptions;
- menuItem -label (uiRes("m_FileMenu.kExportSelection"))
- -annotation (getRunTimeCommandAnnotation("ExportSelection"))
- -command ("ExportSelection") exportActiveFileItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("ExportSelectionOptions"))
- -command ("ExportSelectionOptions")
- exportActiveFileOptions;
- if( $dimWhenNoSelect )
- dimWhen -false SomethingSelected exportActiveFileItem;
- menuItem -divider true;
- menuItem -label (uiRes("m_FileMenu.kExportOfflineFile"))
- -annotation (getRunTimeCommandAnnotation("ExportOfflineFile"))
- -command ("ExportOfflineFile") exportEditsFileItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("ExportOfflineFileOptions"))
- -command ("ExportOfflineFileOptions")
- exportEditsFileOptions;
- if( $dimWhenNoSelect )
- dimWhen -false SomethingSelected exportEditsFileItem;
- menuItem -label (uiRes("m_FileMenu.kAssignOfflineFile"))
- -annotation (getRunTimeCommandAnnotation("AssignOfflineFile"))
- -command ("AssignOfflineFile") assignOfflineFileItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("AssignOfflineFileOptions"))
- -command ("AssignOfflineFileOptions")
- assignOfflineFileOptions;
- if( $dimWhenNoSelect )
- dimWhen -false SomethingSelected assignOfflineFileItem;
- menuItem -divider true;
- menuItem -label (uiRes("m_FileMenu.kViewImage"))
- -annotation (getRunTimeCommandAnnotation ("ViewImage"))
- -command ("ViewImage")
- viewFrameItem;
- menuItem -label (uiRes("m_FileMenu.kViewSequence"))
- -annotation (getRunTimeCommandAnnotation ("ViewSequence"))
- -command ("ViewSequence")
- viewSequenceItem;
- menuItem -divider true;
- menuItem -label (uiRes("m_FileMenu.kCreateReference"))
- -annotation (getRunTimeCommandAnnotation("CreateReference"))
- -command ("CreateReference") referenceFileItem;
- menuItem -optionBox true
- -annotation (getRunTimeCommandAnnotation("CreateReferenceOptions"))
- -command ("CreateReferenceOptions")
- referenceFileOptions;
- menuItem -label (uiRes("m_FileMenu.kReferenceEditor"))
- -annotation (getRunTimeCommandAnnotation("ReferenceEditor"))
- -command ("ReferenceEditor")
- residentFileItem;
- menuItem -divider true;
- menuItem -label "Export SMD..."
- -annotation "Export SMD: Save SMD associated with this file"
- -command ("smdExportMenuItem")
- smdExportMenu;
- menuItem -optionBox true
- -annotation "SMD Option Box"
- -label "SMD Option Box"
- -command ("smdOptionWindow")
- smdExportOptions;
- menuItem -label "Export VTA..."
- -annotation "Emport VTA: emport VTA format file"
- -command ("vtaExport")
- vtaExport;
- menuItem -label "Import SMD..."
- -annotation "Import SMD: import SMD format file"
- -command ("smdImport")
- smdImport;
- menuItem -label "Import SMD Animation"
- -annotation "Import SMD: import SMD format file"
- -command ("smdImportani")
- smdImportani;
- menuItem -label "Import From Hammer..."
- -annotation "Import From Hammer: import DXF exported by Hammer"
- -command ("wcImport")
- wcImport;
- menuItem -label "Compile QC File"
- -annotation "Compile QC: run studiomdl on the QC file for current project"
- -command ("compileQCFile")
- qcFileExportMenu;
- // menuItem -label "SourceSafe"
- // -annotation "SourceSafe: check file in and out of VSS"
- // -command ("if (`vssStatus`){print `vss -f -i`;} else {print `vss -f -o`;}vssStatus;")
- // -cb 0
- // vssMenuItem;
- menuItem -divider true;
- menuItem -label (uiRes("m_FileMenu.kProjectWindow"))
- -annotation (getRunTimeCommandAnnotation("ProjectWindow"))
- -command ("ProjectWindow") projectWindowFileItem;
- menuItem -label (uiRes("m_FileMenu.kSet"))
- -annotation (getRunTimeCommandAnnotation("SetProject"))
- -command ("SetProject") setProjectFileItem;
- // add recent file and project lists
- menuItem -subMenu true -l (uiRes("m_FileMenu.kRecentFiles"))
- -postMenuCommand "buildRecentFileMenu FileMenuRecentFileItems" FileMenuRecentFileItems;
- setParent -m ..;
- menuItem -subMenu true -l (uiRes("m_FileMenu.kRecentIncrements"))
- -postMenuCommand "buildIncrementalSaveMenu" FileMenuRecentBackupItems;
- setParent -m ..;
- menuItem -subMenu true -l (uiRes("m_FileMenu.kRecentProjects"))
- -postMenuCommand "buildRecentProjectsMenu" FileMenuRecentProjectItems;
- setParent -m ..;
- if (!`about -mac`) {
- menuItem -divider true;
- // Do not add any other code to the quit or you will not
- // have it executed for some types of quitting - like
- // quitting through the command language or by double-clicking
- // the main Maya window.
- //
- menuItem -l (uiRes("m_FileMenu.kExit"))
- -annotation (uiRes("m_FileMenu.kExitAnnot"))
- -command ("Quit") quitItem;
- if (`about -nt`)
- {
- menuItem -e -mn "O" openProject;
- menuItem -e -mn "S" saveItem;
- menuItem -e -mn "A" saveAsItem;
- menuItem -e -mn "x" quitItem;
- }
- }
- checkMainFileMenu();
- }
- // OneClick selection setting options
- //
- global proc int oneClickDefaultSendPreviousSelection()
- {
- global int $gOneClickDefaultSendPreviousSelection = 0;
- return $gOneClickDefaultSendPreviousSelection;
- }
- global proc int oneClickDefaultSendEntireScene()
- {
- global int $gOneClickDefaultSendEntireScene = 0;
- return $gOneClickDefaultSendEntireScene;
- }
- {
- global string $gMainFileMenu;
- global string $gMainWindow;
- menu -p $gMainWindow -l (uiRes("m_FileMenu.kFile"))
- -allowOptionBoxes true -tearOff true
- -postMenuCommand "buildFileMenu();"
- -familyImage "menuIconFile.png" $gMainFileMenu;
- setParent -m ..;
- }
Advertisement
Add Comment
Please, Sign In to add comment