Polyphase Game Engine
Loading...
Searching...
No Matches
FileDropImportModal.h
Go to the documentation of this file.
1#pragma once
2
3#include "Engine.h"
4
5#if EDITOR
6
7#include <string>
8#include <vector>
9
10class AssetDir;
11
12// Modal that fires when the OS drops files on the editor window. Per-row, the
13// user picks how the file is imported:
14//
15// Asset -- routes through ActionManager::ImportAsset (so name-clash,
16// non-POT, mesh-mode, and addon-extension flows still fire).
17// LooseFile -- routes through ActionManager::ImportLooseFile (verbatim copy
18// into the current asset directory; readable from Lua via
19// Stream:ReadFile and from native code via SYS_AcquireFileData).
20// Skip -- discards the row, no side effects.
21//
22// The Asset choice is disabled for files with no recognized asset-importer
23// extension; those default to LooseFile.
24class FileDropImportModal
25{
26public:
27
28 enum class Choice
29 {
30 Unresolved,
31 Asset,
32 LooseFile,
33 Skip,
34 };
35
36 struct PendingDrop
37 {
38 std::string mSourcePath; // absolute path from the drop
39 std::string mFilename; // basename with extension
40 std::string mExtension; // lower-cased, includes leading '.'
41 std::string mDetectedTypeName; // "Texture" / "Mesh" / addon name / "(unknown)"
42 bool mCanImportAsAsset = false;
43 bool mIsMeshExtension = false; // queue via mPendingMeshImportPaths
44 Choice mChoice = Choice::Unresolved;
45 bool mResolved = false;
46 };
47
48 static FileDropImportModal* Get();
49
50 // Called once per frame from the editor main loop with whatever the OS
51 // produced this frame. No-op if `paths` is empty.
52 void EnqueueDroppedPaths(const std::vector<std::string>& paths);
53
54 bool HasPending() const { return !mRows.empty(); }
55
56 void Reset();
57
58 void Draw();
59
60private:
61
62 FileDropImportModal() = default;
63
64 void ApplyRow(PendingDrop& row);
65
66 std::vector<PendingDrop> mRows;
67 AssetDir* mTargetDir = nullptr; // captured when the modal first opens
68 bool mModalRequested = false;
69};
70
71#endif // EDITOR
Definition AssetDir.h:11
Definition Asset.h:119