Skip to content

Commit

Permalink
v4?
Browse files Browse the repository at this point in the history
  • Loading branch information
RayDeeUx authored Nov 14, 2024
1 parent 870947f commit a5395c4
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 92 deletions.
6 changes: 2 additions & 4 deletions about.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ Are you bored of hearing the same menu song <cr>over & over</cr>? Well... **No m
This mod allows you to randomize the menu song every time you open the game, picking from a random downloaded song from Newgrounds, RobTop's Music Library, or your own songs. `.mp3`, `.ogg`/`.oga`, `.wav`, and `.flac` files are supported.

# Adding custom songs
If you want to add your own songs to the mod you should go to the settings tab, then click the <cd>pink</c> folder button. Just like with grabbing songs you've downloaded from Newgrounds or RobTop's Music Library, `.mp3` and `.ogg` files are supported.
If you want to add your own songs to the mod you should go to the mod's settings menu, then "Click me to open the Config Directory!". Just like the songs you've downloaded from Newgrounds or RobTop's Music Library, `.mp3` and `.ogg` files are supported.

![Screenshot on how to use it. Install the mod to view this screenshot!](elnexreal.menuloop_randomizer/screenshot.png)

`.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>
<co>*If you click the config directory shortcut 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>

# Blacklisting songs
Ever felt like a song was an absolute dud? Click the (crudely drawn) <cl>blacklist button</c> and you won't ever hear that song as a menu loop again.
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v1.6.2
- Port to 2.2074.
- Remove the pink button config directory shortcut.
# v1.6.1
- Redo the button for blacklisting songs. Base icon shape provided by [FREAKINGDAN](https://github.com/freakingdan).
- Reduce confusion when copying song names/IDs while playing songs replaced by Jukebox/Auto Nong. {Reported by CyBlanc}
Expand Down
19 changes: 8 additions & 11 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"geode": "3.4.0",
"geode": "4.0.0-alpha.1",
"gd": {
"win": "2.206",
"android": "2.206",
"mac": "2.206"
"win": "2.2074",
"android": "2.2074",
"mac": "2.2074"
},
"version": "v1.6.1",
"version": "v1.6.2",
"id": "elnexreal.menuloop_randomizer",
"name": "Menu Loop Randomizer",
"developers": ["RayDeeUx", "elnexreal"],
Expand All @@ -16,7 +16,8 @@
"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 menu loops), 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"
"description": "<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 menu loops), 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:configdir"
},
"useCustomSongs": {
"name": "Use Custom Songs Instead",
Expand Down Expand Up @@ -155,13 +156,9 @@
{
"id": "geode.node-ids",
"importance": "required",
"version": ">=1.13.1"
"version": ">=1.16.0"
}
],
"issues": {
"url": "https://discord.com/channels/911701438269386882/1205523212444639292",
"info": "To disable hyphen prefixes and suffixes in custom messages, edit saved.json. For other issues, ping me <cl>(@erymanthus)</c> in the Geode SDK Discord server's <cl>#help</c> channel if you need help. <cr>DMs are NOT accepted.</c>"
},
"links": {
"community": "https://discord.gg/WqZBYdBWZW",
"homepage": "https://discord.com/channels/822510988409831486/1206371881222144020"
Expand Down
36 changes: 0 additions & 36 deletions src/OptionsLayer.cpp

This file was deleted.

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

SettingNode* MySettingValue::createNode(float width) {
return MySettingNode::create(this, width);
SettingNodeV3* MyButtonSettingV3::createNode(float width) {
return MyButtonSettingNodeV3::create(
std::static_pointer_cast<MyButtonSettingV3>(shared_from_this()),
width
);
}

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

#include <Geode/loader/SettingNode.hpp>
#include <Geode/loader/SettingV3.hpp>

using namespace geode::prelude;

class MySettingValue : public

SettingValue

{
protected:
std::string m_placeholder;
class MyButtonSettingV3 : public SettingV3 {
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;
static Result<std::shared_ptr<SettingV3>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
auto res = std::make_shared<MyButtonSettingV3>();
auto root = checkJson(json, "MyButtonSettingV3");
res->init(key, modID, root);
res->parseNameAndDescription(root);
res->parseEnableIf(root);
return root.ok(std::static_pointer_cast<SettingV3>(res));
}
bool load(matjson::Value const& json) override {
return true;
}
bool save(matjson::Value& json) const override {
return true;
}
bool isDefaultValue() const override {
return true;
}
void reset() override {}
// SettingNodeV3* createNode(float width) override; // this line is [absolutely] certified cringe
SettingNodeV3 *createNode(float width) override; // this line is NOT certified cringe
};

class MySettingNode : public SettingNode {
class MyButtonSettingNodeV3 : public SettingNodeV3 {
private:
std::string m_desc = "";
protected:
public:
void onCommit() {}
void onResetToDefault() {}
bool hasUncommittedChanges() const {
return false;
}
bool hasNonDefaultValue() const {
return false;
}
void onConfigDirButton(CCObject*) {
file::openFolder(Mod::get()->getConfigDir());
#ifndef GEODE_IS_MOBILE
Expand All @@ -34,47 +51,38 @@ class MySettingNode : public SettingNode {
)->show();
#endif
}
bool init(MySettingValue* value, float width) {
if (!SettingNode::init(value))
return false;
bool init(std::shared_ptr<MyButtonSettingV3> setting, float width) {
if (!SettingNodeV3::init(setting, width)) 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");

std::string name = setting->getName().value();
m_desc = setting->getDescription().value();
auto theMenu = CCMenu::create();
auto theLabel = CCLabelBMFont::create(name.c_str(), "bigFont.fnt");

// copied a bit from viper
// copied a bit from louis ck jr
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));
auto theLabelAsAButton = CCMenuItemSpriteExtra::create(theLabel, this, menu_selector(MyButtonSettingNodeV3::onConfigDirButton));

theLabelAsAButton->setPositionX(0);
theLabelAsAButton->setID("config-dir-shortcut-button"_spr);

theMenu->addChild(theLabelAsAButton);
theMenu->setPosition(width / 2, 20.f);
theMenu->setID("config-dir-shortcut-menu"_spr);

this->addChild(theMenu);

return true;
}
for (const auto &node : CCArrayExt<CCNode*>(this->getChildren())) {
node->setVisible(!node->getID().empty());
}

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)) {
static MyButtonSettingNodeV3* create(std::shared_ptr<MyButtonSettingV3> setting, float width) {
auto ret = new MyButtonSettingNodeV3();
if (ret && ret->init(setting, width)) {
ret->autorelease();
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "SongManager.hpp"
#include "Utils.hpp"
#include "Settings.hpp"
#include <Geode/loader/SettingEvent.hpp>
#include <Geode/loader/SettingV3.hpp>

using namespace geode::prelude;

Expand Down

0 comments on commit a5395c4

Please sign in to comment.