From f639221bb92a20bf5bf7c85f7918ec73960b3984 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sat, 30 Oct 2021 23:48:28 +0200 Subject: [PATCH 1/4] Fix MultiplayerModeSelectionFlowCoordinatorPatch, remove ConnectToMatchmakingPatch --- .../HarmonyPatches/CustomSongsPatches.cs | 12 ------------ .../HarmonyPatches/QuickplayPatches.cs | 5 ++++- .../Utilities/Harmony/HarmonyManager.cs | 1 - 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/MultiplayerExtensions/HarmonyPatches/CustomSongsPatches.cs b/MultiplayerExtensions/HarmonyPatches/CustomSongsPatches.cs index abd2846..24ac681 100644 --- a/MultiplayerExtensions/HarmonyPatches/CustomSongsPatches.cs +++ b/MultiplayerExtensions/HarmonyPatches/CustomSongsPatches.cs @@ -22,18 +22,6 @@ static void Prefix(CreateServerFormData data) } } - [HarmonyPatch(typeof(MultiplayerLobbyConnectionController), nameof(MultiplayerLobbyConnectionController.ConnectToMatchmaking), MethodType.Normal)] - internal class ConnectToMatchmakingPatch - { - /// - /// Modifies the data used to matchmake - /// - static void Prefix(ref SongPackMask songPackMask) - { - if (!MPState.CurrentMasterServer.isOfficial) - songPackMask |= new SongPackMask("custom_levelpack_CustomLevels"); - } - } [HarmonyPatch(typeof(MultiplayerLevelSelectionFlowCoordinator), "enableCustomLevels", MethodType.Getter)] internal class EnableCustomLevelsPatch diff --git a/MultiplayerExtensions/HarmonyPatches/QuickplayPatches.cs b/MultiplayerExtensions/HarmonyPatches/QuickplayPatches.cs index 8844d3b..05ec4c1 100644 --- a/MultiplayerExtensions/HarmonyPatches/QuickplayPatches.cs +++ b/MultiplayerExtensions/HarmonyPatches/QuickplayPatches.cs @@ -12,11 +12,12 @@ namespace MultiplayerExtensions.HarmonyPatches [HarmonyPatch(typeof(MultiplayerModeSelectionFlowCoordinator), nameof(MultiplayerModeSelectionFlowCoordinator.HandleJoinQuickPlayViewControllerDidFinish), MethodType.Normal)] internal class MultiplayerModeSelectionFlowCoordinatorPatch { + internal static bool skipCheck = false; static bool Prefix(MultiplayerModeSelectionFlowCoordinator __instance, bool success, JoinQuickPlayViewController ____joinQuickPlayViewController, SimpleDialogPromptViewController ____simpleDialogPromptViewController, SongPackMaskModelSO ____songPackMaskModel) { string levelPackName = ____joinQuickPlayViewController.multiplayerModeSettings.quickPlaySongPackMaskSerializedName; Plugin.Log?.Debug(levelPackName); - if (success && ____songPackMaskModel.ToSongPackMask(levelPackName).Contains("custom_levelpack_CustomLevels")) + if (success && ____songPackMaskModel.ToSongPackMask(levelPackName).Contains("custom_levelpack_CustomLevels") && !skipCheck) { ____simpleDialogPromptViewController.Init( "Custom Song Quickplay", @@ -29,6 +30,7 @@ static bool Prefix(MultiplayerModeSelectionFlowCoordinator __instance, bool succ { default: case 0: // Continue + skipCheck = true; __instance.HandleJoinQuickPlayViewControllerDidFinish(true); break; case 1: // Cancel @@ -44,6 +46,7 @@ static bool Prefix(MultiplayerModeSelectionFlowCoordinator __instance, bool succ }); return false; } + skipCheck = false; return true; } } diff --git a/MultiplayerExtensions/Utilities/Harmony/HarmonyManager.cs b/MultiplayerExtensions/Utilities/Harmony/HarmonyManager.cs index 39f2d17..fa314f8 100644 --- a/MultiplayerExtensions/Utilities/Harmony/HarmonyManager.cs +++ b/MultiplayerExtensions/Utilities/Harmony/HarmonyManager.cs @@ -23,7 +23,6 @@ static HarmonyManager() { AddDefaultPatch(); AddDefaultPatch(); - AddDefaultPatch(); AddDefaultPatch(); AddDefaultPatch(); AddDefaultPatch(); From a11ad543341b03204c7ab76684b90e105d7300a4 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Wed, 3 Nov 2021 17:16:09 +0100 Subject: [PATCH 2/4] New CenterScreenLoadingPanel, fix HandleMultiplayerLevelLoaderCountdownFinished, add ProtocolVersion --- MultiplayerExtensions/Downloader.cs | 2 +- .../Extensions/ExtendedEntitlementChecker.cs | 4 ++++ .../Extensions/ExtendedGameStateController.cs | 15 +++++++++------ .../Extensions/ExtendedPlayer.cs | 10 +++++----- .../Extensions/ExtendedSessionManager.cs | 8 ++++---- .../MultiplayerExtensions.csproj | 2 +- MultiplayerExtensions/Plugin.cs | 2 ++ .../UI/CenterScreenLoadingPanel.cs | 13 +++++++++---- MultiplayerExtensions/manifest.json | 2 +- 9 files changed, 36 insertions(+), 22 deletions(-) diff --git a/MultiplayerExtensions/Downloader.cs b/MultiplayerExtensions/Downloader.cs index 2e3136e..4845021 100644 --- a/MultiplayerExtensions/Downloader.cs +++ b/MultiplayerExtensions/Downloader.cs @@ -49,7 +49,7 @@ public static bool TryGetDownload(string levelId, out Task { Plugin.Log?.Info($"Version: '{version.Key}' '{version.Hash}'"); return version.Hash.ToUpper() == hash; - }).DownloadZIP(progress: UI.CenterScreenLoadingPanel.self); + }).DownloadZIP(progress: UI.CenterScreenLoadingPanel.Instance); #if DEBUG TimeSpan delay = TimeSpan.FromSeconds(Plugin.Config.DebugConfig?.MinDownloadTime ?? 0) - TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds); if (delay > TimeSpan.Zero) diff --git a/MultiplayerExtensions/Extensions/ExtendedEntitlementChecker.cs b/MultiplayerExtensions/Extensions/ExtendedEntitlementChecker.cs index 6072ef2..5e94467 100644 --- a/MultiplayerExtensions/Extensions/ExtendedEntitlementChecker.cs +++ b/MultiplayerExtensions/Extensions/ExtendedEntitlementChecker.cs @@ -118,7 +118,10 @@ public async Task WaitForOkEntitlement(string userId, string levelId, Cancellati { if (_entitlementsDictionary.TryGetValue(userId, out Dictionary userDictionary)) if (userDictionary.TryGetValue(levelId, out EntitlementsStatus entitlement) && entitlement == EntitlementsStatus.Ok) + { + UI.CenterScreenLoadingPanel.Instance.playersReady++; return; + } if (!_tcsDictionary.ContainsKey(userId)) _tcsDictionary[userId] = new Dictionary>(); @@ -132,6 +135,7 @@ public async Task WaitForOkEntitlement(string userId, string levelId, Cancellati { result = await _tcsDictionary[userId][levelId].Task.ContinueWith(t => t.IsCompleted ? t.Result : EntitlementsStatus.Unknown); _tcsDictionary[userId][levelId] = new TaskCompletionSource(); + if (result == EntitlementsStatus.Ok) UI.CenterScreenLoadingPanel.Instance.playersReady++; } } } diff --git a/MultiplayerExtensions/Extensions/ExtendedGameStateController.cs b/MultiplayerExtensions/Extensions/ExtendedGameStateController.cs index 7277558..5151155 100644 --- a/MultiplayerExtensions/Extensions/ExtendedGameStateController.cs +++ b/MultiplayerExtensions/Extensions/ExtendedGameStateController.cs @@ -1,4 +1,5 @@ -using System; +using IPA.Utilities; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -91,7 +92,14 @@ public override void StopLoading() public async override void HandleMultiplayerLevelLoaderCountdownFinished(IPreviewBeatmapLevel previewBeatmapLevel, BeatmapDifficulty beatmapDifficulty, BeatmapCharacteristicSO beatmapCharacteristic, IDifficultyBeatmap difficultyBeatmap, GameplayModifiers gameplayModifiers) { + if (_multiplayerLevelLoader.GetField("_loaderState") == MultiplayerLevelLoader.MultiplayerBeatmapLoaderState.NotLoading) + { + Plugin.Log?.Info("HandleMultiplayerLevelLoaderCountdownFinished already running, returning"); + return; + } + _multiplayerLevelLoader.SetField("_loaderState", MultiplayerLevelLoader.MultiplayerBeatmapLoaderState.NotLoading); Plugin.Log?.Debug("Map finished loading, waiting for other players..."); + UI.CenterScreenLoadingPanel.Instance.playersReady = 0; _menuRpcManager.SetIsEntitledToLevel(previewBeatmapLevel.levelID, EntitlementsStatus.Ok); if (_levelStartedOnTime == false) @@ -116,11 +124,6 @@ public async override void HandleMultiplayerLevelLoaderCountdownFinished(IPrevie Plugin.Log?.Debug("All players ready, starting game."); - Plugin.Log?.Debug($"Null Checking previewBeatmapLevel: '{(previewBeatmapLevel == null ? "null" : "not null")}'"); - Plugin.Log?.Debug($"Null Checking beatmapDifficulty: '{beatmapDifficulty}'"); - Plugin.Log?.Debug($"Null Checking beatmapCharacteristic: '{(beatmapCharacteristic == null ? "null" : "not null")}'"); - Plugin.Log?.Debug($"Null Checking difficultyBeatmap: '{(difficultyBeatmap == null ? "null" : "not null")}'"); - Plugin.Log?.Debug($"Null Checking gameplayModifiers: '{(gameplayModifiers == null ? "null" : "not null")}'"); base.HandleMultiplayerLevelLoaderCountdownFinished(previewBeatmapLevel, beatmapDifficulty, beatmapCharacteristic, difficultyBeatmap, gameplayModifiers); } diff --git a/MultiplayerExtensions/Extensions/ExtendedPlayer.cs b/MultiplayerExtensions/Extensions/ExtendedPlayer.cs index 7c2e6c1..0126b1a 100644 --- a/MultiplayerExtensions/Extensions/ExtendedPlayer.cs +++ b/MultiplayerExtensions/Extensions/ExtendedPlayer.cs @@ -22,7 +22,7 @@ public class ExtendedPlayer : IConnectedPlayer /// /// MultiplayerExtensions version reported by BSIPA. /// - public SemVer.Version mpexVersion; + public Hive.Versioning.Version mpexVersion; /// /// Player's color set in the plugin config. @@ -37,7 +37,7 @@ public class ExtendedPlayer : IConnectedPlayer public ExtendedPlayer(IConnectedPlayer player) { _connectedPlayer = player; - this.mpexVersion = Plugin.PluginMetadata.Version; + this.mpexVersion = Plugin.ProtocolVersion; } public ExtendedPlayer(IConnectedPlayer player, string platformID, Platform platform, Color playerColor) @@ -45,11 +45,11 @@ public ExtendedPlayer(IConnectedPlayer player, string platformID, Platform platf _connectedPlayer = player; this.platformID = platformID; this.platform = platform; - this.mpexVersion = Plugin.PluginMetadata.Version; + this.mpexVersion = Plugin.ProtocolVersion; this.playerColor = playerColor; } - public ExtendedPlayer(IConnectedPlayer player, string platformID, Platform platform, SemVer.Version mpexVersion, Color playerColor) + public ExtendedPlayer(IConnectedPlayer player, string platformID, Platform platform, Hive.Versioning.Version mpexVersion, Color playerColor) { _connectedPlayer = player; this.platformID = platformID; @@ -102,7 +102,7 @@ public void Deserialize(NetDataReader reader) public ExtendedPlayerPacket Init(string platformID, Platform platform, Color playerColor) { this.platformID = platformID; - this.mpexVersion = Plugin.PluginMetadata.Version.ToString(); + this.mpexVersion = Plugin.ProtocolVersion.ToString(); this.playerColor = playerColor; this.platform = platform; return this; diff --git a/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs b/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs index 8249d4b..e69e037 100644 --- a/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs +++ b/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs @@ -92,18 +92,18 @@ private void HandleExtendedPlayerPacket(ExtendedPlayerPacket packet, IConnectedP extendedPlayer.platformID = packet.platformID; extendedPlayer.platform = packet.platform; extendedPlayer.playerColor = packet.playerColor; - extendedPlayer.mpexVersion = new SemVer.Version(packet.mpexVersion); + extendedPlayer.mpexVersion = new Hive.Versioning.Version(packet.mpexVersion); } else { Plugin.Log?.Info($"Received 'ExtendedPlayerPacket' from '{player.userId}' with platformID: '{packet.platformID}' mpexVersion: '{packet.mpexVersion}'"); - ExtendedPlayer extendedPlayer = new ExtendedPlayer(player, packet.platformID, packet.platform, new SemVer.Version(packet.mpexVersion), packet.playerColor); + ExtendedPlayer extendedPlayer = new ExtendedPlayer(player, packet.platformID, packet.platform, new Hive.Versioning.Version(packet.mpexVersion), packet.playerColor); - if (Plugin.PluginMetadata.Version != extendedPlayer.mpexVersion) + if (Plugin.ProtocolVersion != extendedPlayer.mpexVersion) { Plugin.Log?.Warn("###################################################################"); Plugin.Log?.Warn("Different MultiplayerExtensions version detected!"); - Plugin.Log?.Warn($"The player '{player.userName}' is using MultiplayerExtensions {extendedPlayer.mpexVersion} while you are using MultiplayerExtensions {Plugin.PluginMetadata.Version}"); + Plugin.Log?.Warn($"The player '{player.userName}' is using MultiplayerExtensions {extendedPlayer.mpexVersion} while you are using MultiplayerExtensions {Plugin.ProtocolVersion}"); Plugin.Log?.Warn("For best compatibility all players should use the same version of MultiplayerExtensions."); Plugin.Log?.Warn("###################################################################"); } diff --git a/MultiplayerExtensions/MultiplayerExtensions.csproj b/MultiplayerExtensions/MultiplayerExtensions.csproj index 403123c..54e142b 100644 --- a/MultiplayerExtensions/MultiplayerExtensions.csproj +++ b/MultiplayerExtensions/MultiplayerExtensions.csproj @@ -4,7 +4,7 @@ Library Properties MultiplayerExtensions - 0.6.1 + 0.6.2 net472 true portable diff --git a/MultiplayerExtensions/Plugin.cs b/MultiplayerExtensions/Plugin.cs index 83354dc..a724b33 100644 --- a/MultiplayerExtensions/Plugin.cs +++ b/MultiplayerExtensions/Plugin.cs @@ -27,6 +27,8 @@ public class Plugin internal static Plugin Instance { get; private set; } = null!; internal static PluginMetadata PluginMetadata = null!; + + internal static Hive.Versioning.Version ProtocolVersion { get; } = new Hive.Versioning.Version("1.0.0"); internal static IPALogger Log { get; private set; } = null!; internal static PluginConfig Config = null!; diff --git a/MultiplayerExtensions/UI/CenterScreenLoadingPanel.cs b/MultiplayerExtensions/UI/CenterScreenLoadingPanel.cs index efd9898..cddb249 100644 --- a/MultiplayerExtensions/UI/CenterScreenLoadingPanel.cs +++ b/MultiplayerExtensions/UI/CenterScreenLoadingPanel.cs @@ -15,20 +15,23 @@ class CenterScreenLoadingPanel : MonoBehaviour, IProgress private CenterStageScreenController screenController; private LoadingControl? loadingControl; private bool isDownloading; - public static CenterScreenLoadingPanel? self { get; private set; } + public int playersReady; + public static CenterScreenLoadingPanel? Instance { get; private set; } [Inject] internal void Inject(IMultiplayerSessionManager sessionManager, ILobbyGameStateController gameStateController, CenterStageScreenController screenController) { - self = this; + Instance = this; this.sessionManager = sessionManager; this.gameStateController = gameStateController; this.screenController = screenController; BeatSaberMarkupLanguage.Tags.VerticalLayoutTag verticalTag = new BeatSaberMarkupLanguage.Tags.VerticalLayoutTag(); GameObject vertical = verticalTag.CreateObject(transform); +#pragma warning disable CS8602 // Dereference of a possibly null reference. (vertical.transform as RectTransform).sizeDelta = new Vector2(60, 60); (vertical.transform as RectTransform).anchoredPosition = new Vector2(0.0f, -30.0f); +#pragma warning restore CS8602 // Dereference of a possibly null reference. var layout = vertical.AddComponent().minWidth = 60; GameObject existingLoadingControl = Resources.FindObjectsOfTypeAll().First().gameObject; @@ -37,7 +40,7 @@ internal void Inject(IMultiplayerSessionManager sessionManager, ILobbyGameStateC loadingControl.Hide(); } - public void Update() + public void FixedUpdate() { if (isDownloading) { @@ -46,12 +49,13 @@ public void Update() else if (screenController.countdownShown && sessionManager.syncTime >= gameStateController.startTime && gameStateController.levelStartInitiated) { if (loadingControl != null) - loadingControl.ShowLoading("Loading..."); + loadingControl.ShowLoading($"{playersReady + 1} of {(sessionManager.connectedPlayerCount + 1)} players ready..."); } else { if (loadingControl != null) loadingControl.Hide(); + playersReady = 0; } } @@ -59,6 +63,7 @@ public void OnDisable() { if (loadingControl != null) loadingControl.Hide(); + playersReady = 0; } public void Report(double value) diff --git a/MultiplayerExtensions/manifest.json b/MultiplayerExtensions/manifest.json index af15bce..b4906b1 100644 --- a/MultiplayerExtensions/manifest.json +++ b/MultiplayerExtensions/manifest.json @@ -3,7 +3,7 @@ "id": "MultiplayerExtensions", "name": "MultiplayerExtensions", "author": "Zingabopp and Goobwabber", - "version": "0.6.1", + "version": "0.6.2", "description": "Expands the functionality of Beat Saber Multiplayer.", "gameVersion": "1.17.1", "dependsOn": { From 4f61ec7fdf5b8226c4b13f07fcf609ea73057d2c Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sat, 13 Nov 2021 16:33:02 +0100 Subject: [PATCH 3/4] Check requirements, added State for having specific mods installed (currently needed on Quest), Fix, LagReducer disabling zenMode when enabled, added percentage to download indicator --- .../Extensions/ExtendedEntitlementChecker.cs | 33 ++++++++++++++++++- .../Extensions/ExtendedSessionManager.cs | 4 +++ .../HarmonyPatches/InstallerPatches.cs | 3 +- MultiplayerExtensions/Plugin.cs | 11 ++++++- .../UI/CenterScreenLoadingPanel.cs | 2 +- 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/MultiplayerExtensions/Extensions/ExtendedEntitlementChecker.cs b/MultiplayerExtensions/Extensions/ExtendedEntitlementChecker.cs index 5e94467..d049183 100644 --- a/MultiplayerExtensions/Extensions/ExtendedEntitlementChecker.cs +++ b/MultiplayerExtensions/Extensions/ExtendedEntitlementChecker.cs @@ -1,6 +1,7 @@ using BeatSaverSharp.Models; using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Zenject; @@ -75,12 +76,40 @@ public override Task GetEntitlementStatus(string levelId) return base.GetEntitlementStatus(levelId); if (SongCore.Collections.songWithHashPresent(hash)) + { + // The input parameter for RetrieveExtraSongData is called levelId but it only takes the level hash + var extraSongData = SongCore.Collections.RetrieveExtraSongData(hash); + if (extraSongData != null) + { + foreach (var difficultyData in extraSongData._difficulties) + { + if (difficultyData.additionalDifficultyData != null && + ((difficultyData.additionalDifficultyData._requirements.Contains("Noodle Extensions") && !Plugin.IsNoodleInstalled) || + (difficultyData.additionalDifficultyData._requirements.Contains("Mapping Extensions") && !Plugin.IsMappingInstalled))) + return Task.FromResult(EntitlementsStatus.NotOwned); + else if (difficultyData.additionalDifficultyData != null) + { + foreach (string requirement in difficultyData.additionalDifficultyData._requirements) Plugin.Log?.Info($"Requirement found: {requirement}"); + } + else Plugin.Log?.Debug("difficultyData.additionalDifficultyData is null"); + + } + } + else Plugin.Log?.Debug("extraSongData is null"); return Task.FromResult(EntitlementsStatus.Ok); + } return Plugin.BeatSaver.BeatmapByHash(hash).ContinueWith(r => { Beatmap? beatmap = r.Result; if (beatmap == null) return EntitlementsStatus.NotOwned; + else + { + foreach (var difficulty in beatmap.Versions[0].Difficulties) + { + if ((difficulty.NoodleExtensions && !Plugin.IsNoodleInstalled) || (difficulty.MappingExtensions && !Plugin.IsMappingInstalled)) return EntitlementsStatus.NotOwned; + } + } return EntitlementsStatus.NotDownloaded; }); } @@ -120,6 +149,7 @@ public async Task WaitForOkEntitlement(string userId, string levelId, Cancellati if (userDictionary.TryGetValue(levelId, out EntitlementsStatus entitlement) && entitlement == EntitlementsStatus.Ok) { UI.CenterScreenLoadingPanel.Instance.playersReady++; + Plugin.Log?.Info($"User '{userId}' for level '{levelId}' is '{entitlement}'"); return; } @@ -135,8 +165,9 @@ public async Task WaitForOkEntitlement(string userId, string levelId, Cancellati { result = await _tcsDictionary[userId][levelId].Task.ContinueWith(t => t.IsCompleted ? t.Result : EntitlementsStatus.Unknown); _tcsDictionary[userId][levelId] = new TaskCompletionSource(); - if (result == EntitlementsStatus.Ok) UI.CenterScreenLoadingPanel.Instance.playersReady++; } + if (!cancellationToken.IsCancellationRequested) UI.CenterScreenLoadingPanel.Instance.playersReady++; + Plugin.Log?.Info($"User '{userId}' for level '{levelId}' is '{result}' was task cancelled {(cancellationToken.IsCancellationRequested ? "true" : "false")}"); } } } diff --git a/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs b/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs index e69e037..e51c1fe 100644 --- a/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs +++ b/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs @@ -37,6 +37,10 @@ internal void Inject([InjectOptional] PacketManager packetManager, [InjectOption SetLocalPlayerState("modded", true); + SetLocalPlayerState("ME_Installed", Plugin.IsMappingInstalled); + SetLocalPlayerState("NE_Installed", Plugin.IsNoodleInstalled); + SetLocalPlayerState("Chroma_Installed", Plugin.IsChromaInstalled); + connectedEvent += HandleConnected; playerConnectedEvent += HandlePlayerConnected; diff --git a/MultiplayerExtensions/HarmonyPatches/InstallerPatches.cs b/MultiplayerExtensions/HarmonyPatches/InstallerPatches.cs index 41a0b30..9a237f9 100644 --- a/MultiplayerExtensions/HarmonyPatches/InstallerPatches.cs +++ b/MultiplayerExtensions/HarmonyPatches/InstallerPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using IPA.Utilities; using MultiplayerExtensions.Extensions; using System; using System.Collections.Generic; @@ -145,7 +146,7 @@ internal static void Prefix(ref GameplayCoreInstaller __instance, ref IConnected ____sceneSetupData = new GameplayCoreSceneSetupData( ____sceneSetupData.difficultyBeatmap, ____sceneSetupData.previewBeatmapLevel, - ____sceneSetupData.gameplayModifiers.CopyWith(zenMode: Plugin.Config.LagReducer), + ____sceneSetupData.gameplayModifiers.CopyWith(zenMode: (____sceneSetupData.gameplayModifiers.zenMode || Plugin.Config.LagReducer)), ____sceneSetupData.playerSpecificSettings, ____sceneSetupData.practiceSettings, ____sceneSetupData.useTestNoteCutSoundEffects, diff --git a/MultiplayerExtensions/Plugin.cs b/MultiplayerExtensions/Plugin.cs index a724b33..c66d177 100644 --- a/MultiplayerExtensions/Plugin.cs +++ b/MultiplayerExtensions/Plugin.cs @@ -28,7 +28,11 @@ public class Plugin internal static Plugin Instance { get; private set; } = null!; internal static PluginMetadata PluginMetadata = null!; - internal static Hive.Versioning.Version ProtocolVersion { get; } = new Hive.Versioning.Version("1.0.0"); + internal static bool IsNoodleInstalled { get; private set; } + internal static bool IsMappingInstalled { get; private set; } + internal static bool IsChromaInstalled { get; private set; } + + internal static Hive.Versioning.Version ProtocolVersion { get; } = new Hive.Versioning.Version("0.7.1"); internal static IPALogger Log { get; private set; } = null!; internal static PluginConfig Config = null!; @@ -84,6 +88,11 @@ public void OnApplicationStart() HarmonyManager.ApplyDefaultPatches(); Task versionTask = CheckVersion(); + + IsNoodleInstalled = IPA.Loader.PluginManager.IsEnabled(IPA.Loader.PluginManager.GetPluginFromId("NoodleExtensions")); + IsMappingInstalled = IPA.Loader.PluginManager.IsEnabled(IPA.Loader.PluginManager.GetPluginFromId("MappingExtensions")); + IsChromaInstalled = IPA.Loader.PluginManager.IsEnabled(IPA.Loader.PluginManager.GetPluginFromId("Chroma")); + MPEvents_Test(); Sprites.PreloadSprites(); diff --git a/MultiplayerExtensions/UI/CenterScreenLoadingPanel.cs b/MultiplayerExtensions/UI/CenterScreenLoadingPanel.cs index cddb249..832932b 100644 --- a/MultiplayerExtensions/UI/CenterScreenLoadingPanel.cs +++ b/MultiplayerExtensions/UI/CenterScreenLoadingPanel.cs @@ -71,7 +71,7 @@ public void Report(double value) isDownloading = (value < 1.0); if (loadingControl != null) { - loadingControl.ShowDownloadingProgress("Downloading...", (float)value); + loadingControl.ShowDownloadingProgress($"Downloading ({value * 100:F2}%)...", (float)value); } } } From f1046f8124137bfbfe2e8f3dfa9fe22d5dee6547 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sun, 14 Nov 2021 12:46:30 +0100 Subject: [PATCH 4/4] Small changes, remove unused code, allow for live color updating --- .../Extensions/ExtendedGameStateController.cs | 1 - .../Extensions/ExtendedSessionManager.cs | 7 ++++--- MultiplayerExtensions/Plugin.cs | 17 +---------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/MultiplayerExtensions/Extensions/ExtendedGameStateController.cs b/MultiplayerExtensions/Extensions/ExtendedGameStateController.cs index 5151155..010a5bf 100644 --- a/MultiplayerExtensions/Extensions/ExtendedGameStateController.cs +++ b/MultiplayerExtensions/Extensions/ExtendedGameStateController.cs @@ -94,7 +94,6 @@ public async override void HandleMultiplayerLevelLoaderCountdownFinished(IPrevie { if (_multiplayerLevelLoader.GetField("_loaderState") == MultiplayerLevelLoader.MultiplayerBeatmapLoaderState.NotLoading) { - Plugin.Log?.Info("HandleMultiplayerLevelLoaderCountdownFinished already running, returning"); return; } _multiplayerLevelLoader.SetField("_loaderState", MultiplayerLevelLoader.MultiplayerBeatmapLoaderState.NotLoading); diff --git a/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs b/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs index e51c1fe..33d61b0 100644 --- a/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs +++ b/MultiplayerExtensions/Extensions/ExtendedSessionManager.cs @@ -97,6 +97,7 @@ private void HandleExtendedPlayerPacket(ExtendedPlayerPacket packet, IConnectedP extendedPlayer.platform = packet.platform; extendedPlayer.playerColor = packet.playerColor; extendedPlayer.mpexVersion = new Hive.Versioning.Version(packet.mpexVersion); + extendedPlayerConnectedEvent?.Invoke(extendedPlayer); } else { @@ -106,9 +107,9 @@ private void HandleExtendedPlayerPacket(ExtendedPlayerPacket packet, IConnectedP if (Plugin.ProtocolVersion != extendedPlayer.mpexVersion) { Plugin.Log?.Warn("###################################################################"); - Plugin.Log?.Warn("Different MultiplayerExtensions version detected!"); - Plugin.Log?.Warn($"The player '{player.userName}' is using MultiplayerExtensions {extendedPlayer.mpexVersion} while you are using MultiplayerExtensions {Plugin.ProtocolVersion}"); - Plugin.Log?.Warn("For best compatibility all players should use the same version of MultiplayerExtensions."); + Plugin.Log?.Warn("Different MultiplayerExtensions protocol detected!"); + Plugin.Log?.Warn($"The player '{player.userName}' is using MpEx protocol version {extendedPlayer.mpexVersion} while you are using MpEx protocol {Plugin.ProtocolVersion}"); + Plugin.Log?.Warn("For best compatibility all players should use a compatible version of MultiplayerExtensions/MultiQuestensions."); Plugin.Log?.Warn("###################################################################"); } diff --git a/MultiplayerExtensions/Plugin.cs b/MultiplayerExtensions/Plugin.cs index c66d177..f45449c 100644 --- a/MultiplayerExtensions/Plugin.cs +++ b/MultiplayerExtensions/Plugin.cs @@ -3,20 +3,16 @@ using IPA.Config; using IPA.Config.Stores; using IPA.Loader; -using MultiplayerExtensions.HarmonyPatches; using MultiplayerExtensions.Installers; using SiraUtil.Zenject; using MultiplayerExtensions.Utilities; using System; -using System.Reflection; using System.Threading.Tasks; using IPALogger = IPA.Logging.Logger; using BeatSaverSharp; using System.Diagnostics; -using Zenject; using MultiplayerExtensions.UI; using BeatSaberMarkupLanguage.Settings; -using System.Net.Http; namespace MultiplayerExtensions { @@ -36,7 +32,6 @@ public class Plugin internal static IPALogger Log { get; private set; } = null!; internal static PluginConfig Config = null!; - internal static HttpClient HttpClient { get; private set; } = null!; internal static BeatSaver BeatSaver = null!; internal static Harmony? _harmony; internal static Harmony Harmony @@ -47,15 +42,6 @@ internal static Harmony Harmony } } - public static string UserAgent - { - get - { - var modVersion = PluginMetadata.Version.ToString(); - var bsVersion = IPA.Utilities.UnityGame.GameVersion.ToString(); - return $"MultiplayerExtensions/{modVersion} (BeatSaber/{bsVersion})"; - } - } private const int MaxPlayers = 100; private const int MinPlayers = 10; @@ -73,9 +59,8 @@ public Plugin(IPALogger logger, Config conf, Zenjector zenjector, PluginMetadata zenjector.OnGame().OnlyForMultiplayer(); BeatSaverOptions options = new BeatSaverOptions("MultiplayerExtensions", new Version(pluginMetadata.Version.ToString())); + options.Timeout = TimeSpan.FromMinutes(1); BeatSaver = new BeatSaver(options); - HttpClient = new HttpClient(); - HttpClient.DefaultRequestHeaders.Add("User-Agent", Plugin.UserAgent); } [OnStart]