From 5eef7a21c7a3a954fe737a64d4a44692726ba767 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 1 Aug 2011 17:08:51 +0000 Subject: [PATCH] - Script: Return types are now checked explicitly. As a result, 'return 5' and 'return "5"' are not equal any longer. Only the former will respect NumOfDecimals, Scale, etc. now. - NowPlayingPlugin: Accidentally removed "Previous" bang in r880, fixed. --- Library/MeasureScript.cpp | 6 +----- Library/lua/LuaScript.cpp | 13 ++++++------- Plugins/PluginNowPlaying/NowPlaying.cpp | 12 ++++++++---- Plugins/PluginNowPlaying/PluginNowPlaying.rc | 4 ++-- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Library/MeasureScript.cpp b/Library/MeasureScript.cpp index b2add2b7..a1e35d19 100644 --- a/Library/MeasureScript.cpp +++ b/Library/MeasureScript.cpp @@ -100,11 +100,7 @@ bool CMeasureScript::Update() { m_ValueType = m_LuaScript->RunFunctionWithReturn(g_UpdateFunctionName, m_Value, m_StringValue); - if (m_ValueType == LUA_TSTRING) - { - m_Value = 0; - } - else if (m_ValueType == LUA_TNIL && m_HasGetStringFunction) + if (m_ValueType == LUA_TNIL && m_HasGetStringFunction) { // For backwards compatbility m_ValueType = m_LuaScript->RunFunctionWithReturn(g_GetStringFunctionName, m_Value, m_StringValue); diff --git a/Library/lua/LuaScript.cpp b/Library/lua/LuaScript.cpp index b141ae92..021e7b84 100644 --- a/Library/lua/LuaScript.cpp +++ b/Library/lua/LuaScript.cpp @@ -147,12 +147,11 @@ void LuaScript::RunFunction(const char* funcName) ** RunFunctionWithReturn ** ** Runs given function in script file and stores the retruned number or string. -** Returns LUA_TNIL when no return. ** */ int LuaScript::RunFunctionWithReturn(const char* funcName, double& numValue, std::wstring& strValue) { - int ret = LUA_TNIL; + int type = LUA_TNIL; if (m_Initialized) { @@ -169,23 +168,23 @@ int LuaScript::RunFunctionWithReturn(const char* funcName, double& numValue, std } else { - if (lua_isnumber(m_State, -1)) + type = lua_type(m_State, -1); + if (type == LUA_TNUMBER) { numValue = lua_tonumber(m_State, -1); - ret = LUA_TNUMBER; } - else if (lua_isstring(m_State, -1)) + else if (type == LUA_TSTRING) { const char* str = lua_tostring(m_State, -1); strValue = ConvertToWide(str); - ret = LUA_TSTRING; + numValue = 0; } lua_pop(m_State, 2); } } - return ret; + return type; } /* diff --git a/Plugins/PluginNowPlaying/NowPlaying.cpp b/Plugins/PluginNowPlaying/NowPlaying.cpp index 91fe0bd2..79ad3a69 100644 --- a/Plugins/PluginNowPlaying/NowPlaying.cpp +++ b/Plugins/PluginNowPlaying/NowPlaying.cpp @@ -466,14 +466,18 @@ void ExecuteBang(LPCTSTR bang, UINT id) { (player->GetState() != PLAYER_PLAYING) ? player->Play() : player->Pause(); } - else if (_wcsicmp(bang, L"Stop") == 0) - { - player->Stop(); - } else if (_wcsicmp(bang, L"Next") == 0) { player->Next(); } + else if (_wcsicmp(bang, L"Previous") == 0) + { + player->Previous(); + } + else if (_wcsicmp(bang, L"Stop") == 0) + { + player->Stop(); + } else if (_wcsicmp(bang, L"OpenPlayer") == 0) { player->OpenPlayer(parent->playerPath); diff --git a/Plugins/PluginNowPlaying/PluginNowPlaying.rc b/Plugins/PluginNowPlaying/PluginNowPlaying.rc index 54672d55..befacd93 100644 --- a/Plugins/PluginNowPlaying/PluginNowPlaying.rc +++ b/Plugins/PluginNowPlaying/PluginNowPlaying.rc @@ -12,7 +12,7 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,1,3,3 + FILEVERSION 1,1,3,4 PRODUCTVERSION PRODUCTVER FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -29,7 +29,7 @@ BEGIN BLOCK "040904E4" BEGIN VALUE "FileDescription", "NowPlaying Plugin for Rainmeter" - VALUE "FileVersion", "1.1.3.3" + VALUE "FileVersion", "1.1.3.4" VALUE "InternalName", "NowPlaying" VALUE "LegalCopyright", "Copyright (C) 2011 - Birunthan Mohanathas" VALUE "OriginalFilename", "NowPlaying.dll"