Skip to content

Commit c774d08

Browse files
committed
Added voice bitrate option. Separated voice settings into their own category. Fixed erroring in recording pulse enumerator. Fixed replays erroring when they didn't have any voices recorded. Fixed not being able to change replays if first page is all folders. Actually removed all ModUI and ModUI+ references. FINALLY fixed crystal erroring when holding grip between scene loads.
1 parent 3371385 commit c774d08

10 files changed

Lines changed: 47 additions & 36 deletions

File tree

-1.53 MB
Binary file not shown.
512 Bytes
Binary file not shown.

src/Core/Main.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public class Main : MelonMod
9595
public MelonPreferences_Entry<bool> HandFingerRecording = new();
9696
public MelonPreferences_Entry<bool> CloseHandsOnPose = new();
9797

98+
// Recording - Voices
9899
public MelonPreferences_Entry<bool> VoiceRecording = new();
100+
public MelonPreferences_Entry<int> voiceBitrate = new();
99101

100102
// Automatic Markers - Match End
101103
public MelonPreferences_Entry<bool> EnableMatchEndMarker = new();
@@ -151,7 +153,6 @@ public enum ControllerAction
151153
// Other
152154
public MelonPreferences_Entry<float> tableOffset;
153155
public MelonPreferences_Entry<bool> enableDebug;
154-
public MelonPreferences_Category extensionsFolder;
155156

156157
// ------------
157158

@@ -198,7 +199,10 @@ public override void OnInitializeMelon()
198199
HandFingerRecording = recordingFolder.CreateEntry("Finger_Animation_Recording", true, "Finger Animation Recording", "Controls whether finger input values are recorded into the replay.");
199200
CloseHandsOnPose = recordingFolder.CreateEntry("Close_Hands_On_Pose", true, "Close Hands On Pose", "Closes the hands of a clone when they do a pose.");
200201

201-
VoiceRecording = recordingFolder.CreateEntry("Voice_Recording", true, "Record In-Game Voices", "Toggles whether in-game voices are recorded into replays.");
202+
var voiceFolder = MelonPreferences.CreateCategory("Voices");
203+
204+
VoiceRecording = voiceFolder.CreateEntry("Voice_Recording", true, "Record In-Game Voices", "Toggles whether in-game voices are recorded into replays.");
205+
voiceBitrate = voiceFolder.CreateEntry("Voice_Bitrate", 30, "Voice Bitrate", "Determines what bitrate voices are recorded in.\nDefault: 30");
202206

203207
var automaticMarkersFolder = MelonPreferences.CreateCategory("Automatic_Markers", "Automatic Markers");
204208
automaticMarkersFolder.SetFilePath(configPath);
@@ -217,7 +221,7 @@ public override void OnInitializeMelon()
217221
PlaybackControlsFollow = playbackFolder.CreateEntry("Playback_Controls_Follow_Player", false, "Playback Controls Follow Player", "Makes the playback controls menu follow you when opened.");
218222
DestroyControlsOnPunch = playbackFolder.CreateEntry("Destroy_Controls_On_Punch", true, "Destroy Controls On Punch", "Destroys the playback controls when you punch the slab hard enough.");
219223

220-
var playbackTogglesFolder = MelonPreferences.CreateCategory("Toggles");
224+
var playbackTogglesFolder = MelonPreferences.CreateCategory("Visual Toggles");
221225
playbackTogglesFolder.SetFilePath(configPath);
222226

223227
ToggleUI = playbackTogglesFolder.CreateEntry("Toggle_UI", true, "Toggle UI", "Toggles whether the UI for selecting replays is visible.");
@@ -398,6 +402,8 @@ public override void OnApplicationQuit()
398402

