mirror of
https://github.com/hax4dazy/TinWoo.git
synced 2025-02-09 19:25:05 +01:00
add mod tracker audio support to themes
This commit is contained in:
parent
32b41f5605
commit
5aa642f2ff
2
Makefile
2
Makefile
@ -64,7 +64,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -std=gnu++20 -Wall
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lpu -lcurl -lz -lssh2 -lusbhsfs -lntfs-3g -llwext4 -lmbedtls -lmbedcrypto -lmbedx509 -lminizip -lnx -lstdc++fs -lzzip -lpu -lfreetype -lSDL2_mixer -lopusfile -lopus -lmodplug -lmpg123 -lvorbisidec -lSDL2 -lc -logg -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lwebp -lpng -ljpeg `sdl2-config --libs` `freetype-config --libs` -lzstd
|
||||
LIBS := -lpu -lcurl -lz -lssh2 -lusbhsfs -lntfs-3g -llwext4 -lmbedtls -lmbedcrypto -lmbedx509 -lminizip -lnx -lstdc++fs -lzzip -lpu -lfreetype -lSDL2main -lSDL2_mixer -lopusfile -lopus -lmodplug -lmpg123 -lvorbisidec -lSDL2 -lc -logg -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lwebp -lpng -ljpeg `sdl2-config --libs` `freetype-config --libs` -lzstd
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
|
@ -15,6 +15,11 @@
|
||||
#include "util/theme.hpp"
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
// Include sdl2 headers
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
Mix_Music* audio = NULL;
|
||||
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
int statvfs(const char* path, struct statvfs* buf);
|
||||
@ -134,6 +139,19 @@ namespace inst::ui {
|
||||
inst::ui::mainApp->CreateShowDialog("usage.space_info"_lang, Info, { "common.ok"_lang }, true, "romfs:/images/icons/drive.png");
|
||||
}
|
||||
|
||||
void playmusic() {
|
||||
SDL_Init(SDL_INIT_AUDIO);
|
||||
Mix_Init(MIX_INIT_MP3); //enable mp3 support
|
||||
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096);
|
||||
std::string loadsound = "romfs:/bluesong.mod";
|
||||
if (inst::config::useTheme && std::filesystem::exists(inst::config::appDir + "/theme/theme.json") && std::filesystem::exists(inst::config::appDir + "audio.music"_theme)) {
|
||||
loadsound = inst::config::appDir + "audio.music"_theme;
|
||||
}
|
||||
const char* x = loadsound.c_str();
|
||||
audio = Mix_LoadMUS(x);
|
||||
Mix_PlayMusic(audio, 100); //Play the audio file 100 loops
|
||||
}
|
||||
|
||||
void mainMenuThread() {
|
||||
bool menuLoaded = mainApp->IsShown();
|
||||
if (!appletFinished && appletGetAppletType() == AppletType_LibraryApplet) {
|
||||
@ -263,6 +281,7 @@ namespace inst::ui {
|
||||
}
|
||||
this->Add(this->optionMenu);
|
||||
this->AddRenderCallback(mainMenuThread);
|
||||
playmusic();
|
||||
}
|
||||
|
||||
void MainPage::installMenuItem_Click() {
|
||||
@ -380,10 +399,14 @@ namespace inst::ui {
|
||||
if (Down & HidNpadButton_ZR) {
|
||||
}
|
||||
|
||||
if (Down & HidNpadButton_L) {
|
||||
if (Down & Held & HidNpadButton_L) {
|
||||
playmusic();
|
||||
}
|
||||
|
||||
if (Down & HidNpadButton_R) {
|
||||
if (Down & Held & HidNpadButton_R) {
|
||||
Mix_FreeMusic(audio);
|
||||
audio = NULL;
|
||||
Mix_Quit();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user