Files
UnrealEngineUWP/Engine/Plugins/Experimental/Mutable/Source/CustomizableObject/Private/MuCO/CustomizableObjectDGGUI.cpp
ricard rovira 7274b1a888 [mutable] Resubmit fixed version of "Enable open DGGUI command to work even in packaged builds, as long as they are not Shipping config"
#preflight 6437d107d03b1c87dd02f72f
#rnx

[CL 25082418 by ricard rovira in ue5-main branch]
2023-04-18 04:26:00 -04:00

57 lines
1.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MuCO/CustomizableObjectDGGUI.h"
#include "Kismet/GameplayStatics.h"
#include "UObject/UObjectIterator.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(CustomizableObjectDGGUI)
void UDGGUI::OpenDGGUI(const int32 SlotID, UCustomizableSkeletalComponent* SelectedCustomizableSkeletalComponent, const UWorld* CurrentWorld, const int32 PlayerIndex)
{
#if !UE_BUILD_SHIPPING
if (APlayerController* Player = UGameplayStatics::GetPlayerController(CurrentWorld, PlayerIndex))
{
FSoftClassPath DGUIPath(TEXT("/Mutable/UI/DynamicallyGeneratedGUI_DGGUI/DynamicallyGeneratedGUI_DGGUI.DynamicallyGeneratedGUI_DGGUI_C"));
if (UClass* DGUI = DGUIPath.TryLoadClass<UDGGUI>())
{
UDGGUI* WDGUI = CreateWidget<UDGGUI>(Player, DGUI);
if (WDGUI)
{
WDGUI->SetCustomizableSkeletalComponent(SelectedCustomizableSkeletalComponent);
WDGUI->AddToViewport();
Player->SetShowMouseCursor(true);
}
}
}
#endif // !UE_BUILD_SHIPPING
}
bool UDGGUI::CloseExistingDGGUI(const UWorld* CurrentWorld)
{
#if !UE_BUILD_SHIPPING
bool bClosing = false;
for (TObjectIterator<UDGGUI> PreviousGUI; PreviousGUI; ++PreviousGUI)
{
if (PreviousGUI->IsValidLowLevel())
{
if (UCustomizableSkeletalComponent* CustomizableComponent = PreviousGUI->GetCustomizableSkeletalComponent())
{
PreviousGUI->SetCustomizableSkeletalComponent(nullptr);
bClosing = true;
}
PreviousGUI->RemoveFromParent();
}
}
if (bClosing)
{
if (APlayerController* Player = UGameplayStatics::GetPlayerController(CurrentWorld, 0))
{
Player->SetShowMouseCursor(false);
}
return true;
}
#endif // !UE_BUILD_SHIPPING
return false;
}