Skip to content

Add GUI scaling and stabilize settings window#9

Open
VerrPower wants to merge 2 commits into
Nazfib:masterfrom
VerrPower:gui-scale
Open

Add GUI scaling and stabilize settings window#9
VerrPower wants to merge 2 commits into
Nazfib:masterfrom
VerrPower:gui-scale

Conversation

@VerrPower

Copy link
Copy Markdown

Adds GUI scale support and stabilizes the settings window rendering.

Changes:

  • Add persisted GUI scale setting, clamped to 1.0-3.0 and rounded to one decimal place
  • Apply GUI scaling through the window framework
  • Rework the settings window to use fixed IMGUI rendering
  • Prevent the settings window from collapsing or flickering while opening and dragging
  • Remove unused source asset and test project files not needed for build or runtime

Tested:

  • Built Release against KSP 1.12.5
  • Verified the settings window opens, drags, and interacts normally in game

Copilot AI review requested due to automatic review settings June 8, 2026 00:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR introduces configurable UI scaling and refactors the settings window rendering to be more stable (fixed IMGUI rendering), while also removing legacy solution/test/versioning artifacts.

Changes:

  • Add persistent GUI scale setting, apply it across windows, and adjust mouse hit-testing for scaling.
  • Rework the settings window layout/rendering to fixed-position IMGUI with updated sizing/positioning behavior.
  • Remove the Visual Studio solution / unit test project files and the KSP-AVC .version metadata file.

Reviewed changes

Copilot reviewed 15 out of 51 changed files in this pull request and generated no comments.

Show a summary per file
File Description
TransferWindowPlanner/TransferWindowPlanner.version Removed KSP-AVC version metadata file.
TransferWindowPlanner/TransferWindowPlanner.sln Removed Visual Studio solution.
TransferWindowPlanner/TransferWindowPlanner.csproj Updated KSP/Unity managed assembly hint paths to x64 locations.
TransferWindowPlanner/TWPWindowSettings.cs Reworked settings UI rendering, added GUI scale + other input fields, added dynamic sizing/positioning helpers.
TransferWindowPlanner/TWPWindow.cs Adjusted settings-window visibility behavior and click-outside detection; disabled blockout windows.
TransferWindowPlanner/TWP.cs Added centralized window GUI scale application; adjusted mouse-over logic for scaling.
TransferWindowPlanner/Settings.cs Added persistent GuiScale and normalization helper.
TransferWindowPlanner/Framework/MonoBehaviourWindow.cs Added GUI.matrix scaling support for windows and scale-aware screen clamping.
TransferWindowPlanner/DateAndTimeTests.playlist Removed test playlist.
README.md Documented UI scaling feature.
PluginFiles/ReadMe-TransferWindowPlanner.txt Added version history entry describing scaling + settings window rework.
KSPDateTimeUnitTests/packages.config Removed unit test NuGet config.
KSPDateTimeUnitTests/UnitTest1.cs Removed unit tests.
KSPDateTimeUnitTests/Properties/AssemblyInfo.cs Removed unit test assembly metadata.
KSPDateTimeUnitTests/KSPDateTimeUnitTests.csproj Removed unit test project file.
Images/SelectedPoint.svg Removed SVG asset.
Comments suppressed due to low confidence (9)

TransferWindowPlanner/TWPWindow.cs:1

  • This click-outside detection doesn’t account for GUI scaling (the main window is scaled via GUI.matrix). Under GuiScale != 1.0, Event.current.mousePosition and the computed rect may be in different coordinate spaces, causing false closes or failing to close. Align both to the same space (e.g., divide mousePosition by scale, or compute the rect in scaled coordinates), ideally by reusing the same scaling logic used in TWP.MouseOverWindow.
    TransferWindowPlanner/TWPWindow.cs:1
  • These lines force the settings blockout windows to be permanently disabled. Previously they were enabled when settings were visible and the main window wasn’t minimized, which likely prevented click-through / unwanted interactions behind the settings UI. If the blockout feature is still required for correctness, restore the previous visibility condition (or provide an equivalent mechanism in the new fixed settings rendering).
    TransferWindowPlanner/TWPWindowSettings.cs:1
  • UpdateWindowSize() is called every frame, and it currently allocates a new GUILayoutOption[] each time (see below). In IMGUI this can add avoidable per-frame GC pressure. Consider updating size/options only when the selected tab/calendar changes or when WindowWidth/WindowHeight actually changes, and cache the GUILayoutOption[] instead of recreating it.
    TransferWindowPlanner/TWPWindowSettings.cs:1
  • This method allocates a new GUILayoutOption[] on every call. Since UpdateWindowSize() is invoked from multiple places (including per-frame paths), this creates steady allocations. Cache WindowOptions and only rebuild it when width/height changes (or reuse a static array if feasible).
    TransferWindowPlanner/TWPWindowSettings.cs:1
  • SetListBoxOffset is given the unscaled rect coordinates, but this window is drawn under a scaled GUI.matrix in DrawFixedSettingsGUI(). That can misplace the dropdown list when GuiScale != 1.0 (button drawn scaled, list offset not scaled). Pass scale-corrected coordinates (or compute the offset in screen space using the same scale) so the popup aligns with the button at all GUI scales.
    TransferWindowPlanner/Framework/MonoBehaviourWindow.cs:1
  • GUI.matrix is modified without a try/finally. If anything inside the subsequent draw path throws, GUI.matrix may not be restored, potentially corrupting rendering for other IMGUI code. Wrap the scaled draw section in try/finally and restore GUI.matrix in the finally block (similar to what TWPWindowSettings.DrawFixedSettingsGUI() already does).
    TransferWindowPlanner/TransferWindowPlanner.csproj:1
  • Hardcoding KSP_x64_Data can break builds for environments/install layouts that only have KSP_Data (or where the managed directory is different). To keep the project portable, consider using a property like $(KSPManagedDir) (set in a user .props file) or conditional HintPath/Choose logic to fall back to KSP_Data when KSP_x64_Data isn’t present.
    TransferWindowPlanner/Settings.cs:1
  • The PR introduces new user-input parsing + normalization behavior (clamping/rounding/NaN/Infinity handling) that’s easy to regress. This repo previously included KSPDateTimeUnitTests, but the unit test project is removed in this PR, leaving no automated coverage for the new GUI scale logic. Please add equivalent tests in the current test setup (or keep/port the test project) to cover at least: NaN/Infinity → 1.0, clamping at 1.0/3.0, and rounding to one decimal place.
    PluginFiles/ReadMe-TransferWindowPlanner.txt:1
  • This change log indicates a new release/version, but the PR also deletes TransferWindowPlanner/TransferWindowPlanner.version (the KSP-AVC metadata file). If you still rely on KSP-AVC/CKAN-style version metadata, removing that file can break update checks and packaging workflows. Consider keeping the .version file (and bumping it to match 1.9.1.2) or documenting the replacement mechanism.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants