-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Erymanthus[#5074] | (u/)RayDeeUx <[email protected]>
- Loading branch information
Showing
12 changed files
with
356 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,8 @@ | ||
<h2 align="center">This mod is not being maintained by [RayDeeUx](https://github.com/RayDeeUx).</h2> | ||
# This mod is not being maintained by [RayDeeUx](https://github.com/RayDeeUx). | ||
|
||
# MenuLoopRandomizer | ||
This is where she makes a mod. | ||
|
||
<img src="logo.png" width="150" alt="the mod's logo" /> | ||
|
||
*Update logo.png to change your mod's icon (please)* | ||
|
||
## Getting started | ||
We recommend heading over to [the getting started section on our docs](https://docs.geode-sdk.org/getting-started/) for useful info on what to do next. | ||
|
||
## Build instructions | ||
For more info, see [our docs](https://docs.geode-sdk.org/getting-started/create-mod#build) | ||
```sh | ||
# Assuming you have the CLI set up already | ||
geode build | ||
``` | ||
|
||
# Resources | ||
* [Geode SDK Documentation](https://docs.geode-sdk.org/) | ||
* [Geode SDK Source Code](https://github.com/geode-sdk/geode/) | ||
* [Bindings](https://github.com/geode-sdk/bindings/) | ||
* [Dev Tools](https://github.com/geode-sdk/DevTools) | ||
Read [about.md](./about.md) to learn more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include "SongManager.hpp" | ||
#include "Utils.hpp" | ||
#include <Geode/modify/EditorPauseLayer.hpp> | ||
|
||
using namespace geode::prelude; | ||
|
||
class $modify(MenuLoopEPLHook, EditorPauseLayer) { | ||
struct Fields { | ||
SongManager &songManager = SongManager::get(); | ||
}; | ||
#ifndef __APPLE__ | ||
void onExitEditor(CCObject *sender) { | ||
if (Utils::getBool("randomizeWhenExitingEditor")) | ||
m_fields->songManager.pickRandomSong(); | ||
|
||
EditorPauseLayer::onExitEditor(sender); | ||
} | ||
#else | ||
/* | ||
this section is for macOS (both intel and ARM). remarks: | ||
- don't hook onSaveAndPlay; that goes to playlayer | ||
- don't hook onSave or the FLAlertLayer from it; that does not exit the editor | ||
- can't hook onExitEditor for macOS, due to aggressive inlining from robtop/appleclang | ||
(yes, nin. i know the address exists; justin found those addresses for me. | ||
but i keep getting the same song five times in a row if i hook onExitEditor | ||
for macos, and i don't think any of us have the same RNG seed as Dream.) | ||
[for the record, i had 29 possible audio files total while doing this. | ||
1/29 = 0.0344827586207. (1/29)^5 = 4.87539727785E-8 = 1/20511149. | ||
let that sink in for a moment.] | ||
-- raydeeux | ||
*/ | ||
void onSaveAndExit(CCObject *sender) { | ||
if (Utils::getBool("randomizeWhenExitingEditor")) | ||
m_fields->songManager.pickRandomSong(); | ||
|
||
EditorPauseLayer::onSaveAndExit(sender); | ||
} | ||
void FLAlert_Clicked(FLAlertLayer* p0, bool btnTwo) { | ||
bool isQualifedAlert = false; | ||
// determine if the FLAlertLayer being clicked on is the one from onExitNoSave | ||
/* | ||
hooking FLAlertLayer::init() and then storing its desc param is also an option, | ||
but i'm not sure what this mod's stance is with global variables. | ||
consider this overkill, but it gets the job done. | ||
i wanted to use getChildOfType to reduce the line count but ran into one of those | ||
C-Tidy/Clang red squiggly lines about typeinfo_cast or whatever and got worried, | ||
so all you get is this. | ||
yep, nested forloops and typeinfo_cast calls for days. | ||
if anyone has a shorter solution that still hooks this function, go ahead. | ||
for reference, unformatted FLAlertLayer main text is: | ||
R"(Exit without saving? All unsaved changes will be lost!)" | ||
-- raydeeux | ||
*/ | ||
auto tArea = p0->m_mainLayer->getChildByIDRecursive("content-text-area"); | ||
if (auto textArea = typeinfo_cast<TextArea*>(tArea)) { | ||
for (auto node : CCArrayExt<CCNode*>(textArea->getChildren())) { | ||
if (typeinfo_cast<MultilineBitmapFont*>(node)) { | ||
for (auto nodeTwo : CCArrayExt<CCNode*>(node->getChildren())) { | ||
if (auto label = typeinfo_cast<CCLabelBMFont*>(nodeTwo)) { | ||
auto labelString = std::string(label->getString()); | ||
isQualifedAlert = labelString == R"(Exit without saving? All unsaved changes will be lost!)"; | ||
log::debug("labelString: {}", labelString); // log::debug calls since that's kinda this mod's thing | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
log::debug("isQualifedAlert: {}", isQualifedAlert); // log::debug calls since that's kinda this mod's thing | ||
log::debug("btnTwo: {}", btnTwo); // log::debug calls since that's kinda this mod's thing | ||
|
||
if (Utils::getBool("randomizeWhenExitingEditor") && isQualifedAlert && btnTwo) | ||
m_fields->songManager.pickRandomSong(); | ||
|
||
EditorPauseLayer::FLAlert_Clicked(p0, btnTwo); | ||
} | ||
#endif | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "SongManager.hpp" | ||
#include <Geode/modify/GameManager.hpp> | ||
|
||
using namespace geode::prelude; | ||
|
||
class $modify(MenuLoopGMHook, GameManager) { | ||
struct Fields { | ||
SongManager &songManager = SongManager::get(); | ||
}; | ||
gd::string getMenuMusicFile() { | ||
return m_fields->songManager.getCurrentSong(); | ||
} | ||
}; |
Oops, something went wrong.