Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat: Add project creation and file dialog support

esenginedba38b49d17b
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f3118d5b..04f441bfc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -172,6 +172,7 @@ else()
list(APPEND ESENGINE_SOURCES
src/esengine/platform/native/NativePlatform.cpp
src/esengine/platform/native/NativeFileSystem.cpp
+ src/esengine/platform/FileDialog.cpp
# Scripting (Native only - Web uses Emscripten bindings)
src/esengine/scripting/ScriptContext.cpp
src/esengine/scripting/ScriptValue.cpp
@@ -194,6 +195,7 @@ endif()
# Platform-independent headers
list(APPEND ESENGINE_HEADERS
src/esengine/platform/FileSystem.hpp
+ src/esengine/platform/FileDialog.hpp
src/esengine/core/Reflection.hpp
)
diff --git a/src/esengine/editor/CMakeLists.txt b/src/esengine/editor/CMakeLists.txt
index 503416d92..40da11695 100644
--- a/src/esengine/editor/CMakeLists.txt
+++ b/src/esengine/editor/CMakeLists.txt
@@ -30,6 +30,7 @@ set(EDITOR_SOURCES
panels/AssetBrowserPanel.cpp
panels/AssetGridItem.cpp
panels/ProjectLauncherPanel.cpp
+ panels/NewProjectDialog.cpp
)
set(EDITOR_HEADERS
@@ -75,6 +76,7 @@ set(EDITOR_HEADERS
panels/AssetBrowserTypes.hpp
panels/AssetGridItem.hpp
panels/ProjectLauncherPanel.hpp
+ panels/NewProjectDialog.hpp
)
# Create editor executable
diff --git a/src/esengine/editor/EditorApplication.cpp b/src/esengine/editor/EditorApplication.cpp
index e35738521..b6c2720dd 100644
--- a/src/esengine/editor/EditorApplication.cpp
+++ b/src/esengine/editor/EditorApplication.cpp
@@ -29,6 +29,8 @@
#include "panels/SceneViewPanel.hpp"
#include "panels/AssetBrowserPanel.hpp"
#include "panels/ProjectLauncherPanel.hpp"
+#include "panels/NewProjectDialog.hpp"
+#include "../platform/FileDialog.hpp"
namespace esengine {
namespace editor {
@@ -436,6 +438,10 @@ void EditorApplication::setupLauncherLayout() {
mode_ = EditorMode::Launcher;
+ auto container = makeUnique<ui::Panel>(ui::WidgetId("editor.launcher_container"));
+ container->setWidth(ui::SizeValue::percent(100.0f));
+ container->setHeight(ui::SizeValue::percent(100.0f));
+
auto launcherPanel = makeUnique<ProjectLauncherPanel>(
ui::WidgetId("editor.launcher"),
*projectManager_,
@@ -463,7 +469,31 @@ void EditorApplication::setupLauncherLayout() {
}
}));
- uiContext_->setRoot(std::move(launcherPanel));
+ container->addChild(std::move(launcherPanel));
+
+ auto newProjectDialog = makeUnique<NewProjectDialog>(ui::WidgetId("editor.new_project_dialog"));
+ newProjectDialog_ = newProjectDialog.get();
+ newProjectDialog_->hide();
+
+ eventConnections_.add(
+ sink(newProjectDialog_->onProjectCreate).connect([this](const std::string& name, const std::string& path) {
+ ES_LOG_INFO("Creating project '{}' at {}", name, path);
+ auto result = projectManager_->createProject(path, name);
+ if (result.isOk()) {
+ showEditor();
+ } else {
+ ES_LOG_ERROR("Failed to create project: {}", result.error());
+ }
+ }));
+
+ eventConnections_.add(
+ sink(newProjectDialog_->onCancel).connect([this]() {
+ ES_LOG_DEBUG("New project dialog cancelled");
+ }));
+
+ container->addChild(std::move(newProjectDialog));
+
+ uiContext_->setRoot(std::move(container));
ES_LOG_INFO("Launcher layout initialized");
}
@@ -499,11 +529,32 @@ void EditorApplication::showEditor() {
}
void EditorApplication::onNewProjectRequested() {
- ES_LOG_INFO("New project requested - TODO: Show project creation dialog");
+ ES_LOG_INFO("New project requested");
+ if (newProjectDialog_) {
+ newProjectDialog_->show();
+ }
}
void EditorApplication::onOpenProjectRequested() {
- ES_LOG_INFO("Open project requested - TODO: Show file browser dialog");
+ ES_LOG_INFO("Open project requested");
+
+ std::string projectFile = FileDialog::openFile(
+ "Open Project",
+ {{.name = "ESEngine Project", .pattern = "*.esproject"}});
+
+ if (projectFile.empty()) {
+ ES_LOG_DEBUG("Open project cancelled");
+ return;
+ }
+
+ ES_LOG_INFO("Opening project: {}", projectFile);
+
+ auto result = projectManager_->openProject(projectFile);
+ if (result.isOk()) {
+ showEditor();
+ } else {
+ ES_LOG_ERROR("Failed to open project: {}", result.error());
+ }
}
} // namespace editor
diff --git a/src/esengine/editor/EditorApplication.hpp b/src/esengine/editor/EditorApplication.hpp
index 779d8369c..365161a8a 100644
--- a/src/esengine/editor/EditorApplication.hpp
+++ b/src/esengine/editor/EditorApplication.hpp
@@ -33,6 +33,7 @@ namespace esengine {
namespace editor {
class ProjectLauncherPanel;
+class NewProjectDialog;
// =============================================================================
// Editor Mode
@@ -268,6 +269,7 @@ private:
Unique<ui::UIContext> uiContext_; ///< UI system context
ui::DockArea* dockArea_ = nullptr; ///< Main docking area (owned by UIContext)
ProjectLauncherPanel* launcherPanel_ = nullptr; ///< Launcher panel (owned by UIContext)
+ NewProjectDialog* newProjectDialog_ = nullptr; ///< New project dialog
// =========================================================================
// State
diff --git a/src/esengine/editor/panels/NewProjectDialog.cpp b/src/esengine/editor/panels/NewProjectDialog.cpp
new file mode 100644
index 000000000..50dff4ecd
--- /dev/null
+++ b/src/esengine/editor/panels/NewProjectDialog.cpp
@@ -0,0 +1,220 @@
+/**
+ * @file NewProjectDialog.cpp
+ * @brief Dialog for creating new projects implementation
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
+
+#include "NewProjectDialog.hpp"
+#include "../../ui/widgets/Button.hpp"
+#include "../../ui/widgets/Label.hpp"
+#include "../../ui/widgets/TextField.hpp"
+#include "../../ui/widgets/Panel.hpp"
+#include "../../ui/layout/StackLayout.hpp"
+#include "../../ui/rendering/UIBatchRenderer.hpp"
+#include "../../platform/FileDialog.hpp"
+#include "../../events/Sink.hpp"
+#include "../../core/Log.hpp"
+
+namespace esengine::editor {
+
+// =============================================================================
+// Constructor / Destructor
+// =============================================================================
+
+NewProjectDialog::NewProjectDialog(const ui::WidgetId& id)
+ : Widget(id) {
+ setupUI();
+}
+
+NewProjectDialog::~NewProjectDialog() = default;
+
+// =============================================================================
+// Setup
+// =============================================================================
+
+void NewProjectDialog::setupUI() {
+ auto dialogPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".dialog"));
+ dialogPanel->setBackgroundColor(glm::vec4(0.2f, 0.2f, 0.2f, 1.0f));
+ dialogPanel->setCornerRadii(ui::CornerRadii::all(8.0f));
+ dialogPanel->setWidth(ui::SizeValue::px(450.0f));
+ dialogPanel->setHeight(ui::SizeValue::px(280.0f));
+
+ auto layout = makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 16.0f);
+ dialogPanel->setLayout(std::move(layout));
+ dialogPanel->setPadding(ui::Insets(24.0f, 24.0f, 24.0f, 24.0f));
+
+ auto titleLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".title"), "New Project");
+ titleLabel->setFontSize(24.0f);
+ titleLabel->setColor(glm::vec4(1.0f));
+ titleLabel_ = titleLabel.get();
+ dialogPanel->addChild(std::move(titleLabel));
+
+ auto nameLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".name_label"), "Project Name");
+ nameLabel->setFontSize(14.0f);
+ nameLabel->setColor(glm::vec4(0.8f, 0.8f, 0.8f, 1.0f));
+ nameLabel_ = nameLabel.get();
+ dialogPanel->addChild(std::move(nameLabel));
+
+ auto nameField = makeUnique<ui::TextField>(ui::WidgetId(getId().path + ".name_field"));
+ nameField->setPlaceholder("MyGame");
+ nameField->setWidth(ui::SizeValue::percent(100.0f));
+ nameField->setHeight(ui::SizeValue::px(36.0f));
+ nameField_ = nameField.get();
+ dialogPanel->addChild(std::move(nameField));
+
+ auto pathLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".path_label"), "Location");
+ pathLabel->setFontSize(14.0f);
+ pathLabel->setColor(glm::vec4(0.8f, 0.8f, 0.8f, 1.0f));
+ pathLabel_ = pathLabel.get();
+ dialogPanel->addChild(std::move(pathLabel));
+
+ auto pathRow = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".path_row"));
+ auto pathRowLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Horizontal, 8.0f);
+ pathRow->setLayout(std::move(pathRowLayout));
+ pathRow->setWidth(ui::SizeValue::percent(100.0f));
+ pathRow->setHeight(ui::SizeValue::px(36.0f));
+
+ auto pathField = makeUnique<ui::TextField>(ui::WidgetId(getId().path + ".path_field"));
+ pathField->setPlaceholder("Select folder...");
+ pathField->setWidth(ui::SizeValue::px(320.0f));
+ pathField->setHeight(ui::SizeValue::px(36.0f));
+ pathField_ = pathField.get();
+ pathRow->addChild(std::move(pathField));
+
+ auto browseButton = makeUnique<ui::Button>(ui::WidgetId(getId().path + ".browse"), "Browse");
+ browseButton->setButtonStyle(ui::ButtonStyle::Secondary);
+ browseButton->setWidth(ui::SizeValue::px(80.0f));
+ browseButton->setHeight(ui::SizeValue::px(36.0f));
+ browseButton_ = browseButton.get();
+ connections_.push_back(
+ sink(browseButton_->onClick).connect([this]() { onBrowseClicked(); }));
+ pathRow->addChild(std::move(browseButton));
+
+ dialogPanel->addChild(std::move(pathRow));
+
+ auto spacer = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".spacer"));
+ spacer->setHeight(ui::SizeValue::px(16.0f));
+ dialogPanel->addChild(std::move(spacer));
+
+ auto buttonRow = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".buttons"));
+ auto buttonLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Horizontal, 12.0f);
+ buttonRow->setLayout(std::move(buttonLayout));
+
+ auto cancelButton = makeUnique<ui::Button>(ui::WidgetId(getId().path + ".cancel"), "Cancel");
+ cancelButton->setButtonStyle(ui::ButtonStyle::Secondary);
+ cancelButton->setWidth(ui::SizeValue::px(100.0f));
+ cancelButton->setHeight(ui::SizeValue::px(40.0f));
+ cancelButton_ = cancelButton.get();
+ connections_.push_back(
+ sink(cancelButton_->onClick).connect([this]() { onCancelClicked(); }));
+ buttonRow->addChild(std::move(cancelButton));
+
+ auto createButton = makeUnique<ui::Button>(ui::WidgetId(getId().path + ".create"), "Create");
+ createButton->setButtonStyle(ui::ButtonStyle::Primary);
+ createButton->setWidth(ui::SizeValue::px(100.0f));
+ createButton->setHeight(ui::SizeValue::px(40.0f));
+ createButton_ = createButton.get();
+ connections_.push_back(
+ sink(createButton_->onClick).connect([this]() { onCreateClicked(); }));
+ buttonRow->addChild(std::move(createButton));
+
+ dialogPanel->addChild(std::move(buttonRow));
+
+ dialogPanel_ = dialogPanel.get();
+ addChild(std::move(dialogPanel));
+}
+
+// =============================================================================
+// Methods
+// =============================================================================
+
+void NewProjectDialog::show() {
+ showing_ = true;
+ setVisible(true);
+ if (nameField_) {
+ nameField_->setText("");
+ }
+ if (pathField_) {
+ pathField_->setText("");
+ }
+}
+
+void NewProjectDialog::hide() {
+ showing_ = false;
+ setVisible(false);
+}
+
+void NewProjectDialog::onBrowseClicked() {
+ std::string folder = FileDialog::selectFolder("Select Project Location");
+ if (!folder.empty() && pathField_) {
+ pathField_->setText(folder);
+ }
+}
+
+void NewProjectDialog::onCreateClicked() {
+ if (!nameField_ || !pathField_) return;
+
+ std::string name = nameField_->getText();
+ std::string basePath = pathField_->getText();
+
+ if (name.empty()) {
+ ES_LOG_WARN("Project name cannot be empty");
+ return;
+ }
+
+ if (basePath.empty()) {
+ ES_LOG_WARN("Project location cannot be empty");
+ return;
+ }
+
+ std::string fullPath = basePath + "/" + name;
+ ES_LOG_INFO("Creating project '{}' at {}", name, fullPath);
+
+ onProjectCreate.publish(name, fullPath);
+ hide();
+}
+
+void NewProjectDialog::onCancelClicked() {
+ onCancel.publish();
+ hide();
+}
+
+// =============================================================================
+// Widget Overrides
+// =============================================================================
+
+glm::vec2 NewProjectDialog::measure(f32 availableWidth, f32 availableHeight) {
+ return glm::vec2(availableWidth, availableHeight);
+}
+
+void NewProjectDialog::layout(const ui::Rect& bounds) {
+ Widget::layout(bounds);
+
+ if (dialogPanel_) {
+ f32 dialogWidth = 450.0f;
+ f32 dialogHeight = 280.0f;
+ f32 dialogX = bounds.x + (bounds.width - dialogWidth) / 2.0f;
+ f32 dialogY = bounds.y + (bounds.height - dialogHeight) / 2.0f;
+ dialogPanel_->layout(ui::Rect{dialogX, dialogY, dialogWidth, dialogHeight});
+ }
+}
+
+void NewProjectDialog::render(ui::UIBatchRenderer& renderer) {
+ if (!showing_) return;
+
+ renderer.drawRect(getBounds(), glm::vec4(0.0f, 0.0f, 0.0f, 0.6f));
+
+ for (usize i = 0; i < getChildCount(); ++i) {
+ auto* child = getChild(i);
+ if (child && child->isVisible()) {
+ child->renderTree(renderer);
+ }
+ }
+}
+
+} // namespace esengine::editor
diff --git a/src/esengine/editor/panels/NewProjectDialog.hpp b/src/esengine/editor/panels/NewProjectDialog.hpp
new file mode 100644
index 000000000..faf8fec61
--- /dev/null
+++ b/src/esengine/editor/panels/NewProjectDialog.hpp
@@ -0,0 +1,86 @@
+/**
+ * @file NewProjectDialog.hpp
+ * @brief Dialog for creating new projects
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
+#pragma once
+
+// =============================================================================
+// Includes
+// =============================================================================
+
+#include "../../ui/widgets/Widget.hpp"
+#include "../../ui/core/Types.hpp"
+#include "../../events/Signal.hpp"
+#include "../../events/Connection.hpp"
+
+#include <string>
+#include <vector>
+
+namespace esengine::ui {
+class Button;
+class Label;
+class TextField;
+class Panel;
+}
+
+namespace esengine::editor {
+
+// =============================================================================
+// NewProjectDialog
+// =============================================================================
+
+class NewProjectDialog : public ui::Widget {
+public:
+ NewProjectDialog(const ui::WidgetId& id);
+ ~NewProjectDialog() override;
+
+ // =========================================================================
+ // Signals
+ // =========================================================================
+
+ Signal<void(const std::string& name, const std::string& path)> onProjectCreate;
+ Signal<void()> onCancel;
+
+ // =========================================================================
+ // Methods
+ // =========================================================================
+
+ void show();
+ void hide();
+ bool isShowing() const { return showing_; }
+
+ // =========================================================================
+ // Widget Overrides
+ // =========================================================================
+
+ glm::vec2 measure(f32 availableWidth, f32 availableHeight) override;
+ void layout(const ui::Rect& bounds) override;
+ void render(ui::UIBatchRenderer& renderer) override;
+
+private:
+ void setupUI();
+ void onBrowseClicked();
+ void onCreateClicked();
+ void onCancelClicked();
+
+ ui::Panel* dialogPanel_ = nullptr;
+ ui::Label* titleLabel_ = nullptr;
+ ui::Label* nameLabel_ = nullptr;
+ ui::TextField* nameField_ = nullptr;
+ ui::Label* pathLabel_ = nullptr;
+ ui::TextField* pathField_ = nullptr;
+ ui::Button* browseButton_ = nullptr;
+ ui::Button* createButton_ = nullptr;
+ ui::Button* cancelButton_ = nullptr;
+
+ bool showing_ = false;
+ std::vector<Connection> connections_;
+};
+
+} // namespace esengine::editor
diff --git a/src/esengine/editor/panels/ProjectLauncherPanel.cpp b/src/esengine/editor/panels/ProjectLauncherPanel.cpp
index f81235827..1921de19c 100644
--- a/src/esengine/editor/panels/ProjectLauncherPanel.cpp
+++ b/src/esengine/editor/panels/ProjectLauncherPanel.cpp
@@ -158,28 +158,22 @@ void ProjectLauncherPanel::refreshRecentProjects() {
void ProjectLauncherPanel::createRecentProjectItem(const RecentProject& project,
ui::Panel* container, usize index) {
std::string itemId = getId().path + ".item_" + std::to_string(index);
+ std::string projectPath = project.path;
- auto itemPanel = makeUnique<ui::Panel>(ui::WidgetId(itemId));
- itemPanel->setBackgroundColor(glm::vec4(0.18f, 0.18f, 0.18f, 1.0f));
- itemPanel->setWidth(ui::SizeValue::percent(100.0f));
- itemPanel->setHeight(ui::SizeValue::px(60.0f));
- itemPanel->setCornerRadii(ui::CornerRadii::all(4.0f));
+ auto itemButton = makeUnique<ui::Button>(ui::WidgetId(itemId), project.name);
+ itemButton->setButtonStyle(ui::ButtonStyle::Text);
+ itemButton->setWidth(ui::SizeValue::percent(100.0f));
+ itemButton->setHeight(ui::SizeValue::px(50.0f));
+ itemButton->setFontSize(14.0f);
+ itemButton->setCornerRadii(ui::CornerRadii::all(4.0f));
- auto itemLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 4.0f);
- itemPanel->setLayout(std::move(itemLayout));
- itemPanel->setPadding(ui::Insets(8.0f, 12.0f, 8.0f, 12.0f));
-
- auto nameLabel = makeUnique<ui::Label>(ui::WidgetId(itemId + ".name"), project.name);
- nameLabel->setFontSize(14.0f);
- nameLabel->setColor(glm::vec4(1.0f));
- itemPanel->addChild(std::move(nameLabel));
-
- auto pathLabel = makeUnique<ui::Label>(ui::WidgetId(itemId + ".path"), project.path);
- pathLabel->setFontSize(11.0f);
- pathLabel->setColor(glm::vec4(0.5f, 0.5f, 0.5f, 1.0f));
- itemPanel->addChild(std::move(pathLabel));
+ connections_.push_back(
+ sink(itemButton->onClick).connect([this, projectPath]() {
+ ES_LOG_INFO("ProjectLauncher: Opening project {}", projectPath);
+ onProjectOpened.publish(projectPath);
+ }));
- container->addChild(std::move(itemPanel));
+ container->addChild(std::move(itemButton));
}
// =============================================================================
diff --git a/src/esengine/platform/FileDialog.cpp b/src/esengine/platform/FileDialog.cpp
new file mode 100644
index 000000000..136176935
--- /dev/null
+++ b/src/esengine/platform/FileDialog.cpp
@@ -0,0 +1,225 @@
+/**
+ * @file FileDialog.cpp
+ * @brief Native file dialog implementation
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
+
+#include "FileDialog.hpp"
+#include "../core/Log.hpp"
+
+#ifdef ES_PLATFORM_WINDOWS
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#include <commdlg.h>
+#include <shlobj.h>
+#endif
+
+namespace esengine {
+
+// =============================================================================
+// Windows Implementation
+// =============================================================================
+
+#ifdef ES_PLATFORM_WINDOWS
+
+std::string FileDialog::openFile(const std::string& title,
+ const std::vector<FileFilter>& filters,
+ const std::string& defaultPath) {
+ char filename[MAX_PATH] = {0};
+
+ std::string filterStr;
+ if (filters.empty()) {
+ filterStr = "All Files\0*.*\0";
+ } else {
+ for (const auto& filter : filters) {
+ filterStr += filter.name;
+ filterStr.push_back('\0');
+ filterStr += filter.pattern;
+ filterStr.push_back('\0');
+ }
+ }
+ filterStr.push_back('\0');
+
+ OPENFILENAMEA ofn = {};
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = nullptr;
+ ofn.lpstrFilter = filterStr.c_str();
+ ofn.lpstrFile = filename;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.lpstrTitle = title.c_str();
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;
+
+ if (!defaultPath.empty()) {
+ ofn.lpstrInitialDir = defaultPath.c_str();
+ }
+
+ if (GetOpenFileNameA(&ofn)) {
+ return std::string(filename);
+ }
+
+ return "";
+}
+
+std::string FileDialog::saveFile(const std::string& title,
+ const std::vector<FileFilter>& filters,
+ const std::string& defaultPath,
+ const std::string& defaultName) {
+ char filename[MAX_PATH] = {0};
+
+ if (!defaultName.empty()) {
+ strncpy_s(filename, defaultName.c_str(), MAX_PATH - 1);
+ }
+
+ std::string filterStr;
+ if (filters.empty()) {
+ filterStr = "All Files\0*.*\0";
+ } else {
+ for (const auto& filter : filters) {
+ filterStr += filter.name;
+ filterStr.push_back('\0');
+ filterStr += filter.pattern;
+ filterStr.push_back('\0');
+ }
+ }
+ filterStr.push_back('\0');
+
+ OPENFILENAMEA ofn = {};
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = nullptr;
+ ofn.lpstrFilter = filterStr.c_str();
+ ofn.lpstrFile = filename;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.lpstrTitle = title.c_str();
+ ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR;
+
+ if (!defaultPath.empty()) {
+ ofn.lpstrInitialDir = defaultPath.c_str();
+ }
+
+ if (GetSaveFileNameA(&ofn)) {
+ return std::string(filename);
+ }
+
+ return "";
+}
+
+static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /*lParam*/, LPARAM lpData) {
+ if (uMsg == BFFM_INITIALIZED && lpData != 0) {
+ SendMessageA(hwnd, BFFM_SETSELECTION, TRUE, lpData);
+ }
+ return 0;
+}
+
+std::string FileDialog::selectFolder(const std::string& title,
+ const std::string& defaultPath) {
+ char path[MAX_PATH] = {0};
+
+ BROWSEINFOA bi = {};
+ bi.lpszTitle = title.c_str();
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
+ bi.lpfn = BrowseCallbackProc;
+ bi.lParam = reinterpret_cast<LPARAM>(defaultPath.empty() ? nullptr : defaultPath.c_str());
+
+ LPITEMIDLIST pidl = SHBrowseForFolderA(&bi);
+ if (pidl != nullptr) {
+ if (SHGetPathFromIDListA(pidl, path)) {
+ CoTaskMemFree(pidl);
+ return std::string(path);
+ }
+ CoTaskMemFree(pidl);
+ }
+
+ return "";
+}
+
+// =============================================================================
+// macOS Implementation
+// =============================================================================
+
+#elif defined(ES_PLATFORM_MACOS)
+
+std::string FileDialog::openFile(const std::string& /*title*/,
+ const std::vector<FileFilter>& /*filters*/,
+ const std::string& /*defaultPath*/) {
+ ES_LOG_WARN("FileDialog::openFile not implemented on macOS");
+ return "";
+}
+
+std::string FileDialog::saveFile(const std::string& /*title*/,
+ const std::vector<FileFilter>& /*filters*/,
+ const std::string& /*defaultPath*/,
+ const std::string& /*defaultName*/) {
+ ES_LOG_WARN("FileDialog::saveFile not implemented on macOS");
+ return "";
+}
+
+std::string FileDialog::selectFolder(const std::string& /*title*/,
+ const std::string& /*defaultPath*/) {
+ ES_LOG_WARN("FileDialog::selectFolder not implemented on macOS");
+ return "";
+}
+
+// =============================================================================
+// Linux Implementation
+// =============================================================================
+
+#elif defined(ES_PLATFORM_LINUX)
+
+std::string FileDialog::openFile(const std::string& /*title*/,
+ const std::vector<FileFilter>& /*filters*/,
+ const std::string& /*defaultPath*/) {
+ ES_LOG_WARN("FileDialog::openFile not implemented on Linux");
+ return "";
+}
+
+std::string FileDialog::saveFile(const std::string& /*title*/,
+ const std::vector<FileFilter>& /*filters*/,
+ const std::string& /*defaultPath*/,
+ const std::string& /*defaultName*/) {
+ ES_LOG_WARN("FileDialog::saveFile not implemented on Linux");
+ return "";
+}
+
+std::string FileDialog::selectFolder(const std::string& /*title*/,
+ const std::string& /*defaultPath*/) {
+ ES_LOG_WARN("FileDialog::selectFolder not implemented on Linux");
+ return "";
+}
+
+// =============================================================================
+// Fallback (Web, etc.)
+// =============================================================================
+
+#else
+
+std::string FileDialog::openFile(const std::string& /*title*/,
+ const std::vector<FileFilter>& /*filters*/,
+ const std::string& /*defaultPath*/) {
+ ES_LOG_WARN("FileDialog not supported on this platform");
+ return "";
+}
+
+std::string FileDialog::saveFile(const std::string& /*title*/,
+ const std::vector<FileFilter>& /*filters*/,
+ const std::string& /*defaultPath*/,
+ const std::string& /*defaultName*/) {
+ ES_LOG_WARN("FileDialog not supported on this platform");
+ return "";
+}
+
+std::string FileDialog::selectFolder(const std::string& /*title*/,
+ const std::string& /*defaultPath*/) {
+ ES_LOG_WARN("FileDialog not supported on this platform");
+ return "";
+}
+
+#endif
+
+} // namespace esengine
diff --git a/src/esengine/platform/FileDialog.hpp b/src/esengine/platform/FileDialog.hpp
new file mode 100644
index 000000000..60c41dd43
--- /dev/null
+++ b/src/esengine/platform/FileDialog.hpp
@@ -0,0 +1,53 @@
+/**
+ * @file FileDialog.hpp
+ * @brief Native file dialog utilities
+ * @details Provides cross-platform file and folder selection dialogs.
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
+#pragma once
+
+// =============================================================================
+// Includes
+// =============================================================================
+
+#include "../core/Types.hpp"
+
+#include <string>
+#include <vector>
+
+namespace esengine {
+
+// =============================================================================
+// FileFilter
+// =============================================================================
+
+struct FileFilter {
+ std::string name;
+ std::string pattern;
+};
+
+// =============================================================================
+// FileDialog
+// =============================================================================
+
+class FileDialog {
+public:
+ static std::string openFile(const std::string& title = "Open File",
+ const std::vector<FileFilter>& filters = {},
+ const std::string& defaultPath = "");
+
+ static std::string saveFile(const std::string& title = "Save File",
+ const std::vector<FileFilter>& filters = {},
+ const std::string& defaultPath = "",
+ const std::string& defaultName = "");
+
+ static std::string selectFolder(const std::string& title = "Select Folder",
+ const std::string& defaultPath = "");
+};
+
+} // namespace esengine