Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
SubGraphFilePickerModal.h
Go to the documentation of this file.
1/**
2 * @file SubGraphFilePickerModal.h
3 * @brief ImGui modal for selecting SubGraph files (Phase 26).
4 * @author Olympe Engine
5 * @date 2026-03-10
6 *
7 * Provides a file browser dialog for users to select .json blueprint files
8 * to use as SubGraph nodes. Follows the same pattern as SwitchCaseEditorModal:
9 * copy-on-open, confirm to apply, cancel to discard.
10 */
11
12#pragma once
13
14#include <string>
15#include <vector>
16
17namespace Olympe {
18
19/**
20 * @class SubGraphFilePickerModal
21 * @brief ImGui modal dialog for selecting SubGraph blueprint files.
22 *
23 * Usage:
24 * 1. Call Open(currentPath) to initialize and show modal
25 * 2. Call Render() each frame (returns true if still open)
26 * 3. Check IsConfirmed() after close to see if user applied changes
27 * 4. Call GetSelectedFile() to get the chosen file path
28 * 5. Call Close() to dismiss modal
29 */
31public:
34
35 // ====================================================================
36 // Modal Lifecycle
37 // ====================================================================
38
39 /**
40 * @brief Opens the modal with optional initial path.
41 * @param currentPath If non-empty, shows this path as selected initially
42 */
43 void Open(const std::string& currentPath = "");
44
45 /**
46 * @brief Closes the modal without confirming changes.
47 */
48 void Close();
49
50 /**
51 * @brief Renders the modal UI. Call every frame while modal is open.
52 */
53 void Render();
54
55 // ====================================================================
56 // Query Results
57 // ====================================================================
58
59 /**
60 * @brief Returns true if modal is currently visible.
61 */
62 bool IsOpen() const { return m_isOpen; }
63
64 /**
65 * @brief Returns true if user clicked "Select" button.
66 * Call this after modal closes to check if changes should be applied.
67 */
68 bool IsConfirmed() const { return m_confirmed; }
69
70 /**
71 * @brief Returns the selected file path (only valid if IsConfirmed() is true).
72 */
73 const std::string& GetSelectedFile() const { return m_selectedFile; }
74
75private:
76 // ====================================================================
77 // Modal State
78 // ====================================================================
79
80 bool m_isOpen = false; ///< Is modal currently displayed
81 bool m_confirmed = false; ///< Did user click Select button
82 std::string m_selectedFile = ""; ///< The file path user selected
83 std::string m_currentPath = ""; ///< Current browse directory
84
85 // ====================================================================
86 // File Listing State
87 // ====================================================================
88
89 std::vector<std::string> m_blueprintFiles; ///< .json files in current directory
90 int m_selectedIndex = -1; ///< Currently highlighted file (-1 = none)
91
92 // ====================================================================
93 // UI State
94 // ====================================================================
95
96 char m_pathBuffer[512] = ""; ///< Directory path input buffer
97 char m_searchBuffer[128] = ""; ///< Search filter text
98
99 // ====================================================================
100 // Helper Methods
101 // ====================================================================
102
103 /**
104 * @brief Scans current directory for .json blueprint files.
105 * Populates m_blueprintFiles with file names.
106 */
107 void RefreshFileList();
108
109 /**
110 * @brief Renders the file list with scrolling support.
111 */
112 void RenderFileList();
113
114 /**
115 * @brief Renders action buttons (Select, Cancel).
116 */
117 void RenderActionButtons();
118
119 /**
120 * @brief Filters file list by search term.
121 * @return Filtered file list
122 */
123 std::vector<std::string> GetFilteredFiles() const;
124};
125
126} // namespace Olympe
ImGui modal dialog for selecting SubGraph blueprint files.
void RenderFileList()
Renders the file list with scrolling support.
void Open(const std::string &currentPath="")
Opens the modal with optional initial path.
std::vector< std::string > GetFilteredFiles() const
Filters file list by search term.
void RefreshFileList()
Scans current directory for .json blueprint files.
void Close()
Closes the modal without confirming changes.
int m_selectedIndex
Currently highlighted file (-1 = none)
bool IsConfirmed() const
Returns true if user clicked "Select" button.
bool m_isOpen
Is modal currently displayed.
std::string m_selectedFile
The file path user selected.
bool IsOpen() const
Returns true if modal is currently visible.
std::vector< std::string > m_blueprintFiles
.json files in current directory
void RenderActionButtons()
Renders action buttons (Select, Cancel).
bool m_confirmed
Did user click Select button.
char m_searchBuffer[128]
Search filter text.
const std::string & GetSelectedFile() const
Returns the selected file path (only valid if IsConfirmed() is true).
std::string m_currentPath
Current browse directory.
char m_pathBuffer[512]
Directory path input buffer.
< Provides AssetID and INVALID_ASSET_ID