From e3ea26412baa317e6699d54ee09a2907d7e927cb Mon Sep 17 00:00:00 2001 From: SkrubbySkrubInAShrub Date: Thu, 12 Mar 2026 11:37:35 +0100 Subject: [PATCH 1/7] feat: add option to hide viewport --- src/WeatherEditor/EditorWindow.cpp | 21 +++++++++++++++------ src/WeatherEditor/EditorWindow.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/WeatherEditor/EditorWindow.cpp b/src/WeatherEditor/EditorWindow.cpp index 9979154a3c..31d80d6c32 100644 --- a/src/WeatherEditor/EditorWindow.cpp +++ b/src/WeatherEditor/EditorWindow.cpp @@ -10,7 +10,7 @@ #include "WeatherUtils.h" #include "imgui_internal.h" -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(EditorWindow::Settings, recordMarkers, markedRecords, autoApplyChanges, useTextButtons, enableInheritFromParent, editorUIScale, favoriteWidgets, recentWidgets, maxRecentWidgets, rememberOpenWidgets, lastOpenWidgets) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(EditorWindow::Settings, recordMarkers, markedRecords, autoApplyChanges, useTextButtons, enableInheritFromParent, editorUIScale, favoriteWidgets, recentWidgets, maxRecentWidgets, rememberOpenWidgets, lastOpenWidgets, hideViewport) void DrawIconStar(ImVec2 center, float radius, ImU32 color, bool filled) { @@ -882,7 +882,8 @@ void EditorWindow::RenderUI() auto& framebuffer = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGETS::kFRAMEBUFFER]; auto& context = globals::d3d::context; - context->ClearRenderTargetView(framebuffer.RTV, (float*)&ImGui::GetStyle().Colors[ImGuiCol_WindowBg]); + if (!settings.hideViewport) + context->ClearRenderTargetView(framebuffer.RTV, (float*)&ImGui::GetStyle().Colors[ImGuiCol_WindowBg]); // Apply editor UI scale ImGuiIO& io = ImGui::GetIO(); @@ -890,7 +891,8 @@ void EditorWindow::RenderUI() io.FontGlobalScale = settings.editorUIScale; // Increase background opacity for all editor windows - ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.0f); + if (!settings.hideViewport) + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.0f); // Check for Ctrl+Z to undo if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) && ImGui::IsKeyPressed(ImGuiKey_Z, false)) { @@ -1020,6 +1022,10 @@ void EditorWindow::RenderUI() ImGui::EndMenu(); } if (ImGui::BeginMenu("Window")) { + if (ImGui::MenuItem("Hide Viewport", nullptr, settings.hideViewport)) { + settings.hideViewport = !settings.hideViewport; + Save(); + } if (ImGui::MenuItem("Palette", nullptr, PaletteWindow::GetSingleton()->open)) { PaletteWindow::GetSingleton()->open = !PaletteWindow::GetSingleton()->open; } @@ -1222,8 +1228,10 @@ void EditorWindow::RenderUI() ImGui::SetNextWindowSize(ImVec2(sideWidth, ImGui::GetIO().DisplaySize.y * 0.75f), ImGuiCond_FirstUseEver); ShowObjectsWindow(); - ImGui::SetNextWindowSize(ImVec2(viewportWidth, ImGui::GetIO().DisplaySize.y * 0.5f), ImGuiCond_FirstUseEver); - ShowViewportWindow(); + if (!settings.hideViewport) { + ImGui::SetNextWindowSize(ImVec2(viewportWidth, ImGui::GetIO().DisplaySize.y * 0.5f), ImGuiCond_FirstUseEver); + ShowViewportWindow(); + } auto settingsWindowHeight = height * 0.25f; auto settingsWindowWidth = width * 0.25f; @@ -1242,7 +1250,8 @@ void EditorWindow::RenderUI() RenderNotifications(); // Pop the alpha style var - ImGui::PopStyleVar(); + if (!settings.hideViewport) + ImGui::PopStyleVar(); // Restore previous font scale io.FontGlobalScale = previousScale; diff --git a/src/WeatherEditor/EditorWindow.h b/src/WeatherEditor/EditorWindow.h index bee8222415..10d0f7b283 100644 --- a/src/WeatherEditor/EditorWindow.h +++ b/src/WeatherEditor/EditorWindow.h @@ -141,6 +141,7 @@ class EditorWindow int maxRecentWidgets = 10; bool rememberOpenWidgets = true; std::vector lastOpenWidgets; + bool hideViewport = false; // Palette settings struct PaletteColorEntry From 024e9d698f57946c3afb42c8512f463edde21b9f Mon Sep 17 00:00:00 2001 From: SkrubbySkrubInAShrub Date: Thu, 12 Mar 2026 11:46:21 +0100 Subject: [PATCH 2/7] fix: black background with viewport enabled --- src/WeatherEditor/EditorWindow.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/WeatherEditor/EditorWindow.cpp b/src/WeatherEditor/EditorWindow.cpp index 31d80d6c32..654c09d62f 100644 --- a/src/WeatherEditor/EditorWindow.cpp +++ b/src/WeatherEditor/EditorWindow.cpp @@ -878,21 +878,15 @@ void EditorWindow::ShowWidgetWindow() void EditorWindow::RenderUI() { - auto renderer = RE::BSGraphics::Renderer::GetSingleton(); - auto& framebuffer = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGETS::kFRAMEBUFFER]; - auto& context = globals::d3d::context; - - if (!settings.hideViewport) - context->ClearRenderTargetView(framebuffer.RTV, (float*)&ImGui::GetStyle().Colors[ImGuiCol_WindowBg]); - // Apply editor UI scale ImGuiIO& io = ImGui::GetIO(); float previousScale = io.FontGlobalScale; io.FontGlobalScale = settings.editorUIScale; - // Increase background opacity for all editor windows - if (!settings.hideViewport) - ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.0f); + if (!settings.hideViewport) { + // Dim the game scene using the theme's modal dim background color + ImGui::GetBackgroundDrawList()->AddRectFilled({ 0, 0 }, io.DisplaySize, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg)); + } // Check for Ctrl+Z to undo if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) && ImGui::IsKeyPressed(ImGuiKey_Z, false)) { @@ -1249,10 +1243,6 @@ void EditorWindow::RenderUI() // Render notifications on top of everything RenderNotifications(); - // Pop the alpha style var - if (!settings.hideViewport) - ImGui::PopStyleVar(); - // Restore previous font scale io.FontGlobalScale = previousScale; } From 5b526958b7920dc2f57cb1e753affde826d655fc Mon Sep 17 00:00:00 2001 From: SkrubbySkrubInAShrub Date: Thu, 12 Mar 2026 12:12:15 +0100 Subject: [PATCH 3/7] fix: prevent drowpdown menu from closing when toggling viewport. --- src/WeatherEditor/EditorWindow.cpp | 9 +++------ src/WeatherEditor/PaletteWindow.cpp | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/WeatherEditor/EditorWindow.cpp b/src/WeatherEditor/EditorWindow.cpp index 654c09d62f..facca8e872 100644 --- a/src/WeatherEditor/EditorWindow.cpp +++ b/src/WeatherEditor/EditorWindow.cpp @@ -817,7 +817,7 @@ void EditorWindow::ShowObjectsWindow() void EditorWindow::ShowViewportWindow() { - ImGui::Begin("Viewport"); + ImGui::Begin("Viewport", nullptr, ImGuiWindowFlags_NoFocusOnAppearing); // Top bar if (DrawGameHourSlider("##ViewportSlider", "Time: %.2f")) { @@ -1016,12 +1016,9 @@ void EditorWindow::RenderUI() ImGui::EndMenu(); } if (ImGui::BeginMenu("Window")) { - if (ImGui::MenuItem("Hide Viewport", nullptr, settings.hideViewport)) { - settings.hideViewport = !settings.hideViewport; + if (ImGui::Checkbox("Hide Viewport", &settings.hideViewport)) Save(); - } - if (ImGui::MenuItem("Palette", nullptr, PaletteWindow::GetSingleton()->open)) { - PaletteWindow::GetSingleton()->open = !PaletteWindow::GetSingleton()->open; + if (ImGui::Checkbox("Palette", &PaletteWindow::GetSingleton()->open)) { } ImGui::Separator(); diff --git a/src/WeatherEditor/PaletteWindow.cpp b/src/WeatherEditor/PaletteWindow.cpp index e5a054867a..132be6f55b 100644 --- a/src/WeatherEditor/PaletteWindow.cpp +++ b/src/WeatherEditor/PaletteWindow.cpp @@ -11,7 +11,7 @@ void PaletteWindow::Draw() ImGui::SetNextWindowSize(ImVec2(600, 400), ImGuiCond_FirstUseEver); ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - 620, ImGui::GetIO().DisplaySize.y - 420), ImGuiCond_FirstUseEver); - if (ImGui::Begin("Palette", &open)) { + if (ImGui::Begin("Palette", &open, ImGuiWindowFlags_NoFocusOnAppearing)) { if (ImGui::BeginTabBar("PaletteTabs")) { if (ImGui::BeginTabItem("Colours")) { DrawColorsTab(); From f1365fe50b833aa3b32096dc7444c2ad54fbd55e Mon Sep 17 00:00:00 2001 From: SkrubbySkrubInAShrub Date: Thu, 12 Mar 2026 12:24:41 +0100 Subject: [PATCH 4/7] fix: move the time slider to the headerbar so it is always accessible --- src/WeatherEditor/EditorWindow.cpp | 20 +++++++++++++------- src/WeatherEditor/EditorWindow.h | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/WeatherEditor/EditorWindow.cpp b/src/WeatherEditor/EditorWindow.cpp index facca8e872..d301f47be7 100644 --- a/src/WeatherEditor/EditorWindow.cpp +++ b/src/WeatherEditor/EditorWindow.cpp @@ -819,13 +819,6 @@ void EditorWindow::ShowViewportWindow() { ImGui::Begin("Viewport", nullptr, ImGuiWindowFlags_NoFocusOnAppearing); - // Top bar - if (DrawGameHourSlider("##ViewportSlider", "Time: %.2f")) { - ImGui::SameLine(); - int activePeriod = TOD::GetActivePeriod(); - ImGui::Text("(%s)", TOD::GetPeriodName(activePeriod)); - } - // The size of the image in ImGui // Get the available space in the current window ImVec2 availableSpace = ImGui::GetContentRegionAvail(); @@ -1185,9 +1178,22 @@ void EditorWindow::RenderUI() ImGui::PopStyleColor(); } + // Time slider anchored to the right of the menu bar // Close button on the right side float menuBarHeight = ImGui::GetFrameHeight(); float closeButtonSize = menuBarHeight * 0.9f; // 10% smaller than menu bar + + // Time slider anchored to the right of the menu bar + { + const float& itemSpacing = ImGui::GetStyle().ItemSpacing.x; + ImGui::SameLine(ImGui::GetWindowWidth() - closeButtonSize - 10.0f - itemSpacing - kMenuBarSliderWidth); + ImGui::SetNextItemWidth(kMenuBarSliderWidth); + if (DrawGameHourSlider("##MenuBarSlider", "Time: %.2f")) { + ImGui::SameLine(); + ImGui::Text("(%s)", TOD::GetPeriodName(TOD::GetActivePeriod())); + } + } + ImGui::SameLine(ImGui::GetWindowWidth() - closeButtonSize - 10.0f); auto errorColor = Menu::GetSingleton()->GetSettings().Theme.StatusPalette.Error; auto errorHoverColor = errorColor; diff --git a/src/WeatherEditor/EditorWindow.h b/src/WeatherEditor/EditorWindow.h index 10d0f7b283..cd9d10ba65 100644 --- a/src/WeatherEditor/EditorWindow.h +++ b/src/WeatherEditor/EditorWindow.h @@ -53,6 +53,7 @@ class EditorWindow static constexpr float kGameHourMax = 23.99f; static constexpr float kTimeScaleMin = 0.1f; static constexpr float kTimeScaleMax = 4000.0f; + static constexpr float kMenuBarSliderWidth = 200.0f; // Vanity camera control bool vanityCameraDisabled = false; From fdb32289f6c5661093c0337254461eb602d843bf Mon Sep 17 00:00:00 2001 From: SkrubbySkrubInAShrub Date: Thu, 12 Mar 2026 16:08:03 +0100 Subject: [PATCH 5/7] fix: address AI --- src/WeatherEditor/EditorWindow.cpp | 25 ++++++++++++++++--------- src/WeatherEditor/EditorWindow.h | 4 ++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/WeatherEditor/EditorWindow.cpp b/src/WeatherEditor/EditorWindow.cpp index d301f47be7..48009de1d5 100644 --- a/src/WeatherEditor/EditorWindow.cpp +++ b/src/WeatherEditor/EditorWindow.cpp @@ -10,7 +10,7 @@ #include "WeatherUtils.h" #include "imgui_internal.h" -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(EditorWindow::Settings, recordMarkers, markedRecords, autoApplyChanges, useTextButtons, enableInheritFromParent, editorUIScale, favoriteWidgets, recentWidgets, maxRecentWidgets, rememberOpenWidgets, lastOpenWidgets, hideViewport) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(EditorWindow::Settings, recordMarkers, markedRecords, autoApplyChanges, useTextButtons, enableInheritFromParent, editorUIScale, favoriteWidgets, recentWidgets, maxRecentWidgets, rememberOpenWidgets, lastOpenWidgets, showViewport) void DrawIconStar(ImVec2 center, float radius, ImU32 color, bool filled) { @@ -876,7 +876,7 @@ void EditorWindow::RenderUI() float previousScale = io.FontGlobalScale; io.FontGlobalScale = settings.editorUIScale; - if (!settings.hideViewport) { + if (settings.showViewport) { // Dim the game scene using the theme's modal dim background color ImGui::GetBackgroundDrawList()->AddRectFilled({ 0, 0 }, io.DisplaySize, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg)); } @@ -1009,8 +1009,9 @@ void EditorWindow::RenderUI() ImGui::EndMenu(); } if (ImGui::BeginMenu("Window")) { - if (ImGui::Checkbox("Hide Viewport", &settings.hideViewport)) + if (ImGui::Checkbox("Viewport", &settings.showViewport)) { Save(); + } if (ImGui::Checkbox("Palette", &PaletteWindow::GetSingleton()->open)) { } @@ -1186,11 +1187,17 @@ void EditorWindow::RenderUI() // Time slider anchored to the right of the menu bar { const float& itemSpacing = ImGui::GetStyle().ItemSpacing.x; - ImGui::SameLine(ImGui::GetWindowWidth() - closeButtonSize - 10.0f - itemSpacing - kMenuBarSliderWidth); - ImGui::SetNextItemWidth(kMenuBarSliderWidth); - if (DrawGameHourSlider("##MenuBarSlider", "Time: %.2f")) { - ImGui::SameLine(); - ImGui::Text("(%s)", TOD::GetPeriodName(TOD::GetActivePeriod())); + char periodBuf[64]; + std::snprintf(periodBuf, sizeof(periodBuf), "(%s)", TOD::GetPeriodName(TOD::GetActivePeriod())); + float periodWidth = ImGui::CalcTextSize(periodBuf).x; + const float sliderStartX = ImGui::GetWindowWidth() - closeButtonSize - 10.0f - itemSpacing - kMenuBarSliderWidth; + auto calendar = globals::game::calendar ? globals::game::calendar : RE::Calendar::GetSingleton(); + if (calendar && calendar->gameHour) { + ImGui::SameLine(sliderStartX - itemSpacing - periodWidth); + ImGui::TextUnformatted(periodBuf); + ImGui::SameLine(sliderStartX); + ImGui::SetNextItemWidth(kMenuBarSliderWidth); + DrawGameHourSlider("##MenuBarSlider", "Time: %.2f"); } } @@ -1225,7 +1232,7 @@ void EditorWindow::RenderUI() ImGui::SetNextWindowSize(ImVec2(sideWidth, ImGui::GetIO().DisplaySize.y * 0.75f), ImGuiCond_FirstUseEver); ShowObjectsWindow(); - if (!settings.hideViewport) { + if (settings.showViewport) { ImGui::SetNextWindowSize(ImVec2(viewportWidth, ImGui::GetIO().DisplaySize.y * 0.5f), ImGuiCond_FirstUseEver); ShowViewportWindow(); } diff --git a/src/WeatherEditor/EditorWindow.h b/src/WeatherEditor/EditorWindow.h index cd9d10ba65..4f54e8b93c 100644 --- a/src/WeatherEditor/EditorWindow.h +++ b/src/WeatherEditor/EditorWindow.h @@ -53,7 +53,7 @@ class EditorWindow static constexpr float kGameHourMax = 23.99f; static constexpr float kTimeScaleMin = 0.1f; static constexpr float kTimeScaleMax = 4000.0f; - static constexpr float kMenuBarSliderWidth = 200.0f; + static constexpr float kMenuBarSliderWidth = 400.0f; // Vanity camera control bool vanityCameraDisabled = false; @@ -142,7 +142,7 @@ class EditorWindow int maxRecentWidgets = 10; bool rememberOpenWidgets = true; std::vector lastOpenWidgets; - bool hideViewport = false; + bool showViewport = true; // Palette settings struct PaletteColorEntry From c76dada468af9c1f8a7c7f09f58c2a02606f055d Mon Sep 17 00:00:00 2001 From: SkrubbySkrubInAShrub Date: Thu, 12 Mar 2026 16:25:01 +0100 Subject: [PATCH 6/7] fix: address more AI --- src/WeatherEditor/EditorWindow.cpp | 67 ++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/src/WeatherEditor/EditorWindow.cpp b/src/WeatherEditor/EditorWindow.cpp index 48009de1d5..8c5827d6c3 100644 --- a/src/WeatherEditor/EditorWindow.cpp +++ b/src/WeatherEditor/EditorWindow.cpp @@ -837,7 +837,11 @@ void EditorWindow::ShowViewportWindow() imageSize.x = availableSpace.y * aspectRatio; } - ImGui::Image((void*)tempTexture->srv.get(), imageSize); + if (tempTexture && tempTexture->srv) { + ImGui::Image((void*)tempTexture->srv.get(), imageSize); + } else { + ImGui::TextDisabled("Viewport unavailable"); + } ImGui::End(); } @@ -1347,29 +1351,48 @@ void EditorWindow::Draw() } } - auto renderer = RE::BSGraphics::Renderer::GetSingleton(); - auto& framebuffer = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGETS::kFRAMEBUFFER]; - - ID3D11Resource* resource = nullptr; - framebuffer.SRV->GetResource(&resource); - - if (!tempTexture) { - D3D11_TEXTURE2D_DESC texDesc{}; - ((ID3D11Texture2D*)resource)->GetDesc(&texDesc); - - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc{}; - framebuffer.SRV->GetDesc(&srvDesc); - - tempTexture = new Texture2D(texDesc); - tempTexture->CreateSRV(srvDesc); - } - - auto& context = globals::d3d::context; + if (!settings.showViewport) { + delete tempTexture; + tempTexture = nullptr; + } else { + auto renderer = RE::BSGraphics::Renderer::GetSingleton(); + if (renderer) { + auto& framebuffer = renderer->GetRuntimeData().renderTargets[RE::RENDER_TARGETS::kFRAMEBUFFER]; + if (framebuffer.SRV) { + ID3D11Resource* resource = nullptr; + framebuffer.SRV->GetResource(&resource); + + if (resource) { + auto texture = static_cast(resource); + D3D11_TEXTURE2D_DESC texDesc{}; + texture->GetDesc(&texDesc); + + const bool needsRecreate = !tempTexture || !tempTexture->resource || !tempTexture->srv || + tempTexture->desc.Width != texDesc.Width || tempTexture->desc.Height != texDesc.Height || + tempTexture->desc.MipLevels != texDesc.MipLevels || tempTexture->desc.ArraySize != texDesc.ArraySize || + tempTexture->desc.Format != texDesc.Format || + tempTexture->desc.SampleDesc.Count != texDesc.SampleDesc.Count || + tempTexture->desc.SampleDesc.Quality != texDesc.SampleDesc.Quality; + + if (needsRecreate) { + delete tempTexture; + tempTexture = nullptr; + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc{}; + framebuffer.SRV->GetDesc(&srvDesc); + + tempTexture = new Texture2D(texDesc); + tempTexture->CreateSRV(srvDesc); + } - context->CopyResource(tempTexture->resource.get(), resource); + if (tempTexture && tempTexture->resource) { + globals::d3d::context->CopyResource(tempTexture->resource.get(), resource); + } - if (resource) { - resource->Release(); + resource->Release(); + } + } + } } RenderUI(); From eade25d063ff6959c230ce10bae4168ba254b64a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:25:38 +0000 Subject: [PATCH 7/7] =?UTF-8?q?style:=20=F0=9F=8E=A8=20apply=20pre-commit.?= =?UTF-8?q?ci=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details. --- src/WeatherEditor/EditorWindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/WeatherEditor/EditorWindow.cpp b/src/WeatherEditor/EditorWindow.cpp index 8c5827d6c3..0da586a278 100644 --- a/src/WeatherEditor/EditorWindow.cpp +++ b/src/WeatherEditor/EditorWindow.cpp @@ -1368,11 +1368,11 @@ void EditorWindow::Draw() texture->GetDesc(&texDesc); const bool needsRecreate = !tempTexture || !tempTexture->resource || !tempTexture->srv || - tempTexture->desc.Width != texDesc.Width || tempTexture->desc.Height != texDesc.Height || - tempTexture->desc.MipLevels != texDesc.MipLevels || tempTexture->desc.ArraySize != texDesc.ArraySize || - tempTexture->desc.Format != texDesc.Format || - tempTexture->desc.SampleDesc.Count != texDesc.SampleDesc.Count || - tempTexture->desc.SampleDesc.Quality != texDesc.SampleDesc.Quality; + tempTexture->desc.Width != texDesc.Width || tempTexture->desc.Height != texDesc.Height || + tempTexture->desc.MipLevels != texDesc.MipLevels || tempTexture->desc.ArraySize != texDesc.ArraySize || + tempTexture->desc.Format != texDesc.Format || + tempTexture->desc.SampleDesc.Count != texDesc.SampleDesc.Count || + tempTexture->desc.SampleDesc.Quality != texDesc.SampleDesc.Quality; if (needsRecreate) { delete tempTexture;