mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Script: Added measure:ReadString(), measure:ReadNumber(), measure:ReadFormula()
This commit is contained in:
parent
04048a6325
commit
dca935f6ff
@ -37,23 +37,51 @@ static int Measure_GetOption(lua_State* L)
|
||||
CConfigParser& parser = meterWindow->GetParser();
|
||||
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
strTmp = parser.GetValue(self->GetOriginalName(), strTmp, L"");
|
||||
|
||||
if (strTmp.size() >= 3)
|
||||
{
|
||||
if (strTmp.find(L'#') != std::wstring::npos)
|
||||
{
|
||||
parser.SetCurrentSection(self->GetOriginalName()); // Set temporarily
|
||||
parser.ReplaceVariables(strTmp);
|
||||
parser.ClearCurrentSection(); // Reset
|
||||
}
|
||||
parser.ReplaceMeasures(strTmp);
|
||||
}
|
||||
strTmp = parser.ReadString(self->GetName(), strTmp.c_str(), L"");
|
||||
|
||||
LuaManager::PushWide(L, strTmp.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int Measure_ReadString(lua_State* L)
|
||||
{
|
||||
CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0);
|
||||
CMeterWindow* meterWindow = self->GetMeterWindow();
|
||||
CConfigParser& parser = meterWindow->GetParser();
|
||||
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
strTmp = parser.ReadString(self->GetName(), strTmp.c_str(), LuaManager::ToWide(L, 3).c_str());
|
||||
|
||||
LuaManager::PushWide(L, strTmp.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int Measure_ReadNumber(lua_State* L)
|
||||
{
|
||||
CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0);
|
||||
CMeterWindow* meterWindow = self->GetMeterWindow();
|
||||
CConfigParser& parser = meterWindow->GetParser();
|
||||
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
double value = parser.ReadFloat(self->GetName(), strTmp.c_str(), tolua_tonumber(L, 3, 0));
|
||||
|
||||
lua_pushnumber(L, value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int Measure_ReadFormula(lua_State* L)
|
||||
{
|
||||
CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0);
|
||||
CMeterWindow* meterWindow = self->GetMeterWindow();
|
||||
CConfigParser& parser = meterWindow->GetParser();
|
||||
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
double value = parser.ReadFormula(self->GetName(), strTmp.c_str(), tolua_tonumber(L, 3, 0));
|
||||
|
||||
lua_pushnumber(L, value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int Measure_Disable(lua_State* L)
|
||||
{
|
||||
CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0);
|
||||
@ -137,6 +165,9 @@ void LuaManager::RegisterMeasure(lua_State* L)
|
||||
tolua_beginmodule(L, "CMeasure");
|
||||
tolua_function(L, "GetName", Measure_GetName);
|
||||
tolua_function(L, "GetOption", Measure_GetOption);
|
||||
tolua_function(L, "ReadString", Measure_ReadString);
|
||||
tolua_function(L, "ReadNumber", Measure_ReadNumber);
|
||||
tolua_function(L, "ReadFormula", Measure_ReadFormula);
|
||||
tolua_function(L, "Disable", Measure_Disable);
|
||||
tolua_function(L, "Enable", Measure_Enable);
|
||||
tolua_function(L, "GetValue", Measure_GetValue);
|
||||
|
@ -37,12 +37,7 @@ static int Meter_GetOption(lua_State* L)
|
||||
CConfigParser& parser = meterWindow->GetParser();
|
||||
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
strTmp = parser.GetValue(self->GetOriginalName(), strTmp, L"");
|
||||
|
||||
parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetOriginalName()); // Set temporarily
|
||||
parser.ReplaceVariables(strTmp);
|
||||
parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset
|
||||
parser.ReplaceMeasures(strTmp);
|
||||
strTmp = parser.ReadString(self->GetName(), strTmp.c_str(), L"");
|
||||
|
||||
LuaManager::PushWide(L, strTmp.c_str());
|
||||
return 1;
|
||||
|
@ -172,7 +172,6 @@ static int MeterWindow_Bang(lua_State* L)
|
||||
|
||||
CConfigParser& parser = self->GetParser();
|
||||
parser.ReplaceVariables(strTmp);
|
||||
parser.ReplaceMeasures(strTmp);
|
||||
self->GetMainObject()->ExecuteCommand(strTmp.c_str(), self);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user