Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
AIEditorFileDialog.h
Go to the documentation of this file.
1/**
2 * @file AIEditorFileDialog.h
3 * @brief Native file dialog wrapper for AI Editor (Phase 1.5)
4 * @author Olympe Engine
5 * @date 2026-02-19
6 *
7 * @details
8 * Provides a simple C++ interface to nativefiledialog-extended library
9 * for opening native OS file dialogs (Windows Explorer, Linux GTK/Qt, macOS Finder).
10 */
11
12#pragma once
13
14#include <string>
15
16namespace Olympe {
17namespace AI {
18
19// Default file extensions for AI graphs
20const char* const DEFAULT_AI_GRAPH_FILTER = "json,btree";
21const char* const DEFAULT_AI_GRAPH_NAME = "new_ai_graph.json";
22const char* const DEFAULT_AI_GRAPH_EXT = ".json";
23
24/**
25 * @class AIEditorFileDialog
26 * @brief Wrapper for native file dialog operations
27 *
28 * @details
29 * Encapsulates NFD (NativeFileDialog-Extended) API calls to provide
30 * a simple C++ interface for opening, saving, and folder selection dialogs.
31 * All methods are static and thread-safe (NFD handles thread initialization).
32 */
34{
35public:
36 /**
37 * @brief Open a native file dialog to select an existing file
38 * @param filterList Comma-separated extensions (e.g., "json,btree")
39 * @param defaultPath Starting directory (optional)
40 * @return Selected file path or empty string if canceled
41 */
42 static std::string OpenFile(
43 const std::string& filterList = "json,btree",
44 const std::string& defaultPath = ""
45 );
46
47 /**
48 * @brief Open a native save file dialog
49 * @param filterList Comma-separated extensions
50 * @param defaultPath Starting directory (optional)
51 * @param defaultName Suggested filename (optional)
52 * @return Selected save path or empty string if canceled
53 */
54 static std::string SaveFile(
55 const std::string& filterList = "json,btree",
56 const std::string& defaultPath = "",
57 const std::string& defaultName = "new_ai_graph.json"
58 );
59
60 /**
61 * @brief Open a native folder selection dialog
62 * @param defaultPath Starting directory (optional)
63 * @return Selected folder path or empty string if canceled
64 */
65 static std::string OpenFolder(const std::string& defaultPath = "");
66
67 /**
68 * @brief Get last error message from NFD
69 * @return Error string or empty if no error
70 */
71 static std::string GetLastError();
72
73private:
74 /**
75 * @brief Convert comma-separated filter list to NFD format
76 * @param filterList "json,btree" -> "json;btree"
77 * @return Converted filter string for NFD
78 */
79 static std::string ConvertFiltersToNFD(const std::string& filterList);
80
81 /**
82 * @brief Convert std::string to native NFD character type
83 * @param str UTF-8 string
84 * @return Platform-specific wide string (Windows) or UTF-8 (Linux/Mac)
85 */
86#ifdef _WIN32
87 static std::wstring ToNFDString(const std::string& str);
88 static std::string FromNFDString(const wchar_t* wstr);
89#else
90 static std::string ToNFDString(const std::string& str);
91 static std::string FromNFDString(const char* str);
92#endif
93};
94
95} // namespace AI
96} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Wrapper for native file dialog operations.
static std::string ConvertFiltersToNFD(const std::string &filterList)
Convert comma-separated filter list to NFD format.
static std::string FromNFDString(const char *str)
static std::string OpenFile(const std::string &filterList="json,btree", const std::string &defaultPath="")
Open a native file dialog to select an existing file.
static std::string ToNFDString(const std::string &str)
Convert std::string to native NFD character type.
static std::string OpenFolder(const std::string &defaultPath="")
Open a native folder selection dialog.
static std::string GetLastError()
Get last error message from NFD.
static std::string SaveFile(const std::string &filterList="json,btree", const std::string &defaultPath="", const std::string &defaultName="new_ai_graph.json")
Open a native save file dialog.
const char *const DEFAULT_AI_GRAPH_NAME
const char *const DEFAULT_AI_GRAPH_FILTER
const char *const DEFAULT_AI_GRAPH_EXT
< Provides AssetID and INVALID_ASSET_ID