Пример #1
0
void CMLuaOptions::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 | LVIF_PARAM;
	evt->treeviewctrl->GetItem(&lvi);
	lvi.iSubItem = evt->nmlvia->iSubItem;

	CMLuaScript* script = (CMLuaScript*)lvi.lParam;

	switch (lvi.iSubItem)
	{
	case 1:
		ShellExecute(m_hwnd, _T("Open"), script->GetFilePath(), NULL, NULL, SW_SHOWNORMAL);
		break;

	case 2:
		//m_scripts.DeleteItem(evt->nmlvia->iItem);
		script->Unload();
		script->Load();
		lvi.mask = LVIF_IMAGE;
		lvi.iSubItem = 0;
		lvi.iImage = script->GetStatus() - 1;
		ListView_SetItem(m_scripts.GetHwnd(), &lvi);
		m_scripts.Update(evt->nmlvia->iItem);
		break;
	}

	mir_free(lvi.pszText);
}
Пример #2
0
void CMLua::Unload()
{
	Log("Unloading lua engine");

	while (int last = Scripts.getCount())
	{
		CMLuaScript* script = g_mLua->Scripts[last - 1];
		Scripts.remove(script);
		script->Unload();
		delete script;
	}

	::KillModuleScheduleTasks();
	::KillModuleMBButtons();
	::KillModuleTTBButton();

	::KillModuleIcons(hLangpack);
	::KillModuleSounds(hLangpack);
	::KillModuleMenus(hLangpack);
	::KillModuleHotkeys(hLangpack);
	::KillObjectEventHooks(L);
	::KillObjectServices(L);

	lua_close(L);
}
Пример #3
0
void CLuaOptions::LoadScripts()
{
	for (int i = 0; i < g_mLua->Scripts.getCount(); i++)
	{
		CMLuaScript *script = g_mLua->Scripts[i];
		TCHAR *fileName = NEWTSTR_ALLOCA(script->GetFileName());
		int iItem = m_scripts.AddItem(fileName, -1, (LPARAM)script);
		if (db_get_b(NULL, MODULE, _T2A(fileName), 1))
			m_scripts.SetCheckState(iItem, TRUE);
		m_scripts.SetItem(iItem, 1, TranslateT("Open"), 0);
	}
}
Пример #4
0
void CLuaScriptLoader::LoadScript(const TCHAR *path, int iGroup)
{
	CMLuaScript *script = new CMLuaScript(L, path, iGroup);
	g_mLua->Scripts.insert(script);

	if (script->Load())
	{
		TCHAR buf[4096];
		mir_sntprintf(buf, _T("%s:OK"), path);
		CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf);
	}
}
Пример #5
0
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 | LVIF_PARAM;
	evt->treeviewctrl->GetItem(&lvi);
	lvi.iSubItem = evt->nmlvia->iSubItem;

	CMLuaScript* script = (CMLuaScript*)lvi.lParam;

	if (lvi.iSubItem == 1)
		ShellExecute(m_hwnd, _T("Open"), script->GetFilePath(), NULL, NULL, SW_SHOWNORMAL);

	mir_free(lvi.pszText);
}