diff --git a/mods/audio_mod/CMakeLists.txt b/mods/audio_mod/CMakeLists.txt new file mode 100644 index 0000000000..083a348ed2 --- /dev/null +++ b/mods/audio_mod/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.25) +project(audio_mod CXX) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(DUSK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to dusk source root") + option(DUSK_MOD_USE_FULL_TREE "Use full build instead of the minimal mod SDK" OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + if (DUSK_MOD_USE_FULL_TREE) + add_subdirectory("${DUSK_DIR}" dusk EXCLUDE_FROM_ALL) + else () + add_subdirectory("${DUSK_DIR}/sdk" dusk-sdk EXCLUDE_FROM_ALL) + endif () +endif () + +add_mod(audio_mod + SOURCES src/mod.cpp + MOD_JSON mod.json + RES_DIR res +) diff --git a/mods/audio_mod/mod.json b/mods/audio_mod/mod.json new file mode 100644 index 0000000000..7151999aa6 --- /dev/null +++ b/mods/audio_mod/mod.json @@ -0,0 +1,7 @@ +{ + "id": "dev.twilitrealm.audio_mod", + "name": "[DEMO] Audio Mod", + "version": "1.0.0", + "author": "You, the listener", + "description": "An example Dusklight mod" +} diff --git a/mods/audio_mod/res/attribution.txt b/mods/audio_mod/res/attribution.txt new file mode 100644 index 0000000000..5c9d15d0fd --- /dev/null +++ b/mods/audio_mod/res/attribution.txt @@ -0,0 +1 @@ +go.opus and go.wav are licensed CC0, from https://kenney.nl/assets/voiceover-pack \ No newline at end of file diff --git a/mods/audio_mod/res/go.opus b/mods/audio_mod/res/go.opus new file mode 100644 index 0000000000..d5373b60b1 Binary files /dev/null and b/mods/audio_mod/res/go.opus differ diff --git a/mods/audio_mod/res/go.wav b/mods/audio_mod/res/go.wav new file mode 100644 index 0000000000..a6f7bdb5fc Binary files /dev/null and b/mods/audio_mod/res/go.wav differ diff --git a/mods/audio_mod/src/mod.cpp b/mods/audio_mod/src/mod.cpp new file mode 100644 index 0000000000..a68e6bb98e --- /dev/null +++ b/mods/audio_mod/src/mod.cpp @@ -0,0 +1,39 @@ +#include "mods/service.hpp" +#include "mods/svc/audio_res.h" +#include "mods/svc/log.h" + +DEFINE_MOD(); +IMPORT_SERVICE(LogService, svc_log); +IMPORT_SERVICE(AudioResService, svc_audio_res); + +extern "C" { + +MOD_EXPORT ModResult mod_initialize(ModError*) { + svc_log->info(mod_ctx, "template_mod initialized"); + AudioWaveHandle handle; + svc_audio_res->replace_wave( + mod_ctx, + SoundEffects, + 4238, + "res/go.opus", + nullptr, + &handle); + svc_audio_res->replace_wave( + mod_ctx, + SoundEffects, + 4237, + "res/go.opus", + nullptr, + &handle); + return MOD_OK; +} + +MOD_EXPORT ModResult mod_update(ModError*) { + return MOD_OK; +} + +MOD_EXPORT ModResult mod_shutdown(ModError*) { + svc_log->info(mod_ctx, "template_mod unloaded"); + return MOD_OK; +} +}