diff --git a/Editor/src/ComponentsPanel/ScriptPanel.cpp b/Editor/src/ComponentsPanel/ScriptPanel.cpp deleted file mode 100644 index e712f7e7..00000000 --- a/Editor/src/ComponentsPanel/ScriptPanel.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "ScriptPanel.h" -#include "../Windows/FileSystemUI.h" -#include -#include "src/FileSystem/FileDialog.h" -#include "src/FileSystem/FileSystem.h" - -void ScriptPanel::Draw(Nuake::Entity entity) -{ - if (!entity.HasComponent()) - return; - - 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()) - { - if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Script")) - { - char* file = (char*)payload->Data; - - std::string fullPath = std::string(file, 512); - path = Nuake::FileSystem::AbsoluteToRelative(std::move(fullPath)); - - component.LoadScript(path); - } - ImGui::EndDragDropTarget(); - } - - component.Script = path; - - // Double click on file - if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) - { - if(!component.Script.empty()) - { - if (component.mWrenScript) - { - 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")) - { - 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("Cannot create script files that starts with a number.","fileSystem", Nuake::CRITICAL); - } - } - - } - } - - ImGui::TableNextColumn(); - - ComponentTableReset(component.Script, ""); - } - 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 diff --git a/Editor/src/ComponentsPanel/ScriptPanel.h b/Editor/src/ComponentsPanel/ScriptPanel.h deleted file mode 100644 index dac4c0c2..00000000 --- a/Editor/src/ComponentsPanel/ScriptPanel.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once -#include "ComponentPanel.h" - - -const std::string TEMPLATE_SCRIPT_FIRST = R"(import "Nuake:Engine" for Engine -import "Nuake:ScriptableEntity" for ScriptableEntity -import "Nuake:Input" for Input -import "Nuake:Math" for Vector3, Math -import "Nuake:Scene" for Scene - -class )"; - -const std::string TEMPLATE_SCRIPT_SECOND = R"( is ScriptableEntity { - construct new() { - } - - // Called when the scene gets initialized - init() { - // Engine.Log("Hello World!") - } - - // Called every update - update(ts) { - } - - // Called 90 times per second - fixedUpdate(ts) { - } - - // Called on shutdown - exit() { - } -} -)"; - - -class ScriptPanel : ComponentPanel { - -public: - ScriptPanel() {} - - void Draw(Nuake::Entity entity) override; -}; \ No newline at end of file diff --git a/Editor/src/Windows/EditorSelectionPanel.cpp b/Editor/src/Windows/EditorSelectionPanel.cpp index be5abe21..9e060ca4 100644 --- a/Editor/src/Windows/EditorSelectionPanel.cpp +++ b/Editor/src/Windows/EditorSelectionPanel.cpp @@ -161,7 +161,6 @@ void EditorSelectionPanel::DrawEntity(Nuake::Entity entity) // Draw each component properties panels. mLightPanel.Draw(entity); - mScriptPanel.Draw(entity); mNetScriptPanel.Draw(entity); // mAudioEmitterPanel.Draw(entity); // mParticleEmitterPanel.Draw(entity); diff --git a/Editor/src/Windows/EditorSelectionPanel.h b/Editor/src/Windows/EditorSelectionPanel.h index 6d8ba30a..448f7f93 100644 --- a/Editor/src/Windows/EditorSelectionPanel.h +++ b/Editor/src/Windows/EditorSelectionPanel.h @@ -7,7 +7,6 @@ #include "../ComponentsPanel/TransformPanel.h" #include "../ComponentsPanel/LightPanel.h" -#include "../ComponentsPanel/ScriptPanel.h" #include "../ComponentsPanel/MeshPanel.h" #include "../ComponentsPanel/CameraPanel.h" #include "../ComponentsPanel/BoxColliderPanel.h" @@ -35,7 +34,6 @@ class EditorSelectionPanel private: TransformPanel mTransformPanel; LightPanel mLightPanel; - ScriptPanel mScriptPanel; NetScriptPanel mNetScriptPanel; MeshPanel mMeshPanel; CameraPanel mCameraPanel; diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 7304be65..4c52eb43 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -657,36 +657,6 @@ namespace Nuake } } - if (ImGui::MenuItem("Wren Script")) - { - std::string path = FileDialog::SaveFile("*.wren"); - - if (!String::EndsWith(path, ".wren")) - { - path += ".wren"; - } - - if (!path.empty()) - { - std::string fileName = String::ToUpper(FileSystem::GetFileNameFromPath(path)); - fileName = String::RemoveWhiteSpace(fileName); - - if(!String::IsDigit(fileName[0])) - { - - FileSystem::BeginWriteFile(path, true); - FileSystem::WriteLine(TEMPLATE_SCRIPT_FIRST + fileName + TEMPLATE_SCRIPT_SECOND); - FileSystem::EndWriteFile(); - - RefreshFileBrowser(); - } - else - { - Logger::Log("Cannot create script files that starts with a number.", "filesystem", CRITICAL); - } - } - } - ImGui::EndMenu(); }