From b50719685148bc6aa2afcdc9d09ae2555db0a6ab Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 4 Jun 2019 14:44:39 -1000 Subject: [PATCH] LibCommon now being integrated as an add_subdirectory submodule --- .gitmodules | 3 ++ CMakeLists.txt | 13 +++++++- README.md | 5 +++ dewfile.json | 21 +++--------- externals/LibCommon | 1 + src/Core/CMakeLists.txt | 11 ++----- src/Editor/CBasicViewport.cpp | 9 ++++++ src/Editor/CMakeLists.txt | 14 ++++++++ src/Editor/ModelEditor/CModelEditorWindow.h | 36 ++++++++++----------- src/Editor/WorldEditor/CPoiMapSidebar.h | 13 +++++--- 10 files changed, 77 insertions(+), 49 deletions(-) create mode 100644 .gitmodules create mode 160000 externals/LibCommon diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..1ca8eb31 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "externals/LibCommon"] + path = externals/LibCommon + url = ../LibCommon.git diff --git a/CMakeLists.txt b/CMakeLists.txt index ba9f110d..416edbb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,11 @@ endif() project(PrimeWorldEditor CXX) +# Ensure submodules checked out +if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/externals/LibCommon/CMakeLists.txt) + message(FATAL_ERROR "Please run 'git submodules update --init --recursive' to fetch submodules.") +endif() + include(./dew.cmake) integrate_dew() @@ -16,7 +21,7 @@ include(cmake/generate_product_version.cmake) if(MSVC) add_compile_options(/WX /wd4267 /wd4100 /wd4101 /wd4189) else() - add_compile_options(-Wno-multichar) + add_compile_options(-Wno-multichar -Wno-undefined-var-template) endif() if(APPLE) @@ -28,5 +33,11 @@ endif() # as defined above. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +# Directly integrate libcommon and block install targets +set(LIBCOMMON_GENERATE_INSTALL_TARGETS OFF) +set(CODEGEN_GENERATE_INSTALL_TARGETS OFF) +set(CODEGEN_BUILD_PACKAGE_DURING_CONFIGURE ON) +add_subdirectory(externals/LibCommon) + add_subdirectory(src/Core) add_subdirectory(src/Editor) diff --git a/README.md b/README.md index 580371a2..40e99b59 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ Prime World Editor is a custom editor suite for Retro Studios' GameCube and Wii games, including the Metroid Prime series and Donkey Kong Country Returns. +# Clone Submodules First! + +Builders on all platforms should ensure submodules are up to date with the current PrimeWorldEditor +by running `git submodule update --init --recursive`. + # Building on Windows ## Requirements diff --git a/dewfile.json b/dewfile.json index d32ad741..e344126a 100644 --- a/dewfile.json +++ b/dewfile.json @@ -1,4 +1,5 @@ { + "subdirectories": ["externals/LibCommon"], "dependencies": [ { "name": "zlib", @@ -9,10 +10,10 @@ }, { "name": "assimp", - "url": "https://github.com/jackoalan/assimp", + "url": "https://github.com/assimp/assimp", "type": "git", - "head": "static-lib-export", - "ref": "d048bccad1ea3f72906da2d970b30f187db91f33", + "head": "master", + "ref": "83237de02ffb97305317d24564c44ce4794af3db", "dependson": [ "zlib" ], @@ -29,20 +30,6 @@ "head": "master", "ref": "a1284ae06586b958f36b8ecaba29390835ed2820" }, - { - "name": "CodeGen", - "url": "https://github.com/jackoalan/CodeGen", - "type": "git", - "head": "cmake", - "ref": "abfbe39870a0de99a31d536fa958e5391977b85c" - }, - { - "name": "LibCommon", - "url": "https://github.com/jackoalan/LibCommon", - "type": "git", - "head": "dew", - "ref": "09184cc6dd132c831734a3235c4143fcfbd72281" - }, { "name": "lzokay", "url": "https://github.com/sfuller/lzokay", diff --git a/externals/LibCommon b/externals/LibCommon new file mode 160000 index 00000000..b4c0cb42 --- /dev/null +++ b/externals/LibCommon @@ -0,0 +1 @@ +Subproject commit b4c0cb42f6b13b31c7a085d87e1ebf43defca327 diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 535bdab1..d2edac23 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.12) project(pwe_core CXX C) -find_package(libcommon CONFIG REQUIRED) -find_package(codegen CONFIG REQUIRED) find_package(tinyxml2 CONFIG REQUIRED) find_package(nod CONFIG REQUIRED) find_package(logvisor CONFIG REQUIRED) @@ -15,8 +13,6 @@ find_package(ZLIB REQUIRED) # AssImp's cmake config is pretty awful. It doesn't include necesary libraries. Hopefully this can be fixed later. find_library(IIRXML_LIBRARY NAMES IrrXMLd IrrXML) -include(codegen) - file(GLOB_RECURSE source_files "*.c" "*.cpp" @@ -37,12 +33,11 @@ target_include_directories(pwe_core target_link_libraries( pwe_core - libcommon::libcommon + libcommon nod::nod logvisor::logvisor lzokay::lzokay OpenGL::GL - codegen::codegen assimp::assimp ${IIRXML_LIBRARY} ${ZLIB_LIBRARY} @@ -57,14 +52,14 @@ target_compile_definitions( GLEW_STATIC ) -gather_include_directories(pwecore_include_directories pwe_core) +gather_include_directories(pwe_core_include_directories pwe_core) add_codegen_targets( "${source_files}" codegen_generated_files "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" - "${pwecore_include_directories}" + "${pwe_core_include_directories}" ) add_custom_target(pwe_core_codegen DEPENDS ${codegen_generated_files} SOURCES ${source_files}) diff --git a/src/Editor/CBasicViewport.cpp b/src/Editor/CBasicViewport.cpp index 0db74045..2b2ce856 100644 --- a/src/Editor/CBasicViewport.cpp +++ b/src/Editor/CBasicViewport.cpp @@ -83,6 +83,11 @@ void CBasicViewport::mousePressEvent(QMouseEvent *pEvent) if (IsMouseInputActive()) { +#if __APPLE__ + // This will zero out the drag accumulators + gpMouseDragCocoaEventFilter->claimX(); + gpMouseDragCocoaEventFilter->claimY(); +#endif SetCursorVisible(false); mMouseMoved = false; mMoveTimer.Restart(); @@ -266,6 +271,10 @@ void CBasicViewport::ProcessInput() if (IsMouseInputActive()) { #ifdef __APPLE__ + // QCursor::setPos only works on macOS when the user permits PWE + // to control the computer via Universal Access. + // As an alternative to relying on the delta of a warped mouse, + // use the accumulated delta directly reported by AppKit. float XMovement = gpMouseDragCocoaEventFilter->claimX() * 0.01f; float YMovement = gpMouseDragCocoaEventFilter->claimY() * 0.01f; #else diff --git a/src/Editor/CMakeLists.txt b/src/Editor/CMakeLists.txt index c5b2c8ee..fc9ced18 100644 --- a/src/Editor/CMakeLists.txt +++ b/src/Editor/CMakeLists.txt @@ -124,6 +124,20 @@ target_compile_definitions( UNICODE ) +gather_include_directories(pwe_editor_include_directories pwe_editor) + +add_codegen_targets( + "${source_files}" + codegen_generated_files + "${PROJECT_SOURCE_DIR}" + "${PROJECT_BINARY_DIR}" + "${pwe_editor_include_directories}" +) +add_custom_target(pwe_editor_codegen DEPENDS ${codegen_generated_files} SOURCES ${source_files}) + +# Add the generated sources to the library target +target_sources(pwe_editor PRIVATE ${codegen_generated_files}) + if (WIN32 OR APPLE) set(CPACK_GENERATOR ZIP) set(CPACK_STRIP_FILES ON) diff --git a/src/Editor/ModelEditor/CModelEditorWindow.h b/src/Editor/ModelEditor/CModelEditorWindow.h index 66b1456e..8b7c3e5e 100644 --- a/src/Editor/ModelEditor/CModelEditorWindow.h +++ b/src/Editor/ModelEditor/CModelEditorWindow.h @@ -38,24 +38,6 @@ public: void SetActiveModel(CModel *pModel); CModelEditorViewport* Viewport() const; -public slots: - void RefreshViewport(); - void SetActiveMaterial(int MatIndex); - void SetActivePass(int PassIndex); - void UpdateMaterial(); - void UpdateMaterial(int Value); - void UpdateMaterial(int ValueA, int ValueB); - void UpdateMaterial(double Value); - void UpdateMaterial(bool Value); - void UpdateMaterial(QColor Value); - void UpdateMaterial(QString Value); - void UpdateUI(int Value); - void UpdateAnimParamUI(EUVAnimMode Mode); - -private: - void ActivateMatEditUI(bool Active); - void RefreshMaterial(); - enum class EModelEditorWidget { SetSelectComboBox, @@ -99,6 +81,24 @@ private: AnimParamDSpinBox, }; +public slots: + void RefreshViewport(); + void SetActiveMaterial(int MatIndex); + void SetActivePass(int PassIndex); + void UpdateMaterial(); + void UpdateMaterial(int Value); + void UpdateMaterial(int ValueA, int ValueB); + void UpdateMaterial(double Value); + void UpdateMaterial(bool Value); + void UpdateMaterial(QColor Value); + void UpdateMaterial(QString Value); + void UpdateUI(int Value); + void UpdateAnimParamUI(EUVAnimMode Mode); + +private: + void ActivateMatEditUI(bool Active); + void RefreshMaterial(); + private slots: void Import(); void ConvertToDDS(); diff --git a/src/Editor/WorldEditor/CPoiMapSidebar.h b/src/Editor/WorldEditor/CPoiMapSidebar.h index 6cd5de4c..f805b487 100644 --- a/src/Editor/WorldEditor/CPoiMapSidebar.h +++ b/src/Editor/WorldEditor/CPoiMapSidebar.h @@ -18,6 +18,7 @@ class CPoiMapSidebar : public CWorldEditorSidebar Q_OBJECT Ui::CPoiMapSidebar *ui; +public: enum class EHighlightMode { HighlightAll, @@ -25,10 +26,6 @@ class CPoiMapSidebar : public CWorldEditorSidebar HighlightSelected }; - CPoiMapModel mSourceModel; - QSortFilterProxyModel mModel; - EHighlightMode mHighlightMode; - // Viewport Picking enum class EPickType { @@ -36,8 +33,14 @@ class CPoiMapSidebar : public CWorldEditorSidebar AddMeshes, RemoveMeshes, AddPOIs - } mPickType; + }; +private: + CPoiMapModel mSourceModel; + QSortFilterProxyModel mModel; + EHighlightMode mHighlightMode; + + EPickType mPickType; CModelNode *mpHoverModel; static const CColor skNormalColor;