From f0421593e24bc510c9d81fc73f763d7cbb321975 Mon Sep 17 00:00:00 2001 From: Jonathon Fitch Date: Wed, 11 May 2022 08:58:13 +0100 Subject: [PATCH] Disable score submission for ghost notes --- PC/MiscConfig.cs | 21 ++++++++++++++++----- PC/Plugin.cs | 17 ++++++++++++++++- PC/Weather.csproj | 1 + 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/PC/MiscConfig.cs b/PC/MiscConfig.cs index 27f4f22..7337d1e 100644 --- a/PC/MiscConfig.cs +++ b/PC/MiscConfig.cs @@ -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; } } @@ -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); @@ -47,6 +48,7 @@ public static void Write() Plugin.Log.Info(serialized); lines.Add(serialized); } + File.WriteAllLines(Path, lines); } @@ -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) @@ -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); } @@ -89,6 +98,7 @@ public static MiscConfigObject ReadObject(string name) { @out = Deserialize(line); } + return @out; } @@ -100,6 +110,7 @@ public static bool HasObject(string name) var parts = line.Split('_'); if (parts[0] == name) return true; } + return false; } } diff --git a/PC/Plugin.cs b/PC/Plugin.cs index 5d23352..ba61445 100644 --- a/PC/Plugin.cs +++ b/PC/Plugin.cs @@ -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; @@ -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"; @@ -91,6 +94,12 @@ private void GameSceneActive() { WeatherSceneInfo.CurrentScene = SceneManager.GetSceneByName(Game); BundleLoader.WeatherPrefab.GetComponent().SetActiveRefs(); + + var playerData = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (playerData.playerData.gameplayModifiers.ghostNotes) + { + DisableScore(true, "Ghost notes are enabled"); + } } private void LoadForCastUI() @@ -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); + } } } diff --git a/PC/Weather.csproj b/PC/Weather.csproj index 1439bb7..09f376f 100644 --- a/PC/Weather.csproj +++ b/PC/Weather.csproj @@ -19,6 +19,7 @@ +