Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions .github/workflows/build-ndk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ 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
uses: actions/cache@v2
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 }}-
Expand All @@ -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
Expand Down
35 changes: 13 additions & 22 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ 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
uses: actions/cache@v2
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 }}-
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand All @@ -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}}"
117 changes: 72 additions & 45 deletions src/Hooks/WIPAutoReload.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -23,51 +16,85 @@
#include <filesystem>
#include <unordered_map>

custom_types::Helpers::Coroutine wipPathReloader() {
std::unordered_map<std::string_view, std::filesystem::file_time_type> 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<std::string_view, std::filesystem::file_time_type> 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));
}
}*/
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));
}
}