Skip to content

Commit

Permalink
Rc2 probably
Browse files Browse the repository at this point in the history
+ added a check to MininumWaitUntilRecordingCanStart so it cant be too much or below 0

# changed the max stop recording delay to be 20 seconds
# renaming files is more reliable (again)
  • Loading branch information
TheXorog committed Jul 17, 2021
1 parent a2d99c6 commit 369c308
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
3 changes: 3 additions & 0 deletions OBSControl/Objects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class BeatSaberEvent
public static bool FinishedLastSong = false;
public static bool FailedLastSong = false;

public static bool FinishedCurrentSong = false;
public static bool FailedCurrentSong = false;

public class Status
{
public Game game { get; set; }
Expand Down
40 changes: 27 additions & 13 deletions OBSControl/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Program
static Objects.Performance LastPerformance { get; set; }
static Objects.Beatmap LastBeatmap { get; set; }

static Objects.Performance CurrentPerformance { get; set; }
static Objects.Beatmap CurrentBeatmap { get; set; }


static bool OBSRecording = false;
static bool OBSRecordingPaused = false;
Expand Down Expand Up @@ -393,10 +396,10 @@ private static void BeatSaberWebSocket_MessageReceived(string e)
case "songStart":
_logger.LogInfo("[BS] Song started.");

Objects.FailedLastSong = false;
Objects.FinishedLastSong = false;
LastBeatmap = _status.status.beatmap;
LastPerformance = _status.status.performance;
Objects.FailedCurrentSong = false;
Objects.FinishedCurrentSong = false;
CurrentBeatmap = _status.status.beatmap;
CurrentPerformance = _status.status.performance;

try
{
Expand All @@ -412,15 +415,15 @@ private static void BeatSaberWebSocket_MessageReceived(string e)
case "finished":
_logger.LogInfo("[BS] Song finished.");

LastPerformance = _status.status.performance;
Objects.FinishedLastSong = true;
CurrentPerformance = _status.status.performance;
Objects.FinishedCurrentSong = true;
break;

case "failed":
_logger.LogInfo("[BS] Song failed.");
LastPerformance = _status.status.performance;
Objects.FailedLastSong = true;

CurrentPerformance = _status.status.performance;
Objects.FailedCurrentSong = true;

break;

Expand Down Expand Up @@ -461,6 +464,11 @@ private static void BeatSaberWebSocket_MessageReceived(string e)

try
{
LastPerformance = CurrentPerformance;
LastBeatmap = CurrentBeatmap;

Objects.FinishedLastSong = Objects.FinishedCurrentSong;
Objects.FailedLastSong = Objects.FailedCurrentSong;
_ = StopRecording(CancelStopRecordingDelay.Token);
}
catch (Exception ex)
Expand All @@ -471,7 +479,7 @@ private static void BeatSaberWebSocket_MessageReceived(string e)
break;

case "scoreChanged":
LastPerformance = _status.status.performance;
CurrentPerformance = _status.status.performance;
break;
}
}
Expand All @@ -493,7 +501,13 @@ private static async Task StartRecording()
Thread.Sleep(20);
}

Thread.Sleep(Objects.LoadedSettings.MininumWaitUntilRecordingCanStart);
if (Objects.LoadedSettings.MininumWaitUntilRecordingCanStart > 199 || Objects.LoadedSettings.MininumWaitUntilRecordingCanStart < 2001)
Thread.Sleep(Objects.LoadedSettings.MininumWaitUntilRecordingCanStart);
else
{
_logger.LogError("The MininumWaitUntilRecordingCanStart has to be between 200ms and 2000ms. Defaulting to a wait time of 800ms.");
Thread.Sleep(800);
}

OBSWebSocket.Send($"{{\"request-type\":\"StartRecording\", \"message-id\":\"StartRecording\"}}");
}
Expand All @@ -511,7 +525,7 @@ private static async Task StopRecording(CancellationToken CancelToken, bool Forc
{
if (!ForceStop)
{
if (Objects.LoadedSettings.StopRecordingDelay > 0 && Objects.LoadedSettings.StopRecordingDelay < 11)
if (Objects.LoadedSettings.StopRecordingDelay > 0 && Objects.LoadedSettings.StopRecordingDelay < 21)
{
try
{
Expand All @@ -523,7 +537,7 @@ private static async Task StopRecording(CancellationToken CancelToken, bool Forc
}
}
else
_logger.LogError("[OBS] The specified delay is not in between 1 and 10 seconds. The delay will be skipped.");
_logger.LogError("[OBS] The specified delay is not in between 1 and 20 seconds. The delay will be skipped.");
}

OBSWebSocket.Send($"{{\"request-type\":\"StopRecording\", \"message-id\":\"StopRecording\"}}");
Expand Down

0 comments on commit 369c308

Please sign in to comment.