From b6cb6801dfb44f40e0bbc3f18a410e6072baf25a Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 27 Dec 2022 11:33:44 -0500 Subject: [PATCH] Use RenderTemperature method in OptionsView, always re-render it on defocus, and remove degree symbol --- src/Format.cpp | 6 +++--- src/gui/options/OptionsView.cpp | 15 +-------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/Format.cpp b/src/Format.cpp index 286acf51e..6bbcc4b30 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -184,13 +184,13 @@ void format::RenderTemperature(StringBuilder &sb, float temp, int scale) switch (scale) { case 1: - sb << (temp - 273.15f) << " °C"; + sb << (temp - 273.15f) << "C"; break; case 2: - sb << (temp - 273.15f) * 1.8f + 32.0f << " °F"; + sb << (temp - 273.15f) * 1.8f + 32.0f << "F"; break; default: - sb << temp << " K"; + sb << temp << "K"; break; } } diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index bb7608978..ce25eb826 100644 --- a/src/gui/options/OptionsView.cpp +++ b/src/gui/options/OptionsView.cpp @@ -455,18 +455,7 @@ void OptionsView::AmbientAirTempToTextBox(float airTemp) { StringBuilder sb; sb << Format::Precision(2); - switch (temperatureScale->GetOption().second) - { - case 1: - sb << (airTemp - 273.15f) << "C"; - break; - case 2: - sb << (airTemp - 273.15f) * 1.8f + 32.0f << "F"; - break; - default: - sb << airTemp; - break; - } + format::RenderTemperature(sb, airTemp, temperatureScale->GetOption().second); ambientAirTemp->SetText(sb.Build()); } @@ -499,8 +488,6 @@ void OptionsView::UpdateAirTemp(String temp, bool isDefocus) airTemp = MIN_TEMP; else if (airTemp > MAX_TEMP) airTemp = MAX_TEMP; - else - return; AmbientAirTempToTextBox(airTemp); }