#include "ProjectPanelSupport.h" #include namespace XCEngine::UI::Editor::App { namespace { UIEditorHostCommandEvaluationResult BuildEvaluationResult( bool executable, std::string message) { UIEditorHostCommandEvaluationResult result = {}; result.executable = executable; result.message = std::move(message); return result; } UIEditorHostCommandDispatchResult BuildDispatchResult( bool commandExecuted, std::string message) { UIEditorHostCommandDispatchResult result = {}; result.commandExecuted = commandExecuted; result.message = std::move(message); return result; } } // namespace UIEditorHostCommandEvaluationResult ProjectPanel::EvaluateEditCommand( std::string_view commandId) const { const std::optional target = ResolveEditCommandTarget(); if (!target.has_value()) { return BuildEvaluationResult(false, "Select an asset or folder in Project first."); } if (target->assetsRoot && (commandId == "edit.rename" || commandId == "edit.delete")) { return BuildEvaluationResult(false, "The Assets root cannot be renamed or deleted."); } if (commandId == "edit.rename") { return BuildEvaluationResult( true, "Rename project item '" + target->displayName + "'."); } if (commandId == "edit.delete") { return BuildEvaluationResult( false, "Project delete is blocked until asset metadata ownership is wired."); } if (commandId == "edit.duplicate") { return BuildEvaluationResult( false, "Project duplicate is blocked until asset metadata rewrite is wired."); } if (commandId == "edit.cut" || commandId == "edit.copy" || commandId == "edit.paste") { return BuildEvaluationResult( false, "Project clipboard has no bound asset transfer owner in the current shell."); } return BuildEvaluationResult(false, "Project does not expose this edit command."); } UIEditorHostCommandDispatchResult ProjectPanel::DispatchEditCommand( std::string_view commandId) { const UIEditorHostCommandEvaluationResult evaluation = EvaluateEditCommand(commandId); if (!evaluation.executable) { return BuildDispatchResult(false, evaluation.message); } if (commandId == "edit.rename") { if (m_assetSelection.HasSelection()) { if (const AssetEntry* asset = FindAssetEntry(m_assetSelection.GetSelectedId()); asset != nullptr) { EmitEvent(EventKind::RenameRequested, EventSource::None, asset); return BuildDispatchResult( true, "Project rename requested for '" + asset->displayName + "'."); } } if (m_folderSelection.HasSelection()) { if (const FolderEntry* folder = FindFolderEntry(m_folderSelection.GetSelectedId()); folder != nullptr) { EmitEvent(EventKind::RenameRequested, EventSource::None, folder); return BuildDispatchResult( true, "Project rename requested for '" + folder->label + "'."); } } return BuildDispatchResult(false, "Select an asset or folder in Project first."); } return BuildDispatchResult(false, "Project does not expose this edit command."); } } // namespace XCEngine::UI::Editor::App