summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirLua/src/m_sound.cpp')
-rw-r--r--plugins/MirLua/src/m_sound.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/MirLua/src/m_sound.cpp b/plugins/MirLua/src/m_sound.cpp
new file mode 100644
index 0000000000..00b3bdf963
--- /dev/null
+++ b/plugins/MirLua/src/m_sound.cpp
@@ -0,0 +1,48 @@
+#include "stdafx.h"
+
+static int lua_Add(lua_State *L)
+{
+ ptrA name(mir_utf8decodeA(luaL_checkstring(L, 1)));
+ ptrT description(mir_utf8decodeT(luaL_checkstring(L, 2)));
+ ptrT section(mir_utf8decodeT(luaL_optstring(L, 3, MODULE)));
+
+ TCHAR filePath[MAX_PATH];
+ GetModuleFileName(g_hInstance, filePath, _countof(filePath));
+
+ SKINSOUNDDESCEX ssd = { sizeof(SKINSOUNDDESCEX) };
+ ssd.pszName = name;
+ ssd.dwFlags = SSDF_TCHAR;
+ ssd.ptszDescription = description;
+ ssd.ptszSection = section;
+ ssd.ptszDefaultFile = filePath;
+
+ INT_PTR res = ::CallService("Skin/Sounds/AddNew", hLangpack, (LPARAM)&ssd);
+ lua_pushnumber(L, res);
+
+ return 1;
+}
+
+static int lua_Play(lua_State *L)
+{
+ const char *name = luaL_checkstring(L, 1);
+
+ INT_PTR res = SkinPlaySound(name);
+ lua_pushnumber(L, res);
+
+ return 1;
+}
+
+static luaL_Reg soundApi[] =
+{
+ { "Add", lua_Add },
+ { "Play", lua_Play },
+
+ { NULL, NULL }
+};
+
+LUAMOD_API int luaopen_m_sound(lua_State *L)
+{
+ luaL_newlib(L, soundApi);
+
+ return 1;
+}