Skip to content

Commit

Permalink
Added Feature: "PuzzleHudTweaks"
Browse files Browse the repository at this point in the history
Added some exclusion prefixes to log redirect to prevent log spam
  • Loading branch information
AuriRex committed Jun 18, 2023
1 parent b9f73f3 commit a51a17b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions TheArchive.Core/Utilities/GTFOLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public static class GTFOLogger

private static readonly HashSet<string> _ignoreListStartsWith = new HashSet<string>() {
"Wielding new item in slot",
"Backend.", // Just constant console spam in Alt://R4
"BE.OnGameEvent", // Same but Alt://R5
};

public static void Ignore(string str) => _ignoreListExact.Add(str);
Expand Down
77 changes: 77 additions & 0 deletions TheArchive.IL2CPP/Features/QoL/PuzzleHUDTweaks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using ChainedPuzzles;
using TheArchive.Core.Attributes;
using TheArchive.Core.Attributes.Feature.Settings;
using TheArchive.Core.FeaturesAPI;
using TheArchive.Utilities;

namespace TheArchive.Features.QoL
{
#warning TODO: Port to older rundowns
[RundownConstraint(Utils.RundownFlags.RundownSix, Utils.RundownFlags.Latest)]
public class PuzzleHUDTweaks : Feature
{
public override string Name => "Scan HUD Tweaks";

public override string Group => FeatureGroups.QualityOfLife;

public override string Description => "Adds an overall alarm class counter to the HUD message";

[FeatureConfig]
public static PuzzleHUDTweaksSettings Settings { get; set; }

public class PuzzleHUDTweaksSettings
{
[FSDisplayName("Use Roman Numerals")]
[FSDescription("If Roman Numerals should be used instead of numbers:\nI, II, III, IV, V, VI, ...")]
public bool UseRomanNumerals { get; set; } = true;

[FSDisplayName("Ignore Single Scans")]
[FSDescription("If alarms with only a single scan should hide the <color=white>(I/I)</color> text")]
public bool IgnoreSingleScans { get; set; } = true;
}


[ArchivePatch(typeof(CP_Bioscan_Hud), nameof(CP_Bioscan_Hud.SetVisible))]
internal static class CP_Bioscan_Hud_SetVisible_Patch
{
private static string _ogAtText;
private static string _ogEnterScanText;

public static void Postfix(CP_Bioscan_Hud __instance, int puzzleIndex)
{
if (!__instance.m_atText.Contains("("))
{
_ogAtText = __instance.m_atText;
_ogEnterScanText = __instance.m_enterSecurityScanText;
}

// " AT " <- original ("AT" is localized)
// " (I/IV) AT " <- modified
var puzzleInstance = __instance?.transform?.parent?.GetComponentInChildren<ChainedPuzzleInstance>();

if (puzzleInstance == null)
return;

var current = puzzleIndex + 1;
var total = puzzleInstance.m_chainedPuzzleCores.Count;

if (total == 1 && Settings.IgnoreSingleScans)
return;

string scanPuzzleProgress;

if(Settings.UseRomanNumerals)
{
scanPuzzleProgress = $" <color=white>({Utils.ToRoman(current)}/{Utils.ToRoman(total)})</color>";
}
else
{
scanPuzzleProgress = $" <color=white>({current}/{total})</color>";
}

__instance.m_atText = $"{scanPuzzleProgress}{_ogAtText}";
__instance.m_enterSecurityScanText = $"{_ogEnterScanText}{scanPuzzleProgress}";
}
}
}
}

0 comments on commit a51a17b

Please sign in to comment.