From 0c976a221c41693353a29218bc0c8fbac4b87777 Mon Sep 17 00:00:00 2001 From: "born a rick, raised a morty, died a jerry" Date: Sat, 24 Nov 2018 20:56:37 -0500 Subject: [PATCH] allow song to play its own preview and give lua access (experimental) borp --- .../wifeTwirl.lua | 1 + src/Song.cpp | 27 ++++++++++++++++--- src/Song.h | 5 +++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/wifeTwirl.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/wifeTwirl.lua index f3c30f37c1..bd50bbc829 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/wifeTwirl.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/wifeTwirl.lua @@ -114,6 +114,7 @@ local function toggleNoteField() return end if song then + song:Borp() if mcbootlarder:GetVisible() then mcbootlarder:visible(false) mcbootlarder:GetChild("NoteField"):visible(false) diff --git a/src/Song.cpp b/src/Song.cpp index 0de1577cce..e524fb64e8 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -1,4 +1,4 @@ -#include "global.h" +#include "global.h" #include "FontCharAliases.h" #include "GameManager.h" #include "RageLog.h" @@ -34,6 +34,7 @@ #include "LyricsLoader.h" #include "ActorUtil.h" #include "CommonMetrics.h" +#include "GameSoundManager.h" #include "GameState.h" #include @@ -2047,6 +2048,21 @@ Song::IsMarathon() const return m_fMusicLengthSeconds >= g_fMarathonVerSongSeconds; } +void +Song::Borp() +{ + GameSoundManager::PlayMusicParams PlayParams; + PlayParams.sFile = m_sMusicFile; + PlayParams.pTiming = &this->m_SongTiming; + PlayParams.bForceLoop = true; + PlayParams.fStartSecond = m_fMusicSampleStartSeconds; + PlayParams.fLengthSeconds = GetLastSecond() + 2.f; + PlayParams.fFadeOutLengthSeconds = 1.f; + PlayParams.bAlignBeat = true; + PlayParams.bApplyMusicRate = true; + SOUND->PlayMusic(PlayParams); +} + // lua start #include "LuaBinding.h" @@ -2468,13 +2484,17 @@ class LunaSong : public Luna p->ReloadFromSongDir(); COMMON_RETURN_SELF; } - static int GetOrTryAtLeastToGetSimfileAuthor(T* p, lua_State* L) { lua_pushstring(L, p->GetOrTryAtLeastToGetSimfileAuthor()); return 1; } - + static int Borp(T* p, lua_State* L) + { + p->Borp(); + return 0; + } + LunaSong() { ADD_METHOD(GetDisplayFullTitle); @@ -2543,6 +2563,7 @@ class LunaSong : public Luna ADD_METHOD(GetPreviewVidPath); ADD_METHOD(GetPreviewMusicPath); ADD_METHOD(ReloadFromSongDir); + ADD_METHOD(Borp); } }; diff --git a/src/Song.h b/src/Song.h index f87ebfd402..f7205ece4c 100644 --- a/src/Song.h +++ b/src/Song.h @@ -1,4 +1,4 @@ -#ifndef SONG_H +#ifndef SONG_H #define SONG_H #include "Difficulty.h" @@ -438,6 +438,9 @@ class Song bool IsLong() const; bool IsMarathon() const; + // plays music for chart preview and is available to lua -mina + void Borp(); + bool SongCompleteForStyle(const Style* st) const; bool HasStepsType(StepsType st) const; bool HasStepsTypeAndDifficulty(StepsType st, Difficulty dc) const;