Skip to content

Commit 455b38e

Browse files
Merge pull request #7 from EnderdracheLP/dev
Fixed problems with Multiplayer Lobbys, and Battery Percentage plus tweaked code a little
2 parents 201d5c7 + 5c173c7 commit 455b38e

File tree

5 files changed

+56
-7
lines changed

5 files changed

+56
-7
lines changed

Android.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ LOCAL_SHARED_LIBRARIES += codegen_0_6_2
6565
LOCAL_SHARED_LIBRARIES += questui
6666
LOCAL_SHARED_LIBRARIES += custom-types
6767
LOCAL_LDLIBS += -llog
68-
LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"clockmod"' -DVERSION='"0.1.3"' -I'./shared' -I'./extern' -isystem'extern/codegen/include'
68+
LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"clockmod"' -DVERSION='"1.3.0"' -I'./shared' -I'./extern' -isystem'extern/codegen/include'
6969
LOCAL_CPPFLAGS += -std=c++2a
7070
LOCAL_C_INCLUDES += ./include ./src
7171
include $(BUILD_SHARED_LIBRARY)

bmbfmod.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "clockmod",
33
"name": "Clock Mod",
4-
"version": "0.1.3",
4+
"version": "1.3.0",
55
"author": "BoopetyDoopety, EnderdracheLP",
66
"description": [
77
"Displays the time in game."

debugstart.bat

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"C:\Users\%username%\AppData\Roaming\SideQuest\platform-tools\adb.exe" shell am force-stop com.beatgames.beatsaber
2+
3+
powershell ./build.ps1
4+
5+
"C:\Users\%username%\AppData\Roaming\SideQuest\platform-tools\adb.exe" push libs/arm64-v8a/libclockmod.so /sdcard/Android/data/com.beatgames.beatsaber/files/mods/libclockmod.so
6+
7+
"C:\Users\%username%\AppData\Roaming\SideQuest\platform-tools\adb.exe" shell am start com.beatgames.beatsaber/com.unity3d.player.UnityPlayerActivity
8+
echo Done

src/ClockUpdater.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ void ClockMod::ClockUpdater::Update() {
4848
if (getConfig().config["BattToggle"].GetBool() == true) {
4949
float batterylvl = GlobalNamespace::OVRPlugin::OVRP_1_1_0::ovrp_GetSystemBatteryLevel();
5050
batterylvl = batterylvl * 100;
51+
std::string batterylevel = string_format("%g", batterylvl);
5152
std::string tandb = timestr;
5253
tandb += " - ";
53-
std::string batterylevel = std::to_string(batterylvl);
54-
batterylevel.erase(batterylevel.find_last_not_of('0') + 1, std::string::npos);
55-
batterylevel.erase(batterylevel.find_last_not_of('.') + 1, std::string::npos);
54+
// std::string batterylevel = std::to_string(batterylvl);
55+
// batterylevel.erase(batterylevel.find_last_not_of('0') + 1, std::string::npos);
56+
// batterylevel.erase(batterylevel.find_last_not_of('.') + 1, std::string::npos);
5657
tandb += batterylevel;
5758
tandb += "%";
5859

src/main.cpp

+42-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#include "main.hpp"
22

33

4+
45
#include "GlobalNamespace/MainMenuViewController.hpp"
56
#include "GlobalNamespace/AudioTimeSyncController.hpp"
67
#include "GlobalNamespace/PauseMenuManager.hpp"
78
#include "GlobalNamespace/SoloFreePlayFlowCoordinator.hpp"
89
#include "GlobalNamespace/MultiplayerLobbyController.hpp"
10+
#include "GlobalNamespace/HostLobbySetupViewController.hpp"
11+
#include "GlobalNamespace/ClientLobbySetupViewController.hpp"
12+
#include "GlobalNamespace/QuickPlaySetupViewController.hpp"
913
using namespace GlobalNamespace;
1014

1115
#include "TMPro/TextMeshPro.hpp"
@@ -134,13 +138,45 @@ MAKE_HOOK_OFFSETLESS(PauseMenuManager_StartResumeAnimation, void, PauseMenuManag
134138
}
135139
}
136140

141+
// Multiplayer Lobby Specific Code
142+
137143
MAKE_HOOK_OFFSETLESS(MultiplayerLobbyController_ActivateMultiplayerLobby, void, MultiplayerLobbyController* self) {
138144
MultiplayerLobbyController_ActivateMultiplayerLobby(self);
139145

140-
layout->get_transform()->set_position(UnityEngine::Vector3(0, -0.45, 1.62));
146+
// layout->get_transform()->set_position(UnityEngine::Vector3(0, -0.05, 1.62));
147+
// layout->get_transform()->set_localScale(UnityEngine::Vector3(0.35, 0.35, 0.35));
148+
}
149+
150+
MAKE_HOOK_OFFSETLESS(QuickPlaySetupViewController_DidActivate, void, QuickPlaySetupViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
151+
QuickPlaySetupViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling);
152+
153+
auto MLobbyVCPosY = UnityEngine::Object::FindObjectOfType<HostLobbySetupViewController*>()->get_transform()->get_position().y;
154+
MLobbyVCPosY = MLobbyVCPosY - 1;
155+
logger().debug("%g", MLobbyVCPosY);
156+
layout->get_transform()->set_position(UnityEngine::Vector3(0, MLobbyVCPosY, 1.62));
157+
layout->get_transform()->set_localScale(UnityEngine::Vector3(0.35, 0.35, 0.35));
158+
}
159+
160+
MAKE_HOOK_OFFSETLESS(ClientLobbySetupViewController_DidActivate, void, ClientLobbySetupViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
161+
ClientLobbySetupViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling);
162+
163+
auto MLobbyVCPosY = UnityEngine::Object::FindObjectOfType<HostLobbySetupViewController*>()->get_transform()->get_position().y;
164+
MLobbyVCPosY = MLobbyVCPosY - 1;
165+
logger().debug("%g", MLobbyVCPosY);
166+
layout->get_transform()->set_position(UnityEngine::Vector3(0, MLobbyVCPosY, 1.62));
141167
layout->get_transform()->set_localScale(UnityEngine::Vector3(0.35, 0.35, 0.35));
142168
}
143169

