diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-06-18 15:27:08 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-06-18 15:27:08 +0000 |
commit | 3af4bb5ed2c17d17ecc8073cd233277ed8541cf1 (patch) | |
tree | 5269a2674b1e50ba322c1636580c84579c321459 /plugins/MirLua/src/main.cpp | |
parent | 6f8ff613bd81e4592173e9039ec0dc6f01ce5e6b (diff) |
MirLua: scripts reloading pt.1
git-svn-id: http://svn.miranda-ng.org/main/trunk@14245 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/main.cpp')
-rw-r--r-- | plugins/MirLua/src/main.cpp | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp index 35d572a4c7..618ffb6c67 100644 --- a/plugins/MirLua/src/main.cpp +++ b/plugins/MirLua/src/main.cpp @@ -6,7 +6,7 @@ HINSTANCE g_hInstance; HANDLE g_hCommonFolderPath;
HANDLE g_hCustomFolderPath;
-CMLua *mLua;
+CMLua *g_mLua;
HANDLE hConsole = NULL;
PLUGININFOEX pluginInfo =
@@ -37,33 +37,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) return &pluginInfo;
}
-void LoadScripts(const TCHAR *scriptDir)
-{
- mLua->AddPath(ptrA(mir_utf8encodeT(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);
- if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1))
- mLua->Load(T2Utf(path));
- }
- } while (FindNextFile(hFind, &fd));
- FindClose(hFind);
- }
-}
-
int OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
@@ -99,18 +72,13 @@ extern "C" int __declspec(dllexport) Load(void) }
}
- mLua = new CMLua();
-
g_hCommonFolderPath = FoldersRegisterCustomPathT("MirLua", Translate("Common scripts folder"), COMMON_SCRIPTS_PATHT);
g_hCustomFolderPath = FoldersRegisterCustomPathT("MirLua", Translate("Custom scripts folder"), CUSTOM_SCRIPTS_PATHT);
- TCHAR commonScriptDir[MAX_PATH];
- FoldersGetCustomPathT(g_hCommonFolderPath, commonScriptDir, SIZEOF(commonScriptDir), VARST(COMMON_SCRIPTS_PATHT));
- LoadScripts(commonScriptDir);
+ g_mLua = new CMLua();
- TCHAR customScriptDir[MAX_PATH];
- FoldersGetCustomPathT(g_hCustomFolderPath, customScriptDir, SIZEOF(customScriptDir), VARST(CUSTOM_SCRIPTS_PATHT));
- LoadScripts(customScriptDir);
+ CLuaLoader loader(g_mLua);
+ loader.LoadScripts();
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
@@ -123,7 +91,7 @@ extern "C" int __declspec(dllexport) Unload(void) CloseHandle(hConsole);
FreeConsole();
- delete mLua;
+ delete g_mLua;
return 0;
}
|