diff --git a/.github/workflows/nix-build.yml b/.github/workflows/nix-build.yml index d34f3016..cb6b2b37 100644 --- a/.github/workflows/nix-build.yml +++ b/.github/workflows/nix-build.yml @@ -11,5 +11,9 @@ jobs: - uses: actions/checkout@v4 - run: git submodule update --init --recursive - uses: cachix/install-nix-action@v31 - - run: nix build ".?submodules=1#" -L - - run: nix flake check ".?submodules=1#" \ No newline at end of file + - name: Check flake + run: nix flake check ".?submodules=1#" + - name: build BeeEngineEditor + run: nix build ".?submodules=1#BeeEngineEditor" -L + - name: build BeeLocalization + run: nix build ".?submodules=1#BeeLocalization" -L \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 401ec917..adcfb3a5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -44,12 +44,12 @@ path = src/Engine/vendor/ImGui/imgui url = https://github.com/ocornut/imgui.git branch = docking -[submodule "src/Engine/vendor/ImGuizmo/imguizmo"] - path = src/Engine/vendor/ImGuizmo/imguizmo - url = https://github.com/CedricGuillemet/ImGuizmo [submodule "src/Engine/vendor/Box2D/box2d"] path = src/Engine/vendor/Box2D/box2d url = https://github.com/erincatto/Box2D [submodule "src/Engine/vendor/msdfgen/msdf-atlas-gen"] path = src/Engine/vendor/msdfgen/msdf-atlas-gen url = https://github.com/Chlumsky/msdf-atlas-gen +[submodule "src/Editor/vendor/ImGuizmo/imguizmo"] + path = src/Editor/vendor/ImGuizmo/imguizmo + url = https://github.com/CedricGuillemet/ImGuizmo diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ffb42ed..efe4a873 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,9 +105,9 @@ include(cmake/StandardProjectSettings.cmake) # Link project_warnings as "library" to use the warnings # specified in CompilerWarnings.cmake. -add_library(project_warnings INTERFACE) -include(cmake/CompilerWarnings.cmake) -set_project_warnings(project_warnings) +#add_library(project_warnings INTERFACE) +#include(cmake/CompilerWarnings.cmake) +#set_project_warnings(project_warnings) add_subdirectory(src/Engine) if(${BEE_BUILD_SANDBOX}) diff --git a/CMakePresets.json b/CMakePresets.json index d017c74f..38d2c16c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -64,6 +64,7 @@ "BEE_USE_VCPKG": "OFF", "NETHOST_LIB": "$env{NETHOST_LIB}", "BEE_BUILD_EDITOR": "ON", + "BEE_BUILD_LOC_TOOL": "ON", "BEE_USE_SYSTEM_SDL3": "ON" }, "vendor": {}, diff --git a/README.org b/README.org index 48dd82ec..798a4a98 100644 --- a/README.org +++ b/README.org @@ -97,14 +97,21 @@ cmake --preset Release **** Linux (Nix) To build BeeEngine with nix package manager on Linux you need to: 1. Enter the directory with cloned repo and build the Editor with submodules: -#+begin_src shell -nix build ".?submodules=1#BeeEngineEditor" -#+end_src -2. The binaries can be found inside result/BeeEngineEditor -***** Runnin without installing and cloning + - For the editor: + #+begin_src shell + nix build ".?submodules=1#BeeEngineEditor" + #+end_src + - For the localization tool: + #+begin_src shell + nix build ".?submodules=1#BeeLocalization" + #+end_src +2. The files can be found inside ~result~ folder +***** Running without installing and cloning #+begin_src shell nix run 'git+https://github.com/KyleKrein/BeeEngine?submodules=1#BeeEngineEditor' #+end_src +***** Including in your Nix flake +WIP **** Linux (Without Nix) Building on Linux without Nix package manager is possible, but it's not a priority. 1. Install all the dependencies depending on your distro: diff --git a/flake.lock b/flake.lock index 885f8511..8d62618c 100644 --- a/flake.lock +++ b/flake.lock @@ -18,41 +18,7 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs", - "utils": "utils" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 5cd8e930..cdf03629 100644 --- a/flake.nix +++ b/flake.nix @@ -3,33 +3,55 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; - utils.url = "github:numtide/flake-utils"; #self.submodules = true; for nix 2.26 }; - outputs = { self, nixpkgs, ... }@inputs: inputs.utils.lib.eachSystem [ - # Add the system/architecture you would like to support here. Note that not - # all packages in the official nixpkgs support all platforms. - "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" - ] (system: let - pkgs = import nixpkgs { - inherit system; - }; - buildInputsFile = (import ./nix/buildInputs.nix {inherit pkgs;}); + outputs = { self, nixpkgs, ... }@inputs: let + inherit (nixpkgs) lib; + eachSystem = lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]; + pkgsFor = eachSystem (system: + import nixpkgs { + localSystem = system; + overlays = with self.overlays; [ + ]; + }); + pkgsCrossFor = eachSystem (system: crossSystem: + import nixpkgs { + localSystem = system; + inherit crossSystem; + overlays = with self.overlays; [ + ]; + }); src = self; in { - devShells.default = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; } rec { + overlays = eachSystem (system: + final: _prev: { + beeengineeditor = self.packages.${system}.BeeEngineEditor; + beelocalization = self.packages.${system}.BeeLocalization; + }); + devShells = eachSystem (system: let + pkgs = pkgsFor.${system}; + buildInputsFile = (import ./nix/buildInputs.nix {inherit pkgs;}); + in { default = pkgsFor.${system}.mkShell.override { stdenv = pkgs.gcc14Stdenv; } rec { # Update the name to something that suites your project. - name = "BeeEngine"; + name = "BeeEngine-shell"; nativeBuildInputs = buildInputsFile.nativeBuildInputs ++ [pkgs.ccache]; buildInputs = buildInputsFile.buildInputs ++ [pkgs.dotnet-sdk]; NETHOST_LIB = (import ./nix/unofficial-nethost.nix {inherit pkgs; inherit (pkgs) lib;}).nethost-lib-path; VK_LAYER_PATH = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d"; - }; + };}); - packages.default = self.packages.${system}.BeeEngineEditor; - packages.BeeEngineEditor = pkgs.callPackage ./nix/editor.nix { inherit src; inherit buildInputsFile; }; - packages.BeeEngineEditor-Debug = pkgs.callPackage ./nix/editor.nix { inherit src; inherit buildInputsFile; cmakeBuildType = "Debug"; }; + packages = eachSystem(system: + let + pkgs = pkgsFor.${system}; + buildInputsFile = (import ./nix/buildInputs.nix {inherit pkgs;}); + in { + default = self.packages.${system}.BeeEngineEditor; + BeeEngineEditor = pkgs.callPackage ./nix/editor.nix { inherit src; inherit buildInputsFile; }; + BeeEngineEditor-Debug = pkgs.callPackage ./nix/editor.nix { inherit src; inherit buildInputsFile; cmakeBuildType = "Debug"; }; + BeeLocalization = pkgs.callPackage ./nix/localizationtool.nix { inherit src; inherit buildInputsFile; }; + BeeLocalization-Debug = pkgs.callPackage ./nix/localizationtool.nix { inherit src; inherit buildInputsFile; cmakeBuildType = "Debug"; }; }); +}; } diff --git a/nix/buildInputs.nix b/nix/buildInputs.nix index b9c901ec..efe2908e 100644 --- a/nix/buildInputs.nix +++ b/nix/buildInputs.nix @@ -1,13 +1,43 @@ { pkgs }: -{ - # nativeBuildInputs is usually what you want -- tools you need to run +let + # nativeBuildInputs is usually what you want -- tools you need to run nativeBuildInputs = with pkgs.buildPackages; [ cmake ninja python3 - makeWrapper - dotnet-sdk ]; + wrapperPath = pkgs.lib.makeBinPath ([ pkgs.dotnet-sdk ]); +in +{ + #https://discourse.nixos.org/t/generate-and-install-a-desktop-file-along-with-an-executable/42744/2 + makeDesktopApp = { name, app, icon }: pkgs.stdenvNoCC.mkDerivation rec{ + inherit name; + buildCommand = let + inherit app; + desktopEntry = pkgs.makeDesktopItem { + name = name; + desktopName = name; + exec = "${app}/bin/${name} %f"; + icon = icon; #https://discourse.nixos.org/t/what-is-the-recommended-use-of-makedesktopitem-how-to-setup-the-icon-correctly/13388/7 + #terminal = true; + }; + in '' + mkdir -p $out/bin + cp ${app}/bin/${name} $out/bin + mkdir -p $out/share/applications + cp ${desktopEntry}/share/applications/${name}.desktop $out/share/applications/${name}.desktop + ''; + dontBuild = true; + }; + + inherit nativeBuildInputs; + + dotnetNativeBuildInputs = nativeBuildInputs ++ [ pkgs.dotnet-sdk pkgs.makeWrapper ]; + dotnetPostFixup = binary: '' + # Ensure all dependencies are in PATH + wrapProgram $out/bin/${binary} \ + --prefix PATH : "${wrapperPath}" + ''; # libraries buildInputs = with pkgs; [ freetype diff --git a/nix/editor.nix b/nix/editor.nix index 03a922cd..1d4c8800 100644 --- a/nix/editor.nix +++ b/nix/editor.nix @@ -9,24 +9,17 @@ assert pkgs.lib.assertMsg (src.submodules == true) "Unable to build without submodules. Append '?submodules=1#' to the URL."; let nethost-lib-path = (import ./unofficial-nethost.nix {inherit pkgs; inherit lib;}).nethost-lib-path; -in - pkgs.gcc14Stdenv.mkDerivation rec { + icon = ../src/Engine/Assets/Textures/BeeEngineLogo.png; + editor = pkgs.gcc14Stdenv.mkDerivation rec { pname = "BeeEngineEditor"; version = "1.0.0-alpha.1.2"; inherit src; - nativeBuildInputs = buildInputsFile.nativeBuildInputs; + nativeBuildInputs = buildInputsFile.dotnetNativeBuildInputs; buildInputs = buildInputsFile.buildInputs; - wrapperPath = with lib; makeBinPath ([ - pkgs.dotnet-sdk - ]); - postFixup = '' - # Ensure all dependencies are in PATH - wrapProgram $out/bin/BeeEngineEditor \ - --prefix PATH : "${wrapperPath}" - ''; + postFixup = buildInputsFile.dotnetPostFixup pname; cmakeFlags = [ @@ -36,7 +29,6 @@ in "-DBEE_BUILD_EDITOR=ON" "-DNETHOST_LIB=${nethost-lib-path}" "-DBEE_USE_SYSTEM_SDL3=ON" - #"-DICU_INCLUDE_DIR=${pkgs.icu.dev}/include" ]; meta = with lib; { homepage = "https://github.com/KyleKrein/BeeEngine"; @@ -47,4 +39,6 @@ in platforms = with platforms; linux ++ darwin; maintainers = [ maintainers.KyleKrein ]; }; - } + }; +in + buildInputsFile.makeDesktopApp { app = editor; name = "BeeEngineEditor"; inherit icon; } diff --git a/nix/localizationtool.nix b/nix/localizationtool.nix new file mode 100644 index 00000000..e3ebaa52 --- /dev/null +++ b/nix/localizationtool.nix @@ -0,0 +1,41 @@ +{ + lib, + pkgs, + src, + buildInputsFile, + cmakeBuildType ? "Release" +}: +assert pkgs.lib.assertMsg (src.submodules == true) + "Unable to build without submodules. Append '?submodules=1#' to the URL."; + let +icon = ../src/Engine/Assets/Textures/BeeEngineLogo.png; +tool = pkgs.gcc14Stdenv.mkDerivation rec { + pname = "BeeLocalization"; + version = "1.0.0-alpha.1.2"; + + inherit src; + + nativeBuildInputs = buildInputsFile.nativeBuildInputs; + buildInputs = buildInputsFile.buildInputs; + + + cmakeFlags = [ + "-DCMAKE_BUILD_TYPE=${cmakeBuildType}" + "-DBEE_USE_VCPKG=OFF" + "-DBEE_BUILD_TESTS=OFF" + "-DBEE_BUILD_LOC_TOOL=ON" + "-DBEE_USE_SYSTEM_SDL3=ON" + "-DBEE_NO_DOTNET=ON" + ]; + meta = with lib; { + homepage = "https://github.com/KyleKrein/BeeEngine"; + description = '' + A GUI App for easy management of localization files, powered by BeeEngine + ''; + licencse = licenses.mit; + platforms = with platforms; linux ++ darwin; + maintainers = [ maintainers.KyleKrein ]; + }; + }; +in + buildInputsFile.makeDesktopApp { app = tool; name = "BeeLocalization"; inherit icon; } diff --git a/src/Editor/CMakeLists.txt b/src/Editor/CMakeLists.txt index 4bdc5005..9fa6afd9 100644 --- a/src/Editor/CMakeLists.txt +++ b/src/Editor/CMakeLists.txt @@ -13,25 +13,26 @@ add_executable(BeeEngineEditor Start.cpp src/EditorApplication.cpp src/EditorApp src/Panels/ImGuiUIEditor.cpp src/Panels/ProjectSettings.h src/Panels/ProjectSettings.cpp) -# files for native scripting: src/NativeScripting/ScriptParser.cpp src/NativeScripting/ScriptParser.h src/NativeScripting/ScriptScanner.cpp src/NativeScripting/ScriptScanner.h src/NativeScripting/CodeGenerators.cpp src/NativeScripting/CodeGenerators.h src/NativeScripting/GameBuilder.cpp src/NativeScripting/GameBuilder.h src/NativeScripting/StdioLogSystem.cpp set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 23) +add_subdirectory(vendor/ImGuizmo) target_include_directories(BeeEngineEditor PUBLIC ../Engine/include/ PRIVATE ../Engine/vendor/ PRIVATE vendor/FileWatcher PUBLIC src + PUBLIC ${ImGuizmo_SOURCE_DIR} ) -target_link_libraries(BeeEngineEditor PUBLIC BeeEngine::WithScripting) + +target_link_libraries(BeeEngineEditor + PUBLIC BeeEngine::WithScripting + PUBLIC ImGuizmo +) add_compile_definitions(BEE_ENABLE_CHECKS) add_compile_definitions($<$:BEE_ENABLE_PROFILING>) add_compile_definitions($<$:BEE_ENABLE_PROFILING>) -#file(COPY Assets DESTINATION ${CMAKE_BINARY_DIR}/src/${PROJECT_NAME}) file(COPY ../Engine/Assets/Shaders DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -#file(COPY ../Engine/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/EngineInclude) #this is for NativeScripting -#file(COPY libs DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) #this is for NativeScripting -#file(COPY ../Engine/vendor/mono/dotnet-libs/4.5 DESTINATION ../lib/mono) configure_file(${BEE_CSHARP_LIBRARY_PATH}/BeeEngine.Core.dll ${CMAKE_CURRENT_BINARY_DIR}/libs/BeeEngine.Core.dll COPYONLY) configure_file(${BEE_CSHARP_LIBRARY_PATH}/BeeEngine.NativeBridge.runtimeconfig.json ${CMAKE_CURRENT_BINARY_DIR}/libs/BeeEngine.NativeBridge.runtimeconfig.json COPYONLY) configure_file(${BEE_CSHARP_LIBRARY_PATH}/BeeEngine.NativeBridge.dll ${CMAKE_CURRENT_BINARY_DIR}/libs/BeeEngine.NativeBridge.dll COPYONLY) @@ -47,5 +48,4 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/ DESTINATION ${BEE_EDITOR_INS install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Localization/ DESTINATION ${BEE_EDITOR_INSTALL_PATH}/Localization) install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Platforms/ DESTINATION ${BEE_EDITOR_INSTALL_PATH}/Platforms) -# Установка шейдеров install(DIRECTORY ../Engine/Assets/Shaders/ DESTINATION ${BEE_EDITOR_INSTALL_PATH}/Shaders) diff --git a/src/Editor/libs/libBeeEngine.a b/src/Editor/libs/libBeeEngine.a deleted file mode 100644 index 85b5161c..00000000 Binary files a/src/Editor/libs/libBeeEngine.a and /dev/null differ diff --git a/src/Editor/src/NativeScripting/CodeGenerators.cpp b/src/Editor/src/NativeScripting/CodeGenerators.cpp deleted file mode 100644 index 7f1e6816..00000000 --- a/src/Editor/src/NativeScripting/CodeGenerators.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by alexl on 21.07.2023. -// - -#include "CodeGenerators.h" - - -namespace BeeEngine::Editor -{ - -} diff --git a/src/Editor/src/NativeScripting/CodeGenerators.h b/src/Editor/src/NativeScripting/CodeGenerators.h deleted file mode 100644 index 04cc3497..00000000 --- a/src/Editor/src/NativeScripting/CodeGenerators.h +++ /dev/null @@ -1,141 +0,0 @@ -// -// Created by alexl on 21.07.2023. -// - -#pragma once -#include -#include -#include -#include "ScriptParser.h" -#include -#include -namespace BeeEngine::Editor -{ - namespace CodeGenerators - { - static std::vector s_Visited; - - static std::filesystem::path s_WorkingDirectory; - static std::filesystem::path s_OutputDirectory; - - static bool WasSourceFileVisited(const BeeClass& beeClass) - { - return std::find(s_Visited.begin(), s_Visited.end(), beeClass.Path) != s_Visited.end(); - } - - static void GenerateInitFile(const std::vector& beeClasses, const std::filesystem::path& folderPath) - { - std::ostringstream source; - - source << "//GENERATED CODE. DO NOT EDIT THIS FILE!\n"; - source << "//Necessary includes"; - source << "#include \n"; - source << "#include \n"; - source << "\n"; - source << "//User Scripts\n"; - - for (const auto& beeClass : beeClasses) - { - if(!beeClass.Path.is_absolute()) - source << "#include \"" << s_WorkingDirectory.string() << "\\" << beeClass.Path.filename().string() << "\"\n"; - else - source << "#include \"" << beeClass.Path.filename().string() << "\"\n"; - s_Visited.push_back(beeClass.Path); - } - source << "\n"; - source << "extern \"C\"{void InitGameLibrary(void* data);}"; - source << "\n"; - source << "static BeeEngineNativeScriptRegistryData* g_HostData = nullptr;\n"; - source << "\n"; - source << "void* CreateNativeScript(const char* name)\n"; - source << "{\n"; - for (const auto& beeClass : beeClasses) - { - source << "\tif (strcmp(name, \"" << beeClass.Name << "\") == 0)\n"; - source << "\t{\n"; - source << "\t\treturn new " << beeClass.Name << "();\n"; - source << "\t}\n"; - } - source << "\treturn nullptr;\n"; - source << "}\n"; - source << "\n"; - source << "void RegisterScripts()\n"; - source << "{\n"; - for (const auto& beeClass : beeClasses) - { - source << "\tg_HostData->RegisterScript_HostOwned(\"" << beeClass.Name << "\",\n"; - size_t fieldsCount = beeClass.Variables.size(); - source << "\t\t"; - if(fieldsCount == 0) - { - source << "nullptr, 0);\n"; - continue; - } - source << "new BeeEngine::NativeScriptFieldInfo[" << fieldsCount << "]{\n"; - for (size_t i = 0; i < fieldsCount; i++) - { - source << "\t\t\t{ \"" << beeClass.Variables[i].Type << "\", \"" << beeClass.Variables[i].Identifier << "\" }"; - if(i != fieldsCount - 1) - source << ","; - source << "\n"; - } - source << "\t\t},\n"; - source << "\t\t" << fieldsCount << ");\n"; - } - source << "}\n"; - source << "\n"; - source << "void InitGameLibrary(void* data)\n"; - source << "{\n"; - source << "\tg_HostData = (BeeEngineNativeScriptRegistryData*)data;\n"; - source << "\tg_HostData->CreateNativeScript_ClientOwned = CreateNativeScript;\n"; - source << "\tRegisterScripts();\n"; - source << "}\n"; - - if(!std::filesystem::exists(folderPath / "Generated")) - std::filesystem::remove(folderPath / "Generated"); - std::ofstream file(folderPath / "Generated"/ "Init.cpp"); - source.flush(); //Might not be necessary - file << source.str(); - file.close(); - } - - static void GenerateCMakeFile(const std::filesystem::path& filepath) - { - std::ostringstream source; - source << "cmake_minimum_required(VERSION 3.25)\n"; - source << "project(GameLibrary)\n"; - source << "set(CMAKE_CXX_STANDARD 23)\n"; - source << "set(CMAKE_CXX_STANDARD_REQUIRED ON)\n"; - source << "file(GLOB_RECURSE GENERATED_SOURCES \"Generated/*.cpp\")\n"; - source << "file(GLOB_RECURSE SCRIPT_SOURCES \"${BEE_GAME_PROJECT_FOLDER}/*.h\")\n"; - source << "add_library(GameLibrary SHARED ${GENERATED_SOURCES} ${SCRIPT_SOURCES})\n"; - source << "target_include_directories(GameLibrary PUBLIC ${BEE_GAME_PROJECT_FOLDER})\n"; - - source << "add_library(BeeEngine STATIC IMPORTED)\n"; - source << "set_target_properties(BeeEngine PROPERTIES IMPORTED_LOCATION ${BEE_ENGINE_LIBRARY_PATH})\n"; - source << "target_include_directories(BeeEngine\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/include\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/src\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/vendor/gsl/include\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/vendor/debugbreak\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/vendor/magic_enum/include\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/vendor/glm\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/vendor/glm/glm\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/vendor/entt/single_include\n"; - source << "\tINTERFACE ${BEE_ENGINE_DIR}/vendor/spdlog/include\n"; - source << ")\n"; - source << "target_link_libraries(GameLibrary PRIVATE BeeEngine)\n"; - - std::ofstream file(filepath / "CMakeLists.txt"); - source.flush(); //Might not be necessary - file << source.str(); - file.close(); - } - - static void Generate(const std::vector& beeClasses, const std::filesystem::path& folderPath) - { - GenerateInitFile(beeClasses, folderPath); - GenerateCMakeFile(folderPath); - } - }; -} diff --git a/src/Editor/src/NativeScripting/GameBuilder.cpp b/src/Editor/src/NativeScripting/GameBuilder.cpp deleted file mode 100644 index ea253077..00000000 --- a/src/Editor/src/NativeScripting/GameBuilder.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// -// Created by alexl on 26.07.2023. -// - -#include "GameBuilder.h" -#include "Core/ResourceManager.h" -#include "NativeScripting/CodeGenerators.h" -#include -#include -#include "NativeScripting/StdioLogSystem.h" -#include -#include -#include - -namespace BeeEngine::Editor -{ - static IRuntimeObjectSystem* g_pRuntimeObjectSystem = nullptr; - static ICompilerLogger* g_pLogger = nullptr; - void GameBuilder::RCCPPLoad(const std::filesystem::path& compilerPath) - { - if(!g_pRuntimeObjectSystem) - { - g_pRuntimeObjectSystem = new RuntimeObjectSystem(); - if(!g_pRuntimeObjectSystem) - { - BeeCoreError("Failed to create runtime object system"); - return; - } - g_pLogger = new StdioLogSystem(); - if(!g_pRuntimeObjectSystem->Initialise(g_pLogger, nullptr)) - { - delete g_pRuntimeObjectSystem; - g_pRuntimeObjectSystem = nullptr; - BeeCoreError("Failed to initialize runtime object system"); - return; - } - auto currentDirectory = std::filesystem::current_path(); - auto engineIncludePath = currentDirectory / "EngineInclude"; - g_pRuntimeObjectSystem->AddIncludeDir((engineIncludePath / "include").string().c_str()); - g_pRuntimeObjectSystem->AddIncludeDir((engineIncludePath / "src").string().c_str()); - g_pRuntimeObjectSystem->AddIncludeDir((engineIncludePath / "vendor" / "gsl" / "include").string().c_str()); - g_pRuntimeObjectSystem->AddIncludeDir((engineIncludePath / "vendor" / "glm" / "glm").string().c_str()); - g_pRuntimeObjectSystem->AddIncludeDir((engineIncludePath / "vendor" / "debugbreak").string().c_str()); - g_pRuntimeObjectSystem->AddIncludeDir((engineIncludePath / "vendor" / "magic_enum" / "include").string().c_str()); - g_pRuntimeObjectSystem->AddIncludeDir((engineIncludePath / "vendor" / "entt" / "single_include").string().c_str()); - g_pRuntimeObjectSystem->AddIncludeDir((engineIncludePath / "vendor" / "spdlog" / "include").string().c_str()); - - BeeCoreTrace("Compiler path: {}", compilerPath.string()); - g_pRuntimeObjectSystem->SetCompilerLocation(compilerPath.string().c_str()); - - //TODO: FIX ON APPLE CLANG g_pRuntimeObjectSystem->AddLibraryDir((currentDirectory / "libs" / ResourceManager::GetStaticLibraryName("BeeEngine")).string().c_str()); - auto sourcesPath = (m_WorkingDirectory/ "Scripts"); - g_pRuntimeObjectSystem->AddPathToSourceSearch(sourcesPath.string().c_str()); - g_pRuntimeObjectSystem->SetIntermediateDir((m_WorkingDirectory / ".beeengine" / "build").string().c_str()); - g_pRuntimeObjectSystem->SetOptimizationLevel(RCppOptimizationLevel::RCCPPOPTIMIZATIONLEVEL_DEBUG); - - g_pRuntimeObjectSystem->AddToRuntimeFileList((sourcesPath / "Init.cpp").string().c_str()); - g_pRuntimeObjectSystem->CompileAll(true); - } - - } - - GameBuilder::GameBuilder(const std::filesystem::path &path,const std::filesystem::path& compilerPath) - : m_WorkingDirectory(path), m_NativeGameLibraryName(ResourceManager::GetDynamicLibraryName(s_GameLibraryName)) - { - m_TemporaryNames.emplace_back("GameLibraryTemp1"); - if(!std::filesystem::exists(m_WorkingDirectory / ".beeengine")) - std::filesystem::create_directory(m_WorkingDirectory / ".beeengine"); - RCCPPLoad(compilerPath); - } - - void GameBuilder::Load() - { - /*TODO: FIX ON APPLE CLANG if(!std::filesystem::exists(m_WorkingDirectory / ".beeengine" / m_NativeGameLibraryName)) - { - BeeCoreError("Failed to find game library {0}", m_NativeGameLibraryName); - return; - }*/ - Unload(); - //TODO: FIX ON APPLE CLANG std::filesystem::copy(m_WorkingDirectory / ".beeengine" / s_GameLibraryName, m_WorkingDirectory / ".beeengine" / ResourceManager::GetDynamicLibraryName(m_TemporaryNames[0]), std::filesystem::copy_options::overwrite_existing); - m_GameLibrary = CreateScope(m_WorkingDirectory / ".beeengine", m_TemporaryNames[0]); - } - - void GameBuilder::Unload() - { - m_GameLibrary.reset(); - } - - void GameBuilder::Build() - { - system("cmake --build . --target GameLibrary --config Debug -DBEE_ENGINE_DIR=C://Projects//BeeEngineCPP//src//Engine -DBEE_GAME_PROJECT_FOLDER=\"C://Users//alexl//OneDrive//Рабочий стол//BeeEngineProjects//TestProject\" -DBEE_ENGINE_LIBRARY_PATH=C:\\Projects\\BeeEngineCPP\\build\\Debug\\src\\Engine\\libBeeEngine.a"); - } - - GameBuilder::~GameBuilder() - { - if(g_pRuntimeObjectSystem) - { - delete g_pRuntimeObjectSystem; - g_pRuntimeObjectSystem = nullptr; - } - if(g_pLogger) - { - delete g_pLogger; - g_pLogger = nullptr; - } - } - - bool GameBuilder::UpdateAndCompile() - { - //check status of any compile - if( g_pRuntimeObjectSystem->GetIsCompiledComplete() ) - { - // load module when compile complete - g_pRuntimeObjectSystem->LoadCompiledModule(); - return true; - } - - if( !g_pRuntimeObjectSystem->GetIsCompiling() ) - { - g_pRuntimeObjectSystem->GetFileChangeNotifier()->Update( Time::DeltaTime() ); - } - return false; - } -} diff --git a/src/Editor/src/NativeScripting/GameBuilder.h b/src/Editor/src/NativeScripting/GameBuilder.h deleted file mode 100644 index c7cda225..00000000 --- a/src/Editor/src/NativeScripting/GameBuilder.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// Created by alexl on 26.07.2023. -// - -#pragma once -#include -#include "Utils/DynamicLibrary.h" -#include "Core/TypeDefines.h" -namespace BeeEngine::Editor -{ - class GameBuilder - { - public: - GameBuilder(const std::filesystem::path& path, const std::filesystem::path& compilerPath); - void Load(); - void Unload(); - void Build(); - bool UpdateAndCompile(); - ~GameBuilder(); - private: - void RCCPPLoad(const std::filesystem::path& compilerPath); - - Ref m_GameLibrary = nullptr; - std::filesystem::path m_WorkingDirectory; - std::vector m_TemporaryNames; - std::string m_NativeGameLibraryName; - constexpr static const char* s_GameLibraryName = "GameLibrary"; - }; -} diff --git a/src/Editor/src/NativeScripting/ScriptParser.cpp b/src/Editor/src/NativeScripting/ScriptParser.cpp deleted file mode 100644 index 001d10b6..00000000 --- a/src/Editor/src/NativeScripting/ScriptParser.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by alexl on 21.07.2023. -// - -#include "ScriptParser.h" - - -namespace BeeEngine::Editor -{ - -} diff --git a/src/Editor/src/NativeScripting/ScriptParser.h b/src/Editor/src/NativeScripting/ScriptParser.h deleted file mode 100644 index 9bf873ec..00000000 --- a/src/Editor/src/NativeScripting/ScriptParser.h +++ /dev/null @@ -1,64 +0,0 @@ -// -// Created by alexl on 21.07.2023. -// - -#pragma once -#include -#include -#include -#include "ScriptScanner.h" -namespace BeeEngine::Editor -{ - struct BeeVariable - { - std::string Type; - std::string Identifier; - }; - - struct BeeClass - { - std::string Name; - std::filesystem::path Path; - std::vector Variables; - }; - - class ScriptParser - { - public: - ScriptParser(std::vector& tokens, std::filesystem::path& path) - : m_Tokens(tokens), m_Path(path) - {} - std::string GenerateHeaderFile(); - void Parse(); - - bool CanGenerateHeaderFile() const noexcept - { - return !m_Classes.empty(); - } - - const std::vector& GetClasses() const noexcept - { - return m_Classes; - } - - static std::string GetFileNameAsClassName(const std::string& filename) noexcept; - private: - void ParseClass(); - void ParseStruct(); - BeeVariable ParseVariable(); - const Token& Expect(TokenType type); - bool Match(TokenType type); - - inline Token GenerateErrorToken() const noexcept - { - return Token{ 0, 0, TokenType::ERROR_TYPE, "" }; - } - - size_t m_CurrentToken = 0; - std::vector::iterator m_CurrentIterator; - const std::filesystem::path& m_Path; - - std::vector& m_Tokens; - std::vector m_Classes; - }; -} diff --git a/src/Editor/src/NativeScripting/ScriptScanner.cpp b/src/Editor/src/NativeScripting/ScriptScanner.cpp deleted file mode 100644 index 76d00724..00000000 --- a/src/Editor/src/NativeScripting/ScriptScanner.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by alexl on 21.07.2023. -// - -#include "ScriptScanner.h" - - -namespace BeeEngine::Editor -{ - -} diff --git a/src/Editor/src/NativeScripting/ScriptScanner.h b/src/Editor/src/NativeScripting/ScriptScanner.h deleted file mode 100644 index 6adcab26..00000000 --- a/src/Editor/src/NativeScripting/ScriptScanner.h +++ /dev/null @@ -1,110 +0,0 @@ -// -// Created by alexl on 21.07.2023. -// - -#pragma once -#include -#include -#include - -namespace BeeEngine::Editor -{ - enum class TokenType - { - PROPERTY, FUNCTION_PROP, CLASS_PROP, STRUCT_PROP, - STRUCT_KW, CLASS_KW, COLON, - - LEFT_PAREN, RIGHT_PAREN, HASHTAG, LEFT_BRACKET, RIGHT_BRACKET, - SEMICOLON, EQUAL, PLUS_EQUAL, MINUS_EQUAL, TIMES_EQUAL, DIV_EQUAL, - MODULO_EQUAL, CARET_EQUAL, AMPERSAND_EQUAL, BAR_EQUAL, RIGHT_SHIFT_EQUAL, - LEFT_SHIFT_EQUAL, EQUAL_EQUAL, BANG_EQUAL, LESS_THAN_EQUAL, GREATER_THAN_EQUAL, - - CONST_KW, IDENTIFIER, AUTO_KW, - - STAR, REF, LEFT_ANGLE_BRACKET, RIGHT_ANGLE_BRACKET, - - STRING_LITERAL, NUMBER, TRUE_KW, FALSE_KW, - - END_OF_FILE, - ERROR_TYPE - }; - - struct Token - { - size_t m_Line; - size_t m_Column; - TokenType m_Type; - std::string m_Lexeme; - // void* m_Literal; - }; - - class ScriptScanner - { - public: - ScriptScanner(const std::filesystem::path& path); - - std::vector ScanTokens(); - private: - Token ScanToken(); - Token PropertyIdentifier(); - Token Number(); - Token String(); - - char Advance(); - char Peek(); - char PeekNext(); - char PeekNextNext(); - bool Match(char expected); - - inline bool IsDigit(char c) const noexcept - { - return c >= '0' && c <= '9'; - } - inline bool IsAlphaNumeric(char c) const noexcept - { - return IsAlpha(c) || IsDigit(c); - } - - inline bool IsAlpha(char c) const noexcept - { - return (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - c == '_'; - } - - inline bool IsAtEnd() const noexcept - { - return m_Cursor >= m_FileContents.size(); - } - - inline Token GenerateToken(TokenType type, std::string lexeme) - { - return { m_Line, m_Column, type, lexeme }; - } - - inline Token GenerateErrorToken() - { - return { 0, 0, TokenType::ERROR_TYPE, "" }; - } - - const std::map m_Keywords = { - { "UPROPERTY", TokenType::PROPERTY }, - { "UCLASS", TokenType::CLASS_PROP }, - { "USTRUCT", TokenType::STRUCT_PROP }, - { "UFUNCTION", TokenType::FUNCTION_PROP }, - { "auto", TokenType::AUTO_KW }, - { "const", TokenType::CONST_KW }, - { "class", TokenType::CLASS_KW }, - { "struct", TokenType::STRUCT_KW } - }; - - std::string m_FileContents; - std::filesystem::path m_Path; - - size_t m_Cursor = 0; - size_t m_Line = 1; - size_t m_Column = 0; - size_t m_Start = 0; - - }; -} diff --git a/src/Editor/src/NativeScripting/StdioLogSystem.cpp b/src/Editor/src/NativeScripting/StdioLogSystem.cpp deleted file mode 100644 index 5588f613..00000000 --- a/src/Editor/src/NativeScripting/StdioLogSystem.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -// Copyright (c) 2010-2011 Matthew Jack and Doug Binks -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. - -#include "StdioLogSystem.h" - -// Currently we create the file on first real output, and only close it on shutdown - -#include -#include -#include -#include "Core/Logging/Log.h" - -#ifdef _WIN32 - #include "Windows.h" -#include "Core/Logging/Log.h" - -#pragma warning( disable : 4996 4800 ) -#endif - - -void StdioLogSystem::LogError(const char * format, ...) -{ - va_list args; - va_start(args, format); - LogInternal(format, args); - va_end(args); -} - -void StdioLogSystem::LogWarning(const char * format, ...) -{ - va_list args; - va_start(args, format); - LogInternal(format, args); - va_end(args); -} - -void StdioLogSystem::LogInfo(const char * format, ...) -{ - va_list args; - va_start(args, format); - LogInternal(format, args); - va_end(args); -} -void StdioLogSystem::LogInternal(const char * format, va_list args) -{ - vsnprintf(m_buff, LOGSYSTEM_MAX_BUFFER-1, format, args); - // Make sure there's a limit to the amount of rubbish we can output - m_buff[LOGSYSTEM_MAX_BUFFER-1] = '\0'; - BeeCoreTrace("Runtime Compiler: {}", m_buff); -#ifdef _WIN32 - OutputDebugStringA( m_buff ); -#endif -} diff --git a/src/Editor/src/NativeScripting/StdioLogSystem.h b/src/Editor/src/NativeScripting/StdioLogSystem.h deleted file mode 100644 index e2479a44..00000000 --- a/src/Editor/src/NativeScripting/StdioLogSystem.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright (c) 2010-2011 Matthew Jack and Doug Binks -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. - -#pragma once - -#ifndef STDIOLOGSYSTEM_INCLUDED -#define STDIOLOGSYSTEM_INCLUDED - -#include "ICompilerLogger.h" - -#include -#include - -// StdioLogSystem for compiler - -const size_t LOGSYSTEM_MAX_BUFFER = 4096; - -class StdioLogSystem : public ICompilerLogger -{ -public: - virtual void LogError(const char * format, ...); - virtual void LogWarning(const char * format, ...); - virtual void LogInfo(const char * format, ...); - -protected: - void LogInternal(const char * format, va_list args); - char m_buff[LOGSYSTEM_MAX_BUFFER]; -}; - - -#endif //STDIOLOGSYSTEM_INCLUDED \ No newline at end of file diff --git a/src/Engine/vendor/ImGuizmo/CMakeLists.txt b/src/Editor/vendor/ImGuizmo/CMakeLists.txt similarity index 100% rename from src/Engine/vendor/ImGuizmo/CMakeLists.txt rename to src/Editor/vendor/ImGuizmo/CMakeLists.txt diff --git a/src/Engine/vendor/ImGuizmo/LICENSE b/src/Editor/vendor/ImGuizmo/LICENSE similarity index 100% rename from src/Engine/vendor/ImGuizmo/LICENSE rename to src/Editor/vendor/ImGuizmo/LICENSE diff --git a/src/Editor/vendor/ImGuizmo/imguizmo b/src/Editor/vendor/ImGuizmo/imguizmo new file mode 160000 index 00000000..2310acda --- /dev/null +++ b/src/Editor/vendor/ImGuizmo/imguizmo @@ -0,0 +1 @@ +Subproject commit 2310acda820d7383d4c4884b7945ada92cd16a47 diff --git a/src/Engine/CMakeLists.txt b/src/Engine/CMakeLists.txt index 0038543e..9e1e8d32 100644 --- a/src/Engine/CMakeLists.txt +++ b/src/Engine/CMakeLists.txt @@ -8,8 +8,7 @@ project( #set(CMAKE_CXX_STANDARD 23) #set(BEE_COMPILE_GLFW OFF) #set(BEE_COMPILE_WEBGPU ON) - -set(BEE_ENABLE_RUNTIME_COMPILER OFF) +option(BEE_NO_DOTNET OFF "Disable dotnet and C# scripting") set(SOURCE_FILES src/BeeEngine.cpp src/Core/TypeDefines.h src/Core/EntryPoint.cpp src/Core/Application.cpp src/Core/Application.h src/Core/EntryPoint.h src/Windowing/WindowHandler/WindowHandler.cpp src/Windowing/WindowHandler/WindowHandler.h src/Windowing/ApplicationProperties.h src/Core/Logging/Log.h src/Core/Logging/Log.cpp src/Core/Events/Event.h src/Core/Events/EventQueue.cpp src/Core/Events/EventQueue.h src/Core/Layer.h src/Core/LayerStack.cpp src/Core/LayerStack.h src/Core/Input.cpp src/Core/Input.h src/KeyCodes.h src/Core/Events/EventImplementations.h src/Windowing/VSync.h src/Renderer/Renderer.cpp src/Renderer/Renderer.h src/Renderer/RendererAPI.h src/Platform/ImGui/ImGuiController.h src/Core/Layer.cpp src/Renderer/RendererAPI.cpp src/Core/Color4.cpp src/Core/Color4.h src/Renderer/BufferLayout.cpp src/Renderer/BufferLayout.h src/Renderer/Texture.cpp src/Renderer/Texture.h src/Core/Events/Event.cpp src/Allocator/Allocator.h src/Debug/MemoryProfiler.cpp src/Debug/MemoryProfiler.h src/Debug/DebugLayer.cpp src/Debug/DebugLayer.h src/Core/SharedPointer.cpp src/Core/SharedPointer.h src/Renderer/FrameBuffer.cpp src/Renderer/FrameBuffer.h src/Core/ResourceManager.cpp src/Core/ResourceManager.h src/Core/Cameras/ICamera.cpp src/Core/Cameras/ICamera.h src/Renderer/RectangleProperties.h src/Core/Time.cpp src/Core/Time.h src/Debug/Timer.h src/Debug/Instrumentor.h src/Core/CodeSafety/Expects.h src/Gui/ImGui/FpsCounter.cpp src/Gui/ImGui/FpsCounter.h src/Scene/Scene.cpp src/Scene/Scene.h src/Scene/EntityID.h src/Scene/Components.h src/Scene/Entity.cpp src/Scene/Entity.h src/Core/Cameras/Camera.cpp src/Core/Cameras/Camera.h src/Scene/SceneCamera.cpp src/Scene/SceneCamera.h src/Scene/ScriptableEntity.cpp src/Scene/ScriptableEntity.h src/Platform/ImGui/ImGuiController.cpp vendor/Incbin/incbin.h Assets/EmbeddedResources.h src/Gui/ImGuiFonts.h src/Scene/SceneSerializer.cpp src/Scene/SceneSerializer.h src/source_location.h src/Property.h src/Utils/FileDialogs.h src/Core/Math/Math.h src/Core/Math/Math.cpp src/Renderer/EditorCamera.cpp src/Renderer/EditorCamera.h Assets/EmbeddedResources.cpp src/Core/CodeSafety/DebugLog.cpp src/Core/CodeSafety/DebugLog.h src/Core/OsPlatform.h src/Renderer/RenderAPI.h src/Renderer/Surface.cpp src/Renderer/Surface.h src/Renderer/DeviceID.cpp src/Renderer/DeviceID.h src/Renderer/SwapChain.cpp src/Renderer/SwapChain.h src/Platform/Vulkan/VulkanGraphicsDevice.cpp src/Platform/Vulkan/VulkanGraphicsDevice.h src/Platform/Vulkan/VulkanSwapChain.cpp src/Platform/Vulkan/VulkanSwapChain.h src/Renderer/Instance.cpp src/Renderer/Instance.h src/Platform/Vulkan/VulkanInstance.cpp src/Platform/Vulkan/VulkanInstance.h src/Renderer/QueueFamilyIndices.cpp src/Renderer/QueueFamilyIndices.h src/FileSystem/File.cpp src/FileSystem/File.h src/Platform/ImGui/ImGuiControllerVulkan.h src/Platform/ImGui/ImGuiControllerVulkan.cpp src/Utils/ShaderConverter.h src/Utils/ShaderConverter.cpp vendor/VulkanMemoryAllocator/vk_mem_alloc.h src/Core/CodeSafety/NotNull.h src/Core/CodeSafety/BoundsChecking.h src/Platform/Vulkan/VulkanBuffer.h src/Renderer/Vertex.h src/Core/DeletionQueue.cpp src/Core/DeletionQueue.h src/Platform/Vulkan/Utils.h src/Platform/Vulkan/Utils.cpp src/Renderer/AssetManager.cpp src/Renderer/AssetManager.h src/Renderer/Mesh.h src/Renderer/Mesh.cpp src/Renderer/Material.cpp src/Renderer/Material.h src/Windowing/WindowHandler/SDLWindowHandler.cpp src/Windowing/WindowHandler/SDLWindowHandler.h src/Platform/WebGPU/WebGPUInstance.cpp src/Platform/WebGPU/WebGPUInstance.h src/Platform/WebGPU/WebGPUGraphicsDevice.cpp src/Platform/WebGPU/WebGPUGraphicsDevice.h src/Platform/WebGPU/WebGPUSwapchain.cpp src/Platform/WebGPU/WebGPUSwapchain.h src/Platform/WebGPU/WebGPURendererAPI.cpp src/Platform/WebGPU/WebGPURendererAPI.h src/Renderer/CommandBuffer.h src/Platform/WebGPU/WebGPUCommandBuffer.cpp src/Platform/WebGPU/WebGPUCommandBuffer.h src/Platform/ImGui/ImGuiControllerWebGPU.h src/Platform/ImGui/ImGuiControllerWebGPU.cpp src/Renderer/RenderPass.h src/Platform/WebGPU/WebGPUPipeline.cpp src/Platform/WebGPU/WebGPUPipeline.h src/Renderer/Pipeline.h src/Renderer/ShaderTypes.h src/Renderer/ShaderModule.h src/Renderer/ShaderModule.cpp src/Platform/WebGPU/WebGPUShaderModule.cpp src/Platform/WebGPU/WebGPUShaderModule.h src/Renderer/Pipeline.cpp src/Platform/WebGPU/WebGPUMesh.cpp src/Platform/WebGPU/WebGPUMesh.h src/Renderer/UniformBuffer.cpp src/Renderer/UniformBuffer.h src/Platform/WebGPU/WebGPUUniformBuffer.cpp src/Platform/WebGPU/WebGPUUniformBuffer.h src/Renderer/InstancedBuffer.h src/Platform/WebGPU/WebGPUInstancedBuffer.cpp src/Platform/WebGPU/WebGPUInstancedBuffer.h src/Core/RestartApplication.h src/Renderer/Model.h src/Platform/WebGPU/WebGPUMaterial.cpp src/Platform/WebGPU/WebGPUMaterial.h src/Renderer/Model.cpp src/Platform/WebGPU/WebGPUModel.cpp src/Platform/WebGPU/WebGPUTexture2D.cpp src/Platform/WebGPU/WebGPUTexture2D.h vendor/Implementations.cpp src/Renderer/BindingSet.cpp src/Renderer/BindingSet.h src/Renderer/IBindable.h src/Renderer/MaterialDescriptor.h src/Core/ValueType.h src/Platform/WebGPU/WebGPUBindingSet.cpp src/Platform/WebGPU/WebGPUBindingSet.h src/Platform/WebGPU/WebGPUBufferPool.cpp src/Platform/WebGPU/WebGPUBufferPool.h src/Renderer/RenderingQueue.cpp src/Renderer/RenderingQueue.h src/Renderer/InstancedBuffer.cpp src/Renderer/RendererStatistics.h src/Gui/ImGui/RendererStatisticsGUI.cpp src/Gui/ImGui/RendererStatisticsGUI.h src/Platform/WebGPU/WebGPUFramebuffer.cpp src/Platform/WebGPU/WebGPUFramebuffer.h src/Core/FramePtr.cpp src/Core/FramePtr.h src/Scene/INativeScriptRegistry.h src/Scene/NativeScriptFactory.cpp src/Scene/NativeScriptFactory.h src/Scene/INativeScriptFactory.h src/Utils/DynamicLibrary.cpp src/Utils/DynamicLibrary.h src/Core/Logging/GameLogger.cpp src/Core/Logging/GameLogger.h src/Scene/DefaultNativeScript.h src/Core/UUID.cpp src/Core/UUID.h src/Scene/Components.cpp src/Allocator/AllocatorStatistics.h src/Allocator/AllocatorStatistics.h src/Renderer/Font.cpp @@ -104,9 +103,6 @@ set(SOURCE_FILES src/BeeEngine.cpp src/Core/TypeDefines.h src/Core/EntryPoint.cp src/JobSystem/AdaptiveMutex.h src/JobSystem/Mutex.h src/FileSystem/FileSystem.h - src/Scripting/NativeToManaged.cpp - src/Scripting/NativeToManaged.h - src/Scripting/Runtime.cpp src/Platform/Vulkan/VulkanRendererAPI.cpp src/Platform/Vulkan/VulkanRendererAPI.h src/Platform/Vulkan/VulkanTexture2D.cpp @@ -260,26 +256,32 @@ else () FileEmbedUseGeneratedFiles() endif () -set(SCRIPTING_SOURCE_FILES src/Scripting/ScriptingEngine.cpp src/Scripting/ScriptingEngine.h src/Scripting/MAssembly.h src/Scripting/MClass.h src/Scripting/ScriptGlue.cpp src/Scripting/ScriptGlue.h src/Scripting/MObject.h src/Scripting/MMethod.h src/Scripting/GameScript.h src/Scripting/MField.h src/Scripting/MTypes.h src/Scripting/MUtils.cpp src/Scripting/MUtils.h) -list(APPEND SOURCE_FILES ${SCRIPTING_SOURCE_FILES}) +if(NOT ${BEE_NO_DOTNET}) + set(SCRIPTING_SOURCE_FILES src/Scripting/ScriptingEngine.cpp src/Scripting/ScriptingEngine.h src/Scripting/MAssembly.h src/Scripting/MClass.h src/Scripting/ScriptGlue.cpp src/Scripting/ScriptGlue.h src/Scripting/MObject.h src/Scripting/MMethod.h src/Scripting/GameScript.h src/Scripting/MField.h src/Scripting/MTypes.h src/Scripting/MUtils.cpp src/Scripting/MUtils.h src/Scripting/NativeToManaged.cpp src/Scripting/NativeToManaged.h src/Scripting/Runtime.cpp) + list(APPEND SOURCE_FILES ${SCRIPTING_SOURCE_FILES}) +endif() add_library(BeeEngine ${SOURCE_FILES}) - -message(STATUS "Building C# libraries for scripting support") -set(BEE_CSHARP_LIBRARY_PATH ${CMAKE_BINARY_DIR}/src/Engine/net${BEEENGINE_DOTNET_VERSION} CACHE STRING "Path, where built C# libraries are stored") -execute_process( +if(NOT ${BEE_NO_DOTNET}) + message("Building BeeEngine with C# support") + message(STATUS "Building C# libraries for scripting support") + set(BEE_CSHARP_LIBRARY_PATH ${CMAKE_BINARY_DIR}/src/Engine/net${BEEENGINE_DOTNET_VERSION} CACHE STRING "Path, where built C# libraries are stored") + execute_process( COMMAND dotnet build "${CMAKE_CURRENT_LIST_DIR}/../BeeEngineScripting/BeeEngineScripting.sln" -c ${CMAKE_BUILD_TYPE} -o ${BEE_CSHARP_LIBRARY_PATH} WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../BeeEngineScripting" RESULT_VARIABLE dotnet_result OUTPUT_VARIABLE dotnet_output ERROR_VARIABLE dotnet_error -) + ) -if(NOT dotnet_result EQUAL "0") + if(NOT dotnet_result EQUAL "0") message(FATAL_ERROR "Failed to build BeeEngineScripting: ${dotnet_error}: ${dotnet_output}") -else() + else() message(STATUS "C# libraries for scripting support built successfully") - message(STATUS "Output ${dotnet_output}") + message(STATUS "Output ${dotnet_output}") + endif() +else() + message("Building BeeEngine without C# support") endif() #[[if(IOS OR APPLE) set(CMAKE_Swift_LANGUAGE_VERSION 5) @@ -377,7 +379,6 @@ add_subdirectory(vendor/gsl) #add_subdirectory(vendor/BeeAlloc) add_subdirectory(vendor/entt) add_subdirectory(vendor/yaml-cpp) -add_subdirectory(vendor/ImGuizmo) add_subdirectory(vendor/magic_enum) add_subdirectory(vendor/Box2D) add_subdirectory(vendor/msdfgen) @@ -386,13 +387,15 @@ add_subdirectory(vendor/fastgltf) find_package(ICU REQUIRED COMPONENTS data uc in io i18n dt) find_package(Boost REQUIRED COMPONENTS context) -if(NETHOST_LIB) - message("Using provided nethost library: ${NETHOST_LIB}") - target_link_libraries(BeeEngine PRIVATE ${NETHOST_LIB}) - target_include_directories(BeeEngine PRIVATE ${CMAKE_CURRENT_LIST_DIR}/vendor/dotnethost) -else() - find_package(unofficial-nethost CONFIG REQUIRED) - target_link_libraries(BeeEngine PRIVATE unofficial::nethost::nethost) +if(NOT ${BEE_NO_DOTNET}) + if(NETHOST_LIB) + message("Using provided nethost library: ${NETHOST_LIB}") + target_link_libraries(BeeEngine PRIVATE ${NETHOST_LIB}) + target_include_directories(BeeEngine PRIVATE ${CMAKE_CURRENT_LIST_DIR}/vendor/dotnethost) + else() + find_package(unofficial-nethost CONFIG REQUIRED) + target_link_libraries(BeeEngine PRIVATE unofficial::nethost::nethost) + endif() endif() if(BEE_COMPILE_VULKAN) find_package(Vulkan REQUIRED) @@ -425,10 +428,8 @@ target_include_directories( ${PROJECT_NAME} PUBLIC vendor/entt/single_include PUBLIC vendor/Incbin PUBLIC vendor/yaml-cpp/include - PUBLIC ${ImGuizmo_SOURCE_DIR} PUBLIC vendor/glslang PUBLIC vendor/magic_enum/include - PUBLIC vendor/utfcpp/include PUBLIC ${ICU_INCLUDE_DIR} ) @@ -441,7 +442,6 @@ target_link_libraries( ${PROJECT_NAME} #PUBLIC BeeAlloc PUBLIC EnTT PUBLIC yaml-cpp - PUBLIC ImGuizmo PUBLIC SPIRV PUBLIC glslang PUBLIC magic_enum @@ -458,11 +458,6 @@ target_compile_definitions(BeeEngine PUBLIC GLM_FORCE_LEFT_HANDED ) -if(BEE_ENABLE_RUNTIME_COMPILER) - add_subdirectory(vendor/RuntimeCompiler) - target_link_libraries( BeeEngine PUBLIC RuntimeCompiledCPP) -endif () - # Создаем определение DEBUG только для debug configuration add_compile_definitions($<$:DEBUG>) @@ -511,9 +506,10 @@ target_link_libraries(BeeEngine PRIVATE file_embed) add_compile_definitions(ASSETS_PATH="${PROJECT_SOURCE_DIR}/Assets/") add_library(BeeEngine::BeeEngine ALIAS BeeEngine) -add_library(BeeEngine::WithScripting ALIAS BeeEngine) -target_compile_definitions(BeeEngine PRIVATE BEE_ENABLE_SCRIPTING) - +if(NOT ${BEE_NO_DOTNET}) + add_library(BeeEngine::WithScripting ALIAS BeeEngine) + target_compile_definitions(BeeEngine PRIVATE BEE_ENABLE_SCRIPTING) +endif() target_compile_definitions(BeeEngine PUBLIC _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING) # for spdlog #clang_format(BeeEngine "${SOURCE_FILES}") diff --git a/src/Engine/src/Locale/ImGuiLocalizationPanel.cpp b/src/Engine/src/Locale/ImGuiLocalizationPanel.cpp index b7e11e70..8f21a4fa 100644 --- a/src/Engine/src/Locale/ImGuiLocalizationPanel.cpp +++ b/src/Engine/src/Locale/ImGuiLocalizationPanel.cpp @@ -26,9 +26,9 @@ namespace BeeEngine::Locale auto locale = filename.AsUTF8().substr(0, filename.AsUTF8().find('.')); return {locale}; } - ImGuiLocalizationPanel::ImGuiLocalizationPanel(Domain& domain, const Path& path) - : m_Domain(&domain), m_SelectedLocale(domain.m_Locale), m_WorkingDirectory(path) + void ImGuiLocalizationPanel::RegenerateDomainInfo() { + std::unique_lock lock(m_DomainLock); std::vector files = LocalizationGenerator::GetLocalizationFiles(m_WorkingDirectory); for (auto&& file : files) { @@ -37,6 +37,11 @@ namespace BeeEngine::Locale } UpdateLocaleKeys(); } + ImGuiLocalizationPanel::ImGuiLocalizationPanel(Domain& domain, const Path& path) + : m_Domain(&domain), m_SelectedLocale(domain.m_Locale), m_WorkingDirectory(path) + { + RegenerateDomainInfo(); + } void ImGuiLocalizationPanel::Render(ImGuiWindowFlags flags, bool canBeClosed) { if (canBeClosed) @@ -49,6 +54,7 @@ namespace BeeEngine::Locale { ImGui::Begin("Localization", nullptr, flags); } + std::unique_lock lock(m_DomainLock); RenderUpperPanel(); bool removeKey = false; @@ -407,4 +413,4 @@ namespace BeeEngine::Locale } } } -} // namespace BeeEngine::Locale \ No newline at end of file +} // namespace BeeEngine::Locale diff --git a/src/Engine/src/Locale/ImGuiLocalizationPanel.h b/src/Engine/src/Locale/ImGuiLocalizationPanel.h index c05c2fd4..43989939 100644 --- a/src/Engine/src/Locale/ImGuiLocalizationPanel.h +++ b/src/Engine/src/Locale/ImGuiLocalizationPanel.h @@ -25,8 +25,10 @@ namespace BeeEngine::Locale void Render(ImGuiWindowFlags flags = ImGuiWindowFlags_None, bool canBeClosed = true); void SwitchOpened() { m_IsOpened = !m_IsOpened; } void UpdateLocaleKeys(); + void RegenerateDomainInfo(); private: + Jobs::SpinLock m_DomainLock; Domain* m_Domain; Path m_WorkingDirectory; Localization m_SelectedLocale; @@ -50,4 +52,4 @@ namespace BeeEngine::Locale void RenderKeysAndValues(bool& removeKey); }; -} // namespace BeeEngine::Locale \ No newline at end of file +} // namespace BeeEngine::Locale diff --git a/src/Engine/vendor/ImGuizmo/imguizmo b/src/Engine/vendor/ImGuizmo/imguizmo deleted file mode 160000 index b10e9175..00000000 --- a/src/Engine/vendor/ImGuizmo/imguizmo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b10e91756d32395f5c1fefd417899b657ed7cb88 diff --git a/src/Engine/vendor/RuntimeCompiler/CMakeLists.txt b/src/Engine/vendor/RuntimeCompiler/CMakeLists.txt deleted file mode 100644 index afcde1a2..00000000 --- a/src/Engine/vendor/RuntimeCompiler/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -CPMAddPackage( - NAME RuntimeCompiledCPlusPlus - GITHUB_REPOSITORY RuntimeCompiledCPlusPlus/RuntimeCompiledCPlusPlus - GIT_TAG 362caeb839202086abb2c430a8ed63c478a987e4 - DOWNLOAD_ONLY YES -) -set(BUILD_EXAMPLES OFF) - -if(WIN32 AND NOT BEE_RUNTIMECPPCACHECHANGED) - set(BEE_RUNTIMECPPCACHECHANGED ON CACHE INTERNAL "") - message("Applying patches for RuntimeCompilerCPP for Windows") - file(COPY - ${CMAKE_CURRENT_LIST_DIR}/Patches/Compiler_PlatformWindows.cpp - DESTINATION ${RuntimeCompiledCPlusPlus_SOURCE_DIR}/Aurora/RuntimeCompiler/ - ) - file(COPY - ${CMAKE_CURRENT_LIST_DIR}/Patches/RuntimeObjectSystem_PlatformWindows.cpp - DESTINATION ${RuntimeCompiledCPlusPlus_SOURCE_DIR}/Aurora/RuntimeObjectSystem - ) -endif () - -add_subdirectory(${RuntimeCompiledCPlusPlus_SOURCE_DIR}/Aurora ${CMAKE_CURRENT_BINARY_DIR}/CPPRuntime) - -add_library(RuntimeCompiledCPP INTERFACE) -target_include_directories(RuntimeCompiledCPP - INTERFACE ${RuntimeCompiledCPlusPlus_SOURCE_DIR}/Aurora/RuntimeObjectSystem - INTERFACE ${RuntimeCompiledCPlusPlus_SOURCE_DIR}/Aurora/RuntimeCompiler - ) -target_link_libraries(RuntimeCompiledCPP INTERFACE RuntimeCompiler RuntimeObjectSystem) \ No newline at end of file diff --git a/src/Engine/vendor/RuntimeCompiler/Patches/Compiler_PlatformWindows.cpp b/src/Engine/vendor/RuntimeCompiler/Patches/Compiler_PlatformWindows.cpp deleted file mode 100644 index fe793dda..00000000 --- a/src/Engine/vendor/RuntimeCompiler/Patches/Compiler_PlatformWindows.cpp +++ /dev/null @@ -1,767 +0,0 @@ -// -// Copyright (c) 2010-2011 Matthew Jack and Doug Binks -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. - -// -// Notes: -// - We use a single intermediate directory for compiled .obj files, which means -// we don't support compiling multiple files with the same name. Could fix this -// with either mangling names to include paths, or recreating folder structure -// -// - -#ifdef _WIN32 - - -#include "Compiler.h" - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#include "FileSystemUtils.h" - -#include "assert.h" -#include - -#include "ICompilerLogger.h" - -using namespace std; -using namespace FileSystemUtils; - -struct VSVersionInfo -{ - std::string Path; -}; - -const std::string c_CompletionToken( "_COMPLETION_TOKEN_" ); - -void GetPathsOfVisualStudioInstalls( std::vector* pVersions, ICompilerLogger * pLogger ); - -void ReadAndHandleOutputThread( LPVOID arg ); - -struct CmdProcess -{ - CmdProcess(); - ~CmdProcess(); - - void InitialiseProcess(); - void WriteInput(std::string& input); - void CleanupProcessAndPipes(); - - - PROCESS_INFORMATION m_CmdProcessInfo; - HANDLE m_CmdProcessOutputRead; - HANDLE m_CmdProcessInputWrite; - volatile bool m_bIsComplete; - ICompilerLogger* m_pLogger; - bool m_bStoreCmdOutput; - std::string m_CmdOutput; -}; - -class PlatformCompilerImplData -{ -public: - PlatformCompilerImplData(); - ~PlatformCompilerImplData(); - - std::string m_VSPath; - bool m_bFindVS; - CmdProcess m_CmdProcess; - ICompilerLogger* m_pLogger; -}; - -Compiler::Compiler() - : m_pImplData( 0 ) - , m_bFastCompileMode( false ) -{ -} - -Compiler::~Compiler() -{ - delete m_pImplData; -} - -std::string Compiler::GetObjectFileExtension() const -{ - return ".obj"; -} - -bool Compiler::GetIsComplete() const -{ - bool bComplete = m_pImplData->m_CmdProcess.m_bIsComplete; - if( bComplete & !m_bFastCompileMode ) - { - m_pImplData->m_CmdProcess.CleanupProcessAndPipes(); - } - return bComplete; -} - -void Compiler::Initialise( ICompilerLogger * pLogger ) -{ - m_pImplData = new PlatformCompilerImplData; - m_pImplData->m_pLogger = pLogger; - m_pImplData->m_CmdProcess.m_pLogger = pLogger; -} - -void Compiler::RunCompile( const std::vector& filesToCompile_, - const CompilerOptions& compilerOptions_, - std::vector linkLibraryList_, - const FileSystemUtils::Path& moduleName_ ) -{ - if( m_pImplData->m_bFindVS ) - { - // get VS compiler path - m_pImplData->m_bFindVS = false; // only run once - std::vector Versions; - GetPathsOfVisualStudioInstalls(&Versions, m_pImplData->m_pLogger); - - if (!Versions.empty()) - { - m_pImplData->m_VSPath = Versions[0].Path; - } - else - { - m_pImplData->m_VSPath = ""; - if (m_pImplData->m_pLogger) - { - m_pImplData->m_pLogger->LogError("No Supported Compiler for RCC++ found.\n"); - } - } - } - - if( m_pImplData->m_VSPath.empty() ) - { - if (m_pImplData->m_pLogger) { m_pImplData->m_pLogger->LogError("No Supported Compiler for RCC++ found, cannot compile changes.\n"); } - m_pImplData->m_CmdProcess.m_bIsComplete = true; - return; - } - m_pImplData->m_CmdProcess.m_bIsComplete = false; - //optimization and c runtime -#ifdef _DEBUG - std::string flags = "/nologo /Z7 /FC /MDd /LDd "; -#else - std::string flags = "/nologo /Z7 /FC /MD /LD "; //also need debug information in release -#endif - - RCppOptimizationLevel optimizationLevel = GetActualOptimizationLevel( compilerOptions_.optimizationLevel ); - switch( optimizationLevel ) - { - case RCCPPOPTIMIZATIONLEVEL_DEFAULT: - assert(false); - case RCCPPOPTIMIZATIONLEVEL_DEBUG: - flags += "/Od "; - break; - case RCCPPOPTIMIZATIONLEVEL_PERF: - flags += "/O2 "; - -// Add improved debugging options if available: http://randomascii.wordpress.com/2013/09/11/debugging-optimized-codenew-in-visual-studio-2012/ -#if (_MSC_VER >= 1700) - flags += "/d2Zi+ "; -#endif - break; - case RCCPPOPTIMIZATIONLEVEL_NOT_SET:; - case RCCPPOPTIMIZATIONLEVEL_SIZE:; - } - - if( NULL == m_pImplData->m_CmdProcess.m_CmdProcessInfo.hProcess ) - { - m_pImplData->m_CmdProcess.InitialiseProcess(); -#ifndef _WIN64 - std::string cmdSetParams = "\"" + m_pImplData->m_VSPath + "Vcvarsall.bat\" x86\n"; -#else - std::string cmdSetParams = "\"" + m_pImplData->m_VSPath + "Vcvarsall.bat\" x86_amd64\n"; -#endif - //send initial set up command - m_pImplData->m_CmdProcess.WriteInput(cmdSetParams); - } - - flags += compilerOptions_.compileOptions; - flags += " "; - - std::string linkOptions; - bool bHaveLinkOptions = ( 0 != compilerOptions_.linkOptions.length() ); - if( compilerOptions_.libraryDirList.size() || bHaveLinkOptions ) - { - linkOptions = " /link "; - for( size_t i = 0; i < compilerOptions_.libraryDirList.size(); ++i ) - { - linkOptions += " /LIBPATH:\"" + compilerOptions_.libraryDirList[i].m_string + "\""; - } - - if( bHaveLinkOptions ) - { - linkOptions += compilerOptions_.linkOptions; - linkOptions += " "; - } - } - - // Check for intermediate directory, create it if required - // There are a lot more checks and robustness that could be added here - if ( !compilerOptions_.intermediatePath.Exists() ) - { - bool success = compilerOptions_.intermediatePath.CreateDir(); - if( success && m_pImplData->m_pLogger ) { m_pImplData->m_pLogger->LogInfo("Created intermediate folder \"%s\"\n", compilerOptions_.intermediatePath.c_str()); } - else if( m_pImplData->m_pLogger ) { m_pImplData->m_pLogger->LogError("Error creating intermediate folder \"%s\"\n", compilerOptions_.intermediatePath.c_str()); } - } - - - //create include path search string - std::string strIncludeFiles; - for( size_t i = 0; i < compilerOptions_.includeDirList.size(); ++i ) - { - strIncludeFiles += " /I \"" + compilerOptions_.includeDirList[i].m_string + "\""; - } - - - // When using multithreaded compilation, listing a file for compilation twice can cause errors, hence - // we do a final filtering of input here. - // See http://msdn.microsoft.com/en-us/library/bb385193.aspx - "Source Files and Build Order" - - // Create compile path search string - std::string strFilesToCompile; - std::set filteredPaths; - for( size_t i = 0; i < filesToCompile_.size(); ++i ) - { - std::string strPath = filesToCompile_[i].m_string; - FileSystemUtils::ToLowerInPlace(strPath); - - std::set::const_iterator it = filteredPaths.find(strPath); - if (it == filteredPaths.end()) - { - strFilesToCompile += " \"" + strPath + "\""; - filteredPaths.insert(strPath); - } - } - - std::string strLinkLibraries; - for( size_t i = 0; i < linkLibraryList_.size(); ++i ) - { - strLinkLibraries += " \"" + linkLibraryList_[i].m_string + "\" "; - } - - - - -#ifdef UNICODE - const char* pCharTypeFlags = "/D UNICODE /D _UNICODE "; -#else - const char* pCharTypeFlags = ""; -#endif - - std::string compilerLocation = compilerOptions_.compilerLocation.m_string; - if (compilerLocation.size()==0){ -#if defined __clang__ - #ifndef _WIN64 - std::string arch = "-m32 "; - #else - std::string arch = "-m64 "; - #endif - compilerLocation = "\"%VCINSTALLDIR%Tools\\Llvm\\bin\\clang-cl\" "; - compilerLocation += arch; -#else - // full path and arch is not required as cl compiler already initialized by Vcvarsall.bat - compilerLocation = "cl "; -#endif - } - - // /MP - use multiple processes to compile if possible. Only speeds up compile for multiple files and not link - std::string cmdToSend = compilerLocation + flags + pCharTypeFlags - + " /MP /Fo\"" + compilerOptions_.intermediatePath.m_string + "\\\\\" " - + "/D WIN32 /EHa /Fe" + moduleName_.m_string; - cmdToSend += " " + strIncludeFiles + " " + strFilesToCompile + strLinkLibraries + linkOptions - + "\necho "; - if( m_pImplData->m_pLogger ) m_pImplData->m_pLogger->LogInfo( "%s", cmdToSend.c_str() ); // use %s to prevent any tokens in compile string being interpreted as formating - cmdToSend += c_CompletionToken + "\n"; - m_pImplData->m_CmdProcess.WriteInput( cmdToSend ); -} - -struct VSKey -{ - const char* keyName; - const char* pathToAdd; - HKEY key; -}; - -struct VSVersionDiscoveryInfo -{ - const char* valueName; - int versionKey; // index into an array of VSKey values for the key, -1 for don't look - bool tryVSWhere; // can use VSWhere for versioning -}; - -void GetPathsOfVisualStudioInstalls( std::vector* pVersions, ICompilerLogger* pLogger ) -{ - //e.g.: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\\Setup\VS\ - // to view 32bit keys on Windows use start->run and enter: %systemroot%\syswow64\regedit - // as for 32bit keys need to run 32bit regedit. - VSKey VS_KEYS[] = { {"SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7", "", NULL}, - {"SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7", "VC\\Auxiliary\\Build\\", NULL} }; - int NUMVSKEYS = sizeof( VS_KEYS ) / sizeof( VSKey ); - - // supporting: VS2005, VS2008, VS2010, VS2011, VS2013, VS2015, VS2017, VS2019 - // See https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering for version info - VSVersionDiscoveryInfo VS_DISCOVERY_INFO[] = { {"8.0",0,false}, {"9.0",0,false}, {"10.0",0,false}, {"11.0",0,false}, {"12.0",0,false}, {"14.0",0,false}, {"15.0",1,true}, {"16.0",1,true} }; - - - int NUMNAMESTOCHECK = sizeof( VS_DISCOVERY_INFO ) / sizeof( VSVersionDiscoveryInfo ); - // we start searching for a compatible compiler from the current version backwards - int startVersion = NUMNAMESTOCHECK - 1; - -#if !defined __clang__ // do not check _MSC_VER for clang as this reports version 1800 by default - //switch around prefered compiler to the one we've used to compile this file - const unsigned int MSCVERSION = _MSC_VER; - switch( MSCVERSION ) - { - case 1400: //VS 2005 - startVersion = 0; - break; - case 1500: //VS 2008 - startVersion = 1; - break; - case 1600: //VS 2010 - startVersion = 2; - break; - case 1700: //VS 2012 - startVersion = 3; - break; - case 1800: //VS 2013 - startVersion = 4; - break; - case 1900: //VS 2015 - startVersion = 5; - break; - case 1910: //VS 2017 - case 1911: //VS 2017 - case 1912: //VS 2017 - case 1913: //VS 2017 - case 1914: //VS 2017 - case 1915: //VS 2017 - case 1916: //VS 2017 - startVersion = 6; - break; - case 1920: // VS 2019 - case 1921: // VS 2019 - case 1922: // VS 2019 - case 1923: // VS 2019 - case 1924: // VS 2019 - case 1925: // VS 2019 - case 1926: // VS 2019 - case 1927: // VS 2019 - startVersion = 7; - break; - default: - if( pLogger ) - { - pLogger->LogWarning("WARNING: VS Compiler with _MSC_VER %d potentially not supported. Defaulting to version %s.\n",MSCVERSION, VS_DISCOVERY_INFO[startVersion].valueName); - } - } -#endif - - - char value[MAX_PATH]; - DWORD size = MAX_PATH; - - for( int i =0; i < NUMVSKEYS; ++i ) - { - LONG retKeyVal = RegOpenKeyExA( - HKEY_LOCAL_MACHINE, //__in HKEY hKey, - VS_KEYS[i].keyName, //__in_opt LPCTSTR lpSubKey, - 0, //__reserved DWORD ulOptions, - KEY_READ | KEY_WOW64_32KEY, //__in REGSAM samDesired, - &VS_KEYS[i].key //__out PHKEY phkResult - ); - } - - int loopCount = 1; - if( startVersion != NUMNAMESTOCHECK - 1 ) - { - // we potentially need to restart search from top - loopCount = 2; - } - for( int loop = 0; loop < loopCount; ++loop ) - { - for( int i = startVersion; i >= 0; --i ) - { - VSVersionDiscoveryInfo vsinfo = VS_DISCOVERY_INFO[i]; - VSKey vskey = VS_KEYS[ vsinfo.versionKey ]; - - if( vsinfo.tryVSWhere ) - { - CmdProcess cmdProc; - cmdProc.m_pLogger = pLogger; - cmdProc.InitialiseProcess(); - cmdProc.m_bStoreCmdOutput = true; - cmdProc.m_CmdOutput = ""; - std::string vsWhereQuery = "\"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere\"" - " -version " + std::string( vsinfo.valueName ) + - " -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64" - " -property installationPath" - "\nexit\n"; - cmdProc.WriteInput( vsWhereQuery ); - WaitForSingleObject( cmdProc.m_CmdProcessInfo.hProcess, 2000 ); // max 2 secs - // get the first non-empty substring - size_t start = cmdProc.m_CmdOutput.find_first_not_of("\r\n", 0); - if( start != std::string::npos ) - { - size_t end = cmdProc.m_CmdOutput.find_first_of("\r\n", start); - if( end == std::string::npos ) - { - end = cmdProc.m_CmdOutput.length(); - } - FileSystemUtils::Path path = cmdProc.m_CmdOutput.substr( start, end-start ); - if( path.m_string.length() && path.Exists() ) - { - VSVersionInfo vInfo; - vInfo.Path = path.m_string; - vInfo.Path += "\\"; - vInfo.Path += vskey.pathToAdd; - pVersions->push_back( vInfo ); - continue; - } - } - } - - LONG retVal = RegQueryValueExA( - vskey.key, //__in HKEY hKey, - vsinfo.valueName, //__in_opt LPCTSTR lpValueName, - NULL, //__reserved LPDWORD lpReserved, - NULL , //__out_opt LPDWORD lpType, - (LPBYTE)value, //__out_opt LPBYTE lpData, - &size //__inout_opt LPDWORD lpcbData - ); - if( ERROR_SUCCESS == retVal ) - { - VSVersionInfo vInfo; - vInfo.Path = value; - vInfo.Path += vskey.pathToAdd; - pVersions->push_back( vInfo ); - } - } - startVersion = NUMNAMESTOCHECK - 1; // if we loop around again make sure it's from the top - } - - for( int i =0; i < NUMVSKEYS; ++i ) - { - RegCloseKey( VS_KEYS[i].key ); - } - return; -} - - -void ReadAndHandleOutputThread( LPVOID arg ) -{ - CmdProcess* pCmdProc = (CmdProcess*)arg; - - CHAR lpBuffer[1024]; - DWORD nBytesRead; - bool bReadActive = true; - while( bReadActive ) - { - if( !ReadFile( pCmdProc->m_CmdProcessOutputRead,lpBuffer,sizeof(lpBuffer)-1, - &nBytesRead,NULL) || !nBytesRead) - { - bReadActive = false; - if( GetLastError() != ERROR_BROKEN_PIPE) //broken pipe is OK - { - if(pCmdProc->m_pLogger ) pCmdProc->m_pLogger->LogError( "[RuntimeCompiler] Redirect of compile output failed on read\n" ); - } - } - else - { - // Add null termination - lpBuffer[nBytesRead]=0; - - //fist check for completion token... - std::string buffer( lpBuffer ); - size_t found = buffer.find( c_CompletionToken ); - if( found != std::string::npos ) - { - //we've found the completion token, which means we quit - buffer = buffer.substr( 0, found ); - if( !pCmdProc->m_bStoreCmdOutput && pCmdProc->m_pLogger ) pCmdProc->m_pLogger->LogInfo("[RuntimeCompiler] Complete\n"); - pCmdProc->m_bIsComplete = true; - } - if( bReadActive || buffer.length() ) //don't output blank last line - { - if( pCmdProc->m_bStoreCmdOutput ) - { - pCmdProc->m_CmdOutput += buffer; - } - else - { - //check if this is an error - size_t errorFound = buffer.find( " : error " ); - size_t fatalErrorFound = buffer.find( " : fatal error " ); - if( ( errorFound != std::string::npos ) || ( fatalErrorFound != std::string::npos ) ) - { - if(pCmdProc->m_pLogger ) pCmdProc->m_pLogger->LogError( "%s", buffer.c_str() ); - } - else - { - if(pCmdProc->m_pLogger ) pCmdProc->m_pLogger->LogInfo( "%s", buffer.c_str() ); - } - } - } - } - } -} - -PlatformCompilerImplData::PlatformCompilerImplData() - : m_bFindVS(true) - , m_pLogger(NULL) -{ -} - -PlatformCompilerImplData::~PlatformCompilerImplData() -{ -} - -CmdProcess::CmdProcess() - : m_CmdProcessOutputRead(NULL) - , m_CmdProcessInputWrite(NULL) - , m_bIsComplete(false) - , m_pLogger(NULL) - , m_bStoreCmdOutput(false) -{ - ZeroMemory(&m_CmdProcessInfo, sizeof(m_CmdProcessInfo)); -} - -void CmdProcess::InitialiseProcess() -{ - //init compile process - STARTUPINFOW si; - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - - // Set up the security attributes struct. - SECURITY_ATTRIBUTES sa; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - - - // Create the child output pipe. - //redirection of output - si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; - HANDLE hOutputReadTmp = NULL, hOutputWrite = NULL, hErrorWrite = NULL; - if (!CreatePipe(&hOutputReadTmp, &hOutputWrite, &sa, 20 * 1024)) - { - if (m_pLogger) m_pLogger->LogError("[RuntimeCompiler] Failed to create output redirection pipe\n"); - - if( hOutputReadTmp ) - { - CloseHandle( hOutputReadTmp ); - } - if( hOutputWrite ) - { - CloseHandle(hOutputWrite); - } - if( hErrorWrite ) - { - CloseHandle( hErrorWrite ); - } - return; - } - si.hStdOutput = hOutputWrite; - - // Create a duplicate of the output write handle for the std error - // write handle. This is necessary in case the child application - // closes one of its std output handles. - if (!DuplicateHandle(GetCurrentProcess(), hOutputWrite, - GetCurrentProcess(), &hErrorWrite, 0, - TRUE, DUPLICATE_SAME_ACCESS)) - { - if (m_pLogger) m_pLogger->LogError("[RuntimeCompiler] Failed to duplicate error output redirection pipe\n"); - - if( hOutputReadTmp ) - { - CloseHandle( hOutputReadTmp ); - } - if( hOutputWrite ) - { - CloseHandle(hOutputWrite); - } - if( hErrorWrite ) - { - CloseHandle( hErrorWrite ); - } - - return; - } - si.hStdError = hErrorWrite; - - - // Create new output read handle and the input write handles. Set - // the Properties to FALSE. Otherwise, the child inherits the - // properties and, as a result, non-closeable handles to the pipes - // are created. - if (si.hStdOutput) - { - if (!DuplicateHandle(GetCurrentProcess(), hOutputReadTmp, - GetCurrentProcess(), - &m_CmdProcessOutputRead, // Address of new handle. - 0, FALSE, // Make it uninheritable. - DUPLICATE_SAME_ACCESS)) - { - if (m_pLogger) m_pLogger->LogError("[RuntimeCompiler] Failed to duplicate output read pipe\n"); - - if( hOutputReadTmp ) - { - CloseHandle( hOutputReadTmp ); - } - if( hOutputWrite ) - { - CloseHandle(hOutputWrite); - } - if( hErrorWrite ) - { - CloseHandle( hErrorWrite ); - } - return; - } - CloseHandle(hOutputReadTmp); - hOutputReadTmp = NULL; - } - - - HANDLE hInputRead, hInputWriteTmp; - // Create a pipe for the child process's STDIN. - if (!CreatePipe(&hInputRead, &hInputWriteTmp, &sa, 4096)) - { - if (m_pLogger) m_pLogger->LogError("[RuntimeCompiler] Failed to create input pipes\n"); - - if( hOutputReadTmp ) - { - CloseHandle( hOutputReadTmp ); - } - if( hOutputWrite ) - { - CloseHandle(hOutputWrite); - } - if( hErrorWrite ) - { - CloseHandle( hErrorWrite ); - } - return; - } - si.hStdInput = hInputRead; - - // Create new output read handle and the input write handles. Set - // the Properties to FALSE. Otherwise, the child inherits the - // properties and, as a result, non-closeable handles to the pipes - // are created. - if (si.hStdOutput) - { - if (!DuplicateHandle(GetCurrentProcess(), hInputWriteTmp, - GetCurrentProcess(), - &m_CmdProcessInputWrite, // Address of new handle. - 0, FALSE, // Make it uninheritable. - DUPLICATE_SAME_ACCESS)) - { - if (m_pLogger) m_pLogger->LogError("[RuntimeCompiler] Failed to duplicate input write pipe\n"); - if( hOutputReadTmp ) - { - CloseHandle( hOutputReadTmp ); - } - if( hOutputWrite ) - { - CloseHandle(hOutputWrite); - } - if( hErrorWrite ) - { - CloseHandle( hErrorWrite ); - } - return; - } - } - /* - // Ensure the write handle to the pipe for STDIN is not inherited. - if ( !SetHandleInformation(hInputWrite, HANDLE_FLAG_INHERIT, 0) ) - { - m_pLogger->LogError("[RuntimeCompiler] Failed to make input write pipe non inheritable\n"); - goto ERROR_EXIT; - } - */ - - const wchar_t* pCommandLine = L"cmd /q /K @PROMPT $"; - //CreateProcessW won't accept a const pointer, so copy to an array - wchar_t pCmdLineNonConst[1024]; - wcscpy_s(pCmdLineNonConst, pCommandLine); - CreateProcessW( - NULL, //__in_opt LPCTSTR lpApplicationName, - pCmdLineNonConst, //__inout_opt LPTSTR lpCommandLine, - NULL, //__in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes, - NULL, //__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes, - TRUE, //__in BOOL bInheritHandles, - 0, //__in DWORD dwCreationFlags, - NULL, //__in_opt LPVOID lpEnvironment, - NULL, //__in_opt LPCTSTR lpCurrentDirectory, - &si, //__in LPSTARTUPINFO lpStartupInfo, - &m_CmdProcessInfo //__out LPPROCESS_INFORMATION lpProcessInformation - ); - - //launch threaded read. - _beginthread(ReadAndHandleOutputThread, 0, this); //this will exit when process for compile is closed - - - if( hOutputReadTmp ) - { - CloseHandle( hOutputReadTmp ); - } - if( hOutputWrite ) - { - CloseHandle(hOutputWrite); - } - if( hErrorWrite ) - { - CloseHandle( hErrorWrite ); - } -} - - -void CmdProcess::WriteInput( std::string& input ) -{ - DWORD nBytesWritten; - DWORD length = (DWORD)input.length(); - WriteFile( m_CmdProcessInputWrite , input.c_str(), length, &nBytesWritten, NULL); -} - -void CmdProcess::CleanupProcessAndPipes() -{ - // do not reset m_bIsComplete and other members here, just process and pipes - if( m_CmdProcessInfo.hProcess ) - { - TerminateProcess(m_CmdProcessInfo.hProcess, 0); - TerminateThread(m_CmdProcessInfo.hThread, 0); - CloseHandle(m_CmdProcessInfo.hThread); - ZeroMemory(&m_CmdProcessInfo, sizeof(m_CmdProcessInfo)); - CloseHandle(m_CmdProcessInputWrite); - m_CmdProcessInputWrite = 0; - CloseHandle(m_CmdProcessOutputRead); - m_CmdProcessOutputRead = 0; - } -} - -CmdProcess::~CmdProcess() -{ - CleanupProcessAndPipes(); -} - -#endif // #ifdef _WIN32 diff --git a/src/Engine/vendor/RuntimeCompiler/Patches/RuntimeObjectSystem_PlatformWindows.cpp b/src/Engine/vendor/RuntimeCompiler/Patches/RuntimeObjectSystem_PlatformWindows.cpp deleted file mode 100644 index 7f603be6..00000000 --- a/src/Engine/vendor/RuntimeCompiler/Patches/RuntimeObjectSystem_PlatformWindows.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// -// Copyright (c) 2010-2011 Matthew Jack and Doug Binks -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. - -#ifdef _WIN32 - -#include "RuntimeProtector.h" -#include "RuntimeObjectSystem.h" - -#define WIN32_LEAN_AND_MEAN -#include "Windows.h" -#include "WinBase.h" -#include "excpt.h" -#include - -// windows includes can cause GetObject to be defined, we undefine it here. -#ifdef GetObject - #undef GetObject -#endif - -struct RuntimeObjectSystem::PlatformImpl -{ - - enum ExceptionState - { - ES_PASS, - ES_CATCH, - }; - - ExceptionState s_exceptionState; - - PlatformImpl() - : s_exceptionState( ES_PASS ) - { - } - - int RuntimeExceptionFilter() - { - if( !AmBeingDebugged() ) - { - // if there's no debugger, we simply continue operating. - // TODO: Should implement a method to ensure this can be - // disabled so process crashes on end user machines - return EXCEPTION_EXECUTE_HANDLER; - } - - int result; - switch (s_exceptionState) - { - case ES_PASS: - // Let pass to debugger once, then catch it - result = EXCEPTION_CONTINUE_SEARCH; - s_exceptionState = ES_CATCH; - break; - case ES_CATCH: - // Catch it now. Reset to catch in debugger again next time. - result = EXCEPTION_EXECUTE_HANDLER; - s_exceptionState = ES_PASS; - break; - default:; - assert(false); - } - - return result; - } - - bool AmBeingDebugged() - { - if( IsDebuggerPresent() ) - { - return true; - } - BOOL bRDebugPresent = FALSE; - CheckRemoteDebuggerPresent( GetModuleHandle(NULL), &bRDebugPresent ); - if( FALSE == bRDebugPresent ) - { - return false; - } - else - { - return true; - } - } - - int SimpleExceptionFilter( void * nativeExceptionInfo, RuntimeProtector* pRuntimeProtector ) - { - EXCEPTION_RECORD *pRecord = ((LPEXCEPTION_POINTERS) nativeExceptionInfo)->ExceptionRecord; - int nCode = pRecord->ExceptionCode; - pRuntimeProtector->ExceptionInfo.Type = RuntimeProtector::ESE_Unknown; - pRuntimeProtector->ExceptionInfo.Addr = 0; - - - if (nCode == EXCEPTION_ACCESS_VIOLATION) - { - ULONG_PTR flavour = pRecord->ExceptionInformation[0]; - switch( flavour ) - { - case 0: - pRuntimeProtector->ExceptionInfo.Type = RuntimeProtector::ESE_AccessViolationRead; - pRuntimeProtector->ExceptionInfo.Addr = (void*)pRecord->ExceptionInformation[1]; - break; - case 1: - pRuntimeProtector->ExceptionInfo.Type = RuntimeProtector::ESE_AccessViolationWrite; - pRuntimeProtector->ExceptionInfo.Addr = (void*)pRecord->ExceptionInformation[1]; - break; - default: - break; - } - } - else if( nCode == EXCEPTION_ILLEGAL_INSTRUCTION ) - { - pRuntimeProtector->ExceptionInfo.Type = RuntimeProtector::ESE_InvalidInstruction; - pRuntimeProtector->ExceptionInfo.Addr = pRecord->ExceptionAddress; - } - - if( !pRuntimeProtector->m_bHintAllowDebug ) - { - // We don't want debugging to catch this - return EXCEPTION_EXECUTE_HANDLER; - } - - // Otherwise fall back - return RuntimeExceptionFilter(); - } -}; - -void RuntimeObjectSystem::CreatePlatformImpl() -{ - m_pImpl = new PlatformImpl(); -} -void RuntimeObjectSystem::DeletePlatformImpl() -{ - delete m_pImpl; -} - -void RuntimeObjectSystem::SetProtectionEnabled( bool bProtectionEnabled_ ) -{ - m_bProtectionEnabled = bProtectionEnabled_; -} - - -bool RuntimeObjectSystem::TryProtectedFunction( RuntimeProtector* pProtectedObject_ ) -{ - bool bJustCaughtException = false; - if( m_TotalLoadedModulesEver != pProtectedObject_->m_ModulesLoadedCount ) - { - // clear exceptions if we've just loaded a new module - pProtectedObject_->m_ModulesLoadedCount = m_TotalLoadedModulesEver; - pProtectedObject_->m_bHashadException = false; - } - if( m_bProtectionEnabled ) - { - if( !pProtectedObject_->m_bHashadException ) - { - // Clang on Windows error : cannot compile this 'this' captured by SEH yet - // So we make a copy of this. - // https://github.com/RuntimeCompiledCPlusPlus/RuntimeCompiledCPlusPlus/pull/112 - /*RuntimeObjectSystem* thisCopy = this; - __try - { - pProtectedObject_->ProtectedFunc(); - } - __except( thisCopy->m_pImpl->SimpleExceptionFilter( GetExceptionInformation(), pProtectedObject_ ) ) - { - // If we hit any structured exception, exceptionInfo will be initialized - // If it's one we recognise and we hinted for no debugging, we'll go straight here, with info filled out - // If not we'll go to debugger first, then here - pProtectedObject_->m_bHashadException = true; - bJustCaughtException = true; - }*/ - } - } - else - { - pProtectedObject_->m_bHashadException = false; - pProtectedObject_->ProtectedFunc(); - } - return !bJustCaughtException; -} - -bool RuntimeObjectSystem::TestBuildWaitAndUpdate() -{ - Sleep( 100 ); - MSG msg; - while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) - { - DispatchMessage( &msg ); - } - return true; -} - -#endif // #ifdef _WIN32 diff --git a/src/LocalizationTool/CMakeLists.txt b/src/LocalizationTool/CMakeLists.txt index 5748cc61..8d7a3131 100644 --- a/src/LocalizationTool/CMakeLists.txt +++ b/src/LocalizationTool/CMakeLists.txt @@ -12,6 +12,11 @@ set_property(TARGET BeeLocalization PROPERTY CXX_STANDARD 23) target_include_directories(BeeLocalization PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src) target_link_libraries(BeeLocalization PUBLIC BeeEngine) -add_compile_definitions(BEE_ENABLE_CHECKS) +#add_compile_definitions(BEE_ENABLE_CHECKS) -file(COPY ../Engine/Assets/Shaders DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file +file(COPY ../Engine/Assets/Shaders DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + +set(BEE_LOC_INSTALL_PATH share/BeeLocalization) +install(TARGETS BeeLocalization DESTINATION bin) + +install(DIRECTORY ../Engine/Assets/Shaders/ DESTINATION ${BEE_LOC_INSTALL_PATH}/Shaders) diff --git a/src/LocalizationTool/src/LocalizationToolLayer.cpp b/src/LocalizationTool/src/LocalizationToolLayer.cpp index 457d7b72..ebbc8274 100644 --- a/src/LocalizationTool/src/LocalizationToolLayer.cpp +++ b/src/LocalizationTool/src/LocalizationToolLayer.cpp @@ -3,34 +3,33 @@ // #include "LocalizationToolLayer.h" -#include "Utils/FileDialogs.h" +#include "Core/Application.h" #include "Locale/LocalizationGenerator.h" +#include "Utils/FileDialogs.h" +#include #include -#include "Core/Application.h" - +#include namespace BeeEngine::LocalizationTool { - + const char* g_FileDialogKey = "Choose folder with localization files"; void LocalizationToolLayer::OnAttach() { + auto locale = Locale::GetSystemLocale(); + auto& fileIcon = AssetManager::GetAsset(EngineAssetRegistry::FileTexture, locale); + auto& folderIcon = AssetManager::GetAsset(EngineAssetRegistry::DirectoryTexture, locale); + ImGui::SetDefaultFileIcon( + (ImTextureID)fileIcon.GetGPUResource().GetRendererID(), fileIcon.GetWidth(), fileIcon.GetHeight()); + ImGui::SetDefaultFolderIcon( + (ImTextureID)folderIcon.GetGPUResource().GetRendererID(), folderIcon.GetWidth(), folderIcon.GetHeight()); + // ImGui::SetFileDialogThumbnailSize(m_Config.ThumbnailSize); + ImGui::OpenFolderFileDialog(g_FileDialogKey); m_Domain.SetLocale(Locale::Localization::Default); - Path folder = FileDialogs::OpenFolder(); - auto paths = Locale::LocalizationGenerator::GetLocalizationFiles(folder); - Locale::LocalizationGenerator::ProcessLocalizationFiles(m_Domain, paths); - m_Domain.Build(); - m_LocalizationPanel = CreateRef(m_Domain, folder); } - void LocalizationToolLayer::OnDetach() - { + void LocalizationToolLayer::OnDetach() {} - } - - void LocalizationToolLayer::OnUpdate(FrameData& frameData) - { - - } + void LocalizationToolLayer::OnUpdate(FrameData& frameData) {} void LocalizationToolLayer::OnGUIRendering() { @@ -39,17 +38,57 @@ namespace BeeEngine::LocalizationTool ImGui::SetNextWindowPos(viewport->Pos); ImGui::SetNextWindowSize(viewport->Size); ImGui::SetNextWindowViewport(viewport->ID); - //ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); - //ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 10.0f); - window_flags |= /*ImGuiWindowFlags_NoTitleBar |*/ ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; + // ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); + // ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 10.0f); + window_flags |= /*ImGuiWindowFlags_NoTitleBar |*/ ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | + ImGuiWindowFlags_NoMove; window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus; - //ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10.0f, 0.0f)); - m_LocalizationPanel->Render(window_flags, false); - //ImGui::PopStyleVar(2); - } + // ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10.0f, 0.0f)); + std::unique_lock lock(m_Lock); + switch (m_State) + { + case State::FolderChoice: + { + if (ImGui::BeginFileDialog(g_FileDialogKey)) + { + if (ImGui::IsFileDialogReady()) + { + auto chosenPath = ImGui::GetResultFileDialog(); + if (chosenPath.has_value()) + { + auto folder = BeeMove(chosenPath).value(); + auto job = Jobs::CreateJob( + [this, folder = BeeMove(folder)]() + { + auto paths = Locale::LocalizationGenerator::GetLocalizationFiles(folder); + Locale::LocalizationGenerator::ProcessLocalizationFiles(m_Domain, paths); + m_Domain.Build(); + std::unique_lock lock(m_Lock); + m_State = State::Editor; - void LocalizationToolLayer::OnEvent(EventDispatcher &e) - { + m_LocalizationPanel = CreateRef(m_Domain, folder); + }); + Jobs::Schedule(BeeMove(job)); + m_State = State::Waiting; + } + ImGui::CloseFileDialog(); + } + ImGui::EndFileDialog(); + } + break; + } + case State::Waiting: + ImGui::Begin("##loading"); + ImGui::TextCentered("Loading. Please Wait..."); + ImGui::End(); + break; + case State::Editor: + m_LocalizationPanel->Render(window_flags, false); + break; + } + // ImGui::PopStyleVar(2); } -} + + void LocalizationToolLayer::OnEvent(EventDispatcher& e) {} +} // namespace BeeEngine::LocalizationTool diff --git a/src/LocalizationTool/src/LocalizationToolLayer.h b/src/LocalizationTool/src/LocalizationToolLayer.h index ebd06777..18932414 100644 --- a/src/LocalizationTool/src/LocalizationToolLayer.h +++ b/src/LocalizationTool/src/LocalizationToolLayer.h @@ -4,22 +4,32 @@ #pragma once +#include "Core/AssetManagement/EditorAssetManager.h" #include "Core/Layer.h" #include "Locale/ImGuiLocalizationPanel.h" #include "Locale/Locale.h" namespace BeeEngine::LocalizationTool { - class LocalizationToolLayer: public Layer + class LocalizationToolLayer : public Layer { public: void OnAttach() override; void OnDetach() override; void OnUpdate(FrameData& frameData) override; void OnGUIRendering() override; - void OnEvent(BeeEngine::EventDispatcher &e) override; + void OnEvent(BeeEngine::EventDispatcher& e) override; + private: + enum class State + { + FolderChoice, + Waiting, + Editor + } m_State; + Jobs::SpinLock m_Lock; + EditorAssetManager m_AssetManager; Ref m_LocalizationPanel; Locale::Domain m_Domain{"Localization"}; }; -} +} // namespace BeeEngine::LocalizationTool