mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-03 14:09:46 +03:00
Removed Wren script references in the UI
This commit is contained in:
@@ -1,115 +0,0 @@
|
||||
#include "ScriptPanel.h"
|
||||
#include "../Windows/FileSystemUI.h"
|
||||
#include <src/Scene/Components/WrenScriptComponent.h>
|
||||
#include "src/FileSystem/FileDialog.h"
|
||||
#include "src/FileSystem/FileSystem.h"
|
||||
|
||||
void ScriptPanel::Draw(Nuake::Entity entity)
|
||||
{
|
||||
if (!entity.HasComponent<Nuake::WrenScriptComponent>())
|
||||
return;
|
||||
|
||||
Nuake::WrenScriptComponent& component = entity.GetComponent<Nuake::WrenScriptComponent>();
|
||||
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<const char*> 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();
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user