int syscmd(lua_State *L) { if (luaT_check(L, 1, LUA_TTABLE)) { lua_pushinteger(L, 1); lua_gettable(L, -2); std::wstring cmd(luaT_towstring(L, -1)); lua_pop(L, 1); if (cmd == L"sound" || cmd == L"play") { std::vector<std::wstring> params; int n = luaL_len(L, -1); std::wstring text; for (int i=2; i<=n; ++i) { lua_pushinteger(L, i); lua_gettable(L, -2); if (!lua_isstring(L, -1)) { luaT_pushwstring(L, L"Неверные параметры"); return 1; } else { std::wstring p(luaT_towstring(L, -1)); params.push_back(p); } lua_pop(L, 1); } lua_pop(L, 1); std::wstring error; if (cmd == L"play") player->runPlayCommand(params, &error); else player->runCommand(params, &error); if (!error.empty()) luaT_pushwstring(L, error.c_str() ); else lua_pushnil(L); return 1; } } return 1; }
int luaimage_towatch(lua_State *L) { if (luaT_check(L, 1, LUAT_IMAGE)) { Image *img = (Image *)luaT_toobject(L, 1); wchar_t buffer[40]; swprintf(buffer, L"width=%d,height=%d", img->width(), img->height()); luaT_pushwstring(L, buffer); return 1; } return 0; }
int get_description(lua_State *L) { luaT_Props p(L); std::wstring prefix; p.cmdPrefix(&prefix); std::wstring text(L"Плагин добавляет в клиент команду "); text.append(prefix); text.append(L"tray. Данная команда выводит текстовое сообщение\r\n" L"(параметры команды) в правый нижний угол рабочего стола в виде всплывающей подсказки.\r\n" L"Если были получены новые сообщения, а клиент работал в фоновом режиме, то иконка\r\n" L"клиента в панели задач будет переодически мигать. См. настройки в меню клиента."); luaT_pushwstring(L, text.c_str()); return 1; }
int get_description(lua_State *L) { std::wstring s(L"Плагин предназначен для воспроизведения звуковых файлов, а также их записи с микрофона.\r\n" L"Воспроизводятся wav,mp3,ogg,s3m,it,xm,mod. Запись с микрофона производится в wav.\r\n" L"Добавляются две команды #sound и #play. Подробнее в справке #help sound.\r\n" L"#play file [volume] - воспроизведение музыкального файла, аналог (#sound play)\r\n" L"#play - останавливает воспроизведение музыкального файла, аналог (#sound stop)\r\n" L"#sound play file [volume] - воспроизведение музыкального файла или плейлиста (*.lst)\r\n" L"#sound playfx|fx file [volume] - воспроизведение звукового эффекта\r\n" L"#sound volume [значение] - устанавливает или показывает текущую мастер-громкость плагина\r\n" L"#sound stop - останавливает воспроизведение музыкального файла\r\n"); luaT_Props props(L); std::wstring p; props.cmdPrefix(&p); if (p != L"#") wstring_replace(&s, L"#", p); luaT_pushwstring(L, s.c_str()); return 1; }
bool MsdpNetwork::process_val(cursor& c) { const tbyte* p = c.p; if (p == c.e || *p != MSDP_VAL) return false; const tbyte* b = p+1; if (b == c.e) { lua_pushstring(L, ""); lua_settable(L, -3); c.p = b; return true; } if (*b >= ' ') { while (b != c.e && *b >= ' ') b++; if (b != c.e && *b != MSDP_VAR && *b != MSDP_VAL && *b != MSDP_ARRAY_CLOSE && *b != MSDP_TABLE_CLOSE) return false; std::string value((const char*)(p+1), b-p-1); if (m_utf8_encoding) { lua_pushstring(L, value.c_str()); } else { std::string newval; const char* b0 = value.c_str(); const tbyte* b = (const tbyte*)b0; const tbyte* e = b + value.length(); while (b != e) { const tbyte *p = b; while (p!=e && *p!=0xff) p++; if (p==e) break; p++; if (p==e) break; newval.append((const char*)b, p-b); if (*p == 0xff) { p++; } b = p; } newval.append((const char*)b); TA2W ws(newval.c_str()); luaT_pushwstring(L, ws); } lua_settable(L, -3); c.p = b; return true; } else if (*b == MSDP_ARRAY_OPEN) { c.p = b+1; if (c.p == c.e) return false; int index = 1; // index for array's vars lua_newtable(L); // table for array while(true) { lua_pushinteger(L, index++); if (!process_val(c)) { lua_pop(L, 2); return false; } if (*c.p != MSDP_VAL && *c.p != MSDP_ARRAY_CLOSE) { lua_pop(L, 2); return false; } if (*c.p == MSDP_ARRAY_CLOSE) { lua_settable(L, -3); c.p++; return true; } } } else if (*b == MSDP_TABLE_OPEN) { c.p = b+1; if (c.p == c.e) return false; lua_newtable(L); // table for table while (true) { if (!process_var(c)) { lua_pop(L, 1); return false; } if (!process_val(c)) { lua_pop(L, 2); return false; } if (*c.p != MSDP_VAR && *c.p != MSDP_TABLE_CLOSE) { lua_pop(L, 2); return false; } if (*c.p == MSDP_TABLE_CLOSE) { lua_settable(L, -3); c.p++; return true; } } } else if (*b == MSDP_VAL || *b == MSDP_VAR) { lua_pushstring(L, ""); lua_settable(L, -3); c.p = b; return true; } return false; }
int get_name(lua_State *L) { luaT_pushwstring(L, L"Звуковой плагин"); return 1; }
int get_version(lua_State *L) { luaT_pushwstring(L, L"1.04"); return 1; }
int get_name(lua_State *L) { luaT_pushwstring(L, L"Плагин оповещения в трее"); return 1; }