170+
MAKE_HOOK_OFFSETLESS(HostLobbySetupViewController_DidActivate, void, HostLobbySetupViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
171+
HostLobbySetupViewController_DidActivate(self, firstActivation, addedToHierarchy, screenSystemEnabling);
172+
173+
auto MLobbyVCPosY = UnityEngine::Object::FindObjectOfType<HostLobbySetupViewController*>()->get_transform()->get_position().y;
174+
MLobbyVCPosY = MLobbyVCPosY - 1;
175+
logger().debug("%g", MLobbyVCPosY);
176+
layout->get_transform()->set_position(UnityEngine::Vector3(0, MLobbyVCPosY, 1.62));
177+
layout->get_transform()->set_localScale(UnityEngine::Vector3(0.35, 0.35, 0.35));
178+
}
179+
144180
MAKE_HOOK_OFFSETLESS(MultiplayerLobbyController_DeactivateMultiplayerLobby, void, MultiplayerLobbyController* self) {
145181
MultiplayerLobbyController_DeactivateMultiplayerLobby(self);
146182

@@ -210,7 +246,11 @@ extern "C" void load() {
210246
INSTALL_HOOK_OFFSETLESS(hookLogger, SoloFreePlayFlowCoordinator_SinglePlayerLevelSelectionFlowCoordinatorDidActivate, il2cpp_utils::FindMethodUnsafe("", "SoloFreePlayFlowCoordinator", "SinglePlayerLevelSelectionFlowCoordinatorDidActivate", 2));
211247
INSTALL_HOOK_OFFSETLESS(hookLogger, PauseMenuManager_ShowMenu, il2cpp_utils::FindMethodUnsafe("", "PauseMenuManager", "ShowMenu", 0));
212248
INSTALL_HOOK_OFFSETLESS(hookLogger, PauseMenuManager_StartResumeAnimation, il2cpp_utils::FindMethodUnsafe("", "PauseMenuManager", "StartResumeAnimation", 0));
213-
INSTALL_HOOK_OFFSETLESS(hookLogger, MultiplayerLobbyController_ActivateMultiplayerLobby, il2cpp_utils::FindMethodUnsafe("", "MultiplayerLobbyController", "ActivateMultiplayerLobby", 0));
249+
// INSTALL_HOOK_OFFSETLESS(hookLogger, MultiplayerLobbyController_ActivateMultiplayerLobby, il2cpp_utils::FindMethodUnsafe("", "MultiplayerLobbyController", "ActivateMultiplayerLobby", 0));
250+
// Multiplayer specific Hooks
251+
INSTALL_HOOK_OFFSETLESS(hookLogger, HostLobbySetupViewController_DidActivate, il2cpp_utils::FindMethodUnsafe("", "HostLobbySetupViewController", "DidActivate", 3));
252+
INSTALL_HOOK_OFFSETLESS(hookLogger, ClientLobbySetupViewController_DidActivate, il2cpp_utils::FindMethodUnsafe("", "ClientLobbySetupViewController", "DidActivate", 3));
253+
INSTALL_HOOK_OFFSETLESS(hookLogger, QuickPlaySetupViewController_DidActivate, il2cpp_utils::FindMethodUnsafe("", "QuickPlaySetupViewController", "DidActivate", 3));
214254
INSTALL_HOOK_OFFSETLESS(hookLogger, MultiplayerLobbyController_DeactivateMultiplayerLobby, il2cpp_utils::FindMethodUnsafe("", "MultiplayerLobbyController", "DeactivateMultiplayerLobby", 0));
215255

216256
logger().info("Installed all ClockMod hooks!");

0 commit comments

Comments
 (0)