diff --git a/Library/IfActions.cpp b/Library/IfActions.cpp index 4d910c9b..70b2bd94 100644 --- a/Library/IfActions.cpp +++ b/Library/IfActions.cpp @@ -32,7 +32,8 @@ IfActions::IfActions() : m_AboveCommitted(false), m_BelowCommitted(false), m_EqualCommitted(false), - m_Conditions() + m_Conditions(), + m_ConditionMode(false) { } @@ -54,6 +55,8 @@ void IfActions::ReadOptions(ConfigParser& parser, const WCHAR* section) void IfActions::ReadConditionOptions(ConfigParser& parser, const WCHAR* section) { + m_ConditionMode = parser.ReadBool(section, L"IfConditionMode", false); + std::wstring condition = parser.ReadString(section, L"IfCondition", L""); if (!condition.empty()) { @@ -178,11 +181,23 @@ void IfActions::DoIfActions(Measure& measure, double value) if (result == 1.0f) // "True" { - GetRainmeter().ExecuteCommand(item.tAction.c_str(), measure.GetMeterWindow()); + item.fCommitted = false; + + if (m_ConditionMode || !item.tCommitted) + { + item.tCommitted = true; + GetRainmeter().ExecuteCommand(item.tAction.c_str(), measure.GetMeterWindow()); + } } else if (result == 0.0f) // "False" { - GetRainmeter().ExecuteCommand(item.fAction.c_str(), measure.GetMeterWindow()); + item.tCommitted = false; + + if (m_ConditionMode || !item.fCommitted) + { + item.fCommitted = true; + GetRainmeter().ExecuteCommand(item.fAction.c_str(), measure.GetMeterWindow()); + } } } } @@ -206,4 +221,10 @@ void IfActions::SetState(double value) { m_BelowCommitted = false; } + + for (auto& item : m_Conditions) + { + item.tCommitted = false; + item.fCommitted = false; + } } diff --git a/Library/IfActions.h b/Library/IfActions.h index 76b78fe5..214b3ac3 100644 --- a/Library/IfActions.h +++ b/Library/IfActions.h @@ -34,7 +34,9 @@ public: condition(), tAction(), fAction(), - parseError(false) + parseError(false), + tCommitted(false), + fCommitted(false) { Set(value, trueAction, falseAction); } @@ -50,6 +52,8 @@ public: std::wstring tAction; // IfTrueAction std::wstring fAction; // IfFalseAction bool parseError; + bool tCommitted; + bool fCommitted; }; class IfActions @@ -77,5 +81,6 @@ private: bool m_EqualCommitted; std::vector m_Conditions; + bool m_ConditionMode; }; #endif