From 8a931c768bf9ddda07179f454b952e3aea8a9106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89meryc?= Date: Fri, 21 Jul 2023 19:29:50 -0400 Subject: [PATCH] NK-126 - Fix Indent --- Editor/src/ComponentsPanel/ScriptPanel.cpp | 166 ++++++++++----------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/Editor/src/ComponentsPanel/ScriptPanel.cpp b/Editor/src/ComponentsPanel/ScriptPanel.cpp index 3c27ae3e..b9e7b512 100644 --- a/Editor/src/ComponentsPanel/ScriptPanel.cpp +++ b/Editor/src/ComponentsPanel/ScriptPanel.cpp @@ -6,106 +6,106 @@ void ScriptPanel::Draw(Nuake::Entity entity) { if (!entity.HasComponent()) - return; + return; - Nuake::WrenScriptComponent& component = entity.GetComponent(); - BeginComponentTable(SCRIPT, Nuake::WrenScriptComponent); + Nuake::WrenScriptComponent& component = entity.GetComponent(); + BeginComponentTable(SCRIPT, Nuake::WrenScriptComponent); + { { + ImGui::Text("Script"); + ImGui::TableNextColumn(); + + std::string path = component.Script; + ImGui::Button( path.empty() ? "Create New" : component.Script.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0)); + if (ImGui::BeginDragDropTarget()) { - ImGui::Text("Script"); - ImGui::TableNextColumn(); - - std::string path = component.Script; - ImGui::Button( path.empty() ? "Create New" : component.Script.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0)); - if (ImGui::BeginDragDropTarget()) + if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Script")) { - if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Script")) - { - char* file = (char*)payload->Data; + char* file = (char*)payload->Data; - std::string fullPath = std::string(file, 512); - path = Nuake::FileSystem::AbsoluteToRelative(std::move(fullPath)); + std::string fullPath = std::string(file, 512); + path = Nuake::FileSystem::AbsoluteToRelative(std::move(fullPath)); - component.LoadScript(path); - } - ImGui::EndDragDropTarget(); + component.LoadScript(path); } + ImGui::EndDragDropTarget(); + } - component.Script = path; + component.Script = path; - // Double click on file - if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) + // Double click on file + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) + { + if(!component.Script.empty()) { - if(!component.Script.empty()) + Nuake::OS::OpenIn(component.mWrenScript->GetFile()->GetAbsolutePath()); + } + else + { + // TODO: Turn into command (Undo/Redo) + + std::string pathCreation = Nuake::FileDialog::SaveFile("*.wren"); + + if (!pathCreation.empty()) { - Nuake::OS::OpenIn(component.mWrenScript->GetFile()->GetAbsolutePath()); - } - else - { - // TODO: Turn into command (Undo/Redo) - - std::string pathCreation = Nuake::FileDialog::SaveFile("*.wren"); - - if (!pathCreation.empty()) + if (!Nuake::String::EndsWith(pathCreation, ".wren")) { - if (!Nuake::String::EndsWith(pathCreation, ".wren")) - { - pathCreation += ".wren"; - } - - std::string fileName = Nuake::String::ToUpper(Nuake::FileSystem::GetFileNameFromPath(pathCreation)); - fileName = Nuake::String::RemoveWhiteSpace(fileName); - - if(!Nuake::String::IsDigit(fileName[0])) - { - Nuake::FileSystem::BeginWriteFile(pathCreation); - Nuake::FileSystem::WriteLine(TEMPLATE_SCRIPT_FIRST + fileName + TEMPLATE_SCRIPT_SECOND); - Nuake::FileSystem::EndWriteFile(); - - path = Nuake::FileSystem::AbsoluteToRelative(pathCreation); - Nuake::FileSystem::Scan(); - Nuake::FileSystemUI::m_CurrentDirectory = Nuake::FileSystem::RootDirectory; - component.LoadScript(path); - component.Script = path; - } - else - { - Nuake::Logger::Log("[FileSystem] Cannot create script files that starts with a number.", Nuake::CRITICAL); - } + pathCreation += ".wren"; } - } - } - - ImGui::TableNextColumn(); + std::string fileName = Nuake::String::ToUpper(Nuake::FileSystem::GetFileNameFromPath(pathCreation)); + fileName = Nuake::String::RemoveWhiteSpace(fileName); + + if(!Nuake::String::IsDigit(fileName[0])) + { + Nuake::FileSystem::BeginWriteFile(pathCreation); + Nuake::FileSystem::WriteLine(TEMPLATE_SCRIPT_FIRST + fileName + TEMPLATE_SCRIPT_SECOND); + Nuake::FileSystem::EndWriteFile(); - ComponentTableReset(component.Script, ""); + path = Nuake::FileSystem::AbsoluteToRelative(pathCreation); + Nuake::FileSystem::Scan(); + Nuake::FileSystemUI::m_CurrentDirectory = Nuake::FileSystem::RootDirectory; + component.LoadScript(path); + component.Script = path; + } + else + { + Nuake::Logger::Log("[FileSystem] Cannot create script files that starts with a number.", Nuake::CRITICAL); + } + } + + } } + ImGui::TableNextColumn(); - { - ImGui::Text("Module"); - ImGui::TableNextColumn(); - // Here we create a dropdown for every modules - auto& wrenScript = component.mWrenScript; - if (wrenScript) - { - auto modules = wrenScript->GetModules(); - - std::vector modulesC; - - for (auto& m : modules) - { - modulesC.push_back(m.c_str()); - } - static int currentModule = (int)component.mModule; - ImGui::Combo("##WrenModule", ¤tModule, &modulesC[0], modules.size()); - component.mModule = currentModule; - } - - ImGui::TableNextColumn(); - //ComponentTableReset(component.Class, ""); - } + ComponentTableReset(component.Script, ""); } - EndComponentTable(); + ImGui::TableNextColumn(); + { + ImGui::Text("Module"); + ImGui::TableNextColumn(); + + // Here we create a dropdown for every modules + auto& wrenScript = component.mWrenScript; + if (wrenScript) + { + auto modules = wrenScript->GetModules(); + + std::vector modulesC; + + for (auto& m : modules) + { + modulesC.push_back(m.c_str()); + } + static int currentModule = (int)component.mModule; + ImGui::Combo("##WrenModule", ¤tModule, &modulesC[0], modules.size()); + component.mModule = currentModule; + } + + ImGui::TableNextColumn(); + //ComponentTableReset(component.Class, ""); + } + } + EndComponentTable(); } \ No newline at end of file