43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
|
using HarmonyLib;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Runtime.CompilerServices;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace MiuuDiamondTimeViewer.Patches
|
|||
|
{
|
|||
|
[HarmonyPatch(typeof(MedalsDisplay))]
|
|||
|
[HarmonyPatch("Setup")]
|
|||
|
internal class MedalsDisplaySetupPatch
|
|||
|
{
|
|||
|
static bool Prefix(MedalsDisplay __instance, float silver, float gold, List<string> eggUnlock)
|
|||
|
{
|
|||
|
// Get diamond time (since it is not passed in as a parameter)
|
|||
|
float diamond = LevelSelect.instance.level.DiamondTime;
|
|||
|
|
|||
|
bool hasEgg = eggUnlock != null && eggUnlock.Count > 0;
|
|||
|
bool gotEgg = hasEgg && UnlockManager.Get().IsUnlocked(eggUnlock[0]) && !CosmeticValues.WasPurchased(eggUnlock[0]);
|
|||
|
|
|||
|
string eggText = "";
|
|||
|
if (hasEgg)
|
|||
|
eggText = (gotEgg ? "<space=0.5em> <sprite=9>" : "<space=0.5em> <sprite=8>");
|
|||
|
|
|||
|
string diamondText = "";
|
|||
|
if (LevelSelect.instance.bestScore > 0f && LevelSelect.instance.bestScore <= diamond)
|
|||
|
diamondText = "<sprite=3> " + SegmentedTime.SPTimeText(diamond);
|
|||
|
|
|||
|
__instance.MedalTimes.text = string.Concat(new string[]
|
|||
|
{
|
|||
|
"<sprite=1> ",
|
|||
|
SegmentedTime.SPTimeText(silver),
|
|||
|
"<sprite=2> ",
|
|||
|
SegmentedTime.SPTimeText(gold),
|
|||
|
diamondText,
|
|||
|
eggText
|
|||
|
});
|
|||
|
|
|||
|
// Skip original method
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|