#include "ProductEditorHostCommandBridge.h" #include namespace XCEngine::UI::Editor::App { void ProductEditorHostCommandBridge::BindSession(ProductEditorSession& session) { m_session = &session; } void ProductEditorHostCommandBridge::SetExitRequestHandler(std::function handler) { m_requestExit = std::move(handler); } UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::EvaluateHostCommand( std::string_view commandId) const { UIEditorHostCommandEvaluationResult result = {}; if (commandId == "file.exit") { result.executable = true; result.message = "Exit command is ready."; return result; } if (commandId == "help.about") { result.executable = true; result.message = "About placeholder is ready."; return result; } if (commandId.rfind("edit.", 0u) == 0u) { return EvaluateEditCommand(commandId); } if (commandId.rfind("file.", 0u) == 0u) { return BuildDisabledResult("Document command bridge is not attached yet."); } if (commandId.rfind("assets.", 0u) == 0u) { return BuildDisabledResult("Asset pipeline bridge is not attached yet."); } if (commandId.rfind("run.", 0u) == 0u) { return BuildDisabledResult("Runtime bridge is not attached yet."); } if (commandId.rfind("scripts.", 0u) == 0u) { return BuildDisabledResult("Script pipeline bridge is not attached yet."); } return BuildDisabledResult("Host command is not attached yet."); } UIEditorHostCommandDispatchResult ProductEditorHostCommandBridge::DispatchHostCommand( std::string_view commandId) { UIEditorHostCommandDispatchResult result = {}; if (commandId == "file.exit") { result.commandExecuted = true; result.message = "Exit requested."; if (m_requestExit) { m_requestExit(); } return result; } if (commandId == "help.about") { result.commandExecuted = true; result.message = "About dialog will be wired after modal layer lands."; return result; } if (commandId.rfind("edit.", 0u) == 0u) { return DispatchEditCommand(commandId); } result.message = EvaluateHostCommand(commandId).message; return result; } UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::BuildDisabledResult( std::string_view message) const { UIEditorHostCommandEvaluationResult result = {}; result.executable = false; result.message = std::string(message); return result; } UIEditorHostCommandEvaluationResult ProductEditorHostCommandBridge::EvaluateEditCommand( std::string_view commandId) const { if (m_session == nullptr) { return BuildDisabledResult("Editor session is not attached yet."); } switch (m_session->activeRoute) { case ProductEditorActionRoute::Hierarchy: if (SupportsHierarchyEditCommands(commandId)) { return UIEditorHostCommandEvaluationResult{ true, "Hierarchy edit route placeholder is active." }; } return BuildDisabledResult("Current hierarchy route does not expose this command yet."); case ProductEditorActionRoute::Project: if (SupportsProjectEditCommands(commandId)) { return UIEditorHostCommandEvaluationResult{ true, "Project edit route placeholder is active." }; } return BuildDisabledResult("Current project route does not expose this command yet."); case ProductEditorActionRoute::None: return BuildDisabledResult("No active edit route."); default: return BuildDisabledResult("Current panel does not expose edit commands yet."); } } UIEditorHostCommandDispatchResult ProductEditorHostCommandBridge::DispatchEditCommand( std::string_view commandId) { UIEditorHostCommandDispatchResult result = {}; const UIEditorHostCommandEvaluationResult evaluation = EvaluateEditCommand(commandId); if (!evaluation.executable) { result.message = evaluation.message; return result; } result.commandExecuted = true; switch (m_session != nullptr ? m_session->activeRoute : ProductEditorActionRoute::None) { case ProductEditorActionRoute::Hierarchy: result.message = "Hierarchy edit command route reached."; break; case ProductEditorActionRoute::Project: result.message = "Project edit command route reached."; break; default: result.message = "Edit command route reached."; break; } return result; } bool ProductEditorHostCommandBridge::SupportsHierarchyEditCommands( std::string_view commandId) const { return commandId == "edit.cut" || commandId == "edit.copy" || commandId == "edit.paste" || commandId == "edit.duplicate" || commandId == "edit.delete" || commandId == "edit.rename"; } bool ProductEditorHostCommandBridge::SupportsProjectEditCommands( std::string_view commandId) const { return commandId == "edit.delete" || commandId == "edit.rename"; } } // namespace XCEngine::UI::Editor::App