// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: 2 May 2005 // // // // // // uiRes(string $lookUpKey) // // // Lookup the given resource ID, $lookThisUp, in the // MEL resource catalog. The MEL resource catalog is // built up from a series of displayString // commands that associate each resource ID "key" // with a value. // // Lookup keys must be unique. They are formed like // this: // // [prefix_]stringSetName.resourceName // // where "prefix" is an optional single character origin // code, joined to the stringSetName by an underscore. Maya // follows the convention: // // "m" for MEL files // "n" for node/attribute names // "s" for command message strings // "p" for plug-in strings // // The "resource name" is a string identifier that // describes the look-up value. The "string set" name // refers to the origin of the resource. // // // string $lookUpKey Unique key ID for catalog lookup // // // string: the key's lookup value // // // // Query the value of the "kBakeSimulation" resource, // // found in the Edit menu. The resource name is // // "kBakeSimulation", the string set name is the name // // of the MEL file the resource comes from (without the // // .mel extension: buildEditMenu), and the prefix for MEL // // resources is "m_". // // // uiRes( "m_buildEditMenu.kBakeSimulation" ); // // Result: Bake Simulation // // // global proc string uiRes( string $lookUpKey ) { // If not found in the catalog, bring in the resources by // sourcing the appropriate res.mel file, dictated by the // naming convention. // if( !`displayString -exists $lookUpKey` ) { string $buffer[]; tokenize $lookUpKey "." $buffer; // Only one "." between string set and resource id. // if( size( $buffer ) != 2 ) { string $fmt = (uiRes("m_uiRes.kKey")); warning( `format -s $lookUpKey $fmt` ); } else { string $file = $buffer[0]; string $prefixSep; // If there's room, pick off the first two characters // if( size( $file ) >= 2 ) { $prefixSep = `substring $file 1 2`; } // MEL resources require special handling. The resources // have to be exposed first by sourcing the appropriate // .mel.res file. // if( $prefixSep == "m_" ) { $file = `substring $file 3 (size($file))`; $file += ".res.mel"; // Catch this call because if the file doesn't exist, we'll // stop executing this script, and we'd really really rather see // the error message from the displayString cmd below, to let // us know the details about the specific key that couldn't be // found. // catch( initResources( $file ) ); } } } return `displayString -q -value $lookUpKey`; }