|
|
|
@@ -3,8 +3,10 @@
|
|
|
|
|
#include "ReloadEditor.h"
|
|
|
|
|
#include "ReloadEditorStyle.h"
|
|
|
|
|
#include "ReloadEditorCommands.h"
|
|
|
|
|
#include "ReloadEditorSettings.h"
|
|
|
|
|
#include "FileHelpers.h"
|
|
|
|
|
#include "Misc/MessageDialog.h"
|
|
|
|
|
#include "Misc/ConfigCacheIni.h"
|
|
|
|
|
#include "ToolMenus.h"
|
|
|
|
|
#include "Widgets/SBoxPanel.h"
|
|
|
|
|
#include "Widgets/Input/SButton.h"
|
|
|
|
@@ -32,6 +34,9 @@ void FReloadEditorModule::StartupModule()
|
|
|
|
|
FCanExecuteAction()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Initialiser l'objet de configuration
|
|
|
|
|
Settings = GetMutableDefault<UReloadEditorSettings>();
|
|
|
|
|
|
|
|
|
|
FString ReloadMap;
|
|
|
|
|
if (FParse::Value(FCommandLine::Get(), TEXT("reloadmap="), ReloadMap) && !ReloadMap.IsEmpty())
|
|
|
|
|
{
|
|
|
|
@@ -47,6 +52,9 @@ void FReloadEditorModule::StartupModule()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("bAutoSaveBeforeReload = %s"), Settings->bAutoSaveBeforeReload ? TEXT("true") : TEXT("false"));
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("bAutoReloadLastMap = %s"), Settings->bAutoReloadLastMap ? TEXT("true") : TEXT("false"));
|
|
|
|
|
|
|
|
|
|
UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(this, &FReloadEditorModule::RegisterMenus));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -132,9 +140,32 @@ TSharedRef<SWidget> FReloadEditorModule::CreateReloadButton()
|
|
|
|
|
TAttribute<FText>(),
|
|
|
|
|
FSlateIcon(),
|
|
|
|
|
FUIAction(
|
|
|
|
|
FExecuteAction::CreateLambda([this]() { bAutoSaveBeforeReload = !bAutoSaveBeforeReload; }),
|
|
|
|
|
FExecuteAction::CreateLambda([this]() {
|
|
|
|
|
Settings->bAutoSaveBeforeReload = !Settings->bAutoSaveBeforeReload;
|
|
|
|
|
Settings->SaveConfig();
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("Option changée: bAutoSaveBeforeReload = %s"),
|
|
|
|
|
Settings->bAutoSaveBeforeReload ? TEXT("true") : TEXT("false"));
|
|
|
|
|
}),
|
|
|
|
|
FCanExecuteAction(),
|
|
|
|
|
FIsActionChecked::CreateLambda([this]() { return bAutoSaveBeforeReload; })
|
|
|
|
|
FIsActionChecked::CreateLambda([this]() { return Settings->bAutoSaveBeforeReload; })
|
|
|
|
|
),
|
|
|
|
|
NAME_None,
|
|
|
|
|
EUserInterfaceActionType::ToggleButton
|
|
|
|
|
);
|
|
|
|
|
// Ajoute la nouvelle option ici
|
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
|
|
|
LOCTEXT("AutoReloadLastMapOption", "Reload automatique dans la dernière map ouverte"),
|
|
|
|
|
TAttribute<FText>(),
|
|
|
|
|
FSlateIcon(),
|
|
|
|
|
FUIAction(
|
|
|
|
|
FExecuteAction::CreateLambda([this]() {
|
|
|
|
|
Settings->bAutoReloadLastMap = !Settings->bAutoReloadLastMap;
|
|
|
|
|
Settings->SaveConfig();
|
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("Option changée: bAutoReloadLastMap = %s"),
|
|
|
|
|
Settings->bAutoReloadLastMap ? TEXT("true") : TEXT("false"));
|
|
|
|
|
}),
|
|
|
|
|
FCanExecuteAction(),
|
|
|
|
|
FIsActionChecked::CreateLambda([this]() { return Settings->bAutoReloadLastMap; })
|
|
|
|
|
),
|
|
|
|
|
NAME_None,
|
|
|
|
|
EUserInterfaceActionType::ToggleButton
|
|
|
|
@@ -146,7 +177,7 @@ TSharedRef<SWidget> FReloadEditorModule::CreateReloadButton()
|
|
|
|
|
|
|
|
|
|
void FReloadEditorModule::PluginButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
if (bAutoSaveBeforeReload)
|
|
|
|
|
if (Settings->bAutoSaveBeforeReload)
|
|
|
|
|
{
|
|
|
|
|
FEditorFileUtils::SaveDirtyPackages(true, true, true, false, false, false);
|
|
|
|
|
}
|
|
|
|
@@ -154,7 +185,7 @@ void FReloadEditorModule::PluginButtonClicked()
|
|
|
|
|
TArray<UPackage*> DirtyPackages;
|
|
|
|
|
FEditorFileUtils::GetDirtyPackages(DirtyPackages);
|
|
|
|
|
|
|
|
|
|
if (!bAutoSaveBeforeReload && DirtyPackages.Num() > 0)
|
|
|
|
|
if (!Settings->bAutoSaveBeforeReload && DirtyPackages.Num() > 0)
|
|
|
|
|
{
|
|
|
|
|
if (FMessageDialog::Open(EAppMsgType::YesNo, FText::FromString(TEXT("Des fichiers non sauvegardés existent. Voulez-vous vraiment redémarrer ?"))) != EAppReturnType::Yes)
|
|
|
|
|
{
|
|
|
|
@@ -162,12 +193,22 @@ void FReloadEditorModule::PluginButtonClicked()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UWorld* EditorWorld = GEditor->GetEditorWorldContext().World();
|
|
|
|
|
FString CurrentMap = EditorWorld->GetOutermost()->GetName();
|
|
|
|
|
FString EditorExe = FPlatformProcess::ExecutablePath();
|
|
|
|
|
FString ProjectFile = FPaths::GetProjectFilePath();
|
|
|
|
|
FString MapFilePath = FPackageName::LongPackageNameToFilename(CurrentMap, FPackageName::GetMapPackageExtension());
|
|
|
|
|
FString CmdLine = FString::Printf(TEXT("\"%s\" %s -reloadmap=\"%s\""), *ProjectFile, FCommandLine::Get(), *MapFilePath);
|
|
|
|
|
FString CmdLine;
|
|
|
|
|
|
|
|
|
|
if (Settings->bAutoReloadLastMap)
|
|
|
|
|
{
|
|
|
|
|
UWorld* EditorWorld = GEditor->GetEditorWorldContext().World();
|
|
|
|
|
FString CurrentMap = EditorWorld->GetOutermost()->GetName();
|
|
|
|
|
FString MapFilePath = FPackageName::LongPackageNameToFilename(CurrentMap, FPackageName::GetMapPackageExtension());
|
|
|
|
|
CmdLine = FString::Printf(TEXT("\"%s\" %s -reloadmap=\"%s\""), *ProjectFile, FCommandLine::Get(), *MapFilePath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CmdLine = FString::Printf(TEXT("\"%s\" %s"), *ProjectFile, FCommandLine::Get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FPlatformProcess::CreateProc(*EditorExe, *CmdLine, true, false, false, nullptr, 0, nullptr, nullptr);
|
|
|
|
|
FPlatformMisc::RequestExit(false);
|
|
|
|
|
}
|
|
|
|
|