7#include "BlueprintEditor.h"
10#include "../third_party/imgui/imgui.h"
11#include "../third_party/imnodes/imnodes.h"
19 : m_SelectedComponentIndex(-1)
21 , m_ShowDemoWindow(
false)
22 , m_ShowAddComponentDialog(
false)
23 , m_ShowAboutDialog(
false)
24 , m_SelectedComponentType(0)
25 , m_ShowAssetBrowser(
true)
26 , m_ShowAssetInfo(
false)
27 , m_ShowInspector(
true)
28 , m_ShowNodeGraph(
true)
29 , m_ShowEntities(
false)
30 , m_ShowEntityProperties(
false)
31 , m_ShowComponentGraph(
false)
32 , m_ShowPropertyPanel(
false)
33 , m_ShowTemplateBrowser(
false)
34 , m_ShowHistory(
false)
35 , m_ShowPreferences(
false)
36 , m_ShowShortcuts(
false)
37 , m_TemplateBrowserPanel(
nullptr)
62 ImNodes::CreateContext();
63 ImNodes::StyleColorsDark();
112 ImNodes::DestroyContext();
131 if (ImGui::BeginMainMenuBar())
134 if (ImGui::BeginMenu(
"File"))
137 if (ImGui::BeginMenu(
"New Blueprint"))
139 if (ImGui::BeginMenu(
"AI"))
141 if (ImGui::MenuItem(
"Behavior Tree",
"Ctrl+Shift+B"))
144 std::cout <<
"Creating new Behavior Tree..." << std::endl;
146 if (ImGui::MenuItem(
"Hierarchical FSM",
"Ctrl+Shift+H"))
148 std::cout <<
"Creating new HFSM..." << std::endl;
155 if (ImGui::MenuItem(
"Entity Prefab",
"Ctrl+Shift+E"))
157 std::cout <<
"Creating new Entity Prefab..." << std::endl;
160 if (ImGui::MenuItem(
"Animation Graph",
"Ctrl+Shift+A"))
162 std::cout <<
"Creating new Animation Graph..." << std::endl;
165 if (ImGui::MenuItem(
"Scripted Event",
"Ctrl+Shift+S"))
167 std::cout <<
"Creating new Scripted Event..." << std::endl;
172 if (ImGui::MenuItem(
"Level Definition",
"Ctrl+Shift+L"))
174 std::cout <<
"Creating new Level Definition..." << std::endl;
177 if (ImGui::MenuItem(
"UI Menu",
"Ctrl+Shift+U"))
179 std::cout <<
"Creating new UI Menu..." << std::endl;
185 if (ImGui::MenuItem(
"New Blueprint (Legacy)",
"Ctrl+N"))
188 if (ImGui::MenuItem(
"Open Blueprint...",
"Ctrl+O"))
196 if (ImGui::MenuItem(
"Save",
"Ctrl+S",
false,
backend.HasBlueprint()))
199 if (ImGui::MenuItem(
"Save As...",
"Ctrl+Shift+S",
false,
backend.HasBlueprint()))
205 if (ImGui::MenuItem(
"Save as Template...",
"Ctrl+Shift+T",
false,
backend.HasBlueprint()))
221 if (ImGui::MenuItem(
"Reload Assets"))
228 if (ImGui::MenuItem(
"Exit Editor",
"F2"))
235 if (ImGui::BeginMenu(
"Edit"))
266 if (ImGui::MenuItem(
"Add Component",
"Insert",
false,
backend.HasBlueprint()))
269 if (ImGui::MenuItem(
"Remove Component",
"Delete",
false,
277 if (ImGui::MenuItem(
"Preferences..."))
286 if (ImGui::BeginMenu(
"Tools"))
288 if (ImGui::MenuItem(
"Migrate Blueprints v1 -> v2"))
290 backend.SetShowMigrationDialog(
true);
295 if (ImGui::MenuItem(
"Validate All Blueprints"))
297 std::cout <<
"Validating all blueprints..." << std::endl;
304 if (ImGui::BeginMenu(
"View"))
306 ImGui::Text(
"Main Panels:");
316 ImGui::Text(
"Additional:");
323 ImGui::Text(
"Debug:");
329 if (ImGui::MenuItem(
"Reset Layout"))
342 if (ImGui::BeginMenu(
"Help"))
344 if (ImGui::MenuItem(
"Documentation"))
347 std::cout <<
"Opening documentation..." << std::endl;
350 if (ImGui::MenuItem(
"Keyboard Shortcuts"))
357 if (ImGui::MenuItem(
"About Olympe Engine"))
363 ImGui::EndMainMenuBar();
402 if (
backend.ShowMigrationDialog())
408 ImGui::OpenPopup(
"About");
411 ImGui::Text(
"Olympe Blueprint Editor");
413 ImGui::Text(
"Visual node-based editor for entity blueprints");
414 ImGui::Text(
"Version: 2.0");
415 ImGui::Text(
"Status: Interactive panels, entity synchronization, full menus");
417 ImGui::Text(
"Libraries:");
418 ImGui::BulletText(
"ImGui for UI");
419 ImGui::BulletText(
"ImNodes for node editing");
420 ImGui::BulletText(
"SDL3 for window/rendering");
422 ImGui::Text(
"Features:");
423 ImGui::BulletText(
"Interactive, dockable panels");
424 ImGui::BulletText(
"Runtime entity tracking");
425 ImGui::BulletText(
"Synchronized panel selection");
426 ImGui::BulletText(
"Full menu system");
427 if (ImGui::Button(
"Close",
ImVec2(120, 0)))
450 ImGui::Begin(
"Entity Properties");
454 ImGui::Text(
"Blueprint: %s",
blueprint.name.c_str());
455 if (
backend.HasUnsavedChanges())
458 ImGui::TextColored(
ImVec4(1.0f, 0.7f, 0.0f, 1.0f),
"*");
464 ImGui::Text(
"Description:");
465 ImGui::TextWrapped(
"%s",
blueprint.description.c_str());
470 ImGui::Text(
"Components (%zu)",
blueprint.components.size());
472 for (
size_t i = 0;
i <
blueprint.components.size(); ++
i)
483 if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(1))
485 ImGui::OpenPopup(
"component_context");
491 if (ImGui::BeginPopup(
"component_context"))
493 if (ImGui::MenuItem(
"Remove"))
502 if (ImGui::Button(
"Add Component",
ImVec2(-1, 0)))
509 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
"No blueprint loaded");
511 ImGui::Text(
"Use File > New or File > Open");
512 ImGui::Text(
"to get started");
524 ImGui::Begin(
"Component Graph");
528 ImNodes::BeginNodeEditor();
531 for (
size_t i = 0;
i <
blueprint.components.size(); ++
i)
538 ImNodes::BeginNodeTitleBar();
539 ImGui::TextUnformatted(
comp.type.c_str());
540 ImNodes::EndNodeTitleBar();
543 ImGui::PushItemWidth(120.0f);
546 ImGui::TextDisabled(
"Type: %s",
comp.type.c_str());
547 ImGui::TextDisabled(
"Click to view properties");
549 ImGui::PopItemWidth();
557 float x = 100.0f + (
i % 3) * 250.0f;
558 float y = 100.0f + (
i / 3) * 150.0f;
564 ImNodes::EndNodeEditor();
578 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
"No blueprint loaded");
580 ImGui::Text(
"Components will appear as nodes here");
592 ImGui::Begin(
"Properties");
599 ImGui::Text(
"Component: %s",
comp.type.c_str());
603 ImGui::Text(
"Properties:");
608 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.0f, 1.0f),
609 "Note: Use console editor (Phase 1) for property editing");
610 ImGui::Text(
"Phase 2 property editing requires full JSON library");
614 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
615 "Select a component to view properties");
628 ImGui::Begin(
"##StatusBar",
nullptr,
634 ImGui::Text(
"Blueprint: %s",
blueprint.name.c_str());
636 ImGui::Text(
" | Components: %zu",
blueprint.components.size());
638 if (
backend.HasUnsavedChanges())
641 ImGui::TextColored(
ImVec4(1.0f, 0.7f, 0.0f, 1.0f),
"| Modified");
644 const std::string& filepath =
backend.GetCurrentFilepath();
645 if (!filepath.empty())
648 ImGui::TextDisabled(
"| %s", filepath.c_str());
653 ImGui::Text(
"Ready | No blueprint loaded");
657 ImGui::PopStyleVar();
662 ImGui::OpenPopup(
"Add Component");
670 ImGui::Text(
"Select component type:");
674 "Position",
"BoundingBox",
"VisualSprite",
"Movement",
675 "PhysicsBody",
"Health",
"AIBehavior",
"TriggerZone",
676 "Animation",
"AudioSource",
"Inventory",
"PlayerController"
684 if (ImGui::Button(
"Add",
ImVec2(120, 0)))
692 if (ImGui::Button(
"Cancel",
ImVec2(120, 0)))
726 if (
backend.GetCurrentFilepath().empty())
729 const std::string& name =
backend.GetCurrentBlueprint().name;
730 std::string filepath =
"../Blueprints/" + name +
".json";
731 backend.SaveBlueprintAs(filepath);
744 const std::string& name =
backend.GetCurrentBlueprint().name;
745 std::string filepath =
"../Blueprints/" + name +
"_copy.json";
746 backend.SaveBlueprintAs(filepath);
758 if (type ==
"Position")
762 else if (type ==
"BoundingBox")
766 else if (type ==
"VisualSprite")
770 else if (type ==
"Movement")
774 else if (type ==
"PhysicsBody")
778 else if (type ==
"Health")
782 else if (type ==
"AIBehavior")
790 newComp.properties = json::object();
820 ImGui::OpenPopup(
"Preferences");
828 ImGui::Text(
"Editor Preferences");
831 ImGui::TextWrapped(
"Preferences coming soon...");
834 ImGui::Text(
"Planned settings:");
835 ImGui::BulletText(
"Auto-save interval");
836 ImGui::BulletText(
"Theme selection");
837 ImGui::BulletText(
"Grid snap settings");
838 ImGui::BulletText(
"Default component properties");
842 if (ImGui::Button(
"Close",
ImVec2(120, 0)))
853 ImGui::OpenPopup(
"Keyboard Shortcuts");
861 ImGui::Text(
"Keyboard Shortcuts");
864 ImGui::Columns(2,
"shortcuts");
865 ImGui::SetColumnWidth(0, 200);
867 ImGui::Text(
"Editor Control:");
869 ImGui::Text(
"F2"); ImGui::NextColumn(); ImGui::Text(
"Toggle Blueprint Editor"); ImGui::NextColumn();
870 ImGui::Text(
"Escape"); ImGui::NextColumn(); ImGui::Text(
"Exit Application"); ImGui::NextColumn();
873 ImGui::Text(
"File Operations:");
875 ImGui::Text(
"Ctrl+N"); ImGui::NextColumn(); ImGui::Text(
"New Blueprint"); ImGui::NextColumn();
876 ImGui::Text(
"Ctrl+O"); ImGui::NextColumn(); ImGui::Text(
"Open Blueprint"); ImGui::NextColumn();
877 ImGui::Text(
"Ctrl+S"); ImGui::NextColumn(); ImGui::Text(
"Save"); ImGui::NextColumn();
878 ImGui::Text(
"Ctrl+Shift+S"); ImGui::NextColumn(); ImGui::Text(
"Save As"); ImGui::NextColumn();
881 ImGui::Text(
"Edit Operations:");
883 ImGui::Text(
"Ctrl+Z"); ImGui::NextColumn(); ImGui::Text(
"Undo"); ImGui::NextColumn();
884 ImGui::Text(
"Ctrl+Y"); ImGui::NextColumn(); ImGui::Text(
"Redo"); ImGui::NextColumn();
885 ImGui::Text(
"Insert"); ImGui::NextColumn(); ImGui::Text(
"Add Component"); ImGui::NextColumn();
886 ImGui::Text(
"Delete"); ImGui::NextColumn(); ImGui::Text(
"Remove Component"); ImGui::NextColumn();
891 if (ImGui::Button(
"Close",
ImVec2(120, 0)))
904 ImGui::OpenPopup(
"Migrate Blueprints");
912 ImGui::TextWrapped(
"This will migrate all v1 blueprints to v2 format:");
915 ImGui::BulletText(
"Add schema_version and blueprintType fields");
916 ImGui::BulletText(
"Calculate and save node positions");
917 ImGui::BulletText(
"Unify parameters structure");
918 ImGui::BulletText(
"Create .v1.backup files");
924 ImGui::TextWrapped(
"Scanning: Blueprints/");
925 ImGui::TextColored(
ImVec4(1.0f, 0.7f, 0.0f, 1.0f),
926 "Warning: This will modify your blueprint files!");
931 if (ImGui::Button(
"Migrate All",
ImVec2(150, 0)))
933 backend.MigrateAllBlueprints();
934 backend.SetShowMigrationDialog(
false);
939 if (ImGui::Button(
"Cancel",
ImVec2(150, 0)))
941 backend.SetShowMigrationDialog(
false);
949 backend.SetShowMigrationDialog(
false);
960 if (
io.WantTextInput)
966 if (
io.KeyCtrl && ImGui::IsKeyPressed(
ImGuiKey_Z) && !
io.KeyShift)
985 if (
io.KeyCtrl && ImGui::IsKeyPressed(
ImGuiKey_S) && !
io.KeyShift)
1016 if (
io.KeyCtrl &&
io.KeyShift && ImGui::IsKeyPressed(
ImGuiKey_T))
ComponentTypeID GetComponentTypeID_Static()
void Initialize(const std::string &assetsRootPath)
void SetAssetOpenCallback(std::function< void(const std::string &)> callback)
void AddComponent(const std::string &type)
class HistoryPanel * m_HistoryPanel
int m_SelectedComponentIndex
void HandleKeyboardShortcuts()
void RenderShortcutsDialog()
AssetBrowser m_AssetBrowser
void LoadBlueprint(const std::string &filepath)
bool m_ShowAddComponentDialog
bool m_ShowTemplateBrowser
int m_SelectedComponentType
std::map< int, ImVec2 > m_NodePositions
EntitiesPanel m_EntitiesPanel
class TemplateBrowserPanel * m_TemplateBrowserPanel
char m_FilepathBuffer[512]
void RenderPreferencesDialog()
void RemoveComponent(int index)
NodeGraphPanel m_NodeGraphPanel
void RenderComponentAddDialog()
void RenderPropertyPanel()
void RenderMigrationDialog()
char m_NewBlueprintNameBuffer[256]
InspectorPanel m_InspectorPanel
void NewBlueprint(const std::string &name, const std::string &description="")
Blueprint::EntityBlueprint & GetCurrentBlueprintMutable()
static BlueprintEditor & Get()
HistoryPanel - ImGui panel for command history visualization Shows undo/redo stacks with command desc...
TemplateBrowserPanel - ImGui panel for template management Provides interface for browsing,...
ComponentData CreateVisualSpriteComponent(const std::string &spritePath, float srcX, float srcY, float srcWidth, float srcHeight, float hotSpotX, float hotSpotY)
ComponentData CreateBoundingBoxComponent(float x, float y, float width, float height)
ComponentData CreateMovementComponent(float dirX, float dirY, float velX, float velY)
ComponentData CreateAIBehaviorComponent(const std::string &behaviorType)
ComponentData CreatePositionComponent(float x, float y)
ComponentData CreatePhysicsBodyComponent(float mass, float speed)
ComponentData CreateHealthComponent(int current, int max)
std::vector< ComponentData > components