// =========================================================================== // 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: Nov 25 1998 // // Description: // Supports the help menus. // Initializes context sensitive help. // Supports popup help. // { source "ContextHelp.mel"; help -popupMode `optionVar -q popUpHelpMode`; help -popupSimpleMode `optionVar -q popUpSimpleHelpMode`; help -rolloverMode on; } global proc helpLocationErrorDialogDismissCmd(int $isDismissYes, string $showHelpCmd) { global string $gMayaVersionYear; string $dismissString; if($isDismissYes) { $dismissString = `button -q -l yesBtn`; //save previous help mode pref string $helpModeOld = `optionVar -q helpMode`; //override help mode pref and display the help using Installed Local Help optionVar -sv "helpMode" "Installed Local Help"; eval($showHelpCmd); if(!`checkBox -q -value setInstalledLocalHelpCb`) { //restore old prefs since we did not set the preference //to use the Installed Local Help optionVar -sv "helpMode" $helpModeOld; } } else { $dismissString = `button -q -l noBtn`; if(`checkBox -q -value setInstalledLocalHelpCb`) { //set the help mode preference to use Installed Local Help optionVar -sv "helpMode" "Installed Local Help"; } } layoutDialog -dismiss $dismissString; } proc string cannotConnectString() { return (uiRes("m_initHelp.kCannotConnect")); } proc string canInstallHelpFromString() { return (uiRes("m_initHelp.kCanInstallFrom")); } proc string canUseWebHelpString() { return (uiRes("m_initHelp.kCanUseWebHelp")); } proc string checkBoxSetAdskWebSitePref() { string $setAdskWebSite = (uiRes("m_initHelp.kSetAdskWebSite")); string $cb2= `checkBox -l $setAdskWebSite -onc "optionVar -sv \"helpMode\" \"Autodesk Web Site\"" -ofc "optionVar -sv \"helpMode\" \"Installed Local Help\"" setAdskWebSiteCb`; if (`optionVar -q helpMode` == "Custom") { $cb2= `checkBox -e -ofc "optionVar -sv \"helpMode\" \"Custom\"" setAdskWebSiteCb`; } return $cb2; } proc string helpDownloadUrlString() { global string $gAvailableLanguages[]; string $helpDownloadUrl=`text -al "left" -l ""`; string $selectedLanguage = `optionVar -q helpLanguage`; for ($language in $gAvailableLanguages) { string $a[]; tokenize $language ":" $a; if($selectedLanguage == $a[0]) { string $href = "http://www.autodesk.com/maya-helpdownload-" + $a[2] + ""; $helpDownloadUrl = `text -al "left" -l $href -hl true`; } } return $helpDownloadUrl; } global proc createNoConnectionNoLocalHelpPrompt(string $showHelpCmd) { string $form = `setParent -q`; formLayout -e -width 300 $form; int $spacer = 10; int $top = 20; int $edge = 20; string $cannotConnect = cannotConnectString(); string $canInstallHelpFrom = canInstallHelpFromString(); string $helpDownloadUrl = helpDownloadUrlString(); string $warnFormat = "^1s\n\n^2s"; string $warnText = `format -stringArg $cannotConnect -stringArg $canInstallHelpFrom $warnFormat`; $warnText = `text -al "left" -l $warnText`; string $t1 = `text -al "left" -l ((uiRes("m_initHelp.kMustBeConnected")))`; formLayout -edit -attachForm $warnText "top" $top -attachForm $warnText "left" $edge -attachNone $warnText "bottom" -attachForm $warnText "right" $edge -attachControl $helpDownloadUrl "top" $spacer $warnText -attachForm $helpDownloadUrl "left" $edge -attachNone $helpDownloadUrl "bottom" -attachForm $helpDownloadUrl "right" $edge -attachControl $t1 "top" $spacer $helpDownloadUrl -attachForm $t1 "left" $edge -attachForm $t1 "bottom" $edge -attachForm $t1 "right" $edge $form; } global proc createNoConnectionLocalHelpAvailablePrompt(string $showHelpCmd) { string $form = `setParent -q`; formLayout -e -width 300 $form; int $spacer = 10; int $top = 20; int $edge = 20; string $cannotConnect = cannotConnectString(); string $t1 = (uiRes("m_initHelp.kWantLocalHelp")); string $warnFormat = "^1s\n\n^2s"; string $warnText = `format -stringArg $cannotConnect -stringArg $t1 $warnFormat`; $warnText = `text -al "left" -l $warnText`; string $t2= `text -al "left" -l (uiRes("m_initHelp.kWantLocalHelpCont"))`; string $b1 = `button -l (uiRes("m_initHelp.kYes")) -c("helpLocationErrorDialogDismissCmd 1 \"" + $showHelpCmd + "\"") yesBtn`; string $b2 = `button -l (uiRes("m_initHelp.kNo")) -c ("helpLocationErrorDialogDismissCmd 0 \"" + $showHelpCmd + "\"") noBtn`; string $cb1= `checkBox -l (uiRes("m_initHelp.kSetHelpPrefLocal")) setInstalledLocalHelpCb`; formLayout -edit -attachForm $warnText "top" $top -attachForm $warnText "left" $edge -attachNone $warnText "bottom" -attachForm $warnText "right" $edge -attachControl $b1 "top" $spacer $warnText -attachForm $b1 "left" $edge -attachNone $b1 "bottom" -attachNone $b1 "right" -attachControl $b2 "top" $spacer $warnText -attachControl $b2 "left" $spacer $b1 -attachNone $b2 "bottom" -attachNone $b2 "right" -attachControl $t2 "top" $spacer $b1 -attachForm $t2 "left" $edge -attachNone $t2 "bottom" -attachForm $t2 "right" $edge -attachControl $cb1 "top" $spacer $t2 -attachForm $cb1 "left" $edge -attachForm $cb1 "bottom" $edge -attachForm $cb1 "right" $edge $form; } global proc createNoLocalHelpInDefaultLanguagePrompt(string $showHelpCmd) { string $form = `setParent -q`; formLayout -e -width 300 $form; int $spacer = 10; int $top = 20; int $edge = 20; string $canInstallHelpFrom = canInstallHelpFromString(); string $helpDownloadUrl = helpDownloadUrlString(); string $canUseWebHelp = canUseWebHelpString(); string $cb2 = checkBoxSetAdskWebSitePref(); string $t1 = (uiRes("m_initHelp.kNoInstalledLocalHelp")); string $warnFormat = "^1s\n\n^2s"; string $warnText = `format -stringArg $t1 -stringArg $canInstallHelpFrom $warnFormat`; $warnText = `text -al "left" -l $warnText`; $t1 = `text -al "left" -l $canUseWebHelp`; formLayout -edit -attachForm $warnText "top" $top -attachForm $warnText "left" $edge -attachNone $warnText "bottom" -attachForm $warnText "right" $edge -attachControl $helpDownloadUrl "top" $spacer $warnText -attachForm $helpDownloadUrl "left" $edge -attachNone $helpDownloadUrl "bottom" -attachForm $helpDownloadUrl "right" $edge -attachControl $t1 "top" $spacer $helpDownloadUrl -attachForm $t1 "left" $edge -attachNone $t1 "bottom" -attachForm $t1 "right" $edge -attachControl $cb2 "top" $spacer $t1 -attachForm $cb2 "left" $edge -attachForm $cb2 "bottom" $edge -attachForm $cb2 "right" $edge $form; } global proc createNoHelpFoundAtCustomPathPrompt(string $showHelpCmd) { global string $gMayaVersionYear; string $form = `setParent -q`; formLayout -e -width 300 $form; int $spacer = 10; int $top = 20; int $edge = 20; string $helpDownloadUrl = helpDownloadUrlString(); string $canUseWebHelp = canUseWebHelpString(); string $cb2 = checkBoxSetAdskWebSitePref(); string $t1 = (uiRes("m_initHelp.kCannotFindHelp")); string $pathName = `optionVar -q ("customPathHelpUrl" + $gMayaVersionYear)`; if($pathName =="") { $pathName = (uiRes("m_initHelp.kLocalHelpPathNotSpecified")); } string $t2 = (uiRes("m_initHelp.kCannotFindHelpCont")); string $t3 = `text -al "left" -l $canUseWebHelp`; string $warnFormat = "^1s\n\n^2s\n\n^3s"; string $warnText = `format -stringArg $t1 -stringArg $pathName -stringArg $t2 $warnFormat`; $warnText = `text -al "left" -l $warnText`; formLayout -edit -attachForm $warnText "top" $top -attachForm $warnText "left" $edge -attachNone $warnText "bottom" -attachForm $warnText "right" $edge -attachControl $helpDownloadUrl "top" $spacer $warnText -attachForm $helpDownloadUrl "left" $edge -attachNone $helpDownloadUrl "bottom" -attachForm $helpDownloadUrl "right" $edge -attachControl $t3 "top" $spacer $helpDownloadUrl -attachForm $t3 "left" $edge -attachNone $t3 "bottom" -attachForm $t3 "right" $edge -attachControl $cb2 "top" $spacer $t3 -attachForm $cb2 "left" $edge -attachForm $cb2 "bottom" $edge -attachForm $cb2 "right" $edge $form; } global proc createNoLocalHelpInNonDefaultLanguagePrompt(string $showHelpCmd) { string $form = `setParent -q`; formLayout -e -width 300 $form; int $spacer = 10; int $top = 20; int $edge = 20; string $canUseWebHelp = canUseWebHelpString(); string $canInstallHelpFrom = canInstallHelpFromString(); string $helpDownloadUrl = helpDownloadUrlString(); string $cb2 = checkBoxSetAdskWebSitePref(); string $t1 = (uiRes("m_initHelp.kHelpLanugageErr")); string $t2 = `text -al "left" -l (uiRes("m_initHelp.kConfirmLangPref"))`; string $t3 = `text -al "left" -l $canUseWebHelp`; string $warnFormat = "^1s\n\n^2s"; string $warnText = `format -stringArg $t1 -stringArg $canInstallHelpFrom $warnFormat`; $warnText = `text -al "left" -l $warnText`; formLayout -edit -attachForm $warnText "top" $top -attachForm $warnText "left" $edge -attachNone $warnText "bottom" -attachForm $warnText "right" $edge -attachControl $helpDownloadUrl "top" $spacer $warnText -attachForm $helpDownloadUrl "left" $edge -attachNone $helpDownloadUrl "bottom" -attachForm $helpDownloadUrl "right" $edge -attachControl $t2 "top" $spacer $helpDownloadUrl -attachForm $t2 "left" $edge -attachNone $t2 "bottom" -attachForm $t2 "right" $edge -attachControl $t3 "top" $spacer $t2 -attachForm $t3 "left" $edge -attachNone $t3 "bottom" -attachForm $t3 "right" $edge -attachControl $cb2 "top" $spacer $t3 -attachForm $cb2 "left" $edge -attachForm $cb2 "bottom" $edge -attachForm $cb2 "right" $edge $form; } proc helpLocationErrorDialog(string $dialogCallback, string $showHelpCmd) { layoutDialog -title (uiRes("m_initHelp.kHelpLocationError")) -ui($dialogCallback + " \"" + $showHelpCmd +"\""); } proc int isConnectedToInternet() { return `about -connected`; } proc int isLocalHelpAtTextFieldPath() { global string $gMayaVersionYear; //checking if the index.html file exists string $helpLocation = `optionVar -q ("customPathHelpUrl" + $gMayaVersionYear)`; if( !endsWith($helpLocation,"\\") && !endsWith($helpLocation, "/")) { $helpLocation += "/"; } $helpLocation += "/index.html"; return `filetest -e $helpLocation`; } proc int isLocalHelpAtDefaultPath() { //checking if the index.html file exists string $helpLocation = getDefaultLocalHelpLocationFromTextFile(); if(!endsWith($helpLocation,"\\") && !endsWith($helpLocation, "/")) { $helpLocation += "/"; } $helpLocation += `optionVar -q helpLanguage` + "/index.html"; return `filetest -e $helpLocation`; } global proc int showHelpErrPromptIfRequired(string $showHelpCmd) { global string $gMayaVersionYear; string $helpMode = `optionVar -q helpMode`; int $connectedToInternet = isConnectedToInternet(); if($helpMode == "Autodesk Web Site") { if(!$connectedToInternet) { if(isLocalHelpAtDefaultPath()) { helpLocationErrorDialog("createNoConnectionLocalHelpAvailablePrompt", $showHelpCmd); } else { helpLocationErrorDialog("createNoConnectionNoLocalHelpPrompt",""); } return true; } } else if ($helpMode == "Installed Local Help") { string $uiLanguage = `about -uiLanguage`; if (!isLocalHelpAtDefaultPath()) { if(`optionVar -q helpLanguage` == $uiLanguage) { helpLocationErrorDialog("createNoLocalHelpInDefaultLanguagePrompt",""); } else { helpLocationErrorDialog("createNoLocalHelpInNonDefaultLanguagePrompt",""); } return true; } } else { if(!isLocalHelpAtTextFieldPath()) { string $helpLocation = `optionVar -q ("customPathHelpUrl" + $gMayaVersionYear)`; if(startsWith($helpLocation, "http://") || startsWith($helpLocation, "https://")) { if(!$connectedToInternet) { if(isLocalHelpAtDefaultPath()) { helpLocationErrorDialog("createNoConnectionLocalHelpAvailablePrompt", $showHelpCmd); } else { helpLocationErrorDialog("createNoConnectionNoLocalHelpPrompt",""); } return true; } } else { helpLocationErrorDialog("createNoHelpFoundAtCustomPathPrompt",""); return true; } } } return false; } global proc int checkHelpLanguageMismatch() { if( (`about -uiLanguage` != `optionVar -query "helpLanguage"`) && (!`optionVar -exists helpLanguageMismatchConfirm`) ){ optionVar -iv helpLanguageMismatchConfirm true; string $answer; string $dialogTitle = (uiRes("m_initHelp.kHelpLanguage")); string $open = (uiRes("m_initHelp.kOpenHelp")); string $change = (uiRes("m_initHelp.kChangeHelpLanguage")); string $message = (uiRes("m_initHelp.kMessage")); $answer = `confirmDialog -title $dialogTitle -message $message -button $change -button $open -defaultButton $change -cancelButton $open `; if($answer == $change) { preferencesWnd "Help"; return true; } } return false; } global proc checkHelpPrefs() { string $helpURL; $helpURL = "index.html"; showHelp -docs $helpURL; }