Skip to content

Commit

Permalink
Disable score submission for ghost notes
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyVR1 committed May 11, 2022
1 parent 02e29b0 commit f042159
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
21 changes: 16 additions & 5 deletions PC/MiscConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ internal class MiscConfigObject

public MiscConfigObject(string name, bool showInMenu, bool showInGame)
{
this.Name = name;
this.ShowInMenu = showInMenu;
this.ShowInGame = showInGame;
Name = name;
ShowInMenu = showInMenu;
ShowInGame = showInGame;
}
}

Expand All @@ -38,6 +38,7 @@ private static MiscConfigObject Deserialize(string @object)
var parts = @object.Split('_');
return new MiscConfigObject(parts[0], bool.Parse(parts[1]), bool.Parse(parts[2]));
}

public static void Write()
{
Plugin.Log.Info(Path);
Expand All @@ -47,6 +48,7 @@ public static void Write()
Plugin.Log.Info(serialized);
lines.Add(serialized);
}

File.WriteAllLines(Path, lines);
}

Expand All @@ -57,7 +59,11 @@ public static void Add(MiscConfigObject @object)

public static void Read()
{
if (!File.Exists(Path)) { File.WriteAllText(Path, ""); return; }
if (!File.Exists(Path))
{
File.WriteAllText(Path, ""); return;
}

var lines = File.ReadAllLines(Path);
Root.MiscConfigObjects.Clear();
foreach (var line in lines)
Expand All @@ -75,9 +81,12 @@ public static void WriteToObject(MiscConfigObject @object)
{
var line = arrLine[i];
var parts = line.Split('_');
if(parts[0] == @object.Name)
if (parts[0] == @object.Name)
{
arrLine[i] = Serialize(@object);
}
}

File.WriteAllLines(Path, arrLine);
}

Expand All @@ -89,6 +98,7 @@ public static MiscConfigObject ReadObject(string name)
{
@out = Deserialize(line);
}

return @out;
}

Expand All @@ -100,6 +110,7 @@ public static bool HasObject(string name)
var parts = line.Split('_');
if (parts[0] == name) return true;
}

return false;
}
}
Expand Down
17 changes: 16 additions & 1 deletion PC/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using BeatSaberMarkupLanguage;
using System.Linq;
using BeatSaberMarkupLanguage;
using BeatSaberMarkupLanguage.MenuButtons;
using HarmonyLib;
using IPA;
using IPA.Config.Stores;
using System.Reflection;
using JetBrains.Annotations;
using SiraUtil.Submissions;
using UnityEngine;
using UnityEngine.SceneManagement;
using IPALogger = IPA.Logging.Logger;
Expand All @@ -20,6 +22,7 @@ internal class Plugin
internal static IPA.Config.Config Config { get; private set; }
internal static MenuButton MenuButton { get; private set; }
private static ForecastFlowCoordinator ForecastFlowCoordinator { get; set; }
private static readonly Submission _submission;
internal const string Menu = "MainMenu";
internal const string Game = "GameCore";

Expand Down Expand Up @@ -91,6 +94,12 @@ private void GameSceneActive()
{
WeatherSceneInfo.CurrentScene = SceneManager.GetSceneByName(Game);
BundleLoader.WeatherPrefab.GetComponent<WeatherSceneInfo>().SetActiveRefs();

var playerData = Resources.FindObjectsOfTypeAll<PlayerDataModel>().FirstOrDefault();
if (playerData.playerData.gameplayModifiers.ghostNotes)
{
DisableScore(true, "Ghost notes are enabled");
}
}

private void LoadForCastUI()
Expand All @@ -102,5 +111,11 @@ private void LoadForCastUI()

BeatSaberUI.MainFlowCoordinator.PresentFlowCoordinator(ForecastFlowCoordinator);
}

private static void DisableScore(bool disable, string reason)
{
if (!disable) return;
_submission.DisableScoreSubmission("Weather", reason);
}
}
}
1 change: 1 addition & 0 deletions PC/Weather.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Reference Include="HMLib" HintPath="$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll" />
<Reference Include="HMUI" HintPath="$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll" />
<Reference Include="IPA.Loader" HintPath="$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll" />
<Reference Include="SiraUtil" HintPath="$(BeatSaberDir)\Plugins\SiraUtil.dll" />
<Reference Include="Unity.TextMeshPro" HintPath="$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll" />
<Reference Include="UnityEngine" HintPath="$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll" />
<Reference Include="UnityEngine.AssetBundleModule" HintPath="$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.AssetBundleModule.dll" />
Expand Down

0 comments on commit f042159

Please sign in to comment.