-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompleteScreenUI.cs
49 lines (38 loc) · 1.74 KB
/
CompleteScreenUI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Text;
using HarmonyLib;
using TMPro;
using UnityEngine;
namespace SRXDModifiers;
public static class CompleteScreenUI {
private static TMP_Text modifiersLabel;
private static TMP_Text modifiersText;
[HarmonyPatch(typeof(XDLevelCompleteMenu), nameof(XDLevelCompleteMenu.Setup)), HarmonyPostfix]
private static void Setup_Postfix(XDLevelCompleteMenu __instance) {
var scoreValueText = __instance.scoreValueText;
var parent = scoreValueText.transform.parent;
if (modifiersLabel == null) {
modifiersLabel = Object.Instantiate(parent.Find("Score_text"), parent, false).GetComponent<TMP_Text>();
Object.Destroy(modifiersLabel.GetComponent<TranslatedTextMeshPro>());
modifiersLabel.SetText("Modifiers");
modifiersLabel.transform.localPosition = new Vector3(310f, 11f, 0f);
modifiersLabel.alignment = TextAlignmentOptions.Center;
}
if (modifiersText == null) {
modifiersText = Object.Instantiate(scoreValueText.gameObject, parent, false).GetComponent<TMP_Text>();
modifiersText.transform.localPosition = new Vector3(310f, -11f, 0f);
modifiersText.enableAutoSizing = true;
modifiersText.alignment = TextAlignmentOptions.Center;
}
var builder = new StringBuilder();
var modifiers = Plugin.Modifiers;
for (int i = 0; i < modifiers.Count; i++) {
var modifier = modifiers[i];
if (!modifier.Enabled.Value)
continue;
if (builder.Length > 0)
builder.Append(", ");
builder.Append(modifier.Name);
}
modifiersText.SetText(builder.ToString());
}
}