/** * Activates an editor mode. Shuts down all other active modes which cannot run with the passed in mode. * * @param InID The ID of the editor mode to activate. * @param bToggle true if the passed in editor mode should be toggled off if it is already active. */ void FEditorModeTools::ActivateMode( FEditorModeID InID, bool bToggle ) { if (InID == FBuiltinEditorModes::EM_Default) { InID = DefaultID; } // Check to see if the mode is already active if( IsModeActive(InID) ) { // The mode is already active toggle it off if we should toggle off already active modes. if( bToggle ) { DeactivateMode( InID ); } // Nothing more to do return; } // Recycle a mode or factory a new one TSharedPtr<FEdMode> Mode = RecycledModes.FindRef( InID ); if ( Mode.IsValid() ) { RecycledModes.Remove( InID ); } else { Mode = FEditorModeRegistry::Get().CreateMode( InID, *this ); } if( !Mode.IsValid() ) { UE_LOG(LogEditorModes, Log, TEXT("FEditorModeTools::ActivateMode : Couldn't find mode '%s'."), *InID.ToString() ); // Just return and leave the mode list unmodified return; } // Remove anything that isn't compatible with this mode for( int32 ModeIndex = Modes.Num() - 1; ModeIndex >= 0; --ModeIndex ) { const bool bModesAreCompatible = Mode->IsCompatibleWith( Modes[ModeIndex]->GetID() ) || Modes[ModeIndex]->IsCompatibleWith( Mode->GetID() ); if ( !bModesAreCompatible ) { DeactivateModeAtIndex(ModeIndex); } } Modes.Add( Mode ); // Enter the new mode Mode->Enter(); // Update the editor UI FEditorSupportDelegates::UpdateUI.Broadcast(); }
FReply SLevelEditorActiveToolkit::OnToolkitCloseButtonClicked() { DeactivateMode(); return FReply::Handled(); }