Merge branch 'main' into NK-103-camera-corrupted-rotation

This commit is contained in:
Antoine Pilote
2023-07-10 17:36:22 -04:00
30 changed files with 677 additions and 404 deletions

View File

@@ -94,7 +94,7 @@ namespace Nuake {
float needed = half - used;
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || (Input::IsKeyPressed(GLFW_KEY_F5) && !Engine::IsPlayMode))
if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || (Input::IsKeyPressed(GLFW_KEY_F5) && !Engine::IsPlayMode()))
{
SceneSnapshot = Engine::GetCurrentScene()->Copy();
Engine::EnterPlayMode();
@@ -172,14 +172,14 @@ namespace Nuake {
ImGuizmo::AllowAxisFlip(true);
ImGuizmo::SetRect(imagePos.x + 8.0, imagePos.y + 30.0, viewportPanelSize.x, viewportPanelSize.y);
if (m_DrawGrid && !Engine::IsPlayMode)
if (m_DrawGrid && !Engine::IsPlayMode())
{
ImGuizmo::DrawGrid(glm::value_ptr(Engine::GetCurrentScene()->GetCurrentCamera()->GetTransform()),
glm::value_ptr(Engine::GetCurrentScene()->GetCurrentCamera()->GetPerspective()),
glm::value_ptr(glm::identity<glm::mat4>()), 100.f);
}
if (Selection.Type == EditorSelectionType::Entity && !Engine::IsPlayMode)
if (Selection.Type == EditorSelectionType::Entity && !Engine::IsPlayMode())
{
TransformComponent& tc = Selection.Entity.GetComponent<TransformComponent>();
ParentComponent& parent = Selection.Entity.GetComponent<ParentComponent>();
@@ -1498,7 +1498,7 @@ namespace Nuake {
void EditorInterface::Update(float ts)
{
if (!Engine::GetCurrentScene() || Engine::IsPlayMode)
if (!Engine::GetCurrentScene() || Engine::IsPlayMode())
{
return;
}

View File

@@ -9,13 +9,15 @@
#include "src/Rendering/Textures/TextureManager.h"
#include "EditorInterface.h"
const std::string TEMPLATE_SCRIPT = R"(import "Nuake:Engine" for Engine
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 MyEntityScript is ScriptableEntity {
class )";
const std::string TEMPLATE_SCRIPT_SECOND = R"( is ScriptableEntity {
construct new() {
}
@@ -246,6 +248,7 @@ namespace Nuake
if (ImGui::MenuItem("Wren Script"))
{
std::string path = FileDialog::SaveFile("*.wren");
if (!String::EndsWith(path, ".wren"))
{
path += ".wren";
@@ -253,11 +256,22 @@ namespace Nuake
if (!path.empty())
{
FileSystem::BeginWriteFile(path);
FileSystem::WriteLine(TEMPLATE_SCRIPT);
FileSystem::EndWriteFile();
std::string fileName = String::ToUpper(FileSystem::GetFileNameFromPath(path));
fileName = String::RemoveWhiteSpace(fileName);
RefreshFileBrowser();
if(!String::IsDigit(fileName[0]))
{
FileSystem::BeginWriteFile(path);
FileSystem::WriteLine(TEMPLATE_SCRIPT_FIRST + fileName + TEMPLATE_SCRIPT_SECOND);
FileSystem::EndWriteFile();
RefreshFileBrowser();
}
else
{
Logger::Log("[FileSystem] Cannot create script files that starts with a number.", CRITICAL);
}
}
}