fix(uxassist): UI fixes

This commit is contained in:
soarqin committed 2026-09-24 16:19:19 +08:00
1 parent 60d54ac918
commit d084f9cf75
4 files changed
+25 -24

No files matched your search

+2 -1
View File
@@ -34,7 +34,7 @@
- Use `ModCompatHelper` for external plugin/type/member resolution and preserve legacy public type identities when refactoring reflection targets. Use `DysonSphereReflection` for DSPOptimizations-compatible Dyson sphere fields.
- Performance-sensitive Harmony transpilers must include the standard target/fallback header and use `TranspilerGuard` when a matcher can fail; returning original instructions is the fallback. Match named enum members and semantic calls or fields instead of hard-coded enum values or local-variable slots. Validate injected stack operand types and branch destinations, not just successful matching.
- `PatchImpl<T>.Enable(true)` must remain fail-soft: log, unpatch, and leave the patch unset if Harmony application fails so config delegate chains remain consistent.
- Overlay UI state must converge from actual game state on periodic updates, not depend only on one-shot event or patch callbacks. Cloned controls must reset runtime state while retaining source styles; use `UXAssist.UI.Util.GetPreferredWidth` for dynamic text and `ResetButton` for cloned buttons.
- Overlay UI state must converge from actual game state on periodic updates, not depend only on one-shot event or patch callbacks. Cloned controls must reset runtime state while retaining source styles; use `UXAssist.UI.Util.GetPreferredWidth` for dynamic text and `ResetButton` for cloned buttons. Shared button sizing must use anchor-relative child positions so text and icons remain aligned after a button pivot changes.
- UI-only options must preserve native progression, statistics, and event delivery. Suppress presentation handlers rather than bypassing authoritative game-state setters.
- LiveStreamAssist browser overlays must use single-flight polling and discard stale work after connection changes. Compound queries must reject mixed session IDs; cache only positive production indices so newly tracked items remain discoverable.
- LiveStreamAssist production reads must schedule the native extra-info calculator for queried factories independently of the statistics UI. Deduplicate and throttle refreshes, let active native batches finish, and clear pending factory indices and deadlines at session boundaries.
@@ -55,6 +55,7 @@
- `PlayerPatch.AutoNavigation` is the only auto-cruise implementation. Its Harmony patches follow `AutoCruiseEnabled`; use auto-cruise terminology in user-facing text rather than the game's native autopilot terminology. Keep persistent status and the current configured shortcut on the auto-cruise button, without a separate HUD label; fix its left edge so adaptive width grows rightward without overlapping the auto-construct button.
- Use one navigation lifecycle path for target state and reusable obstacle data. Require a resolvable target, yield to `player.navigation.navigating`, and reject an active native autopilot before reporting that auto-cruise started.
- Preserve native movement and braking conventions; manual warp input takes precedence.
- Use `MySideSlider` consistently for auto-cruise numeric settings. Keep each slider and its value label on a shared vertical center with explicit anchors and pivots, without additional row offsets.
## Review Standard
+4 -4
View File
@@ -51,7 +51,7 @@ public class MyCheckButton : MonoBehaviour
txt.rectTransform.anchorMax = new Vector2(0f, 1f);
txt.rectTransform.anchorMin = new Vector2(0f, 1f);
txt.rectTransform.pivot = new Vector2(0f, 1f);
txt.rectTransform.localPosition = new Vector3(0f, 0f, 0f);
txt.rectTransform.anchoredPosition3D = new Vector3(0f, 0f, 0f);
}
var localizer = comp.GetComponent<Localizer>();
if (localizer) DestroyImmediate(localizer);
@@ -155,12 +155,12 @@ public class MyCheckButton : MonoBehaviour
{
var width = rectTrans.sizeDelta.x;
var height = rectTrans.sizeDelta.y;
labelText.rectTransform.localPosition = new Vector3(icon != null ? _iconWidth : 0f, 0f, 0f);
labelText.rectTransform.anchoredPosition3D = new Vector3(icon != null ? _iconWidth : 0f, 0f, 0f);
labelText.rectTransform.sizeDelta = new Vector2(icon != null ? width - _iconWidth : width, height);
if (icon != null)
{
icon.rectTransform.sizeDelta = new Vector2(_iconWidth, _iconWidth);
icon.rectTransform.localPosition = new Vector3(0f, -height * 0.5f, 0f);
icon.rectTransform.anchoredPosition3D = new Vector3(0f, -height * 0.5f, 0f);
}
}
@@ -200,7 +200,7 @@ public class MyCheckButton : MonoBehaviour
rect.anchorMin = new Vector2(0f, 1f);
rect.pivot = new Vector2(0f, 0.5f);
var height = rectTrans.sizeDelta.y;
rect.localPosition = new Vector3(0f, -height * 0.5f, 0f);
rect.anchoredPosition3D = new Vector3(0f, -height * 0.5f, 0f);
iconGo.SetActive(sprite != null);
UpdateSize();
}
+11 -12
View File
@@ -44,8 +44,12 @@ public class MySideSlider : MonoBehaviour
if (width == 0) width = 160f;
if (sl.slider.transform is RectTransform rectTrans)
{
rectTrans.localPosition = new Vector3(width, rectTrans.localPosition.y, rectTrans.localPosition.z);
rectTrans.sizeDelta = new Vector2(width, rectTrans.sizeDelta.y);
var sliderHeight = rectTrans.rect.height;
rectTrans.anchorMin = new Vector2(0f, 0.5f);
rectTrans.anchorMax = new Vector2(0f, 0.5f);
rectTrans.pivot = new Vector2(0f, 0.5f);
rectTrans.anchoredPosition3D = Vector3.zero;
rectTrans.sizeDelta = new Vector2(width, sliderHeight);
}
sl.Value = 0f;
@@ -55,16 +59,11 @@ public class MySideSlider : MonoBehaviour
sl.labelText.alignment = textWidth <= 0f ? TextAnchor.MiddleLeft : TextAnchor.MiddleRight;
if (sl.labelText.transform is RectTransform rectTrans2)
{
if (textWidth > 0f)
{
rectTrans2.sizeDelta = new Vector2(textWidth, rectTrans2.sizeDelta.y);
}
else
{
rectTrans2.sizeDelta = new Vector2(-textWidth, rectTrans2.sizeDelta.y);
}
rectTrans2.pivot = new Vector2(0f, 1f);
rectTrans2.localPosition = new Vector3(textWidth <= 0f ? width + 10f : width, rectTrans2.localPosition.y, rectTrans2.localPosition.z);
rectTrans2.anchorMin = Vector2.zero;
rectTrans2.anchorMax = new Vector2(0f, 1f);
rectTrans2.pivot = new Vector2(0f, 0.5f);
rectTrans2.anchoredPosition3D = new Vector3(textWidth <= 0f ? width + 10f : width, 0f, 0f);
rectTrans2.sizeDelta = new Vector2(Mathf.Abs(textWidth), 0f);
}
sl.labelFormat = "G";
+8 -7
View File
@@ -707,7 +707,7 @@ public static class UIConfigWindow
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.UseWarpMinimalEnergy, 13, "use-warp-minimal-energy");
var warpEnergySlider = wnd.AddSideSlider(
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
y + 6f,
y,
tab4,
PlayerPatch.UseWarperMinimalEnergy,
new EnergyMapper( ),
@@ -716,21 +716,22 @@ public static class UIConfigWindow
- 100f).WithFontSize(13);
y += 27f;
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.DistanceToUseWarp, 13, "text-new-navigation-distance-to-warp");
var newNavDistanceSlider = wnd.AddSlider(
var newNavDistanceSlider = wnd.AddSideSlider(
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
y + 6f,
y,
tab4,
PlayerPatch.UseWarperDistance,
new DistanceMapper( ),
"0.0",
200f);
200f,
-100f).WithFontSize(13);
y += 27f;
var speedUpCheckBox = wnd.AddCheckBox(x + 20f, y, tab4, PlayerPatch.UseSpeedUp, I18NKeys.AutoBoost, 13);
y += 27f;
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.AutoBoostMinimalEnergy, 13, "auto-boost-minimal-energy");
var speedUpEnergySlider = wnd.AddSideSlider(
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
y + 6f,
y,
tab4,
PlayerPatch.UseSpeedUpMinimalEnergy,
new EnergyMapper( ),
@@ -741,7 +742,7 @@ public static class UIConfigWindow
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.DarkFogHiveFollowDistance, 13, "dark-fog-hive-follow-distance");
var dfHiveSlider = wnd.AddSideSlider(
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
y + 6f,
y,
tab4,
PlayerPatch.DFHiveFollowDistance,
new DistanceMapperHive( ),
@@ -752,7 +753,7 @@ public static class UIConfigWindow
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.DarkFogCarrierFollowDistance, 13, "dark-fog-carrier-follow-distance");
var dfCarrierSlider = wnd.AddSideSlider(
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
y + 6f,
y,
tab4,
PlayerPatch.DFCarrierFollowDistance,
new DistanceMapperCarrier( ),