From 04b6aef8c189b28cb6b476d97b053e7561faccc6 Mon Sep 17 00:00:00 2001 From: SkrubbySkrubInAShrub Date: Sun, 19 Apr 2026 13:59:32 +0200 Subject: [PATCH 1/2] chore: remove duplicate code --- .../Weather/PrecipitationWidget.cpp | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/WeatherEditor/Weather/PrecipitationWidget.cpp b/src/WeatherEditor/Weather/PrecipitationWidget.cpp index 2c6c0cea41..a74226e685 100644 --- a/src/WeatherEditor/Weather/PrecipitationWidget.cpp +++ b/src/WeatherEditor/Weather/PrecipitationWidget.cpp @@ -75,26 +75,21 @@ void PrecipitationWidget::DrawWidget() } ImGui::SeparatorText("Texture Path"); - if (ImGui::InputText("Particle Texture", textureBuffer, sizeof(textureBuffer))) { + const bool inputChanged = ImGui::InputText("Particle Texture", textureBuffer, sizeof(textureBuffer)); + { std::string_view buf(textureBuffer); if (buf != lastCheckedBuffer) { - lastCheckedExists = WeatherUtils::TexturePath::ExistsOnDisk(buf); lastCheckedBuffer = std::string(buf); + lastCheckedExists = WeatherUtils::TexturePath::ExistsOnDisk(buf); } - if (lastCheckedExists) { + if (inputChanged && lastCheckedExists) { settings.particleTexture = lastCheckedBuffer; changed = true; } - } - if (std::string_view buf(textureBuffer); settings.particleTexture != buf) { - if (!buf.empty() && !WeatherUtils::TexturePath::HasDdsExtension(buf)) - ImGui::TextColored(globals::menu->GetTheme().StatusPalette.Error, "Path must end with '.dds'"); - else if (!buf.empty()) { - if (buf != lastCheckedBuffer) { - lastCheckedExists = WeatherUtils::TexturePath::ExistsOnDisk(buf); - lastCheckedBuffer = std::string(buf); - } - if (!lastCheckedExists) + if (settings.particleTexture != buf && !buf.empty()) { + if (!WeatherUtils::TexturePath::HasDdsExtension(buf)) + ImGui::TextColored(globals::menu->GetTheme().StatusPalette.Error, "Path must end with '.dds'"); + else if (!lastCheckedExists) ImGui::TextColored(globals::menu->GetTheme().StatusPalette.Error, "Texture file not found under Data/textures/."); } } From d553debdbac55b03ef6929b1b12924573834393e Mon Sep 17 00:00:00 2001 From: SkrubbySkrubInAShrub Date: Sun, 19 Apr 2026 14:27:35 +0200 Subject: [PATCH 2/2] chore: remove redundant block scope --- .../Weather/PrecipitationWidget.cpp | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/WeatherEditor/Weather/PrecipitationWidget.cpp b/src/WeatherEditor/Weather/PrecipitationWidget.cpp index a74226e685..ba0cfaae85 100644 --- a/src/WeatherEditor/Weather/PrecipitationWidget.cpp +++ b/src/WeatherEditor/Weather/PrecipitationWidget.cpp @@ -76,22 +76,20 @@ void PrecipitationWidget::DrawWidget() ImGui::SeparatorText("Texture Path"); const bool inputChanged = ImGui::InputText("Particle Texture", textureBuffer, sizeof(textureBuffer)); - { - std::string_view buf(textureBuffer); - if (buf != lastCheckedBuffer) { - lastCheckedBuffer = std::string(buf); - lastCheckedExists = WeatherUtils::TexturePath::ExistsOnDisk(buf); - } - if (inputChanged && lastCheckedExists) { - settings.particleTexture = lastCheckedBuffer; - changed = true; - } - if (settings.particleTexture != buf && !buf.empty()) { - if (!WeatherUtils::TexturePath::HasDdsExtension(buf)) - ImGui::TextColored(globals::menu->GetTheme().StatusPalette.Error, "Path must end with '.dds'"); - else if (!lastCheckedExists) - ImGui::TextColored(globals::menu->GetTheme().StatusPalette.Error, "Texture file not found under Data/textures/."); - } + std::string_view buf(textureBuffer); + if (buf != lastCheckedBuffer) { + lastCheckedBuffer = std::string(buf); + lastCheckedExists = WeatherUtils::TexturePath::ExistsOnDisk(buf); + } + if (inputChanged && lastCheckedExists) { + settings.particleTexture = lastCheckedBuffer; + changed = true; + } + if (settings.particleTexture != buf && !buf.empty()) { + if (!WeatherUtils::TexturePath::HasDdsExtension(buf)) + ImGui::TextColored(globals::menu->GetTheme().StatusPalette.Error, "Path must end with '.dds'"); + else if (!lastCheckedExists) + ImGui::TextColored(globals::menu->GetTheme().StatusPalette.Error, "Texture file not found under Data/textures/."); } EndScrollableContent();