Skip to content

Commit

Permalink
1.0.2 momento
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined06855 committed Apr 26, 2024
1 parent a1a791b commit 673969e
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 11 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# EditorMusic
## v1.0.2
- Fix random bugs and add pause menu button
## v1.0.1
- Android support
## v1.0.0
- Initial release
14 changes: 12 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"geode": "2.0.0-beta.25",
"gd": { "win": "2.204", "android": "2.205" },
"version": "v1.0.1",
"version": "v1.0.2",
"id": "undefined0.editormusic",
"name": "EditorMusic",
"developer": "undefined0",
"description": "hey it's like super mario maker",
"repository": "https://github.com/undefined06855/EditorMusic",
"tags": [ "editor", "enhancement" ]
"tags": [ "editor", "enhancement" ],

"settings": {
"volume": {
"name": "Music volume",
"type": "float",
"default": 0.8,
"min": 0,
"max": 1
}
}
}
15 changes: 10 additions & 5 deletions src/AudioManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class AudioManager {
int songID;
bool hasNoSongs = false;


void setup() {
std::vector<std::string> files = {};

Expand All @@ -33,8 +32,7 @@ class AudioManager {

this->sounds.push_back(sound);
log::info("Sound created for {}", path.filename().string());
}
else {
} else {
log::info("Unsupported file extension found in config dir: {}", path.filename().string());
}
}
Expand Down Expand Up @@ -94,11 +92,11 @@ class AudioManager {
}

void turnDownMusic() {
this->channel->setVolume(GameManager::get()->m_bgVolume * .4f);
this->channel->setVolume(.4f * Mod::get()->getSettingValue<double>("volume"));
}

void turnUpMusic() {
this->channel->setVolume(GameManager::get()->m_bgVolume * .8f);
this->channel->setVolume(Mod::get()->getSettingValue<double>("volume"));
}

void onExitEditor() {
Expand All @@ -121,4 +119,11 @@ class AudioManager {
this->playAudio(true);
}
}

void nextSong() {
if (this->hasNoSongs) return;

this->stopAudio();
this->playAudio(true);
}
};
56 changes: 52 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Geode/modify/MenuLayer.hpp>
#include <Geode/modify/EditorUI.hpp>
#include <Geode/modify/CCScheduler.hpp>
#include <Geode/modify/LoadingLayer.hpp>
#include "AudioManager.hpp"

using namespace geode::prelude;
Expand Down Expand Up @@ -46,7 +47,22 @@ class $modify(LevelEditorLayer) {
}
};

class $modify(EditorPauseLayer) {
class $modify(EditorUI) {
void onPlayback(CCObject * sender) {
isPlaybackPlaying = !isPlaybackPlaying;
if (isPlaybackPlaying) {
log::info("stop music (playback started)");
audioManager->stopAudio();
} else {
log::info("start music (playback stopped)");
audioManager->playAudio(false);
}

EditorUI::onPlayback(sender);
}
};

class $modify(FunkyEditorPauseLayer, EditorPauseLayer) {
void onExitEditor(CCObject* sender) {
EditorPauseLayer::onExitEditor(sender);
log::info("stop music (exit)");
Expand All @@ -66,6 +82,32 @@ class $modify(EditorPauseLayer) {
log::info("turn up music");
audioManager->turnUpMusic();
}

bool init(LevelEditorLayer* p0) {
if (!EditorPauseLayer::init(p0)) return false;

auto menu = this->getChildByID("small-actions-menu");

auto spr = ButtonSprite::create(
"Next\nSong", 30, 0, .4f, true,
"bigFont.fnt", "GJ_button_04.png", 30.f
);
spr->setScale(.8f);

auto nextSongButton = CCMenuItemSpriteExtra::create(
spr, this, menu_selector(FunkyEditorPauseLayer::onNextSong)
);
nextSongButton->setID("next-song-btn"_spr);
menu->insertAfter(nextSongButton, nullptr);

menu->updateLayout();

return true;
}

void onNextSong(CCObject* sender) {
audioManager->nextSong();
}
};

class $modify(CCScheduler) {
Expand All @@ -82,14 +124,20 @@ class $modify(MenuLayer) {
if (!MenuLayer::init()) return false;

if (audioManager->hasNoSongs) {
FLAlertLayer::create("Message from EditorMusic", "You have no songs in your config folder! Press the pencil icon next to the mod config to access the folder, where you can place music. See the mod description for more details.", "OK");
auto alert = FLAlertLayer::create(
"Message from EditorMusic",
"You have no songs in your config folder! Press the pencil icon next to the mod config to access the folder, where you can place music. See the mod description for more details.",
"OK"
);

alert->m_scene = this;
alert->show();
}

return true;
}
};

$execute {
// load audio
$execute{
audioManager->setup();
}

0 comments on commit 673969e

Please sign in to comment.