Skip to content

Commit

Permalink
Add save replay config option
Browse files Browse the repository at this point in the history
  • Loading branch information
RRM101 committed Oct 6, 2024
1 parent f0f0579 commit 06f13e6
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 6 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/fallguyloadr/v17/.suo
Binary file not shown.
7 changes: 5 additions & 2 deletions fallguyloadr/FallGuyBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class FallGuyBehaviour : MonoBehaviour
CheckpointManager checkpointManager;
MotorFunctionMovement movement;
bool qualified;
bool wasReplaying;

void Start()
{
Expand All @@ -60,6 +61,7 @@ void Start()

if (ReplayManager.Instance.currentReplay != null)
{
wasReplaying = true;
Replay replay = ReplayManager.Instance.currentReplay;
foreach (float[] position in replay.Positions)
{
Expand Down Expand Up @@ -163,7 +165,7 @@ void SetV11Physics()

public void StopRecording(bool save)
{
if (ReplayManager.Instance.currentReplay == null)
if (ReplayManager.Instance.currentReplay == null && !wasReplaying)
{
ReplayManager.Instance.startPlaying = false;
if (save)
Expand Down Expand Up @@ -198,7 +200,8 @@ void OnTriggerEnter(Collider other)
{
qualified = true;

StopRecording(true);
if (Plugin.SaveReplays.Value)
StopRecording(true);

Qualify(false);
}
Expand Down
3 changes: 2 additions & 1 deletion fallguyloadr/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ static void MotorFunctionGrabStateGrabCrown(MotorFunctionGrabStateGrabCrown __in
{
FallGuyBehaviour fallguy = LoaderManager.instance.fallguy.GetComponent<FallGuyBehaviour>();
fallguy.Qualify(true);
fallguy.StopRecording(true);
if (Plugin.SaveReplays.Value)
fallguy.StopRecording(true);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions fallguyloadr/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class Plugin : BasePlugin
public static ConfigEntry<string> Theme { get; set; }
public static ConfigEntry<int> CustomAudioVolume { get; set; }
public static ConfigEntry<bool> UseV11CharacterPhysics { get; set; }
public static ConfigEntry<bool> SaveReplays { get; set; }

public override void Load()
{
Expand All @@ -61,6 +62,7 @@ public override void Load()
Theme = Config.Bind("Config", "Theme", "Default", "Custom theme for the Main Menu and the Round Loading Screen.");
CustomAudioVolume = Config.Bind("Config", "Custom Audio Volume", 50, "Volume for custom audio. (Max 100)");
UseV11CharacterPhysics = Config.Bind("Config", "Use V11 Physics", false, "Enables the physics changes made in Fall Guys versions 10.9 and 11.0");
SaveReplays = Config.Bind("Config", "Save Replays", true, "Saves Replays when you qualify or win.");

BepInEx.Logging.Logger.Sources.Add(Logs);

Expand Down
3 changes: 2 additions & 1 deletion fallguyloadr/ReplayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public static void SaveReplay(Vector3[] positions_, Quaternion[] rotations_)
string replayJson = JsonSerializer.Serialize<Replay>(replay);

File.WriteAllText(filepath, replayJson);
Plugin.Logs.LogInfo("Saved Replay");
}
else
{
Expand All @@ -153,7 +154,7 @@ public static void SaveReplay(Vector3[] positions_, Quaternion[] rotations_)
Message = $"Could not save Replay because a file with the same name exists.",
LocaliseTitle = UIModalMessage.LocaliseOption.NotLocalised,
LocaliseMessage = UIModalMessage.LocaliseOption.NotLocalised,
ModalType = UIModalMessage.ModalType.MT_BLOCKING,
ModalType = UIModalMessage.ModalType.MT_OK,
};

PopupManager.Instance.Show(PopupInteractionType.Error, modalMessageData);
Expand Down
4 changes: 2 additions & 2 deletions fallguyloadr/UI/InfoPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public InfoPanel(UIBase owner) : base(owner)

public override string Name => "Info";
public override int MinWidth => 355;
public override int MinHeight => 275;
public override int MinHeight => 295;
public override Vector2 DefaultAnchorMin => new(0.25f, 0.25f);
public override Vector2 DefaultAnchorMax => new(0.75f, 0.75f);
public override bool CanDragAndResize => true;

string InfoText = "FGChaos Keyboard Shortcuts:\nCtrl+L: Stop Chaos\nF1: Open Effect Options\nF3: Open Debug Menu\n\nfallguyloadr Keyboard Shortcuts:\nF2: Toggle UI\nO: Stop Playing Replay\nP: Save Recorded Replay";
string InfoText = "FGChaos Keyboard Shortcuts:\nCtrl+L: Stop Chaos\nF1: Open Effect Options\nF3: Open Debug Menu\n\nfallguyloadr Keyboard Shortcuts:\nF2: Toggle UI\nR: Respawn\nO: Stop Playing Replay\nP: Save Recorded Replay";

protected override void ConstructPanelContent()
{
Expand Down

0 comments on commit 06f13e6

Please sign in to comment.