summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_sounds.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-12-14 20:37:32 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-12-14 20:37:32 +0000
commit2b962e1ce27336c7ce3a028a8b5f58f8b3a79e78 (patch)
tree40c53728ed43985b4a76131e881d1f9536b6bd95 /plugins/MirLua/src/m_sounds.cpp
parent31df706da55782980a13328303da309bd4c38ad5 (diff)
MirLua: minor fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@15863 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_sounds.cpp')
-rw-r--r--plugins/MirLua/src/m_sounds.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/plugins/MirLua/src/m_sounds.cpp b/plugins/MirLua/src/m_sounds.cpp
new file mode 100644
index 0000000000..8630c53093
--- /dev/null
+++ b/plugins/MirLua/src/m_sounds.cpp
@@ -0,0 +1,60 @@
+#include "stdafx.h"
+
+static int lua_AddSound(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_PlaySound(lua_State *L)
+{
+ const char *name = luaL_checkstring(L, 1);
+
+ INT_PTR res = SkinPlaySound(name);
+ lua_pushnumber(L, res);
+
+ return 1;
+}
+
+static int lua_PlayFile(lua_State *L)
+{
+ const char *path = luaL_checkstring(L, 1);
+
+ INT_PTR res = SkinPlaySoundFile(ptrT(mir_utf8decodeT(path)));
+ lua_pushnumber(L, res);
+
+ return 1;
+}
+
+static luaL_Reg soundApi[] =
+{
+ { "AddSound", lua_AddSound },
+ { "PlaySound", lua_PlaySound },
+
+ { "PlayFile", lua_PlayFile },
+
+ { NULL, NULL }
+};
+
+LUAMOD_API int luaopen_m_sounds(lua_State *L)
+{
+ luaL_newlib(L, soundApi);
+
+ return 1;
+}