mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Added IfConditionMode. If 1, will execute the True/False action on every update of the measure. If 0, will only execute the True/False action once until it switches case and back again (like IfActions).
This commit is contained in:
		@@ -32,7 +32,8 @@ IfActions::IfActions() :
 | 
				
			|||||||
	m_AboveCommitted(false),
 | 
						m_AboveCommitted(false),
 | 
				
			||||||
	m_BelowCommitted(false),
 | 
						m_BelowCommitted(false),
 | 
				
			||||||
	m_EqualCommitted(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)
 | 
					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"");
 | 
						std::wstring condition = parser.ReadString(section, L"IfCondition", L"");
 | 
				
			||||||
	if (!condition.empty())
 | 
						if (!condition.empty())
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -178,15 +181,27 @@ void IfActions::DoIfActions(Measure& measure, double value)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				if (result == 1.0f)			// "True"
 | 
									if (result == 1.0f)			// "True"
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
 | 
										item.fCommitted = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if (m_ConditionMode || !item.tCommitted)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											item.tCommitted = true;
 | 
				
			||||||
						GetRainmeter().ExecuteCommand(item.tAction.c_str(), measure.GetMeterWindow());
 | 
											GetRainmeter().ExecuteCommand(item.tAction.c_str(), measure.GetMeterWindow());
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				else if (result == 0.0f)	// "False"
 | 
									else if (result == 0.0f)	// "False"
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
 | 
										item.tCommitted = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if (m_ConditionMode || !item.fCommitted)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											item.fCommitted = true;
 | 
				
			||||||
						GetRainmeter().ExecuteCommand(item.fAction.c_str(), measure.GetMeterWindow());
 | 
											GetRainmeter().ExecuteCommand(item.fAction.c_str(), measure.GetMeterWindow());
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void IfActions::SetState(double value)
 | 
					void IfActions::SetState(double value)
 | 
				
			||||||
@@ -206,4 +221,10 @@ void IfActions::SetState(double value)
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		m_BelowCommitted = false;
 | 
							m_BelowCommitted = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (auto& item : m_Conditions)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							item.tCommitted = false;
 | 
				
			||||||
 | 
							item.fCommitted = false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,9 @@ public:
 | 
				
			|||||||
		condition(),
 | 
							condition(),
 | 
				
			||||||
		tAction(),
 | 
							tAction(),
 | 
				
			||||||
		fAction(),
 | 
							fAction(),
 | 
				
			||||||
		parseError(false)
 | 
							parseError(false),
 | 
				
			||||||
 | 
							tCommitted(false),
 | 
				
			||||||
 | 
							fCommitted(false)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Set(value, trueAction, falseAction);
 | 
							Set(value, trueAction, falseAction);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -50,6 +52,8 @@ public:
 | 
				
			|||||||
	std::wstring tAction;		// IfTrueAction
 | 
						std::wstring tAction;		// IfTrueAction
 | 
				
			||||||
	std::wstring fAction;		// IfFalseAction
 | 
						std::wstring fAction;		// IfFalseAction
 | 
				
			||||||
	bool parseError;
 | 
						bool parseError;
 | 
				
			||||||
 | 
						bool tCommitted;
 | 
				
			||||||
 | 
						bool fCommitted;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class IfActions
 | 
					class IfActions
 | 
				
			||||||
@@ -77,5 +81,6 @@ private:
 | 
				
			|||||||
	bool m_EqualCommitted;
 | 
						bool m_EqualCommitted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::vector<IfCondition> m_Conditions;
 | 
						std::vector<IfCondition> m_Conditions;
 | 
				
			||||||
 | 
						bool m_ConditionMode;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user