using HarmonyLib; using System.Collections.Generic; namespace DiamondTimeViewer.Patches { [HarmonyPatch(typeof(MedalsDisplay), nameof(MedalsDisplay.Setup))] internal class MedalsDisplaySetupPatch { static bool Prefix(MedalsDisplay __instance, float silver, float gold, List eggUnlock) { if (Config.Mode == DisplayMode.Never) return true; // Get diamond time (since it is not passed in as a parameter) float diamond = LevelSelect.instance.level.DiamondTime; bool showDiamondTime = false; if (diamond > 0.0f) { switch (Config.Mode) { case DisplayMode.Always: showDiamondTime = true; break; case DisplayMode.Diamond: showDiamondTime = LevelSelect.instance.bestScore > 0f && LevelSelect.instance.bestScore <= diamond; break; case DisplayMode.Gold: showDiamondTime = LevelSelect.instance.bestScore > 0f && LevelSelect.instance.bestScore <= gold; break; } } string silverText = " " + SegmentedTime.SPTimeText(silver); string spacingText = " "; string diamondText = ""; if (showDiamondTime) { if (Config.HideSilver) silverText = ""; else spacingText = " "; diamondText = spacingText + " " + SegmentedTime.SPTimeText(diamond, true); } if (silverText != "") silverText += spacingText; bool hasEgg = eggUnlock != null && eggUnlock.Count > 0; bool gotEgg = hasEgg && UnlockManager.Get().IsUnlocked(eggUnlock[0]) && !CosmeticValues.WasPurchased(eggUnlock[0]); string eggText = ""; if (hasEgg) eggText = spacingText + (gotEgg ? "" : ""); __instance.MedalTimes.text = string.Concat(new string[] { silverText, " ", SegmentedTime.SPTimeText(gold), diamondText, eggText }); // Skip original method return false; } } }