// =========================================================================== // 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 17 1996 // // Procedure Name: // saveChanges // // Description: // Prompt the user to save changes before performing the requested // action. // // Input Arguments: // ?? // // Return Value: // 1 = everything's groovy // 0 = user selected cancel from dialog // global proc int saveChanges ( string $saveChangeAction ) // // Description: // // { string $fileName; string $result; int $returnValue = 1; if (`file -q -mf`) { $fileName = `file -q -sceneName`; // These are not tagged and come from // TdialogStrings, since Tdialog has special string // processing to add (windows only!) hotkey-mnemonic // shortcuts to a small but very specific list of // strings. // string $save = `uiRes "s_TdialogStrings.rSave"`; string $dontSave = `uiRes "s_TdialogStrings.rDontSave"`; string $cancel = `uiRes "s_TdialogStrings.rCancel"`; if ($fileName != "") { string $saveMsg = (uiRes("m_saveChanges.kSaveFileMsg")); string $confirmMessage = (`format -s $fileName $saveMsg`); $result = `confirmDialog -title (uiRes("m_saveChanges.kSaveChanges")) -message $confirmMessage -button $save -button $dontSave -button $cancel -defaultButton $save -cancelButton $cancel`; if ($result == $save) { if (catch(`file -save`)) { // There is already plenty of prompts when this happens. $returnValue = 0; } } else if ($result == $cancel || $result == "dismiss") { $returnValue = 0; } } else { $result = `confirmDialog -title (uiRes("m_saveChanges.kWarningSceneNotSaved")) -message ( (uiRes("m_saveChanges.kSaveChangesToUntitled")) ) -button $save -button $dontSave -button $cancel -defaultButton $save -cancelButton $cancel`; if ( $result == $save ) { $returnValue = `projectViewer "SaveAs"`; } else if ( $result == $dontSave ) { $returnValue = 1; } else if ( $result == $cancel || $result == "dismiss" ) { $returnValue = 0; } } } if ($returnValue == 1) { if ($saveChangeAction != "") { evalEcho($saveChangeAction); } } return $returnValue; }