From 8a1fbfa6227786eb7fcee1fdeef2855a13d16962 Mon Sep 17 00:00:00 2001 From: ManlyMarco Date: Wed, 2 Jun 2021 03:22:32 +0200 Subject: [PATCH] Fix layout of card/coord load toggles --- .../Maker/UI/MakerCoordinateLoadToggle.cs | 9 +++++++- .../Maker/UI/MakerLoadToggle.cs | 22 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Shared.KKalike/Maker/UI/MakerCoordinateLoadToggle.cs b/src/Shared.KKalike/Maker/UI/MakerCoordinateLoadToggle.cs index fbc43a2..66a33d1 100644 --- a/src/Shared.KKalike/Maker/UI/MakerCoordinateLoadToggle.cs +++ b/src/Shared.KKalike/Maker/UI/MakerCoordinateLoadToggle.cs @@ -68,6 +68,10 @@ internal static void CreateCustomToggles() var baseToggle = _baseToggles[index]; baseToggle.localPosition = new Vector3(_baseToggle.localPosition.x + singleWidth * index, _verticalOffset, 0); baseToggle.offsetMax = new Vector2(baseToggle.offsetMin.x + singleWidth, baseToggle.offsetMin.y + 26); +#if KKS + // Need to fix text positioning in KKS + KoikatuAPI.Instance.StartCoroutine(FixLayout(baseToggle)); +#endif } } @@ -106,7 +110,10 @@ private static IEnumerator FixLayout(RectTransform rt) { yield return new WaitUntil(() => rt == null || rt.gameObject.activeInHierarchy); yield return null; - +#if KKS + // Need to fix text positioning in KKS + rt.GetComponent().enabled = true; +#endif LayoutRebuilder.MarkLayoutForRebuild(rt); } diff --git a/src/Shared.KKalike/Maker/UI/MakerLoadToggle.cs b/src/Shared.KKalike/Maker/UI/MakerLoadToggle.cs index 6c8f651..1ec1367 100644 --- a/src/Shared.KKalike/Maker/UI/MakerLoadToggle.cs +++ b/src/Shared.KKalike/Maker/UI/MakerLoadToggle.cs @@ -17,7 +17,11 @@ namespace KKAPI.Maker.UI /// public class MakerLoadToggle : BaseEditableGuiEntry { +#if KKS + private const int TotalWidth = 380 + 292 - 25; // KKS has fatter all on/off buttons +#else private const int TotalWidth = 380 + 292 - 5; // -5 for KKP +#endif private static readonly List Toggles = new List(); private static Transform _baseToggle; @@ -89,7 +93,10 @@ private static IEnumerator FixLayout(RectTransform rt) { yield return new WaitUntil(() => rt.gameObject.activeInHierarchy); yield return null; - +#if KKS + // Need to fix text positioning in KKS + rt.GetComponent().enabled = true; +#endif LayoutRebuilder.MarkLayoutForRebuild(rt); } @@ -128,6 +135,10 @@ internal static void Setup() var baseToggle = baseToggles[index]; baseToggle.localPosition = new Vector3(_baseToggle.localPosition.x + singleWidth * index, 52, 0); baseToggle.offsetMax = new Vector2(baseToggle.offsetMin.x + singleWidth, baseToggle.offsetMin.y + 26); +#if KKS + // Need to fix text positioning in KKS + KoikatuAPI.Instance.StartCoroutine(FixLayout(baseToggle)); +#endif } var allon = _root.transform.Find("btnAllOn"); @@ -135,6 +146,11 @@ internal static void Setup() var alloff = _root.transform.Find("btnAllOff"); alloff.GetComponentInChildren