Created
July 29, 2018 20:21
-
-
Save jkinz3/a635ad22cc4d3b4c8e383d30126ecc82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. | |
#include "GeoEditorEdMode.h" | |
#include "GeoEditorEdModeToolkit.h" | |
#include "GeoEditorCommands.h" | |
#include "Toolkits/ToolkitManager.h" | |
#include "Engine/Selection.h" | |
#include "EditorModeManager.h" | |
const FEditorModeID FGeoEditorEdMode::EM_GeoEditorEdModeId = TEXT("EM_GeoEditorEdMode"); | |
FGeoEditorEdMode::FGeoEditorEdMode() | |
{ | |
GEditor->AddOnScreenDebugMessage(-1, 1.f, FColor::White, "HAI"); | |
UICommandList = MakeShareable(new FUICommandList); | |
} | |
FGeoEditorEdMode::~FGeoEditorEdMode() | |
{ | |
} | |
void FGeoEditorEdMode::Enter() | |
{ | |
FEdMode::Enter(); | |
if (!Toolkit.IsValid() && UsesToolkits()) | |
{ | |
Toolkit = MakeShareable(new FGeoEditorEdModeToolkit); | |
Toolkit->Init(Owner->GetToolkitHost()); | |
} | |
} | |
void FGeoEditorEdMode::Exit() | |
{ | |
if (Toolkit.IsValid()) | |
{ | |
FToolkitManager::Get().CloseToolkit(Toolkit.ToSharedRef()); | |
Toolkit.Reset(); | |
} | |
// Call base Exit method to ensure proper cleanup | |
FEdMode::Exit(); | |
} | |
bool FGeoEditorEdMode::UsesToolkits() const | |
{ | |
return true; | |
} | |
bool FGeoEditorEdMode::InputKey(FEditorViewportClient* InViewportClient, FViewport* InViewport, FKey InKey, EInputEvent InEvent) | |
{ | |
bRightMouseDown = InKey == EKeys::RightMouseButton; | |
bCtrlPressed = InViewportClient->IsCtrlPressed(); | |
bAltPressed = InViewportClient->IsAltPressed(); | |
bShiftPressed = InViewportClient->IsShiftPressed(); | |
bool bHandled = false; | |
if (!bHandled && InEvent != EInputEvent::IE_Released) | |
{ | |
if (UICommandList->ProcessCommandBindings(InKey, FSlateApplication::Get().GetModifierKeys(), false)) | |
{ | |
bHandled = true; | |
} | |
} | |
if (!bHandled) | |
{ | |
const bool bKeyPressed = InEvent == EInputEvent::IE_Pressed; | |
const bool bKeyReleased = InEvent == EInputEvent::IE_Released; | |
if (InKey == EKeys::U && bCtrlPressed) | |
{ | |
GEditor->AddOnScreenDebugMessage(-1, 1.f, FColor::White, "HAI"); | |
USelection* SelectedActors = GEditor->GetSelectedActors(); | |
TArray<AActor*> Actors; | |
for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter) | |
{ | |
AActor* SelectedActor = Cast<AActor>(*Iter); | |
if (SelectedActor) | |
{ | |
SelectedActor->Destroy(); | |
} | |
} | |
} | |
} | |
return bHandled; | |
} | |
void FGeoEditorEdMode::BindCommands() | |
{ | |
const FGeoEditorCommands& Commands = FGeoEditorCommands::Get(); | |
UICommandList->MapAction(Commands.AlignBrushVerticesToGrid, FExecuteAction::CreateRaw(this, &FGeoEditorEdMode::AlignBrushVerticesToGrid)); | |
} | |
void FGeoEditorEdMode::AlignBrushVerticesToGrid() | |
{ | |
GEditor->AddOnScreenDebugMessage(-1, 1.f, FColor::White, "HAI"); | |
USelection* SelectedActors = GEditor->GetSelectedActors(); | |
TArray<AActor*> Actors; | |
for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter) | |
{ | |
AActor* SelectedActor = Cast<AActor>(*Iter); | |
if (SelectedActor) | |
{ | |
SelectedActor->Destroy(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment