Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
BlueprintEditorStandaloneMain.cpp
Go to the documentation of this file.
1/*
2 * Olympe Blueprint Editor Standalone - Entry Point
3 *
4 * This executable provides a dedicated WYSIWYG blueprint editor without game runtime.
5 * It shares all Blueprint Editor code with the runtime editor but operates in
6 * Blueprint Editor Standalone mode for full CRUD operations.
7 */
8
9#define SDL_MAIN_USE_CALLBACKS
10#include <SDL3/SDL.h>
11#include <SDL3/SDL_main.h>
12#include "../third_party/imgui/imgui.h"
13#include "../third_party/imgui/backends/imgui_impl_sdl3.h"
14#include "../third_party/imgui/backends/imgui_impl_sdlrenderer3.h"
15#include "../BlueprintEditor/blueprinteditor.h"
16#include "../BlueprintEditor/BlueprintEditorGUI.h"
17#include "../AI/BehaviorTreeDebugWindow.h"
18#include <iostream>
19
20// This provides the platform-specific entry point implementation for SDL3
21#include <SDL3/SDL_main_impl.h>
22
23// Global BT debugger instance (required by ECS_Systems_AI)
25
30
32{
33 std::cout << "=============================================" << std::endl;
34 std::cout << " Olympe Blueprint Editor Standalone" << std::endl;
35 std::cout << "=============================================" << std::endl;
36 std::cout << "Version: 1.0.0" << std::endl;
37 std::cout << "Mode: Blueprint Editor Standalone (Full CRUD)" << std::endl;
38 std::cout << "=============================================" << std::endl;
39
41 {
42 std::cerr << "[BlueprintEditorStandalone] SDL3 Init failed: " << SDL_GetError() << std::endl;
43 return SDL_APP_FAILURE;
44 }
45
47 "Olympe Blueprint Editor Standalone - WYSIWYG Editor",
48 1920, 1080,
50 );
51
53 {
54 std::cerr << "[BlueprintEditorStandalone] Window creation failed: " << SDL_GetError() << std::endl;
55 SDL_Quit();
56 return SDL_APP_FAILURE;
57 }
58
61 {
62 std::cerr << "[BlueprintEditorStandalone] Renderer creation failed: " << SDL_GetError() << std::endl;
64 SDL_Quit();
65 return SDL_APP_FAILURE;
66 }
67
69 ImGui::CreateContext();
70 ImGuiIO& io = ImGui::GetIO();
72 // Note: ImGuiConfigFlags_DockingEnable is not available in this ImGui version
73 // We use manual layout with ImGui::BeginChild instead
74
75 // Disable imgui.ini - we use JSON config instead
76 io.IniFilename = nullptr;
77
78 ImGui::StyleColorsDark();
79
80 ImGuiStyle& style = ImGui::GetStyle();
81 style.Colors[ImGuiCol_WindowBg] = ImVec4(0.12f, 0.12f, 0.14f, 1.00f);
82 style.Colors[ImGuiCol_TitleBg] = ImVec4(0.15f, 0.15f, 0.18f, 1.00f);
83 style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.20f, 0.40f, 0.60f, 1.00f);
84
87
91
94
95 std::cout << "[BlueprintEditorStandalone] Initialization complete" << std::endl;
96 std::cout << "[BlueprintEditorStandalone] EditorContext: Standalone (Full CRUD enabled)" << std::endl;
97 std::cout << "[BlueprintEditorStandalone] Press Ctrl+Q to quit" << std::endl;
98
99 // Initialize frame timing
101
102 return SDL_APP_CONTINUE;
103}
104
106{
107 if (!event) return SDL_APP_CONTINUE;
108
110
111 ImGuiIO& io = ImGui::GetIO();
112
114 {
115 return SDL_APP_SUCCESS;
116 }
117
118 if (event->type == SDL_EVENT_KEY_DOWN && !io.WantCaptureKeyboard)
119 {
120 if ((event->key.mod & SDL_KMOD_CTRL) && event->key.key == SDLK_Q)
121 {
122 std::cout << "[BlueprintEditorStandalone] User requested quit (Ctrl+Q)" << std::endl;
123 if (Olympe::BlueprintEditor::Get().HasUnsavedChanges())
124 {
125 std::cout << "[BlueprintEditorStandalone] Warning: Unsaved changes detected" << std::endl;
126 }
127 return SDL_APP_SUCCESS;
128 }
129
130 if (event->key.key == SDLK_ESCAPE)
131 {
132 if (Olympe::BlueprintEditor::Get().HasUnsavedChanges())
133 {
134 std::cout << "[BlueprintEditorStandalone] ESC pressed with unsaved changes" << std::endl;
135 }
136 else
137 {
138 return SDL_APP_SUCCESS;
139 }
140 }
141 }
142
143 return SDL_APP_CONTINUE;
144}
145
147{
148 // Calculate delta time
150 float deltaTime = (currentTime - g_LastFrameTime) / 1000.0f;
152
153 // Clamp delta time to prevent large jumps (e.g., when debugging)
154 if (deltaTime > 0.1f) {
155 deltaTime = 0.016f; // Fall back to ~60 FPS if delta is too large
156 }
157
159
162 ImGui::NewFrame();
163
165 {
167 }
168
169 ImGui::Render();
170
173
175
177
178 return SDL_APP_CONTINUE;
179}
180
182{
183 std::cout << "[BlueprintEditorStandalone] Shutting down..." << std::endl;
184
186 {
189 g_BlueprintEditorGUI = nullptr;
190 }
191
193
196 ImGui::DestroyContext();
197
199 {
202 }
203
205 {
207 g_BlueprintEditorWindow = nullptr;
208 }
209
210 SDL_Quit();
211
212 std::cout << "[BlueprintEditorStandalone] Shutdown complete" << std::endl;
213}
static Olympe::BlueprintEditorGUI * g_BlueprintEditorGUI
void SDL_AppQuit(void *appstate, SDL_AppResult result)
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
static SDL_Window * g_BlueprintEditorWindow
SDL_AppResult SDL_AppIterate(void *appstate)
static Uint64 g_LastFrameTime
static SDL_Renderer * g_BlueprintEditorRenderer
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
Olympe::BehaviorTreeDebugWindow * g_btDebugWindow
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Main debug window for behavior tree runtime visualization.
BlueprintEditorGUI - Frontend UI for Blueprint Editor Renders ImGui interface and interacts with Blue...
void SetActive(bool active)
static BlueprintEditor & Get()
void Update(float deltaTime)