From 9702aa2046ef9be93b382b8fa42647b3998839cf Mon Sep 17 00:00:00 2001 From: Scialytic <11653155+Scialytic@users.noreply.github.com> Date: Thu, 3 Mar 2022 14:27:58 -0500 Subject: [PATCH 1/8] Improve behavior when there are many subtypes --- B9PartSwitch/UI/UIPartActionSubtypeSelector.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/B9PartSwitch/UI/UIPartActionSubtypeSelector.cs b/B9PartSwitch/UI/UIPartActionSubtypeSelector.cs index 9212faca..0545185e 100644 --- a/B9PartSwitch/UI/UIPartActionSubtypeSelector.cs +++ b/B9PartSwitch/UI/UIPartActionSubtypeSelector.cs @@ -111,6 +111,21 @@ public override void Setup(UIPartActionWindow window, Part part, PartModule part subtypeTitleText.text = switcherModule.CurrentSubtype.title; subtypeButtons[currentButtonIndex].Activate(); + + // up to 7 subtypeButtons fit in the PAW without scrolling + if (subtypeButtons.Count > 7) + { + scrollMain.scrollSensitivity = subtypeButtons.Count; + // scrollMain.horizontalNormalizedPosition is the left edge of the viewport relative to the content. + // scrollMain.viewport.rect.width will be 200+(2/3) units after layout stuff is finished. Sadly, it is 0 when this code runs so we can't make use of it here. + // Each button is effectively 28 units wide, meaning the viewport is 7+(1/6) buttons wide. + // If we scroll past the last button, the buttons will bounce back so that the last button is touching the viewport's right edge. + // That bounce could make a player lose their place in the button list (plus it just looks bad). Therefore, we don't use 1.0 to set the viewport full right. + const float viewportWidthInButtons = 7+1/6f; + if (currentButtonIndex < 4) scrollMain.horizontalNormalizedPosition = 0f; + else if (subtypeButtons.Count - currentButtonIndex < 5) scrollMain.horizontalNormalizedPosition = (subtypeButtons.Count - viewportWidthInButtons) / subtypeButtons.Count; + else scrollMain.horizontalNormalizedPosition = (currentButtonIndex + 4 - viewportWidthInButtons) / subtypeButtons.Count; + } } private void PreviousSubtype() From 76824bfd4c7a2774606e03fdee17a8e7920b21f1 Mon Sep 17 00:00:00 2001 From: Scialytic <11653155+Scialytic@users.noreply.github.com> Date: Thu, 3 Mar 2022 14:33:17 -0500 Subject: [PATCH 2/8] Use scrolling when normal popup would be too tall --- .../PartSwitch/PartSwitchFlightDialog.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs b/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs index 3df83646..52205975 100644 --- a/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs +++ b/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs @@ -3,6 +3,8 @@ using System.Linq; using TMPro; using B9PartSwitch.UI; +using UnityEngine; +using UnityEngine.UI; namespace B9PartSwitch { @@ -104,7 +106,28 @@ private static DialogGUIBase[] CreateOptions(ModuleB9PartSwitch module, IList Date: Thu, 3 Mar 2022 14:39:30 -0500 Subject: [PATCH 3/8] TextRenderingModule needed for TextAnchor --- B9PartSwitch/B9PartSwitch.csproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/B9PartSwitch/B9PartSwitch.csproj b/B9PartSwitch/B9PartSwitch.csproj index c8d15c94..ca25699a 100644 --- a/B9PartSwitch/B9PartSwitch.csproj +++ b/B9PartSwitch/B9PartSwitch.csproj @@ -46,6 +46,9 @@ False + + False + False @@ -202,4 +205,4 @@ --> - \ No newline at end of file + From ba5749a9c9807d40688ad967ffcb3a9c1da2d33f Mon Sep 17 00:00:00 2001 From: Scialytic <11653155+Scialytic@users.noreply.github.com> Date: Fri, 4 Mar 2022 00:04:15 -0500 Subject: [PATCH 4/8] fix unneeded newline From c87dafe9194972919fa23cfab3cf39aadc9b3275 Mon Sep 17 00:00:00 2001 From: Scialytic <11653155+Scialytic@users.noreply.github.com> Date: Fri, 4 Mar 2022 00:07:47 -0500 Subject: [PATCH 5/8] Remove reminder comment --- B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs b/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs index 52205975..6ac10629 100644 --- a/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs +++ b/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs @@ -109,7 +109,6 @@ private static DialogGUIBase[] CreateOptions(ModuleB9PartSwitch module, IList Date: Fri, 4 Mar 2022 04:33:58 -0500 Subject: [PATCH 6/8] Fix unneeded newline (for real this time) --- B9PartSwitch/B9PartSwitch.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/B9PartSwitch/B9PartSwitch.csproj b/B9PartSwitch/B9PartSwitch.csproj index ca25699a..d2a6b065 100644 --- a/B9PartSwitch/B9PartSwitch.csproj +++ b/B9PartSwitch/B9PartSwitch.csproj @@ -46,7 +46,7 @@ False - + False @@ -205,4 +205,4 @@ --> - + \ No newline at end of file From a67e74fae7424867887b1f1e288ee6553f73c5df Mon Sep 17 00:00:00 2001 From: Scialytic <11653155+Scialytic@users.noreply.github.com> Date: Fri, 4 Mar 2022 04:37:07 -0500 Subject: [PATCH 7/8] spaces not tab --- B9PartSwitch/B9PartSwitch.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/B9PartSwitch/B9PartSwitch.csproj b/B9PartSwitch/B9PartSwitch.csproj index d2a6b065..3f15cc6e 100644 --- a/B9PartSwitch/B9PartSwitch.csproj +++ b/B9PartSwitch/B9PartSwitch.csproj @@ -46,7 +46,7 @@ False - + False From 2582f4525924181fdcfd01593ec82110fa1b996a Mon Sep 17 00:00:00 2001 From: Scialytic <11653155+Scialytic@users.noreply.github.com> Date: Sat, 29 Oct 2022 22:57:28 -0400 Subject: [PATCH 8/8] Add files via upload --- B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs b/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs index 6ac10629..0f5bf0fe 100644 --- a/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs +++ b/B9PartSwitch/PartSwitch/PartSwitchFlightDialog.cs @@ -78,6 +78,8 @@ private static DialogGUIBase[] CreateOptions(ModuleB9PartSwitch module, IList