Minor Update - Restart In Open Map - V0.2.0

This commit is contained in:
2025-05-15 13:22:05 +02:00
parent 3fc76c1215
commit fd6a726a02
62 changed files with 20661 additions and 10405 deletions

View File

@@ -1,9 +1,9 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "ReloadEditor.h"
#include "FileHelpers.h"
#include "ReloadEditorStyle.h"
#include "ReloadEditorCommands.h"
#include "FileHelpers.h"
#include "Misc/MessageDialog.h"
#include "ToolMenus.h"
#include "Widgets/SBoxPanel.h"
@@ -32,6 +32,21 @@ void FReloadEditorModule::StartupModule()
FCanExecuteAction()
);
FString ReloadMap;
if (FParse::Value(FCommandLine::Get(), TEXT("reloadmap="), ReloadMap) && !ReloadMap.IsEmpty())
{
static bool bMapReloaded = false;
FEditorDelegates::OnMapOpened.AddLambda([ReloadMap](const FString& Filename, bool bAsTemplate)
{
if (!bMapReloaded)
{
bMapReloaded = true;
UE_LOG(LogTemp, Warning, TEXT("ReloadEditor: Forçage d'ouverture de la map: %s"), *ReloadMap);
UEditorLoadingAndSavingUtils::LoadMap(ReloadMap);
}
});
}
UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(this, &FReloadEditorModule::RegisterMenus));
}
@@ -147,10 +162,12 @@ void FReloadEditorModule::PluginButtonClicked()
}
}
UWorld* EditorWorld = GEditor->GetEditorWorldContext().World();
FString CurrentMap = EditorWorld->GetOutermost()->GetName();
FString EditorExe = FPlatformProcess::ExecutablePath();
FString ProjectFile = FPaths::GetProjectFilePath();
FString CmdLine = FString::Printf(TEXT("\"%s\" %s"), *ProjectFile, FCommandLine::Get());
FString MapFilePath = FPackageName::LongPackageNameToFilename(CurrentMap, FPackageName::GetMapPackageExtension());
FString CmdLine = FString::Printf(TEXT("\"%s\" %s -reloadmap=\"%s\""), *ProjectFile, FCommandLine::Get(), *MapFilePath);
FPlatformProcess::CreateProc(*EditorExe, *CmdLine, true, false, false, nullptr, 0, nullptr, nullptr);
FPlatformMisc::RequestExit(false);
}