File tree Expand file tree Collapse file tree
OvEditor/src/OvEditor/Core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ namespace OvCore::Helpers
6262 using PickerProviderCallback = std::function<void (PickerItemList, std::string)>;
6363 using IconProviderCallback = std::function<uint32_t (OvTools::Utils::PathParser::EFileType)>;
6464 using ActorSelectionProviderCallback = std::function<void (uint64_t )>;
65+ using AssetExistsCallback = std::function<bool (const std::string&)>;
6566
6667 static void ProvideEmptyTexture (OvRendering::Resources::Texture& p_emptyTexture);
6768 static OvRendering::Resources::Texture* GetEmptyTexture ();
@@ -89,5 +90,8 @@ namespace OvCore::Helpers
8990
9091 static void SetActorSelectionProvider (ActorSelectionProviderCallback p_provider);
9192 static void SelectActor (uint64_t p_guid);
93+
94+ static void SetAssetExistsChecker (AssetExistsCallback p_checker);
95+ static bool AssetExists (const std::string& p_path);
9296 };
9397}
Original file line number Diff line number Diff line change @@ -170,8 +170,13 @@ void OvCore::Helpers::GUIDrawer::DrawColor(OvUI::Internal::WidgetContainer & p_r
170170
171171std::string OvCore::Helpers::GUIDrawer::GetAssetDisplayName (const std::string& p_path)
172172{
173+ if (p_path.empty ())
174+ return " " ;
173175 const std::string friendly = OvTools::Utils::PathParser::GetFriendlyPath (p_path);
174- return friendly.empty () ? " " : std::filesystem::path (friendly).stem ().string ();
176+ const std::string stem = friendly.empty () ? " " : std::filesystem::path (friendly).stem ().string ();
177+ if (!GUIHelpers::AssetExists (p_path))
178+ return stem.empty () ? " (Missing Reference)" : stem + " (Missing Reference)" ;
179+ return stem;
175180}
176181
177182std::string OvCore::Helpers::GUIDrawer::GetAssetTooltip (const std::string& p_path)
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ namespace
1616 OvCore::Helpers::GUIHelpers::IconProviderCallback __ICON_PROVIDER;
1717 OvCore::Helpers::GUIHelpers::OpenProviderCallback __OPEN_PROVIDER;
1818 OvCore::Helpers::GUIHelpers::ActorSelectionProviderCallback __ACTOR_SELECTION_PROVIDER;
19+ OvCore::Helpers::GUIHelpers::AssetExistsCallback __ASSET_EXISTS_CHECKER;
1920 uint32_t __ACTOR_ICON_ID = 0 ;
2021
2122 std::string TitleFromFileType (OvTools::Utils::PathParser::EFileType p_type)
@@ -122,3 +123,13 @@ void OvCore::Helpers::GUIHelpers::SelectActor(uint64_t p_guid)
122123 if (__ACTOR_SELECTION_PROVIDER)
123124 __ACTOR_SELECTION_PROVIDER (p_guid);
124125}
126+
127+ void OvCore::Helpers::GUIHelpers::SetAssetExistsChecker (AssetExistsCallback p_checker)
128+ {
129+ __ASSET_EXISTS_CHECKER = std::move (p_checker);
130+ }
131+
132+ bool OvCore::Helpers::GUIHelpers::AssetExists (const std::string& p_path)
133+ {
134+ return __ASSET_EXISTS_CHECKER && __ASSET_EXISTS_CHECKER (p_path);
135+ }
Original file line number Diff line number Diff line change 77#include " OvEditor/Core/EditorActions.h"
88#include < tracy/Tracy.hpp>
99
10+ #include < filesystem>
11+
1012#include < OvCore/Helpers/GUIDrawer.h>
1113#include < OvCore/Helpers/GUIHelpers.h>
1214
@@ -137,6 +139,14 @@ void OvEditor::Core::Editor::SetupUI()
137139 if (auto * actorTexture = m_context.editorResources ->GetTexture (" Actor" ))
138140 OvCore::Helpers::GUIHelpers::SetActorIconID (actorTexture->GetTexture ().GetID ());
139141
142+ // Provide asset existence checker so AssetFields show "(Missing Reference)" for invalid paths.
143+ OvCore::Helpers::GUIHelpers::SetAssetExistsChecker (
144+ [this ](const std::string& p_path)
145+ {
146+ return std::filesystem::exists (m_editorActions.GetRealPath (p_path));
147+ }
148+ );
149+
140150 // Provide actor selection so double-clicking an ActorField selects it in the inspector.
141151 OvCore::Helpers::GUIHelpers::SetActorSelectionProvider (
142152 [this ](uint64_t p_guid)
You can’t perform that action at this time.
0 commit comments