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: Integrate ProjectLauncherPanel into EditorApplication

esengine9991f64e4b67
diff --git a/src/esengine/editor/EditorApplication.cpp b/src/esengine/editor/EditorApplication.cpp
index 08e019c88..e35738521 100644
--- a/src/esengine/editor/EditorApplication.cpp
+++ b/src/esengine/editor/EditorApplication.cpp
@@ -28,6 +28,7 @@
#include "panels/InspectorPanel.hpp"
#include "panels/SceneViewPanel.hpp"
#include "panels/AssetBrowserPanel.hpp"
+#include "panels/ProjectLauncherPanel.hpp"
namespace esengine {
namespace editor {
@@ -131,13 +132,10 @@ void EditorApplication::onInit() {
// Load recent projects list
projectManager_->getRecentProjects().load();
- // Create demo scene for testing
- createDemoScene();
-
- // Setup editor UI layout
- setupEditorLayout();
-
setupEventListeners();
+
+ // Start in launcher mode
+ setupLauncherLayout();
}
void EditorApplication::onUpdate(f32 deltaTime) {
@@ -429,5 +427,84 @@ void EditorApplication::createDemoScene() {
ES_LOG_INFO("Demo scene created with {} entities", registry_.entityCount());
}
+// =============================================================================
+// Mode Switching
+// =============================================================================
+
+void EditorApplication::setupLauncherLayout() {
+ ES_LOG_INFO("Setting up launcher layout");
+
+ mode_ = EditorMode::Launcher;
+
+ auto launcherPanel = makeUnique<ProjectLauncherPanel>(
+ ui::WidgetId("editor.launcher"),
+ *projectManager_,
+ dispatcher_);
+
+ launcherPanel_ = launcherPanel.get();
+
+ eventConnections_.add(
+ sink(launcherPanel_->onCreateProjectRequested).connect([this]() {
+ onNewProjectRequested();
+ }));
+
+ eventConnections_.add(
+ sink(launcherPanel_->onBrowseProjectRequested).connect([this]() {
+ onOpenProjectRequested();
+ }));
+
+ eventConnections_.add(
+ sink(launcherPanel_->onProjectOpened).connect([this](const std::string& path) {
+ auto result = projectManager_->openProject(path);
+ if (result.isOk()) {
+ showEditor();
+ } else {
+ ES_LOG_ERROR("Failed to open project: {}", result.error());
+ }
+ }));
+
+ uiContext_->setRoot(std::move(launcherPanel));
+
+ ES_LOG_INFO("Launcher layout initialized");
+}
+
+void EditorApplication::showLauncher() {
+ if (mode_ == EditorMode::Launcher) {
+ return;
+ }
+
+ ES_LOG_INFO("Switching to launcher mode");
+
+ dockArea_ = nullptr;
+
+ setupLauncherLayout();
+}
+
+void EditorApplication::showEditor() {
+ if (mode_ == EditorMode::Editor) {
+ return;
+ }
+
+ ES_LOG_INFO("Switching to editor mode");
+
+ launcherPanel_ = nullptr;
+
+ mode_ = EditorMode::Editor;
+
+ createDemoScene();
+
+ setupEditorLayout();
+
+ ES_LOG_INFO("Editor mode active");
+}
+
+void EditorApplication::onNewProjectRequested() {
+ ES_LOG_INFO("New project requested - TODO: Show project creation dialog");
+}
+
+void EditorApplication::onOpenProjectRequested() {
+ ES_LOG_INFO("Open project requested - TODO: Show file browser dialog");
+}
+
} // namespace editor
} // namespace esengine
diff --git a/src/esengine/editor/EditorApplication.hpp b/src/esengine/editor/EditorApplication.hpp
index 63c707508..779d8369c 100644
--- a/src/esengine/editor/EditorApplication.hpp
+++ b/src/esengine/editor/EditorApplication.hpp
@@ -32,6 +32,17 @@
namespace esengine {
namespace editor {
+class ProjectLauncherPanel;
+
+// =============================================================================
+// Editor Mode
+// =============================================================================
+
+enum class EditorMode : u8 {
+ Launcher,
+ Editor
+};
+
// =============================================================================
// EditorApplication Class
// =============================================================================
@@ -126,6 +137,22 @@ public:
*/
ProjectManager& getProjectManager() { return *projectManager_; }
+ /**
+ * @brief Get current editor mode
+ * @return Current editor mode (Launcher or Editor)
+ */
+ EditorMode getMode() const { return mode_; }
+
+ /**
+ * @brief Switch to launcher mode
+ */
+ void showLauncher();
+
+ /**
+ * @brief Switch to editor mode
+ */
+ void showEditor();
+
protected:
// =========================================================================
// Application Lifecycle Overrides
@@ -205,6 +232,21 @@ private:
*/
void createDemoScene();
+ /**
+ * @brief Setup project launcher UI
+ */
+ void setupLauncherLayout();
+
+ /**
+ * @brief Handle new project request from launcher
+ */
+ void onNewProjectRequested();
+
+ /**
+ * @brief Handle open project request from launcher
+ */
+ void onOpenProjectRequested();
+
// =========================================================================
// Constants
// =========================================================================
@@ -225,11 +267,13 @@ private:
Unique<ProjectManager> projectManager_; ///< Project manager
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)
// =========================================================================
// State
// =========================================================================
+ EditorMode mode_ = EditorMode::Launcher; ///< Current editor mode
glm::vec4 clearColor_{0.15f, 0.15f, 0.15f, 1.0f}; ///< Editor background color
f64 frameTime_ = 0.0; ///< Accumulated frame time
u32 frameCount_ = 0; ///< Frame counter for FPS