From aafcbbb7f98b42958a0465c5dd87c7b878a5576c Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Sun, 12 Apr 2026 12:01:43 +0200 Subject: [PATCH] Add BaseLevelNameOverride for dedicated editor maps PlayerController gets a BaseLevelNameOverride property. When set (e.g. "Warehouse"), scenes are tagged with that level name instead of the auto-detected map name. Use case: editing on "Warehouse_Editor" map but scenes should be associated with the "Warehouse" base level for PROSERVE runtime loading. Save, load list, and scene filtering all respect this override. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../PS_Editor/GameMode/PS_Editor_PlayerController.h | 9 +++++++++ .../Serialization/PS_Editor_SceneSerializer.cpp | 11 ++++++++--- .../PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp | 10 +++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Unreal/Plugins/PS_Editor/Source/PS_Editor/GameMode/PS_Editor_PlayerController.h b/Unreal/Plugins/PS_Editor/Source/PS_Editor/GameMode/PS_Editor_PlayerController.h index 1d80762..8beda42 100644 --- a/Unreal/Plugins/PS_Editor/Source/PS_Editor/GameMode/PS_Editor_PlayerController.h +++ b/Unreal/Plugins/PS_Editor/Source/PS_Editor/GameMode/PS_Editor_PlayerController.h @@ -42,6 +42,15 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PS Editor") TSoftObjectPtr MasterCatalogAsset; + /** + * Override the level name stored in saved scenes. + * If empty, auto-detected from the current map name. + * Use this when editing on a dedicated map (e.g. "Warehouse_Editor") + * but scenes should be associated with the base level ("Warehouse"). + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PS Editor") + FString BaseLevelNameOverride; + // ---- Editor Mode (Normal / SplinePlacement) ---- UFUNCTION(BlueprintCallable, Category = "PS Editor") diff --git a/Unreal/Plugins/PS_Editor/Source/PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp b/Unreal/Plugins/PS_Editor/Source/PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp index 40be6c3..81cc2d2 100644 --- a/Unreal/Plugins/PS_Editor/Source/PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp +++ b/Unreal/Plugins/PS_Editor/Source/PS_Editor/Serialization/PS_Editor_SceneSerializer.cpp @@ -2,6 +2,7 @@ #include "PS_Editor_SpawnManager.h" #include "PS_Editor_SelectionManager.h" #include "PS_Editor_EditableComponent.h" +#include "PS_Editor_PlayerController.h" #include "PS_Editor_SplineActor.h" #include "JsonObjectConverter.h" #include "Misc/FileHelper.h" @@ -22,10 +23,14 @@ bool UPS_Editor_SceneSerializer::SaveScene(const FString& SceneName, UPS_Editor_ SceneData.SceneName = SceneName; SceneData.Timestamp = FDateTime::Now().ToString(); - // Auto-detect the current level name - if (APlayerController* PC = Cast(GetOuter())) + // Use BaseLevelNameOverride if set, otherwise auto-detect from map name + if (APS_Editor_PlayerController* EditorPC = Cast(GetOuter())) { - if (UWorld* World = PC->GetWorld()) + if (!EditorPC->BaseLevelNameOverride.IsEmpty()) + { + SceneData.LevelName = EditorPC->BaseLevelNameOverride; + } + else if (UWorld* World = EditorPC->GetWorld()) { SceneData.LevelName = World->GetMapName(); SceneData.LevelName.RemoveFromStart(World->StreamingLevelsPrefix); diff --git a/Unreal/Plugins/PS_Editor/Source/PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp b/Unreal/Plugins/PS_Editor/Source/PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp index 24fec77..118cee8 100644 --- a/Unreal/Plugins/PS_Editor/Source/PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp +++ b/Unreal/Plugins/PS_Editor/Source/PS_Editor/UI/Widgets/PS_Editor_MainWidget.cpp @@ -570,11 +570,15 @@ void UPS_Editor_MainWidget::PopulateSceneList() UPS_Editor_SceneSerializer* Ser = SceneSerializer.Get(); if (!Ser) return; - // Get current level name for filtering + // Get current level name for filtering (use override if set) FString CurrentLevel; - if (APlayerController* PC = GetOwningPlayer()) + if (APS_Editor_PlayerController* EditorPC = Cast(GetOwningPlayer())) { - if (UWorld* World = PC->GetWorld()) + if (!EditorPC->BaseLevelNameOverride.IsEmpty()) + { + CurrentLevel = EditorPC->BaseLevelNameOverride; + } + else if (UWorld* World = EditorPC->GetWorld()) { CurrentLevel = World->GetMapName(); CurrentLevel.RemoveFromStart(World->StreamingLevelsPrefix);