4#include "../../system/system_utils.h"
5#include "../../Source/third_party/imgui/imgui.h"
6#include "../Utilities/CustomCanvasEditor.h"
12 : m_canvas(
canvas), m_filePath(
""), m_isDirty(
false), m_canvasPanelWidth(0.75f)
37 float totalWidth = ImGui::GetContentRegionAvail().x;
49 ImVec2 canvasSize = ImGui::GetContentRegionAvail();
62 SYSTEM_LOG <<
"[EntityPrefabRenderer] CustomCanvasEditor initialized\n";
134 if (ImGui::IsItemHovered())
142 ImGui::PopStyleColor(3);
160 if (ImGui::BeginDragDropTarget())
164 const char* componentName = (
const char*)
payload->Data;
169 ImGui::EndDragDropTarget();
171 ImGui::PopClipRect();
177 ImGui::TextUnformatted(
"Right Panel");
183 if (ImGui::BeginTabItem(
"Components"))
190 if (ImGui::BeginTabItem(
"Properties"))
194 if (selectedNodes.size() > 0)
216 SYSTEM_LOG <<
"[EntityPrefabRenderer] Loaded JSON from: " << path <<
"\n";
219 if (
jsonData.contains(
"blueprintType"))
221 std::string blueprintType =
jsonData[
"blueprintType"].get<std::string>();
222 SYSTEM_LOG <<
"[EntityPrefabRenderer] blueprintType: " << blueprintType <<
"\n";
223 if (blueprintType !=
"EntityPrefab")
225 SYSTEM_LOG <<
"[EntityPrefabRenderer] ERROR: Not an EntityPrefab type\n";
234 SYSTEM_LOG <<
"[EntityPrefabRenderer] ERROR: GetDocument() returned nullptr\n";
238 SYSTEM_LOG <<
"[EntityPrefabRenderer] Document obtained, loading from file...\n";
243 SYSTEM_LOG <<
"[EntityPrefabRenderer] ERROR: document->LoadFromFile() failed\n";
247 SYSTEM_LOG <<
"[EntityPrefabRenderer] Successfully loaded prefab\n";
251 catch (
const std::exception&
e)
253 SYSTEM_LOG <<
"[EntityPrefabRenderer] EXCEPTION: " <<
e.what() <<
"\n";
285 catch (
const std::exception&)
304 return "EntityPrefab";
352 ImGui::BeginChild(
"##ToolbarEntityPrefab",
ImVec2(0, 40.0f),
true);
354 ImGui::AlignTextToFramePadding();
355 ImGui::Text(
"Minimap:");
367 if (ImGui::DragFloat(
"Size##minimap_ep", &
m_minimapSize, 0.01f, 0.05f, 0.5f))
376 const char*
positionLabels[] = {
"Top-Left",
"Top-Right",
"Bottom-Left",
"Bottom-Right" };
384 ImGui::PopStyleColor();
ComponentTypeID GetComponentTypeID_Static()
void Render(EntityPrefabGraphDocument *document)
const std::vector< NodeId > & GetSelectedNodes() const
bool Save(const std::string &path) override
Saves the current graph state to disk.
void SetCanvasStateJSON(const std::string &json) override
Restore canvas state from JSON string.
std::unique_ptr< ICanvasEditor > m_canvasEditor
bool IsDirty() const override
Returns true when the graph has unsaved changes.
void Render() override
Renders the graph canvas into the current ImGui child window.
EntityPrefabRenderer(PrefabCanvas &canvas)
ComponentPalettePanel m_componentPalette
bool Load(const std::string &path) override
Loads a graph from a file on disk.
std::string GetCanvasStateJSON() const override
Get canvas state as JSON string for persistence.
void RestoreCanvasState() override
Restore previously saved canvas viewport state Called when tab is reactivated.
void SaveCanvasState() override
Save the current canvas viewport state (pan, zoom, etc.) Called when tab is deactivated.
void RenderRightPanelTabs()
std::string GetCurrentPath() const override
Returns the last path successfully loaded/saved, or empty string.
std::string GetGraphType() const override
Returns the graph type string, e.g.
PropertyEditorPanel m_propertyEditor
struct Olympe::EntityPrefabRenderer::CanvasState m_savedCanvasState
void RenderLayoutWithTabs()
EntityPrefabGraphDocument * GetDocument() const
void AcceptComponentDropAtScreenPos(const std::string &componentType, const std::string &componentName, float screenX, float screenY)
void SetCanvasEditor(ICanvasEditor *canvasEditor)
static json LoadJsonFromFile(const std::string &filePath)
void Render(EntityPrefabGraphDocument *document)
void SetSelectedNode(NodeId nodeId)
< Provides AssetID and INVALID_ASSET_ID