diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-06-21 18:40:46 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-06-21 18:40:46 +0000 |
commit | b048ea322fac0d6cb59b9f1645fad9d7a898fc57 (patch) | |
tree | 77cab073f0cca54369cf47dadb973bf45d640e15 /plugins/MirLua/src | |
parent | 78f36745d03f03d4772e09720eef976cff5a4d9b (diff) |
MirLua: Scripts reloading pt.2
git-svn-id: http://svn.miranda-ng.org/main/trunk@14304 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src')
-rw-r--r-- | plugins/MirLua/src/m_core.cpp | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/m_database.cpp | 2 | ||||
-rw-r--r-- | plugins/MirLua/src/m_genmenu.cpp | 7 | ||||
-rw-r--r-- | plugins/MirLua/src/main.cpp | 5 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 29 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_options.cpp | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/stdafx.h | 2 |
7 files changed, 18 insertions, 35 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index e71c20471d..72d899e5b9 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -169,8 +169,8 @@ static int lua_Translate(lua_State *L) {
char *what = (char*)luaL_checkstring(L, 1);
- ptrT value(mir_utf8decodeT(what, NULL));
- lua_pushstring(L, T2Utf(TranslateTS(value)));
+ ptrT value(mir_utf8decodeT(what));
+ lua_pushstring(L, T2Utf(TranslateW_LP(value, hScriptsLangpack)));
return 1;
}
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 5aedf56b8f..18ac994cfd 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -111,7 +111,7 @@ static int lua_DeleteModule(lua_State *L) MCONTACT hContact = lua_tointeger(L, 1);
LPCSTR szModule = luaL_checkstring(L, 2);
- INT_PTR res = ::CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule);
+ INT_PTR res = ::CallService(MS_DB_MODULE_DELETE, hContact, (LPARAM)szModule);
lua_pushinteger(L, res);
return 1;
diff --git a/plugins/MirLua/src/m_genmenu.cpp b/plugins/MirLua/src/m_genmenu.cpp index fb651b1515..4f1162ba9b 100644 --- a/plugins/MirLua/src/m_genmenu.cpp +++ b/plugins/MirLua/src/m_genmenu.cpp @@ -4,6 +4,7 @@ static CLISTMENUITEM* MakeMenuItem(lua_State *L) {
CLISTMENUITEM *pmi = (CLISTMENUITEM*)mir_calloc(sizeof(CLISTMENUITEM));
pmi->cbSize = sizeof(CLISTMENUITEM);
+ pmi->hLangpack = hScriptsLangpack;
lua_pushstring(L, "Flags");
lua_gettable(L, -2);
@@ -51,7 +52,7 @@ static int lua_AddMainMenuItem(lua_State *L) mir_ptr<CLISTMENUITEM> pmi(MakeMenuItem(L));
- HGENMENU res = ::Menu_AddMainMenuItem(pmi);
+ HGENMENU res = (HGENMENU)::CallService("CList/AddMainMenuItem", 0, (LPARAM)pmi);
lua_pushlightuserdata(L, res);
return 1;
@@ -67,7 +68,7 @@ static int lua_AddContactMenuItem(lua_State *L) mir_ptr<CLISTMENUITEM> pmi(MakeMenuItem(L));
- HGENMENU res = ::Menu_AddContactMenuItem(pmi);
+ HGENMENU res = (HGENMENU)::CallService("CList/AddContactMenuItem", 0, (LPARAM)pmi);
lua_pushlightuserdata(L, res);
return 1;
@@ -83,7 +84,7 @@ static int lua_AddTrayMenuItem(lua_State *L) mir_ptr<CLISTMENUITEM> pmi(MakeMenuItem(L));
- HGENMENU res = ::Menu_AddTrayMenuItem(pmi);
+ HGENMENU res = (HGENMENU)::CallService("CList/AddTrayMenuItem", 0, (LPARAM)pmi);
lua_pushlightuserdata(L, res);
return 1;
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp index 8e9c71c812..b7062abd7f 100644 --- a/plugins/MirLua/src/main.cpp +++ b/plugins/MirLua/src/main.cpp @@ -1,6 +1,8 @@ #include "stdafx.h"
int hLangpack;
+int hScriptsLangpack;
+
HINSTANCE g_hInstance;
HANDLE g_hCommonFolderPath;
@@ -76,9 +78,6 @@ extern "C" int __declspec(dllexport) Load(void) g_mLua = new CMLua();
- CLuaLoader loader(g_mLua);
- loader.LoadScripts();
-
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
return 0;
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 5945947441..f9772e0021 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -23,39 +23,24 @@ void CMLua::Load() lua_pop(L, 1);
LoadMirandaModules();
+
+ hScriptsLangpack = GetPluginLangId(MIID_LAST, 0);
+
+ CLuaLoader loader(this);
+ loader.LoadScripts();
}
void CMLua::Unload()
{
if (L)
lua_close(L);
+ KillModuleMenus(hScriptsLangpack);
}
void CMLua::Reload()
{
- /*lua_getglobal(L, "m");
- lua_getfield(L, -1, "OnPreShutdown");
- if (lua_isfunction(L, -1))
- {
- lua_pushlightuserdata(L, NULL);
- lua_pushlightuserdata(L, NULL);
- if (lua_pcall(L, 2, 1, 0))
- printf("%s\n", lua_tostring(L, -1));
- }
- lua_pop(L, 1);*/
Unload();
-
Load();
- /*lua_getglobal(L, "m");
- lua_getfield(L, -1, "OnModulesLoaded");
- if (lua_isfunction(L, -1))
- {
- lua_pushlightuserdata(L, NULL);
- lua_pushlightuserdata(L, NULL);
- if (lua_pcall(L, 2, 1, 0))
- printf("%s\n", lua_tostring(L, -1));
- }
- lua_pop(L, 1);*/
}
void CMLua::LoadModule(const char *name, lua_CFunction loader)
@@ -69,7 +54,7 @@ void CMLua::LoadModule(const char *name, lua_CFunction loader) void CMLua::LoadCoreModule()
{
luaL_newlib(L, coreLib);
- lua_pushlightuserdata(L, NULL); + lua_pushlightuserdata(L, NULL);
lua_setfield(L, -2, "NULL");
lua_setglobal(L, "m");
}
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp index 8cd86f0f3d..89fe72af98 100644 --- a/plugins/MirLua/src/mlua_options.cpp +++ b/plugins/MirLua/src/mlua_options.cpp @@ -22,8 +22,6 @@ void CLuaOptions::LoadScripts(const TCHAR *scriptDir, int iGroup) TCHAR searchMask[MAX_PATH];
mir_sntprintf(searchMask, _T("%s\\%s"), scriptDir, _T("*.lua"));
- TCHAR fullPath[MAX_PATH], path[MAX_PATH];
-
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(searchMask, &fd);
if (hFind != INVALID_HANDLE_VALUE)
@@ -105,6 +103,4 @@ INT_PTR CLuaOptions::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) void CLuaOptions::OnReload(CCtrlBase*)
{
g_mLua->Reload();
- CLuaLoader loader(g_mLua);
- loader.LoadScripts();
}
\ No newline at end of file diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 1d9ca47929..b7bd486bac 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -41,6 +41,8 @@ extern "C" extern CMLua *g_mLua;
+extern int hScriptsLangpack;
+
extern HINSTANCE g_hInstance;
extern HANDLE g_hCommonFolderPath;
|