-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menus.cs
59 lines (53 loc) · 1.93 KB
/
Menus.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
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using TMPro;
using System.Reflection;
using MelonLoader;
using static LanguageCache;
namespace Blindnautica
{
[HarmonyPatch(typeof(Selectable))]
internal class SelectablePatches
{
[HarmonyPatch(nameof(Selectable.OnPointerEnter))]
[HarmonyPostfix]
public static void OnPointerEnter(Selectable __instance)
{
SpeakElementName(__instance);
}
[HarmonyPatch(nameof(Selectable.OnSelect))]
[HarmonyPostfix]
public static void OnSelect(Selectable __instance)
{
SpeakElementName(__instance);
}
private static void SpeakElementName(Selectable __instance)
{
if (__instance.name == "LoadButton")
{
GameObject loadInfo = __instance.transform.parent.gameObject;
string gameMode = Utility.getStringFromTMP(loadInfo.transform.Find("SaveGameMode").GetComponent<TextMeshProUGUI>());
string lastPlayed = Utility.getStringFromTMP(loadInfo.transform.Find("SaveGameTime").GetComponent<TextMeshProUGUI>());
string gameLength = Utility.getStringFromTMP(loadInfo.transform.Find("SaveGameLength").GetComponent<TextMeshProUGUI>());
NVDA.Speak($"Load; Gamemode: {gameMode}; Last played: {lastPlayed}; Play time: {gameLength}");
} else {
try
{
TextMeshProUGUI ButtonText = __instance.GetComponentInChildren<TextMeshProUGUI>();
string TextToSay = Utility.getStringFromTMP(ButtonText);
NVDA.Speak(TextToSay);
} catch
{
NVDA.Speak(__instance.name);
}
}
}
}
}