Skip to content

Commit 262002b

Browse files
committed
Add ClockMod Settings Button to Main Menu, for quicker access
1 parent c03ae59 commit 262002b

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

include/ClockViewController.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
DECLARE_CLASS_CODEGEN(ClockMod, ClockViewController, HMUI::ViewController) {
88

9-
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);
9+
DECLARE_OVERRIDE_METHOD_MATCH(void, DidActivate, &HMUI::ViewController::DidActivate, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
10+
DECLARE_OVERRIDE_METHOD_MATCH(void, DidDeactivate, &HMUI::ViewController::DidDeactivate, bool removedFromHierarchy, bool systemScreenDisabling);
1111

1212
DECLARE_INSTANCE_FIELD(BSML::ModalColorPicker*, ColorPicker);
1313
DECLARE_INSTANCE_FIELD(HMUI::CurvedTextMeshPro*, TimeInfo);
14+
DECLARE_INSTANCE_FIELD(UnityEngine::Coroutine*, timeInfoRoutine);
1415

1516
custom_types::Helpers::Coroutine UpdateTimeText();
1617
bool SettingsOpen;

qpm.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/QuestPackageManager/QPM.Package/refs/heads/main/qpm.schema.json",
32
"version": "0.4.0",
43
"sharedDir": "shared",
54
"dependenciesDir": "extern",
@@ -22,7 +21,7 @@
2221
"pwsh build.ps1 -clean"
2322
]
2423
},
25-
"ndk": "^27.3.13750724",
24+
"ndk": "^27.2.12479018",
2625
"qmodIncludeDirs": [
2726
"build",
2827
"extern/libs"
@@ -75,4 +74,4 @@
7574
}
7675
}
7776
]
78-
}
77+
}

qpm.shared.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/QuestPackageManager/QPM.Package/refs/heads/main/qpm.shared.schema.json",
32
"config": {
43
"version": "0.4.0",
54
"sharedDir": "shared",
@@ -23,7 +22,7 @@
2322
"pwsh build.ps1 -clean"
2423
]
2524
},
26-
"ndk": "^27.3.13750724",
25+
"ndk": "^27.2.12479018",
2726
"qmodIncludeDirs": [
2827
"build",
2928
"extern/libs"

src/ClockViewContoller.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,22 @@ namespace ClockMod {
138138
// BeatSaberUI::AddHoverHint(AddConfigValueIncrementFloat(parent, getModConfig().ClockYOffset, 1, 0.1f, -10.0f, 10.0f)->get_gameObject(), "Offsets the Y (Up/Down) Position of the Clock");
139139
// BeatSaberUI::AddHoverHint(AddConfigValueIncrementFloat(parent, getModConfig().ClockZOffset, 1, 0.1f, -10.0f, 10.0f)->get_gameObject(), "Offsets the Z (Forward/Backward) Position of the Clock");
140140

141-
//BeatSaberUI::CreateColorPicker(parent, getModConfig().ClockColor.GetName(), getModConfig().ClockColor.GetValue(),
142-
// [](UnityEngine::Color value, GlobalNamespace::ColorChangeUIEventType eventType) {
143-
// getModConfig().ClockColor.SetValue(value);
144-
// });
145-
146141
if (ColorPicker)
147142
BSML::Lite::CreateUIButton(parent, "Change ClockColor", [this] {
148143
ColorPicker->modalView->Show();
149144
}
150145
);
151146

152147
}
153-
StartCoroutine(custom_types::Helpers::CoroutineHelper::New(UpdateTimeText()));
148+
timeInfoRoutine = StartCoroutine(custom_types::Helpers::CoroutineHelper::New(UpdateTimeText()));
154149
}
155150
void ClockViewController::DidDeactivate(bool removedFromHierarchy, bool systemScreenDisabling) {
156151
SettingsOpen = false;
157-
StopAllCoroutines();
152+
if (timeInfoRoutine) {
153+
StopCoroutine(timeInfoRoutine);
154+
timeInfoRoutine = nullptr;
155+
}
156+
// StopAllCoroutines();
158157
//Config.InSettings = false;
159158
}
160159
}

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ MOD_EXPORT void late_load() {
550550

551551
custom_types::Register::AutoRegister();
552552
BSML::Register::RegisterSettingsMenu<ClockMod::ClockViewController*>("ClockMod");
553+
BSML::Register::RegisterMainMenu<ClockMod::ClockViewController*>("ClockMod", "ClockMod", "Open the ClockMod Settings");
553554

554555
if (timeinfo && (timeinfo->tm_mon == 2 && timeinfo->tm_mday == 31) || (timeinfo->tm_mon == 3 && timeinfo->tm_mday == 1)) {
555556
INSTALL_HOOK(hkLog, ResultsViewController_DidActivate);

0 commit comments

Comments
 (0)