62 lines
1.7 KiB
C#
62 lines
1.7 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)
|
|
{
|
|
if (!Config.Enabled)
|
|
return true;
|
|
|
|
// 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>");
|
|
|
|
bool showDiamondTime = false;
|
|
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;
|
|
case DisplayMode.Never:
|
|
showDiamondTime = false;
|
|
break;
|
|
}
|
|
|
|
string diamondText = "";
|
|
if (showDiamondTime)
|
|
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;
|
|
}
|
|
}
|
|
}
|