Skip to content

Commit 613bc17

Browse files
committed
Stuff is working now, added support for 360/90 Map, added option to have clock either at top or bottom, except in MP Lobbys, tweaked the position generally a bit and have the battery indicator change color depending on it's current charge.
1 parent 732d0ca commit 613bc17

9 files changed

+381
-102
lines changed

copy.ps1

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ if ($?) {
66
adb shell am start com.beatgames.beatsaber/com.unity3d.player.UnityPlayerActivity
77
if ($args[0] -eq "--log") {
88
$timestamp = Get-Date -Format "MM-dd HH:mm:ss.fff"
9-
adb logcat -T "$timestamp" main-modloader:W QuestHook[clockmod`|v1.4.0]:* AndroidRuntime:E *:S
9+
adb logcat -T "$timestamp" main-modloader:W QuestHook[clockmod`|v1.4.0]:* AndroidRuntime:E *:S QuestHook[UtilsLogger`|v1.0.12]:E
10+
}
11+
if ($args[0] -eq "--debug") {
12+
$timestamp = Get-Date -Format "MM-dd HH:mm:ss.fff"
13+
adb logcat -T "$timestamp" main-modloader:W QuestHook[clockmod`|v1.4.0]:* AndroidRuntime:E *:S QuestHook[UtilsLogger`|v1.0.12]:*
1014
}
1115
}
1216
}

include/ClockModConfig.hpp

+8-13
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,23 @@ DECLARE_CONFIG(ModConfig,
1010
DECLARE_VALUE(RainbowClock, bool, "Rainbowify it", false);
1111
DECLARE_VALUE(FontSize, double, "Font Size", 3.5);
1212

13-
DECLARE_VALUE(ClockXOffset, double, "Clock X Offset", 0);
14-
DECLARE_VALUE(ClockYOffset, double, "Clock Y Offset", 0);
15-
DECLARE_VALUE(ClockZOffset, double, "Clock Z Offset", 0);
13+
// DECLARE_VALUE(ClockXOffset, double, "Clock X Offset", 0);
14+
// DECLARE_VALUE(ClockYOffset, double, "Clock Y Offset", 0);
15+
// DECLARE_VALUE(ClockZOffset, double, "Clock Z Offset", 0);
16+
DECLARE_VALUE(ClockPosition, bool, "In-Menu Clock Position (Top/Bottom)", false);
1617
DECLARE_VALUE(ClockColor, UnityEngine::Color, "Clock Color", UnityEngine::Color(1.0f, 1.0f, 1.0f, 1.0f));
1718

18-
DECLARE_VALUE(ClockX, float, "Clock X Pos", 0);
19-
DECLARE_VALUE(ClockY, float, "Clock Y Pos", -1.7);
20-
DECLARE_VALUE(ClockZ, float, "Clock Z Pos", 3.85);
21-
2219
INIT_FUNCTION(
2320
INIT_VALUE(InSong);
2421
INIT_VALUE(TwelveToggle);
2522
INIT_VALUE(SecToggle);
2623
INIT_VALUE(BattToggle);
2724
INIT_VALUE(RainbowClock);
2825
INIT_VALUE(FontSize);
29-
INIT_VALUE(ClockXOffset);
30-
INIT_VALUE(ClockYOffset);
31-
INIT_VALUE(ClockZOffset);
26+
// INIT_VALUE(ClockXOffset);
27+
// INIT_VALUE(ClockYOffset);
28+
// INIT_VALUE(ClockZOffset);
29+
INIT_VALUE(ClockPosition);
3230
INIT_VALUE(ClockColor);
33-
INIT_VALUE(ClockX);
34-
INIT_VALUE(ClockY);
35-
INIT_VALUE(ClockZ);
3631
)
3732
)

include/main.hpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@
88
#include "beatsaber-hook/shared/utils/logging.hpp"
99
#include "beatsaber-hook/shared/config/config-utils.hpp"
1010
#include "beatsaber-hook/shared/utils/il2cpp-functions.hpp"
11+
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
1112

1213
// Define these functions here so that we can easily read configuration and log information from other files
1314
Logger& logger();
1415

16+
// Defining values here, so I can use them wherever the fuck I want to.
1517
struct Config_t {
1618
bool InMPLobby = false;
17-
// other values
19+
float ClockY = -1.7;
20+
float ClockZ = 3.85;
21+
bool IsInSong = false;
22+
// bool InSettings = false;
23+
bool InRotationMap = false;
24+
bool noTextAndHUD = false;
1825
};
1926
extern Config_t Config;
2027

shared/ClockRotationUpdater.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
#include "custom-types/shared/macros.hpp"
3+
#include "UnityEngine/MonoBehaviour.hpp"
4+
5+
DECLARE_CLASS_CODEGEN(ClockMod, ClockRotationUpdater, UnityEngine::MonoBehaviour,
6+
7+
DECLARE_METHOD(void, Update);
8+
9+
REGISTER_FUNCTION(ClockRotationUpdater,
10+
REGISTER_METHOD(Update);
11+
)
12+
)

shared/ClockViewController.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
DECLARE_CLASS_CODEGEN(ClockMod, ClockViewController, HMUI::ViewController,
88

99
DECLARE_OVERRIDE_METHOD(void, DidActivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidActivate", 3), bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
10+
// DECLARE_OVERRIDE_METHOD(void, DidDeactivate, il2cpp_utils::FindMethodUnsafe("HMUI", "ViewController", "DidDeactivate", 2), bool removedFromHierarchy, bool systemScreenDisabling);
1011

1112
REGISTER_FUNCTION(ClockViewController,
1213
REGISTER_METHOD(DidActivate);
14+
// REGISTER_METHOD(DidDeactivate);
1315
)
1416

1517
);

src/ClockRotationUpdater.cpp

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "main.hpp"
2+
#include "ClockRotationUpdater.hpp" // Part of making this a class
3+
#include "ClockModConfig.hpp" // Just the config
4+
using namespace ClockMod;
5+
6+
#include "GlobalNamespace/CoreGameHUDController.hpp" // Just take the damn rotation from CoreGameHUDController, and it'll rotate smooth as fuck.
7+
#include "GlobalNamespace/PlayerDataModel.hpp" // For checking if noTextandHUDs is enabled
8+
#include "GlobalNamespace/PlayerData.hpp" // For checking if noTextandHUDs is enabled
9+
#include "GlobalNamespace/PlayerSpecificSettings.hpp" // For checking if noTextandHUDs is enabled
10+
using namespace GlobalNamespace;
11+
12+
// Needed for the Transform stuff.
13+
#include "UnityEngine/Quaternion.hpp"
14+
#include "UnityEngine/GameObject.hpp"
15+
#include "UnityEngine/Transform.hpp"
16+
#include "UnityEngine/Vector3.hpp"
17+
#include "UnityEngine/Canvas.hpp"
18+
using namespace UnityEngine;
19+
20+
DEFINE_CLASS(ClockMod::ClockRotationUpdater);
21+
22+
// Updates every frame and runs the following code.
23+
// Setting any Position does not work well here, please don't try, it is only for Realtime Rotation.
24+
void ClockMod::ClockRotationUpdater::Update() {
25+
if (Config.IsInSong) {
26+
// Instance of PlayerDataModel the noTextAndHUDs variable specifically
27+
bool NoTextAndHUD = UnityEngine::Object::FindObjectOfType<PlayerDataModel*>()->playerData->playerSpecificSettings->noTextsAndHuds;
28+
if (NoTextAndHUD == false) {
29+
Config.noTextAndHUD = false;
30+
// This will get an instance of CoreGameHUDController
31+
auto coreGameHUDController = UnityEngine::Object::FindObjectOfType<CoreGameHUDController*>();
32+
// Checks if the CoreGameHUDControlller exists, and will run the following code.
33+
if (coreGameHUDController) {
34+
if (Config.InRotationMap) {
35+
get_transform()->set_rotation(coreGameHUDController->get_transform()->get_rotation());
36+
}
37+
// else if (getModConfig().ClockPosition.GetValue()) {
38+
// get_transform()->set_eulerAngles(UnityEngine::Vector3(60, 0, 0));
39+
// }
40+
// else { get_transform()->set_eulerAngles(UnityEngine::Vector3(0, 0, 0)); }
41+
// Gets the rotation from the CoreGameHUDController and applies it to the Clock
42+
}
43+
// else if (getModConfig().ClockPosition.GetValue() == false) {
44+
// get_transform()->set_position(UnityEngine::Vector3(0, -1.25, -0.5));
45+
// get_transform()->set_eulerAngles(UnityEngine::Vector3(60, 0, 0));
46+
// get_transform()->set_localScale(UnityEngine::Vector3(0.6, 0.6, 0.6));
47+
// get_transform()->set_localPosition(UnityEngine::Vector3(getModConfig().ClockXOffset.GetValue(), getModConfig().ClockYOffset.GetValue(), getModConfig().ClockZOffset.GetValue()));
48+
// }
49+
else {
50+
// get_transform()->GetParent()->set_position(UnityEngine::Vector3(0, 0, 0));
51+
get_transform()->set_eulerAngles(UnityEngine::Vector3(0, 0, 0));
52+
}
53+
}
54+
else {
55+
Config.noTextAndHUD = true;
56+
GetComponent<UnityEngine::Canvas*>()->get_gameObject()->SetActive(false);
57+
}
58+
}
59+
}
60+
61+
// get_transform()->set_rotation(UnityEngine::Object::FindObjectOfType<NoteController*>()->get_worldRotation());
62+
//auto ClockRot = UnityEngine::Object::FindObjectOfType<NoteController*>()->get_worldRotation();
63+
//layout->get_transform()->GetParent()->set_rotation(ClockRot);

0 commit comments

Comments
 (0)