diff --git a/.github/workflows/buildMod.yml b/.github/workflows/buildMod.yml index 8b2afcd..c448123 100644 --- a/.github/workflows/buildMod.yml +++ b/.github/workflows/buildMod.yml @@ -2,12 +2,14 @@ name: NDK build on: push: - branches: [ main ] + branches: [ main, dev ] pull_request: - branches: [ main ] + branches: [ main, dev ] jobs: build: + env: + module_id: clockmod runs-on: ubuntu-latest steps: @@ -18,15 +20,32 @@ jobs: lfs: true - name: Install Powershell run: sudo apt-get install -y powershell - - - name: Setup NDK - id: setup-ndk - uses: nttld/setup-ndk@v1.0.2 + + - name: Cache Android NDK + id: cache-ndk + uses: actions/cache@v2 + env: + cache-name: cache-ndk + ndkname: android-ndk-r21 with: - ndk-version: r21 + path: ndk + key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} + + - name: Install Android NDK + if: steps.cache-ndk.outputs.cache-hit != 'true' + env: + ndkname: android-ndk-r21 + run: | + wget -q -O ndk.zip https://dl.google.com/android/repository/${ndkname}-linux-x86_64.zip + unzip -q ndk.zip + mv ${ndkname} ndk - name: Create ndkpath.txt - run: echo ${{ steps.setup-ndk.outputs.ndk-path }} > ${GITHUB_WORKSPACE}/ndkpath.txt + run: | + cd ndk + pwd > ${GITHUB_WORKSPACE}/ndkpath.txt # - name: Cache QPM # id: cache-qpm @@ -76,7 +95,7 @@ jobs: id: libname run: | cd ./libs/arm64-v8a/ - pattern="libclockmod.so" + pattern="lib${module_id}*.so" files=( $pattern ) echo ::set-output name=NAME::"${files[0]}" - name: Upload non-debug artifact diff --git a/.gitignore b/.gitignore index d09a514..ae8880a 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,9 @@ !.vscode/c_cpp_properties.json !.vscode/tasks.json +# Visual Stuido Stuff +.vs/ + # NDK stuff out/ [Ll]ib/ diff --git a/Android.mk b/Android.mk index 99f8d96..a0d490b 100644 --- a/Android.mk +++ b/Android.mk @@ -35,7 +35,7 @@ LOCAL_MODULE := codegen_0_6_2 LOCAL_EXPORT_C_INCLUDES := extern/codegen LOCAL_SRC_FILES := extern/libcodegen_0_6_2.so include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: questui - version: 0.4.3 +# Creating prebuilt for dependency: questui - version: 0.4.4 include $(CLEAR_VARS) LOCAL_MODULE := questui LOCAL_EXPORT_C_INCLUDES := extern/questui @@ -65,7 +65,7 @@ LOCAL_SHARED_LIBRARIES += codegen_0_6_2 LOCAL_SHARED_LIBRARIES += questui LOCAL_SHARED_LIBRARIES += custom-types LOCAL_LDLIBS += -llog -LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"clockmod"' -DVERSION='"0.1.2"' -I'./shared' -I'./extern' -isystem'extern/codegen/include' +LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"clockmod"' -DVERSION='"0.1.3"' -I'./shared' -I'./extern' -isystem'extern/codegen/include' LOCAL_CPPFLAGS += -std=c++2a LOCAL_C_INCLUDES += ./include ./src include $(BUILD_SHARED_LIBRARY) diff --git a/Cover.png b/Cover.png index ae60f83..3ca0119 100644 Binary files a/Cover.png and b/Cover.png differ diff --git a/bmbfmod.json b/bmbfmod.json index 1918a34..1512b9c 100644 --- a/bmbfmod.json +++ b/bmbfmod.json @@ -1,14 +1,14 @@ { "id": "clockmod", "name": "Clock Mod", - "version": "0.1.2", + "version": "0.1.3", "author": "BoopetyDoopety, EnderdracheLP", "description": [ "Displays the time in game." ], "coverImageFilename": "Cover.png", "icon": "Cover.png", - "category": "Gameplay", + "category": "Other", "gameVersion": "1.13.2", "platform": "Quest", "components": [ diff --git a/buildBMBF.ps1 b/buildBMBF.ps1 index 02e1d3f..07f370d 100644 --- a/buildBMBF.ps1 +++ b/buildBMBF.ps1 @@ -1,6 +1,7 @@ -# Builds a .zip file for loading with BMBF -& $PSScriptRoot/build.ps1 - -if ($?) { - Compress-Archive -Path "./libs/arm64-v8a/libclockmod.so", "./libs/arm64-v8a/libbeatsaber-hook_1_0_12.so", "./bmbfmod.json","./Cover.png" -DestinationPath "./Clockmod.zip" -Update -} +# Builds a .zip file for loading with BMBF +& $PSScriptRoot/build.ps1 + +if ($?) { + Compress-Archive -Path "./libs/arm64-v8a/libclockmod.so", "./libs/arm64-v8a/libbeatsaber-hook_1_0_12.so", "./bmbfmod.json","./Cover.png" -DestinationPath "./Clockmod.zip" -Update +} +echo "Task Completed" diff --git a/buildBMBFDebug.ps1 b/buildBMBFDebug.ps1 new file mode 100644 index 0000000..6844e19 --- /dev/null +++ b/buildBMBFDebug.ps1 @@ -0,0 +1,7 @@ +# Builds a .zip file for loading with BMBF +& $PSScriptRoot/build.ps1 + +if ($?) { + Compress-Archive -Path "./obj/local/arm64-v8a/libclockmod.so", "./obj/local/arm64-v8a/libbeatsaber-hook_1_0_12.so", "./bmbfmod.json","./Cover.png" -DestinationPath "./ClockmodDebug.zip" -Update +} +echo "Task Completed" diff --git a/include/main.hpp b/include/main.hpp index db7ebec..7a6825a 100644 --- a/include/main.hpp +++ b/include/main.hpp @@ -11,4 +11,4 @@ // Define these functions here so that we can easily read configuration and log information from other files Configuration& getConfig(); -const Logger& getLogger(); \ No newline at end of file +Logger& logger(); \ No newline at end of file diff --git a/qpm.json b/qpm.json index 4813c0d..7a9ced0 100644 --- a/qpm.json +++ b/qpm.json @@ -4,7 +4,7 @@ "info": { "name": "CLock Mod", "id": "clockmod", - "version": "0.1.2", + "version": "0.1.3", "url": null, "additionalData": {} }, diff --git a/src/ClockUpdater.cpp b/src/ClockUpdater.cpp index b300b73..0299729 100644 --- a/src/ClockUpdater.cpp +++ b/src/ClockUpdater.cpp @@ -5,6 +5,7 @@ #include "UnityEngine/GameObject.hpp" #include "TMPro/TextMeshProUGUI.hpp" #include +#include "GlobalNamespace/OVRPlugin_OVRP_1_1_0.hpp" using namespace UnityEngine; using namespace TMPro; @@ -29,7 +30,7 @@ void ClockMod::ClockUpdater::Update() { strftime(timestr, 20, "%H:%M", timeinfo); } } - else { // If set to show 12 Hour Format + else { // If set to show 24 Hour Format if (getConfig().config["SecToggle"].GetBool() == true) { //Check if seconds should be shown strftime(timestr, 20, "%l:%M:%S %p", timeinfo); } @@ -37,6 +38,27 @@ void ClockMod::ClockUpdater::Update() { strftime(timestr, 20, "%l:%M %p", timeinfo); }; } + // Sets the fontsize + float fontsize = getConfig().config["FontSize"].GetFloat(); auto text = get_gameObject()->GetComponent(); - text->set_text(il2cpp_utils::createcsstr(timestr)); -} + text->set_fontSize(fontsize); + // Sets position +// text->get_transform()->set_position(UnityEngine::Vector3(0, 1, 2.6)); + // Get current Battery Level + if (getConfig().config["BattToggle"].GetBool() == true) { + float batterylvl = GlobalNamespace::OVRPlugin::OVRP_1_1_0::ovrp_GetSystemBatteryLevel(); + batterylvl = batterylvl * 100; + std::string tandb = timestr; + tandb += " - "; + std::string batterylevel = std::to_string(batterylvl); + batterylevel.erase(batterylevel.find_last_not_of('0') + 1, std::string::npos); + batterylevel.erase(batterylevel.find_last_not_of('.') + 1, std::string::npos); + tandb += batterylevel; + tandb += "%"; + + text->set_text(il2cpp_utils::createcsstr(tandb)); + } + else { + text->set_text(il2cpp_utils::createcsstr(timestr)); + } +} \ No newline at end of file diff --git a/src/ClockViewContoller.cpp b/src/ClockViewContoller.cpp index 2ee6adf..45b7a0c 100644 --- a/src/ClockViewContoller.cpp +++ b/src/ClockViewContoller.cpp @@ -23,33 +23,73 @@ void FormatToggle(ClockMod::ClockViewController* parent, bool newValue) { void SecToggle(ClockMod::ClockViewController* parent, bool newValue) { getConfig().config["SecToggle"].SetBool(newValue); } - +void SetFontSize(ClockMod::ClockViewController* parent, float newValue) { +getConfig().config["FontSize"].SetFloat(newValue); +} +void BattToggle(ClockMod::ClockViewController* parent, bool newValue) { + getConfig().config["BattToggle"].SetBool(newValue); +} +//void SetClockXOffset(ClockMod::ClockViewController* parent, float newValue) { +//getConfig().config["ClockXOffset"].SetFloat(newValue); +//} +//void SetClockYOffset(ClockMod::ClockViewController* parent, float newValue) { +//getConfig().config["ClockYOffset"].SetFloat(newValue); +//} +//void SetClockZOffset(ClockMod::ClockViewController* parent, float newValue) { +//getConfig().config["ClockZOffset"].SetFloat(newValue); +//} void ClockMod::ClockViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { if (firstActivation) { get_gameObject()->AddComponent(); GameObject* container = QuestUI::BeatSaberUI::CreateScrollableSettingsContainer(get_transform()); // Show Clock during Song Play - UnityEngine::Events::UnityAction_1* onInSongSettingChange = il2cpp_utils::MakeDelegate*>( + auto onInSongSettingChange = il2cpp_utils::MakeDelegate*>( classof(UnityEngine::Events::UnityAction_1*), this, InSongToggle ); UnityEngine::UI::Toggle* InsongToggleObject = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Show During Song", getConfig().config["insong"].GetBool(), onInSongSettingChange); - QuestUI::BeatSaberUI::AddHoverHint(InsongToggleObject->get_gameObject(), "Whether or not to show the Clock while playing a Beatmap."); + QuestUI::BeatSaberUI::AddHoverHint(InsongToggleObject->get_gameObject(), "If the Clock should be shown while playing a Beatmap."); // Change format 24/12 - UnityEngine::Events::UnityAction_1* onFormatSettingChange = il2cpp_utils::MakeDelegate*>( + auto onFormatSettingChange = il2cpp_utils::MakeDelegate*>( classof(UnityEngine::Events::UnityAction_1*), this, FormatToggle ); UnityEngine::UI::Toggle* FormatToggleObject = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "24/12 Toggle", getConfig().config["12Toggle"].GetBool(), onFormatSettingChange); - QuestUI::BeatSaberUI::AddHoverHint(FormatToggleObject->get_gameObject(), "Whether to show time in 24 Hour or 12 Hour format."); + QuestUI::BeatSaberUI::AddHoverHint(FormatToggleObject->get_gameObject(), "If time should be in 12 or 24 Hour format."); // Show Seconds - UnityEngine::Events::UnityAction_1* onSecSettingChange = il2cpp_utils::MakeDelegate*>( + auto onSecSettingChange = il2cpp_utils::MakeDelegate*>( classof(UnityEngine::Events::UnityAction_1*), this, SecToggle ); UnityEngine::UI::Toggle* SecToggleObject = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Show Seconds", getConfig().config["SecToggle"].GetBool(), onSecSettingChange); - QuestUI::BeatSaberUI::AddHoverHint(SecToggleObject->get_gameObject(), "Whether or not to show seconds."); + QuestUI::BeatSaberUI::AddHoverHint(SecToggleObject->get_gameObject(), "If Seconds should be displayed."); + // Change Size + auto onFontSizeChange = il2cpp_utils::MakeDelegate*>( + classof(UnityEngine::Events::UnityAction_1*), this, SetFontSize); // Decimal places Value Steps Min Value Max Value + QuestUI::IncrementSetting* FontIncrementObject = QuestUI::BeatSaberUI::CreateIncrementSetting(container->get_transform(), "Font Size", 1, 0.1, getConfig().config["FontSize"].GetFloat(), 1.0f, 5.0f, onFontSizeChange); + QuestUI::BeatSaberUI::AddHoverHint(FontIncrementObject->get_gameObject(), "Changes the Font Size of the Clock (Default: 4)"); + // Show Battery Percentage + auto onBattSettingChange = il2cpp_utils::MakeDelegate*>( + classof(UnityEngine::Events::UnityAction_1*), this, BattToggle + ); + UnityEngine::UI::Toggle* BattToggleObject = QuestUI::BeatSaberUI::CreateToggle(container->get_transform(), "Show Battery Percentage", getConfig().config["BattToggle"].GetBool(), onBattSettingChange); + QuestUI::BeatSaberUI::AddHoverHint(BattToggleObject->get_gameObject(), "Displays Battery percentage next to the clock."); + // Change Pos X +// auto onClockXOffsetChange = il2cpp_utils::MakeDelegate*>( +// classof(UnityEngine::Events::UnityAction_1*), this, SetClockXOffset); // Decimal places Value Steps Min Value Max Value +// QuestUI::IncrementSetting* ClockXIncrementObject = QuestUI::BeatSaberUI::CreateIncrementSetting(container->get_transform(), "Clock X Offset", 1, 0.1, getConfig().config["ClockXOffset"].GetFloat(), -10.0f, 10.0f, onClockXOffsetChange); +// QuestUI::BeatSaberUI::AddHoverHint(ClockXIncrementObject->get_gameObject(), "Offsets the X Position of the Clock"); + // Change Pos Y +// auto onClockYOffsetChange = il2cpp_utils::MakeDelegate*>( +// classof(UnityEngine::Events::UnityAction_1*), this, SetClockYOffset); // Decimal places Value Steps Min Value Max Value +// QuestUI::IncrementSetting* ClockYIncrementObject = QuestUI::BeatSaberUI::CreateIncrementSetting(container->get_transform(), "Clock Y Offset", 1, 0.1, getConfig().config["ClockYOffset"].GetFloat(), -10.0f, 10.0f, onClockYOffsetChange); +// QuestUI::BeatSaberUI::AddHoverHint(ClockYIncrementObject->get_gameObject(), "Offsets the Y Position of the Clock"); + // Change Pos Z +// auto onClockZOffsetChange = il2cpp_utils::MakeDelegate*>( +// classof(UnityEngine::Events::UnityAction_1*), this, SetClockZOffset); // Decimal places Value Steps Min Value Max Value +// QuestUI::IncrementSetting* ClockZIncrementObject = QuestUI::BeatSaberUI::CreateIncrementSetting(container->get_transform(), "Clock Z Offset", 1, 0.1, getConfig().config["ClockZOffset"].GetFloat(), -10.0f, 10.0f, onClockZOffsetChange); +// QuestUI::BeatSaberUI::AddHoverHint(ClockZIncrementObject->get_gameObject(), "Offsets the Z Position of the Clock"); } } // Write config void ClockMod::ClockViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling) { getConfig().Write(); -} +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 5fe9650..c9a82ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,6 +11,7 @@ using namespace GlobalNamespace; #include "TMPro/TextMeshPro.hpp" #include "TMPro/TextMeshProUGUI.hpp" #include "TMPro/TextAlignmentOptions.hpp" +#include "TMPro/TMP_Text.hpp" using namespace TMPro; #include "UnityEngine/Canvas.hpp" @@ -22,6 +23,7 @@ using namespace TMPro; #include "UnityEngine/RenderMode.hpp" #include "UnityEngine/UI/CanvasScaler.hpp" #include "UnityEngine/CanvasRenderer.hpp" +#include "UnityEngine/MonoBehaviour.hpp" using namespace UnityEngine; using namespace UnityEngine::UI; @@ -67,7 +69,7 @@ MAKE_HOOK_OFFSETLESS(MainMenuViewController_DidActivate, void, MainMenuViewContr auto canvas_renderer = canvas_object->AddComponent(); canvas_object->AddComponent(); - canvas_object->get_transform()->set_position(UnityEngine::Vector3(0, 0.5, 2.6)); + canvas_object->get_transform()->set_position(UnityEngine::Vector3(0, 0.5, 3)); canvas_object->get_transform()->set_localScale(UnityEngine::Vector3(0.1, 0.1, 0.1)); Object::DontDestroyOnLoad(canvas_object); @@ -79,15 +81,23 @@ MAKE_HOOK_OFFSETLESS(MainMenuViewController_DidActivate, void, MainMenuViewContr layout->GetComponent()->set_minWidth(7); layout->GetComponent()->set_minHeight(80); +// layout->set_childAlignment(TMPro::TextAlignmentOptions::Center, TMPro::TMP_Text::m_lineSpacing(0)); layout->set_childAlignment(TMPro::TextAlignmentOptions::Center); - layout->get_transform()->set_position(UnityEngine::Vector3(0, -2.20, 3)); - clock_text->set_fontSize(4); - clock_text->get_transform()->set_position(UnityEngine::Vector3(0, 1, 2.6)); +// layout->set_(TMPro::TMP_Text::m_lineSpacing(0)) + layout->get_transform()->set_position(UnityEngine::Vector3(0, -1.7, 3.85)); +// float fontsize = getConfig().config["FontSize"].GetFloat(); + + clock_text->get_transform()->set_position(UnityEngine::Vector3(0, 0.5, 3.85)); clock_text->get_gameObject()->AddComponent(); } canvas->get_gameObject()->SetActive(true); } +//void ClockMod::ClockViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { +// UnityEngine::MonoBehaviour::Update(); +// clock_text->get_transform()->set_position(UnityEngine::Vector3(0, 1, 12.6)); +//} + MAKE_HOOK_OFFSETLESS(AudioTimeSyncController_StartSong, void, AudioTimeSyncController* self, float startTimeOffset) { AudioTimeSyncController_StartSong(self, startTimeOffset); @@ -127,13 +137,15 @@ MAKE_HOOK_OFFSETLESS(PauseMenuManager_StartResumeAnimation, void, PauseMenuManag MAKE_HOOK_OFFSETLESS(MultiplayerLobbyController_ActivateMultiplayerLobby, void, MultiplayerLobbyController* self) { MultiplayerLobbyController_ActivateMultiplayerLobby(self); - layout->get_transform()->set_position(UnityEngine::Vector3(0, -1.9, 3)); + layout->get_transform()->set_position(UnityEngine::Vector3(0, -0.45, 1.62)); + layout->get_transform()->set_localScale(UnityEngine::Vector3(0.35, 0.35, 0.35)); } MAKE_HOOK_OFFSETLESS(MultiplayerLobbyController_DeactivateMultiplayerLobby, void, MultiplayerLobbyController* self) { MultiplayerLobbyController_DeactivateMultiplayerLobby(self); - layout->get_transform()->set_position(UnityEngine::Vector3(0, -2.2, 3)); + layout->get_transform()->set_position(UnityEngine::Vector3(0, -1.7, 3.85)); + layout->get_transform()->set_localScale(UnityEngine::Vector3(1.0, 1.0, 1.0)); } // Called at the early stages of game loading @@ -147,7 +159,7 @@ extern "C" void setup(ModInfo & info) { rapidjson::Document::AllocatorType& allocator = getConfig().config.GetAllocator(); if (!getConfig().config.HasMember("insong")) { - getConfig().config.AddMember("insong", rapidjson::Value(0).SetBool(false), allocator); + getConfig().config.AddMember("insong", rapidjson::Value(0).SetBool(true), allocator); getConfig().Write(); } if (!getConfig().config.HasMember("12Toggle")) { @@ -158,6 +170,26 @@ extern "C" void setup(ModInfo & info) { getConfig().config.AddMember("SecToggle", rapidjson::Value(0).SetBool(false), allocator); getConfig().Write(); } + if (!getConfig().config.HasMember("FontSize")) { + getConfig().config.AddMember("FontSize", rapidjson::Value(0).SetFloat(4), allocator); + getConfig().Write(); + } + if (!getConfig().config.HasMember("BattToggle")) { + getConfig().config.AddMember("BattToggle", rapidjson::Value(0).SetBool(false), allocator); + getConfig().Write(); + } +// if (!getConfig().config.HasMember("ClockXOffset")) { +// getConfig().config.AddMember("ClockXOffset", rapidjson::Value(0).SetFloat(0), allocator); +// getConfig().Write(); +// } +// if (!getConfig().config.HasMember("ClockYOffset")) { +// getConfig().config.AddMember("ClockYOffset", rapidjson::Value(0).SetFloat(0), allocator); +// getConfig().Write(); +// } +// if (!getConfig().config.HasMember("ClockZOffset")) { +// getConfig().config.AddMember("ClockZOffset", rapidjson::Value(0).SetFloat(0), allocator); +// getConfig().Write(); +// } } // Called later on in the game loading - a good time to install function hooks