summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua_options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirLua/src/mlua_options.cpp')
-rw-r--r--plugins/MirLua/src/mlua_options.cpp51
1 files changed, 49 insertions, 2 deletions
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp
index bd8234ed9a..9c59e246e3 100644
--- a/plugins/MirLua/src/mlua_options.cpp
+++ b/plugins/MirLua/src/mlua_options.cpp
@@ -1,9 +1,28 @@
#include "stdafx.h"
+CCtrlScriptList::CCtrlScriptList(CDlgBase* dlg, int ctrlId)
+ : CCtrlListView(dlg, ctrlId)
+{
+}
+
+BOOL CCtrlScriptList::OnNotify(int idCtrl, NMHDR *pnmh)
+{
+ if (pnmh->code == NM_CLICK)
+ {
+ TEventInfo evt = { this, pnmh };
+ OnClick(&evt);
+ return TRUE;
+ }
+ return CCtrlListView::OnNotify(idCtrl, pnmh);
+}
+
+/****************************************/
+
CLuaOptions::CLuaOptions(int idDialog) : CDlgBase(g_hInstance, idDialog),
m_scripts(this, IDC_SCRIPTS), isScriptListInit(false),
m_reload(this, IDC_RELOAD)
{
+ m_scripts.OnClick = Callback(this, &CLuaOptions::OnScriptListClick);
m_reload.OnClick = Callback(this, &CLuaOptions::OnReload);
}
@@ -45,6 +64,7 @@ void CLuaOptions::LoadScripts(const TCHAR *scriptDir, int iGroup)
int iItem = m_scripts.AddItem(fd.cFileName, -1, NULL, iGroup);
if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1))
m_scripts.SetCheckState(iItem, TRUE);
+ m_scripts.SetItem(iItem, 1, _T(""), 0);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
@@ -71,9 +91,14 @@ void CLuaOptions::OnInitDialog()
{
CDlgBase::OnInitDialog();
- m_scripts.SetExtendedListViewStyle(LVS_EX_CHECKBOXES | LVS_EX_INFOTIP);
+ m_scripts.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_INFOTIP);
m_scripts.EnableGroupView(TRUE);
- m_scripts.AddColumn(0, _T("Script"), 300);
+ m_scripts.AddColumn(0, _T("Script"), 440);
+ m_scripts.AddColumn(1, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL));
+
+ HIMAGELIST hImageList = m_scripts.CreateImageList(LVSIL_SMALL);
+ HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_OPEN));
+ ImageList_AddIcon(hImageList, icon);
LoadScripts();
@@ -117,6 +142,28 @@ INT_PTR CLuaOptions::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
return CDlgBase::DlgProc(msg, wParam, lParam);
}
+void CLuaOptions::OnScriptListClick(CCtrlListView::TEventInfo *evt)
+{
+ LVITEM lvi = { 0 };
+ lvi.iItem = evt->nmlvia->iItem;
+ if (lvi.iItem == -1) return;
+ lvi.pszText = (LPTSTR)mir_calloc(MAX_PATH * sizeof(TCHAR));
+ lvi.cchTextMax = MAX_PATH;
+ lvi.mask = LVIF_GROUPID | LVIF_TEXT;
+ evt->treeviewctrl->GetItem(&lvi);
+ lvi.iSubItem = evt->nmlvia->iSubItem;
+ if (lvi.iSubItem == 1)
+ {
+ TCHAR path[MAX_PATH];
+ if (lvi.iGroupId == 0)
+ FoldersGetCustomPathT(g_hCommonFolderPath, path, _countof(path), VARST(COMMON_SCRIPTS_PATHT));
+ else
+ FoldersGetCustomPathT(g_hCustomFolderPath, path, _countof(path), VARST(CUSTOM_SCRIPTS_PATHT));
+ ShellExecute(m_hwnd, NULL, lvi.pszText, NULL, path, SW_SHOWNORMAL);
+ }
+ mir_free(lvi.pszText);
+}
+
void CLuaOptions::OnReload(CCtrlBase*)
{
isScriptListInit = false;