diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml old mode 100644 new mode 100755 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml old mode 100644 new mode 100755 diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/build_engine.yml b/.github/workflows/build_engine.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index e24398cb9..85c6ff7b2 --- a/.gitignore +++ b/.gitignore @@ -3,15 +3,37 @@ .vs/ .vscode/ +# VSCode +.vscode/ + CMakeSettings.json # Build cmake-build-*/ +build/ +out/ build*/ -out*/ .ccls-cache -# macOS +# macos */.DS_Store +*/*/.DS_Store .DS_Store + +# Xcode +ChiraEngine.xcodeproj/*/xcuserdata +ChiraEngine.xcodeproj/xcuserdata + +# KDevelop +*.kdev4 +.kdev4/ + +# clangd +.cache/ + +# what +steam_appid.txt + +# generator that is not ready at all +generator/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules old mode 100644 new mode 100755 index 674a0090d..f8418515d --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "engine/thirdparty/imgui-filebrowser"] path = engine/thirdparty/imgui-filebrowser url = https://github.com/AirGuanZ/imgui-filebrowser +[submodule "editor/thirdparty/imguizmo"] + path = editor/thirdparty/imguizmo + url = https://github.com/ashifolfi/ImGuizmo-cmake diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index ec2744829..bd2bccfbc --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,14 @@ if(CHIRA_COMPILER_ID MATCHES "clang") endif() endif() +# Detect macOS so we can make needed changes +if(${CMAKE_SYSTEM} MATCHES "Darwin") + add_definitions(-DMACOSX) + # Include CoreFoundation Library as we absolutely need this + find_library(CORE_LIB CoreFoundation) + list(APPEND CHIRA_ENGINE_LINK_LIBRARIES ${CORE_LIB}) +endif() + # Macro to apply optimization flags to multiple targets option(CHIRA_BUILD_WITH_WARNINGS "Build Chira Engine with warnings enabled" ON) option(CHIRA_TREAT_WARNINGS_AS_ERRORS "Build Chira Engine with warnings treated as errors" OFF) # Currently catches warnings from libraries @@ -206,7 +214,8 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/engine/thirdparty/stb ${CMAKE_CURRENT_SOURCE_DIR}/engine/thirdparty/stduuid/include ${CMAKE_CURRENT_SOURCE_DIR}/engine/thirdparty/tinyfiledialogs - ${CMAKE_CURRENT_SOURCE_DIR}/engine/thirdparty/imgui-filebrowser) + ${CMAKE_CURRENT_SOURCE_DIR}/engine/thirdparty/imgui-filebrowser +) target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/engine/thirdparty/glad/include) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/engine) @@ -215,77 +224,26 @@ target_link_libraries(${PROJECT_NAME} PUBLIC ${OPENGL_LIBRARIES} ${CHIRA_ENGINE_ # CHIRAEDITOR option(CHIRA_BUILD_EDITOR "Build the editor GUI application" ON) if(CHIRA_BUILD_EDITOR) - include(${CMAKE_CURRENT_SOURCE_DIR}/editor/CMakeLists.txt) - if(WIN32) - list(APPEND CHIRA_EDITOR_SOURCES ${CMAKE_CURRENT_LIST_DIR}/resources/platform/windows/icon.rc) - endif() - if(APPLE) - list(APPEND CHIRA_APPLE_BUNDLE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/resources/platform/macOS/AppIcon.icns - ${CMAKE_CURRENT_SOURCE_DIR}/resources/platform/macOS/Info.plist) - list(APPEND CHIRA_EDITOR_SOURCES ${CHIRA_APPLE_BUNDLE_FILES}) - endif() - add_executable(ChiraEditor ${CHIRA_EDITOR_SOURCES}) - apply_optimizations(ChiraEditor) - if(WIN32) - add_custom_target( - CopyEditorIcon - ALL - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/platform/windows/icon.ico ${CMAKE_BINARY_DIR}/resources/platform/windows/icon.ico) - add_dependencies(ChiraEditor CopyEditorIcon) - endif() - if(APPLE) - set_target_properties(ChiraEditor PROPERTIES - MACOSX_BUNDLE TRUE - MACOSX_FRAMEWORK_IDENTIFIER info.craftablescience.ChiraEditor - BUNDLE "${CHIRA_APPLE_BUNDLE_FILES}") - endif() - target_link_libraries(ChiraEditor PRIVATE ${PROJECT_NAME}) - target_include_directories(ChiraEditor PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/editor) - - option(CHIRA_EDITOR_BUILD_INSTALLER "Build an installer for the editor binaries" OFF) - if(CHIRA_EDITOR_BUILD_INSTALLER) - set(CPACK_PACKAGE_VENDOR "Chira Engine Developers" CACHE STRING "" FORCE) - set(CPACK_GENERATOR "TGZ" CACHE STRING "" FORCE) - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An open source game engine for Windows, Linux, and macOS." CACHE STRING "" FORCE) - set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/branding/steam/avatars/spider.png" CACHE STRING "" FORCE) - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt" CACHE STRING "" FORCE) - set(CPACK_MONOLITHIC_INSTALL TRUE CACHE BOOL "" FORCE) - if(WIN32) - #todo: NSIS or WIX - #set(CPACK_GENERATOR "WIX" CACHE STRING "" FORCE) - message(FATAL_ERROR "Sorry, no Windows installer is supported yet.") - elseif(APPLE) - set(CPACK_GENERATOR "Bundle" CACHE STRING "" FORCE) - set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/branding/github/readme_banner.png" CACHE STRING "" FORCE) - set(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE TRUE CACHE BOOL "" FORCE) - set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/platform/macOS/Info.plist CACHE STRING "" FORCE) - set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/resources/platform/macOS/AppIcon.icns CACHE STRING "" FORCE) - elseif(UNIX) - #todo: DEB and/or RPM - message(FATAL_ERROR "Sorry, no Linux installer is supported yet.") - endif() - include(CPack) - endif() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/editor) endif() + # CHIRATEST -if(CHIRA_BUILD_TESTS) - add_executable(ChiraTest ${CHIRA_TEST_SOURCES}) - target_link_libraries(ChiraTest PUBLIC ${PROJECT_NAME} gtest_main) - target_include_directories(ChiraTest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) - include(GoogleTest) - gtest_discover_tests(ChiraTest) - - # Copy gtest binaries next to the executable - add_custom_command( - TARGET ChiraTest - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}) -endif() +# if(CHIRA_BUILD_TESTS) +# add_executable(ChiraTest ${CHIRA_TEST_SOURCES}) +# target_link_libraries(ChiraTest PUBLIC ${PROJECT_NAME} gtest_main) +# target_include_directories(ChiraTest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) +# include(GoogleTest) +# gtest_discover_tests(ChiraTest) + +# # Copy gtest binaries next to the executable +# add_custom_command( +# TARGET ChiraTest +# PRE_BUILD +# COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}) +# endif() # Copy resources -add_custom_command( - TARGET ${PROJECT_NAME} - PRE_BUILD +add_custom_target(${PROJECT_NAME}CopyResources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/resources ${CMAKE_BINARY_DIR}/resources) +add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}CopyResources) diff --git a/LICENSE.txt b/LICENSE.txt old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/branding/README.md b/branding/README.md old mode 100644 new mode 100755 diff --git a/branding/github/readme_banner.png b/branding/github/readme_banner.png old mode 100644 new mode 100755 diff --git a/branding/steam/avatars/spider.png b/branding/steam/avatars/spider.png old mode 100644 new mode 100755 diff --git a/branding/steam/community/capsule.png b/branding/steam/community/capsule.png old mode 100644 new mode 100755 diff --git a/branding/steam/community/community_group_header.png b/branding/steam/community/community_group_header.png old mode 100644 new mode 100755 diff --git a/branding/steam/community/community_icon.ico b/branding/steam/community/community_icon.ico old mode 100644 new mode 100755 diff --git a/branding/steam/community/community_icon.png b/branding/steam/community/community_icon.png old mode 100644 new mode 100755 diff --git a/branding/steam/community/devhub_banner.png b/branding/steam/community/devhub_banner.png old mode 100644 new mode 100755 diff --git a/branding/steam/community/workshop_banner.png b/branding/steam/community/workshop_banner.png old mode 100644 new mode 100755 diff --git a/branding/steam/library/library_capsule.png b/branding/steam/library/library_capsule.png old mode 100644 new mode 100755 diff --git a/branding/steam/library/library_hero.png b/branding/steam/library/library_hero.png old mode 100644 new mode 100755 diff --git a/branding/steam/library/library_logo.png b/branding/steam/library/library_logo.png old mode 100644 new mode 100755 diff --git a/branding/steam/store/store_header_capsule.png b/branding/steam/store/store_header_capsule.png old mode 100644 new mode 100755 diff --git a/branding/steam/store/store_main_capsule.png b/branding/steam/store/store_main_capsule.png old mode 100644 new mode 100755 diff --git a/branding/steam/store/store_small_capsule.png b/branding/steam/store/store_small_capsule.png old mode 100644 new mode 100755 diff --git a/branding/steam/store/store_vertical_capsule.png b/branding/steam/store/store_vertical_capsule.png old mode 100644 new mode 100755 diff --git a/bundle_resources/AppIcon.icns b/bundle_resources/AppIcon.icns new file mode 100755 index 000000000..6cce6fb0c Binary files /dev/null and b/bundle_resources/AppIcon.icns differ diff --git a/bundle_resources/Info.plist b/bundle_resources/Info.plist new file mode 100755 index 000000000..e04740e05 --- /dev/null +++ b/bundle_resources/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ChiraEditor + CFBundleGetInfoString + + CFBundleIconFile + AppIcon.icns + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + + CFBundleName + Chira Editor + CFBundlePackageType + APPL + CFBundleShortVersionString + + CFBundleSignature + ???? + CFBundleVersion + 1.0 + CSResourcesFileMapped + + NSHumanReadableCopyright + + + diff --git a/cmake_configure_macos.sh b/cmake_configure_macos.sh index a4794390b..8998dcdca 100755 --- a/cmake_configure_macos.sh +++ b/cmake_configure_macos.sh @@ -20,14 +20,14 @@ config_xcode() check_param() { - TYPE=$1 + TYPE="$1" if [ "$TYPE" ]; then - if [ "$TYPE" = "Xcode" ]; + if [ "$TYPE" == "Xcode" ]; then config_xcode - elif [ "$TYPE" = "Makefiles" ]; + elif [ "$TYPE" == "Makefiles" ]; then config_noxcode else diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt old mode 100644 new mode 100755 index 1e0d75cf4..ab728c6fd --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -1,2 +1,77 @@ +list(APPEND CHIRA_EDITOR_HEADERS + ${CMAKE_CURRENT_LIST_DIR}/Editor.h + ${CMAKE_CURRENT_LIST_DIR}/EditorPlugin.h + ${CMAKE_CURRENT_LIST_DIR}/EngineView.h +) + list(APPEND CHIRA_EDITOR_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/Editor.cpp) + ${CHIRA_EDITOR_HEADERS} + ${CMAKE_CURRENT_LIST_DIR}/Editor.cpp + ${CMAKE_CURRENT_LIST_DIR}/EditorPlugin.cpp + ${CMAKE_CURRENT_LIST_DIR}/EngineView.cpp +) + +include(${CMAKE_CURRENT_LIST_DIR}/modeleditor/CMakeLists.txt) + +if(WIN32) + list(APPEND CHIRA_EDITOR_SOURCES ${CMAKE_CURRENT_LIST_DIR}/../resources/platform/windows/icon.rc) +endif() + +if(APPLE) + list(APPEND CHIRA_APPLE_BUNDLE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../resources/platform/macOS/AppIcon.icns + ${CMAKE_CURRENT_SOURCE_DIR}/../resources/platform/macOS/Info.plist) + list(APPEND CHIRA_EDITOR_SOURCES ${CHIRA_APPLE_BUNDLE_FILES}) +endif() + +# macos bundle for editor +# if(${CMAKE_SYSTEM} MATCHES "Darwin") +# add_executable(ChiraEditor MACOSX_BUNDLE ${CHIRA_EDITOR_SOURCES}) +# else() + add_executable(ChiraEditor ${CHIRA_EDITOR_SOURCES}) +# endif() + +apply_optimizations(ChiraEditor) + +if(WIN32) + add_custom_target( + CopyEditorIcon + ALL + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../resources/platform/windows/icon.ico ${CMAKE_BINARY_DIR}/resources/platform/windows/icon.ico) + add_dependencies(ChiraEditor CopyEditorIcon) +endif() + +if(APPLE) + set_target_properties(ChiraEditor PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_FRAMEWORK_IDENTIFIER info.craftablescience.ChiraEditor + BUNDLE "${CHIRA_APPLE_BUNDLE_FILES}") +endif() + +target_link_libraries(ChiraEditor PRIVATE ${PROJECT_NAME}) +target_include_directories(ChiraEditor PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/editor) + +option(CHIRA_EDITOR_BUILD_INSTALLER "Build an installer for the editor binaries" OFF) +if(CHIRA_EDITOR_BUILD_INSTALLER) + set(CPACK_PACKAGE_VENDOR "Chira Engine Developers" CACHE STRING "" FORCE) + set(CPACK_GENERATOR "TGZ" CACHE STRING "" FORCE) + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An open source game engine for Windows, Linux, and macOS." CACHE STRING "" FORCE) + set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/branding/steam/avatars/spider.png" CACHE STRING "" FORCE) + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt" CACHE STRING "" FORCE) + set(CPACK_MONOLITHIC_INSTALL TRUE CACHE BOOL "" FORCE) + if(WIN32) + #todo: NSIS or WIX + #set(CPACK_GENERATOR "WIX" CACHE STRING "" FORCE) + message(FATAL_ERROR "Sorry, no Windows installer is supported yet.") + elseif(APPLE) + set(CPACK_GENERATOR "Bundle" CACHE STRING "" FORCE) + set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/branding/github/readme_banner.png" CACHE STRING "" FORCE) + set(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE TRUE CACHE BOOL "" FORCE) + set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/../resources/platform/macOS/Info.plist CACHE STRING "" FORCE) + set(CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/../resources/platform/macOS/AppIcon.icns CACHE STRING "" FORCE) + elseif(UNIX) + #todo: DEB and/or RPM + message(FATAL_ERROR "Sorry, no Linux installer is supported yet.") + endif() + include(CPack) +endif() diff --git a/editor/Editor.cpp b/editor/Editor.cpp old mode 100644 new mode 100755 index b8ba82ce7..4b2db9667 --- a/editor/Editor.cpp +++ b/editor/Editor.cpp @@ -1,4 +1,7 @@ +#include "Editor.h" + // Disable console window on Windows (MSVC) +// EXPLAIN: what is the issue with having a console window? #include #if defined(_WIN32) && !defined(DEBUG) && defined(CHIRA_COMPILER_MSVC) #pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") @@ -9,13 +12,13 @@ #include #include #include -#include -#include -#include #include -#include #include #include +#include +#include +#include "EditorPlugin.h" +#include