Skip to content

Commit

Permalink
Add BombExplosionSounds, completing the list of possible editable gam…
Browse files Browse the repository at this point in the history
…eplay sounds
  • Loading branch information
michael-r-elp committed Jul 26, 2024
1 parent 7ae814a commit 7f62c82
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 3 deletions.
5 changes: 3 additions & 2 deletions assets/ConfigMenuSelectionViewController.bsml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
</vertical>
</tab>
<tab tags='main' tab-name='Notes' >
<vertical pad-left="3" pad-right="3" pad-top="2" pad-bottom="2" horizontal-fit="PreferredSize" vertical-fit="PreferredSize">
<vertical pad-left="3" pad-right="3" pad-top="1" pad-bottom="1" horizontal-fit="PreferredSize" vertical-fit="PreferredSize">
<button text="Hit Sounds" pref-width="50" on-click="HitSoundButtonPressed" />
<button text="Bad Hit Sounds" pref-width="50" on-click="BadHitSoundButtonPressed" />
<button text="Miss Sounds" pref-width="50" on-click="MissSoundButtonPressed" />
<button text="Miss Sounds" pref-width="50" on-click="MissSoundButtonPressed" />
<button text="Bomb Explosions" pref-width="50" on-click="BombExplosionSoundButtonPressed" />
</vertical>
</tab>
<tab tags='main' tab-name='Level Results' >
Expand Down
2 changes: 2 additions & 0 deletions include/AudioClips.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace QuestSounds::AudioClips {
extern QuestSounds::Utils::AsyncAudioClipLoader hitSoundLoader, // hitSound
badHitSoundLoader, // badHitSound
noteMissedSoundLoader,
bombExplosionSoundLoader,
menuMusicLoader, // menuMusic
menuClickLoader,
fireworkSoundLoader,
Expand All @@ -16,6 +17,7 @@ namespace QuestSounds::AudioClips {

extern ::ArrayW<::UnityW<::UnityEngine::AudioClip>> hitSoundArr, // hitSoundArray
badHitSoundArr, // badHitSoundArray
bombExplosionSoundLoaderArr,
menuClickArr,
fireworkSoundArr;

Expand Down
2 changes: 2 additions & 0 deletions include/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ namespace QuestSounds {
SOUND_VALUE_SIMPLE(LevelCleared, "LevelCleared");
SOUND_VALUE(LevelFailed, "LevelFailed", 0);
SOUND_VALUE_SIMPLE(LobbyMusic, "LobbyMusic");
SOUND_VALUE(BombExplosionSound, "BombExplosionSounds", 0);
)

DECLARE_JSON_CLASS(
SoundsConfig,
VALUE_DEFAULT(std::string, ConfigVersion, "3.1.0");
NAMED_VALUE(Sounds, Sounds, NAME_OPTS("SoundsConfig_v3", "SoundsConfig_v2", "SoundsConfig_v1", "Sounds"));
)
extern SoundsConfig Config;
Expand Down
1 change: 1 addition & 0 deletions include/UI/ConfigMenuSelectionViewController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ DECLARE_CLASS_CODEGEN(QuestSounds::UI, ConfigMenuSelectionViewController, HMUI::
DECLARE_INSTANCE_METHOD(void, LevelClearedButtonPressed);
DECLARE_INSTANCE_METHOD(void, LevelFailedButtonPressed);
DECLARE_INSTANCE_METHOD(void, FireworkButtonPressed);
DECLARE_INSTANCE_METHOD(void, BombExplosionSoundButtonPressed);

DECLARE_CTOR(ctor);

Expand Down
27 changes: 26 additions & 1 deletion src/Hooks/NoteSoundHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ using namespace QuestSounds::AudioClips;

#include "GlobalNamespace/NoteCutSoundEffectManager.hpp"
#include "GlobalNamespace/NoteCutSoundEffect.hpp"
#include "GlobalNamespace/BombCutSoundEffectManager.hpp"
#include "GlobalNamespace/BeatmapObjectManager.hpp"
#include "GlobalNamespace/NoteController.hpp"
#include "GlobalNamespace/NoteData.hpp"
#include "GlobalNamespace/PauseMenuManager.hpp"
using namespace GlobalNamespace;


#pragma region HitSounds

MAKE_AUTO_HOOK_MATCH(NoteCutSoundEffectManager_Start, &NoteCutSoundEffectManager::Start, void, NoteCutSoundEffectManager* self) {
if(hitSoundLoader.loaded && Config.Sounds.HitSound.Active)
Expand All @@ -36,6 +38,10 @@ MAKE_AUTO_HOOK_MATCH(NoteCutSoundEffectManager_Start, &NoteCutSoundEffectManager
getLogger().debug("Beatalign offset is: {}", self->_beatAlignOffset);
}

#pragma endregion

#pragma region HitSoundsAndBadHitSounds

MAKE_AUTO_HOOK_MATCH(NoteCutSoundEffect_Awake, &NoteCutSoundEffect::Awake, void, NoteCutSoundEffect* self) {
if (hitSoundLoader.loaded && Config.Sounds.HitSound.Active) {
self->_goodCutVolume += Config.Sounds.HitSound.VolumeOffset.value_or(0.0f);
Expand All @@ -50,6 +56,10 @@ MAKE_AUTO_HOOK_MATCH(NoteCutSoundEffect_Awake, &NoteCutSoundEffect::Awake, void,
NoteCutSoundEffect_Awake(self);
}

#pragma endregion

#pragma region NoteMissedSounds

MAKE_AUTO_HOOK_MATCH(BeatmapObjectManager_HandleNoteWasMissed, &BeatmapObjectManager::HandleNoteControllerNoteWasMissed, void, BeatmapObjectManager* self, NoteController* noteController) {
BeatmapObjectManager_HandleNoteWasMissed(self, noteController);
if (noteMissedSoundLoader.loaded &&
Expand All @@ -67,4 +77,19 @@ MAKE_AUTO_HOOK_MATCH(PauseMenuManager_MenuButtonPressed, &PauseMenuManager::Menu
if (noteMissedSoundLoader.audioSource) noteMissedSoundLoader.audioSource->Stop();
}
PauseMenuManager_MenuButtonPressed(self);
}
}

#pragma endregion

#pragma region BombHitSounds

MAKE_AUTO_HOOK_MATCH(BombCutSoundEffectManager_Start, &BombCutSoundEffectManager::Start, void, BombCutSoundEffectManager* self) {
if (bombExplosionSoundLoader.loaded && Config.Sounds.BombExplosionSound.Active) {
bombExplosionSoundLoaderArr = createAudioClipArray(bombExplosionSoundLoader);
self->_bombExplosionAudioClips = bombExplosionSoundLoaderArr;
self->_volume += Config.Sounds.BombExplosionSound.VolumeOffset.value_or(0.0f);
}
BombCutSoundEffectManager_Start(self);
}

#pragma endregion
7 changes: 7 additions & 0 deletions src/UI/ConfigMenuSelectionViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,11 @@ namespace QuestSounds::UI {
callback(8);
}
}

void ConfigMenuSelectionViewController::BombExplosionSoundButtonPressed() {
getLogger().info("BombExplosionSoundButtonPressed");
if (callback) {
callback(9);
}
}
}
6 changes: 6 additions & 0 deletions src/UI/QuestSoundsFlowCoordinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ namespace QuestSounds::UI {
SetTitle("Firework", HMUI::ViewController::AnimationType::In);
// ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
break;
case 9:
getLogger().info("BombExplosionSoundButtonPressed");
soundSettingsViewController->Setup("BombExplosionSounds", &QuestSounds::Config.Sounds.BombExplosionSound, &QuestSounds::AudioClips::bombExplosionSoundLoader);
SetTitle("Bomb Explosion Sound", HMUI::ViewController::AnimationType::In);
// ReplaceTopViewController(soundSettingsViewController, nullptr, HMUI::ViewController::AnimationType::In, HMUI::ViewController::AnimationDirection::Horizontal);
break;
default:
getLogger().error("Invalid index");
SetTitle("QuestSounds", HMUI::ViewController::AnimationType::In);
Expand Down
13 changes: 13 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ void makeFolder()
}
}

if (!direxists(Config.Sounds.BombExplosionSound.FolderPath.c_str()))
{
int makePath = mkpath(Config.Sounds.BombExplosionSound.FolderPath.c_str());
if (makePath == -1)
{
getLogger().error("Failed to make BombExplosionSound Folder path!");
}
}

if (!direxists(Config.Sounds.MenuClick.FolderPath.c_str()))
{
int makePath = mkpath(Config.Sounds.MenuClick.FolderPath.c_str());
Expand Down Expand Up @@ -125,6 +134,7 @@ namespace QuestSounds::AudioClips {
QuestSounds::Utils::AsyncAudioClipLoader hitSoundLoader, // hitSound
badHitSoundLoader, // badHitSound
noteMissedSoundLoader,
bombExplosionSoundLoader,
menuMusicLoader, // menuMusic
menuClickLoader,
fireworkSoundLoader,
Expand All @@ -133,6 +143,7 @@ QuestSounds::Utils::AsyncAudioClipLoader hitSoundLoader, // hitSound
lobbyAmbienceLoader; // Added for LobbyMusic
::ArrayW<::UnityW<::UnityEngine::AudioClip>> hitSoundArr, // hitSoundArray
badHitSoundArr, // badHitSoundArray
bombExplosionSoundLoaderArr,
menuClickArr,
fireworkSoundArr;

Expand All @@ -145,6 +156,7 @@ ::ArrayW<::UnityW<::UnityEngine::AudioClip>> origMenuClickArr;
hitSoundLoader.streamAudio = false; // Streaming HitSounds breaks them
badHitSoundLoader.filePath = Config.Sounds.BadHitSound.FilePath;
noteMissedSoundLoader.filePath = Config.Sounds.NoteMissedSound.FilePath;
bombExplosionSoundLoader.filePath = Config.Sounds.BombExplosionSound.FilePath;
menuMusicLoader.filePath = Config.Sounds.MenuMusic.FilePath;
menuClickLoader.filePath = Config.Sounds.MenuClick.FilePath;
fireworkSoundLoader.filePath = Config.Sounds.Firework.FilePath;
Expand All @@ -157,6 +169,7 @@ ::ArrayW<::UnityW<::UnityEngine::AudioClip>> origMenuClickArr;
if (Config.Sounds.HitSound.Active) hitSoundLoader.load();
if (Config.Sounds.BadHitSound.Active) badHitSoundLoader.load();
if (Config.Sounds.NoteMissedSound.Active) noteMissedSoundLoader.load();
if (Config.Sounds.BombExplosionSound.Active) bombExplosionSoundLoader.load();
if (Config.Sounds.Firework.Active) fireworkSoundLoader.load();
if (Config.Sounds.LevelCleared.Active) levelClearedLoader.load();
if (Config.Sounds.LevelFailed.Active) levelFailedLoader.load();
Expand Down

0 comments on commit 7f62c82

Please sign in to comment.