diff --git a/.github/workflows/build-ndk.yml b/.github/workflows/build-ndk.yml index 877174e..31584a4 100644 --- a/.github/workflows/build-ndk.yml +++ b/.github/workflows/build-ndk.yml @@ -47,14 +47,14 @@ jobs: with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: cargo-build.yml - name: linux-qpm-rust + name: linux-qpm path: QPM - repo: RedBrumbler/QuestPackageManager-Rust + repo: QuestPackageManager/QPM.CLI - name: QPM Collapse run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust collapse + chmod +x ./QPM/qpm + ./QPM/qpm collapse - name: QPM Dependencies Cache id: cache-qpm-deps @@ -62,7 +62,7 @@ jobs: env: cache-name: cache-qpm-deps with: - path: /home/runner/.local/share/QPM-Rust/cache + path: /home/runner/.local/share/qpm/cache key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- @@ -71,21 +71,12 @@ jobs: - name: QPM Restore run: | - ./QPM/qpm-rust restore - - - name: List Post Restore - run: | - echo includes: - ls -la ${GITHUB_WORKSPACE}/extern/includes - echo libs: - ls -la ${GITHUB_WORKSPACE}/extern/libs - echo cache: - ls -la $HOME/.local/share/QPM-Rust/cache + ./QPM/qpm restore - name: Build run: | cd ${GITHUB_WORKSPACE} - ./QPM/qpm-rust qmod build + ./QPM/qpm qmod build pwsh -Command ./build.ps1 - name: Create Qmod diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6a3b544..b98c338 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -34,14 +34,14 @@ jobs: with: github_token: ${{secrets.GITHUB_TOKEN}} workflow: cargo-build.yml - name: linux-qpm-rust + name: linux-qpm path: QPM - repo: RedBrumbler/QuestPackageManager-Rust + repo: QuestPackageManager/QPM.CLI - name: QPM Collapse run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust collapse + chmod +x ./QPM/qpm + ./QPM/qpm collapse - name: QPM Dependencies Cache id: cache-qpm-deps @@ -49,7 +49,7 @@ jobs: env: cache-name: cache-qpm-deps with: - path: /home/runner/.local/share/QPM-Rust/cache + path: /home/runner/.local/share/qpm/cache key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- @@ -58,16 +58,7 @@ jobs: - name: QPM Restore run: | - ./QPM/qpm-rust restore - - - name: List Post Restore - run: | - echo includes: - ls -la ${GITHUB_WORKSPACE}/extern/includes - echo libs: - ls -la ${GITHUB_WORKSPACE}/extern/libs - echo cache: - ls -la $HOME/.local/share/QPM-Rust/cache + ./QPM/qpm restore - name: Get Tag Version id: get_tag_version @@ -78,12 +69,12 @@ jobs: - name: QPM Edit Version run: | - ./QPM/qpm-rust package edit --version "${{ steps.get_tag_version.outputs.VERSION }}" + ./QPM/qpm package edit --version "${{ steps.get_tag_version.outputs.VERSION }}" - name: Build run: | cd ${GITHUB_WORKSPACE} - ./QPM/qpm-rust qmod build + ./QPM/qpm qmod build pwsh -Command ./build.ps1 - name: Create Qmod @@ -178,10 +169,10 @@ jobs: - name: Change QPM Package Info run: | - ./QPM/qpm-rust package edit-extra --branchName "version-${{ steps.get_tag_version.outputs.TAG }}" - ./QPM/qpm-rust package edit-extra --soLink "${{ steps.upload_release_asset.outputs.browser_download_url }}" - ./QPM/qpm-rust package edit-extra --debugSoLink "${{ steps.upload_debug_asset.outputs.browser_download_url }}" - ./QPM/qpm-rust package edit-extra --modLink "${{ steps.upload_qmod_asset.outputs.browser_download_url }}" + ./QPM/qpm package edit-extra --branchName "version-${{ steps.get_tag_version.outputs.TAG }}" + ./QPM/qpm package edit-extra --soLink "${{ steps.upload_release_asset.outputs.browser_download_url }}" + ./QPM/qpm package edit-extra --debugSoLink "${{ steps.upload_debug_asset.outputs.browser_download_url }}" + ./QPM/qpm package edit-extra --modLink "${{ steps.upload_qmod_asset.outputs.browser_download_url }}" - name: Commit Changed package info run: | @@ -202,4 +193,4 @@ jobs: git push --tags --force - name: QPM Publish - run: ./QPM/qpm-rust publish "${{secrets.QPM_KEY}}" + run: ./QPM/qpm publish "${{secrets.QPM_KEY}}" diff --git a/src/Hooks/WIPAutoReload.cpp b/src/Hooks/WIPAutoReload.cpp index 164cb5e..134abd7 100644 --- a/src/Hooks/WIPAutoReload.cpp +++ b/src/Hooks/WIPAutoReload.cpp @@ -1,18 +1,11 @@ -/*#include "beatsaber-hook/shared/utils/logging.hpp" +#include "beatsaber-hook/shared/utils/logging.hpp" #include "beatsaber-hook/shared/utils/hooking.hpp" -#include "hooks.hpp" #include "config.hpp" - -#include "Utils/SongUtils.hpp" -#include "Utils/DifficultyNameUtils.hpp" +#include "hooks.hpp" #include "GlobalNamespace/LevelCollectionViewController.hpp" -#include "GlobalNamespace/IBeatmapLevelPack.hpp" -#include "GlobalNamespace/SongPackMask.hpp" -#include "GlobalNamespace/SelectLevelCategoryViewController.hpp" -#include "UnityEngine/UI/Button.hpp" #include "UnityEngine/WaitForSecondsRealtime.hpp" #include "custom-types/shared/coroutine.hpp" @@ -23,51 +16,85 @@ #include #include -custom_types::Helpers::Coroutine wipPathReloader() { - std::unordered_map times; +std::filesystem::file_time_type +max_last_file_time(std::filesystem::path const &path, bool recursive) { + std::filesystem::file_time_type lastTime = + std::filesystem::last_write_time(path); - std::string wipPath = RuntimeSongLoader::API::GetCustomWIPLevelsPath(); + for (auto const &file : std::filesystem::directory_iterator(path)) { + lastTime = std::max(lastTime, file.last_write_time()); + } - while (true) { - try { - // LOG errors, then ignore - // TODO: Just crash if any errors - IL2CPP_CATCH_HANDLER( - if (!std::filesystem::exists(wipPath)) break; + if (recursive) { + for (auto const &file : std::filesystem::directory_iterator(path)) { + lastTime = std::max(lastTime, max_last_file_time(path, true)); + } + } - for (auto const &folder: std::filesystem::directory_iterator(wipPath)) { + return lastTime; +} - auto lastTimeIt = times.find(folder.path().c_str()); +custom_types::Helpers::Coroutine wipPathReloader() { + std::unordered_map times; - if (lastTimeIt == times.end()) { - times.emplace(folder.path().c_str(), folder.last_write_time()); - continue; - } + std::string wipPath = RuntimeSongLoader::API::GetCustomWIPLevelsPath(); - auto &lastTime = lastTimeIt->second; + std::filesystem::file_time_type oldLastTime = max_last_file_time(wipPath, true); - if (folder.last_write_time() <= lastTime) continue; + while (true) { - lastTime = folder.last_write_time(); - RuntimeSongLoader::API::RefreshSongs(); - break; - } - ) - } - // ignore - catch (std::exception const& e) {} - catch (...) {} + auto lastTime = max_last_file_time(wipPath, true); - co_yield UnityEngine::WaitForSecondsRealtime::New_ctor(4)->i_IEnumerator(); + // if a file was modified, refresh + if (lastTime >= oldLastTime) { + RuntimeSongLoader::API::RefreshSongs(); + oldLastTime = lastTime; } -} - -MAKE_AUTO_HOOK_MATCH(LevelCollectionViewController_DidActivate, &GlobalNamespace::LevelCollectionViewController::DidActivate, void, GlobalNamespace::LevelCollectionViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) -{ - LevelCollectionViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling); + // try { + // // LOG errors, then ignore + // // TODO: Just crash if any errors + // IL2CPP_CATCH_HANDLER( + // if (!std::filesystem::exists(wipPath)) break; + + // for (auto const &folder + // : std::filesystem::directory_iterator(wipPath)) { + // auto lastTimeIt = times.find(folder.path().c_str()); + + // if (lastTimeIt == times.end()) { + // times.emplace(folder.path().c_str(), + // max_last_file_time(folder.path(), true)); + // continue; + // } + + // auto &lastTime = lastTimeIt->second; + + // if (folder.last_write_time() <= lastTime) + // continue; + + // lastTime = max_last_file_time(folder.path(), true); + // RuntimeSongLoader::API::RefreshSongs(); + // break; + // }) + // } + // // ignore + // catch (std::exception const &e) { + // } catch (...) { + // } + + co_yield UnityEngine::WaitForSecondsRealtime::New_ctor(4)->i_IEnumerator(); + } +} - if (firstActivation) { - //self->StartCoroutine(custom_types::Helpers::new_coro(wipPathReloader)); - } -}*/ \ No newline at end of file +MAKE_AUTO_HOOK_MATCH( + LevelCollectionViewController_DidActivate, + &GlobalNamespace::LevelCollectionViewController::DidActivate, void, + GlobalNamespace::LevelCollectionViewController *self, bool firstActivation, + bool addedToHierarchy, bool screenSystemEnabling) { + LevelCollectionViewController_DidActivate( + self, firstActivation, addedToHierarchy, screenSystemEnabling); + + if (firstActivation) { + self->StartCoroutine(custom_types::Helpers::new_coro(wipPathReloader)); + } +} \ No newline at end of file