Add GUI scaling and stabilize settings window#9
Open
VerrPower wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
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
.versionmetadata 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). UnderGuiScale != 1.0,Event.current.mousePositionand 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 inTWP.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 newGUILayoutOption[]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 whenWindowWidth/WindowHeightactually changes, and cache theGUILayoutOption[]instead of recreating it.
TransferWindowPlanner/TWPWindowSettings.cs:1- This method allocates a new
GUILayoutOption[]on every call. SinceUpdateWindowSize()is invoked from multiple places (including per-frame paths), this creates steady allocations. CacheWindowOptionsand only rebuild it when width/height changes (or reuse a static array if feasible).
TransferWindowPlanner/TWPWindowSettings.cs:1 SetListBoxOffsetis given the unscaled rect coordinates, but this window is drawn under a scaledGUI.matrixinDrawFixedSettingsGUI(). That can misplace the dropdown list whenGuiScale != 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:1GUI.matrixis modified without atry/finally. If anything inside the subsequent draw path throws,GUI.matrixmay not be restored, potentially corrupting rendering for other IMGUI code. Wrap the scaled draw section intry/finallyand restoreGUI.matrixin thefinallyblock (similar to whatTWPWindowSettings.DrawFixedSettingsGUI()already does).
TransferWindowPlanner/TransferWindowPlanner.csproj:1- Hardcoding
KSP_x64_Datacan break builds for environments/install layouts that only haveKSP_Data(or where the managed directory is different). To keep the project portable, consider using a property like$(KSPManagedDir)(set in a user.propsfile) or conditionalHintPath/Chooselogic to fall back toKSP_DatawhenKSP_x64_Dataisn’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.versionfile (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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds GUI scale support and stabilizes the settings window rendering.
Changes:
Tested: