Skip to content

Commit

Permalink
v1.5.0 cleanup hopefully
Browse files Browse the repository at this point in the history
Signed-off-by: Erymanthus[#5074] | (u/)RayDeeUx <[email protected]>
  • Loading branch information
RayDeeUx committed Sep 8, 2024
1 parent 4ddc74f commit 8025f95
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 2 deletions.
2 changes: 2 additions & 0 deletions about.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ If you want to add your own songs to the mod you should go to the settings tab,

`.oga`, `.flac` and `.wav` files are also supported, for the few audiophiles who want the highest of audio quality out there.

*<cy>Note:</c>* ***<cy>There is an alternative config directory shortcut button within the mod's settings, in case you have QOLMod installed.</c>***

## Android
<co>*If you click the folder and you get sent to the geode folder itself, you should go to `game/geode/config/elnexreal.menuloop_randomizer` and put the songs there*</co>

Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
- Added "Playlist Mode" (suggested by [TheKevineer](https://discord.com/users/633040761256017963)). <cy>This feature is incredibly unstable, especially outside of Windows. I have done everything I could to keep its behavior consistent between Windows, macOS, and Android, but any crashes/issues from this feature are either beyond my control or have been acknowledged during beta testing without an obvious/more immediate fix.</c>
- Added "Remember Last Menu Loop" (suggested by [HexCodesGMD](https://discord.com/users/1222327935315218506)).
- Renamed and reordered a few settings to reduce confusion.
- Added config directory shortcut button.
- Incidentally, the pink config directory shortcut button from previous versions won't be added if QOLMod is loaded.
# v1.4.3
- Made sure the new "Regenerate Notification" sprite is actually part of the mod's resources.
- Also shrunk the mod file size down as there haven't been any new crashes from the changes introduced in v1.4.1.
Expand Down
9 changes: 7 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
"homepage": "https://github.com/elnexreal"
},
"settings": {
"configdir": {
"name": "Click me to open the Config Directory!",
"desc": "<cy>(Hopefully.)</c>\nThis setting does literally nothing new except being a button that acts as a shortcut to open the config directory for this mod (which is kind of important for using this mod properly, because this is where you will store your \"New Best\" sound effects), because the legendary developers in the Geode Team themselves forgot to add a shortcut button that would have done this exact same thing, and I have gotten far too many folks (rightfully) asking me to find the config directory when using some of my other mods, and I hate repeating the same things over and over again, and I don't know if the next major update for Geode will also repeat this mistake where HJfod forgets to include a config directory shortcut button, so this setting and this button are here for extra insurance, so please enjoy this extra button, I guess. Anyway, by the time you're finished reading this, your device should be finished with opening the config directory; press \"Aight\" to close this window.",
"type": "custom"
},
"useCustomSongs": {
"name": "Use Custom Songs Instead",
"description": "Use your own songs instead of those you have downloaded from Newgrounds or RobTop's Music Library.\n\n<cy>Find instructions in the mod info popup.</c>",
Expand Down Expand Up @@ -122,13 +127,13 @@
},
"randomizeWhenExitingLevel": {
"name": "Randomize on Level Exit",
"description": "Randomize the song when you exit a level.",
"description": "Randomize the song when you exit a level.\n\n<cy>This setting is ignored when \"Playlist Mode\" is enabled.</c>",
"type": "bool",
"default": true
},
"randomizeWhenExitingEditor": {
"name": "Randomize on Editor Exit",
"description": "Randomize the song when you exit the editor.",
"description": "Randomize the song when you exit the editor.\n\n<cy>This setting is ignored when \"Playlist Mode\" is enabled.</c>",
"type": "bool",
"default": true
}
Expand Down
2 changes: 2 additions & 0 deletions src/OptionsLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class $modify(MenuLoopOLHook, OptionsLayer) {
void customSetup() {
OptionsLayer::customSetup();

if (Loader::get()->getLoadedMod("thesillydoggo.qolmod")) return;

// add the folder btn to the settings layer
auto menu = CCMenu::create();

Expand Down
7 changes: 7 additions & 0 deletions src/Settings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "Settings.hpp"

SettingNode* MySettingValue::createNode(float width) {
return MySettingNode::create(this, width);
}

// i had to include this cpp file because C++ is a legendary language!
84 changes: 84 additions & 0 deletions src/Settings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#pragma once

#include <Geode/loader/SettingNode.hpp>

using namespace geode::prelude;

class MySettingValue : public

SettingValue

{
protected:
std::string m_placeholder;
public:
MySettingValue(std::string const& key, std::string const& modID, std::string const& placeholder)
: SettingValue(key, modID), m_placeholder(placeholder) {}
bool load(matjson::Value const& json) override { return true; }
bool save(matjson::Value& json) const override { return true; }
SettingNode* createNode(float width) override;
};

class MySettingNode : public SettingNode {
private:
std::string m_desc = "";
protected:
void onConfigDirButton(CCObject*) {
file::openFolder(Mod::get()->getConfigDir());
#ifndef GEODE_IS_MOBILE
if (!CCKeyboardDispatcher::get()->getShiftKeyPressed()) return;
FLAlertLayer::create(
"Config Directory Opened!",
m_desc,
"Aight"
)->show();
#endif
}
bool init(MySettingValue* value, float width) {
if (!SettingNode::init(value))
return false;
this->setContentSize({ width, 40.f });
std::string name = Mod::get()->getSettingDefinition(value->getKey())->get<CustomSetting>()->json->get<std::string>("name");
m_desc = Mod::get()->getSettingDefinition(value->getKey())->get<CustomSetting>()->json->get<std::string>("desc");

auto theMenu = CCMenu::create();
auto theLabel = CCLabelBMFont::create(name.c_str(), "bigFont.fnt");

// copied a bit from viper
theLabel->setScale(.35f);
theLabel->limitLabelWidth(300.f, .35f, .25f); // added by Ery. max width is 346.f

auto theLabelAsAButton = CCMenuItemSpriteExtra::create(theLabel, this, menu_selector(MySettingNode::onConfigDirButton));

theLabelAsAButton->setPositionX(0);

theMenu->addChild(theLabelAsAButton);
theMenu->setPosition(width / 2, 20.f);

this->addChild(theMenu);

return true;
}

public:
void commit() override {
this->dispatchCommitted();
}
bool hasUncommittedChanges() override {
return false;
}
bool hasNonDefaultValue() override {
return true;
}
void resetToDefault() override {}

static MySettingNode* create(MySettingValue* value, float width) {
auto ret = new MySettingNode();
if (ret && ret->init(value, width)) {
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}
};
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "SongManager.hpp"
#include "Utils.hpp"
#include "Settings.hpp"
#include <Geode/loader/SettingEvent.hpp>
#include <Geode/loader/Dirs.hpp>

Expand Down Expand Up @@ -71,6 +72,8 @@ void populateVector(bool customSongs) {
}

$on_mod(Loaded) {
Mod::get()->addCustomSetting<MySettingValue>("configdir", "none");

populateVector(Utils::getBool("useCustomSongs"));

std::string lastMenuLoop = Mod::get()->getSavedValue<std::string>("lastMenuLoop");
Expand Down

0 comments on commit 8025f95

Please sign in to comment.