7#include "BlueprintEditor.h"
16#include "../TaskSystem/TaskGraphLoader.h"
17#include "../Core/FontManager.h"
18#include "../third_party/imgui/imgui.h"
19#include "../third_party/imnodes/imnodes.h"
20#include "../third_party/nlohmann/json.hpp"
21#include "../system/system_utils.h"
31 : m_SelectedComponentIndex(-1)
33 , m_ShowDemoWindow(
false)
34 , m_ShowAddComponentDialog(
false)
35 , m_ShowAboutDialog(
false)
36 , m_SelectedComponentType(0)
37 , m_ShowAssetBrowser(
true)
38 , m_ShowAssetInfo(
false)
39 , m_ShowInspector(
true)
40 , m_ShowNodeGraph(
true)
41 , m_ShowEntities(
false)
42 , m_ShowEntityProperties(
false)
43 , m_ShowComponentGraph(
false)
44 , m_ShowPropertyPanel(
false)
45 , m_ShowTemplateBrowser(
false)
46 , m_ShowHistory(
false)
47 , m_ShowDebugger(
false)
48 , m_ShowProfiler(
false)
49 , m_ShowVSEditor(
false)
50 , m_ShowPreferences(
false)
51 , m_ShowShortcuts(
false)
52 , m_TemplateBrowserPanel(
nullptr)
57 , m_AssetBrowserWidth(400.0f)
58 , m_InspectorWidth(400.0f)
59 , m_MinPanelWidth(200.0f)
60 , m_SplitterSize(8.0f)
61 , m_LeftPanelSplitHeight(0.0f)
62 , m_InspectorPanelHeight(0.0f)
63 , m_VerificationLogsPanelHeight(0.0f)
105 ImNodes::CreateContext();
106 ImNodes::StyleColorsDark();
150 if (
config.contains(
"layout"))
153 if (
layout.contains(
"asset_browser_width"))
155 if (
layout.contains(
"inspector_width"))
157 if (
layout.contains(
"min_panel_width"))
159 if (
layout.contains(
"splitter_size"))
169 if (!
config.contains(
"layout"))
170 config[
"layout"] = json::object();
218 ImNodes::DestroyContext();
237 if (ImGui::BeginMainMenuBar())
243 if (ImGui::MenuItem(
ICON_FA_CODE " New Visual Script",
"Ctrl+N"))
246 if (ImGui::MenuItem(
ICON_FA_BRAIN " New Behavior Tree",
"Ctrl+Shift+N"))
249 if (ImGui::MenuItem(
ICON_FA_CUBES " New Entity Prefab",
"Ctrl+Alt+N"))
284 ImGui::TextDisabled(
"Old BehaviorTree v2 system");
285 ImGui::TextDisabled(
"Use 'New Visual Script' instead");
321 bool canUndo =
backend.CanUndo();
322 bool canRedo =
backend.CanRedo();
330 if (ImGui::MenuItem(
undoLabel.c_str(),
"Ctrl+Z",
false, canUndo))
341 if (ImGui::MenuItem(
redoLabel.c_str(),
"Ctrl+Y",
false, canRedo))
349 if (ImGui::MenuItem(
ICON_FA_PLUS " Add Component",
"Insert",
false,
backend.HasBlueprint()))
373 backend.SetShowMigrationDialog(
true);
378 if (ImGui::MenuItem(
ICON_FA_CHECK " Validate All Blueprints"))
380 std::cout <<
"Validating all blueprints..." << std::endl;
389 ImGui::Text(
"Main Panels:");
399 ImGui::Text(
"Additional:");
409 ImGui::Text(
"Debug:");
433 std::cout <<
"Opening documentation..." << std::endl;
449 ImGui::EndMainMenuBar();
469 if (
backend.ShowMigrationDialog())
475 ImGui::OpenPopup(
"About");
478 ImGui::Text(
"Olympe Blueprint Editor");
480 ImGui::Text(
"Visual node-based editor for entity blueprints");
481 ImGui::Text(
"Version: 2.0");
482 ImGui::Text(
"Status: Interactive panels, entity synchronization, full menus");
484 ImGui::Text(
"Libraries:");
485 ImGui::BulletText(
"ImGui for UI");
486 ImGui::BulletText(
"ImNodes for node editing");
487 ImGui::BulletText(
"SDL3 for window/rendering");
489 ImGui::Text(
"Features:");
490 ImGui::BulletText(
"Interactive, dockable panels");
491 ImGui::BulletText(
"Runtime entity tracking");
492 ImGui::BulletText(
"Synchronized panel selection");
493 ImGui::BulletText(
"Full menu system");
494 if (ImGui::Button(
"Close",
ImVec2(120, 0)))
508 ImGui::SetNextWindowPos(
ImVec2(0, ImGui::GetFrameHeight()));
510 ImGui::GetIO().DisplaySize.y - ImGui::GetFrameHeight()));
520 if (!ImGui::Begin(
"##FixedLayoutWindow",
nullptr,
windowFlags))
526 float windowWidth = ImGui::GetContentRegionAvail().x;
542 float leftHeight = ImGui::GetContentRegionAvail().y;
570 ImGui::BeginChild(
"AssetBrowserSection",
578 if (ImGui::IsItemActive())
580 if (ImGui::IsItemHovered())
591 if (ImGui::IsItemActive())
593 if (ImGui::IsItemHovered())
599 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
"Verification Output");
619 ImGui::TextDisabled(
"(Unable to retrieve verification logs - renderer mismatch)");
624 ImGui::TextDisabled(
"(Open a VisualScript graph to see verification logs)");
634 if (ImGui::IsItemActive())
643 if (ImGui::IsItemHovered())
690 ImGui::Begin(
"Entity Properties");
694 ImGui::Text(
"Blueprint: %s",
blueprint.name.c_str());
695 if (
backend.HasUnsavedChanges())
698 ImGui::TextColored(
ImVec4(1.0f, 0.7f, 0.0f, 1.0f),
"*");
704 ImGui::Text(
"Description:");
705 ImGui::TextWrapped(
"%s",
blueprint.description.c_str());
710 ImGui::Text(
"Components (%zu)",
blueprint.components.size());
712 for (
size_t i = 0;
i <
blueprint.components.size(); ++
i)
717 if (ImGui::Selectable(
comp.type.c_str(), selected))
723 if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(1))
725 ImGui::OpenPopup(
"component_context");
731 if (ImGui::BeginPopup(
"component_context"))
733 if (ImGui::MenuItem(
"Remove"))
742 if (ImGui::Button(
"Add Component",
ImVec2(-1, 0)))
749 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
"No blueprint loaded");
751 ImGui::Text(
"Use File > New or File > Open");
752 ImGui::Text(
"to get started");
764 ImGui::Begin(
"Component Graph");
768 ImNodes::BeginNodeEditor();
771 for (
size_t i = 0;
i <
blueprint.components.size(); ++
i)
778 ImNodes::BeginNodeTitleBar();
779 ImGui::TextUnformatted(
comp.type.c_str());
780 ImNodes::EndNodeTitleBar();
783 ImGui::PushItemWidth(120.0f);
786 ImGui::TextDisabled(
"Type: %s",
comp.type.c_str());
787 ImGui::TextDisabled(
"Click to view properties");
789 ImGui::PopItemWidth();
797 float x = 100.0f + (
i % 3) * 250.0f;
798 float y = 100.0f + (
i / 3) * 150.0f;
804 ImNodes::EndNodeEditor();
818 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
"No blueprint loaded");
820 ImGui::Text(
"Components will appear as nodes here");
832 ImGui::Begin(
"Properties");
839 ImGui::Text(
"Component: %s",
comp.type.c_str());
843 ImGui::Text(
"Properties:");
848 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.0f, 1.0f),
849 "Note: Use console editor (Phase 1) for property editing");
850 ImGui::Text(
"Phase 2 property editing requires full JSON library");
854 ImGui::TextColored(
ImVec4(0.7f, 0.7f, 0.7f, 1.0f),
855 "Select a component to view properties");
868 ImGui::Begin(
"##StatusBar",
nullptr,
874 ImGui::Text(
"Blueprint: %s",
blueprint.name.c_str());
876 ImGui::Text(
" | Components: %zu",
blueprint.components.size());
878 if (
backend.HasUnsavedChanges())
881 ImGui::TextColored(
ImVec4(1.0f, 0.7f, 0.0f, 1.0f),
"| Modified");
884 const std::string& filepath =
backend.GetCurrentFilepath();
885 if (!filepath.empty())
888 ImGui::TextDisabled(
"| %s", filepath.c_str());
893 ImGui::Text(
"Ready | No blueprint loaded");
897 ImGui::PopStyleVar();
902 ImGui::OpenPopup(
"Add Component");
910 ImGui::Text(
"Select component type:");
914 "Position",
"BoundingBox",
"VisualSprite",
"Movement",
915 "PhysicsBody",
"Health",
"AIBehavior",
"TriggerZone",
916 "Animation",
"AudioSource",
"Inventory",
"PlayerController"
924 if (ImGui::Button(
"Add",
ImVec2(120, 0)))
932 if (ImGui::Button(
"Cancel",
ImVec2(120, 0)))
955 SYSTEM_LOG <<
"[BlueprintEditorGUI] Created new Visual Script graph via TabManager\n";
984 if (
backend.GetCurrentFilepath().empty())
987 const std::string& name =
backend.GetCurrentBlueprint().name;
988 std::string filepath =
"../Blueprints/" + name +
".json";
989 backend.SaveBlueprintAs(filepath);
1006 SYSTEM_LOG <<
"[BlueprintEditorGUI] SaveBlueprintAs not yet implemented" << std::endl;
1018 if (type ==
"Position")
1022 else if (type ==
"BoundingBox")
1026 else if (type ==
"VisualSprite")
1030 else if (type ==
"Movement")
1034 else if (type ==
"PhysicsBody")
1038 else if (type ==
"Health")
1042 else if (type ==
"AIBehavior")
1050 newComp.properties = json::object();
1080 ImGui::OpenPopup(
"Preferences");
1088 ImGui::Text(
"Editor Preferences");
1091 ImGui::TextWrapped(
"Preferences coming soon...");
1094 ImGui::Text(
"Planned settings:");
1095 ImGui::BulletText(
"Auto-save interval");
1096 ImGui::BulletText(
"Theme selection");
1097 ImGui::BulletText(
"Grid snap settings");
1098 ImGui::BulletText(
"Default component properties");
1102 if (ImGui::Button(
"Close",
ImVec2(120, 0)))
1113 ImGui::OpenPopup(
"Keyboard Shortcuts");
1121 ImGui::Text(
"Keyboard Shortcuts");
1124 ImGui::Columns(2,
"shortcuts");
1125 ImGui::SetColumnWidth(0, 200);
1127 ImGui::Text(
"Editor Control:");
1129 ImGui::Text(
"F2"); ImGui::NextColumn(); ImGui::Text(
"Toggle Blueprint Editor"); ImGui::NextColumn();
1130 ImGui::Text(
"Escape"); ImGui::NextColumn(); ImGui::Text(
"Exit Application"); ImGui::NextColumn();
1133 ImGui::Text(
"File Operations:");
1135 ImGui::Text(
"Ctrl+N"); ImGui::NextColumn(); ImGui::Text(
"New Blueprint"); ImGui::NextColumn();
1136 ImGui::Text(
"Ctrl+O"); ImGui::NextColumn(); ImGui::Text(
"Open Blueprint"); ImGui::NextColumn();
1137 ImGui::Text(
"Ctrl+S"); ImGui::NextColumn(); ImGui::Text(
"Save"); ImGui::NextColumn();
1138 ImGui::Text(
"Ctrl+Shift+S"); ImGui::NextColumn(); ImGui::Text(
"Save As"); ImGui::NextColumn();
1141 ImGui::Text(
"Edit Operations:");
1143 ImGui::Text(
"Ctrl+Z"); ImGui::NextColumn(); ImGui::Text(
"Undo"); ImGui::NextColumn();
1144 ImGui::Text(
"Ctrl+Y"); ImGui::NextColumn(); ImGui::Text(
"Redo"); ImGui::NextColumn();
1145 ImGui::Text(
"Insert"); ImGui::NextColumn(); ImGui::Text(
"Add Component"); ImGui::NextColumn();
1146 ImGui::Text(
"Delete"); ImGui::NextColumn(); ImGui::Text(
"Remove Component"); ImGui::NextColumn();
1151 if (ImGui::Button(
"Close",
ImVec2(120, 0)))
1164 ImGui::OpenPopup(
"Migrate Blueprints");
1172 ImGui::TextWrapped(
"This will migrate all v1 blueprints to v2 format:");
1175 ImGui::BulletText(
"Add schema_version and blueprintType fields");
1176 ImGui::BulletText(
"Calculate and save node positions");
1177 ImGui::BulletText(
"Unify parameters structure");
1178 ImGui::BulletText(
"Create .v1.backup files");
1184 ImGui::TextWrapped(
"Scanning: Blueprints/");
1185 ImGui::TextColored(
ImVec4(1.0f, 0.7f, 0.0f, 1.0f),
1186 "Warning: This will modify your blueprint files!");
1191 if (ImGui::Button(
"Migrate All",
ImVec2(150, 0)))
1193 backend.MigrateAllBlueprints();
1194 backend.SetShowMigrationDialog(
false);
1199 if (ImGui::Button(
"Cancel",
ImVec2(150, 0)))
1201 backend.SetShowMigrationDialog(
false);
1209 backend.SetShowMigrationDialog(
false);
1220 if (
io.WantTextInput)
1224 if (
io.KeyCtrl && ImGui::IsKeyPressed(
ImGuiKey_Z) && !
io.KeyShift)
1239 if (
io.KeyCtrl && ImGui::IsKeyPressed(
ImGuiKey_S) && !
io.KeyShift)
1243 else if (
backend.HasBlueprint())
1248 if (
io.KeyCtrl &&
io.KeyShift && ImGui::IsKeyPressed(
ImGuiKey_S))
1252 else if (
backend.HasBlueprint())
1257 if (
io.KeyCtrl && ImGui::IsKeyPressed(
ImGuiKey_N) && !
io.KeyShift && !
io.KeyAlt)
1261 if (
io.KeyCtrl &&
io.KeyShift && ImGui::IsKeyPressed(
ImGuiKey_N))
1265 if (
io.KeyCtrl &&
io.KeyAlt && ImGui::IsKeyPressed(
ImGuiKey_N) && !
io.KeyShift)
1269 if (
io.KeyCtrl && ImGui::IsKeyPressed(
ImGuiKey_W) && !
io.KeyShift)
1276 if (
io.KeyCtrl &&
io.KeyShift && ImGui::IsKeyPressed(
ImGuiKey_W))
1287 if (
io.KeyCtrl &&
io.KeyShift && ImGui::IsKeyPressed(
ImGuiKey_T))
Converts legacy BT v2 JSON graphs to ATS VS v4 JSON format (Phase 6).
ImGui debug panel for ATS VS runtime debugging (Phase 5).
ComponentTypeID GetComponentTypeID_Static()
#define ICON_FA_PEN_TO_SQUARE
#define ICON_FA_ARROW_ROTATE_RIGHT
#define ICON_FA_LIGHTBULB
#define ICON_FA_DIAGRAM_PROJECT
#define ICON_FA_ROTATE_RIGHT
#define ICON_FA_TRASH_CAN
#define ICON_FA_WINDOW_RESTORE
#define ICON_FA_CIRCLE_INFO
#define ICON_FA_FOLDER_OPEN
#define ICON_FA_FILE_CODE
#define ICON_FA_CIRCLE_QUESTION
#define ICON_FA_FLOPPY_DISK
#define ICON_FA_ROTATE_LEFT
#define ICON_FA_ARROW_RIGHT
ImGui profiler panel for ATS VS node execution metrics (Phase 5).
Central manager for the multi-graph tab system.
ImNodes-based graph editor for ATS Visual Script graphs (Phase 5).
IGraphRenderer adapter that wraps VisualScriptEditorPanel.
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 NewVisualScriptGraph()
void HandleKeyboardShortcuts()
float m_InspectorPanelHeight
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
class VisualScriptEditorPanel * m_VSEditorPanel
EntitiesPanel m_EntitiesPanel
class TemplateBrowserPanel * m_TemplateBrowserPanel
class DebugPanel * m_DebugPanel
char m_FilepathBuffer[512]
void RenderPreferencesDialog()
void RemoveComponent(int index)
NodeGraphPanel m_NodeGraphPanel
class ProfilerPanel * m_ProfilerPanel
void RenderComponentAddDialog()
float m_AssetBrowserWidth
void RenderPropertyPanel()
void RenderMigrationDialog()
char m_NewBlueprintNameBuffer[256]
InspectorPanel m_InspectorPanel
float m_LeftPanelSplitHeight
void NewBlueprint(const std::string &name, const std::string &description="")
Blueprint::EntityBlueprint & GetCurrentBlueprintMutable()
static BlueprintEditor & Get()
ImGui panel that exposes DebugController UI.
void Render()
Renders the debug panel window.
void Initialize()
Initialize font system Must be called after ImGui context creation but before first frame.
static FontManager & Get()
Get singleton instance.
bool LoadFontAwesome(const std::string &fontPath, float fontSize=16.0f)
Load Font Awesome font.
HistoryPanel - ImGui panel for command history visualization Shows undo/redo stacks with command desc...
ImGui panel that visualizes PerformanceProfiler data.
void Render()
Renders the profiler panel window.
Singleton that owns and manages all open graph editor tabs.
bool SaveActiveTabAs(const std::string &path)
Saves the active tab to a specific path.
static TabManager & Get()
Returns the global singleton instance.
std::string CreateNewTab(const std::string &graphType)
Creates a new empty tab of the given graph type.
bool CloseAllTabs()
Attempts to close all tabs.
bool SaveActiveTab()
Saves the active tab.
bool IsEmpty() const
Returns true when there are no open tabs.
bool CloseTab(const std::string &tabID)
Closes the given tab.
void RenderTabBar()
Renders the horizontal tab bar (call before RenderActiveCanvas).
void RenderActiveCanvas()
Renders the graph canvas of the active tab.
std::string OpenFileInTab(const std::string &filePath)
Opens a file in a new tab.
TemplateBrowserPanel - ImGui panel for template management Provides interface for browsing,...
ImNodes graph editor for ATS Visual Script v4 graphs.
void Shutdown()
Shutdown the editor panel and release all resources.
void Initialize()
Initialize the editor panel with ImNodes context and UI helpers.
void RenderVerificationLogsPanel()
Public render method for verification logs panel.
Adapts the existing VisualScriptEditorPanel to the IGraphRenderer interface.
VisualScriptEditorPanel & GetPanel()
Direct access to the wrapped panel (for advanced operations).
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)
< Provides AssetID and INVALID_ASSET_ID
std::vector< ComponentData > components
Represents a single open graph in the editor.