From f15ecdd09b647bd388b8091c6f1ca9d2ba9ff120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sat, 15 Feb 2025 20:44:17 +0100 Subject: [PATCH] Fix prop sampling ignoring temperature scale So it would always sample in K. For example, sampling something with a temp of 20C would sample the string "295.15" without specifying a scale, which would then translate to 295.15C once OK'd. --- src/gui/game/tool/PropertyTool.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/game/tool/PropertyTool.cpp b/src/gui/game/tool/PropertyTool.cpp index f3e623d04..10e5b6243 100644 --- a/src/gui/game/tool/PropertyTool.cpp +++ b/src/gui/game/tool/PropertyTool.cpp @@ -3,6 +3,7 @@ #include "gui/Style.h" #include "gui/game/Brush.h" #include "gui/game/GameModel.h" +#include "gui/game/GameController.h" #include "gui/interface/Window.h" #include "gui/interface/Button.h" #include "gui/interface/Textbox.h" @@ -10,6 +11,7 @@ #include "simulation/Simulation.h" #include "simulation/SimulationData.h" #include "graphics/Graphics.h" +#include "Format.h" #include class PropertyWindow: public ui::Window @@ -102,7 +104,18 @@ std::optional> PropertyWindow::TakePropertyFrom(const Sim } auto value = toolConfiguration->changeProperty.Get(sim, *i); auto &prop = Particle::GetProperties()[toolConfiguration->changeProperty.propertyIndex]; - return std::pair{ toolConfiguration->changeProperty.propertyIndex, prop.ToString(value) }; + String valueString; + if (prop.Name == "temp") + { + StringBuilder sb; + format::RenderTemperature(sb, std::get(value), GameController::Ref().GetTemperatureScale()); + valueString = sb.Build(); + } + else + { + valueString = prop.ToString(value); + } + return std::pair{ toolConfiguration->changeProperty.propertyIndex, valueString }; } void PropertyWindow::HandlePropertyChange()