From 8cc51fd3ebfd3138030499557a015174d9bcfdca Mon Sep 17 00:00:00 2001 From: Sean Donnelly <23455376+seando-adsk@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:45:12 -0500 Subject: [PATCH 1/2] EMSUSD-717: USD Preferences: "Use Display Color" preferences are maintained when user cancels change * Fix cancel case and optimize when to call 'ogs -reset' --- plugin/adsk/scripts/mayaUsd_preferenceTab.mel | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/plugin/adsk/scripts/mayaUsd_preferenceTab.mel b/plugin/adsk/scripts/mayaUsd_preferenceTab.mel index 3d7059ab68..05e030bfa3 100644 --- a/plugin/adsk/scripts/mayaUsd_preferenceTab.mel +++ b/plugin/adsk/scripts/mayaUsd_preferenceTab.mel @@ -94,6 +94,10 @@ global proc mayaUsd_PrefUntexturedModeChanged() if (`radioButtonGrp -exists usdPrefUntexturedMode`) { int $sel = `radioButtonGrp -q -select usdPrefUntexturedMode`; optionVar -iv mayaUsd_ShowDisplayColorTextureOff ($sel == 2); + + // Set a temporary optionVar saying that we have changed the untextured mode + // so in case user cancels, we can do reset again. + optionVar -transient -iv mayaUsd_PrefUntexturedModeChanged 1; ogs -reset; } } @@ -104,6 +108,13 @@ global proc mayaUsd_PrefInitOptionVars(int $forceFactoryDefault) string $saveLayerFormatArgBinaryOptionPref = `python("import mayaUsd.lib as mlib; mlib.OptionVarTokens.SaveLayerFormatArgBinaryOption")`; string $confirmExistingFileSaveOptionPref = `python("import mayaUsd.lib as mlib; mlib.OptionVarTokens.ConfirmExistingFileSave")`; + // Special case for the resetting the untextured mode. + if ($forceFactoryDefault && `optionVar -exists "mayaUsd_ShowDisplayColorTextureOff"`) { + if (`optionVar -q "mayaUsd_ShowDisplayColorTextureOff"`) { + optionVar -transient -iv mayaUsd_PrefUntexturedModeChanged 1; + } + } + int $mjv = `about -majorVersion`; if ($mjv <= 2022) { if ($forceFactoryDefault || !`optionVar -exists mayaUsd_SerializedUsdEditsLocation`) { @@ -155,8 +166,13 @@ global proc mayaUsd_PrefInitOptionVars(int $forceFactoryDefault) -iv mayaUsd_ShowDisplayColorTextureOff false ; } - // Need to refresh the viewport for display mayaUsd_ShowDisplayColorTextureOff - ogs -reset; + + if ($forceFactoryDefault && `optionVar -q mayaUsd_PrefUntexturedModeChanged`) + { + // Need to refresh the viewport for display mayaUsd_ShowDisplayColorTextureOff + optionVar -remove mayaUsd_PrefUntexturedModeChanged; + ogs -reset; + } } global proc mayaUsd_PrefCreateTab() @@ -392,10 +408,22 @@ global proc mayaUsd_PrefHoldState(string $mode) }; prefsHoldOptionVars($prefOptionVars, $mode); - if ($mode == "remove") { - // Finalize preference changes into MayaUsd. + if ($mode == "save") { + // Preferences dialog was opened, make sure we don't have this transient optionVar. + optionVar -remove mayaUsd_PrefUntexturedModeChanged; + } + + if ($mode == "restore") { + if (`optionVar -q mayaUsd_PrefUntexturedModeChanged`) { + // Need to refresh the viewport for display mayaUsd_ShowDisplayColorTextureOff + ogs -reset; + } } + if ($mode == "remove") { + optionVar -remove mayaUsd_PrefUntexturedModeChanged; + } + global string $gPreferenceWindow; if (`window -exists $gPreferenceWindow`) { setParent mayaUsd_PrefLayout; From b591b136f9b2fb82f8a7cc2319924d6b0b40058c Mon Sep 17 00:00:00 2001 From: Sean Donnelly <23455376+seando-adsk@users.noreply.github.com> Date: Tue, 16 Jan 2024 10:02:48 -0500 Subject: [PATCH 2/2] EMSUSD-717: USD Preferences: "Use Display Color" preferences are maintained when user cancels change * Fix indentation (code review comment) --- plugin/adsk/scripts/mayaUsd_preferenceTab.mel | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugin/adsk/scripts/mayaUsd_preferenceTab.mel b/plugin/adsk/scripts/mayaUsd_preferenceTab.mel index 05e030bfa3..49644a2aa8 100644 --- a/plugin/adsk/scripts/mayaUsd_preferenceTab.mel +++ b/plugin/adsk/scripts/mayaUsd_preferenceTab.mel @@ -408,21 +408,21 @@ global proc mayaUsd_PrefHoldState(string $mode) }; prefsHoldOptionVars($prefOptionVars, $mode); - if ($mode == "save") { - // Preferences dialog was opened, make sure we don't have this transient optionVar. - optionVar -remove mayaUsd_PrefUntexturedModeChanged; - } + if ($mode == "save") { + // Preferences dialog was opened, make sure we don't have this transient optionVar. + optionVar -remove mayaUsd_PrefUntexturedModeChanged; + } if ($mode == "restore") { - if (`optionVar -q mayaUsd_PrefUntexturedModeChanged`) { - // Need to refresh the viewport for display mayaUsd_ShowDisplayColorTextureOff - ogs -reset; - } + if (`optionVar -q mayaUsd_PrefUntexturedModeChanged`) { + // Need to refresh the viewport for display mayaUsd_ShowDisplayColorTextureOff + ogs -reset; + } } - if ($mode == "remove") { - optionVar -remove mayaUsd_PrefUntexturedModeChanged; - } + if ($mode == "remove") { + optionVar -remove mayaUsd_PrefUntexturedModeChanged; + } global string $gPreferenceWindow; if (`window -exists $gPreferenceWindow`) {