mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Removed trailing zeros when DynamicVariables=1 even if a value is such as "1.01000".
E.g. 1.00000 -> 1 1.01000 -> 1.01 1.01001 -> 1.01001
This commit is contained in:
parent
8ae8a68547
commit
341e9d2bd0
@ -569,13 +569,8 @@ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int dec
|
||||
}
|
||||
else if (decimals == -1)
|
||||
{
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%.5f", val);
|
||||
|
||||
size_t len = wcslen(buffer);
|
||||
if (len >= 6 && wcscmp(&buffer[len - 6], L".00000") == 0)
|
||||
{
|
||||
buffer[len - 6] = L'\0';
|
||||
}
|
||||
int len = _snwprintf_s(buffer, _TRUNCATE, L"%.5f", val);
|
||||
RemoveTrailingZero(buffer, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -631,6 +626,26 @@ void CMeasure::GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue
|
||||
_snwprintf_s(buffer, sizeInWords, _TRUNCATE, format, value);
|
||||
}
|
||||
|
||||
void CMeasure::RemoveTrailingZero(WCHAR* str, int strLen)
|
||||
{
|
||||
--strLen;
|
||||
while (strLen >= 0)
|
||||
{
|
||||
if (str[strLen] == L'0')
|
||||
{
|
||||
str[strLen] = L'\0';
|
||||
--strLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (str[strLen] == L'.')
|
||||
{
|
||||
str[strLen] = L'\0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** GetStats
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
|
||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
||||
static void GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue, WCHAR* buffer, size_t sizeInWords);
|
||||
static void RemoveTrailingZero(WCHAR* str, int strLen);
|
||||
|
||||
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name);
|
||||
|
||||
|
@ -983,7 +983,8 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
|
||||
if (result != -1)
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%f", value);
|
||||
int len = _snwprintf_s(buffer, _TRUNCATE, L"%.5f", value);
|
||||
CMeasure::RemoveTrailingZero(buffer, len);
|
||||
|
||||
const std::wstring& resultString = buffer;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user