Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Audio.music" system with music overriding #77

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion LunaDll/LuaMain/LuaProxyComponent/LuaProxyAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../../SMBXInternal/PlayerMOB.h"
#include "../../SMBXInternal/Level.h"
#include "../../SMBXInternal/Sound.h"
#include "../../Misc/ResourceFileMapper.h"

#include <memory>
#include <mutex>
Expand Down Expand Up @@ -345,6 +346,22 @@ Mix_Chunk* LuaProxy::Audio::newMix_Chunk()
return NULL;
}

void LuaProxy::Audio::__setOverrideForMusicAlias(const std::string& alias, std::string chunk)
{
#ifndef NO_SDL
PGE_MusPlayer::setOverrideForMusicAlias(alias, chunk);
#endif
}

std::string LuaProxy::Audio::__getMusicForAlias(const std::string& alias, int type)
{
#ifndef NO_SDL
return PGE_MusPlayer::getMusicForAlias(alias, type);
#else
return "";
#endif
}



void LuaProxy::Audio::clearSFXBuffer()
Expand Down Expand Up @@ -378,7 +395,7 @@ Mix_Chunk *LuaProxy::Audio::SfxOpen(const std::string& filename, lua_State* L)
// If error, pass to Lua
luaL_error(L, "%s", PGE_Sounds::SND_getLastError());
}

return chunk;
}

Expand Down
8 changes: 8 additions & 0 deletions LunaDll/LuaMain/LuaProxyComponent/LuaProxyAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

#include <string>
#include <memory>

#include "../../SdlMusic/MusicManager.h"
#include "../../SdlMusic/SdlMusPlayer.h"
#include "../../Defines.h"

struct Mix_Chunk;
class MciEmulator;
struct lua_State;
Expand Down Expand Up @@ -54,6 +59,9 @@ namespace LuaProxy
double MusicGetPitch();
double MusicGetSpeed();

void __setOverrideForMusicAlias(const std::string& alias, std::string chunk);
std::string __getMusicForAlias(const std::string& alias, int type);

//SFX
Mix_Chunk* newMix_Chunk();
void clearSFXBuffer();
Expand Down
4 changes: 4 additions & 0 deletions LunaDll/LuaMain/LunaLuaMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ bool CLunaLua::shutdown()
m_ready = false;
m_onStartRan = false;
m_luaCallDepth = 0;

LuaProxy::Audio::resetMciSections();
lua_close(L);
L = NULL;
Expand Down Expand Up @@ -905,6 +906,9 @@ void CLunaLua::bindAll()
def("MusicGetPitch", (double(*)())&LuaProxy::Audio::MusicGetPitch),
def("MusicGetSpeed", (double(*)())&LuaProxy::Audio::MusicGetSpeed),

def("__setOverrideForMusicAlias", LuaProxy::Audio::__setOverrideForMusicAlias),
def("__getMusicForAlias", LuaProxy::Audio::__getMusicForAlias),

//SFX
def("newMix_Chunk", (Mix_Chunk*(*)())&LuaProxy::Audio::newMix_Chunk),
def("clearSFXBuffer", (void(*)())&LuaProxy::Audio::clearSFXBuffer),
Expand Down
1 change: 1 addition & 0 deletions LunaDll/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ int TestFunc()
}

Blocks::DoSortingIfRequired();

return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions LunaDll/Misc/RuntimeHookComponents/RuntimeHookHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,7 @@ extern void __stdcall RenderLevelHook()
short oldRenderDoneCameraUpdate = g_renderDoneCameraUpdate;
g_renderDoneCameraUpdate = 0;
RenderLevelReal();
MusicManager::update();
g_renderDoneCameraUpdate = oldRenderDoneCameraUpdate;

if (g_GLEngine.IsEnabled() && !Renderer::IsAltThreadActive())
Expand Down Expand Up @@ -1552,6 +1553,7 @@ extern void __stdcall RenderWorldHook()
}
g_EventHandler.hookWorldRenderStart();
RenderWorldReal();
MusicManager::update();
if (g_GLEngine.IsEnabled() && !Renderer::IsAltThreadActive())
{
g_GLEngine.EndFrame(g_GLEngine.GetHDC());
Expand Down
2 changes: 1 addition & 1 deletion LunaDll/SdlMusic/MusicDefList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::string MusicManager::musAliasesList[75]=
"music53",
"music54",
"music55",
"music56" //73
"music56" //75
};

std::string MusicManager::chunksAliasesList[91]=
Expand Down
Loading