Skip to content

Commit 144660e

Browse files
committed
Add option to auto-skip the fail animation
1 parent cef3428 commit 144660e

File tree

8 files changed

+58
-15
lines changed

8 files changed

+58
-15
lines changed

FastFail/Config.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace FastFail
2+
{
3+
class Config
4+
{
5+
public static BS_Utils.Utilities.Config config = new BS_Utils.Utilities.Config("FastFail");
6+
public static bool autoSkip = false;
7+
8+
public static void Read()
9+
{
10+
autoSkip = config.GetBool("FastFail", "autoSkip", false, true);
11+
}
12+
13+
public static void Write()
14+
{
15+
config.SetBool("FastFail", "autoSkip", autoSkip);
16+
}
17+
}
18+
}

FastFail/FailSkip.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,18 @@ class FailSkip : MonoBehaviour
2222

2323
protected bool _standardLevel;
2424
protected bool _hasFailed = false;
25+
protected bool autoSkip;
2526

2627
public void Awake()
2728
{
28-
Logger.Log("Awakening");
2929
_standardLevelGameplayManager = Resources.FindObjectsOfTypeAll<StandardLevelGameplayManager>().FirstOrDefault();
3030
if (_standardLevelGameplayManager)
3131
{
3232
_standardLevelGameplayManager.levelFailedEvent += this.OnLevelFail;
3333
_standardLevel = true;
34-
Logger.Log("Standard");
3534
}
3635
else
3736
{
38-
Logger.Log("Mission");
3937
_missionLevelGameplayManager = Resources.FindObjectsOfTypeAll<MissionLevelGameplayManager>().FirstOrDefault();
4038
_missionLevelGameplayManager.levelFailedEvent += this.OnLevelFail;
4139
_standardLevel = false;
@@ -59,6 +57,8 @@ public void Awake()
5957

6058
_vrControllersInputManager = Resources.FindObjectsOfTypeAll<PauseMenuManager>().FirstOrDefault()
6159
.GetField<VRControllersInputManager, PauseMenuManager>("_vrControllersInputManager");
60+
61+
autoSkip = Config.autoSkip;
6262
}
6363

6464
public void OnLevelFail()
@@ -68,10 +68,8 @@ public void OnLevelFail()
6868

6969
public void Update()
7070
{
71-
if (_hasFailed && _vrControllersInputManager.MenuButtonDown())
71+
if (_hasFailed && (autoSkip || _vrControllersInputManager.MenuButtonDown()))
7272
{
73-
Logger.Log("pause button pressed during fail!");
74-
7573
if (_standardLevel)
7674
{
7775
_standardLevelFailedController.StopAllCoroutines();

FastFail/FastFail.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
3434
<ItemGroup>
35+
<Reference Include="BSML">
36+
<HintPath>E:\Steam\steamapps\common\Beat Saber\Plugins\BSML.dll</HintPath>
37+
</Reference>
3538
<Reference Include="BS_Utils">
3639
<HintPath>E:\Steam\steamapps\common\Beat Saber\Plugins\BS_Utils.dll</HintPath>
3740
</Reference>
@@ -45,6 +48,9 @@
4548
<Reference Include="Main">
4649
<HintPath>E:\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Main.dll</HintPath>
4750
</Reference>
51+
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
52+
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
53+
</Reference>
4854
<Reference Include="System" />
4955
<Reference Include="System.Core" />
5056
<Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
@@ -66,17 +72,20 @@
6672
<Reference Include="UnityEngine.XRModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" />
6773
</ItemGroup>
6874
<ItemGroup>
75+
<Compile Include="Config.cs" />
6976
<Compile Include="FailSkip.cs" />
7077
<Compile Include="Plugin.cs" />
7178
<Compile Include="Logger.cs" />
7279
<Compile Include="PluginConfig.cs" />
7380
<Compile Include="Properties\AssemblyInfo.cs" />
81+
<Compile Include="UI\Settings.cs" />
7482
</ItemGroup>
7583
<ItemGroup>
7684
<EmbeddedResource Include="manifest.json" />
7785
</ItemGroup>
7886
<ItemGroup>
7987
<None Include="packages.config" />
88+
<EmbeddedResource Include="UI\settings.bsml" />
8089
</ItemGroup>
8190
<ItemGroup />
8291
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

FastFail/Plugin.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
using BS_Utils;
1+
using BeatSaberMarkupLanguage.Settings;
2+
using FastFail.UI;
23
using IPA;
34
using IPALogger = IPA.Logging.Logger;
4-
using LogLevel = IPA.Logging.Logger.Level;
5-
using System;
6-
using System.Reflection;
75
using UnityEngine;
86

97
namespace FastFail
@@ -20,7 +18,9 @@ public void Init(IPALogger logger)
2018
[OnStart]
2119
public void OnStart()
2220
{
21+
Config.Read();
2322
BS_Utils.Utilities.BSEvents.gameSceneLoaded += OnGameSceneLoaded;
23+
BSMLSettings.instance.AddSettingsMenu("FastFail", "FastFail.UI.settings.bsml", Settings.instance);
2424
}
2525

2626
private void OnGameSceneLoaded()

FastFail/UI/Settings.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using BeatSaberMarkupLanguage.Attributes;
2+
3+
namespace FastFail.UI
4+
{
5+
class Settings : PersistentSingleton<Settings>
6+
{
7+
[UIValue("autoSkip")]
8+
public bool autoSkip
9+
{
10+
get => Config.autoSkip;
11+
set
12+
{
13+
Config.autoSkip = value;
14+
Config.Write();
15+
}
16+
}
17+
}
18+
}

FastFail/UI/settings.bsml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<settings-container>
2+
<checkbox text='Auto skip' value='autoSkip' hover-hint='If disabled, you will have to press the menu (pause) button to skip the fail animation'></checkbox>
3+
</settings-container>

FastFail/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"gameVersion": "1.8.0",
66
"id": "FastFail",
77
"name": "FastFail",
8-
"version": "0.7.0",
8+
"version": "0.8.0",
99
"features": []
1010
}

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# FastFail
22
Beat Saber mod to make failing a song not take as long
33

4-
Desired features before 1.0 release:
5-
* ~~Skip fail animation via button press~~
6-
* ~~Support skipping mission fail~~
7-
* Option to toggle between auto and manual skip
4+
By default, you must press the menu (pause) button to skip the fail animation, but there is an option to enable auto-skipping.

0 commit comments

Comments
 (0)