- Allow multiple named entries for grave force command on the same tile - Update dismiss behavior to clear Lore and dossier while keeping idle off - Introduce new methods for managing dismiss grace period - Refactor focus handling for fallen subjects and their killers - Increment version to 0.28.13 in mod.json
113 lines
2.7 KiB
C#
113 lines
2.7 KiB
C#
using UnityEngine;
|
|
|
|
namespace IdleSpectator;
|
|
|
|
/// <summary>
|
|
/// Outside-click dismiss for Lore + idle dossier. Always turns Idle Spectator off.
|
|
/// </summary>
|
|
public static class InspectUi
|
|
{
|
|
/// <summary>True after a skull open until <see cref="DismissAll"/>.</summary>
|
|
public static bool GraveSessionActive { get; private set; }
|
|
|
|
public static void MarkGraveSession()
|
|
{
|
|
GraveSessionActive = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Close Lore / dossier pin, clear grave scope, and force Idle Spectator off.
|
|
/// </summary>
|
|
public static void DismissAll()
|
|
{
|
|
GraveSessionActive = false;
|
|
// Outside dismiss must not auto-resume idle when Lore was opened via L.
|
|
ChronicleHud.NotifyManualIdleToggle();
|
|
|
|
if (SpectatorMode.Active)
|
|
{
|
|
SpectatorMode.SetActive(false, quiet: true);
|
|
}
|
|
|
|
ChronicleHud.ClearGraveStackScope();
|
|
if (ChronicleHud.DetailUnitId != 0)
|
|
{
|
|
ChronicleHud.ClearUnitDetail();
|
|
}
|
|
|
|
if (ChronicleHud.Visible)
|
|
{
|
|
ChronicleHud.SetVisible(false);
|
|
}
|
|
|
|
WatchCaption.HideForDismiss();
|
|
}
|
|
|
|
public static void Update()
|
|
{
|
|
bool loreOpen = ChronicleHud.Visible;
|
|
bool dossierOpen = WatchCaption.Visible;
|
|
bool idleOn = SpectatorMode.Active;
|
|
if (!loreOpen && !dossierOpen && !idleOn && !GraveSessionActive)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!InputHelpers.GetMouseButtonDown(0))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (Time.unscaledTime < ChronicleHud.IgnoreDismissUntil)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (ChronicleHud.IsTypingSearch)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (ChronicleHud.IsPointerOverPanel() || WatchCaption.IsPointerOverPanel())
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Skull click opens Lore this frame; leave the new session alone.
|
|
if (IsClickingGraveSkull())
|
|
{
|
|
return;
|
|
}
|
|
|
|
DismissAll();
|
|
}
|
|
|
|
private static bool IsClickingGraveSkull()
|
|
{
|
|
if (!ModSettings.GravestonesEnabled || GraveMarkers.StackCount <= 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
try
|
|
{
|
|
if (World.world != null && World.world.isOverUI())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
WorldTile tile = World.world.getMouseTilePosCachedFrame() ?? World.world.getMouseTilePos();
|
|
if (tile != null && GraveMarkers.TryGetStack(tile.x, tile.y, out _))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
Vector2 mouse = World.world.getMousePos();
|
|
return GraveMarkers.FindNearestStack(mouse, 1.35f) != null;
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|