-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPopupHandler.cs
More file actions
70 lines (66 loc) · 2.17 KB
/
PopupHandler.cs
File metadata and controls
70 lines (66 loc) · 2.17 KB
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
60
61
62
63
64
65
66
67
68
69
70
using HarmonyLib;
using MelonLoader;
using UnityEngine;
using TMPro;
namespace MelatoninAccess
{
// --- Extra Message (Popup/Hint) ---
[HarmonyPatch(typeof(ExtraMessage), "Activate")]
public static class ExtraMessage_Activate_Patch
{
public static void Postfix(ExtraMessage __instance, int stateNum)
{
if (__instance.message != null)
{
var tmp = __instance.message.GetComponent<TextMeshPro>();
if (tmp != null)
{
// Submenu.SetCalibrationMenu() uses ExtraMessage.Activate(1).
// Queue this hint so it is spoken together with the first calibration menu option.
if (stateNum == 1)
{
MenuHandler.QueuePrefaceAnnouncement(tmp.text);
return;
}
ScreenReader.Say(tmp.text, true);
}
}
}
}
// --- Confirm Modal (Quit Game etc) ---
[HarmonyPatch(typeof(ConfirmModal), "Activate")]
public static class ConfirmModal_Activate_Patch
{
public static void Postfix(ConfirmModal __instance)
{
// Texts: 0=Title? 1=Yes? 2=No?
// Let's read all of them
string message = "";
if (__instance.texts != null)
{
foreach(var txt in __instance.texts)
{
var tmp = txt.GetComponent<TextMeshPro>();
if (tmp != null && !string.IsNullOrEmpty(tmp.text))
{
message += tmp.text + " ";
}
}
}
ScreenReader.Say(message, true);
}
}
// --- Rebind Modal ---
[HarmonyPatch(typeof(RebindModal), "Show")]
public static class RebindModal_Show_Patch
{
public static void Postfix(RebindModal __instance)
{
if (__instance.message != null)
{
var tmp = __instance.message.GetComponent<TextMeshPro>();
if (tmp != null) ScreenReader.Say(tmp.text, true);
}
}
}
}