summaryrefslogtreecommitdiff
path: root/plugins/MirLua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirLua')
-rw-r--r--plugins/MirLua/src/Modules/m_clist.cpp8
-rw-r--r--plugins/MirLua/src/Modules/m_core.cpp2
-rw-r--r--plugins/MirLua/src/Modules/m_hotkeys.cpp4
-rw-r--r--plugins/MirLua/src/Modules/m_icolib.cpp3
-rw-r--r--plugins/MirLua/src/Modules/m_options.cpp5
-rw-r--r--plugins/MirLua/src/Modules/m_srmm.cpp3
-rw-r--r--plugins/MirLua/src/environment.cpp16
-rw-r--r--plugins/MirLua/src/environment.h2
-rw-r--r--plugins/MirLua/src/lua.cpp7
-rw-r--r--plugins/MirLua/src/options.cpp3
-rw-r--r--plugins/MirLua/src/plugin.cpp8
-rw-r--r--plugins/MirLua/src/stdafx.h1
12 files changed, 23 insertions, 39 deletions
diff --git a/plugins/MirLua/src/Modules/m_clist.cpp b/plugins/MirLua/src/Modules/m_clist.cpp
index c43ee1782e..0b6d390004 100644
--- a/plugins/MirLua/src/Modules/m_clist.cpp
+++ b/plugins/MirLua/src/Modules/m_clist.cpp
@@ -2,7 +2,7 @@
void MakeMenuItem(lua_State *L, CMenuItem &mi)
{
- mi.langId = CMLuaEnvironment::GetEnvironmentId(L);
+ mi.pPlugin = CMLuaEnvironment::GetEnvironmentId(L);
lua_getfield(L, -1, "Flags");
mi.flags = lua_tointeger(L, -1);
@@ -57,7 +57,7 @@ static int clist_AddMainMenuItem(lua_State *L)
{
luaL_checktype(L, 1, LUA_TTABLE);
- CMenuItem mi(g_plugin);
+ CMenuItem mi(&g_plugin);
MakeMenuItem(L, mi);
HGENMENU res = Menu_AddMainMenuItem(&mi);
@@ -88,7 +88,7 @@ static int clist_AddContactMenuItem(lua_State *L)
{
luaL_checktype(L, 1, LUA_TTABLE);
- CMenuItem mi(g_plugin);
+ CMenuItem mi(&g_plugin);
MakeMenuItem(L, mi);
ptrA szProto(mir_utf8decodeA(lua_tostring(L, 2)));
@@ -105,7 +105,7 @@ static int clist_AddTrayMenuItem(lua_State *L)
{
luaL_checktype(L, 1, LUA_TTABLE);
- CMenuItem mi(g_plugin);
+ CMenuItem mi(&g_plugin);
MakeMenuItem(L, mi);
HGENMENU res = Menu_AddTrayMenuItem(&mi);
diff --git a/plugins/MirLua/src/Modules/m_core.cpp b/plugins/MirLua/src/Modules/m_core.cpp
index 281aa288fe..36cbcb3dc4 100644
--- a/plugins/MirLua/src/Modules/m_core.cpp
+++ b/plugins/MirLua/src/Modules/m_core.cpp
@@ -222,7 +222,7 @@ static int core_Translate(lua_State *L)
char *what = (char*)luaL_checkstring(L, 1);
ptrW value(mir_utf8decodeW(what));
- lua_pushstring(L, T2Utf(TranslateW_LP(value, g_plugin.m_hLang)));
+ lua_pushstring(L, T2Utf(TranslateW_LP(value, &g_plugin)));
return 1;
}
diff --git a/plugins/MirLua/src/Modules/m_hotkeys.cpp b/plugins/MirLua/src/Modules/m_hotkeys.cpp
index 1245d2348f..a6c35fdefb 100644
--- a/plugins/MirLua/src/Modules/m_hotkeys.cpp
+++ b/plugins/MirLua/src/Modules/m_hotkeys.cpp
@@ -41,9 +41,7 @@ static int hotkeys_Register(lua_State *L)
HOTKEYDESC hk;
MakeHotkey(L, hk);
- int hScriptLangpack = CMLuaEnvironment::GetEnvironmentId(L);
-
- INT_PTR res = Hotkey_Register(&hk, hScriptLangpack);
+ INT_PTR res = Hotkey_Register(&hk, CMLuaEnvironment::GetEnvironmentId(L));
lua_pushboolean(L, res);
return 1;
diff --git a/plugins/MirLua/src/Modules/m_icolib.cpp b/plugins/MirLua/src/Modules/m_icolib.cpp
index 86b5163290..3f94e26894 100644
--- a/plugins/MirLua/src/Modules/m_icolib.cpp
+++ b/plugins/MirLua/src/Modules/m_icolib.cpp
@@ -69,8 +69,7 @@ static int lua_AddIcon(lua_State *L)
else
luaL_argerror(L, 1, luaL_typename(L, 1));
- int hScriptLangpack = CMLuaEnvironment::GetEnvironmentId(L);
- HANDLE res = IcoLib_AddIcon(&sid, hScriptLangpack);
+ HANDLE res = IcoLib_AddIcon(&sid, CMLuaEnvironment::GetEnvironmentId(L));
lua_pushlightuserdata(L, res);
mir_free((void*)sid.pszName);
diff --git a/plugins/MirLua/src/Modules/m_options.cpp b/plugins/MirLua/src/Modules/m_options.cpp
index 29383e89ad..bcb9c799d0 100644
--- a/plugins/MirLua/src/Modules/m_options.cpp
+++ b/plugins/MirLua/src/Modules/m_options.cpp
@@ -45,8 +45,7 @@ public:
void MakeOptionDialogPage(lua_State *L, OPTIONSDIALOGPAGE &odp)
{
- odp.hInstance = g_plugin.getInst();
- odp.langId = CMLuaEnvironment::GetEnvironmentId(L);
+ odp.pPlugin = CMLuaEnvironment::GetEnvironmentId(L);
lua_getfield(L, -1, "Flags");
odp.flags = luaL_optinteger(L, -1, ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE);
@@ -91,7 +90,7 @@ int opt_AddPage(lua_State *L)
luaL_checktype(L, 1, LUA_TLIGHTUSERDATA);
WPARAM wParam = (WPARAM)lua_touserdata(L, 1);
- OPTIONSDIALOGPAGE odp = { 0 };
+ OPTIONSDIALOGPAGE odp = {};
MakeOptionDialogPage(L, odp);
INT_PTR res = g_plugin.addOptions(wParam, &odp);
diff --git a/plugins/MirLua/src/Modules/m_srmm.cpp b/plugins/MirLua/src/Modules/m_srmm.cpp
index bbaf3edc3f..316a81171f 100644
--- a/plugins/MirLua/src/Modules/m_srmm.cpp
+++ b/plugins/MirLua/src/Modules/m_srmm.cpp
@@ -47,8 +47,7 @@ static int lua_AddButton(lua_State *L)
BBButton bbb = {};
MakeBBButton(L, bbb);
- int hScriptLangpack = CMLuaEnvironment::GetEnvironmentId(L);
- HANDLE res = Srmm_AddButton(&bbb, hScriptLangpack);
+ HANDLE res = Srmm_AddButton(&bbb, CMLuaEnvironment::GetEnvironmentId(L));
CleanBBButton(bbb);
if (!res) {
diff --git a/plugins/MirLua/src/environment.cpp b/plugins/MirLua/src/environment.cpp
index 76a34cbc55..88e7bff62b 100644
--- a/plugins/MirLua/src/environment.cpp
+++ b/plugins/MirLua/src/environment.cpp
@@ -8,16 +8,14 @@ CMLuaEnvironment::CMLuaEnvironment(lua_State *_l) :
CMPluginBase(nullptr, pluginInfoEx),
L(_l)
{
- MUUID muidLast = MIID_LAST;
- m_hLang = GetPluginLangId(muidLast, 0);
}
CMLuaEnvironment::~CMLuaEnvironment()
{
- KillModuleIcons(m_hLang);
- KillModuleSounds(m_hLang);
- KillModuleMenus(m_hLang);
- KillModuleHotkeys(m_hLang);
+ KillModuleIcons(this);
+ KillModuleSounds(this);
+ KillModuleMenus(this);
+ KillModuleHotkeys(this);
KillObjectEventHooks(this);
KillObjectServices(this);
@@ -41,12 +39,10 @@ CMLuaEnvironment* CMLuaEnvironment::GetEnvironment(lua_State *L)
return env;
}
-int CMLuaEnvironment::GetEnvironmentId(lua_State *L)
+HPLUGIN CMLuaEnvironment::GetEnvironmentId(lua_State *L)
{
CMLuaEnvironment *env = GetEnvironment(L);
- return env != nullptr
- ? env->m_hLang
- : g_hMLuaLangpack;
+ return env != nullptr ? HPLUGIN(env) : &g_plugin;
}
static int HookEventEnvParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param)
diff --git a/plugins/MirLua/src/environment.h b/plugins/MirLua/src/environment.h
index 1f05f1f986..7c2300b6d9 100644
--- a/plugins/MirLua/src/environment.h
+++ b/plugins/MirLua/src/environment.h
@@ -15,7 +15,7 @@ public:
virtual ~CMLuaEnvironment();
static CMLuaEnvironment* GetEnvironment(lua_State *L);
- static int GetEnvironmentId(lua_State *L);
+ static HPLUGIN GetEnvironmentId(lua_State *L);
HANDLE HookEvent(const char *name, int ref);
int UnhookEvent(HANDLE hHook);
diff --git a/plugins/MirLua/src/lua.cpp b/plugins/MirLua/src/lua.cpp
index dd2fd64606..7f96a2300f 100644
--- a/plugins/MirLua/src/lua.cpp
+++ b/plugins/MirLua/src/lua.cpp
@@ -2,19 +2,12 @@
CMLua::CMLua() : L(nullptr)
{
- //MUUID muidLast = MIID_LAST;
- //g_hMLuaLangpack = GetPluginLangId(muidLast, 0);
}
CMLua::~CMLua()
{
Log("Unloading lua engine");
- KillModuleIcons(g_hMLuaLangpack);
- KillModuleSounds(g_hMLuaLangpack);
- KillModuleMenus(g_hMLuaLangpack);
- KillModuleHotkeys(g_hMLuaLangpack);
-
KillObjectEventHooks(L);
KillObjectServices(L);
diff --git a/plugins/MirLua/src/options.cpp b/plugins/MirLua/src/options.cpp
index f6b0f4cd51..fe3ac6abba 100644
--- a/plugins/MirLua/src/options.cpp
+++ b/plugins/MirLua/src/options.cpp
@@ -25,6 +25,8 @@ static int ScriptStatusToIcon(ScriptStatus status)
case ScriptStatus::Failed:
return 1;
}
+
+ return 0;
}
void CMLuaOptions::LoadScripts()
@@ -163,7 +165,6 @@ void CMLuaOptions::OnReload(CCtrlBase*)
int OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {};
- odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE;
odp.szGroup.w = LPGENW("Services");
odp.szTitle.w = L"Lua";
diff --git a/plugins/MirLua/src/plugin.cpp b/plugins/MirLua/src/plugin.cpp
index 02a849b2dd..d8f1864c94 100644
--- a/plugins/MirLua/src/plugin.cpp
+++ b/plugins/MirLua/src/plugin.cpp
@@ -50,10 +50,10 @@ void CMPlugin::UnloadLua()
{
Scripts.destroy();
- KillModuleIcons(g_hMLuaLangpack);
- KillModuleSounds(g_hMLuaLangpack);
- KillModuleMenus(g_hMLuaLangpack);
- KillModuleHotkeys(g_hMLuaLangpack);
+ KillModuleIcons(this);
+ KillModuleSounds(this);
+ KillModuleMenus(this);
+ KillModuleHotkeys(this);
KillObjectEventHooks(lua->L);
KillObjectServices(lua->L);
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h
index 434dcb8e50..2aabb9c8a5 100644
--- a/plugins/MirLua/src/stdafx.h
+++ b/plugins/MirLua/src/stdafx.h
@@ -50,7 +50,6 @@ class CMLuaScript;
#define MODULENAME "MirLua"
-extern int g_hMLuaLangpack;
extern PLUGININFOEX g_pluginInfoEx;
extern HANDLE g_hCLibsFolder;