summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MirLua/src/m_genmenu.cpp23
-rw-r--r--plugins/MirLua/src/m_icolib.cpp8
-rw-r--r--plugins/MirLua/src/m_sounds.cpp (renamed from plugins/MirLua/src/m_sound.cpp)10
-rw-r--r--plugins/MirLua/src/m_windows.cpp14
-rw-r--r--plugins/MirLua/src/mlua_module_loader.cpp2
-rw-r--r--plugins/MirLua/src/stdafx.h4
6 files changed, 36 insertions, 25 deletions
diff --git a/plugins/MirLua/src/m_genmenu.cpp b/plugins/MirLua/src/m_genmenu.cpp
index 64ff383ac6..8bad0c23c9 100644
--- a/plugins/MirLua/src/m_genmenu.cpp
+++ b/plugins/MirLua/src/m_genmenu.cpp
@@ -47,7 +47,7 @@ void MakeMenuItem(lua_State *L, CMenuItem &mi)
static int lua_CreateRoot(lua_State *L)
{
- int hMenuObject = lua_tointeger(L, 1);
+ int hMenuObject = luaL_checkinteger(L, 1);
const char *name = luaL_checkstring(L, 2);
int position = lua_tointeger(L, 3);
HANDLE hIcon = (HANDLE)lua_touserdata(L, 4);
@@ -60,7 +60,7 @@ static int lua_CreateRoot(lua_State *L)
static int lua_AddMenuItem(lua_State *L)
{
- int hMenuObject = lua_tointeger(L, 1);
+ int hMenuObject = luaL_checkinteger(L, 1);
if (lua_type(L, 2) != LUA_TTABLE)
{
@@ -71,7 +71,7 @@ static int lua_AddMenuItem(lua_State *L)
CMenuItem mi;
MakeMenuItem(L, mi);
- HGENMENU res = ::Menu_AddItem(hMenuObject, &mi, NULL);
+ HGENMENU res = Menu_AddItem(hMenuObject, &mi, NULL);
lua_pushlightuserdata(L, res);
return 1;
@@ -79,6 +79,7 @@ static int lua_AddMenuItem(lua_State *L)
static int lua_ModifyMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
ptrT name(mir_utf8decodeT(lua_tostring(L, 2)));
HANDLE hIcolibItem = lua_touserdata(L, 3);
@@ -87,47 +88,51 @@ static int lua_ModifyMenuItem(lua_State *L)
if (!(flags & CMIF_UNICODE))
flags |= CMIF_UNICODE;
- INT_PTR res = ::Menu_ModifyItem(hMenuItem, name, hIcolibItem, flags);
+ INT_PTR res = Menu_ModifyItem(hMenuItem, name, hIcolibItem, flags);
lua_pushinteger(L, res);
return 1;
}
static int lua_ShowMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
bool isShow = luaM_toboolean(L, 2);
- ::Menu_ShowItem(hMenuItem, isShow);
+ Menu_ShowItem(hMenuItem, isShow);
return 0;
}
static int lua_EnableMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
bool isEnable = luaM_toboolean(L, 2);
- ::Menu_EnableItem(hMenuItem, isEnable);
+ Menu_EnableItem(hMenuItem, isEnable);
return 0;
}
static int lua_CheckMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
bool isChecked = luaM_toboolean(L, 2);
- ::Menu_SetChecked(hMenuItem, isChecked);
+ Menu_SetChecked(hMenuItem, isChecked);
return 0;
}
static int lua_RemoveMenuItem(lua_State *L)
{
+ luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
HGENMENU hMenuItem = (HGENMENU)lua_touserdata(L, 1);
- INT_PTR res = ::Menu_RemoveItem(hMenuItem);
- lua_pushinteger(L, res);
+ INT_PTR res = Menu_RemoveItem(hMenuItem);
+ lua_pushboolean(L, res == 0);
return 1;
}
diff --git a/plugins/MirLua/src/m_icolib.cpp b/plugins/MirLua/src/m_icolib.cpp
index 5b2a5b23a3..733fab90e0 100644
--- a/plugins/MirLua/src/m_icolib.cpp
+++ b/plugins/MirLua/src/m_icolib.cpp
@@ -35,18 +35,12 @@ static int lua_GetIcon(lua_State *L)
static int lua_RemoveIcon(lua_State *L)
{
- INT_PTR res = 0;
-
if (lua_isuserdata(L, 1))
::IcoLib_RemoveIconByHandle(lua_touserdata(L, 1));
else if (lua_isstring(L, 1))
::IcoLib_RemoveIcon(luaL_checkstring(L, 1));
- else
- res = 1;
- lua_pushinteger(L, res);
-
- return 1;
+ return 0;
}
static luaL_Reg icolibApi[] =
diff --git a/plugins/MirLua/src/m_sound.cpp b/plugins/MirLua/src/m_sounds.cpp
index 3411f72971..8630c53093 100644
--- a/plugins/MirLua/src/m_sound.cpp
+++ b/plugins/MirLua/src/m_sounds.cpp
@@ -1,6 +1,6 @@
#include "stdafx.h"
-static int lua_Add(lua_State *L)
+static int lua_AddSound(lua_State *L)
{
ptrA name(mir_utf8decodeA(luaL_checkstring(L, 1)));
ptrT description(mir_utf8decodeT(luaL_checkstring(L, 2)));
@@ -22,7 +22,7 @@ static int lua_Add(lua_State *L)
return 1;
}
-static int lua_Play(lua_State *L)
+static int lua_PlaySound(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
@@ -44,15 +44,15 @@ static int lua_PlayFile(lua_State *L)
static luaL_Reg soundApi[] =
{
- { "Add", lua_Add },
- { "Play", lua_Play },
+ { "AddSound", lua_AddSound },
+ { "PlaySound", lua_PlaySound },
{ "PlayFile", lua_PlayFile },
{ NULL, NULL }
};
-LUAMOD_API int luaopen_m_sound(lua_State *L)
+LUAMOD_API int luaopen_m_sounds(lua_State *L)
{
luaL_newlib(L, soundApi);
diff --git a/plugins/MirLua/src/m_windows.cpp b/plugins/MirLua/src/m_windows.cpp
index b78f9f7278..160f632974 100644
--- a/plugins/MirLua/src/m_windows.cpp
+++ b/plugins/MirLua/src/m_windows.cpp
@@ -147,7 +147,7 @@ static int lua_FindIterator(lua_State *L)
static int lua_Find(lua_State *L)
{
- TCHAR* path = mir_utf8decodeT(luaL_checkstring(L, 1));
+ TCHAR *path = mir_utf8decodeT(luaL_checkstring(L, 1));
lua_pushlightuserdata(L, NULL);
lua_pushlightuserdata(L, path);
@@ -156,6 +156,16 @@ static int lua_Find(lua_State *L)
return 1;
}
+static int lua_GetKeyState(lua_State *L)
+{
+ int vKey = luaL_checkinteger(L, 1);
+
+ int res = GetKeyState(vKey);
+ lua_pushinteger(L, res);
+
+ return 1;
+}
+
static int lua_GetIniValue(lua_State *L)
{
ptrT path(mir_utf8decodeT(luaL_checkstring(L, 1)));
@@ -358,6 +368,8 @@ static luaL_Reg winApi[] =
{ "Find", lua_Find },
+ { "GetKeyState", lua_GetKeyState },
+
{ "GetIniValue", lua_GetIniValue },
{ "SetIniValue", lua_SetIniValue },
{ "DeleteIniValue", lua_DeleteIniValue },
diff --git a/plugins/MirLua/src/mlua_module_loader.cpp b/plugins/MirLua/src/mlua_module_loader.cpp
index e6fc4e2251..a4cce4f418 100644
--- a/plugins/MirLua/src/mlua_module_loader.cpp
+++ b/plugins/MirLua/src/mlua_module_loader.cpp
@@ -26,7 +26,7 @@ void CLuaModuleLoader::LoadModules()
PreloadModule(MLUA_POPUP, luaopen_m_popup);
PreloadModule(MLUA_PROTOCOLS, luaopen_m_protocols);
PreloadModule(MLUA_SCHEDULE, luaopen_m_schedule);
- PreloadModule(MLUA_SOUND, luaopen_m_sound);
+ PreloadModule(MLUA_SOUNDS, luaopen_m_sounds);
PreloadModule(MLUA_TOPTOOLBAR, luaopen_m_toptoolbar);
PreloadModule(MLUA_VARIABLES, luaopen_m_variables);
PreloadModule(MLUA_WINDOWS, luaopen_m_windows);
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h
index 3eb5c82241..2192f19872 100644
--- a/plugins/MirLua/src/stdafx.h
+++ b/plugins/MirLua/src/stdafx.h
@@ -99,8 +99,8 @@ LUAMOD_API int (luaopen_m_popup)(lua_State *L);
#include "m_schedule.h"
-#define MLUA_SOUND "m_sound"
-LUAMOD_API int (luaopen_m_sound)(lua_State *L);
+#define MLUA_SOUNDS "m_sounds"
+LUAMOD_API int (luaopen_m_sounds)(lua_State *L);
#include "m_toptoolbar.h"