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 <iostream>
18
19// This provides the platform-specific entry point implementation for SDL3
20#include <SDL3/SDL_main_impl.h>
21
26
28{
29 std::cout << "=============================================" << std::endl;
30 std::cout << " Olympe Blueprint Editor Standalone" << std::endl;
31 std::cout << "=============================================" << std::endl;
32 std::cout << "Version: 1.0.0" << std::endl;
33 std::cout << "Mode: Blueprint Editor Standalone (Full CRUD)" << std::endl;
34 std::cout << "=============================================" << std::endl;
35
37 {
38 std::cerr << "[BlueprintEditorStandalone] SDL3 Init failed: " << SDL_GetError() << std::endl;
39 return SDL_APP_FAILURE;
40 }
41
43 "Olympe Blueprint Editor Standalone - WYSIWYG Editor",
44 1920, 1080,
46 );
47
49 {
50 std::cerr << "[BlueprintEditorStandalone] Window creation failed: " << SDL_GetError() << std::endl;
51 SDL_Quit();
52 return SDL_APP_FAILURE;
53 }
54
57 {
58 std::cerr << "[BlueprintEditorStandalone] Renderer creation failed: " << SDL_GetError() << std::endl;
60 SDL_Quit();
61 return SDL_APP_FAILURE;
62 }
63
65 ImGui::CreateContext();
66 ImGuiIO& io = ImGui::GetIO();
68 // io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // does not exist in SDL3 imgui backend yet
69
70 ImGui::StyleColorsDark();
71
72 ImGuiStyle& style = ImGui::GetStyle();
73 style.Colors[ImGuiCol_WindowBg] = ImVec4(0.12f, 0.12f, 0.14f, 1.00f);
74 style.Colors[ImGuiCol_TitleBg] = ImVec4(0.15f, 0.15f, 0.18f, 1.00f);
75 style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.20f, 0.40f, 0.60f, 1.00f);
76
79
83
86
87 std::cout << "[BlueprintEditorStandalone] Initialization complete" << std::endl;
88 std::cout << "[BlueprintEditorStandalone] EditorContext: Standalone (Full CRUD enabled)" << std::endl;
89 std::cout << "[BlueprintEditorStandalone] Press Ctrl+Q to quit" << std::endl;
90
91 // Initialize frame timing
93
94 return SDL_APP_CONTINUE;
95}
96
98{
99 if (!event) return SDL_APP_CONTINUE;
100
102
103 ImGuiIO& io = ImGui::GetIO();
104
106 {
107 return SDL_APP_SUCCESS;
108 }
109
110 if (event->type == SDL_EVENT_KEY_DOWN && !io.WantCaptureKeyboard)
111 {
112 if ((event->key.mod & SDL_KMOD_CTRL) && event->key.key == SDLK_Q)
113 {
114 std::cout << "[BlueprintEditorStandalone] User requested quit (Ctrl+Q)" << std::endl;
115 if (Olympe::BlueprintEditor::Get().HasUnsavedChanges())
116 {
117 std::cout << "[BlueprintEditorStandalone] Warning: Unsaved changes detected" << std::endl;
118 }
119 return SDL_APP_SUCCESS;
120 }
121
122 if (event->key.key == SDLK_ESCAPE)
123 {
124 if (Olympe::BlueprintEditor::Get().HasUnsavedChanges())
125 {
126 std::cout << "[BlueprintEditorStandalone] ESC pressed with unsaved changes" << std::endl;
127 }
128 else
129 {
130 return SDL_APP_SUCCESS;
131 }
132 }
133 }
134
135 return SDL_APP_CONTINUE;
136}
137
139{
140 // Calculate delta time
142 float deltaTime = (currentTime - g_LastFrameTime) / 1000.0f;
144
145 // Clamp delta time to prevent large jumps (e.g., when debugging)
146 if (deltaTime > 0.1f) {
147 deltaTime = 0.016f; // Fall back to ~60 FPS if delta is too large
148 }
149
151
154 ImGui::NewFrame();
155
157 {
159 }
160
161 ImGui::Render();
162
165
167
169
170 return SDL_APP_CONTINUE;
171}
172
174{
175 std::cout << "[BlueprintEditorStandalone] Shutting down..." << std::endl;
176
178 {
181 g_BlueprintEditorGUI = nullptr;
182 }
183
185
188 ImGui::DestroyContext();
189
191 {
194 }
195
197 {
199 g_BlueprintEditorWindow = nullptr;
200 }
201
202 SDL_Quit();
203
204 std::cout << "[BlueprintEditorStandalone] Shutdown complete" << std::endl;
205}
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)
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
BlueprintEditorGUI - Frontend UI for Blueprint Editor Renders ImGui interface and interacts with Blue...
void SetActive(bool active)
static BlueprintEditor & Get()
void Update(float deltaTime)