From 32774618584b817d04c5ce704984aefd94cf24e3 Mon Sep 17 00:00:00 2001 From: Huseyn Ismayilov Date: Fri, 22 Nov 2024 17:40:41 +0400 Subject: [PATCH] fix: Fix resources conflict and update scripts --- editor/CMakeLists.txt | 10 +++++-- editor/resources/imgui.ini | 49 +++++++++++++++++++++++++++++++++++ editor/src/GUI.cpp | 6 +++-- engine/CMakeLists.txt | 7 +++-- engine/rendering/Renderer.cpp | 2 +- engine/resources/imgui.ini | 49 ----------------------------------- scripts/BuildProject.sh | 43 ++++++++++++++++++------------ scripts/Makefile | 38 +++++++++++++++++---------- 8 files changed, 117 insertions(+), 87 deletions(-) create mode 100644 editor/resources/imgui.ini delete mode 100644 engine/resources/imgui.ini diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 6a079a0..5f10860 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -8,11 +8,17 @@ set(EDITOR_INCLUDE_DIR include) set(EDITOR_RESOURCES_DIR resources) file(GLOB_RECURSE EDITOR_SOURCES ${EDITOR_SOURCE_DIR}/*.cpp) -file(COPY ${EDITOR_RESOURCES_DIR}/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) add_executable(${NAME}) +# Add resources folder +if(CMAKE_BUILD_TYPE STREQUAL "Release") + file(COPY ${EDITOR_RESOURCES_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + target_compile_definitions(${NAME} PUBLIC EDITOR_RESOURCES_PATH="resources/") +else() + target_compile_definitions(${NAME} PUBLIC EDITOR_RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/") +endif() + target_sources(${NAME} PRIVATE ${EDITOR_SOURCES}) target_include_directories(${NAME} PRIVATE ${EDITOR_INCLUDE_DIR}) - target_link_libraries(${NAME} engine) diff --git a/editor/resources/imgui.ini b/editor/resources/imgui.ini new file mode 100644 index 0000000..7377525 --- /dev/null +++ b/editor/resources/imgui.ini @@ -0,0 +1,49 @@ +[Window][DockSpaceViewport_11111111] +Pos=0,24 +Size=900,576 +Collapsed=0 + +[Window][ Properties] +Pos=706,24 +Size=194,576 +Collapsed=0 +DockId=0x00000002,0 + +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][ Entities] +Pos=0,24 +Size=176,576 +Collapsed=0 +DockId=0x00000003,0 + +[Window][ Files] +Pos=178,442 +Size=526,158 +Collapsed=0 +DockId=0x00000006,0 + +[Window][ Scene] +Pos=178,24 +Size=526,416 +Collapsed=0 +DockId=0x00000005,0 + +[Window][ Console] +Pos=178,442 +Size=526,158 +Collapsed=0 +DockId=0x00000006,1 + +[Docking][Data] +DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,24 Size=900,576 Split=X + DockNode ID=0x00000003 Parent=0x8B93E3BD SizeRef=176,576 Selected=0xCCD86976 + DockNode ID=0x00000004 Parent=0x8B93E3BD SizeRef=722,576 Split=X + DockNode ID=0x00000001 Parent=0x00000004 SizeRef=526,576 Split=Y Selected=0xEE09B48D + DockNode ID=0x00000005 Parent=0x00000001 SizeRef=517,416 CentralNode=1 Selected=0xEE09B48D + DockNode ID=0x00000006 Parent=0x00000001 SizeRef=517,158 Selected=0x3CB89FC3 + DockNode ID=0x00000002 Parent=0x00000004 SizeRef=194,576 Selected=0x7B89DB48 + diff --git a/editor/src/GUI.cpp b/editor/src/GUI.cpp index 20e5699..c515a37 100644 --- a/editor/src/GUI.cpp +++ b/editor/src/GUI.cpp @@ -33,17 +33,19 @@ void GUI::LoadConfigs() io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; + io.IniFilename = EDITOR_RESOURCES_PATH"imgui.ini"; + float baseFontSize = 14.0f; float iconFontSize = baseFontSize * 2.0f / 2.4f; // FontAwesome fonts need to have their sizes reduced by 2.0f/3.0f in order to align correctly - io.Fonts->AddFontFromFileTTF("fonts/Ruda-Bold.ttf", baseFontSize); + io.Fonts->AddFontFromFileTTF(ENGINE_RESOURCES_PATH"fonts/Ruda-Bold.ttf", baseFontSize); static const ImWchar iconsRanges[] = { ICON_MIN_FA, ICON_MAX_16_FA, 0 }; ImFontConfig iconsConfig; iconsConfig.MergeMode = true; iconsConfig.PixelSnapH = true; iconsConfig.GlyphMinAdvanceX = iconFontSize; - io.Fonts->AddFontFromFileTTF( "fonts/" FONT_ICON_FILE_NAME_FAS, iconFontSize, &iconsConfig, iconsRanges ); + io.Fonts->AddFontFromFileTTF(ENGINE_RESOURCES_PATH"fonts/" FONT_ICON_FILE_NAME_FAS, iconFontSize, &iconsConfig, iconsRanges ); ImGui::StyleColorsDark(); diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 7ac7334..79f5b10 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -21,14 +21,17 @@ file(GLOB COMPONENTS_SOURCES "${COMPONENTS_INCLUDES}/*.cpp") set(UI_INCLUDES ui) file(GLOB UI_SOURCES "${UI_INCLUDES}/*.cpp") +set(ENGINE_RESOURCES_DIR resources) + # Build engine as library add_library(${PROJECT_NAME}) # Add resources folder if(CMAKE_BUILD_TYPE STREQUAL "Release") - target_compile_definitions(${PROJECT_NAME} PUBLIC RESOURCES_PATH="./resources/") + file(COPY ${ENGINE_RESOURCES_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + target_compile_definitions(${PROJECT_NAME} PUBLIC ENGINE_RESOURCES_PATH="${CMAKE_CURRENT_BINARY_DIR}/resources/") else() - target_compile_definitions(${PROJECT_NAME} PUBLIC RESOURCES_PATH="${CMAKE_SOURCE_DIR}/engine/resources/") + target_compile_definitions(${PROJECT_NAME} PUBLIC ENGINE_RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/") endif() # Link sources, include directories, and third party libraries diff --git a/engine/rendering/Renderer.cpp b/engine/rendering/Renderer.cpp index c11958a..e418b6b 100644 --- a/engine/rendering/Renderer.cpp +++ b/engine/rendering/Renderer.cpp @@ -47,7 +47,7 @@ RendererData& Renderer::GetData() void Renderer::LoadShaders() { - s_Data.m_Shader = new Shader(RESOURCES_PATH"shaders/vertex.glsl", RESOURCES_PATH"shaders/fragment.glsl"); + s_Data.m_Shader = new Shader(ENGINE_RESOURCES_PATH"shaders/vertex.glsl", ENGINE_RESOURCES_PATH"shaders/fragment.glsl"); } void Renderer::SetupBuffers() diff --git a/engine/resources/imgui.ini b/engine/resources/imgui.ini deleted file mode 100644 index 2bf75d3..0000000 --- a/engine/resources/imgui.ini +++ /dev/null @@ -1,49 +0,0 @@ -[Window][DockSpaceViewport_11111111] -Pos=0,19 -Size=900,581 -Collapsed=0 - -[Window][Debug##Default] -Pos=60,60 -Size=400,400 -Collapsed=0 - -[Window][Hierarchy] -Pos=0,19 -Size=189,581 -Collapsed=0 -DockId=0x00000005,0 - -[Window][Scene] -Pos=191,19 -Size=510,420 -Collapsed=0 -DockId=0x00000003,0 - -[Window][Project] -Pos=191,441 -Size=510,159 -Collapsed=0 -DockId=0x00000004,0 - -[Window][Console] -Pos=191,441 -Size=510,159 -Collapsed=0 -DockId=0x00000004,1 - -[Window][Inspector] -Pos=703,19 -Size=197,581 -Collapsed=0 -DockId=0x00000002,0 - -[Docking][Data] -DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,19 Size=900,581 Split=X - DockNode ID=0x00000005 Parent=0x8B93E3BD SizeRef=189,581 Selected=0x29EABFBD - DockNode ID=0x00000006 Parent=0x8B93E3BD SizeRef=709,581 Split=X - DockNode ID=0x00000001 Parent=0x00000006 SizeRef=701,581 Split=Y - DockNode ID=0x00000003 Parent=0x00000001 SizeRef=608,420 CentralNode=1 Selected=0xE192E354 - DockNode ID=0x00000004 Parent=0x00000001 SizeRef=608,159 Selected=0xD04A4B96 - DockNode ID=0x00000002 Parent=0x00000006 SizeRef=197,581 Selected=0xE7039252 - diff --git a/scripts/BuildProject.sh b/scripts/BuildProject.sh index 6055f71..4323d49 100755 --- a/scripts/BuildProject.sh +++ b/scripts/BuildProject.sh @@ -1,34 +1,43 @@ #!/bin/bash -BUILD_DIR="build" +RELEASE_BUILD_DIR="build-release" +DEBUG_BUILD_DIR="build-debug" EDITOR_DIR="editor" NAME="ferx" case $1 in - release) - cmake -S .. -B ../"$BUILD_DIR" -G Ninja -DCMAKE_BUILD_TYPE=Release - cmake --build ../"$BUILD_DIR" -j8 + build-release) + cmake -S .. -B ../"$RELEASE_BUILD_DIR" -G Ninja -DCMAKE_BUILD_TYPE=Release + cmake --build ../"$RELEASE_BUILD_DIR" -j8 ;; - debug) - cmake -S .. -B ../"$BUILD_DIR" -G Ninja -DCMAKE_BUILD_TYPE=Debug - cmake --build ../"$BUILD_DIR" -j8 + build-debug) + cmake -S .. -B ../"$DEBUG_BUILD_DIR" -G Ninja -DCMAKE_BUILD_TYPE=Debug + cmake --build ../"$DEBUG_BUILD_DIR" -j8 ;; - run) - cd "../$BUILD_DIR/$EDITOR_DIR" && ./"$NAME" + run-release) + cd "../$RELEASE_BUILD_DIR/$EDITOR_DIR" && ./"$NAME" ;; - clean) - cmake --build ../"$BUILD_DIR" --target clean + run-debug) + cd "../$DEBUG_BUILD_DIR/$EDITOR_DIR" && ./"$NAME" ;; - clean-all) - rm -r ../"$BUILD_DIR" + clean-release) + cmake --build ../"$RELEASE_BUILD_DIR" --target clean + ;; + clean-debug) + cmake --build ../"$DEBUG_BUILD_DIR" --target clean + ;; + clean-release-all) + rm -r ../"$RELEASE_BUILD_DIR" + ;; + clean-debug-all) + rm -r ../"$DEBUG_BUILD_DIR" ;; all) - bash $0 enter_dir - bash $0 debug - bash $0 run + bash $0 build-debug + bash $0 run-debug ;; *) - echo "Usage: $0 {release|debug|run|clean|clean-all|all}" + echo "Usage: $0 {all|build-release|build-debug|run-release|run-debug|clean-release|clean-debug|clean-release-all|clean-debug-all}" exit 1 ;; esac diff --git a/scripts/Makefile b/scripts/Makefile index 5bcf81e..7975e90 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,24 +1,34 @@ -BUILD_DIR = build +DEBUG_BUILD_DIR = build-debug +RELEASE_BUILD_DIR = build-release EDITOR_DIR = editor NAME = ferx RM += -r -all: debug run +all: build-debug run-debug -release: - cmake -S .. -B ../$(BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Release - cmake --build ../$(BUILD_DIR) -j8 +build-release: + cmake -S .. -B ../$(RELEASE_BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Release + cmake --build ../$(RELEASE_BUILD_DIR) -j8 -debug: - cmake -S .. -B ../$(BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Debug - cmake --build ../$(BUILD_DIR) -j8 +build-debug: + cmake -S .. -B ../$(DEBUG_BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Debug + cmake --build ../$(DEBUG_BUILD_DIR) -j8 -run: - cd ../$(BUILD_DIR)/${EDITOR_DIR} && ./${NAME} +run-release: + cd ../$(RELEASE_BUILD_DIR)/${EDITOR_DIR} && ./${NAME} -clean: - cmake --build ../$(BUILD_DIR) --target clean +run-debug: + cd ../$(DEBUG_BUILD_DIR)/${EDITOR_DIR} && ./${NAME} + +clean-release: + cmake --build ../$(RELEASE_BUILD_DIR) --target clean -clean-all: - $(RM) ../$(BUILD_DIR) +clean-debug: + cmake --build ../$(DEBUG_BUILD_DIR) --target clean + +clean-release-all: + $(RM) ../$(RELEASE_BUILD_DIR) + +clean-debug-all: + $(RM) ../$(DEBUG_BUILD_DIR)