Skip to content

Commit

Permalink
#5662: Introduce new map events to know when the user is done merging
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 21, 2021
1 parent e635e6d commit d291a24
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions include/imap.h
Expand Up @@ -106,6 +106,9 @@ class IMap :
MapUnloaded, // emitted after a map has been unloaded
MapSaving, // emitted before a map is about to be saved (changes are possible)
MapSaved, // emitted right after a map has been saved
MapMergeOperationStarted, // emitted after a merge operation has been started
MapMergeOperationAborted, // emitted after a merge operation has been aborted
MapMergeOperationFinished, // emitted after a merge operation has been finished
};

typedef sigc::signal<void, MapEvent> MapEventSignal;
Expand Down
21 changes: 17 additions & 4 deletions radiantcore/map/Map.cpp
Expand Up @@ -196,12 +196,14 @@ void Map::finishMergeOperation()
_mergeActionNodes.clear();

// At this point the scene should look the same as before the merge
{
UndoableCommand cmd("mergeMap");
_mergeOperation->applyActions();

UndoableCommand cmd("mergeMap");
_mergeOperation->applyActions();

cleanupMergeOperation();
cleanupMergeOperation();
}
setEditMode(EditMode::Normal);
emitMapEvent(IMap::MapMergeOperationFinished);
}

void Map::cleanupMergeOperation()
Expand All @@ -222,9 +224,16 @@ void Map::cleanupMergeOperation()

void Map::abortMergeOperation()
{
bool mergeWasActive = _mergeOperation != nullptr;

// Remove the nodes and switch back to normal without applying the operation
cleanupMergeOperation();
setEditMode(EditMode::Normal);

if (mergeWasActive)
{
emitMapEvent(IMap::MapMergeOperationAborted);
}
}

scene::merge::IMergeOperation::Ptr Map::getActiveMergeOperation()
Expand Down Expand Up @@ -1191,6 +1200,8 @@ void Map::startMergeOperation(const std::string& sourceMap)

// Switch to merge mode
setEditMode(EditMode::Merge);

emitMapEvent(IMap::MapMergeOperationStarted);
}
else
{
Expand Down Expand Up @@ -1228,6 +1239,8 @@ void Map::startMergeOperation(const std::string& sourceMap, const std::string& b

// Switch to merge mode
setEditMode(EditMode::Merge);

emitMapEvent(IMap::MapMergeOperationStarted);
}
else
{
Expand Down

0 comments on commit d291a24

Please sign in to comment.