Named camera bookmarks, Auto Engineer / WaypointQueue pins, and extracted track labels. Stock MapWindow stays collapsed while S3 owns the camera. Radio Runner is not in this drop.
85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
using HarmonyLib;
|
|
using S3.Modules.Popout;
|
|
using UI.Common;
|
|
using UI.Map;
|
|
using UnityEngine;
|
|
|
|
namespace S3.Core.Ui;
|
|
|
|
/// <summary>
|
|
/// Keeps the stock Unity MapWindow invisible while the Map Module is enabled.
|
|
/// The overlay/popout still call MapWindow.Show (with MapBypass) so the camera
|
|
/// and icons initialize; this collapses the game's own panel so it can never
|
|
/// steal the view or flash over the ImGui map.
|
|
/// </summary>
|
|
internal static class StockMapGuard
|
|
{
|
|
private static Vector3 _savedScale = Vector3.one;
|
|
private static bool _haveScale;
|
|
|
|
public static void Tick()
|
|
{
|
|
if (!PopoutModule.Settings.enabled)
|
|
{
|
|
RestoreIfNeeded();
|
|
return;
|
|
}
|
|
CollapseCurrent();
|
|
}
|
|
|
|
public static void CollapseCurrent()
|
|
{
|
|
var win = PanelFinder.GetMapWindowUI();
|
|
if (win == null) return;
|
|
Collapse(win);
|
|
}
|
|
|
|
public static void Collapse(Window? win)
|
|
{
|
|
if (win == null) return;
|
|
if (win.transform is not RectTransform rt) return;
|
|
if (!_haveScale && rt.localScale != Vector3.zero)
|
|
{
|
|
_savedScale = rt.localScale;
|
|
_haveScale = true;
|
|
}
|
|
if (rt.localScale != Vector3.zero)
|
|
rt.localScale = Vector3.zero;
|
|
}
|
|
|
|
public static void Collapse(MapWindow? mw)
|
|
{
|
|
if (mw == null) return;
|
|
Collapse(Traverse.Create(mw).Field<Window>("_window").Value);
|
|
}
|
|
|
|
private static void RestoreIfNeeded()
|
|
{
|
|
if (!_haveScale) return;
|
|
var win = PanelFinder.GetMapWindowUI();
|
|
if (win != null && win.transform is RectTransform rt)
|
|
rt.localScale = _savedScale;
|
|
_haveScale = false;
|
|
}
|
|
}
|
|
|
|
// Any Show/Toggle that reaches the stock window (bypass, other mods, animations)
|
|
// must stay at scale zero while the Map Module is on.
|
|
[HarmonyPatch(typeof(MapWindow), "OnWindowShown")]
|
|
internal static class MapWindow_OnWindowShown_Patch
|
|
{
|
|
private static void Postfix(MapWindow __instance, bool shown)
|
|
{
|
|
if (!PopoutModule.Settings.enabled) return;
|
|
try
|
|
{
|
|
StockMapGuard.Collapse(__instance);
|
|
if (shown && !UiService.MapBypass && !UiService.IsOverlayVisible && !PopoutModule.IsDetached)
|
|
UiService.OpenOverlay();
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Log.Error($"[ui] stock map collapse: {ex.Message}");
|
|
}
|
|
}
|
|
}
|