summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/main.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-06-09 06:44:57 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-06-09 06:44:57 +0000
commitd93bdfc096f018d3b9c80dad756e5b573e886f68 (patch)
treee5561831fa8f318e61d2ffc62d7f718e82674451 /plugins/MirLua/src/main.cpp
parent00c46f24d60c9de29293bef608f34114392822d2 (diff)
MirLua:
- added loading of internal modules - added loading of lua scripts - added folders plugin support git-svn-id: http://svn.miranda-ng.org/main/trunk@14069 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/main.cpp')
-rw-r--r--plugins/MirLua/src/main.cpp44
1 files changed, 41 insertions, 3 deletions
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp
index d696848850..a374da2daa 100644
--- a/plugins/MirLua/src/main.cpp
+++ b/plugins/MirLua/src/main.cpp
@@ -1,9 +1,12 @@
#include "stdafx.h"
int hLangpack;
-CMLua *g_luaCore;
HINSTANCE g_hInstance;
+CMLua *g_mLua;
+HANDLE hCommonFolderPath;
+HANDLE hCustomFolderPath;
+
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
@@ -32,18 +35,53 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
return &pluginInfo;
}
+void 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);
+ g_mLua->Load(T2Utf(path));
+ }
+ } while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
+}
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
- g_luaCore = new CMLua();
+ g_mLua = new CMLua();
+
+ hCommonFolderPath = FoldersRegisterCustomPathT("MirLua", Translate("Common scripts folder"), COMMON_SCRIPTS_PATHT);
+ hCustomFolderPath = FoldersRegisterCustomPathT("MirLua", Translate("Custom scripts folder"), CUSTOM_SCRIPTS_PATHT);
+
+ TCHAR commonScriptDir[MAX_PATH];
+ FoldersGetCustomPathT(hCommonFolderPath, commonScriptDir, SIZEOF(commonScriptDir), VARST(COMMON_SCRIPTS_PATHT));
+ LoadScripts(commonScriptDir);
+
+ TCHAR customScriptDir[MAX_PATH];
+ FoldersGetCustomPathT(hCommonFolderPath, customScriptDir, SIZEOF(customScriptDir), VARST(CUSTOM_SCRIPTS_PATHT));
+ LoadScripts(customScriptDir);
return 0;
}
extern "C" int __declspec(dllexport) Unload(void)
{
- delete g_luaCore;
+ delete g_mLua;
return 0;
}