2019-12-26 15:33:43 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-10-01 20:41:42 -04:00
|
|
|
|
|
|
|
|
#include "Tools/UEdMode.h"
|
2021-03-29 11:32:25 -04:00
|
|
|
|
2019-10-01 20:41:42 -04:00
|
|
|
#include "EditorModeManager.h"
|
|
|
|
|
#include "EditorModes.h"
|
|
|
|
|
#include "Toolkits/BaseToolkit.h"
|
2020-06-23 18:40:00 -04:00
|
|
|
#include "EdModeInteractiveToolsContext.h"
|
2019-10-01 20:41:42 -04:00
|
|
|
#include "Toolkits/ToolkitManager.h"
|
|
|
|
|
#include "InteractiveToolManager.h"
|
2019-12-19 18:07:47 -05:00
|
|
|
#include "GameFramework/Actor.h"
|
2021-02-14 15:29:11 -04:00
|
|
|
#include "Elements/Framework/TypedElementSelectionSet.h"
|
|
|
|
|
#include "Elements/Interfaces/TypedElementObjectInterface.h"
|
|
|
|
|
|
2019-10-01 20:41:42 -04:00
|
|
|
|
|
|
|
|
//////////////////////////////////
|
|
|
|
|
// UEdMode
|
|
|
|
|
|
|
|
|
|
UEdMode::UEdMode()
|
2021-11-18 14:37:34 -05:00
|
|
|
: Owner(nullptr)
|
2019-10-01 20:41:42 -04:00
|
|
|
{
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
EditorToolsContext = nullptr;
|
|
|
|
|
ModeToolsContext = nullptr;
|
2019-12-19 18:07:47 -05:00
|
|
|
ToolCommandList = MakeShareable(new FUICommandList);
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
|
2020-06-23 18:40:00 -04:00
|
|
|
void UEdMode::Initialize()
|
2019-10-01 20:41:42 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UEdMode::SelectNone()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UEdMode::ProcessEditDelete()
|
|
|
|
|
{
|
2020-06-23 18:40:00 -04:00
|
|
|
return false;
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UEdMode::Enter()
|
|
|
|
|
{
|
|
|
|
|
// Update components for selected actors, in case the mode we just exited
|
|
|
|
|
// was hijacking selection events selection and not updating components.
|
2021-02-14 15:29:11 -04:00
|
|
|
Owner->GetEditorSelectionSet()->ForEachSelectedObject<AActor>([](AActor* ActorPtr)
|
|
|
|
|
{
|
|
|
|
|
ActorPtr->MarkComponentsRenderStateDirty();
|
|
|
|
|
return true;
|
|
|
|
|
});
|
2019-10-01 20:41:42 -04:00
|
|
|
|
2022-05-19 12:34:51 -04:00
|
|
|
CreateInteractiveToolsContexts();
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
|
|
|
|
|
ModeToolsContext->ToolManager->OnToolStarted.AddUObject(this, &UEdMode::OnToolStarted);
|
|
|
|
|
ModeToolsContext->ToolManager->OnToolEnded.AddUObject(this, &UEdMode::OnToolEnded);
|
2019-12-19 18:07:47 -05:00
|
|
|
|
2020-12-08 11:27:52 -04:00
|
|
|
// Create the settings object so that the toolkit has access to the object we are going to use at creation time
|
|
|
|
|
if (SettingsClass.IsValid())
|
|
|
|
|
{
|
|
|
|
|
UClass* LoadedSettingsObject = SettingsClass.LoadSynchronous();
|
|
|
|
|
SettingsObject = NewObject<UObject>(this, LoadedSettingsObject);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-19 18:07:47 -05:00
|
|
|
// Now that the context is ready, make the toolkit
|
|
|
|
|
CreateToolkit();
|
2020-11-02 11:48:42 -04:00
|
|
|
if (Toolkit.IsValid())
|
|
|
|
|
{
|
|
|
|
|
Toolkit->Init(Owner->GetToolkitHost(), this);
|
|
|
|
|
}
|
2020-09-02 15:43:58 -04:00
|
|
|
|
|
|
|
|
BindCommands();
|
|
|
|
|
|
|
|
|
|
if (SettingsObject)
|
|
|
|
|
{
|
2020-10-08 18:56:55 -04:00
|
|
|
SettingsObject->LoadConfig();
|
2020-11-02 11:48:42 -04:00
|
|
|
|
|
|
|
|
if (Toolkit.IsValid())
|
|
|
|
|
{
|
|
|
|
|
Toolkit->SetModeSettingsObject(SettingsObject);
|
|
|
|
|
}
|
2020-09-02 15:43:58 -04:00
|
|
|
}
|
2019-10-01 20:41:42 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
Owner->OnEditorModeIDChanged().AddUObject(this, &UEdMode::OnModeActivated);
|
|
|
|
|
|
|
|
|
|
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
2019-10-01 20:41:42 -04:00
|
|
|
FEditorDelegates::EditorModeIDEnter.Broadcast(GetID());
|
2021-11-18 14:37:34 -05:00
|
|
|
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
2019-12-19 18:07:47 -05:00
|
|
|
}
|
|
|
|
|
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
void UEdMode::RegisterTool(TSharedPtr<FUICommandInfo> UICommand, FString ToolIdentifier, UInteractiveToolBuilder* Builder, EToolsContextScope ToolScope)
|
2019-12-19 18:07:47 -05:00
|
|
|
{
|
2021-06-08 20:23:30 -04:00
|
|
|
if (!Toolkit.IsValid())
|
2021-06-08 19:09:02 -04:00
|
|
|
{
|
2021-06-08 20:23:30 -04:00
|
|
|
return;
|
2021-06-08 19:09:02 -04:00
|
|
|
}
|
2021-06-08 20:23:30 -04:00
|
|
|
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
if (ToolScope == EToolsContextScope::Default)
|
|
|
|
|
{
|
|
|
|
|
ToolScope = GetDefaultToolScope();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UEditorInteractiveToolsContext* UseToolsContext = GetInteractiveToolsContext(ToolScope);
|
|
|
|
|
if (ensure(UseToolsContext != nullptr) == false)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 20:23:30 -04:00
|
|
|
const TSharedRef<FUICommandList>& CommandList = Toolkit->GetToolkitCommands();
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
UseToolsContext->ToolManager->RegisterToolType(ToolIdentifier, Builder);
|
2021-06-08 20:23:30 -04:00
|
|
|
CommandList->MapAction(UICommand,
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
FExecuteAction::CreateUObject(UseToolsContext, &UEdModeInteractiveToolsContext::StartTool, ToolIdentifier),
|
|
|
|
|
FCanExecuteAction::CreateWeakLambda(UseToolsContext, [this, ToolIdentifier, UseToolsContext]() {
|
|
|
|
|
return ShouldToolStartBeAllowed(ToolIdentifier) &&
|
|
|
|
|
UseToolsContext->ToolManager->CanActivateTool(EToolSide::Mouse, ToolIdentifier);
|
|
|
|
|
}),
|
|
|
|
|
FIsActionChecked::CreateUObject(UseToolsContext, &UEdModeInteractiveToolsContext::IsToolActive, EToolSide::Mouse, ToolIdentifier),
|
2021-06-08 20:23:30 -04:00
|
|
|
EUIActionRepeatMode::RepeatDisabled);
|
|
|
|
|
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
if (ToolScope == EToolsContextScope::Editor)
|
|
|
|
|
{
|
|
|
|
|
RegisteredEditorTools.Emplace(UICommand, ToolIdentifier);
|
|
|
|
|
}
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
|
2021-03-24 16:38:43 -04:00
|
|
|
bool UEdMode::ShouldToolStartBeAllowed(const FString& ToolIdentifier) const
|
|
|
|
|
{
|
|
|
|
|
// Disallow starting tools when playing in editor or simulating.
|
|
|
|
|
return !GEditor->PlayWorld && !GIsPlayInEditorWorld;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 20:41:42 -04:00
|
|
|
void UEdMode::Exit()
|
|
|
|
|
{
|
2020-10-08 18:56:55 -04:00
|
|
|
if (SettingsObject)
|
|
|
|
|
{
|
|
|
|
|
SettingsObject->SaveConfig();
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
if (UObjectInitialized())
|
2021-09-29 20:12:25 -04:00
|
|
|
{
|
2021-11-18 14:37:34 -05:00
|
|
|
Owner->OnEditorModeIDChanged().RemoveAll(this);
|
|
|
|
|
|
|
|
|
|
// Shutdown the Mode-scope ToolsContext, and notify the EditorToolsContext so it can release the reference it holds.
|
|
|
|
|
// Do this before shutting down the Toolkit as if a Mode-scope Tool is still active it will need to clean up
|
2022-05-19 12:34:51 -04:00
|
|
|
DestroyInteractiveToolsContexts();
|
2021-09-29 20:12:25 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 20:41:42 -04:00
|
|
|
if (Toolkit.IsValid())
|
|
|
|
|
{
|
2020-11-02 11:48:42 -04:00
|
|
|
const TSharedRef<FUICommandList>& CommandList = Toolkit->GetToolkitCommands();
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
for (auto& RegisteredTool : RegisteredEditorTools)
|
2020-11-02 11:48:42 -04:00
|
|
|
{
|
|
|
|
|
CommandList->UnmapAction(RegisteredTool.Key);
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
EditorToolsContext->ToolManager->UnregisterToolType(RegisteredTool.Value);
|
2020-11-02 11:48:42 -04:00
|
|
|
}
|
2021-11-18 14:37:34 -05:00
|
|
|
|
2019-10-01 20:41:42 -04:00
|
|
|
Toolkit.Reset();
|
|
|
|
|
}
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
RegisteredEditorTools.SetNum(0);
|
2019-10-01 20:41:42 -04:00
|
|
|
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
// disconnect from the Mode Manager's shared ToolsContext
|
|
|
|
|
EditorToolsContext = nullptr;
|
|
|
|
|
ModeToolsContext = nullptr;
|
2020-09-02 15:43:58 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
2019-10-01 20:41:42 -04:00
|
|
|
FEditorDelegates::EditorModeIDExit.Broadcast(GetID());
|
2021-11-18 14:37:34 -05:00
|
|
|
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UEdMode::UsesToolkits() const
|
|
|
|
|
{
|
2020-09-01 10:23:07 -04:00
|
|
|
return true;
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UWorld* UEdMode::GetWorld() const
|
|
|
|
|
{
|
|
|
|
|
return Owner->GetWorld();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class FEditorModeTools* UEdMode::GetModeManager() const
|
|
|
|
|
{
|
|
|
|
|
return Owner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AActor* UEdMode::GetFirstSelectedActorInstance() const
|
|
|
|
|
{
|
2021-02-14 15:29:11 -04:00
|
|
|
return Owner->GetEditorSelectionSet()->GetTopSelectedObject<AActor>();
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
UInteractiveToolManager* UEdMode::GetToolManager(EToolsContextScope ToolScope) const
|
2019-10-01 20:41:42 -04:00
|
|
|
{
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
if (ToolScope == EToolsContextScope::Default)
|
2020-09-02 15:43:58 -04:00
|
|
|
{
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
ToolScope = GetDefaultToolScope();
|
2020-09-02 15:43:58 -04:00
|
|
|
}
|
|
|
|
|
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
if (ToolScope == EToolsContextScope::Editor)
|
|
|
|
|
{
|
|
|
|
|
return (EditorToolsContext.IsValid()) ? EditorToolsContext->ToolManager : nullptr;
|
|
|
|
|
}
|
|
|
|
|
else if (ToolScope == EToolsContextScope::EdMode)
|
|
|
|
|
{
|
|
|
|
|
return ModeToolsContext->ToolManager;
|
|
|
|
|
}
|
|
|
|
|
ensure(false);
|
2020-09-02 15:43:58 -04:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
UEditorInteractiveToolsContext* UEdMode::GetInteractiveToolsContext(EToolsContextScope ToolScope) const
|
2020-09-02 15:43:58 -04:00
|
|
|
{
|
Add support for UEdMode-level InteractiveToolsContext which exists at the same time as the existing ModeManager-level ITC.
- rename UEdModeInteractiveToolsContext to UEditorInteractiveToolsContext, made all functions virtual so they can be customized for the new Editor/EdMode implementations where necessary
- add UModeManagerInteractiveToolsContext and UEdModeInteractiveToolsContext subclasses. Most functionality stays in the base class. Mouse-handling functions that manipulate the InputRouter move to ModeManagerITC.
- EdModeITC now is initialized based on a ModeManagerITC, and shares it's InputRouter
- ModeManagerITC creates the child EdModeITCs, forwards Tick/Render/DrawHUD calls
- FEditorModeTools now creates a ModeManagerITC
- Add EToolsContextScope enum, with options for Editor and EdMode ToolsContext
- UEdMode::Enter() now creates a child EdModeITC via new EditorITC::CreateNewChildEdModeToolsContext() function above, in addition to storing reference to the ModeManagerITC. Internal code updated to handle both ITCs.
- The EdModeITC is shut down on ::Exit() and unregistered from the EditorITC parent
- UEdMode ITC access functions (GetToolsContext, GetToolManager, RegisterTool) now take an optional Scope argument
- UEdMode::GetDefaultToolScope() allows EdModes to define default scope for the entire mode, defaults to Editor scope
- removed unused CanStartTool()/etc wrapper functions from FModeToolkit, they were not being called
- FModeToolkit::Init() now listens to events from both the ModeManagerITC and EdModeITC, delete cleans them both up
- FModeToolkit::OnToolStarted() checks both ITCs to see which one owns the new Tool
- updated all EdModes that were directly accessing the UEdMode::ToolsContext member, replaced with calls to GetToolsContext() / GetToolManager() APIs
- updated ModelingToolsEditorMode to use EdMode ToolScope
#rb brooke.hubert
#rnx
#jira none
#preflight 6140cc1130c00d0001dc4b9e
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 17510176 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17510201 by ryan schmidt in ue5-release-engine-test branch]
2021-09-14 17:11:13 -04:00
|
|
|
if (ToolScope == EToolsContextScope::Default)
|
|
|
|
|
{
|
|
|
|
|
ToolScope = GetDefaultToolScope();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ToolScope == EToolsContextScope::Editor)
|
|
|
|
|
{
|
|
|
|
|
return EditorToolsContext.IsValid() ? EditorToolsContext.Get() : nullptr;
|
|
|
|
|
}
|
|
|
|
|
else if (ToolScope == EToolsContextScope::EdMode)
|
|
|
|
|
{
|
|
|
|
|
return ModeToolsContext;
|
|
|
|
|
}
|
|
|
|
|
ensure(false);
|
|
|
|
|
return nullptr;
|
2019-10-01 20:41:42 -04:00
|
|
|
}
|
|
|
|
|
|
2019-12-19 18:07:47 -05:00
|
|
|
void UEdMode::CreateToolkit()
|
|
|
|
|
{
|
2020-11-02 11:48:42 -04:00
|
|
|
if (!UsesToolkits())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-02 15:43:58 -04:00
|
|
|
check(!Toolkit.IsValid())
|
|
|
|
|
Toolkit = MakeShareable(new FModeToolkit);
|
2019-12-19 18:07:47 -05:00
|
|
|
}
|
|
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
void UEdMode::OnModeActivated(const FEditorModeID& InID, bool bIsActive)
|
|
|
|
|
{
|
|
|
|
|
if (InID == GetID())
|
|
|
|
|
{
|
|
|
|
|
if (bIsActive)
|
|
|
|
|
{
|
|
|
|
|
Owner->GetInteractiveToolsContext()->OnChildEdModeActivated(ModeToolsContext);
|
|
|
|
|
|
|
|
|
|
EditorToolsContext->ToolManager->OnToolStarted.AddUObject(this, &UEdMode::OnToolStarted);
|
|
|
|
|
EditorToolsContext->ToolManager->OnToolEnded.AddUObject(this, &UEdMode::OnToolEnded);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
EditorToolsContext->ToolManager->OnToolStarted.RemoveAll(this);
|
|
|
|
|
EditorToolsContext->ToolManager->OnToolEnded.RemoveAll(this);
|
|
|
|
|
|
|
|
|
|
Owner->GetInteractiveToolsContext()->OnChildEdModeDeactivated(ModeToolsContext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 12:34:51 -04:00
|
|
|
void UEdMode::CreateInteractiveToolsContexts()
|
|
|
|
|
{
|
|
|
|
|
// Editor-scope ToolsContext is provided by the Mode Manager
|
|
|
|
|
EditorToolsContext = Owner->GetInteractiveToolsContext();
|
|
|
|
|
check(EditorToolsContext.IsValid());
|
|
|
|
|
|
|
|
|
|
// Mode-scope ToolsContext is created derived from the Editor-Scope ToolsContext so that the UInputRouter can be shared
|
|
|
|
|
ModeToolsContext = EditorToolsContext->CreateNewChildEdModeToolsContext();
|
|
|
|
|
check(ModeToolsContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UEdMode::DestroyInteractiveToolsContexts()
|
|
|
|
|
{
|
|
|
|
|
if (ModeToolsContext)
|
|
|
|
|
{
|
|
|
|
|
ModeToolsContext->ShutdownContext();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 20:41:42 -04:00
|
|
|
bool UEdMode::IsSnapRotationEnabled()
|
|
|
|
|
{
|
|
|
|
|
return GetDefault<ULevelEditorViewportSettings>()->RotGridEnabled;
|
|
|
|
|
}
|