Script: Added support for multiple parameters to SKIN:Bang()

For example: 'SKIN:Bang("Bang", var, "str", 2)' can now be used instead of 'SKIN:Bang("!Bang \"" .. var .. "\" str \"" .. 2 .. "\"")'
This commit is contained in:
Birunthan Mohanathas 2012-05-08 17:11:22 +03:00
parent 854b925ce9
commit 9db39b72bc
2 changed files with 22 additions and 6 deletions

View File

@ -216,6 +216,7 @@ public:
const std::wstring& GetTrayExecuteDR() { return m_TrayExecuteDR; } const std::wstring& GetTrayExecuteDR() { return m_TrayExecuteDR; }
const std::wstring& GetTrayExecuteDM() { return m_TrayExecuteDM; } const std::wstring& GetTrayExecuteDM() { return m_TrayExecuteDM; }
void ExecuteBang(const WCHAR* bang, std::vector<std::wstring>& args, CMeterWindow* meterWindow);
void ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow); void ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow);
void DelayedExecuteCommand(const WCHAR* command); void DelayedExecuteCommand(const WCHAR* command);
@ -246,8 +247,6 @@ private:
void Bang_WriteKeyValue(std::vector<std::wstring>& args, CMeterWindow* meterWindow); void Bang_WriteKeyValue(std::vector<std::wstring>& args, CMeterWindow* meterWindow);
void Bang_Log(std::vector<std::wstring>& args); void Bang_Log(std::vector<std::wstring>& args);
void ExecuteBang(const WCHAR* bang, std::vector<std::wstring>& args, CMeterWindow* meterWindow);
void ActivateActiveConfigs(); void ActivateActiveConfigs();
void CreateMeterWindow(const std::wstring& config, const std::wstring& iniFile); void CreateMeterWindow(const std::wstring& config, const std::wstring& iniFile);
void WriteActive(const std::wstring& config, int iniIndex); void WriteActive(const std::wstring& config, int iniIndex);

View File

@ -32,11 +32,28 @@ inline CMeterWindow* GetSelf(lua_State* L)
static int Bang(lua_State* L) static int Bang(lua_State* L)
{ {
CMeterWindow* self = GetSelf(L); CMeterWindow* self = GetSelf(L);
std::wstring strTmp = LuaManager::ToWide(L, 2);
CConfigParser& parser = self->GetParser(); CConfigParser& parser = self->GetParser();
parser.ReplaceVariables(strTmp);
Rainmeter->ExecuteCommand(strTmp.c_str(), self); std::wstring bang = LuaManager::ToWide(L, 2);
int top = lua_gettop(L);
if (top == 2) // 1 argument
{
parser.ReplaceVariables(bang);
Rainmeter->ExecuteCommand(bang.c_str(), self);
}
else
{
std::vector<std::wstring> args;
for (int i = 3; i <= top; ++i)
{
std::wstring tmpSz = LuaManager::ToWide(L, i);
parser.ReplaceVariables(tmpSz);
args.push_back(tmpSz);
}
Rainmeter->ExecuteBang(bang.c_str(), args, self);
}
return 0; return 0;
} }