diff --git a/Eklipse/src/Eklipse/Project/ProjectExporter.cpp b/Eklipse/src/Eklipse/Project/ProjectExporter.cpp index a4a1b70..6447dfd 100644 --- a/Eklipse/src/Eklipse/Project/ProjectExporter.cpp +++ b/Eklipse/src/Eklipse/Project/ProjectExporter.cpp @@ -73,6 +73,7 @@ namespace Eklipse EK_CORE_PROFILE(); EK_ASSERT(project, "Project is null!"); + std::error_code ec; auto& config = project->GetConfig(); EK_CORE_INFO("Exporting project '{0}' to '{1}'", config.name, settings.path.string()); @@ -109,7 +110,6 @@ namespace Eklipse else { EK_CORE_WARN("Script library not found at path '{0}'!", scriptLibraryPath.string()); - return false; } // Copy the engine library @@ -130,7 +130,12 @@ namespace Eklipse if (FileUtilities::IsPathValid(scriptApiLibraryPath)) { Path destinationScriptApiLibraryPath = destinationDir / (String("EklipseScriptAPI") + EK_SCRIPT_LIBRARY_EXTENSION); - fs::copy_file(scriptApiLibraryPath, destinationScriptApiLibraryPath, fs::copy_options::overwrite_existing); + fs::copy_file(scriptApiLibraryPath, destinationScriptApiLibraryPath, fs::copy_options::overwrite_existing, ec); + if (ec) + { + EK_CORE_ERROR("Failed to copy script API library! {0}", ec.message()); + return false; + } } else { diff --git a/Eklipse/src/Eklipse/Scene/Scene.cpp b/Eklipse/src/Eklipse/Scene/Scene.cpp index dc11aa5..5754d66 100644 --- a/Eklipse/src/Eklipse/Scene/Scene.cpp +++ b/Eklipse/src/Eklipse/Scene/Scene.cpp @@ -616,9 +616,12 @@ namespace Eklipse if (scriptComponent) { auto scriptName = TryDeserailize(scriptComponent, "Name", ""); - auto& scriptComponent = deserializedEntity.AddComponent(); - scriptComponent.scriptName = scriptName; - ScriptLinker::Get().FetchScriptClasses({ scriptName }); + if (!scriptName.empty()) + { + auto& scriptComponent = deserializedEntity.AddComponent(); + scriptComponent.scriptName = scriptName; + ScriptLinker::Get().FetchScriptClasses({ scriptName }); + } /*if (!scriptName.empty()) { EklipseEngine::Reflections::ClassInfo info{}; @@ -685,7 +688,7 @@ namespace Eklipse if (scriptComponent) { auto properties = scriptComponent["Properties"]; - if (properties) + if (properties && entity.HasComponent()) DeserializeScriptProperties(entity, properties); } } diff --git a/Eklipse/src/Eklipse/Scripting/ScriptLinker.cpp b/Eklipse/src/Eklipse/Scripting/ScriptLinker.cpp index 1660663..649d267 100644 --- a/Eklipse/src/Eklipse/Scripting/ScriptLinker.cpp +++ b/Eklipse/src/Eklipse/Scripting/ScriptLinker.cpp @@ -82,7 +82,7 @@ namespace Eklipse } catch (const std::exception& e) { - EK_CORE_ERROR("Failed to fetch script class: {0}. {1}", scriptClassName, e.what()); + EK_CORE_ERROR("Failed to fetch script class: '{0}'. {1}", scriptClassName, e.what()); } } diff --git a/Eklipse/src/Eklipse/Scripting/ScriptManager.cpp b/Eklipse/src/Eklipse/Scripting/ScriptManager.cpp index 4cc6623..cddb177 100644 --- a/Eklipse/src/Eklipse/Scripting/ScriptManager.cpp +++ b/Eklipse/src/Eklipse/Scripting/ScriptManager.cpp @@ -18,6 +18,16 @@ namespace Eklipse default: return "Unknown"; } } + static String BuildTypeToFolderName(ProjectExportBuildType type) + { + switch (type) + { + case ProjectExportBuildType::DEBUG: return "Debug"; + case ProjectExportBuildType::Developement: return "Developement"; + case ProjectExportBuildType::Release: return "Release"; + default: return "Unknown"; + } + } ScriptManager::ScriptManager(ScriptManagerSettings* settings) : m_settings(settings), m_state(ScriptsState::NONE) @@ -35,7 +45,7 @@ namespace Eklipse SetState(ScriptsState::NONE); - auto& libraryPath = config.scriptBuildDirectoryPath / BuildTypeToString(EK_CURRENT_CONFIG) / (config.name + EK_SCRIPT_LIBRARY_EXTENSION); + auto& libraryPath = config.scriptBuildDirectoryPath / BuildTypeToFolderName(EK_CURRENT_CONFIG) / (config.name + EK_SCRIPT_LIBRARY_EXTENSION); if (fs::exists(libraryPath) && m_scriptLinker->LinkScriptLibrary(libraryPath)) { auto& classReflections = ScriptParser::ParseDirectory(config.scriptsSourceDirectoryPath); @@ -247,7 +257,7 @@ namespace Eklipse RunPremake(config.scriptPremakeDirectoryPath); CompileScripts(config.scriptsSourceDirectoryPath, EK_CURRENT_CONFIG); - auto& libraryPath = config.scriptBuildDirectoryPath / BuildTypeToString(EK_CURRENT_CONFIG) / (config.name + EK_SCRIPT_LIBRARY_EXTENSION); + auto& libraryPath = config.scriptBuildDirectoryPath / BuildTypeToFolderName(EK_CURRENT_CONFIG) / (config.name + EK_SCRIPT_LIBRARY_EXTENSION); if (FileUtilities::IsPathValid(libraryPath)) { if (m_scriptLinker->LinkScriptLibrary(libraryPath)) diff --git a/EklipseEditor/Resources/Scripting/Premake/premake5.lua b/EklipseEditor/Resources/Scripting/Premake/premake5.lua index 38db718..f8affe1 100644 --- a/EklipseEditor/Resources/Scripting/Premake/premake5.lua +++ b/EklipseEditor/Resources/Scripting/Premake/premake5.lua @@ -80,13 +80,13 @@ project "__PRJ_NAME__" } end - configs = { "Debug", "Developement", "Release" } - for _, config in ipairs(configs) do + configs = { Debug="Debug", Developement="Release", Release="Dist" } + for name, config in pairs(configs) do for system, ext in pairs(extensions) do filter { "system:" .. system, "configurations:" .. config } postbuildcommands { - "{COPY} %{cfg.targetdir}/%{prj.name}" .. ext .. " ./Scripts/Build/" .. config + "{COPY} %{cfg.targetdir}/%{prj.name}" .. ext .. " ./Scripts/Build/" .. name } end end \ No newline at end of file diff --git a/EklipseEditor/src/EditorLayer.cpp b/EklipseEditor/src/EditorLayer.cpp index 0a9c524..caae284 100644 --- a/EklipseEditor/src/EditorLayer.cpp +++ b/EklipseEditor/src/EditorLayer.cpp @@ -649,6 +649,11 @@ namespace Eklipse if (EK_CURRENT_CONFIG != exportSettings.buildType && ScriptLinker::Get().HasAnyScriptClasses()) { m_scriptManager->CompileScripts(Project::GetActive()->GetConfig().scriptsSourceDirectoryPath, exportSettings.buildType); + if (m_scriptManager->GetScriptsState() == ScriptsState::COMPILATION_FAILED) + { + EK_ERROR("Failed to compile scripts!"); + return; + } } if (!ProjectExporter::Export(m_editorAssetLibrary, Project::GetActive(), exportSettings)) { diff --git a/EklipseSandbox/imgui.ini b/EklipseSandbox/imgui.ini index e1fc87b..8d29e30 100644 --- a/EklipseSandbox/imgui.ini +++ b/EklipseSandbox/imgui.ini @@ -19,7 +19,7 @@ Size=381,205 Collapsed=0 [Window][Sandbox] -Pos=866,80 +Pos=1047,132 Size=544,586 Collapsed=0 diff --git a/README.md b/README.md index 3e27a1c..3468a61 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Eklipse Engine +# Eklipse Engine Eklipse is a game engine which tries to provide proof-of-concept solutions to the most important problems of a complex game engine (which this engine is not). -## How it works +## How it works ⚙ **Editor** - allows you to import assets, view the scene, scene hierarchy and export the project to a precompiled executable. Editor supports managing multiple projects. @@ -19,7 +19,7 @@ Eklipse is a game engine which tries to provide proof-of-concept solutions to th

-**Scritps API** - all scripts are written in C++ and provide a simple custom logic injection system. Scripts are part of a separate C++ project that is automatically created with an editor project. Creating a new script is as simple as writing a new class that derives from the base *Script* class. All scripts are compiled into a shared library that is then linked to a given executable (Editor or Runtime). +**Script API** - all scripts are written in C++ and provide a simple custom logic injection system. Scripts are part of a separate C++ project that is automatically created with an editor project. Creating a new script is as simple as writing a new class that derives from the base *Script* class. All scripts are compiled into a shared library that is then linked to a given executable (Editor or Runtime). ```cpp @@ -32,8 +32,8 @@ public: void OnCreate(); void OnUpdate(float deltaTime); - float speed = 5.0f; - float rotationSpeed = 5.0f; + EK_FLOAT speed = 5.0f; + EK_FLOAT rotationSpeed = 5.0f; }; ``` @@ -95,9 +95,9 @@ void CameraController::OnUpdate(float deltaTime) ## Disclaimer ⚠ -This engine has been written in Visual Studio 2022 on Windows and this is the only target setup that is supported for now. +This project has been written in Visual Studio 2022 on Windows and this is the only target setup that is supported for now. -## How to build +## How to build 🛠 1. Clone the repo with all of it's submodules