From 31b4d83fac82e634f9b18825e77614c454d3331f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 10 Jul 2010 11:48:05 +0200 Subject: [PATCH] moved sound extensions from mwsound to mwscript (reduces coupling between openmw components) --- apps/openmw/CMakeLists.txt | 8 +-- apps/openmw/mwscript/extensions.cpp | 5 +- apps/openmw/mwscript/scriptmanager.cpp | 5 +- .../soundextensions.cpp} | 72 +++++++++---------- apps/openmw/mwscript/soundextensions.hpp | 27 +++++++ apps/openmw/mwsound/extensions.hpp | 24 ------- 6 files changed, 69 insertions(+), 72 deletions(-) rename apps/openmw/{mwsound/extensions.cpp => mwscript/soundextensions.cpp} (76%) create mode 100644 apps/openmw/mwscript/soundextensions.hpp delete mode 100644 apps/openmw/mwsound/extensions.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 216627786..78b06d2b4 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -35,6 +35,7 @@ set(GAMESCRIPT mwscript/cellextensions.cpp mwscript/miscextensions.cpp mwscript/guiextensions.cpp + mwscript/soundextensions.cpp mwscript/extensions.cpp mwscript/globalscripts.cpp ) @@ -46,17 +47,16 @@ set(GAMESCRIPT_HEADER mwscript/cellextensions.hpp mwscript/miscextensions.hpp mwscript/guiextensions.hpp + mwscript/soundextensions.hpp mwscript/extensions.hpp mwscript/globalscripts.hpp ) source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER}) set(GAMESOUND - mwsound/soundmanager.cpp - mwsound/extensions.cpp) + mwsound/soundmanager.cpp) set(GAMESOUND_HEADER - mwsound/soundmanager.hpp - mwsound/extensions.hpp) + mwsound/soundmanager.hpp) source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER}) set(GAMEGUI diff --git a/apps/openmw/mwscript/extensions.cpp b/apps/openmw/mwscript/extensions.cpp index e309d632c..b688b2037 100644 --- a/apps/openmw/mwscript/extensions.cpp +++ b/apps/openmw/mwscript/extensions.cpp @@ -1,8 +1,7 @@ #include "extensions.hpp" -#include "../mwsound/extensions.hpp" - +#include "soundextensions.hpp" #include "cellextensions.hpp" #include "miscextensions.hpp" #include "guiextensions.hpp" @@ -14,7 +13,7 @@ namespace MWScript Cell::registerExtensions (extensions); Misc::registerExtensions (extensions); Gui::registerExtensions (extensions); - MWSound::registerExtensions (extensions); + Sound::registerExtensions (extensions); } } diff --git a/apps/openmw/mwscript/scriptmanager.cpp b/apps/openmw/mwscript/scriptmanager.cpp index 912e959ae..926dcb699 100644 --- a/apps/openmw/mwscript/scriptmanager.cpp +++ b/apps/openmw/mwscript/scriptmanager.cpp @@ -15,8 +15,7 @@ #include #include -#include "../mwsound/extensions.hpp" - +#include "soundextensions.hpp" #include "cellextensions.hpp" #include "miscextensions.hpp" #include "guiextensions.hpp" @@ -125,7 +124,7 @@ namespace MWScript Cell::installOpcodes (interpreter); Misc::installOpcodes (interpreter); Gui::installOpcodes (interpreter); - MWSound::installOpcodes (interpreter); + Sound::installOpcodes (interpreter); } } diff --git a/apps/openmw/mwsound/extensions.cpp b/apps/openmw/mwscript/soundextensions.cpp similarity index 76% rename from apps/openmw/mwsound/extensions.cpp rename to apps/openmw/mwscript/soundextensions.cpp index 4aee9827c..33de38103 100644 --- a/apps/openmw/mwsound/extensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -7,15 +7,15 @@ #include #include -#include "../mwscript/interpretercontext.hpp" +#include "interpretercontext.hpp" #include "../mwworld/world.hpp" -#include "soundmanager.hpp" +#include "../mwsound/soundmanager.hpp" -namespace MWSound +namespace MWScript { - namespace Script + namespace Sound { class OpSay : public Interpreter::Opcode0 { @@ -198,39 +198,35 @@ namespace MWSound const int opcodePlayLoopSound3DVP = 0x2000009; const int opcodeStopSound = 0x200000a; const int opcodeGetSoundPlaying = 0x200000b; - } - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("say", "SS", Script::opcodeSay); - extensions.registerFunction ("saydone", 'l', "", Script::opcodeSayDone); - extensions.registerInstruction ("streammusic", "S", Script::opcodeStreamMusic); - extensions.registerInstruction ("playsound", "c", Script::opcodePlaySound); - extensions.registerInstruction ("playsoundvp", "cff", Script::opcodePlaySoundVP); - extensions.registerInstruction ("playsound3d", "c", Script::opcodePlaySound3D); - extensions.registerInstruction ("playsound3dvp", "cff", Script::opcodePlaySound3DVP); - extensions.registerInstruction ("playloopsound3d", "c", Script::opcodePlayLoopSound3D); - extensions.registerInstruction ("playloopsound3dvp", "cff", - Script::opcodePlayLoopSound3DVP); - extensions.registerInstruction ("stopsound", "c", Script::opcodeStopSound); - extensions.registerFunction ("getsoundplaying", 'l', "c", Script::opcodeGetSoundPlaying); - } - - void installOpcodes (Interpreter::Interpreter& interpreter) - { - interpreter.installSegment5 (Script::opcodeSay, new Script::OpSay); - interpreter.installSegment5 (Script::opcodeSayDone, new Script::OpSayDone); - interpreter.installSegment5 (Script::opcodeStreamMusic, new Script::OpStreamMusic); - interpreter.installSegment5 (Script::opcodePlaySound, new Script::OpPlaySound); - interpreter.installSegment5 (Script::opcodePlaySoundVP, new Script::OpPlaySoundVP); - interpreter.installSegment5 (Script::opcodePlaySound3D, new Script::OpPlaySound3D (false)); - interpreter.installSegment5 (Script::opcodePlaySound3DVP, - new Script::OpPlaySoundVP3D (false)); - interpreter.installSegment5 (Script::opcodePlayLoopSound3D, - new Script::OpPlaySound3D (true)); - interpreter.installSegment5 (Script::opcodePlayLoopSound3DVP, - new Script::OpPlaySoundVP3D (true)); - interpreter.installSegment5 (Script::opcodeStopSound, new Script::OpStopSound); - interpreter.installSegment5 (Script::opcodeGetSoundPlaying, new Script::OpGetSoundPlaying); - } + void registerExtensions (Compiler::Extensions& extensions) + { + extensions.registerInstruction ("say", "SS", opcodeSay); + extensions.registerFunction ("saydone", 'l', "", opcodeSayDone); + extensions.registerInstruction ("streammusic", "S", opcodeStreamMusic); + extensions.registerInstruction ("playsound", "c", opcodePlaySound); + extensions.registerInstruction ("playsoundvp", "cff", opcodePlaySoundVP); + extensions.registerInstruction ("playsound3d", "c", opcodePlaySound3D); + extensions.registerInstruction ("playsound3dvp", "cff", opcodePlaySound3DVP); + extensions.registerInstruction ("playloopsound3d", "c", opcodePlayLoopSound3D); + extensions.registerInstruction ("playloopsound3dvp", "cff", opcodePlayLoopSound3DVP); + extensions.registerInstruction ("stopsound", "c", opcodeStopSound); + extensions.registerFunction ("getsoundplaying", 'l', "c", opcodeGetSoundPlaying); + } + + void installOpcodes (Interpreter::Interpreter& interpreter) + { + interpreter.installSegment5 (opcodeSay, new OpSay); + interpreter.installSegment5 (opcodeSayDone, new OpSayDone); + interpreter.installSegment5 (opcodeStreamMusic, new OpStreamMusic); + interpreter.installSegment5 (opcodePlaySound, new OpPlaySound); + interpreter.installSegment5 (opcodePlaySoundVP, new OpPlaySoundVP); + interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D (false)); + interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D (false)); + interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D (true)); + interpreter.installSegment5 (opcodePlayLoopSound3DVP, new OpPlaySoundVP3D (true)); + interpreter.installSegment5 (opcodeStopSound, new OpStopSound); + interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying); + } + } } diff --git a/apps/openmw/mwscript/soundextensions.hpp b/apps/openmw/mwscript/soundextensions.hpp new file mode 100644 index 000000000..85416a6df --- /dev/null +++ b/apps/openmw/mwscript/soundextensions.hpp @@ -0,0 +1,27 @@ +#ifndef GAME_SCRIPT_SOUNDEXTENSIONS_H +#define GAME_SCRIPT_SOUNDEXTENSIONS_H + +namespace Compiler +{ + class Extensions; +} + +namespace Interpreter +{ + class Interpreter; +} + +namespace MWScript +{ + namespace Sound + { + // Script-extensions related to sound + + void registerExtensions (Compiler::Extensions& extensions); + + void installOpcodes (Interpreter::Interpreter& interpreter); + } +} + +#endif + diff --git a/apps/openmw/mwsound/extensions.hpp b/apps/openmw/mwsound/extensions.hpp deleted file mode 100644 index 0e860952a..000000000 --- a/apps/openmw/mwsound/extensions.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef GAME_SOUND_EXTENSIONS_H -#define GAME_SOUND_EXTENSIONS_H - -namespace Compiler -{ - class Extensions; -} - -namespace Interpreter -{ - class Interpreter; -} - -namespace MWSound -{ - // Script-extensions related to sound - - void registerExtensions (Compiler::Extensions& extensions); - - void installOpcodes (Interpreter::Interpreter& interpreter); -} - -#endif -