diff --git a/AGENTS.md b/AGENTS.md index 91b585d..6f52676 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -158,3 +158,4 @@ The sync is implemented as an inline PowerShell `Exec` step inside the `ZipMod` - **Mod-compatibility reflection:** Use `UXAssist.Common.ModCompat.ModCompatHelper` for BepInEx plugin detection, external mod type/method/field resolution, and property-setter lookup. Preserve the old public type identity with a forwarding or inherited compatibility facade when a refactor moves a type that external mods may locate through reflection; build and verify that the legacy reflection target forwards to the refactored implementation. Use `UXAssist.Common.Utils.DysonSphereReflection` for the DSPOptimizations-compatible `DysonSphereLayer` private fields (`totalNodeSP`, `totalFrameSP`, `totalCP`) instead of resolving them locally in each consumer. - **Build quality gates:** Root `.editorconfig` defines suggestion-only C# style conventions. `Directory.Build.props` enables `TreatWarningsAsErrors` with `NoWarn>0618` for the expected obsolete-API usage, so any new warning fails the build. `.github/workflows/build.yml` runs a Release build and packages the three main mods on every push/PR. - **Save persistence:** Mods that need to persist data use the `IModCanSave` interface from DSPModSave. +- **Cloned UI button reset:** `UXAssist.UI.Util.ResetButton` calls the original `UIButton.Init` before resetting copied interaction state, preserving the original `Transition.normalColor` values. Do not replace cloned UI styles with guessed colors such as `Color.white`; clear runtime state while retaining the source's default style. diff --git a/UXAssist/Functions/UI/MenuButtonUI.cs b/UXAssist/Functions/UI/MenuButtonUI.cs index ad847c4..288f062 100644 --- a/UXAssist/Functions/UI/MenuButtonUI.cs +++ b/UXAssist/Functions/UI/MenuButtonUI.cs @@ -79,10 +79,7 @@ internal static class MenuButtonUI btn.name = "button-uxassist-config"; btn.button.enabled = true; btn.button.interactable = true; - btn.text.color = Color.white; btn.text.fontStyle = FontStyle.Normal; - btn.selectBg.color = new Color(1f, 1f, 1f, 0f); - btn.selectBar.color = new Color(1f, 1f, 1f, 0f); var l = btn.text.GetComponent(); if (l != null) { @@ -114,7 +111,6 @@ internal static class MenuButtonUI if (img != null) { img.sprite = icon; - img.color = Color.white; img.enabled = icon != null; } diff --git a/UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs b/UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs index dc930bc..bde3d6d 100644 --- a/UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs +++ b/UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs @@ -354,7 +354,6 @@ internal static class RealtimeLogisticsInfoPanel var itemIcon = Object.Instantiate(tipIconPrefab.gameObject, new Vector3(0, 0, 0), Quaternion.identity, _tipPrefab.transform); itemIcon.name = "icon" + index; var itemIconImage = itemIcon.GetComponent(); - itemIconImage.color = Color.white; itemIconImage.enabled = true; rectTrans = (RectTransform)itemIcon.transform; rectTrans.sizeDelta = new Vector2(30f, 30f); @@ -402,7 +401,6 @@ internal static class RealtimeLogisticsInfoPanel var text = countText.GetComponent(); text.fontSize = 18; text.text = ""; - text.color = Color.white; text.alignment = TextAnchor.UpperRight; text.fontStyle = FontStyle.Normal; text.horizontalOverflow = HorizontalWrapMode.Overflow; @@ -419,7 +417,6 @@ internal static class RealtimeLogisticsInfoPanel stateLocal.name = "iconLocal" + index; var stateLocalImage = stateLocal.GetComponent(); stateLocalImage.material = null; - stateLocalImage.color = Color.white; stateLocalImage.enabled = true; rectTrans = (RectTransform)stateLocal.transform; rectTrans.sizeDelta = new Vector2(16f, 16f); @@ -431,7 +428,6 @@ internal static class RealtimeLogisticsInfoPanel stateRemote.name = "iconRemote" + index; var stateRemoteImage = stateRemote.GetComponent(); stateRemoteImage.material = null; - stateRemoteImage.color = Color.white; stateRemoteImage.enabled = true; rectTrans = (RectTransform)stateRemote.transform; rectTrans.sizeDelta = new Vector2(20f, 20f); @@ -443,7 +439,6 @@ internal static class RealtimeLogisticsInfoPanel var iconPrefab = Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Top Tips/Entity Briefs/brief-info-top/brief-info/content/icons/icon"), _tipPrefab.transform); var iconPrefabImage = iconPrefab.GetComponent(); - iconPrefabImage.color = Color.white; iconPrefabImage.enabled = true; Object.Destroy(iconPrefab.transform.Find("count-text").gameObject); Object.Destroy(iconPrefab.transform.Find("bg").gameObject); diff --git a/UXAssist/Patches/PlayerPatch.cs b/UXAssist/Patches/PlayerPatch.cs index 462ad11..b7133a3 100644 --- a/UXAssist/Patches/PlayerPatch.cs +++ b/UXAssist/Patches/PlayerPatch.cs @@ -730,7 +730,6 @@ public class PlayerPatch : PatchImpl UiTipText = Object.Instantiate(originText, originText.transform.parent); UiTipText.gameObject.SetActive(false); UiTipText.rectTransform.anchoredPosition = new Vector2(0f, 160f); - UiTipText.color = Color.white; UiTipText.fontStyle = FontStyle.Normal; UiTipText.text = I18NKeys.AutoNavigationActive.Translate(); } diff --git a/UXAssist/UI/LayoutHelper.cs b/UXAssist/UI/LayoutHelper.cs index b354c17..dcb7ce4 100644 --- a/UXAssist/UI/LayoutHelper.cs +++ b/UXAssist/UI/LayoutHelper.cs @@ -72,7 +72,6 @@ public static class LayoutHelper if (t != null) { t.text = text.Translate(); - t.color = Color.white; t.fontStyle = FontStyle.Normal; t.horizontalOverflow = HorizontalWrapMode.Overflow; t.verticalOverflow = VerticalWrapMode.Overflow; diff --git a/UXAssist/UI/MyCheckButton.cs b/UXAssist/UI/MyCheckButton.cs index ee9a29d..3a5df46 100644 --- a/UXAssist/UI/MyCheckButton.cs +++ b/UXAssist/UI/MyCheckButton.cs @@ -47,7 +47,6 @@ public class MyCheckButton : MonoBehaviour { txt.text = ""; txt.alignment = TextAnchor.MiddleCenter; - txt.color = Color.white; txt.fontStyle = FontStyle.Normal; txt.rectTransform.anchorMax = new Vector2(0f, 1f); txt.rectTransform.anchorMin = new Vector2(0f, 1f); @@ -95,7 +94,6 @@ public class MyCheckButton : MonoBehaviour { cb.labelText.text = ""; cb.labelText.fontSize = fontSize; - cb.labelText.color = Color.white; cb.labelText.fontStyle = FontStyle.Normal; } } diff --git a/UXAssist/UI/MyCheckbox.cs b/UXAssist/UI/MyCheckbox.cs index 1792089..9f580c0 100644 --- a/UXAssist/UI/MyCheckbox.cs +++ b/UXAssist/UI/MyCheckbox.cs @@ -17,10 +17,9 @@ public class MyCheckBox : MonoBehaviour private bool _checked; private static GameObject _baseObject; - - private static readonly Color BoxColor = new(1f, 1f, 1f, 100f / 255f); - private static readonly Color CheckColor = new(1f, 1f, 1f, 1f); - private static readonly Color TextColor = new(178f / 255f, 178f / 255f, 178f / 255f, 168f / 255f); + private static Color _boxColor; + private static Color _checkColor; + private static Color _textColor; public static void InitBaseObject() { @@ -32,13 +31,12 @@ public class MyCheckBox : MonoBehaviour var boxImage = go.GetComponent(); if (boxImage) { - boxImage.color = BoxColor; boxImage.enabled = true; } var checkImage = go.transform.Find("checked")?.GetComponent(); if (checkImage) { - checkImage.color = CheckColor; + _checkColor = checkImage.color; checkImage.enabled = false; } var comp = go.transform.Find("text"); @@ -48,13 +46,14 @@ public class MyCheckBox : MonoBehaviour if (txt) { txt.text = ""; - txt.color = TextColor; + _textColor = txt.color; txt.alignment = TextAnchor.MiddleLeft; txt.fontStyle = FontStyle.Normal; } var localizer = comp.GetComponent(); if (localizer) DestroyImmediate(localizer); } + if (boxImage) _boxColor = boxImage.color; _baseObject = go; } @@ -86,9 +85,7 @@ public class MyCheckBox : MonoBehaviour cb.boxImage = go.transform.GetComponent(); cb.checkImage = go.transform.Find("checked")?.GetComponent(); Util.ResetButton(cb.uiButton); - cb.boxImage.color = BoxColor; cb.boxImage.enabled = true; - cb.checkImage.color = CheckColor; cb.checkImage.enabled = false; Util.NormalizeRectWithTopLeft(cb.checkImage, 0f, 0f); @@ -100,7 +97,6 @@ public class MyCheckBox : MonoBehaviour { cb.labelText.text = ""; cb.labelText.fontSize = fontSize; - cb.labelText.color = TextColor; cb.labelText.alignment = TextAnchor.MiddleLeft; cb.labelText.fontStyle = FontStyle.Normal; cb.UpdateLabelTextWidth(); @@ -141,15 +137,15 @@ public class MyCheckBox : MonoBehaviour if (uiButton) uiButton.enabled = on; if (on) { - if (boxImage) boxImage.color = BoxColor; - if (checkImage) checkImage.color = CheckColor; - if (labelText) labelText.color = TextColor; + if (boxImage) boxImage.color = _boxColor; + if (checkImage) checkImage.color = _checkColor; + if (labelText) labelText.color = _textColor; } else { - if (boxImage) boxImage.color = BoxColor.RGBMultiplied(0.5f); - if (checkImage) checkImage.color = CheckColor.RGBMultiplied(0.5f); - if (labelText) labelText.color = TextColor.RGBMultiplied(0.5f); + if (boxImage) boxImage.color = _boxColor.RGBMultiplied(0.5f); + if (checkImage) checkImage.color = _checkColor.RGBMultiplied(0.5f); + if (labelText) labelText.color = _textColor.RGBMultiplied(0.5f); } } diff --git a/UXAssist/UI/MyComboBox.cs b/UXAssist/UI/MyComboBox.cs index 63916a2..38168df 100644 --- a/UXAssist/UI/MyComboBox.cs +++ b/UXAssist/UI/MyComboBox.cs @@ -42,7 +42,6 @@ public class MyComboBox : MonoBehaviour txtComp.font = fontSource.font; txtComp.fontSize = fontSource.fontSize; txtComp.fontStyle = fontSource.fontStyle; - txtComp.color = Color.white; } txtComp = rect.Find("Main Button/Text")?.GetComponent(); if (txtComp) @@ -50,7 +49,6 @@ public class MyComboBox : MonoBehaviour txtComp.font = fontSource.font; txtComp.fontSize = fontSource.fontSize; txtComp.fontStyle = fontSource.fontStyle; - txtComp.color = Color.white; } } cbctrl.onSubmit.RemoveAllListeners(); @@ -59,8 +57,6 @@ public class MyComboBox : MonoBehaviour cbctrl.isDroppedDown = false; cbctrl.m_Input.text = ""; cbctrl.m_Text.text = ""; - cbctrl.m_Input.textComponent.color = Color.white; - cbctrl.m_Text.color = Color.white; cbctrl.m_DropDownContent.anchoredPosition = Vector2.zero; cbctrl.m_DropDownList.gameObject.SetActive(false); cbctrl.m_EmptyItemRes.gameObject.SetActive(false); diff --git a/UXAssist/UI/MyCornerComboBox.cs b/UXAssist/UI/MyCornerComboBox.cs index 59f1e27..6deb515 100644 --- a/UXAssist/UI/MyCornerComboBox.cs +++ b/UXAssist/UI/MyCornerComboBox.cs @@ -33,8 +33,6 @@ public class MyCornerComboBox : MonoBehaviour cbctrl.isDroppedDown = false; cbctrl.m_Input.text = ""; cbctrl.m_Text.text = ""; - cbctrl.m_Input.textComponent.color = Color.white; - cbctrl.m_Text.color = Color.white; cbctrl.m_DropDownContent.anchoredPosition = Vector2.zero; cbctrl.m_DropDownList.gameObject.SetActive(false); cbctrl.m_EmptyItemRes.gameObject.SetActive(false); @@ -46,7 +44,6 @@ public class MyCornerComboBox : MonoBehaviour } cbctrl.Items.Clear(); cbctrl.ItemButtons.Clear(); - cbctrl.m_ListItemRes.GetComponentInChildren().color = Color.white; _baseObject = go; } diff --git a/UXAssist/UI/MyFlatButton.cs b/UXAssist/UI/MyFlatButton.cs index 96676b1..6fa35d9 100644 --- a/UXAssist/UI/MyFlatButton.cs +++ b/UXAssist/UI/MyFlatButton.cs @@ -27,14 +27,12 @@ public class MyFlatButton : MonoBehaviour if (img != null) { img.sprite = panel.buttonDefaultSprite; - img.color = new Color(1f, 1f, 1f, 13f / 255f); img.enabled = true; } img = btn.gameObject.transform.Find("frame")?.GetComponent(); if (img != null) { - img.color = new Color(1f, 1f, 1f, 0f); img.enabled = true; } @@ -42,7 +40,6 @@ public class MyFlatButton : MonoBehaviour if (text) { text.text = ""; - text.color = Color.white; text.fontStyle = FontStyle.Normal; } diff --git a/UXAssist/UI/MyKeyBinder.cs b/UXAssist/UI/MyKeyBinder.cs index 1b6101e..65d9d42 100644 --- a/UXAssist/UI/MyKeyBinder.cs +++ b/UXAssist/UI/MyKeyBinder.cs @@ -64,7 +64,6 @@ public class MyKeyBinder : MonoBehaviour Util.ResetButton(kb.setDefaultUIButton); Util.ResetButton(kb.setNoneKeyUIButton); kb.functionText.text = ""; - kb.functionText.color = Color.white; kb.functionText.fontStyle = FontStyle.Normal; kb.keyText.text = ""; kb.keyText.color = uikeyEntry.builtinColor; diff --git a/UXAssist/UI/MySideSlider.cs b/UXAssist/UI/MySideSlider.cs index f8314e6..0029c58 100644 --- a/UXAssist/UI/MySideSlider.cs +++ b/UXAssist/UI/MySideSlider.cs @@ -51,7 +51,6 @@ public class MySideSlider : MonoBehaviour sl.labelText = go.transform.Find("value").GetComponent(); sl.labelText.text = ""; - sl.labelText.color = Color.white; sl.labelText.fontStyle = FontStyle.Normal; sl.labelText.alignment = textWidth <= 0f ? TextAnchor.MiddleLeft : TextAnchor.MiddleRight; if (sl.labelText.transform is RectTransform rectTrans2) diff --git a/UXAssist/UI/MySlider.cs b/UXAssist/UI/MySlider.cs index 03c1156..cdd312d 100644 --- a/UXAssist/UI/MySlider.cs +++ b/UXAssist/UI/MySlider.cs @@ -52,7 +52,6 @@ public class MySlider : MonoBehaviour if (sl.labelText) { sl.labelText.text = ""; - sl.labelText.color = Color.white; sl.labelText.alignment = TextAnchor.MiddleCenter; sl.labelText.fontStyle = FontStyle.Normal; sl.labelText.fontSize = 14; diff --git a/UXAssist/UI/MyWindow.cs b/UXAssist/UI/MyWindow.cs index 2a01cf1..211f44f 100644 --- a/UXAssist/UI/MyWindow.cs +++ b/UXAssist/UI/MyWindow.cs @@ -391,7 +391,6 @@ public class MyWindow : ManualBehaviour var rect = Util.NormalizeRectWithTopLeft(inputField, x, y, parent); rect.sizeDelta = new Vector2(210, rect.sizeDelta.y); inputField.text = text; - inputField.textComponent.color = Color.white; inputField.textComponent.fontStyle = FontStyle.Normal; inputField.textComponent.fontSize = fontSize; @@ -458,7 +457,6 @@ public class MyWindowWithTabs : MyWindow var btn = Instantiate(src); Util.ResetButton(btn); btn.gameObject.GetComponent().sprite = swarmPanel.buttonDefaultSprite; - btn.gameObject.GetComponent().color = Color.white; btn.gameObject.GetComponent().enabled = true; btn.name = "tab-btn-" + index; btn.highlighted = false; @@ -480,7 +478,6 @@ public class MyWindowWithTabs : MyWindow shadow.effectColor = new Color(0f, 0f, 0f, 0.4f); shadow.effectDistance = new Vector2(1f, -1f); btnText.text = label.Translate(); - btnText.color = Color.white; btnText.fontSize = 16; btnText.fontStyle = FontStyle.Normal; btn.data = index; @@ -505,7 +502,6 @@ public class MyWindowWithTabs : MyWindow var image = img.GetComponent(); if (image) { - image.color = Color.white; image.enabled = true; } Destroy(img.Find("tri").gameObject); diff --git a/UXAssist/UI/Util.cs b/UXAssist/UI/Util.cs index 380cc40..439ae08 100644 --- a/UXAssist/UI/Util.cs +++ b/UXAssist/UI/Util.cs @@ -16,6 +16,7 @@ public static class Util public static void ResetButton(UIButton button) { if (!button) return; + button.Init(); button.enabled = true; button.highlighted = false; button.updating = true; diff --git a/UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs b/UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs index edf2df8..d305595 100644 --- a/UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs +++ b/UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs @@ -125,7 +125,6 @@ public static class GalaxySelectUIPatch var origText = orig.transform.parent.GetComponent(); title = Object.Instantiate(origText, origText.transform.parent); title.text = ""; - title.color = Color.white; title.fontStyle = FontStyle.Normal; title.horizontalOverflow = HorizontalWrapMode.Overflow; title.verticalOverflow = VerticalWrapMode.Overflow; @@ -144,7 +143,6 @@ public static class GalaxySelectUIPatch slider.onValueChanged.RemoveAllListeners(); text = slider.transform.FindChildRecur("Text").GetComponent(); text.text = ""; - text.color = Color.white; text.fontStyle = FontStyle.Normal; text.horizontalOverflow = HorizontalWrapMode.Overflow; text.verticalOverflow = VerticalWrapMode.Overflow;