diff options
author | Eugene Sandulenko | 2010-08-06 13:13:25 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2010-10-12 22:35:55 +0000 |
commit | 47904bc7b2992189bb554833f00a79ff0fea9fb8 (patch) | |
tree | 1cec51758c6741b970bd064fafee77607b9f884f /engines/sword25/sfx/soundengine_script.cpp | |
parent | ca17def625154e5f758b797e4fc48c76b0566320 (diff) | |
download | scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.tar.gz scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.tar.bz2 scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.zip |
SWORD25: Mass-astyle.
svn-id: r53222
Diffstat (limited to 'engines/sword25/sfx/soundengine_script.cpp')
-rw-r--r-- | engines/sword25/sfx/soundengine_script.cpp | 159 |
1 files changed, 68 insertions, 91 deletions
diff --git a/engines/sword25/sfx/soundengine_script.cpp b/engines/sword25/sfx/soundengine_script.cpp index 34188e9f05..ecffd2b42a 100644 --- a/engines/sword25/sfx/soundengine_script.cpp +++ b/engines/sword25/sfx/soundengine_script.cpp @@ -23,7 +23,7 @@ * */ -/* +/* * This code is based on Broken Sword 2.5 engine * * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer @@ -45,11 +45,10 @@ // ----------------------------------------------------------------------------- -static int Init(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int Init(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); if (lua_gettop(L) == 0) @@ -57,18 +56,17 @@ static int Init(lua_State * L) else if (lua_gettop(L) == 1) lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), 32)); else - lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<unsigned int>(luaL_checknumber(L, 2)))); + lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<unsigned int>(luaL_checknumber(L, 2)))); return 1; } // ----------------------------------------------------------------------------- -static int Update(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int Update(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->Update(); @@ -78,26 +76,24 @@ static int Update(lua_State * L) // ----------------------------------------------------------------------------- -static int SetVolume(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int SetVolume(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->SetVolume(static_cast<float>(luaL_checknumber(L, 1)), - static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2)))); + static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2)))); return 0; } // ----------------------------------------------------------------------------- -static int GetVolume(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int GetVolume(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); lua_pushnumber(L, pSfx->GetVolume(static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 1))))); @@ -107,11 +103,10 @@ static int GetVolume(lua_State * L) // ----------------------------------------------------------------------------- -static int PauseAll(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int PauseAll(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->PauseAll(); @@ -121,11 +116,10 @@ static int PauseAll(lua_State * L) // ----------------------------------------------------------------------------- -static int ResumeAll(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int ResumeAll(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->ResumeAll(); @@ -135,11 +129,10 @@ static int ResumeAll(lua_State * L) // ----------------------------------------------------------------------------- -static int PauseLayer(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int PauseLayer(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->PauseLayer(static_cast<int>(luaL_checknumber(L, 1))); @@ -149,11 +142,10 @@ static int PauseLayer(lua_State * L) // ----------------------------------------------------------------------------- -static int ResumeLayer(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int ResumeLayer(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->ResumeLayer(static_cast<int>(luaL_checknumber(L, 1))); @@ -163,8 +155,7 @@ static int ResumeLayer(lua_State * L) // ----------------------------------------------------------------------------- -static void ProcessPlayParams(lua_State * L, std::string & FileName, BS_SoundEngine::SOUND_TYPES & Type, float & Volume, float & Pan, bool & Loop, int & LoopStart, int & LoopEnd, unsigned int & Layer) -{ +static void ProcessPlayParams(lua_State *L, std::string &FileName, BS_SoundEngine::SOUND_TYPES &Type, float &Volume, float &Pan, bool &Loop, int &LoopStart, int &LoopEnd, unsigned int &Layer) { FileName = luaL_checkstring(L, 1); Type = static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2))); @@ -188,11 +179,10 @@ static void ProcessPlayParams(lua_State * L, std::string & FileName, BS_SoundEng else Layer = static_cast<unsigned int>(luaL_checknumber(L, 8)); } -static int PlaySound(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int PlaySound(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); std::string FileName; @@ -210,11 +200,10 @@ static int PlaySound(lua_State * L) return 1; } -static int PlaySoundEx(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int PlaySoundEx(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); std::string FileName; @@ -234,11 +223,10 @@ static int PlaySoundEx(lua_State * L) // ----------------------------------------------------------------------------- -static int SetSoundVolume(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int SetSoundVolume(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->SetSoundVolume(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2))); @@ -248,11 +236,10 @@ static int SetSoundVolume(lua_State * L) // ----------------------------------------------------------------------------- -static int SetSoundPanning(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int SetSoundPanning(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->SetSoundPanning(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2))); @@ -262,11 +249,10 @@ static int SetSoundPanning(lua_State * L) // ----------------------------------------------------------------------------- -static int PauseSound(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int PauseSound(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->PauseSound(static_cast<unsigned int>(luaL_checknumber(L, 1))); @@ -276,11 +262,10 @@ static int PauseSound(lua_State * L) // ----------------------------------------------------------------------------- -static int ResumeSound(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int ResumeSound(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->ResumeSound(static_cast<unsigned int>(luaL_checknumber(L, 1))); @@ -290,11 +275,10 @@ static int ResumeSound(lua_State * L) // ----------------------------------------------------------------------------- -static int StopSound(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int StopSound(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); pSfx->StopSound(static_cast<unsigned int>(luaL_checknumber(L, 1))); @@ -304,11 +288,10 @@ static int StopSound(lua_State * L) // ----------------------------------------------------------------------------- -static int IsSoundPaused(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int IsSoundPaused(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); lua_pushbooleancpp(L, pSfx->IsSoundPaused(static_cast<unsigned int>(luaL_checknumber(L, 1)))); @@ -318,11 +301,10 @@ static int IsSoundPaused(lua_State * L) // ----------------------------------------------------------------------------- -static int IsSoundPlaying(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int IsSoundPlaying(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); lua_pushbooleancpp(L, pSfx->IsSoundPlaying(static_cast<unsigned int>(luaL_checknumber(L, 1)))); @@ -332,11 +314,10 @@ static int IsSoundPlaying(lua_State * L) // ----------------------------------------------------------------------------- -static int GetSoundVolume(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int GetSoundVolume(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); lua_pushnumber(L, pSfx->GetSoundVolume(static_cast<unsigned int>(luaL_checknumber(L, 1)))); @@ -346,11 +327,10 @@ static int GetSoundVolume(lua_State * L) // ----------------------------------------------------------------------------- -static int GetSoundPanning(lua_State * L) -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +static int GetSoundPanning(lua_State *L) { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); + BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx")); BS_ASSERT(pSfx); lua_pushnumber(L, pSfx->GetSoundPanning(static_cast<unsigned int>(luaL_checknumber(L, 1)))); @@ -360,10 +340,9 @@ static int GetSoundPanning(lua_State * L) // ----------------------------------------------------------------------------- -static const char * SFX_LIBRARY_NAME = "Sfx"; +static const char *SFX_LIBRARY_NAME = "Sfx"; -static const luaL_reg SFX_FUNCTIONS[] = -{ +static const luaL_reg SFX_FUNCTIONS[] = { "Init", Init, "Update", Update, "__SetVolume", SetVolume, @@ -386,8 +365,7 @@ static const luaL_reg SFX_FUNCTIONS[] = 0, 0, }; -static const lua_constant_reg SFX_CONSTANTS[] = -{ +static const lua_constant_reg SFX_CONSTANTS[] = { "MUSIC", BS_SoundEngine::MUSIC, "SPEECH", BS_SoundEngine::SPEECH, "SFX", BS_SoundEngine::SFX, @@ -396,13 +374,12 @@ static const lua_constant_reg SFX_CONSTANTS[] = // ----------------------------------------------------------------------------- -bool BS_SoundEngine::_RegisterScriptBindings() -{ - BS_Kernel * pKernel = BS_Kernel::GetInstance(); +bool BS_SoundEngine::_RegisterScriptBindings() { + BS_Kernel *pKernel = BS_Kernel::GetInstance(); BS_ASSERT(pKernel); - BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script")); + BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script")); BS_ASSERT(pScript); - lua_State * L = static_cast<lua_State *>(pScript->GetScriptObject()); + lua_State *L = static_cast<lua_State *>(pScript->GetScriptObject()); BS_ASSERT(L); if (!BS_LuaBindhelper::AddFunctionsToLib(L, SFX_LIBRARY_NAME, SFX_FUNCTIONS)) return false; |