From 679b23b4d1c5b2d935085b199d9327bec8477378 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 28 Oct 2015 20:12:50 +0000 Subject: MirLua: - internal icons added to iconlib - minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@15641 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_core.cpp | 2 +- plugins/MirLua/src/m_genmenu.cpp | 4 ++-- plugins/MirLua/src/m_icolib.cpp | 2 +- plugins/MirLua/src/m_protocols.cpp | 6 ++---- plugins/MirLua/src/main.cpp | 2 ++ plugins/MirLua/src/mlua_icons.cpp | 31 +++++++++++++++++++++++++++++++ plugins/MirLua/src/mlua_options.cpp | 16 +++++++--------- plugins/MirLua/src/resource.h | 3 ++- plugins/MirLua/src/stdafx.h | 4 ++++ 9 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 plugins/MirLua/src/mlua_icons.cpp (limited to 'plugins/MirLua/src') diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp index 48e54dd8c6..228a0d6f38 100644 --- a/plugins/MirLua/src/m_core.cpp +++ b/plugins/MirLua/src/m_core.cpp @@ -182,7 +182,7 @@ static int lua_IsPluginLoaded(lua_State *L) const char *value = lua_tostring(L, 1); MUUID uuid = { 0 }; - int res = sscanf_s(value, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", + int res = sscanf_s(value, "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}", &uuid.a, &uuid.b, &uuid.c, &uuid.d[0], &uuid.d[1], &uuid.d[2], &uuid.d[3], &uuid.d[4], &uuid.d[5], &uuid.d[6], &uuid.d[7]) == 11; if (res == TRUE) res = ::IsPluginLoaded(uuid); diff --git a/plugins/MirLua/src/m_genmenu.cpp b/plugins/MirLua/src/m_genmenu.cpp index ddc04b5549..09b64bbc65 100644 --- a/plugins/MirLua/src/m_genmenu.cpp +++ b/plugins/MirLua/src/m_genmenu.cpp @@ -20,8 +20,8 @@ void MakeMenuItem(lua_State *L, CMenuItem &mi) unsigned long a; unsigned short b, c; unsigned char d[8]; - if (sscanf_s(uuid, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", - &mi.uid.a, &mi.uid.b, &mi.uid.c, &mi.uid.d[0], &mi.uid.d[1], &mi.uid.d[2], &mi.uid.d[3], &mi.uid.d[4], &mi.uid.d[5], &mi.uid.d[6], &mi.uid.d[7]) == 11) + if (sscanf_s(uuid, "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}", + &a, &b, &c, &d[0], &d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7]) == 11) SET_UID(mi, a, b, c, d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7]); } lua_pop(L, 1); diff --git a/plugins/MirLua/src/m_icolib.cpp b/plugins/MirLua/src/m_icolib.cpp index f94959268b..30146cd503 100644 --- a/plugins/MirLua/src/m_icolib.cpp +++ b/plugins/MirLua/src/m_icolib.cpp @@ -15,7 +15,7 @@ static int lua_AddIcon(lua_State *L) si.description.t = description; si.section.t = section; si.defaultFile.t = filePath; - si.iDefaultIndex = -IDI_ICON; + si.hDefaultIcon = GetIcon(IDI_SCRIPT); HANDLE res = ::IcoLib_AddIcon(&si, hScriptsLangpack); lua_pushlightuserdata(L, res); diff --git a/plugins/MirLua/src/m_protocols.cpp b/plugins/MirLua/src/m_protocols.cpp index 3d9908a61a..9aa4b4f753 100644 --- a/plugins/MirLua/src/m_protocols.cpp +++ b/plugins/MirLua/src/m_protocols.cpp @@ -18,9 +18,8 @@ static int lua_GetProto(lua_State *L) const char *name = luaL_checkstring(L, 1); PROTOCOLDESCRIPTOR* pd = ::Proto_IsProtocolLoaded(ptrA(mir_utf8decodeA(name))); - if (pd) - MapToTable(L, pd); + lua_pushlightuserdata(L, pd); else lua_pushnil(L); @@ -121,9 +120,8 @@ static int lua_GetAccount(lua_State *L) ptrA moduleName(mir_utf8decodeA(luaL_checkstring(L, 1))); PROTOACCOUNT* pa = ::Proto_GetAccount(moduleName); - if (pa) - MapToTable(L, pa); + lua_pushlightuserdata(L, pa); else lua_pushnil(L); diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp index 5381b34c19..fabad6a287 100644 --- a/plugins/MirLua/src/main.cpp +++ b/plugins/MirLua/src/main.cpp @@ -48,6 +48,8 @@ int OnModulesLoaded(WPARAM, LPARAM) hRecvMessage = CreateHookableEvent(MODULE PSR_MESSAGE); CreateProtoServiceFunction(MODULE, PSR_MESSAGE, FilterRecvMessage); + InitIcons(); + g_mLua = new CMLua(); g_mLua->Load(); diff --git a/plugins/MirLua/src/mlua_icons.cpp b/plugins/MirLua/src/mlua_icons.cpp new file mode 100644 index 0000000000..7b0e9c37f3 --- /dev/null +++ b/plugins/MirLua/src/mlua_icons.cpp @@ -0,0 +1,31 @@ +#include "stdafx.h" + +IconItemT Icons[] = +{ + { LPGENT("Script"), "script", IDI_SCRIPT }, + { LPGENT("Open"), "open", IDI_OPEN }, + { LPGENT("Reload") , "reload", IDI_RELOAD }, +}; + +void InitIcons() +{ + Icon_RegisterT(g_hInstance, LPGENT(MODULE), Icons, _countof(Icons), MODULE); +} + +HICON GetIcon(int iconId) +{ + for (size_t i = 0; i < _countof(Icons); i++) + if (Icons[i].defIconID == iconId) + return IcoLib_GetIconByHandle(Icons[i].hIcolib); + + return NULL; +} + +HANDLE GetIconHandle(int iconId) +{ + for (size_t i = 0; i < _countof(Icons); i++) + if (Icons[i].defIconID == iconId) + return Icons[i].hIcolib; + + return NULL; +} \ No newline at end of file diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp index e6bcbbd0c3..3aad7345cd 100644 --- a/plugins/MirLua/src/mlua_options.cpp +++ b/plugins/MirLua/src/mlua_options.cpp @@ -72,8 +72,8 @@ void CLuaOptions::OnInitDialog() m_scripts.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_INFOTIP); HIMAGELIST hImageList = m_scripts.CreateImageList(LVSIL_SMALL); - ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_OPEN))); - ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_RELOAD))); + ImageList_AddIcon(hImageList, GetIcon(IDI_OPEN)); + ImageList_AddIcon(hImageList, GetIcon(IDI_RELOAD)); TCHAR scriptDir[MAX_PATH], relativeScriptDir[MAX_PATH], header[MAX_PATH + 100]; FoldersGetCustomPathT(g_hCommonScriptFolder, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT)); @@ -84,9 +84,9 @@ void CLuaOptions::OnInitDialog() m_scripts.AddColumn(0, _T("Script"), 420); m_scripts.AddColumn(1, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL)); -#ifdef DEBUG +//#ifdef DEBUG m_scripts.AddColumn(2, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL)); -#endif +//#endif LoadScripts(); @@ -144,16 +144,14 @@ void CLuaOptions::OnScriptListClick(CCtrlListView::TEventInfo *evt) CMLuaScript* script = (CMLuaScript*)lvi.lParam; if (lvi.iSubItem == 1) - { - ShellExecute(m_hwnd, NULL, lvi.pszText, NULL, script->GetFilePath(), SW_SHOWNORMAL); - } -#ifdef DEBUG + ShellExecute(m_hwnd, _T("Open"), script->GetFilePath(), NULL, NULL, SW_SHOWNORMAL); +//#ifdef DEBUG else if (lvi.iSubItem == 2) { script->Unload(); script->Load(); } -#endif +//#endif mir_free(lvi.pszText); } diff --git a/plugins/MirLua/src/resource.h b/plugins/MirLua/src/resource.h index d94ef6d1b1..ad362f5cce 100644 --- a/plugins/MirLua/src/resource.h +++ b/plugins/MirLua/src/resource.h @@ -1,8 +1,9 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by D:\Projects\MirandaNG\plugins\MirLua\res\resource.rc +// Used by E:\Projects\C++\MirandaNG\plugins\MirLua\res\resource.rc // #define IDI_ICON 100 +#define IDI_SCRIPT 100 #define IDI_OPEN 105 #define IDD_OPTIONS 106 #define IDI_RELOAD 107 diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 72ed4cc247..552ff7b89c 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -112,6 +112,10 @@ bool luaM_toboolean(lua_State *L, int idx); WPARAM luaM_towparam(lua_State *L, int idx); LPARAM luaM_tolparam(lua_State *L, int idx); +void InitIcons(); +HICON GetIcon(int iconId); +HANDLE GetIconHandle(int iconId); + void ShowNotification(const char *caption, const char *message, int flags, MCONTACT hContact); void ObsoleteMethod(lua_State *L, const char *message); -- cgit v1.2.3