refactor(weather-editor): remove duplicate code#2154
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRefactored the ImGui particle texture input flow in PrecipitationWidget: compute a single Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/WeatherEditor/Weather/PrecipitationWidget.cpp (1)
79-95: Nit: redundant block scope.The anonymous
{ ... }block around lines 79–95 previously isolated locals that are no longer declared inside it (bufis the only remaining local and doesn't need its own scope). Optional cleanup:Proposed cleanup
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/."); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/WeatherEditor/Weather/PrecipitationWidget.cpp` around lines 79 - 95, Remove the redundant anonymous scope surrounding the texture validation code: unnest the block so the logic using std::string_view buf, lastCheckedBuffer, lastCheckedExists, WeatherUtils::TexturePath::ExistsOnDisk, WeatherUtils::TexturePath::HasDdsExtension and settings.particleTexture runs in the current function scope without an extra `{ ... }`; preserve all existing checks and assignments (updating lastCheckedBuffer/lastCheckedExists, setting settings.particleTexture when inputChanged, and showing ImGui error texts) and only eliminate the unnecessary braces and any extra indentation to keep behavior identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/WeatherEditor/Weather/PrecipitationWidget.cpp`:
- Around line 79-95: Remove the redundant anonymous scope surrounding the
texture validation code: unnest the block so the logic using std::string_view
buf, lastCheckedBuffer, lastCheckedExists,
WeatherUtils::TexturePath::ExistsOnDisk,
WeatherUtils::TexturePath::HasDdsExtension and settings.particleTexture runs in
the current function scope without an extra `{ ... }`; preserve all existing
checks and assignments (updating lastCheckedBuffer/lastCheckedExists, setting
settings.particleTexture when inputChanged, and showing ImGui error texts) and
only eliminate the unnecessary braces and any extra indentation to keep behavior
identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f1c5d241-d865-4a2b-ad22-4014f4c99913
📒 Files selected for processing (1)
src/WeatherEditor/Weather/PrecipitationWidget.cpp
|
✅ A pre-release build is available for this PR: |
Reverts upstream PRs community-shaders#2151, community-shaders#2152, community-shaders#2154 which removed the inline ImageSpaceSettings struct from WeatherWidget and replaced HDR/bloom/cinematic/tint/DoF inline storage with TESImageSpace form pickers. These changes broke existing per-weather edits saved in user JSON files (old 'imageSpaces' array key is silently ignored by the new loader, and SetWeatherValues unconditionally overwrites weather->imageSpaces[] with possibly-null form pointers from missing keys). Restoring the old behavior on the fork pending a forward-compatible migration.
Co-authored-by: SkrubbySkrubInAShrub <skrubbyskrubinashrub@gmail.com> (cherry picked from commit 310f577)
After revisiting my recent PR I noticed that I had a duplicated HasDdsExtension() call.
This PR cleans up this code so that there is only 1 filesystem read instead of 2.
Summary by CodeRabbit