summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-06-16 15:58:53 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-06-16 15:58:53 +0000
commit35205b9114784ff8f9f40b04f9ec8e14a250e467 (patch)
treeae8cde6b6c520e9131a980577a2ec594218ecda6 /plugins/MirLua/src
parent6dc20e70f308daee742372a7978c1f65668186f3 (diff)
oops
git-svn-id: http://svn.miranda-ng.org/main/trunk@14208 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src')
-rw-r--r--plugins/MirLua/src/m_variables.cpp26
-rw-r--r--plugins/MirLua/src/mlua_options.cpp42
-rw-r--r--plugins/MirLua/src/mlua_options.h4
3 files changed, 71 insertions, 1 deletions
diff --git a/plugins/MirLua/src/m_variables.cpp b/plugins/MirLua/src/m_variables.cpp
new file mode 100644
index 0000000000..bb0b0d908e
--- /dev/null
+++ b/plugins/MirLua/src/m_variables.cpp
@@ -0,0 +1,26 @@
+#include "stdafx.h"
+
+static int lua_FormatString(lua_State *L)
+{
+ ptrT format(mir_utf8decodeT(luaL_checkstring(L, 1)));
+ MCONTACT hContact = lua_tointeger(L, 2);
+
+ TCHAR *res = variables_parse(format, NULL, hContact);
+ lua_pushstring(L, T2Utf(res));
+
+ return 1;
+}
+
+static luaL_Reg variablesApi[] =
+{
+ { "FormatString", lua_FormatString },
+
+ { NULL, NULL }
+};
+
+LUAMOD_API int luaopen_m_variables(lua_State *L)
+{
+ luaL_newlib(L, variablesApi);
+
+ return 1;
+}
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp
index 1a93789f52..dae408ea64 100644
--- a/plugins/MirLua/src/mlua_options.cpp
+++ b/plugins/MirLua/src/mlua_options.cpp
@@ -44,6 +44,8 @@ void CLuaOptions::OnInitDialog()
{
CDlgBase::OnInitDialog();
+ m_scripts.SetExtendedListViewStyle(LVS_EX_CHECKBOXES);
+
m_scripts.EnableGroupView(TRUE);
m_scripts.AddGroup(0, TranslateT("Common scripts"));
m_scripts.AddGroup(1, TranslateT("Custom scripts"));
@@ -64,7 +66,9 @@ void CLuaOptions::OnInitDialog()
{
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
- m_scripts.AddItem(fd.cFileName, -1, NULL, 0);
+ int iItem = m_scripts.AddItem(fd.cFileName, -1, NULL, 0);
+ if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1))
+ m_scripts.SetCheckState(iItem, TRUE);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
@@ -84,4 +88,40 @@ void CLuaOptions::OnInitDialog()
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
+}
+
+INT_PTR CLuaOptions::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_NOTIFY:
+ {
+ LPNMHDR lpnmHdr = (LPNMHDR)lParam;
+ if (lpnmHdr->idFrom == m_scripts.GetCtrlId() && lpnmHdr->code == LVN_ITEMCHANGED)
+ {
+ LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
+ if (pnmv->uChanged & LVIF_STATE && pnmv->uNewState & LVIS_STATEIMAGEMASK)
+ {
+ NotifyChange();
+ }
+ }
+ }
+ break;
+ }
+
+ return CDlgBase::DlgProc(msg, wParam, lParam);
+}
+
+void CLuaOptions::OnApply()
+{
+ int count = m_scripts.GetItemCount();
+ for (int iItem = 0; iItem < count; iItem++)
+ {
+ TCHAR fileName[MAX_PATH];
+ m_scripts.GetItemText(iItem, 0, fileName, SIZEOF(fileName));
+ if (!m_scripts.GetCheckState(iItem))
+ db_set_b(NULL, MODULE, _T2A(fileName), 0);
+ else
+ db_unset(NULL, MODULE, _T2A(fileName));
+ }
} \ No newline at end of file
diff --git a/plugins/MirLua/src/mlua_options.h b/plugins/MirLua/src/mlua_options.h
index 7311cf5df6..4fae51a1fc 100644
--- a/plugins/MirLua/src/mlua_options.h
+++ b/plugins/MirLua/src/mlua_options.h
@@ -11,6 +11,10 @@ private:
protected:
void OnInitDialog();
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
+
+ void OnApply();
+
public:
CLuaOptions(int idDialog);