399403
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
400404
{
405+
isSceneReady = false;
406+
401407
if (currentScene == "Loader" || !UIInitialized)
402408
return;
403409

src/Core/Patches.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using HarmonyLib;
66
using Il2Cpp;
77
using Il2CppPhoton.Pun;
8-
using Il2CppPhoton.Voice;
98
using Il2CppRUMBLE.Audio;
109
using Il2CppRUMBLE.Environment;
1110
using Il2CppRUMBLE.Input;

src/Core/ReplayPlayback.cs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -304,24 +304,33 @@ public void LoadReplay(string path, bool allowDifferentSceneLoad = false)
304304

305305
ReorderPlayers();
306306

307-
foreach (var info in currentReplay.Header.VoiceTrackInfos)
307+
try
308308
{
309-
var clone = PlaybackPlayers.FirstOrDefault(p =>
310-
p.Controller.assignedPlayer.Data.GeneralData.PlayFabMasterId == info.MasterId);
309+
if (currentReplay.Header.VoiceTrackInfos != null)
310+
{
311+
foreach (var info in currentReplay.Header.VoiceTrackInfos)
312+
{
313+
var clone = PlaybackPlayers.FirstOrDefault(p =>
314+
p.Controller.assignedPlayer.Data.GeneralData.PlayFabMasterId == info.MasterId);
311315

312-
if (clone == null) continue;
316+
if (clone == null) continue;
313317

314-
string voicePath = Path.Combine(currentReplay.Header.VoiceFolder, info.FileName);
318+
string voicePath = Path.Combine(currentReplay.Header.VoiceFolder, info.FileName);
315319

316-
var clip = ReplayVoices.LoadVoiceClipFromFile(voicePath);
317-
318-
if (clip == null) return;
319-
320-
clone.VoiceTracks.Add(new Clone.VoiceTrack
321-
{
322-
StartTime = info.StartTime,
323-
Clip = clip
324-
});
320+
var clip = ReplayVoices.LoadVoiceClipFromFile(voicePath);
321+
322+
if (clip == null) continue;
323+
324+
clone.VoiceTracks.Add(new Clone.VoiceTrack
325+
{
326+
StartTime = info.StartTime, Clip = clip
327+
});
328+
}
329+
}
330+
}
331+
catch (Exception e)
332+
{
333+
Main.ReplayError($"Voice laoding failed: {e}");
325334
}
326335

327336
if (currentReplay.Header.Scene == "Gym")

src/Core/ReplayRecording.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -827,14 +827,17 @@ public IEnumerator Pulse()
827827

828828
while (recording.CurrentRecordingState == RecordingState.Saving)
829829
{
830-
t += Time.deltaTime * 2f;
830+
if (tmp != null && transform != null)
831+
{
832+
t += Time.deltaTime * 2f;
831833

832-
float ping = Mathf.PingPong(t, 1f);
833-
ping = Utilities.EaseInOut(ping);
834-
tmp.color = Color.Lerp(a, b, ping);
834+
float ping = Mathf.PingPong(t, 1f);
835+
ping = Utilities.EaseInOut(ping);
836+
tmp.color = Color.Lerp(a, b, ping);
835837

836-
float scale = Mathf.Lerp(0.95f, 1.05f, ping);
837-
transform.localScale = Vector3.one * (0.4f * scale);
838+
float scale = Mathf.Lerp(0.95f, 1.05f, ping);
839+
transform.localScale = Vector3.one * (0.4f * scale);
840+
}
838841

839842
yield return null;
840843
}

src/Replay/Files/ReplayExplorer.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ public void GoUp()
210210
public void Next()
211211
{
212212
if (currentReplayEntries.Count == 0) return;
213-
214-
if (GetPage().All(e => e.IsFolder)) return;
213+
if (currentReplayEntries.All(e => e.IsFolder)) return;
215214

216215
do
217216
{
@@ -225,8 +224,7 @@ public void Next()
225224
public void Previous()
226225
{
227226
if (currentReplayEntries.Count == 0) return;
228-
229-
if (GetPage().All(e => e.IsFolder)) return;
227+
if (currentReplayEntries.All(e => e.IsFolder)) return;
230228

231229
do
232230
{

src/Replay/ReplayAPI.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,16 @@
88
using ReplayMod.Replay.Files;
99
using ReplayMod.Replay.Serialization;
1010
using ReplayMod.Replay.UI;
11-
using RumbleModUI;
12-
using RumbleModUIPlus;
1311
using UnityEngine;
1412
using BuildInfo = ReplayMod.Core.BuildInfo;
1513
using CompressionLevel = System.IO.Compression.CompressionLevel;
1614
using Main = ReplayMod.Core.Main;
17-
using Mod = RumbleModUI.Mod;
1815

1916
namespace ReplayMod.Replay;
2017

2118
public static class ReplayAPI
2219
{
2320
private static readonly List<ReplayExtension> _extensions = new();
24-
private static readonly List<ModSettingFolder> _extensionFolders = new();
2521

2622
/// <summary>
2723
/// Invoked when a replay is selected from the UI.

src/Replay/ReplayVoices.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public static void OnRemoteVoiceLinkAdded(RemoteVoiceLink link)
176176
link.VoiceInfo.SamplingRate,
177177
link.VoiceInfo.Channels,
178178
path,
179+
bitrate: Mathf.Clamp(Main.instance.voiceBitrate.Value, 8, 128),
179180
initalTimeStamp: startTime // file doesnt actually start until the person starts speaking for the first time
180181
);
181182

@@ -228,9 +229,8 @@ public VoiceStreamWriter(
228229
Channels = channels;
229230

230231
_fileStream = File.Create(path);
231-
232-
233-
_encoder = OpusCodecFactory.CreateEncoder(sampleRate, channels, Concentus.Enums.OpusApplication.OPUS_APPLICATION_VOIP);
232+
233+
_encoder = OpusCodecFactory.CreateEncoder(sampleRate, channels, OpusApplication.OPUS_APPLICATION_VOIP);
234234
_encoder.Bitrate = bitrate;
235235
_encoder.Complexity = complexity;
236236
_encoder.SignalType = OpusSignal.OPUS_SIGNAL_VOICE;

src/Replay/UI/ReplayCrystals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void HandleCrystals()
5252
}
5353
}
5454

55-
if (heldCrystal == null)
55+
if (heldCrystal == null && Main.isSceneReady)
5656
{
5757
if (Calls.ControllerMap.RightController.GetGrip() > 0.5f)
5858
{

0 commit comments

Comments
 (0)