-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSideLabelHandler.cs
More file actions
79 lines (70 loc) · 2.21 KB
/
SideLabelHandler.cs
File metadata and controls
79 lines (70 loc) · 2.21 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
71
72
73
74
75
76
77
78
79
using HarmonyLib;
using MelonLoader;
using UnityEngine;
using TMPro;
using System;
namespace MelatoninAccess
{
// --- Side Label (Persistent Gameplay Text) ---
[HarmonyPatch(typeof(SideLabel), "ShowAsPractice")]
public static class SideLabel_ShowAsPractice_Patch
{
public static void Postfix(SideLabel __instance)
{
SideLabelHelper.AnnounceTutorialStart();
}
}
[HarmonyPatch(typeof(SideLabel), "ActivateAsTutorial")]
public static class SideLabel_ActivateAsTutorial_Patch
{
public static void Postfix(SideLabel __instance)
{
SideLabelHelper.AnnounceTutorialStart();
}
}
[HarmonyPatch(typeof(SideLabel), "ShowAsEdited")]
public static class SideLabel_ShowAsEdited_Patch
{
public static void Postfix(SideLabel __instance)
{
SideLabelHelper.AnnounceLabel(__instance.skipText);
}
}
public static class SideLabelHelper
{
public static void AnnounceTutorialStart()
{
if (IsStandaloneTutorial())
{
ScreenReader.Say(Loc.Get("tutorial_label"), true);
return;
}
ScreenReader.Say(Loc.Get("tutorial_skip_prompt", GetSkipPrompt()), true);
}
public static void AnnounceLabel(textboxFragment fragment)
{
if (fragment != null)
{
var tmp = fragment.GetComponent<TextMeshPro>();
if (tmp != null)
{
ScreenReader.Say(tmp.text, true);
}
}
}
private static string GetSkipPrompt()
{
if (ControlHandler.mgr == null) return "Tab";
int ctrlType = ControlHandler.mgr.GetCtrlType();
if (ctrlType == 1) return "Y";
if (ctrlType == 2) return "Triangle";
return "Tab";
}
private static bool IsStandaloneTutorial()
{
if (SceneMonitor.mgr == null) return false;
string sceneName = SceneMonitor.mgr.GetActiveSceneName();
return string.Equals(sceneName, "Dream_tutorial", System.StringComparison.OrdinalIgnoreCase);
}
}
}