Polyphase Game Engine
Loading...
Searching...
No Matches
AssetFixupModal.h
Go to the documentation of this file.
1#pragma once
2
3#include "Engine.h"
4
5#if EDITOR
6
7#include "AssetRef.h"
8#include "Nodes/Node.h"
9
10#include <string>
11#include <vector>
12
13// Post-load scan that catches widgets whose Asset-typed properties were
14// bound to the wrong-type asset (e.g. a Texture slot pointing at a
15// StaticMesh because the user imported a mesh with a name that collided
16// with an existing texture). The import-clash modal in EditorImgui prevents
17// new collisions, but already-saved scenes need this fixup. Surfaced as a
18// modal at scene-open with a per-row picker so the user can rebind to a
19// valid asset, clear the slot, or skip and investigate.
20class AssetFixupModal
21{
22public:
23
24 struct BrokenAssetRef
25 {
26 WeakPtr<Node> mNode;
27 std::string mNodeDisplayName; // captured at scan time so the row still has a label after teardown
28 std::string mPropName;
29 TypeId mExpectedType = 0;
30 std::string mExpectedTypeName;
31 Asset* mCurrentAsset = nullptr;
32 std::string mCurrentAssetName;
33 std::string mCurrentTypeName;
34 AssetRef mPickedReplacement;
35 bool mResolved = false; // true once Apply/Clear has fired -- row sticks around for the user to read until Close
36 };
37
38 static AssetFixupModal* Get();
39
40 // Walk the freshly-instantiated widget subtree and enqueue any
41 // Asset-typed widget property whose binding fails its type filter
42 // (mAsset non-null but doesn't pass Is(expectedType)).
43 void ScanWidgetTree(Node* root);
44
45 bool HasPending() const { return !mBrokenRefs.empty(); }
46
47 // Call from EditorImguiDraw every frame.
48 void Draw();
49
50private:
51
52 AssetFixupModal() = default;
53
54 void ApplyRow(BrokenAssetRef& row, Asset* newAsset);
55
56 std::vector<BrokenAssetRef> mBrokenRefs;
57 bool mModalRequested = false;
58};
59
60#endif
uint32_t TypeId
Definition EngineTypes.h:71
Definition AssetRef.h:18
Definition Asset.h:119
Definition Node.h:67
Definition SmartPointer.h:312