Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate callbacks for Save and Export #1226

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions lib/mayaUsd/nodes/layerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,14 @@ class LayerDatabase : public TfWeakBase

static LayerDatabase& instance();
static void setBatchSaveDelegate(BatchSaveDelegate delegate);
static void prepareForWriteCheck(bool*, void*);
static void prepareForSaveCheck(bool*, void*);
static void prepareForExportCheck(bool*, void*);
static void prepareForWriteCheck(bool*, bool);
static void loadLayersPostRead(void*);
static void cleanUpNewScene(void*);
static void removeManagerNode(MayaUsd::LayerManager* lm = nullptr);

bool getStagesToSave();
bool getStagesToSave(bool isExport);
bool supportedNodeType(MTypeId type);
void addSupportForNodeType(MTypeId type);
void removeSupportForNodeType(MTypeId type);
Expand Down Expand Up @@ -269,9 +271,9 @@ void LayerDatabase::registerCallbacks()
{
if (0 == preSaveCallbackId) {
preSaveCallbackId = MSceneMessage::addCallback(
MSceneMessage::kBeforeSaveCheck, LayerDatabase::prepareForWriteCheck);
MSceneMessage::kBeforeSaveCheck, LayerDatabase::prepareForSaveCheck);
preExportCallbackId = MSceneMessage::addCallback(
MSceneMessage::kBeforeExportCheck, LayerDatabase::prepareForWriteCheck);
MSceneMessage::kBeforeExportCheck, LayerDatabase::prepareForExportCheck);
postNewCallbackId
= MSceneMessage::addCallback(MSceneMessage::kAfterNew, LayerDatabase::cleanUpNewScene);
preOpenCallbackId = MSceneMessage::addCallback(
Expand Down Expand Up @@ -321,11 +323,21 @@ void LayerDatabase::setBatchSaveDelegate(BatchSaveDelegate delegate)
_batchSaveDelegate = delegate;
}

void LayerDatabase::prepareForWriteCheck(bool* retCode, void*)
void LayerDatabase::prepareForSaveCheck(bool* retCode, void*)
{
prepareForWriteCheck(retCode, false);
}

void LayerDatabase::prepareForExportCheck(bool* retCode, void*)
{
prepareForWriteCheck(retCode, true);
}

void LayerDatabase::prepareForWriteCheck(bool* retCode, bool isExport)
{
cleanUpNewScene(nullptr);

if (LayerDatabase::instance().getStagesToSave()) {
if (LayerDatabase::instance().getStagesToSave(isExport)) {

int dialogResult = true;

Expand All @@ -343,10 +355,10 @@ void LayerDatabase::prepareForWriteCheck(bool* retCode, void*)
}
}

bool LayerDatabase::getStagesToSave()
bool LayerDatabase::getStagesToSave(bool isExport)
{
auto allStages = MayaUsd::ufe::getAllStages();
bool checkSelection = (MFileIO::kExportTypeSelected == MFileIO::exportType());
bool checkSelection = isExport && (MFileIO::kExportTypeSelected == MFileIO::exportType());
seando-adsk marked this conversation as resolved.
Show resolved Hide resolved
const UFE_NS::GlobalSelection::Ptr& ufeSelection = UFE_NS::GlobalSelection::get();

_stagesToSave.clear();
Expand Down