-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
215 lines (192 loc) · 7.78 KB
/
Main.cs
File metadata and controls
215 lines (192 loc) · 7.78 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
using System.Collections;
using MelonLoader;
using UnityEngine;
[assembly: MelonInfo(typeof(BlippoAccess.Main), "BlippoAccess", "0.1.0", "TODO_AUTHOR")]
[assembly: MelonGame("Noble Robot", "Blippo+")]
namespace BlippoAccess
{
/// <summary>
/// Main mod entry point. Initializes core systems and handles global hotkeys.
/// </summary>
public sealed class Main : MelonMod
{
private bool _gameReady;
private SystemScreenHandler _systemScreenHandler;
private SignalLossHandler _signalLossHandler;
private ProgramGuideHandler _programGuideHandler;
private TunerCalibrationHandler _tunerCalibrationHandler;
private PacketteLoadHandler _packetteLoadHandler;
private CreditsHandler _creditsHandler;
private BroadcastStatusHandler _broadcastStatusHandler;
private ControlMenuHandler _controlMenuHandler;
private MessagesHandler _messagesHandler;
private FemtofaxHandler _femtofaxHandler;
private BroadcastModeHandler _broadcastModeHandler;
private ShowSubtitlesHandler _showSubtitlesHandler;
private DataManagerContentHandler _dataManagerContentHandler;
private FactoryResetHandler _factoryResetHandler;
private NewMessageAlertHandler _newMessageAlertHandler;
/// <summary>
/// Gets a value indicating whether debug logging is enabled.
/// </summary>
public static bool DebugMode { get; private set; }
/// <summary>
/// Initializes localization and screen reader support.
/// </summary>
public override void OnInitializeMelon()
{
Loc.Initialize();
ScreenReader.Initialize();
_systemScreenHandler = new SystemScreenHandler();
_signalLossHandler = new SignalLossHandler();
_programGuideHandler = new ProgramGuideHandler();
_tunerCalibrationHandler = new TunerCalibrationHandler();
_packetteLoadHandler = new PacketteLoadHandler();
_creditsHandler = new CreditsHandler();
_broadcastStatusHandler = new BroadcastStatusHandler();
_controlMenuHandler = new ControlMenuHandler();
_messagesHandler = new MessagesHandler();
_femtofaxHandler = new FemtofaxHandler();
_broadcastModeHandler = new BroadcastModeHandler();
_showSubtitlesHandler = new ShowSubtitlesHandler();
_dataManagerContentHandler = new DataManagerContentHandler();
_factoryResetHandler = new FactoryResetHandler();
_newMessageAlertHandler = new NewMessageAlertHandler();
MelonCoroutines.Start(AnnounceStartupCoroutine());
}
/// <summary>
/// Marks the game as ready after a scene load.
/// </summary>
/// <param name="buildIndex">The loaded scene build index.</param>
/// <param name="sceneName">The loaded scene name.</param>
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
_gameReady = true;
DebugLogger.LogState($"Scene loaded: {sceneName} ({buildIndex})");
}
/// <summary>
/// Processes global hotkeys once the game is ready.
/// </summary>
public override void OnUpdate()
{
if (!_gameReady)
{
return;
}
_systemScreenHandler.Update();
_signalLossHandler.Update();
_programGuideHandler.Update();
_tunerCalibrationHandler.Update();
_packetteLoadHandler.Update();
_creditsHandler.Update();
_broadcastStatusHandler.Update();
_controlMenuHandler.Update();
_messagesHandler.Update();
_femtofaxHandler.Update();
_broadcastModeHandler.Update();
_showSubtitlesHandler.Update();
_dataManagerContentHandler.Update();
_factoryResetHandler.Update();
_newMessageAlertHandler.Update();
ProcessHotkeys();
}
/// <summary>
/// Shuts down the screen reader wrapper when the game exits.
/// </summary>
public override void OnApplicationQuit()
{
ScreenReader.Shutdown();
}
private IEnumerator AnnounceStartupCoroutine()
{
yield return new WaitForSeconds(1.0f);
ScreenReader.Say(Loc.Get("mod_loaded"));
}
private void ProcessHotkeys()
{
if (Input.GetKeyDown(KeyCode.F12))
{
DebugMode = !DebugMode;
DebugLogger.LogState($"Debug mode: {(DebugMode ? "on" : "off")}");
ScreenReader.Say(Loc.Get(DebugMode ? "debug_enabled" : "debug_disabled"));
}
if (Input.GetKeyDown(KeyCode.F1))
{
DebugLogger.LogInput("F1", "WhereAmI");
ScreenReader.Say(WhereAmIService.BuildAnnouncement());
}
if (Input.GetKeyDown(KeyCode.F2))
{
DebugLogger.LogInput("F2", "RepeatLast");
if (!ScreenReader.RepeatLast())
{
ScreenReader.Say(Loc.Get("repeat_last_none"));
}
}
if (Input.GetKeyDown(KeyCode.F3))
{
DebugLogger.LogInput("F3", "StopSpeech");
ScreenReader.Stop();
}
if (Input.GetKeyDown(KeyCode.F4))
{
DebugLogger.LogInput("F4", "BroadcastContext");
if (BroadcastContextService.TryBuildAnnouncement(out var announcement))
{
ScreenReader.Say(announcement);
return;
}
ScreenReader.Say(Loc.Get("broadcast_context_unavailable"));
}
if (Input.GetKeyDown(KeyCode.F5))
{
DebugLogger.LogInput("F5", "ReloadLocalizationOverrides");
var applied = Loc.ReloadExternalOverrides();
ScreenReader.Say(applied > 0
? Loc.Get("localization_overrides_reloaded", applied)
: Loc.Get("localization_overrides_reloaded_none"));
}
if (Input.GetKeyDown(KeyCode.F6))
{
DebugLogger.LogInput("F6", "RepeatPrevious");
if (!ScreenReader.RepeatPrevious())
{
ScreenReader.Say(Loc.Get("announcement_history_empty"));
}
}
if (Input.GetKeyDown(KeyCode.F7))
{
DebugLogger.LogInput("F7", "RepeatNext");
if (!ScreenReader.RepeatNext())
{
ScreenReader.Say(Loc.Get("announcement_history_empty"));
}
}
if (Input.GetKeyDown(KeyCode.F8))
{
DebugLogger.LogInput("F8", "ContextHelp");
ScreenReader.Say(ContextHelpService.BuildAnnouncement());
}
if (Input.GetKeyDown(KeyCode.F9))
{
DebugLogger.LogInput("F9", "InboxSummary");
if (InboxSummaryService.TryBuildAnnouncement(out var announcement))
{
ScreenReader.Say(announcement);
return;
}
ScreenReader.Say(Loc.Get("messages_summary_unavailable"));
}
if (Input.GetKeyDown(KeyCode.F10))
{
DebugLogger.LogInput("F10", "SignalStatus");
if (SignalStatusService.TryBuildAnnouncement(out var announcement))
{
ScreenReader.Say(announcement);
return;
}
ScreenReader.Say(Loc.Get("signal_status_unavailable"));
}
}
}
}