mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	NumOfDecimals is now enabled when Percentual=1 in STRING meter.
This commit is contained in:
		@@ -510,7 +510,17 @@ const WCHAR* CMeasure::GetStringValue(bool autoScale, double scale, int decimals
 | 
			
		||||
 | 
			
		||||
	if(percentual)
 | 
			
		||||
	{
 | 
			
		||||
		swprintf(buffer, L"%i", (UINT)(100.0 * GetRelativeValue()));
 | 
			
		||||
		double val = 100.0 * GetRelativeValue();
 | 
			
		||||
 | 
			
		||||
		if (decimals == 0)
 | 
			
		||||
		{
 | 
			
		||||
			swprintf(buffer, L"%i", (UINT)val);
 | 
			
		||||
		} 
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			swprintf(format, L"%%.%if", decimals);
 | 
			
		||||
			swprintf(buffer, format, val);
 | 
			
		||||
		}
 | 
			
		||||
	} 
 | 
			
		||||
	else if(autoScale)
 | 
			
		||||
	{
 | 
			
		||||
@@ -518,15 +528,16 @@ const WCHAR* CMeasure::GetStringValue(bool autoScale, double scale, int decimals
 | 
			
		||||
	}
 | 
			
		||||
	else 
 | 
			
		||||
	{
 | 
			
		||||
		double val = GetValue() * (1.0 / scale);
 | 
			
		||||
 | 
			
		||||
		if(decimals == 0)
 | 
			
		||||
		{
 | 
			
		||||
			double val = GetValue() * (1.0 / scale);
 | 
			
		||||
			val += (val >= 0) ? 0.5 : -0.5;
 | 
			
		||||
			swprintf(buffer, L"%lli", (LONGLONG)val);
 | 
			
		||||
		}
 | 
			
		||||
		else if (decimals == -1)
 | 
			
		||||
		{
 | 
			
		||||
			swprintf(buffer, L"%.5f", GetValue() * (1.0 / scale));
 | 
			
		||||
			swprintf(buffer, L"%.5f", val);
 | 
			
		||||
 | 
			
		||||
			size_t len = wcslen(buffer);
 | 
			
		||||
			if (len >= 6 && wcscmp(buffer + len - 6, L".00000") == 0)
 | 
			
		||||
@@ -537,7 +548,7 @@ const WCHAR* CMeasure::GetStringValue(bool autoScale, double scale, int decimals
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			swprintf(format, L"%%.%if", decimals);
 | 
			
		||||
			swprintf(buffer, format, GetValue() * (1.0 / scale));
 | 
			
		||||
			swprintf(buffer, format, val);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -272,7 +272,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
 | 
			
		||||
	std::wstring scale;
 | 
			
		||||
	scale = parser.ReadString(section, L"Scale", L"1");
 | 
			
		||||
 | 
			
		||||
	if (wcschr(scale.c_str(), '.') == NULL)
 | 
			
		||||
	if (scale.find(L'.') == std::wstring::npos)
 | 
			
		||||
	{
 | 
			
		||||
		m_NoDecimals = true;
 | 
			
		||||
	}
 | 
			
		||||
@@ -396,8 +396,7 @@ bool CMeterString::Update()
 | 
			
		||||
	{
 | 
			
		||||
		std::vector<std::wstring> stringValues;
 | 
			
		||||
 | 
			
		||||
		int decimals = (m_NoDecimals && !m_AutoScale) ? 0 : 1;
 | 
			
		||||
		if (m_NumOfDecimals != -1) decimals = m_NumOfDecimals;
 | 
			
		||||
		int decimals = (m_NumOfDecimals != -1) ? m_NumOfDecimals : (m_NoDecimals && (m_Percentual || !m_AutoScale)) ? 0 : 1;
 | 
			
		||||
 | 
			
		||||
		if (m_Measure) stringValues.push_back(m_Measure->GetStringValue(m_AutoScale, m_Scale, decimals, m_Percentual));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user