diff --git a/BeatSaberMarkupLanguage/Components/BSMLScrollView.cs b/BeatSaberMarkupLanguage/Components/BSMLScrollView.cs index cd29a385..b749c416 100644 --- a/BeatSaberMarkupLanguage/Components/BSMLScrollView.cs +++ b/BeatSaberMarkupLanguage/Components/BSMLScrollView.cs @@ -8,12 +8,6 @@ public class BSMLScrollView : ScrollView { private Coroutine updateLayoutCoroutine; - internal void UpdateViewport() - { - // Resize viewport so it doesn't overlap with scroll bar - viewportTransform.offsetMax = _verticalScrollIndicator != null && _verticalScrollIndicator.gameObject.activeSelf ? new Vector2(-6, 0) : Vector3.zero; - } - private void OnRectTransformDimensionsChange() { if (isActiveAndEnabled && updateLayoutCoroutine == null) diff --git a/BeatSaberMarkupLanguage/Harmony Patches/ScrollViewSetContentSize.cs b/BeatSaberMarkupLanguage/Harmony Patches/ScrollViewSetContentSize.cs deleted file mode 100644 index 71350563..00000000 --- a/BeatSaberMarkupLanguage/Harmony Patches/ScrollViewSetContentSize.cs +++ /dev/null @@ -1,18 +0,0 @@ -using BeatSaberMarkupLanguage.Components; -using HarmonyLib; -using HMUI; - -namespace BeatSaberMarkupLanguage.Harmony_Patches -{ - [HarmonyPatch(typeof(ScrollView), nameof(ScrollView.SetContentSize))] - internal class ScrollViewSetContentSize - { - public static void Postfix(ScrollView __instance) - { - if (__instance is BSMLScrollView bsmlScrollView) - { - bsmlScrollView.UpdateViewport(); - } - } - } -} diff --git a/BeatSaberMarkupLanguage/Tags/CustomListTag.cs b/BeatSaberMarkupLanguage/Tags/CustomListTag.cs index aea2ec43..0f41ecb7 100644 --- a/BeatSaberMarkupLanguage/Tags/CustomListTag.cs +++ b/BeatSaberMarkupLanguage/Tags/CustomListTag.cs @@ -6,7 +6,7 @@ namespace BeatSaberMarkupLanguage.Tags { - public class CustomListTag : BSMLTag + public class CustomListTag : ListTag { private Canvas canvasTemplate; @@ -16,14 +16,26 @@ public class CustomListTag : BSMLTag public override GameObject CreateObject(Transform parent) { - GameObject gameObject = new("BSMLCustomList", typeof(LayoutElement)) + GameObject containerObject = new("BSMLCustomListContainer", typeof(LayoutElement)) + { + layer = 5, + }; + + RectTransform container = (RectTransform)containerObject.transform; + container.SetParent(parent, false); + container.anchorMin = Vector2.zero; + container.anchorMax = Vector2.one; + container.sizeDelta = Vector2.zero; + container.anchoredPosition = Vector2.zero; + + GameObject gameObject = new("BSMLCustomList") { layer = 5, }; gameObject.SetActive(false); - RectTransform rectTransform = (RectTransform)gameObject.transform; - rectTransform.SetParent(parent, false); + RectTransform rectTransform = gameObject.AddComponent(); + rectTransform.SetParent(container, false); rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.sizeDelta = Vector2.zero; @@ -42,7 +54,7 @@ public override GameObject CreateObject(Transform parent) ScrollView scrollView = DiContainer.InstantiateComponent(gameObject); TableView tableView = gameObject.AddComponent(); - CustomCellListTableData tableData = gameObject.AddComponent(); + CustomCellListTableData tableData = containerObject.AddComponent(); tableData.tableView = tableView; tableView._preallocatedCells = new TableView.CellsGroup[0]; @@ -67,7 +79,7 @@ public override GameObject CreateObject(Transform parent) // Changed the bool param to "false", as it would otherwise trigger LazyInit earlier than we want it to tableView.SetDataSource(tableData, false); - return gameObject; + return containerObject; } } } diff --git a/BeatSaberMarkupLanguage/Tags/ListTag.cs b/BeatSaberMarkupLanguage/Tags/ListTag.cs index 2e2664d5..0515a4d6 100644 --- a/BeatSaberMarkupLanguage/Tags/ListTag.cs +++ b/BeatSaberMarkupLanguage/Tags/ListTag.cs @@ -14,14 +14,26 @@ public class ListTag : BSMLTag public override GameObject CreateObject(Transform parent) { - GameObject gameObject = new("BSMLList", typeof(LayoutElement)) + GameObject containerObject = new("BSMLListContainer", typeof(LayoutElement)) + { + layer = 5, + }; + + RectTransform container = (RectTransform)containerObject.transform; + container.SetParent(parent, false); + container.anchorMin = Vector2.zero; + container.anchorMax = Vector2.one; + container.sizeDelta = Vector2.zero; + container.anchoredPosition = Vector2.zero; + + GameObject gameObject = new("BSMLList") { layer = 5, }; gameObject.SetActive(false); - RectTransform rectTransform = (RectTransform)gameObject.transform; - rectTransform.SetParent(parent, false); + RectTransform rectTransform = gameObject.AddComponent(); + rectTransform.SetParent(container, false); rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.sizeDelta = Vector2.zero; @@ -40,7 +52,7 @@ public override GameObject CreateObject(Transform parent) ScrollView scrollView = DiContainer.InstantiateComponent(gameObject); TableView tableView = gameObject.AddComponent(); - CustomListTableData tableData = gameObject.AddComponent(); + CustomListTableData tableData = containerObject.AddComponent(); tableData.tableView = tableView; tableView._preallocatedCells = new TableView.CellsGroup[0]; @@ -64,7 +76,7 @@ public override GameObject CreateObject(Transform parent) viewport.anchoredPosition = Vector2.zero; tableView.SetDataSource(tableData, false); - return gameObject; + return containerObject; } } } diff --git a/BeatSaberMarkupLanguage/TypeHandlers/CustomCellListTableDataHandler.cs b/BeatSaberMarkupLanguage/TypeHandlers/CustomCellListTableDataHandler.cs index cf6ca339..a46c99d0 100644 --- a/BeatSaberMarkupLanguage/TypeHandlers/CustomCellListTableDataHandler.cs +++ b/BeatSaberMarkupLanguage/TypeHandlers/CustomCellListTableDataHandler.cs @@ -88,16 +88,13 @@ public override void HandleType(ComponentTypeWithData componentType, BSMLParserP VerticalScrollIndicator verticalScrollIndicator = textScrollView._verticalScrollIndicator; RectTransform scrollBar = (RectTransform)verticalScrollIndicator.transform.parent; - // Make scrollbar have less padding on the right - scrollBar.offsetMin = new Vector2(-6, 0); - ((RectTransform)verticalScrollIndicator.transform).anchoredPosition = new Vector2(1, -8); - ((RectTransform)pageUpButton.transform.Find("Icon")).anchoredPosition = new Vector2(-2, -4); - ((RectTransform)pageDownButton.transform.Find("Icon")).anchoredPosition = new Vector2(-2, 4); + scrollBar.offsetMin = Vector2.zero; + scrollBar.offsetMax = new Vector2(8, 0); scrollView._pageUpButton = pageUpButton; scrollView._pageDownButton = pageDownButton; scrollView._verticalScrollIndicator = verticalScrollIndicator; - scrollBar.SetParent(scrollView.viewportTransform.parent, false); + scrollBar.SetParent(componentType.component.transform, false); Object.Destroy(textScrollView.gameObject); } diff --git a/BeatSaberMarkupLanguage/TypeHandlers/CustomListTableDataHandler.cs b/BeatSaberMarkupLanguage/TypeHandlers/CustomListTableDataHandler.cs index 025e1f1d..d9ad10e6 100644 --- a/BeatSaberMarkupLanguage/TypeHandlers/CustomListTableDataHandler.cs +++ b/BeatSaberMarkupLanguage/TypeHandlers/CustomListTableDataHandler.cs @@ -88,20 +88,14 @@ public override void HandleType(ComponentTypeWithData componentType, BSMLParserP VerticalScrollIndicator verticalScrollIndicator = textScrollView._verticalScrollIndicator; RectTransform scrollBar = (RectTransform)verticalScrollIndicator.transform.parent; - // Make scrollbar have less padding on the right - scrollBar.offsetMin = new Vector2(-6, 0); - ((RectTransform)verticalScrollIndicator.transform).anchoredPosition = new Vector2(1, -8); - ((RectTransform)pageUpButton.transform.Find("Icon")).anchoredPosition = new Vector2(-2, -4); - ((RectTransform)pageDownButton.transform.Find("Icon")).anchoredPosition = new Vector2(-2, 4); + scrollBar.offsetMin = Vector2.zero; + scrollBar.offsetMax = new Vector2(8, 0); scrollView._pageUpButton = pageUpButton; scrollView._pageDownButton = pageDownButton; scrollView._verticalScrollIndicator = verticalScrollIndicator; - scrollBar.SetParent(scrollView.viewportTransform.parent, false); + scrollBar.SetParent(componentType.component.transform, false); Object.Destroy(textScrollView.gameObject); - - // Resize viewport so it doesn't overlap with scroll bar - scrollView.viewportTransform.offsetMax = new Vector2(-6, 0); } if (componentType.data.TryGetValue("data", out string value)) diff --git a/BeatSaberMarkupLanguage/Views/settings-list.bsml b/BeatSaberMarkupLanguage/Views/settings-list.bsml index bf310e74..44cbbd6a 100644 --- a/BeatSaberMarkupLanguage/Views/settings-list.bsml +++ b/BeatSaberMarkupLanguage/Views/settings-list.bsml @@ -1,3 +1,3 @@ - + \ No newline at end of file