summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-01-02 14:54:06 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-01-02 14:54:06 +0000
commitb544097135831f24da3d6b11211d19e9536005f0 (patch)
treec2527a7cca50fef51ddea2980d0c455633c149c5 /plugins
parent90cac394f9e49fb2ccc5e588dd78e093e0510c4e (diff)
MirLua: added new settings
git-svn-id: http://svn.miranda-ng.org/main/trunk@15993 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MirLua/res/reload.icobin2550 -> 0 bytes
-rw-r--r--plugins/MirLua/res/resource.rc25
-rw-r--r--plugins/MirLua/src/mlua_icons.cpp1
-rw-r--r--plugins/MirLua/src/mlua_options.cpp29
-rw-r--r--plugins/MirLua/src/mlua_options.h3
-rw-r--r--plugins/MirLua/src/mlua_utils.cpp63
-rw-r--r--plugins/MirLua/src/resource.h7
-rw-r--r--plugins/MirLua/src/stdafx.h8
8 files changed, 82 insertions, 54 deletions
diff --git a/plugins/MirLua/res/reload.ico b/plugins/MirLua/res/reload.ico
deleted file mode 100644
index b5070a2bfe..0000000000
--- a/plugins/MirLua/res/reload.ico
+++ /dev/null
Binary files differ
diff --git a/plugins/MirLua/res/resource.rc b/plugins/MirLua/res/resource.rc
index 517cd81077..f7205fd285 100644
--- a/plugins/MirLua/res/resource.rc
+++ b/plugins/MirLua/res/resource.rc
@@ -63,8 +63,9 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SCRIPT ICON "script.ico"
+
IDI_OPEN ICON "open.ico"
-IDI_RELOAD ICON "reload.ico"
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -76,8 +77,12 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- CONTROL "",IDC_SCRIPTS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,0,0,310,220
- PUSHBUTTON "Reload all",IDC_RELOAD,234,224,76,14
+ CONTROL "",IDC_SCRIPTS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,8,57,294,169
+ PUSHBUTTON "Reload all",IDC_RELOAD,226,228,76,14
+ GROUPBOX "Scripts",IDC_STATIC,0,46,309,203
+ CONTROL "Popup on script error",IDC_POPUPONERROR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,10,83,10
+ GROUPBOX "General",IDC_STATIC,1,0,308,44
+ CONTROL "Popup on obsolete methods",IDC_POPUPONOBSOLETE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,21,105,10
END
@@ -91,10 +96,24 @@ GUIDELINES DESIGNINFO
BEGIN
IDD_OPTIONS, DIALOG
BEGIN
+ VERTGUIDE, 8
+ VERTGUIDE, 302
+ HORZGUIDE, 242
END
END
#endif // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPTIONS AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // English resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/MirLua/src/mlua_icons.cpp b/plugins/MirLua/src/mlua_icons.cpp
index 7b0e9c37f3..b8da8bce9e 100644
--- a/plugins/MirLua/src/mlua_icons.cpp
+++ b/plugins/MirLua/src/mlua_icons.cpp
@@ -4,7 +4,6 @@ IconItemT Icons[] =
{
{ LPGENT("Script"), "script", IDI_SCRIPT },
{ LPGENT("Open"), "open", IDI_OPEN },
- { LPGENT("Reload") , "reload", IDI_RELOAD },
};
void InitIcons()
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp
index 7b89599af5..9d44bbde83 100644
--- a/plugins/MirLua/src/mlua_options.cpp
+++ b/plugins/MirLua/src/mlua_options.cpp
@@ -18,10 +18,16 @@ BOOL CCtrlScriptList::OnNotify(int idCtrl, NMHDR *pnmh)
/****************************************/
-CLuaOptions::CLuaOptions(int idDialog) : CDlgBase(g_hInstance, idDialog),
- m_scripts(this, IDC_SCRIPTS), isScriptListInit(false),
+CLuaOptions::CLuaOptions(int idDialog)
+ : CDlgBase(g_hInstance, idDialog),
+ m_popupOnError(this, IDC_POPUPONERROR),
+ m_popupOnObsolete(this, IDC_POPUPONOBSOLETE),
+ isScriptListInit(false), m_scripts(this, IDC_SCRIPTS),
m_reload(this, IDC_RELOAD)
{
+ CreateLink(m_popupOnError, "PopupOnError", DBVT_BYTE, 1);
+ CreateLink(m_popupOnObsolete, "PopupOnObsolete", DBVT_BYTE, 1);
+
m_scripts.OnClick = Callback(this, &CLuaOptions::OnScriptListClick);
m_reload.OnClick = Callback(this, &CLuaOptions::OnReload);
}
@@ -59,9 +65,6 @@ void CLuaOptions::LoadScripts()
if (db_get_b(NULL, MODULE, _T2A(fileName), 1))
m_scripts.SetCheckState(iItem, TRUE);
m_scripts.SetItem(iItem, 1, TranslateT("Open"), 0);
-//#ifdef DEBUG
- m_scripts.SetItem(iItem, 2, _T(""), 1);
-//#endif
}
}
@@ -73,20 +76,14 @@ void CLuaOptions::OnInitDialog()
HIMAGELIST hImageList = m_scripts.CreateImageList(LVSIL_SMALL);
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));
+ FoldersGetCustomPathT(g_hScriptsFolder, scriptDir, _countof(scriptDir), VARST(MIRLUA_PATHT));
PathToRelativeT(scriptDir, relativeScriptDir, NULL);
mir_sntprintf(header, _T("%s (%s)"), TranslateT("Common scripts"), relativeScriptDir);
- //m_scripts.AddGroup(0, header);
- //m_scripts.EnableGroupView(TRUE);
m_scripts.AddColumn(0, _T("Script"), 420);
m_scripts.AddColumn(1, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL));
-//#ifdef DEBUG
- //m_scripts.AddColumn(2, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL));
-//#endif
LoadScripts();
@@ -145,13 +142,7 @@ void CLuaOptions::OnScriptListClick(CCtrlListView::TEventInfo *evt)
if (lvi.iSubItem == 1)
ShellExecute(m_hwnd, _T("Open"), script->GetFilePath(), NULL, NULL, SW_SHOWNORMAL);
-//#ifdef DEBUG
- else if (lvi.iSubItem == 2)
- {
- script->Unload();
- script->Load();
- }
-//#endif
+
mir_free(lvi.pszText);
}
diff --git a/plugins/MirLua/src/mlua_options.h b/plugins/MirLua/src/mlua_options.h
index 25bf442ed1..b81676bfc8 100644
--- a/plugins/MirLua/src/mlua_options.h
+++ b/plugins/MirLua/src/mlua_options.h
@@ -19,6 +19,9 @@ public:
class CLuaOptions : public CDlgBase
{
private:
+ CCtrlCheck m_popupOnError;
+ CCtrlCheck m_popupOnObsolete;
+
bool isScriptListInit;
CCtrlScriptList m_scripts;
CCtrlButton m_reload;
diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp
index 99bae923d1..c253ad244c 100644
--- a/plugins/MirLua/src/mlua_utils.cpp
+++ b/plugins/MirLua/src/mlua_utils.cpp
@@ -1,8 +1,34 @@
#include "stdafx.h"
+void ShowNotification(const char *caption, const char *message, int flags, MCONTACT hContact)
+{
+ if (Miranda_Terminated())
+ return;
+
+ if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1))
+ {
+ POPUPDATA ppd = { 0 };
+ ppd.lchContact = hContact;
+ mir_strncpy(ppd.lpzContactName, caption, MAX_CONTACTNAME);
+ mir_strncpy(ppd.lpzText, message, MAX_SECONDLINE);
+
+ if (!PUAddPopup(&ppd))
+ return;
+ }
+
+ ::MessageBoxA(NULL, message, caption, MB_OK | flags);
+}
+
+void ReportError(const char *message)
+{
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)message);
+ if (db_get_b(NULL, MODULE, "PopupOnError", 0))
+ ShowNotification(MODULE, message, MB_OK | MB_ICONERROR);
+}
+
int luaM_atpanic(lua_State *L)
{
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ ReportError(lua_tostring(L, -1));
return 0;
}
@@ -20,13 +46,16 @@ int luaM_trace(lua_State *L)
int luaM_pcall(lua_State *L, int n, int r)
{
- /*lua_pushcfunction(L, luaM_trace);
- lua_insert(L, f);
- const int f = -(n + 2);*/
- const int f = 0;
+ int f = 0;
+ /*if (db_get_b(NULL, MODULE, "AddTaraceback", 0))
+ {
+ f = -(n + 2);
+ lua_pushcfunction(L, luaM_trace);
+ lua_insert(L, f);
+ }*/
int res = lua_pcall(L, n, r, f);
if (res != LUA_OK)
- CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ ReportError(lua_tostring(L, -1));
return res;
}
@@ -150,25 +179,6 @@ int luaM_totable(lua_State *L)
return 1;
}
-void ShowNotification(const char *caption, const char *message, int flags, MCONTACT hContact)
-{
- if (Miranda_Terminated())
- return;
-
- if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1))
- {
- POPUPDATA ppd = { 0 };
- ppd.lchContact = hContact;
- mir_strncpy(ppd.lpzContactName, caption, MAX_CONTACTNAME);
- mir_strncpy(ppd.lpzText, message, MAX_SECONDLINE);
-
- if (!PUAddPopup(&ppd))
- return;
- }
-
- ::MessageBoxA(NULL, message, caption, MB_OK | flags);
-}
-
void ObsoleteMethod(lua_State *L, const char *message)
{
lua_Debug info;
@@ -178,5 +188,6 @@ void ObsoleteMethod(lua_State *L, const char *message)
char text[512];
mir_snprintf(text, "%s is obsolete. %s", info.name, message);
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)text);
- ShowNotification(MODULE, text, MB_OK | MB_ICONWARNING, NULL);
+ if (db_get_b(NULL, MODULE, "PopupOnObsolete", 0))
+ ShowNotification(MODULE, text, MB_OK | MB_ICONWARNING, NULL);
} \ No newline at end of file
diff --git a/plugins/MirLua/src/resource.h b/plugins/MirLua/src/resource.h
index ad362f5cce..22507f4637 100644
--- a/plugins/MirLua/src/resource.h
+++ b/plugins/MirLua/src/resource.h
@@ -6,17 +6,18 @@
#define IDI_SCRIPT 100
#define IDI_OPEN 105
#define IDD_OPTIONS 106
-#define IDI_RELOAD 107
#define IDC_SCRIPTS 1011
#define IDC_RELOAD 1012
+#define IDC_POPUPONERROR 1013
+#define IDC_POPUPONOBSOLETE 1014
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1013
+#define _APS_NEXT_CONTROL_VALUE 1015
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h
index f791f4a183..73573652ef 100644
--- a/plugins/MirLua/src/stdafx.h
+++ b/plugins/MirLua/src/stdafx.h
@@ -73,6 +73,8 @@ extern HANDLE hNetlib;
#define MIRLUA_PATHT MIRANDA_PATH "\\Scripts"
#endif
+/* modules */
+
#define MLUA_CORE "m_core"
LUAMOD_API int (luaopen_m_core)(lua_State *L);
@@ -113,6 +115,10 @@ LUAMOD_API int (luaopen_m_variables)(lua_State *L);
#define MLUA_WINDOWS "m_windows"
LUAMOD_API int (luaopen_m_windows)(lua_State *L);
+/* utils */
+
+void ShowNotification(const char *caption, const char *message, int flags = 0, MCONTACT hContact = NULL);
+
int luaM_atpanic(lua_State *L);
int luaM_pcall(lua_State *L, int n = 0, int r = 0);
@@ -131,8 +137,6 @@ void InitIcons();
HICON GetIcon(int iconId);
HANDLE GetIconHandle(int iconId);
-void ShowNotification(const char *caption, const char *message, int flags = 0, MCONTACT hContact = NULL);
-
void ObsoleteMethod(lua_State *L, const char *message);
#endif //_COMMON_H_