5#include "../include/TilemapEditorApp.h"
6#include "../../third_party/imgui/imgui.h"
14 : m_showNewLevelDialog(
false)
15 , m_showOpenLevelDialog(
false)
16 , m_showSaveLevelDialog(
false)
17 , m_showAboutDialog(
false)
18 , m_viewportZoom(1.0f)
19 , m_viewportOffset(0, 0, 0)
21 , m_initialized(
false)
36 std::cerr <<
"[TilemapEditorApp] Already initialized" << std::endl;
40 std::cout <<
"[TilemapEditorApp] Initializing..." << std::endl;
50 std::cout <<
"[TilemapEditorApp] Initialization complete" << std::endl;
62 std::cout <<
"[TilemapEditorApp] Shutting down..." << std::endl;
115 const std::string& currentPath =
m_levelManager->GetCurrentLevelPath();
116 if (currentPath.empty())
152 if (ImGui::BeginMainMenuBar())
154 if (ImGui::BeginMenu(
"File"))
156 if (ImGui::MenuItem(
"New Level",
"Ctrl+N"))
160 if (ImGui::MenuItem(
"Open Level...",
"Ctrl+O"))
165 if (ImGui::MenuItem(
"Save",
"Ctrl+S"))
169 if (ImGui::MenuItem(
"Save As...",
"Ctrl+Shift+S"))
174 if (ImGui::MenuItem(
"Exit",
"Alt+F4"))
181 if (ImGui::BeginMenu(
"Edit"))
186 if (ImGui::MenuItem(
"Undo",
"Ctrl+Z",
false,
canUndo))
190 if (ImGui::MenuItem(
"Redo",
"Ctrl+Y",
false,
canRedo))
197 if (ImGui::BeginMenu(
"View"))
199 if (ImGui::MenuItem(
"Reset Zoom"))
203 if (ImGui::MenuItem(
"Reset Pan"))
210 if (ImGui::BeginMenu(
"Help"))
212 if (ImGui::MenuItem(
"About"))
219 ImGui::EndMainMenuBar();
225 ImGui::Begin(
"Toolbar");
227 ImGui::Text(
"Tools");
230 if (ImGui::Button(
"Select",
ImVec2(80, 30)))
236 if (ImGui::Button(
"Paint Tile",
ImVec2(80, 30)))
242 if (ImGui::Button(
"Entity",
ImVec2(80, 30)))
256 ImGui::Begin(
"Level Viewport");
262 ImGui::TextColored(
ImVec4(1.0f, 0.5f, 0.0f, 1.0f),
"*");
270 if (ImGui::Button(
"-"))
275 if (ImGui::Button(
"+"))
286 ImGui::Text(
"Canvas Area");
288 ImGui::Text(
"Entities: %zu",
m_levelManager->GetAllEntities().size());
303 ImGui::Begin(
"Entity List");
305 ImGui::Text(
"Entities");
308 if (ImGui::Button(
"Add Entity"))
310 auto cmd = std::make_unique<PlaceEntityCommand>(
311 "Blueprints/DefaultEntity.json",
321 for (
auto* entity : entities)
329 ImGui::TreeNodeEx(entity->id.c_str(),
node_flags,
"%s", entity->name.c_str());
330 if (ImGui::IsItemClicked())
336 if (ImGui::BeginPopupContextItem())
338 if (ImGui::MenuItem(
"Delete"))
340 auto cmd = std::make_unique<DeleteEntityCommand>(entity->id);
353 ImGui::Begin(
"Properties");
360 ImGui::Text(
"Entity Properties");
378 ImGui::Text(
"Prefab: %s", entity->
prefabPath.c_str());
381 float posX =
static_cast<float>(entity->
position.
x);
382 float posY =
static_cast<float>(entity->
position.
y);
383 if (ImGui::DragFloat(
"Position X", &posX, 1.0f))
388 if (ImGui::DragFloat(
"Position Y", &posY, 1.0f))
396 ImGui::Text(
"Selected entity not found");
402 ImGui::Text(
"No entity selected");
410 ImGui::Begin(
"History");
412 ImGui::Text(
"Command History");
427 ImGui::Text(
"History Size: %zu",
m_editorState->GetHistorySize());
428 ImGui::Text(
"Current Index: %zu",
m_editorState->GetHistoryIndex());
432 ImGui::Text(
"Next Undo: %s",
m_editorState->GetUndoDescription().c_str());
436 ImGui::Text(
"Next Redo: %s",
m_editorState->GetRedoDescription().c_str());
445 ImGui::SetNextWindowPos(
ImVec2(viewport->WorkPos.x, viewport->WorkPos.y + viewport->WorkSize.y - 25));
446 ImGui::SetNextWindowSize(
ImVec2(viewport->WorkSize.x, 25));
451 ImGui::Text(
"Olympe Tilemap Editor - Phase 1");
452 ImGui::SameLine(viewport->WorkSize.x - 200);
453 ImGui::Text(
"Entities: %zu",
m_levelManager->GetAllEntities().size());
464 ImGui::OpenPopup(
"New Level");
471 ImGui::Text(
"Create a new level");
478 if (ImGui::Button(
"Create",
ImVec2(120, 0)))
481 if (levelName.empty())
483 levelName =
"UntitledLevel";
491 if (ImGui::Button(
"Cancel",
ImVec2(120, 0)))
502 ImGui::OpenPopup(
"Open Level");
509 ImGui::Text(
"Open an existing level");
513 ImGui::Text(
"Note: Use full or relative path to JSON file");
517 if (ImGui::Button(
"Open",
ImVec2(120, 0)))
520 if (!filePath.empty())
531 std::cerr <<
"[TilemapEditorApp] Failed to open level: " << filePath << std::endl;
536 if (ImGui::Button(
"Cancel",
ImVec2(120, 0)))
547 ImGui::OpenPopup(
"Save Level As");
554 ImGui::Text(
"Save level to file");
558 ImGui::Text(
"Note: Use full or relative path (e.g., Levels/my_level.json)");
562 if (ImGui::Button(
"Save",
ImVec2(120, 0)))
565 if (!filePath.empty())
574 std::cerr <<
"[TilemapEditorApp] Failed to save level: " << filePath << std::endl;
579 if (ImGui::Button(
"Cancel",
ImVec2(120, 0)))
590 ImGui::OpenPopup(
"About");
597 ImGui::Text(
"Olympe Tilemap Editor");
599 ImGui::Text(
"Version: 1.0.0 (Phase 1)");
600 ImGui::Text(
"Author: Atlasbruce");
602 ImGui::Text(
"A tilemap/level editor for Olympe Engine");
603 ImGui::Text(
"Built with SDL3 + ImGui");
606 if (ImGui::Button(
"Close",
ImVec2(120, 0)))
ComponentTypeID GetComponentTypeID_Static()
std::unique_ptr< EditorState > m_editorState
bool m_showNewLevelDialog
bool m_showOpenLevelDialog
bool m_showSaveLevelDialog
std::string m_selectedEntityId
void RenderLevelViewport()
char m_filePathBuffer[512]
bool HasUnsavedChanges() const
char m_newLevelNameBuffer[256]
void RenderPropertiesPanel()
void ShowSaveLevelDialog()
void RenderHistoryPanel()
void ShowNewLevelDialog()
void ShowOpenLevelDialog()
const std::string & GetCurrentLevelName() const
std::unique_ptr< LevelManager > m_levelManager