From 923215c0daedbb67351a7fad0a644aaab2d6c19f Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 31 Jul 2013 13:36:53 +0300 Subject: [PATCH] ConfigParser: Implement ReadBool This may break backwards compatibility in some cases. For example, the FreeDiskSpace measure treated only `Type=1` as true and `Type={0, 2, 3, ...}` as false. Now `Type=0` is false and everything else is true like with most other boolean options. --- Library/ConfigParser.h | 1 + Library/Measure.cpp | 8 ++++---- Library/MeasureCalc.cpp | 2 +- Library/MeasureDiskSpace.cpp | 10 +++++----- Library/MeasureMemory.cpp | 2 +- Library/MeasureNet.cpp | 2 +- Library/MeasurePhysicalMemory.cpp | 2 +- Library/MeasureTime.cpp | 2 +- Library/MeasureUptime.cpp | 2 +- Library/MeasureVirtualMemory.cpp | 2 +- Library/Meter.cpp | 8 ++++---- Library/MeterBar.cpp | 2 +- Library/MeterBitmap.cpp | 4 ++-- Library/MeterHistogram.cpp | 4 ++-- Library/MeterLine.cpp | 6 +++--- Library/MeterRoundLine.cpp | 8 ++++---- Library/MeterString.cpp | 2 +- Library/MeterWindow.cpp | 24 ++++++++++++------------ Library/Mouse.cpp | 2 +- Library/Rainmeter.cpp | 16 ++++++++-------- Library/Section.cpp | 2 +- Library/TintedImage.cpp | 4 ++-- Library/TrayWindow.cpp | 2 +- 23 files changed, 59 insertions(+), 58 deletions(-) diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index d4ebe0a1..65b20980 100644 --- a/Library/ConfigParser.h +++ b/Library/ConfigParser.h @@ -69,6 +69,7 @@ public: const std::wstring& ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures = true); bool IsKeyDefined(LPCTSTR section, LPCTSTR key); bool IsValueDefined(LPCTSTR section, LPCTSTR key); + bool ReadBool(LPCTSTR section, LPCTSTR key, bool defValue) { return ReadInt(section, key, (int)defValue) != 0; } int ReadInt(LPCTSTR section, LPCTSTR key, int defValue); uint32_t ReadUInt(LPCTSTR section, LPCTSTR key, uint32_t defValue); uint64_t ReadUInt64(LPCTSTR section, LPCTSTR key, uint64_t defValue); diff --git a/Library/Measure.cpp b/Library/Measure.cpp index c114943e..63293d2b 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -126,10 +126,10 @@ void Measure::ReadOptions(ConfigParser& parser, const WCHAR* section) m_Substitute.clear(); } - m_Invert = 0!=parser.ReadInt(section, L"InvertMeasure", 0); + m_Invert = parser.ReadBool(section, L"InvertMeasure", false); - m_Disabled = 0!=parser.ReadInt(section, L"Disabled", 0); - m_Paused = 0!=parser.ReadInt(section, L"Paused", 0); + m_Disabled = parser.ReadBool(section, L"Disabled", false); + m_Paused = parser.ReadBool(section, L"Paused", false); m_MinValue = parser.ReadFloat(section, L"MinValue", m_MinValue); m_MaxValue = parser.ReadFloat(section, L"MaxValue", m_MaxValue); @@ -149,7 +149,7 @@ void Measure::ReadOptions(ConfigParser& parser, const WCHAR* section) m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0); - m_RegExpSubstitute = 0!=parser.ReadInt(section, L"RegExpSubstitute", 0); + m_RegExpSubstitute = parser.ReadBool(section, L"RegExpSubstitute", false); std::wstring subs = parser.ReadString(section, L"Substitute", L""); if (!subs.empty()) { diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index c802964e..592ebfc3 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -89,7 +89,7 @@ void MeasureCalc::ReadOptions(ConfigParser& parser, const WCHAR* section) m_LowBound = parser.ReadInt(section, L"LowBound", 0); m_HighBound = parser.ReadInt(section, L"HighBound", 100); - m_UpdateRandom = 0!=parser.ReadInt(section, L"UpdateRandom", 0); + m_UpdateRandom = parser.ReadBool(section, L"UpdateRandom", false); if (!m_Initialized || wcscmp(m_Formula.c_str(), oldFormula.c_str()) != 0 || diff --git a/Library/MeasureDiskSpace.cpp b/Library/MeasureDiskSpace.cpp index 3889665d..3229ed4c 100644 --- a/Library/MeasureDiskSpace.cpp +++ b/Library/MeasureDiskSpace.cpp @@ -195,11 +195,11 @@ void MeasureDiskSpace::ReadOptions(ConfigParser& parser, const WCHAR* section) PathUtil::AppendBacklashIfMissing(m_Drive); } - m_Type = (1 == parser.ReadInt(section, L"Type", 0)); - m_Total = (1 == parser.ReadInt(section, L"Total", 0)); - m_Label = (1 == parser.ReadInt(section, L"Label", 0)); - m_IgnoreRemovable = (1 == parser.ReadInt(section, L"IgnoreRemovable", 1)); - m_DiskQuota = (1 == parser.ReadInt(section, L"DiskQuota", 1)); + m_Type = parser.ReadBool(section, L"Type", false); + m_Total = parser.ReadBool(section, L"Total", false); + m_Label = parser.ReadBool(section, L"Label", false); + m_IgnoreRemovable = parser.ReadBool(section, L"IgnoreRemovable", true); + m_DiskQuota = parser.ReadBool(section, L"DiskQuota", true); // Set the m_MaxValue if (!m_Initialized) diff --git a/Library/MeasureMemory.cpp b/Library/MeasureMemory.cpp index 1f515619..9b82a91b 100644 --- a/Library/MeasureMemory.cpp +++ b/Library/MeasureMemory.cpp @@ -72,5 +72,5 @@ void MeasureMemory::ReadOptions(ConfigParser& parser, const WCHAR* section) Measure::ReadOptions(parser, section); m_MaxValue = oldMaxValue; - m_Total = (1 == parser.ReadInt(section, L"Total", 0)); + m_Total = parser.ReadBool(section, L"Total", false); } diff --git a/Library/MeasureNet.cpp b/Library/MeasureNet.cpp index 148a479f..fe8d7fa4 100644 --- a/Library/MeasureNet.cpp +++ b/Library/MeasureNet.cpp @@ -488,7 +488,7 @@ void MeasureNet::ReadOptions(ConfigParser& parser, const WCHAR* section) m_Interface = parser.ReadInt(section, L"Interface", 0); - m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0); + m_Cumulative = parser.ReadBool(section, L"Cumulative", false); if (m_Cumulative) { GetRainmeter().SetNetworkStatisticsTimer(); diff --git a/Library/MeasurePhysicalMemory.cpp b/Library/MeasurePhysicalMemory.cpp index 2ddc2a21..42e41725 100644 --- a/Library/MeasurePhysicalMemory.cpp +++ b/Library/MeasurePhysicalMemory.cpp @@ -67,7 +67,7 @@ void MeasurePhysicalMemory::ReadOptions(ConfigParser& parser, const WCHAR* secti Measure::ReadOptions(parser, section); m_MaxValue = oldMaxValue; - m_Total = (1 == parser.ReadInt(section, L"Total", 0)); + m_Total = parser.ReadBool(section, L"Total", false); if (m_Total) { m_Value = m_MaxValue; diff --git a/Library/MeasureTime.cpp b/Library/MeasureTime.cpp index e98c4ada..c69c3431 100644 --- a/Library/MeasureTime.cpp +++ b/Library/MeasureTime.cpp @@ -248,7 +248,7 @@ void MeasureTime::ReadOptions(ConfigParser& parser, const WCHAR* section) else { double zone = parser.ParseDouble(timezone, 0.0); - bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1); + bool dst = parser.ReadBool(section, L"DaylightSavingTime", true); struct tm* today; time_t now; diff --git a/Library/MeasureUptime.cpp b/Library/MeasureUptime.cpp index d5f7f0e7..e60db735 100644 --- a/Library/MeasureUptime.cpp +++ b/Library/MeasureUptime.cpp @@ -50,7 +50,7 @@ void MeasureUptime::ReadOptions(ConfigParser& parser, const WCHAR* section) if (m_Format.find(L"%4") == std::wstring::npos) { - m_AddDaysToHours = 0!=parser.ReadInt(section, L"AddDaysToHours", 1); + m_AddDaysToHours = parser.ReadBool(section, L"AddDaysToHours", true); } else { diff --git a/Library/MeasureVirtualMemory.cpp b/Library/MeasureVirtualMemory.cpp index a18595dd..d6bb11bc 100644 --- a/Library/MeasureVirtualMemory.cpp +++ b/Library/MeasureVirtualMemory.cpp @@ -72,6 +72,6 @@ void MeasureVirtualMemory::ReadOptions(ConfigParser& parser, const WCHAR* sectio Measure::ReadOptions(parser, section); m_MaxValue = oldMaxValue; - m_Total = (1 == parser.ReadInt(section, L"Total", 0)); + m_Total = parser.ReadBool(section, L"Total", false); } diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 1ca33e11..18c51f08 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -331,7 +331,7 @@ void Meter::ReadOptions(ConfigParser& parser, const WCHAR* section) } bool oldHidden = m_Hidden; - m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0); + m_Hidden = parser.ReadBool(section, L"Hidden", false); if (oldX != m_X || oldY != m_Y || oldHidden != m_Hidden) { @@ -351,10 +351,10 @@ void Meter::ReadOptions(ConfigParser& parser, const WCHAR* section) m_ToolTipTitle = parser.ReadString(section, L"ToolTipTitle", L""); m_ToolTipIcon = parser.ReadString(section, L"ToolTipIcon", L""); m_ToolTipWidth = parser.ReadInt(section, L"ToolTipWidth", 1000); - m_ToolTipType = 0!=parser.ReadInt(section, L"ToolTipType", 0); - m_ToolTipHidden = 0!=parser.ReadInt(section, L"ToolTipHidden", m_MeterWindow->GetMeterToolTipHidden()); + m_ToolTipType = parser.ReadBool(section, L"ToolTipType", false); + m_ToolTipHidden = parser.ReadBool(section, L"ToolTipHidden", m_MeterWindow->GetMeterToolTipHidden()); - m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); + m_AntiAlias = parser.ReadBool(section, L"AntiAlias", false); std::vector matrix = parser.ReadFloats(section, L"TransformationMatrix"); if (matrix.size() == 6) diff --git a/Library/MeterBar.cpp b/Library/MeterBar.cpp index 96ecad82..28a565a7 100644 --- a/Library/MeterBar.cpp +++ b/Library/MeterBar.cpp @@ -105,7 +105,7 @@ void MeterBar::ReadOptions(ConfigParser& parser, const WCHAR* section) m_Border = parser.ReadInt(section, L"BarBorder", 0); - m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); + m_Flip = parser.ReadBool(section, L"Flip", false); const WCHAR* orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL").c_str(); if (_wcsicmp(L"VERTICAL", orientation) == 0) diff --git a/Library/MeterBitmap.cpp b/Library/MeterBitmap.cpp index 0243ce74..5fd7ad4e 100644 --- a/Library/MeterBitmap.cpp +++ b/Library/MeterBitmap.cpp @@ -177,10 +177,10 @@ void MeterBitmap::ReadOptions(ConfigParser& parser, const WCHAR* section) } m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1); - m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 0); + m_ZeroFrame = parser.ReadBool(section, L"BitmapZeroFrame", false); m_Separation = parser.ReadInt(section, L"BitmapSeparation", 0); - m_Extend = 0!=parser.ReadInt(section, L"BitmapExtend", 0); + m_Extend = parser.ReadBool(section, L"BitmapExtend", false); m_Digits = parser.ReadInt(section, L"BitmapDigits", 0); m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0); diff --git a/Library/MeterHistogram.cpp b/Library/MeterHistogram.cpp index 29d9a713..1e764f47 100644 --- a/Library/MeterHistogram.cpp +++ b/Library/MeterHistogram.cpp @@ -243,8 +243,8 @@ void MeterHistogram::ReadOptions(ConfigParser& parser, const WCHAR* section) m_OverlapImage.ClearOptionFlags(); } - m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); - m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); + m_Autoscale = parser.ReadBool(section, L"AutoScale", false); + m_Flip = parser.ReadBool(section, L"Flip", false); const WCHAR* graph = parser.ReadString(section, L"GraphStart", L"RIGHT").c_str(); if (_wcsicmp(graph, L"RIGHT") == 0) diff --git a/Library/MeterLine.cpp b/Library/MeterLine.cpp index 22dc0a91..bebba731 100644 --- a/Library/MeterLine.cpp +++ b/Library/MeterLine.cpp @@ -141,10 +141,10 @@ void MeterLine::ReadOptions(ConfigParser& parser, const WCHAR* section) m_ScaleValues.push_back(parser.ReadFloat(section, tmpName, 1.0)); } - m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); - m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); + m_Flip = parser.ReadBool(section, L"Flip", false); + m_Autoscale = parser.ReadBool(section, L"AutoScale", false); m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0); - m_HorizontalLines = 0!=parser.ReadInt(section, L"HorizontalLines", 0); + m_HorizontalLines = parser.ReadBool(section, L"HorizontalLines", false); ARGB color = parser.ReadColor(section, L"HorizontalColor", Color::Black); // This is left here for backwards compatibility m_HorizontalColor = parser.ReadColor(section, L"HorizontalLineColor", color); // This is what it should be diff --git a/Library/MeterRoundLine.cpp b/Library/MeterRoundLine.cpp index c7d0ef8c..08e72e4e 100644 --- a/Library/MeterRoundLine.cpp +++ b/Library/MeterRoundLine.cpp @@ -73,10 +73,10 @@ void MeterRoundLine::ReadOptions(ConfigParser& parser, const WCHAR* section) m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder); m_LineColor = parser.ReadColor(section, L"LineColor", Color::Black); - m_Solid = 0!=parser.ReadInt(section, L"Solid", 0); - m_CntrlAngle = 0!=parser.ReadInt(section, L"ControlAngle", 1); - m_CntrlLineStart = 0!=parser.ReadInt(section, L"ControlStart", 0); - m_CntrlLineLength = 0!=parser.ReadInt(section, L"ControlLength", 0); + m_Solid = parser.ReadBool(section, L"Solid", false); + m_CntrlAngle = parser.ReadBool(section, L"ControlAngle", true); + m_CntrlLineStart = parser.ReadBool(section, L"ControlStart", false); + m_CntrlLineLength = parser.ReadBool(section, L"ControlLength", false); m_LineStartShift = parser.ReadFloat(section, L"StartShift", 0.0); m_LineLengthShift = parser.ReadFloat(section, L"LengthShift", 0.0); } diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index ddbc761f..ac35bbac 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -178,7 +178,7 @@ void MeterString::ReadOptions(ConfigParser& parser, const WCHAR* section) m_Postfix = parser.ReadString(section, L"Postfix", L""); m_Text = parser.ReadString(section, L"Text", L""); - m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0); + m_Percentual = parser.ReadBool(section, L"Percentual", false); int clipping = parser.ReadInt(section, L"ClipString", 0); switch (clipping) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 6940cb0c..e6edf72e 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -1916,21 +1916,21 @@ void MeterWindow::ReadOptions() int hideMode = parser.ReadInt(section, L"HideOnMouseOver", HIDEMODE_NONE); m_WindowHide = (hideMode >= HIDEMODE_NONE && hideMode <= HIDEMODE_FADEOUT) ? (HIDEMODE)hideMode : HIDEMODE_NONE; - m_WindowDraggable = 0!=parser.ReadInt(section, L"Draggable", 1); + m_WindowDraggable = parser.ReadBool(section, L"Draggable", true); addWriteFlag(OPTION_DRAGGABLE); - m_SnapEdges = 0!=parser.ReadInt(section, L"SnapEdges", 1); + m_SnapEdges = parser.ReadBool(section, L"SnapEdges", true); addWriteFlag(OPTION_SNAPEDGES); - m_ClickThrough = 0!=parser.ReadInt(section, L"ClickThrough", 0); + m_ClickThrough = parser.ReadBool(section, L"ClickThrough", false); addWriteFlag(OPTION_CLICKTHROUGH); - m_KeepOnScreen = 0!=parser.ReadInt(section, L"KeepOnScreen", 1); + m_KeepOnScreen = parser.ReadBool(section, L"KeepOnScreen", true); addWriteFlag(OPTION_KEEPONSCREEN); - m_SavePosition = 0!=parser.ReadInt(section, L"SavePosition", 1); - m_WindowStartHidden = 0!=parser.ReadInt(section, L"StartHidden", 0); - m_AutoSelectScreen = 0!=parser.ReadInt(section, L"AutoSelectScreen", 0); + m_SavePosition = parser.ReadBool(section, L"SavePosition", true); + m_WindowStartHidden = parser.ReadBool(section, L"StartHidden", false); + m_AutoSelectScreen = parser.ReadBool(section, L"AutoSelectScreen", false); m_AlphaValue = parser.ReadInt(section, L"AlphaValue", 255); m_AlphaValue = max(m_AlphaValue, 0); @@ -2074,7 +2074,7 @@ bool MeterWindow::ReadSkin() bool useD2D = GetRainmeter().GetUseD2D(); if (revision_beta) { - useD2D = 0!=m_Parser.ReadInt(L"Rainmeter", L"__UseD2D", useD2D ? 1 : 0); + useD2D = m_Parser.ReadBool(L"Rainmeter", L"__UseD2D", useD2D); } m_Canvas = Gfx::Canvas::Create(useD2D ? Gfx::Renderer::PreferD2D : Gfx::Renderer::GDIP); @@ -2082,7 +2082,7 @@ bool MeterWindow::ReadSkin() // Gotta have some kind of buffer during initialization CreateDoubleBuffer(1, 1); - m_AccurateText = 0!=m_Parser.ReadInt(L"Rainmeter", L"AccurateText", 0); + m_AccurateText = m_Parser.ReadBool(L"Rainmeter", L"AccurateText", false); m_Canvas->SetAccurateText(m_AccurateText); // Check the version @@ -2118,7 +2118,7 @@ bool MeterWindow::ReadSkin() m_SolidColor2 = m_Parser.ReadColor(L"Rainmeter", L"SolidColor2", m_SolidColor.GetValue()); m_SolidAngle = (Gdiplus::REAL)m_Parser.ReadFloat(L"Rainmeter", L"GradientAngle", 0.0); - m_DynamicWindowSize = 0!=m_Parser.ReadInt(L"Rainmeter", L"DynamicWindowSize", 0); + m_DynamicWindowSize = m_Parser.ReadBool(L"Rainmeter", L"DynamicWindowSize", false); if (m_BackgroundMode == BGMODE_IMAGE || m_BackgroundMode == BGMODE_SCALED_IMAGE || m_BackgroundMode == BGMODE_TILED_IMAGE) { @@ -2144,11 +2144,11 @@ bool MeterWindow::ReadSkin() m_WindowUpdate = m_Parser.ReadInt(L"Rainmeter", L"Update", INTERVAL_METER); m_TransitionUpdate = m_Parser.ReadInt(L"Rainmeter", L"TransitionUpdate", INTERVAL_TRANSITION); - m_ToolTipHidden = 0 != m_Parser.ReadInt(L"Rainmeter", L"ToolTipHidden", 0); + m_ToolTipHidden = m_Parser.ReadBool(L"Rainmeter", L"ToolTipHidden", false); if (Platform::IsAtLeastWinVista()) { - if (0 != m_Parser.ReadInt(L"Rainmeter", L"Blur", 0)) + if (m_Parser.ReadBool(L"Rainmeter", L"Blur", false)) { const WCHAR* blurRegion = m_Parser.ReadString(L"Rainmeter", L"BlurRegion", L"", false).c_str(); diff --git a/Library/Mouse.cpp b/Library/Mouse.cpp index c473681f..e42b9dba 100644 --- a/Library/Mouse.cpp +++ b/Library/Mouse.cpp @@ -69,7 +69,7 @@ void Mouse::ReadOptions(ConfigParser& parser, const WCHAR* section) } const bool defaultState = (section == L"Rainmeter") ? true : m_MeterWindow->GetMouse().GetCursorState(); - m_CursorState = 0!=parser.ReadInt(section, L"MouseActionCursor", defaultState); + m_CursorState = parser.ReadBool(section, L"MouseActionCursor", defaultState); const WCHAR* defaultMouseCursor = (section == L"Rainmeter") ? L"HAND" : L""; const WCHAR* mouseCursor = parser.ReadString(section, L"MouseActionCursorName", defaultMouseCursor).c_str(); diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 90656adc..45b81e09 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1255,13 +1255,13 @@ void Rainmeter::ReadGeneralSettings(const std::wstring& iniFile) ConfigParser parser; parser.Initialize(iniFile, nullptr, nullptr); - m_UseD2D = 0!=parser.ReadInt(L"Rainmeter", L"UseD2D", 0); + m_UseD2D = parser.ReadBool(L"Rainmeter", L"UseD2D", false); - m_Debug = 0!=parser.ReadInt(L"Rainmeter", L"Debug", 0); + m_Debug = parser.ReadBool(L"Rainmeter", L"Debug", false); // Read Logging settings Logger& logger = GetLogger(); - const bool logging = parser.ReadInt(L"Rainmeter", L"Logging", 0) != 0; + const bool logging = parser.ReadBool(L"Rainmeter", L"Logging", false); logger.SetLogToFile(logging); if (logging) { @@ -1276,8 +1276,8 @@ void Rainmeter::ReadGeneralSettings(const std::wstring& iniFile) m_GlobalOptions.netInSpeed = parser.ReadFloat(L"Rainmeter", L"NetInSpeed", 0.0); m_GlobalOptions.netOutSpeed = parser.ReadFloat(L"Rainmeter", L"NetOutSpeed", 0.0); - m_DisableDragging = 0!=parser.ReadInt(L"Rainmeter", L"DisableDragging", 0); - m_DisableRDP = 0!=parser.ReadInt(L"Rainmeter", L"DisableRDP", 0); + m_DisableDragging = parser.ReadBool(L"Rainmeter", L"DisableDragging", false); + m_DisableRDP = parser.ReadBool(L"Rainmeter", L"DisableRDP", false); m_SkinEditor = parser.ReadString(L"Rainmeter", L"ConfigEditor", L""); if (m_SkinEditor.empty()) @@ -1298,7 +1298,7 @@ void Rainmeter::ReadGeneralSettings(const std::wstring& iniFile) m_TrayExecuteDR = parser.ReadString(L"Rainmeter", L"TrayExecuteDR", L"", false); m_TrayExecuteDM = parser.ReadString(L"Rainmeter", L"TrayExecuteDM", L"", false); - m_DisableVersionCheck = 0!=parser.ReadInt(L"Rainmeter", L"DisableVersionCheck", 0); + m_DisableVersionCheck = parser.ReadBool(L"Rainmeter", L"DisableVersionCheck", false); const std::wstring& area = parser.ReadString(L"Rainmeter", L"DesktopWorkArea", L""); if (!area.empty()) @@ -1318,9 +1318,9 @@ void Rainmeter::ReadGeneralSettings(const std::wstring& iniFile) } } - m_DesktopWorkAreaType = 0!=parser.ReadInt(L"Rainmeter", L"DesktopWorkAreaType", 0); + m_DesktopWorkAreaType = parser.ReadBool(L"Rainmeter", L"DesktopWorkAreaType", false); - m_NormalStayDesktop = 0!=parser.ReadInt(L"Rainmeter", L"NormalStayDesktop", 1); + m_NormalStayDesktop = parser.ReadBool(L"Rainmeter", L"NormalStayDesktop", true); for (auto iter = parser.GetSections().cbegin(); iter != parser.GetSections().end(); ++iter) { diff --git a/Library/Section.cpp b/Library/Section.cpp index 9fc40d3a..6b7a879c 100644 --- a/Library/Section.cpp +++ b/Library/Section.cpp @@ -53,7 +53,7 @@ void Section::ReadOptions(ConfigParser& parser, const WCHAR* section) m_UpdateCounter = m_UpdateDivider = updateDivider; } - m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0); + m_DynamicVariables = parser.ReadBool(section, L"DynamicVariables", false); m_OnUpdateAction = parser.ReadString(section, L"OnUpdateAction", L"", false); diff --git a/Library/TintedImage.cpp b/Library/TintedImage.cpp index d9084807..d1acc7bb 100644 --- a/Library/TintedImage.cpp +++ b/Library/TintedImage.cpp @@ -691,7 +691,7 @@ void TintedImage::ReadOptions(ConfigParser& parser, const WCHAR* section, const m_NeedsCrop = (oldCrop.X != m_Crop.X || oldCrop.Y != m_Crop.Y || oldCrop.Width != m_Crop.Width || oldCrop.Height != m_Crop.Height || oldCropMode != m_CropMode); - m_GreyScale = 0!=parser.ReadInt(section, m_OptionArray[OptionIndexGreyscale], 0); + m_GreyScale = parser.ReadBool(section, m_OptionArray[OptionIndexGreyscale], false); Color tint = parser.ReadColor(section, m_OptionArray[OptionIndexImageTint], Color::White); int alpha = parser.ReadInt(section, m_OptionArray[OptionIndexImageAlpha], tint.GetAlpha()); // for backwards compatibility @@ -767,7 +767,7 @@ void TintedImage::ReadOptions(ConfigParser& parser, const WCHAR* section, const m_NeedsTinting = (oldGreyScale != m_GreyScale || !CompareColorMatrix(&oldColorMatrix, m_ColorMatrix)); - m_UseExifOrientation = 0!=parser.ReadInt(section, m_OptionArray[OptionIndexUseExifOrientation], 0); + m_UseExifOrientation = parser.ReadBool(section, m_OptionArray[OptionIndexUseExifOrientation], false); const WCHAR* flip = parser.ReadString(section, m_OptionArray[OptionIndexImageFlip], L"NONE").c_str(); if (_wcsicmp(flip, L"NONE") == 0) diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 8e43d229..ba21d96a 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -363,7 +363,7 @@ void TrayWindow::ReadOptions(ConfigParser& parser) m_MeterType = TRAY_METER_TYPE_NONE; // Read tray settings - m_IconEnabled = 0!=parser.ReadInt(L"Rainmeter", L"TrayIcon", 1); + m_IconEnabled = parser.ReadBool(L"Rainmeter", L"TrayIcon", true); if (m_IconEnabled) { const std::wstring& measureName = parser.ReadString(L"TrayMeasure", L"Measure", L"");