summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua_options.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-06-15 15:52:22 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-06-15 15:52:22 +0000
commit27985042841f1ea60156ed532e0b9f57e9c3b369 (patch)
treedfb25c2cbdb9b1d8896ce47d9620dd9a569ecf0b /plugins/MirLua/src/mlua_options.cpp
parentff55088a637a2716d1ab950b42b992cce78f4f6b (diff)
MirLua: added options page
git-svn-id: http://svn.miranda-ng.org/main/trunk@14179 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua_options.cpp')
-rw-r--r--plugins/MirLua/src/mlua_options.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp
new file mode 100644
index 0000000000..1a93789f52
--- /dev/null
+++ b/plugins/MirLua/src/mlua_options.cpp
@@ -0,0 +1,87 @@
+#include "stdafx.h"
+
+CLuaOptions::CLuaOptions(int idDialog)
+ : CDlgBase(g_hInstance, idDialog), m_scripts(this, IDC_SCRIPTS)
+{
+}
+
+void CLuaOptions::CreateLink(CCtrlData& ctrl, const char *szSetting, BYTE type, DWORD iValue)
+{
+ ctrl.CreateDbLink(MODULE, szSetting, type, iValue);
+}
+
+void CLuaOptions::CreateLink(CCtrlData& ctrl, const char *szSetting, TCHAR *szValue)
+{
+ ctrl.CreateDbLink(MODULE, szSetting, szValue);
+}
+
+void CLuaOptions::LoadScripts(const TCHAR *scriptDir)
+{
+ 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)
+ {
+ do
+ {
+ if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, fd.cFileName);
+ PathToRelativeT(fullPath, path);
+
+ m_scripts.AddItem(fd.cFileName, -1, NULL, 0);
+ }
+ } while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
+}
+
+void CLuaOptions::OnInitDialog()
+{
+ CDlgBase::OnInitDialog();
+
+ m_scripts.EnableGroupView(TRUE);
+ m_scripts.AddGroup(0, TranslateT("Common scripts"));
+ m_scripts.AddGroup(1, TranslateT("Custom scripts"));
+
+ m_scripts.AddColumn(0, _T("Script"), 300);
+
+ WIN32_FIND_DATA fd;
+ HANDLE hFind = NULL;
+ TCHAR scriptDir[MAX_PATH];
+ TCHAR searchMask[MAX_PATH];
+
+ FoldersGetCustomPathT(g_hCommonFolderPath, scriptDir, SIZEOF(scriptDir), VARST(COMMON_SCRIPTS_PATHT));
+ mir_sntprintf(searchMask, _T("%s\\%s"), scriptDir, _T("*.lua"));
+ hFind = FindFirstFile(searchMask, &fd);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ m_scripts.AddItem(fd.cFileName, -1, NULL, 0);
+ }
+ } while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
+
+ FoldersGetCustomPathT(g_hCustomFolderPath, scriptDir, SIZEOF(scriptDir), VARST(CUSTOM_SCRIPTS_PATHT));
+ mir_sntprintf(searchMask, _T("%s\\%s"), scriptDir, _T("*.lua"));
+ hFind = FindFirstFile(searchMask, &fd);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ m_scripts.AddItem(fd.cFileName, -1, NULL, 1);
+ }
+ } while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
+} \ No newline at end of file