|
|
|
|
| #include "LyraCosmeticDeveloperSettings.h"
|
| #include "Cosmetics/LyraCharacterPartTypes.h"
|
| #include "Misc/App.h"
|
| #include "Widgets/Notifications/SNotificationList.h"
|
| #include "Framework/Notifications/NotificationManager.h"
|
| #include "System/LyraDevelopmentStatics.h"
|
| #include "TimerManager.h"
|
| #include "Engine/Engine.h"
|
| #include "LyraControllerComponent_CharacterParts.h"
|
| #include "EngineUtils.h"
|
|
|
| #include UE_INLINE_GENERATED_CPP_BY_NAME(LyraCosmeticDeveloperSettings)
|
|
|
| #define LOCTEXT_NAMESPACE "LyraCheats"
|
|
|
| ULyraCosmeticDeveloperSettings::ULyraCosmeticDeveloperSettings()
|
| {
|
| }
|
|
|
| FName ULyraCosmeticDeveloperSettings::GetCategoryName() const
|
| {
|
| return FApp::GetProjectName();
|
| }
|
|
|
| #if WITH_EDITOR
|
|
|
| void ULyraCosmeticDeveloperSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
| {
|
| Super::PostEditChangeProperty(PropertyChangedEvent);
|
|
|
| ApplySettings();
|
| }
|
|
|
| void ULyraCosmeticDeveloperSettings::PostReloadConfig(FProperty* PropertyThatWasLoaded)
|
| {
|
| Super::PostReloadConfig(PropertyThatWasLoaded);
|
|
|
| ApplySettings();
|
| }
|
|
|
| void ULyraCosmeticDeveloperSettings::PostInitProperties()
|
| {
|
| Super::PostInitProperties();
|
|
|
| ApplySettings();
|
| }
|
|
|
| void ULyraCosmeticDeveloperSettings::ApplySettings()
|
| {
|
| if (GIsEditor && (GEngine != nullptr))
|
| {
|
| ReapplyLoadoutIfInPIE();
|
| }
|
| }
|
|
|
| void ULyraCosmeticDeveloperSettings::ReapplyLoadoutIfInPIE()
|
| {
|
| #if WITH_SERVER_CODE
|
|
|
| UWorld* ServerWorld = ULyraDevelopmentStatics::FindPlayInEditorAuthorityWorld();
|
| if (ServerWorld != nullptr)
|
| {
|
| ServerWorld->GetTimerManager().SetTimerForNextTick(FTimerDelegate::CreateLambda([=]()
|
| {
|
| for (TActorIterator<APlayerController> PCIterator(ServerWorld); PCIterator; ++PCIterator)
|
| {
|
| if (APlayerController* PC = *PCIterator)
|
| {
|
| if (ULyraControllerComponent_CharacterParts* CosmeticComponent = PC->FindComponentByClass<ULyraControllerComponent_CharacterParts>())
|
| {
|
| CosmeticComponent->ApplyDeveloperSettings();
|
| }
|
| }
|
| }
|
| }));
|
| }
|
| #endif
|
| }
|
|
|
| void ULyraCosmeticDeveloperSettings::OnPlayInEditorStarted() const
|
| {
|
|
|
| if (CheatCosmeticCharacterParts.Num() > 0)
|
| {
|
| FNotificationInfo Info(LOCTEXT("CosmeticOverrideActive", "Applying Cosmetic Override"));
|
| Info.ExpireDuration = 2.0f;
|
| FSlateNotificationManager::Get().AddNotification(Info);
|
| }
|
| }
|
|
|
| #endif
|
|
|
| #undef LOCTEXT_NAMESPACE
|
|
|
|
|