From a02b4a3a5de25d69bbff2f1838e56134a6915dd3 Mon Sep 17 00:00:00 2001 From: goobwabber Date: Mon, 4 Jul 2022 19:32:53 -0400 Subject: [PATCH 01/34] fix max players being reset for main bt server --- BeatTogether/Config.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/BeatTogether/Config.cs b/BeatTogether/Config.cs index 85e57ea..323179a 100644 --- a/BeatTogether/Config.cs +++ b/BeatTogether/Config.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using BeatTogether.Models; using IPA.Config.Stores.Attributes; using IPA.Config.Stores.Converters; @@ -14,7 +15,7 @@ public class Config public const string BeatTogetherServerName = "BeatTogether"; public const string BeatTogetherHostName = "master.beattogether.systems"; public const string BeatTogetherStatusUri = "http://master.beattogether.systems/status"; - public const int BeatTogetherMaxPartySize = 10; + public const int BeatTogetherMaxPartySize = 100; public virtual string SelectedServer { get; set; } = BeatTogetherServerName; @@ -23,15 +24,14 @@ public class Config public virtual void OnReload() { - Servers.RemoveAll(server => - server.ServerName == BeatTogetherServerName); - Servers.Insert(0, new ServerDetails - { - ServerName = BeatTogetherServerName, - HostName = BeatTogetherHostName, - StatusUri = BeatTogetherStatusUri, - MaxPartySize = BeatTogetherMaxPartySize - }); + if (Servers.All(server => server.ServerName != BeatTogetherServerName)) + Servers.Insert(0, new ServerDetails + { + ServerName = BeatTogetherServerName, + HostName = BeatTogetherHostName, + StatusUri = BeatTogetherStatusUri, + MaxPartySize = BeatTogetherMaxPartySize + }); } public virtual void CopyFrom(Config other) From ef0171bca7d2a33a652d2efdcaae7ea2e3ae0d22 Mon Sep 17 00:00:00 2001 From: goobwabber Date: Tue, 5 Jul 2022 00:18:21 -0400 Subject: [PATCH 02/34] format file --- BeatTogether/UI/ServerSelectionController.cs | 518 +++++++++---------- 1 file changed, 259 insertions(+), 259 deletions(-) diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 76b6358..37bcaf4 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -1,262 +1,262 @@ -using BeatSaberMarkupLanguage; -using BeatSaberMarkupLanguage.Attributes; -using BeatSaberMarkupLanguage.Components.Settings; -using BeatSaberMarkupLanguage.FloatingScreen; -using BeatTogether.Models; -using BeatTogether.Registries; -using HMUI; -using IPA.Utilities; -using MultiplayerCore.Patchers; -using Polyglot; -using SiraUtil.Affinity; -using SiraUtil.Logging; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using JetBrains.Annotations; -using UnityEngine; -using Zenject; +using BeatSaberMarkupLanguage; +using BeatSaberMarkupLanguage.Attributes; +using BeatSaberMarkupLanguage.Components.Settings; +using BeatSaberMarkupLanguage.FloatingScreen; +using BeatTogether.Models; +using BeatTogether.Registries; +using HMUI; +using IPA.Utilities; +using MultiplayerCore.Patchers; +using Polyglot; +using SiraUtil.Affinity; +using SiraUtil.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using JetBrains.Annotations; +using UnityEngine; +using Zenject; using System.Threading; -namespace BeatTogether.UI -{ - internal class ServerSelectionController : IInitializable, IAffinity, INotifyPropertyChanged - { - public const string ResourcePath = "BeatTogether.UI.ServerSelectionController.bsml"; - - private Action _didActivate - = MethodAccessor> - .GetDelegate("DidActivate"); - - private Action _didDeactivate - = MethodAccessor> - .GetDelegate("DidDeactivate"); - - private Action _replaceTopScreenViewController - = MethodAccessor> - .GetDelegate("ReplaceTopViewController"); - - private FieldAccessor.Accessor _cancellationTokenSource - = FieldAccessor.GetAccessor(nameof(_cancellationTokenSource)); - - private FloatingScreen _screen = null!; - - private MultiplayerModeSelectionFlowCoordinator _modeSelectionFlow; - private readonly JoiningLobbyViewController _joiningLobbyView; - private readonly NetworkConfigPatcher _networkConfig; - private readonly ServerDetailsRegistry _serverRegistry; - private readonly SiraLog _logger; - - [UIComponent("server-list")] private ListSetting _serverList = null!; - - [UIValue("server")] - private ServerDetails _serverValue - { - get => _serverRegistry.SelectedServer; - set => ServerChanged(value); - } - - [UIValue("server-options")] private List _serverOptions; - - internal ServerSelectionController( - MultiplayerModeSelectionFlowCoordinator modeSelectionFlow, - JoiningLobbyViewController joiningLobbyView, - NetworkConfigPatcher networkConfig, - ServerDetailsRegistry serverRegistry, - SiraLog logger) - { - _modeSelectionFlow = modeSelectionFlow; - _joiningLobbyView = joiningLobbyView; - _networkConfig = networkConfig; - _serverRegistry = serverRegistry; - _logger = logger; - - _serverOptions = new(_serverRegistry.Servers); - } - - public void Initialize() - { - _screen = FloatingScreen.CreateFloatingScreen(new Vector2(90, 90), false, new Vector3(0, 3f, 4.35f), - new Quaternion(0, 0, 0, 0)); - BSMLParser.instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), ResourcePath), - _screen.gameObject, this); - (_serverList.gameObject.transform.GetChild(1) as RectTransform)!.sizeDelta = new Vector2(60, 0); - _screen.GetComponent().SetRadius(140); - _screen.gameObject.SetActive(false); - } - - private void ServerChanged(ServerDetails server) - { - if (server is TemporaryServerDetails) - return; - - _logger.Debug($"Server changed to '{server.ServerName}': '{server.HostName}:{server.Port}'"); - _serverRegistry.SetSelectedServer(server); - if (server.IsOfficial) - _networkConfig.UseOfficialServer(); - else - _networkConfig.UseMasterServer(server.EndPoint!, server.StatusUri, server.MaxPartySize); - - SyncTemporarySelectedServer(); - - SetInteraction(false); - //_cancellationTokenSource(ref _modeSelectionFlow) = new CancellationTokenSource(); - _didDeactivate(_modeSelectionFlow, false, false); - _didActivate(_modeSelectionFlow, false, true, false); - _replaceTopScreenViewController(_modeSelectionFlow, _joiningLobbyView, HandleTransitionFinished, - ViewController.AnimationType.None, ViewController.AnimationDirection.Vertical); - } - - private void HandleTransitionFinished() - { - } - //=> SetInteraction(true); - - [AffinityPrefix] - [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "DidActivate")] - private void DidActivate() - { - SyncSelectedServer(); - } - - private void SyncSelectedServer() - { - var didChangeSelection = false; - - if (_networkConfig.MasterServerEndPoint is not null) - { - // Master server is being patched by MpCore, sync our selection - var knownServer = _serverRegistry.Servers.FirstOrDefault( - sd => sd.EndPoint?.Equals(_networkConfig.MasterServerEndPoint) ?? false - ); - - if (knownServer != _serverRegistry.SelectedServer) - { - _logger.Info("Changing server selection from patch sync!"); - _serverRegistry.SetSelectedServer(knownServer - ?? new TemporaryServerDetails(_networkConfig.MasterServerEndPoint)); - didChangeSelection = true; - } - } - else - { - // No one is patching the master server, restore our selected server from config - if (_serverRegistry.SelectedServer.IsOfficial) - _networkConfig.UseOfficialServer(); - else - _networkConfig.UseMasterServer(_serverRegistry.SelectedServer.EndPoint!, - _serverRegistry.SelectedServer.StatusUri, _serverRegistry.SelectedServer.MaxPartySize); - } - - // Sync UI - if (didChangeSelection) - { - SyncTemporarySelectedServer(); - OnPropertyChanged(nameof(_serverValue)); // for BSML binding - } - - _screen.gameObject.SetActive(true); - } - - private void SyncTemporarySelectedServer() - { - var didChange = false; - - if (_serverRegistry.TemporarySelectedServer is not null) - { - var temporaryServer = _serverRegistry.TemporarySelectedServer!; - - if (!_serverOptions.Contains(temporaryServer)) - { - _serverOptions.Add(temporaryServer); - didChange = true; - } - } - else - { - if (_serverOptions.RemoveAll(so => so is TemporaryServerDetails) > 0) - didChange = true; - } - - if (didChange) - OnPropertyChanged(nameof(_serverOptions)); // for BSML binding - } - - [AffinityPrefix] - [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "DidDeactivate")] - private void DidDeactivate(bool removedFromHierarchy) - { - _screen.gameObject.SetActive(false); - if (removedFromHierarchy) - _networkConfig.UseOfficialServer(); - } - - [AffinityPrefix] - [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "TopViewControllerWillChange")] - private bool TopViewControllerWillChange(ViewController oldViewController, ViewController newViewController, - ViewController.AnimationType animationType) - { - if (oldViewController is MultiplayerModeSelectionViewController) - SetInteraction(false); - if (newViewController is MultiplayerModeSelectionViewController) - SetInteraction(true); - if (newViewController is JoiningLobbyViewController && animationType == ViewController.AnimationType.None) - return false; - return true; - } - - [AffinityPrefix] - [AffinityPatch(typeof(ViewControllerTransitionHelpers), - nameof(ViewControllerTransitionHelpers.DoPresentTransition))] - private void DoPresentTransition(ViewController toPresentViewController, ViewController toDismissViewController, - ref ViewController.AnimationDirection animationDirection) - { - if (toDismissViewController is JoiningLobbyViewController) - animationDirection = ViewController.AnimationDirection.Vertical; - } - - [AffinityPrefix] - [AffinityPatch(typeof(FlowCoordinator), "SetTitle")] - private void SetTitle(ref string value, ref string ____title) - { - if (value == Localization.Get("LABEL_CHECKING_SERVER_STATUS")) - value = Localization.Get("LABEL_MULTIPLAYER_MODE_SELECTION"); - if (____title == Localization.Get("LABEL_CHECKING_SERVER_STATUS") && value == "") - SetInteraction(true); - } - - private bool _interactable = true; - private bool _globalInteraction = true; - - private void SetInteraction(bool value) - { - _interactable = value; - _serverList.interactable = _interactable && _globalInteraction; - } - - [AffinityPrefix] - [AffinityPatch(typeof(FlowCoordinator), "SetGlobalUserInteraction")] - private void SetGlobalUserInteraction(bool value) - { - _globalInteraction = value; - _serverList.interactable = _interactable && _globalInteraction; - } - - #region INotifyPropertyChanged - - public event PropertyChangedEventHandler? PropertyChanged; - - [NotifyPropertyChangedInvocator] - protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - - #endregion - } +namespace BeatTogether.UI +{ + internal class ServerSelectionController : IInitializable, IAffinity, INotifyPropertyChanged + { + public const string ResourcePath = "BeatTogether.UI.ServerSelectionController.bsml"; + + private Action _didActivate + = MethodAccessor> + .GetDelegate("DidActivate"); + + private Action _didDeactivate + = MethodAccessor> + .GetDelegate("DidDeactivate"); + + private Action _replaceTopScreenViewController + = MethodAccessor> + .GetDelegate("ReplaceTopViewController"); + + private FieldAccessor.Accessor _cancellationTokenSource + = FieldAccessor.GetAccessor(nameof(_cancellationTokenSource)); + + private FloatingScreen _screen = null!; + + private MultiplayerModeSelectionFlowCoordinator _modeSelectionFlow; + private readonly JoiningLobbyViewController _joiningLobbyView; + private readonly NetworkConfigPatcher _networkConfig; + private readonly ServerDetailsRegistry _serverRegistry; + private readonly SiraLog _logger; + + [UIComponent("server-list")] private ListSetting _serverList = null!; + + [UIValue("server")] + private ServerDetails _serverValue + { + get => _serverRegistry.SelectedServer; + set => ServerChanged(value); + } + + [UIValue("server-options")] private List _serverOptions; + + internal ServerSelectionController( + MultiplayerModeSelectionFlowCoordinator modeSelectionFlow, + JoiningLobbyViewController joiningLobbyView, + NetworkConfigPatcher networkConfig, + ServerDetailsRegistry serverRegistry, + SiraLog logger) + { + _modeSelectionFlow = modeSelectionFlow; + _joiningLobbyView = joiningLobbyView; + _networkConfig = networkConfig; + _serverRegistry = serverRegistry; + _logger = logger; + + _serverOptions = new(_serverRegistry.Servers); + } + + public void Initialize() + { + _screen = FloatingScreen.CreateFloatingScreen(new Vector2(90, 90), false, new Vector3(0, 3f, 4.35f), + new Quaternion(0, 0, 0, 0)); + BSMLParser.instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), ResourcePath), + _screen.gameObject, this); + (_serverList.gameObject.transform.GetChild(1) as RectTransform)!.sizeDelta = new Vector2(60, 0); + _screen.GetComponent().SetRadius(140); + _screen.gameObject.SetActive(false); + } + + private void ServerChanged(ServerDetails server) + { + if (server is TemporaryServerDetails) + return; + + _logger.Debug($"Server changed to '{server.ServerName}': '{server.HostName}:{server.Port}'"); + _serverRegistry.SetSelectedServer(server); + if (server.IsOfficial) + _networkConfig.UseOfficialServer(); + else + _networkConfig.UseMasterServer(server.EndPoint!, server.StatusUri, server.MaxPartySize); + + SyncTemporarySelectedServer(); + + SetInteraction(false); + //_cancellationTokenSource(ref _modeSelectionFlow) = new CancellationTokenSource(); + _didDeactivate(_modeSelectionFlow, false, false); + _didActivate(_modeSelectionFlow, false, true, false); + _replaceTopScreenViewController(_modeSelectionFlow, _joiningLobbyView, HandleTransitionFinished, + ViewController.AnimationType.None, ViewController.AnimationDirection.Vertical); + } + + private void HandleTransitionFinished() + { + } + //=> SetInteraction(true); + + [AffinityPrefix] + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "DidActivate")] + private void DidActivate() + { + SyncSelectedServer(); + } + + private void SyncSelectedServer() + { + var didChangeSelection = false; + + if (_networkConfig.MasterServerEndPoint is not null) + { + // Master server is being patched by MpCore, sync our selection + var knownServer = _serverRegistry.Servers.FirstOrDefault( + sd => sd.EndPoint?.Equals(_networkConfig.MasterServerEndPoint) ?? false + ); + + if (knownServer != _serverRegistry.SelectedServer) + { + _logger.Info("Changing server selection from patch sync!"); + _serverRegistry.SetSelectedServer(knownServer + ?? new TemporaryServerDetails(_networkConfig.MasterServerEndPoint)); + didChangeSelection = true; + } + } + else + { + // No one is patching the master server, restore our selected server from config + if (_serverRegistry.SelectedServer.IsOfficial) + _networkConfig.UseOfficialServer(); + else + _networkConfig.UseMasterServer(_serverRegistry.SelectedServer.EndPoint!, + _serverRegistry.SelectedServer.StatusUri, _serverRegistry.SelectedServer.MaxPartySize); + } + + // Sync UI + if (didChangeSelection) + { + SyncTemporarySelectedServer(); + OnPropertyChanged(nameof(_serverValue)); // for BSML binding + } + + _screen.gameObject.SetActive(true); + } + + private void SyncTemporarySelectedServer() + { + var didChange = false; + + if (_serverRegistry.TemporarySelectedServer is not null) + { + var temporaryServer = _serverRegistry.TemporarySelectedServer!; + + if (!_serverOptions.Contains(temporaryServer)) + { + _serverOptions.Add(temporaryServer); + didChange = true; + } + } + else + { + if (_serverOptions.RemoveAll(so => so is TemporaryServerDetails) > 0) + didChange = true; + } + + if (didChange) + OnPropertyChanged(nameof(_serverOptions)); // for BSML binding + } + + [AffinityPrefix] + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "DidDeactivate")] + private void DidDeactivate(bool removedFromHierarchy) + { + _screen.gameObject.SetActive(false); + if (removedFromHierarchy) + _networkConfig.UseOfficialServer(); + } + + [AffinityPrefix] + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "TopViewControllerWillChange")] + private bool TopViewControllerWillChange(ViewController oldViewController, ViewController newViewController, + ViewController.AnimationType animationType) + { + if (oldViewController is MultiplayerModeSelectionViewController) + SetInteraction(false); + if (newViewController is MultiplayerModeSelectionViewController) + SetInteraction(true); + if (newViewController is JoiningLobbyViewController && animationType == ViewController.AnimationType.None) + return false; + return true; + } + + [AffinityPrefix] + [AffinityPatch(typeof(ViewControllerTransitionHelpers), + nameof(ViewControllerTransitionHelpers.DoPresentTransition))] + private void DoPresentTransition(ViewController toPresentViewController, ViewController toDismissViewController, + ref ViewController.AnimationDirection animationDirection) + { + if (toDismissViewController is JoiningLobbyViewController) + animationDirection = ViewController.AnimationDirection.Vertical; + } + + [AffinityPrefix] + [AffinityPatch(typeof(FlowCoordinator), "SetTitle")] + private void SetTitle(ref string value, ref string ____title) + { + if (value == Localization.Get("LABEL_CHECKING_SERVER_STATUS")) + value = Localization.Get("LABEL_MULTIPLAYER_MODE_SELECTION"); + if (____title == Localization.Get("LABEL_CHECKING_SERVER_STATUS") && value == "") + SetInteraction(true); + } + + private bool _interactable = true; + private bool _globalInteraction = true; + + private void SetInteraction(bool value) + { + _interactable = value; + _serverList.interactable = _interactable && _globalInteraction; + } + + [AffinityPrefix] + [AffinityPatch(typeof(FlowCoordinator), "SetGlobalUserInteraction")] + private void SetGlobalUserInteraction(bool value) + { + _globalInteraction = value; + _serverList.interactable = _interactable && _globalInteraction; + } + + #region INotifyPropertyChanged + + public event PropertyChangedEventHandler? PropertyChanged; + + [NotifyPropertyChangedInvocator] + protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + #endregion + } } \ No newline at end of file From 955af99daa98c17fdfb7a1d77d78a265a2df23c1 Mon Sep 17 00:00:00 2001 From: goobwabber Date: Thu, 21 Jul 2022 09:05:49 -0400 Subject: [PATCH 03/34] remove old code i forgor --- .../MasterServerQuickPlaySetupModelPatch.cs | 45 ---------- ...playerModeSelectionFlowCoordinatorPatch.cs | 85 ------------------- Patches/QuickPlaySongPacksDropdownPatch.cs | 83 ------------------ Providers/ModStatusProvider.cs | 22 ----- 4 files changed, 235 deletions(-) delete mode 100644 Patches/MasterServerQuickPlaySetupModelPatch.cs delete mode 100644 Patches/MultiplayerModeSelectionFlowCoordinatorPatch.cs delete mode 100644 Patches/QuickPlaySongPacksDropdownPatch.cs delete mode 100644 Providers/ModStatusProvider.cs diff --git a/Patches/MasterServerQuickPlaySetupModelPatch.cs b/Patches/MasterServerQuickPlaySetupModelPatch.cs deleted file mode 100644 index 894c222..0000000 --- a/Patches/MasterServerQuickPlaySetupModelPatch.cs +++ /dev/null @@ -1,45 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using IPA.Loader; -using BeatTogether.Providers; - -namespace BeatTogether.Patches -{ - [HarmonyPatch(typeof(MasterServerQuickPlaySetupModel), "Init")] - class MasterServerQuickPlaySetupModelInitPatch - { - internal static void Postfix(MasterServerQuickPlaySetupModel __instance) - { - GameClassInstanceProvider.Instance.MasterServerQuickPlaySetupModel = __instance; - } - } - - // TODO: Should probably check if the server was switched or not, for now we just always return false - [HarmonyPatch(typeof(MasterServerQuickPlaySetupModel), "IsQuickPlaySetupTaskValid")] - class IsQuickPlaySetupTaskValidPatch - { - internal static void Postfix(MasterServerQuickPlaySetupModel __instance, ref bool __result, ref Task ____request) - { - ____request = null; - __result = false; - } - } - - [HarmonyPatch(typeof(MasterServerQuickPlaySetupModel), "GetQuickPlaySetupAsync")] - class GetQuickPlaySetupAsyncPatch - { - internal static void Postfix(MasterServerQuickPlaySetupModel __instance, ref Task __result, ref Task ____request) - { - if (ModStatusProvider.ShouldBlockSongPackOverrides) - { - __result = new Task(null); - } - - } - } - -} diff --git a/Patches/MultiplayerModeSelectionFlowCoordinatorPatch.cs b/Patches/MultiplayerModeSelectionFlowCoordinatorPatch.cs deleted file mode 100644 index 496177e..0000000 --- a/Patches/MultiplayerModeSelectionFlowCoordinatorPatch.cs +++ /dev/null @@ -1,85 +0,0 @@ -using BeatTogether.Providers; -using HarmonyLib; -using HMUI; -using IPA.Utilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using QPSPDP = BeatTogether.Patches.QuickPlaySongPacksDropdownPatch; - -namespace BeatTogether.Patches -{ - [HarmonyPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "DidActivate")] - class MultiplayerModeSelectionFlowCoordinatorDidActivatePatch - { - internal static void Prefix(MultiplayerModeSelectionFlowCoordinator __instance, JoiningLobbyViewController ____joiningLobbyViewController, JoinQuickPlayViewController ____joinQuickPlayViewController) - { - GameClassInstanceProvider classInstanceProvider = GameClassInstanceProvider.Instance; - classInstanceProvider.MultiplayerModeSelectionFlowCoordinator = __instance; - classInstanceProvider.JoinQuickPlayViewController = ____joinQuickPlayViewController; - classInstanceProvider.JoiningLobbyViewController = ____joiningLobbyViewController; - } - - } - - //[HarmonyPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "HandleMultiplayerLobbyControllerDidFinish")] - //class MultiplayerModeSelectionFlowCoordinatorPatch - //{ - // internal static bool isWaitingForPacks = false; - // internal static bool Prefix(MultiplayerModeSelectionFlowCoordinator __instance, MultiplayerModeSelectionViewController viewController, MultiplayerModeSelectionViewController.MenuButton menuButton, JoiningLobbyViewController ____joiningLobbyViewController, JoinQuickPlayViewController ____joinQuickPlayViewController) - // { - // if (menuButton == MultiplayerModeSelectionViewController.MenuButton.QuickPlay && QPSPDP.TaskState == QPSPDP.TaskStateEnum.Running) - // { - // ____joiningLobbyViewController.Init("Loading Quickplay Pack Overrides"); - // ____joiningLobbyViewController.didCancelEvent += OnDidCancelEvent; - // //__instance.InvokeMethod("ReplaceTopViewController", new object[] { - // // ____joiningLobbyViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical}); - // __instance.InvokeMethod("PresentViewController", new object[] { - // ____joiningLobbyViewController, null, ViewController.AnimationDirection.Vertical, false}); - // isWaitingForPacks = true; - // ShowQuickPlayLobbyScreenIfWaiting(); - // return false; - // } else - // { - // isWaitingForPacks = false; - // return true; - // } - // } - - // internal static void OnDidCancelEvent() - // { - // GameClassInstanceProvider classInstanceProvider = GameClassInstanceProvider.Instance; - // //classInstanceProvider.JoinQuickPlayViewController.gameObject.SetActive(true); - // //classInstanceProvider.MultiplayerModeSelectionFlowCoordinator.InvokeMethod("DismissViewController", new object[] { - // // classInstanceProvider.JoiningLobbyViewController, ViewController.AnimationDirection.Vertical, null, false}); - // classInstanceProvider.MultiplayerModeSelectionFlowCoordinator.InvokeMethod("PresentViewController", new object[] { - // classInstanceProvider.MultiplayerModeSelectionViewController, null, ViewController.AnimationDirection.Vertical, false}); - // //classInstanceProvider.MultiplayerModeSelectionFlowCoordinator.InvokeMethod("ReplaceTopViewController", new object[] { - // // classInstanceProvider.MultiplayerModeSelectionViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical}); - - - // classInstanceProvider.JoiningLobbyViewController.didCancelEvent -= OnDidCancelEvent; - // } - - // public static void ShowQuickPlayLobbyScreenIfWaiting() - // { - // GameClassInstanceProvider classInstanceProvider = GameClassInstanceProvider.Instance; - // MultiplayerModeSelectionFlowCoordinator instance = classInstanceProvider.MultiplayerModeSelectionFlowCoordinator; - // if (isWaitingForPacks && instance != null && classInstanceProvider.JoinQuickPlayViewController != null && QPSPDP.TaskState != QPSPDP.TaskStateEnum.Running) - // { - // classInstanceProvider.JoinQuickPlayViewController.Setup( - // ReflectionUtil.GetField(instance, "_masterServerQuickPlaySetupData"), - // ReflectionUtil.GetField(instance, "_playerDataModel").playerData.multiplayerModeSettings); - // instance.InvokeMethod("PresentViewController", new object[] { - // classInstanceProvider.JoinQuickPlayViewController, null, ViewController.AnimationDirection.Vertical, false}); - // } - // else - // { - // Plugin.Logger.Debug($"isWaitingForPacks: {(isWaitingForPacks ? "true" : "false")}, QPSPDP.TaskState: {(QPSPDP.TaskState)}"); - // } - // } - - //} -} diff --git a/Patches/QuickPlaySongPacksDropdownPatch.cs b/Patches/QuickPlaySongPacksDropdownPatch.cs deleted file mode 100644 index 10d21cf..0000000 --- a/Patches/QuickPlaySongPacksDropdownPatch.cs +++ /dev/null @@ -1,83 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using IPA.Utilities; -using BeatTogether.Providers; -using System.Threading; -// TODO: Add some sort of loadingScreen while it checks SongPackOverrides -namespace BeatTogether.Patches -{ - [HarmonyPatch(typeof(QuickPlaySongPacksDropdown), "Start")] - internal class QuickPlaySongPacksDropdownPatch - { - public enum TaskStateEnum - { - Unknown, Finished, Running, Failed - } - public static TaskStateEnum TaskState { get; private set; } = TaskStateEnum.Unknown; - private static CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); - internal static void Prefix(QuickPlaySongPacksDropdown __instance) - { - GameClassInstanceProvider.Instance.QuickPlaySongPacksDropdown = __instance; - } - - public static void UpdateSongPacks() - { - if (cancellationTokenSource.Token.CanBeCanceled) cancellationTokenSource.Cancel(); - cancellationTokenSource = new CancellationTokenSource(); - QuickPlaySongPacksDropdown instance = GameClassInstanceProvider.Instance.QuickPlaySongPacksDropdown; - if (instance != null) - instance.SetField("_quickPlaySongPacksOverride", null); - if (ModStatusProvider.ShouldBlockSongPackOverrides) - { - Plugin.Logger.Info("MultiplayerExtensions not installed, not overriding packs"); - return; - } - TaskState = TaskStateEnum.Running; - System.Threading.Tasks.Task.Run(async () => - { - try - { - Plugin.Logger.Info("Get QuickPlaySongPacksOverride"); - var quickPlaySetupData = await GameClassInstanceProvider.Instance.MasterServerQuickPlaySetupModel.GetQuickPlaySetupAsync(cancellationTokenSource.Token); - return quickPlaySetupData.quickPlayAvailablePacksOverride; - } - catch (Exception) - { - Plugin.Logger.Warn("Could not get QuickPlaySongPacksOverride"); - TaskState = TaskStateEnum.Failed; - return null; - } - }).ContinueWith(r => - { - Plugin.Logger.Debug("ContinueWith running for quickplaySongPackOverrides"); - if (instance != null) - { - instance.SetField("_quickPlaySongPacksOverride", r.Result); - instance.SetField("_initialized", false); - } - if (TaskState == TaskStateEnum.Running) TaskState = TaskStateEnum.Finished; - //MultiplayerModeSelectionFlowCoordinatorPatch.ShowQuickPlayLobbyScreenIfWaiting(); - //GameClassInstanceProvider.Instance.QuickPlaySongPacksDropdown.LazyInit(); - } - ); - } - } - - [HarmonyPatch(typeof(QuickPlaySongPacksDropdown), "LazyInit")] - class QuickPlaySongPacksDropdownLazyInitPatch - { - internal static void Prefix(QuickPlaySongPacksDropdown __instance, ref MasterServerQuickPlaySetupData.QuickPlaySongPacksOverride ____quickPlaySongPacksOverride, ref bool ____initialized) - { - if (ModStatusProvider.ShouldBlockSongPackOverrides || QuickPlaySongPacksDropdownPatch.TaskState != QuickPlaySongPacksDropdownPatch.TaskStateEnum.Finished) - { - ____quickPlaySongPacksOverride = null; - ____initialized = false; - } - } - } - -} diff --git a/Providers/ModStatusProvider.cs b/Providers/ModStatusProvider.cs deleted file mode 100644 index 4a8f416..0000000 --- a/Providers/ModStatusProvider.cs +++ /dev/null @@ -1,22 +0,0 @@ -using IPA.Loader; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeatTogether.Providers -{ - internal class ModStatusProvider - { - public static bool ShouldBlockSongPackOverrides - { - get { - var pluginMetadata = PluginManager.GetPluginFromId("MultiplayerExtensions"); - bool valid = ((pluginMetadata == null || !PluginManager.IsEnabled(pluginMetadata)) && !Plugin.ServerDetailProvider.Selection.IsOfficial); - if (valid) Plugin.Logger.Info("On Official Servers or not modded with MpEx!"); - return valid; - } - } - } -} From a837f7d27417721c48b5a940c6dea441b1dc81b7 Mon Sep 17 00:00:00 2001 From: Goobwabber <47616186+Goobwabber@users.noreply.github.com> Date: Thu, 21 Jul 2022 09:15:53 -0400 Subject: [PATCH 04/34] Update manifest.json --- BeatTogether/manifest.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index 66e23df..93ba99f 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -3,14 +3,14 @@ "id": "BeatTogether", "name": "BeatTogether", "author": "Goobwabber", - "version": "2.0.0", + "version": "2.0.1", "description": "A multiplayer private server for the modding community. Supports crossplay between PC and Quest.", "gameVersion": "1.21.0", "dependsOn": { "BSIPA": "^4.2.0", "BeatSaberMarkupLanguage": "^1.5.0", - "SiraUtil": "^3.0.0", - "MultiplayerCore": "^1.0.0" + "SiraUtil": "^3.1.0", + "MultiplayerCore": "^1.1.1" }, "features": [] } From ce0b5105fcf2554c495af2d728b73c3e8b30c405 Mon Sep 17 00:00:00 2001 From: Goobwabber <47616186+Goobwabber@users.noreply.github.com> Date: Thu, 21 Jul 2022 09:24:42 -0400 Subject: [PATCH 05/34] Update BeatTogether.csproj --- BeatTogether/BeatTogether.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BeatTogether/BeatTogether.csproj b/BeatTogether/BeatTogether.csproj index dbb6bd9..15d788c 100644 --- a/BeatTogether/BeatTogether.csproj +++ b/BeatTogether/BeatTogether.csproj @@ -4,7 +4,7 @@ Library Properties BeatTogether - 2.0.0 + 2.0.1 net472 true portable @@ -139,4 +139,4 @@ - \ No newline at end of file + From 21f198ceec177fa80316d16fa9362412d9f0cfae Mon Sep 17 00:00:00 2001 From: Kevin Hammett Date: Thu, 21 Jul 2022 12:06:55 -0400 Subject: [PATCH 06/34] Remove Strikethrough --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 130b6cc..ea606c1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using Mo **Recommended Install:** -~~The easiest way to install is through [ModAssistant](https://github.com/Assistant/ModAssistant)!~~ Use our manual instructions below for now! +The easiest way to install is through [ModAssistant](https://github.com/Assistant/ModAssistant)! Use our manual instructions below for now! **Manual Install:** From 5109a1810a2ec61f764b8262a090f3c729dc3b3d Mon Sep 17 00:00:00 2001 From: Kevin Hammett Date: Thu, 21 Jul 2022 18:46:46 -0400 Subject: [PATCH 07/34] Forgot this part earlier --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea606c1..859f778 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using Mo **Recommended Install:** -The easiest way to install is through [ModAssistant](https://github.com/Assistant/ModAssistant)! Use our manual instructions below for now! +The easiest way to install is through [ModAssistant](https://github.com/Assistant/ModAssistant)! **Manual Install:** From 474f1327c38f8cbf8ff171b0cd1b03e900359989 Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Fri, 31 Mar 2023 15:39:14 +0200 Subject: [PATCH 08/34] wip(1.29): adapting for API overrides / new MpCore --- BeatTogether/Config.cs | 28 +++++--- BeatTogether/Models/ServerDetails.cs | 65 ++++++++++++++++++- BeatTogether/Models/TemporaryServerDetails.cs | 16 +++-- BeatTogether/UI/ServerSelectionController.cs | 13 ++-- 4 files changed, 100 insertions(+), 22 deletions(-) diff --git a/BeatTogether/Config.cs b/BeatTogether/Config.cs index 323179a..644d827 100644 --- a/BeatTogether/Config.cs +++ b/BeatTogether/Config.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Linq; +using System.Linq; using BeatTogether.Models; using IPA.Config.Stores.Attributes; using IPA.Config.Stores.Converters; @@ -16,22 +16,30 @@ public class Config public const string BeatTogetherHostName = "master.beattogether.systems"; public const string BeatTogetherStatusUri = "http://master.beattogether.systems/status"; public const int BeatTogetherMaxPartySize = 100; + public const int BeatTogetherApiPort = 80; + public const bool BeatTogetherApiSecure = false; public virtual string SelectedServer { get; set; } = BeatTogetherServerName; [NonNullable, UseConverter(typeof(CollectionConverter>))] - public virtual List Servers { get; set; } = new List(); + public virtual List Servers { get; set; } = new(); public virtual void OnReload() { - if (Servers.All(server => server.ServerName != BeatTogetherServerName)) - Servers.Insert(0, new ServerDetails - { - ServerName = BeatTogetherServerName, - HostName = BeatTogetherHostName, - StatusUri = BeatTogetherStatusUri, - MaxPartySize = BeatTogetherMaxPartySize - }); + var btServer = Servers.FirstOrDefault(server => server.ServerName == BeatTogetherServerName); + + if (btServer != null) + return; + + Servers.Insert(0, new ServerDetails + { + ServerName = BeatTogetherServerName, + HostName = BeatTogetherHostName, + StatusUri = BeatTogetherStatusUri, + MaxPartySize = BeatTogetherMaxPartySize, + ApiPort = BeatTogetherApiPort, + ApiSecure = BeatTogetherApiSecure + }); } public virtual void CopyFrom(Config other) diff --git a/BeatTogether/Models/ServerDetails.cs b/BeatTogether/Models/ServerDetails.cs index 8127ab9..06ebd68 100644 --- a/BeatTogether/Models/ServerDetails.cs +++ b/BeatTogether/Models/ServerDetails.cs @@ -1,16 +1,79 @@ -namespace BeatTogether.Models +using System; +using System.Security.Policy; + +namespace BeatTogether.Models { public class ServerDetails { + /// + /// Display name for UI + /// public string ServerName { get; set; } = string.Empty; + /// + /// Hostname for master server and API url + /// public string HostName { get; set; } = string.Empty; + /// + /// Port number for master/auth server + /// public int Port { get; set; } = 2328; + /// + /// Optional status check URL for the server + /// public string StatusUri { get; set; } = string.Empty; + /// + /// Max amount of players per instance + /// public int MaxPartySize { get; set; } = 5; + /// + /// HTTP port number for Graph API server + /// + public int ApiPort { get; set; } = 80; + /// + /// Whether Graph API requests should use HTTPS protocol + /// + public bool ApiSecure { get; set; } = false; public DnsEndPoint? EndPoint => string.IsNullOrEmpty(ServerName) ? null : new(HostName, Port); + + public string ApiUrl + { + get + { + var protocol = ApiSecure ? "https" : "http"; + return $"{protocol}://{HostName}:{ApiPort}"; + } + } + public bool IsOfficial => ServerName == Config.OfficialServerName; + /// + /// Gets whether this server matches against a given override URL. + /// Only checks whether the hostname and port match. + /// + public bool MatchesApiUrl(string? apiUrl) + { + if (string.IsNullOrEmpty(apiUrl)) + return false; + + Console.WriteLine(apiUrl); + + try + { + var urlParsed = new Uri(apiUrl); + + Console.WriteLine($"parsed.Host = {urlParsed.Host}"); + Console.WriteLine($"parsed.Port = {urlParsed.Port}"); + + return urlParsed.Host == HostName && urlParsed.Port == ApiPort; + } + catch (UriFormatException ex) + { + Console.WriteLine(ex.Message); + return false; + } + } + public override string ToString() => ServerName; } } diff --git a/BeatTogether/Models/TemporaryServerDetails.cs b/BeatTogether/Models/TemporaryServerDetails.cs index 697ee3a..443a5fe 100644 --- a/BeatTogether/Models/TemporaryServerDetails.cs +++ b/BeatTogether/Models/TemporaryServerDetails.cs @@ -1,14 +1,20 @@ -namespace BeatTogether.Models +using System; + +namespace BeatTogether.Models { public class TemporaryServerDetails : ServerDetails { - public TemporaryServerDetails(DnsEndPoint masterServerEndPoint) + public TemporaryServerDetails(string apiUrl, int masterServerPort) { - ServerName = masterServerEndPoint.hostName; - HostName = masterServerEndPoint.hostName; - Port = masterServerEndPoint.port; + var urlParsed = new Uri(apiUrl); + + ServerName = urlParsed.Host; + HostName = urlParsed.Host; + Port = masterServerPort; StatusUri = string.Empty; MaxPartySize = IsOfficial ? 5 : 128; + ApiPort = urlParsed.Port; + ApiSecure = urlParsed.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase); } } } \ No newline at end of file diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index f90ca4f..6391d3b 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -104,7 +104,7 @@ private void ApplySelectedServer(ServerDetails server) if (server.IsOfficial) _networkConfig.UseOfficialServer(); else - _networkConfig.UseMasterServer(server.EndPoint!, server.StatusUri, server.MaxPartySize); + _networkConfig.UseCustomApiServer(server.ApiUrl, server.StatusUri, server.MaxPartySize); SyncTemporarySelectedServer(); @@ -120,11 +120,11 @@ private void SyncSelectedServer() { ServerDetails selectedServer; - if (_networkConfig.MasterServerEndPoint is not null) + if (_networkConfig.IsOverridingApi) { // Master server is being patched by MpCore, sync our selection var knownServer = _serverRegistry.Servers.FirstOrDefault(serverDetails => - serverDetails.EndPoint?.Equals(_networkConfig.MasterServerEndPoint) ?? false); + serverDetails.MatchesApiUrl(_networkConfig.GraphUrl)); if (knownServer != null) { @@ -134,8 +134,9 @@ private void SyncSelectedServer() else { // Selected server is not in our config, set temporary value - _logger.Debug($"Setting temporary server details (MasterServerEndPoint={_networkConfig.MasterServerEndPoint})"); - selectedServer = new TemporaryServerDetails(_networkConfig.MasterServerEndPoint); + // TODO + _logger.Error($"Server not in config // TODO // not supported right now"); + return; } } else @@ -188,7 +189,7 @@ private void DidActivate() if (_serverRegistry.SelectedServer.IsOfficial) _networkConfig.UseOfficialServer(); else - _networkConfig.UseMasterServer(_serverRegistry.SelectedServer.EndPoint!, + _networkConfig.UseCustomApiServer(_serverRegistry.SelectedServer.ApiUrl, _serverRegistry.SelectedServer.StatusUri, _serverRegistry.SelectedServer.MaxPartySize); _isFirstActivation = false; From fa0247510959eeae9dea3bb4d27b8ec4d734856a Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Fri, 31 Mar 2023 15:42:13 +0200 Subject: [PATCH 09/34] wip(1.29): bump & clarify supported versions --- BeatTogether/manifest.json | 4 ++-- README.md | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index 93ba99f..205687e 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -3,9 +3,9 @@ "id": "BeatTogether", "name": "BeatTogether", "author": "Goobwabber", - "version": "2.0.1", + "version": "2.1.0", "description": "A multiplayer private server for the modding community. Supports crossplay between PC and Quest.", - "gameVersion": "1.21.0", + "gameVersion": "1.29.0", "dependsOn": { "BSIPA": "^4.2.0", "BeatSaberMarkupLanguage": "^1.5.0", diff --git a/README.md b/README.md index 859f778..7ecf63b 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,13 @@ Want to support development and server costs? [Click Here](https://www.patreon.c * 10 Player lobbies ## Requirements -These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using Mod Assistant. +This version supports Beat Saber 1.29+ with mods: + * BSIPA v4.1.4+ * BeatSaberMarkupLanguage v1.6.6+ -* [MultiplayerCore v1.0.0+](https://github.com/Goobwabber/MultiplayerCore#installation) +* [MultiplayerCore v1.3.0+](https://github.com/Goobwabber/MultiplayerCore#installation) + +These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using Mod Assistant. ## Installation From a334ab861737f5e14a36cf6aedbe0640ebb1fe2c Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Fri, 31 Mar 2023 17:07:44 +0200 Subject: [PATCH 10/34] wip(1.29): better API url config, auto migrate old configs --- BeatTogether/Config.cs | 37 ++++++++++------ BeatTogether/Models/ServerDetails.cs | 44 ++++++------------- BeatTogether/Models/TemporaryServerDetails.cs | 19 +++++--- BeatTogether/UI/ServerSelectionController.cs | 2 +- 4 files changed, 50 insertions(+), 52 deletions(-) diff --git a/BeatTogether/Config.cs b/BeatTogether/Config.cs index 644d827..06ea8e2 100644 --- a/BeatTogether/Config.cs +++ b/BeatTogether/Config.cs @@ -12,12 +12,12 @@ public class Config public const string OfficialServerName = "Official Servers"; // BeatTogether master server config + public const int DefaultApiPort = 8989; public const string BeatTogetherServerName = "BeatTogether"; public const string BeatTogetherHostName = "master.beattogether.systems"; + public const string BeatTogetherApiUri = "http://master.beattogether.systems:8989"; public const string BeatTogetherStatusUri = "http://master.beattogether.systems/status"; public const int BeatTogetherMaxPartySize = 100; - public const int BeatTogetherApiPort = 80; - public const bool BeatTogetherApiSecure = false; public virtual string SelectedServer { get; set; } = BeatTogetherServerName; @@ -26,20 +26,29 @@ public class Config public virtual void OnReload() { - var btServer = Servers.FirstOrDefault(server => server.ServerName == BeatTogetherServerName); - - if (btServer != null) - return; + var haveBtServer = false; - Servers.Insert(0, new ServerDetails + foreach (var server in Servers) + { + if (server.ServerName == BeatTogetherServerName) + haveBtServer = true; + + // Try to auto migrate API URL if missing from older configs + if (string.IsNullOrEmpty(server.ApiUrl)) + server.ApiUrl = $"http://{server.HostName}:{DefaultApiPort}"; + } + + if (!haveBtServer) { - ServerName = BeatTogetherServerName, - HostName = BeatTogetherHostName, - StatusUri = BeatTogetherStatusUri, - MaxPartySize = BeatTogetherMaxPartySize, - ApiPort = BeatTogetherApiPort, - ApiSecure = BeatTogetherApiSecure - }); + Servers.Insert(0, new ServerDetails + { + ServerName = BeatTogetherServerName, + HostName = BeatTogetherHostName, + ApiUrl = BeatTogetherApiUri, + StatusUri = BeatTogetherStatusUri, + MaxPartySize = BeatTogetherMaxPartySize + }); + } } public virtual void CopyFrom(Config other) diff --git a/BeatTogether/Models/ServerDetails.cs b/BeatTogether/Models/ServerDetails.cs index 06ebd68..1e1deb1 100644 --- a/BeatTogether/Models/ServerDetails.cs +++ b/BeatTogether/Models/ServerDetails.cs @@ -10,13 +10,13 @@ public class ServerDetails /// public string ServerName { get; set; } = string.Empty; /// - /// Hostname for master server and API url + /// Legacy hostname for master server (no longer used, except for automatic config migrations) /// public string HostName { get; set; } = string.Empty; /// - /// Port number for master/auth server + /// The multiplayer API url / graph url /// - public int Port { get; set; } = 2328; + public string ApiUrl { get; set; } = string.Empty; /// /// Optional status check URL for the server /// @@ -25,26 +25,7 @@ public class ServerDetails /// Max amount of players per instance /// public int MaxPartySize { get; set; } = 5; - /// - /// HTTP port number for Graph API server - /// - public int ApiPort { get; set; } = 80; - /// - /// Whether Graph API requests should use HTTPS protocol - /// - public bool ApiSecure { get; set; } = false; - - public DnsEndPoint? EndPoint => string.IsNullOrEmpty(ServerName) ? null : new(HostName, Port); - public string ApiUrl - { - get - { - var protocol = ApiSecure ? "https" : "http"; - return $"{protocol}://{HostName}:{ApiPort}"; - } - } - public bool IsOfficial => ServerName == Config.OfficialServerName; /// @@ -53,23 +34,24 @@ public string ApiUrl /// public bool MatchesApiUrl(string? apiUrl) { + if (apiUrl == ApiUrl) + // Exact match + return true; + if (string.IsNullOrEmpty(apiUrl)) return false; - Console.WriteLine(apiUrl); - + // Loose match try { - var urlParsed = new Uri(apiUrl); - - Console.WriteLine($"parsed.Host = {urlParsed.Host}"); - Console.WriteLine($"parsed.Port = {urlParsed.Port}"); + var urlOurs = new Uri(ApiUrl); + var urlTheirs = new Uri(apiUrl); - return urlParsed.Host == HostName && urlParsed.Port == ApiPort; + return urlOurs.Host == urlTheirs.Host && + urlOurs.Port == urlTheirs.Port; } - catch (UriFormatException ex) + catch (UriFormatException) { - Console.WriteLine(ex.Message); return false; } } diff --git a/BeatTogether/Models/TemporaryServerDetails.cs b/BeatTogether/Models/TemporaryServerDetails.cs index 443a5fe..2222532 100644 --- a/BeatTogether/Models/TemporaryServerDetails.cs +++ b/BeatTogether/Models/TemporaryServerDetails.cs @@ -6,15 +6,22 @@ public class TemporaryServerDetails : ServerDetails { public TemporaryServerDetails(string apiUrl, int masterServerPort) { - var urlParsed = new Uri(apiUrl); + try + { + var urlParsed = new Uri(apiUrl); - ServerName = urlParsed.Host; - HostName = urlParsed.Host; - Port = masterServerPort; + ServerName = urlParsed.Host; + HostName = urlParsed.Host; + } + catch (UriFormatException) + { + ServerName = apiUrl; + HostName = apiUrl; + } + + ApiUrl = apiUrl; StatusUri = string.Empty; MaxPartySize = IsOfficial ? 5 : 128; - ApiPort = urlParsed.Port; - ApiSecure = urlParsed.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase); } } } \ No newline at end of file diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 6391d3b..fd7a50a 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -99,7 +99,7 @@ private void ApplySelectedServer(ServerDetails server) if (server is TemporaryServerDetails) return; - _logger.Debug($"Server changed to '{server.ServerName}': '{server.HostName}:{server.Port}'"); + _logger.Debug($"Server changed to '{server.ServerName}': '{server.ApiUrl}'"); _serverRegistry.SetSelectedServer(server); if (server.IsOfficial) _networkConfig.UseOfficialServer(); From 5d6df9c33ed0886ab8a2334e040f02c1213f65bd Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Mon, 10 Apr 2023 00:47:39 +0200 Subject: [PATCH 11/34] wip(1.29): handle temporary server selection --- BeatTogether/Models/TemporaryServerDetails.cs | 12 ++++++------ BeatTogether/UI/ServerSelectionController.cs | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/BeatTogether/Models/TemporaryServerDetails.cs b/BeatTogether/Models/TemporaryServerDetails.cs index 2222532..037a78d 100644 --- a/BeatTogether/Models/TemporaryServerDetails.cs +++ b/BeatTogether/Models/TemporaryServerDetails.cs @@ -4,23 +4,23 @@ namespace BeatTogether.Models { public class TemporaryServerDetails : ServerDetails { - public TemporaryServerDetails(string apiUrl, int masterServerPort) + public TemporaryServerDetails(string graphApiUrl, string? statusUrl) { try { - var urlParsed = new Uri(apiUrl); + var urlParsed = new Uri(graphApiUrl); ServerName = urlParsed.Host; HostName = urlParsed.Host; } catch (UriFormatException) { - ServerName = apiUrl; - HostName = apiUrl; + ServerName = graphApiUrl; + HostName = graphApiUrl; } - ApiUrl = apiUrl; - StatusUri = string.Empty; + ApiUrl = graphApiUrl; + StatusUri = statusUrl ?? graphApiUrl; MaxPartySize = IsOfficial ? 5 : 128; } } diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index fd7a50a..1240623 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -134,9 +134,8 @@ private void SyncSelectedServer() else { // Selected server is not in our config, set temporary value - // TODO - _logger.Error($"Server not in config // TODO // not supported right now"); - return; + _logger.Debug($"Setting temporary server details (GraphUrl={_networkConfig.GraphUrl})"); + selectedServer = new TemporaryServerDetails(_networkConfig.GraphUrl!, _networkConfig.MasterServerStatusUrl); } } else From f86ccd11f3dbb0ff1c4429287d775cf120131e8a Mon Sep 17 00:00:00 2001 From: Kevin Hammett Date: Fri, 14 Apr 2023 19:07:19 -0400 Subject: [PATCH 12/34] Update manifest.json --- BeatTogether/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index 205687e..121dbe8 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -10,7 +10,7 @@ "BSIPA": "^4.2.0", "BeatSaberMarkupLanguage": "^1.5.0", "SiraUtil": "^3.1.0", - "MultiplayerCore": "^1.1.1" + "MultiplayerCore": "^1.3.0" }, "features": [] } From 160275f9ef3de5dcd047be3cc07f2b14178be3bb Mon Sep 17 00:00:00 2001 From: Kevin Hammett Date: Fri, 14 Apr 2023 19:14:52 -0400 Subject: [PATCH 13/34] Update manifest.json --- BeatTogether/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index 121dbe8..782ebf2 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -3,7 +3,7 @@ "id": "BeatTogether", "name": "BeatTogether", "author": "Goobwabber", - "version": "2.1.0", + "version": "2.1.1", "description": "A multiplayer private server for the modding community. Supports crossplay between PC and Quest.", "gameVersion": "1.29.0", "dependsOn": { From 41d64262050e41e98198ecda38fc291186438487 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sun, 30 Apr 2023 17:40:15 +0200 Subject: [PATCH 14/34] Scale Server Selector with VC, fix bug where selector is not interactible when an error dialog is shown --- BeatTogether/BeatTogether.csproj | 275 ++++++++++--------- BeatTogether/UI/ServerSelectionController.cs | 15 +- 2 files changed, 149 insertions(+), 141 deletions(-) diff --git a/BeatTogether/BeatTogether.csproj b/BeatTogether/BeatTogether.csproj index 15d788c..452e201 100644 --- a/BeatTogether/BeatTogether.csproj +++ b/BeatTogether/BeatTogether.csproj @@ -1,142 +1,145 @@  - - Library - Properties - BeatTogether - 2.0.1 - net472 - true - portable - ..\Refs - $(LocalRefsDir) + + Library + Properties + BeatTogether + 2.0.1 + net472 + true + portable + ..\Refs + $(LocalRefsDir) - prompt - 4 - 9.0 - enable - Unofficial - local - - + prompt + 4 + 9.0 + enable + Unofficial + local + + + + + + + false + DEBUG;TRACE + + + true + + + True + + + True + True + + + + + + + $(BeatSaberDir)\Libs\0Harmony.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\BGNet.dll + False + + + False + $(BeatSaberDir)\Plugins\BSML.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll + False + False + + + $(BeatSaberDir)\Plugins\MultiplayerCore.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\Polyglot.dll + False + + + False + $(BeatSaberDir)\Plugins\SiraUtil.dll + False + + + + + + $(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject-usage.dll + False + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + Official - - false - DEBUG;TRACE + + $(VersionType)-$(GitBranch)-$(CommitHash) - - true + + $(VersionType)-$(GitBranch)-$(CommitHash)-$(GitModified) - - True - - - True - True - - - - - - - $(BeatSaberDir)\Libs\0Harmony.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\BGNet.dll - False - - - False - $(BeatSaberDir)\Plugins\BSML.dll - False - - - $(BeatSaberDir)\Plugins\MultiplayerCore.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\Polyglot.dll - False - - - False - $(BeatSaberDir)\Plugins\SiraUtil.dll - False - - - - - - $(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject-usage.dll - False - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - Official - - - $(VersionType)-$(GitBranch)-$(CommitHash) - - - $(VersionType)-$(GitBranch)-$(CommitHash)-$(GitModified) - - - - + + + \ No newline at end of file diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 1240623..3d30e99 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -196,12 +196,11 @@ private void DidActivate() else { // Secondary activation: server selection may have been externally modified, sync it now - SyncSelectedServer(); + SyncSelectedServer(); + _screen.gameObject.SetActive(true); } - - _screen.gameObject.SetActive(true); } - + [AffinityPrefix] [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "DidDeactivate")] private void DidDeactivate(bool removedFromHierarchy) @@ -214,9 +213,15 @@ private void DidDeactivate(bool removedFromHierarchy) private bool TopViewControllerWillChange(ViewController oldViewController, ViewController newViewController, ViewController.AnimationType animationType) { + Transform screenContainer = oldViewController != null ? oldViewController.transform.parent.parent : newViewController.transform.parent.parent; + Transform screenSystem = screenContainer.parent; + _screen.gameObject.transform.localScale = screenContainer.localScale * screenSystem.localScale.y; + _screen.transform.position = screenContainer.position + new Vector3(0, screenSystem.localScale.y * 1.15f, 0); + _screen.gameObject.SetActive(true); + if (oldViewController is MultiplayerModeSelectionViewController) SetInteraction(false); - if (newViewController is MultiplayerModeSelectionViewController) + if (newViewController is MultiplayerModeSelectionViewController || newViewController is ConnectionErrorDialogViewController) SetInteraction(true); if (newViewController is JoiningLobbyViewController && animationType == ViewController.AnimationType.None) return false; From 2f74a370db33afbfc5eb5d9bcdff523b2cfd5d94 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sun, 30 Apr 2023 17:58:31 +0200 Subject: [PATCH 15/34] Update build workflows and csproj checks --- .github/workflows/Build.yml | 6 +++--- .github/workflows/PR_Build.yml | 4 ++-- BeatTogether/BeatTogether.csproj | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 79a3d36..bfa8c71 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -12,11 +12,11 @@ jobs: Build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup dotnet - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: 5.0.x + dotnet-version: '5.0.x' - name: Fetch SIRA References uses: ProjectSIRA/download-sira-stripped@1.0.0 with: diff --git a/.github/workflows/PR_Build.yml b/.github/workflows/PR_Build.yml index 0a5e3e4..f1e7b9a 100644 --- a/.github/workflows/PR_Build.yml +++ b/.github/workflows/PR_Build.yml @@ -12,9 +12,9 @@ jobs: Build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup dotnet - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: dotnet-version: 5.0.x - name: Fetch SIRA References diff --git a/BeatTogether/BeatTogether.csproj b/BeatTogether/BeatTogether.csproj index 452e201..b46fe4a 100644 --- a/BeatTogether/BeatTogether.csproj +++ b/BeatTogether/BeatTogether.csproj @@ -131,7 +131,7 @@ - + Official From 3b548827af45b147e79d20357d2dd40656508496 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sun, 30 Apr 2023 18:03:39 +0200 Subject: [PATCH 16/34] Bump version --- BeatTogether/BeatTogether.csproj | 2 +- BeatTogether/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BeatTogether/BeatTogether.csproj b/BeatTogether/BeatTogether.csproj index b46fe4a..7b6bcbd 100644 --- a/BeatTogether/BeatTogether.csproj +++ b/BeatTogether/BeatTogether.csproj @@ -4,7 +4,7 @@ Library Properties BeatTogether - 2.0.1 + 2.1.2 net472 true portable diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index 782ebf2..7f62c97 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -3,7 +3,7 @@ "id": "BeatTogether", "name": "BeatTogether", "author": "Goobwabber", - "version": "2.1.1", + "version": "2.1.2", "description": "A multiplayer private server for the modding community. Supports crossplay between PC and Quest.", "gameVersion": "1.29.0", "dependsOn": { From 82f312d4c1d67a3d100a8efb0962b9389fc35566 Mon Sep 17 00:00:00 2001 From: Michael R Date: Mon, 1 May 2023 19:01:24 +0200 Subject: [PATCH 17/34] Create Bug_Report.yml ISSUE_TEMPLATE This commits add a bug report issue template to the BT repo --- .github/ISSUE_TEMPLATE/Bug_Report.yml | 76 +++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/Bug_Report.yml diff --git a/.github/ISSUE_TEMPLATE/Bug_Report.yml b/.github/ISSUE_TEMPLATE/Bug_Report.yml new file mode 100644 index 0000000..88d69ba --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_Report.yml @@ -0,0 +1,76 @@ +name: "Bug report 🐛" +description: Report issues, errors or unexpected behavior +title: "[Bug]: " +labels: [bug] +assignees: + - michael-r-elp +body: +- type: markdown + attributes: + value: | + Please make sure to search for existing issues before making a new one! + +- type: textarea + attributes: + label: Describe the bug + placeholder: "Thing 'x' isn't working when I do 'y', etc." + description: | + A clear and concise description of what the bug is. + validations: + required: true + +- type: textarea + attributes: + label: Steps to reproduce + placeholder: Steps to reproduce the behavior. + validations: + required: true + +- type: textarea + attributes: + label: Expected Behavior + description: If applicable, add screenshots to help explain your problem. + placeholder: What were you expecting? + validations: + required: false + +- type: textarea + attributes: + label: Actual Behavior + placeholder: What happened instead? + validations: + required: true + +- type: input + attributes: + label: Game Version + placeholder: "1.29.0" + description: | + The version of the game you were running + validations: + required: true + +- type: input + attributes: + label: Mod Version + placeholder: "0.1.0" + description: | + The version of the mod you were using + validations: + required: true + +- type: textarea + attributes: + label: Additional context + description: Add any other context about the problem here. + validations: + required: false + +#- type: checkboxes +# id: terms +# attributes: +# label: Code of Conduct +# description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/BeatTogether/.github/blob/main/CODE_OF_CONDUCT.md) +# options: +# - label: I agree to follow this project's Code of Conduct +# required: true From e56ace71f822fcf3dc45324cffc5b017262c8b28 Mon Sep 17 00:00:00 2001 From: Michael R Date: Mon, 1 May 2023 19:04:19 +0200 Subject: [PATCH 18/34] Create config.yml This controls blank issues and adds a link to the BT discord --- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..876de7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: true # Enabled for now until all issue templates are added +contact_links: + - name: BeatTogether Community Support + url: https://discord.com/invite/gezGrFG4tz + about: Please ask and answer questions here. From d8e4adee1a2ac4dd9140fce3b39ea1b0cec7529e Mon Sep 17 00:00:00 2001 From: Michael R Date: Mon, 1 May 2023 19:04:54 +0200 Subject: [PATCH 19/34] Update config.yml replace "Support" with "Discord" --- .github/ISSUE_TEMPLATE/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 876de7d..09e7cee 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: true # Enabled for now until all issue templates are added contact_links: - - name: BeatTogether Community Support + - name: BeatTogether Community Discord url: https://discord.com/invite/gezGrFG4tz about: Please ask and answer questions here. From 7d6255a51a9aea0d8090548cc2cd6b78c0ea7967 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Mon, 19 Jun 2023 14:49:41 +0200 Subject: [PATCH 20/34] Fix server selection not being interactable when status check fails --- BeatTogether/UI/ServerSelectionController.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 3d30e99..5479844 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -238,6 +238,16 @@ private void DoPresentTransition(ViewController toPresentViewController, ViewCon animationDirection = ViewController.AnimationDirection.Vertical; } + [AffinityPrefix] + [AffinityPatch(typeof(MultiplayerUnavailableReasonMethods), + nameof(MultiplayerUnavailableReasonMethods.TryGetMultiplayerUnavailableReason))] + private void TryGetMultiplayerUnavailableReason() + { + // Re-Enable interaction when the MultiplayerUnavailableReason method is called, which happens when the initial status check returns an error + if (_serverList.enabled) + SetInteraction(true); + } + [AffinityPrefix] [AffinityPatch(typeof(FlowCoordinator), "SetTitle")] private void SetTitle(ref string value, ref string ____title) From 5000d7d23b9ad88617f6820723894a8dfbd82758 Mon Sep 17 00:00:00 2001 From: Kevin Hammett Date: Mon, 26 Jun 2023 06:17:08 -0400 Subject: [PATCH 21/34] 1.30.2 Prep --- BeatTogether/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index 7f62c97..7733ee0 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -3,7 +3,7 @@ "id": "BeatTogether", "name": "BeatTogether", "author": "Goobwabber", - "version": "2.1.2", + "version": "2.2.0", "description": "A multiplayer private server for the modding community. Supports crossplay between PC and Quest.", "gameVersion": "1.29.0", "dependsOn": { From 745effee1ef84feec39e968bd9c233b7ba3d2ebd Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Wed, 5 Jul 2023 03:16:12 +0200 Subject: [PATCH 22/34] feat: MpCore 1.5 / DisableSsl server setting --- BeatTogether/Config.cs | 3 ++- BeatTogether/Models/ServerDetails.cs | 4 ++++ BeatTogether/Models/TemporaryServerDetails.cs | 1 + BeatTogether/UI/ServerSelectionController.cs | 23 ++++++++++--------- BeatTogether/manifest.json | 15 ++++++------ 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/BeatTogether/Config.cs b/BeatTogether/Config.cs index 06ea8e2..2c2e67e 100644 --- a/BeatTogether/Config.cs +++ b/BeatTogether/Config.cs @@ -46,7 +46,8 @@ public virtual void OnReload() HostName = BeatTogetherHostName, ApiUrl = BeatTogetherApiUri, StatusUri = BeatTogetherStatusUri, - MaxPartySize = BeatTogetherMaxPartySize + MaxPartySize = BeatTogetherMaxPartySize, + DisableSsl = true }); } } diff --git a/BeatTogether/Models/ServerDetails.cs b/BeatTogether/Models/ServerDetails.cs index 1e1deb1..5e30923 100644 --- a/BeatTogether/Models/ServerDetails.cs +++ b/BeatTogether/Models/ServerDetails.cs @@ -25,6 +25,10 @@ public class ServerDetails /// Max amount of players per instance /// public int MaxPartySize { get; set; } = 5; + /// + /// If set: disable SSL and certificate validation for all Ignorance/ENet client connections. + /// + public bool DisableSsl { get; set; } = true; public bool IsOfficial => ServerName == Config.OfficialServerName; diff --git a/BeatTogether/Models/TemporaryServerDetails.cs b/BeatTogether/Models/TemporaryServerDetails.cs index 037a78d..93b1b4d 100644 --- a/BeatTogether/Models/TemporaryServerDetails.cs +++ b/BeatTogether/Models/TemporaryServerDetails.cs @@ -22,6 +22,7 @@ public TemporaryServerDetails(string graphApiUrl, string? statusUrl) ApiUrl = graphApiUrl; StatusUri = statusUrl ?? graphApiUrl; MaxPartySize = IsOfficial ? 5 : 128; + DisableSsl = true; } } } \ No newline at end of file diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 5479844..36e422c 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -100,12 +100,9 @@ private void ApplySelectedServer(ServerDetails server) return; _logger.Debug($"Server changed to '{server.ServerName}': '{server.ApiUrl}'"); + _serverRegistry.SetSelectedServer(server); - if (server.IsOfficial) - _networkConfig.UseOfficialServer(); - else - _networkConfig.UseCustomApiServer(server.ApiUrl, server.StatusUri, server.MaxPartySize); - + ApplyNetworkConfig(server); SyncTemporarySelectedServer(); SetInteraction(false); @@ -115,6 +112,15 @@ private void ApplySelectedServer(ServerDetails server) _replaceTopScreenViewController(_modeSelectionFlow, _joiningLobbyView, () => { }, ViewController.AnimationType.None, ViewController.AnimationDirection.Vertical); } + + private void ApplyNetworkConfig(ServerDetails server) + { + if (server.IsOfficial) + _networkConfig.UseOfficialServer(); + else + _networkConfig.UseCustomApiServer(server.ApiUrl, server.StatusUri, server.MaxPartySize, + null, server.DisableSsl); + } private void SyncSelectedServer() { @@ -185,12 +191,7 @@ private void DidActivate() if (_isFirstActivation) { // First activation: apply the currently selected server (from our config) - if (_serverRegistry.SelectedServer.IsOfficial) - _networkConfig.UseOfficialServer(); - else - _networkConfig.UseCustomApiServer(_serverRegistry.SelectedServer.ApiUrl, - _serverRegistry.SelectedServer.StatusUri, _serverRegistry.SelectedServer.MaxPartySize); - + ApplyNetworkConfig(_serverRegistry.SelectedServer); _isFirstActivation = false; } else diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index 7733ee0..4499ad7 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -3,14 +3,13 @@ "id": "BeatTogether", "name": "BeatTogether", "author": "Goobwabber", - "version": "2.2.0", + "version": "2.3.0", "description": "A multiplayer private server for the modding community. Supports crossplay between PC and Quest.", - "gameVersion": "1.29.0", + "gameVersion": "1.31.0", "dependsOn": { - "BSIPA": "^4.2.0", - "BeatSaberMarkupLanguage": "^1.5.0", - "SiraUtil": "^3.1.0", - "MultiplayerCore": "^1.3.0" - }, - "features": [] + "BSIPA": "^4.3.0", + "BeatSaberMarkupLanguage": "^1.7.3", + "SiraUtil": "^3.1.3", + "MultiplayerCore": "^1.5.0" + } } From e7f152b9c4108ff75c0c5dde4e7df042aad5a458 Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Wed, 5 Jul 2023 21:24:23 +0200 Subject: [PATCH 23/34] feat: auto update DisableSsl setting from mp status data --- BeatTogether/UI/ServerSelectionController.cs | 65 +++++++++++++++----- 1 file changed, 51 insertions(+), 14 deletions(-) diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 36e422c..cc81f02 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -20,6 +20,8 @@ using UnityEngine; using Zenject; using System.Threading; +using MultiplayerCore.Models; +using MultiplayerCore.Repositories; namespace BeatTogether.UI { @@ -49,6 +51,7 @@ private FieldAccessor { }, ViewController.AnimationType.None, ViewController.AnimationDirection.Vertical); } - - private void ApplyNetworkConfig(ServerDetails server) - { - if (server.IsOfficial) - _networkConfig.UseOfficialServer(); - else - _networkConfig.UseCustomApiServer(server.ApiUrl, server.StatusUri, server.MaxPartySize, - null, server.DisableSsl); - } private void SyncSelectedServer() { @@ -155,6 +156,19 @@ private void SyncSelectedServer() OnPropertyChanged(nameof(_serverValue)); // for BSML binding } + + #endregion + + #region Server config + + private void ApplyNetworkConfig(ServerDetails server) + { + if (server.IsOfficial) + _networkConfig.UseOfficialServer(); + else + _networkConfig.UseCustomApiServer(server.ApiUrl, server.StatusUri, server.MaxPartySize, + null, server.DisableSsl); + } private void SyncTemporarySelectedServer() { @@ -179,7 +193,30 @@ private void SyncTemporarySelectedServer() if (didChange) OnPropertyChanged(nameof(_serverOptions)); // for BSML binding } - + + private void HandleMpStatusUpdateForUrl(string statusUrl, MpStatusData statusData) + { + // Automatically set disableSsl setting from mp status data + + var targetServers = _serverRegistry.Servers + .Where((server) => server.StatusUri.Equals(statusUrl)); + + foreach (var targetServer in targetServers) + { + var disableSsl = !statusData.useSsl; + + if (disableSsl == targetServer.DisableSsl) + continue; + + _logger.Info($"Config update for \"{targetServer.ServerName}\": disableSsl={disableSsl}"); + + targetServer.DisableSsl = disableSsl; + + if (_serverRegistry.SelectedServer == targetServer) + ApplyNetworkConfig(targetServer); + } + } + #endregion #region Affinity patches From ef7623ac4cc38bb7f00ac8546841e97cffa4cbc9 Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Sat, 6 Apr 2024 00:47:54 +0200 Subject: [PATCH 24/34] chore: update references for 1.35.0 --- BeatTogether/BeatTogether.csproj | 21 ++++++++++++-------- BeatTogether/UI/ServerSelectionController.cs | 13 +++++++----- BeatTogether/manifest.json | 8 ++++---- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/BeatTogether/BeatTogether.csproj b/BeatTogether/BeatTogether.csproj index 7b6bcbd..5ea8f40 100644 --- a/BeatTogether/BeatTogether.csproj +++ b/BeatTogether/BeatTogether.csproj @@ -44,10 +44,6 @@ $(BeatSaberDir)\Libs\0Harmony.dll False - - $(BeatSaberDir)\Beat Saber_Data\Managed\BGNet.dll - False - False $(BeatSaberDir)\Plugins\BSML.dll @@ -62,10 +58,6 @@ $(BeatSaberDir)\Plugins\MultiplayerCore.dll False - - $(BeatSaberDir)\Beat Saber_Data\Managed\Polyglot.dll - False - False $(BeatSaberDir)\Plugins\SiraUtil.dll @@ -74,6 +66,14 @@ + + $(BeatSaberDir)\Beat Saber_Data\Managed\DataModels.dll + False + + + $(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.Polyglot.dll + False + $(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll False @@ -81,6 +81,7 @@ $(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll False + True $(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll @@ -121,6 +122,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index cc81f02..02a12e6 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -7,7 +7,6 @@ using HMUI; using IPA.Utilities; using MultiplayerCore.Patchers; -using Polyglot; using SiraUtil.Affinity; using SiraUtil.Logging; using System; @@ -20,6 +19,7 @@ using UnityEngine; using Zenject; using System.Threading; +using BGLib.Polyglot; using MultiplayerCore.Models; using MultiplayerCore.Repositories; @@ -222,7 +222,8 @@ private void HandleMpStatusUpdateForUrl(string statusUrl, MpStatusData statusDat #region Affinity patches [AffinityPrefix] - [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "DidActivate")] + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), + nameof(MultiplayerModeSelectionFlowCoordinator.DidActivate))] private void DidActivate() { if (_isFirstActivation) @@ -240,14 +241,16 @@ private void DidActivate() } [AffinityPrefix] - [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "DidDeactivate")] + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), + nameof(MultiplayerModeSelectionFlowCoordinator.DidDeactivate))] private void DidDeactivate(bool removedFromHierarchy) { _screen.gameObject.SetActive(false); } [AffinityPrefix] - [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), "TopViewControllerWillChange")] + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), + nameof(MultiplayerModeSelectionFlowCoordinator.TopViewControllerWillChange))] private bool TopViewControllerWillChange(ViewController oldViewController, ViewController newViewController, ViewController.AnimationType animationType) { @@ -287,7 +290,7 @@ private void TryGetMultiplayerUnavailableReason() } [AffinityPrefix] - [AffinityPatch(typeof(FlowCoordinator), "SetTitle")] + [AffinityPatch(typeof(FlowCoordinator), nameof(FlowCoordinator.SetTitle))] private void SetTitle(ref string value, ref string ____title) { if (value == Localization.Get("LABEL_CHECKING_SERVER_STATUS")) diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index 4499ad7..e85c5be 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -5,11 +5,11 @@ "author": "Goobwabber", "version": "2.3.0", "description": "A multiplayer private server for the modding community. Supports crossplay between PC and Quest.", - "gameVersion": "1.31.0", + "gameVersion": "1.35.0", "dependsOn": { - "BSIPA": "^4.3.0", - "BeatSaberMarkupLanguage": "^1.7.3", - "SiraUtil": "^3.1.3", + "BSIPA": "^4.3.3", + "BeatSaberMarkupLanguage": "^1.9.0", + "SiraUtil": "^3.1.7", "MultiplayerCore": "^1.5.0" } } From 76c19c2a3effce9ab97ba359bbac47e2e65fb0a0 Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Sat, 6 Apr 2024 17:34:48 +0200 Subject: [PATCH 25/34] fix: menu UI can break when switching at the wrong time --- BeatTogether/BeatTogether.csproj | 1 + BeatTogether/UI/ServerSelectionController.cs | 79 +++++++++++--------- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/BeatTogether/BeatTogether.csproj b/BeatTogether/BeatTogether.csproj index 5ea8f40..923720f 100644 --- a/BeatTogether/BeatTogether.csproj +++ b/BeatTogether/BeatTogether.csproj @@ -53,6 +53,7 @@ $(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll False False + True $(BeatSaberDir)\Plugins\MultiplayerCore.dll diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 02a12e6..5a07a10 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -114,8 +114,8 @@ private void ApplySelectedServer(ServerDetails server) ApplyNetworkConfig(server); SyncTemporarySelectedServer(); - - SetInteraction(false); + RefreshSwitchInteractable(); + //_cancellationTokenSource(ref _modeSelectionFlow) = new CancellationTokenSource(); _didDeactivate(_modeSelectionFlow, false, false); _didActivate(_modeSelectionFlow, false, true, false); @@ -248,27 +248,22 @@ private void DidDeactivate(bool removedFromHierarchy) _screen.gameObject.SetActive(false); } - [AffinityPrefix] + [AffinityPostfix] [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), - nameof(MultiplayerModeSelectionFlowCoordinator.TopViewControllerWillChange))] - private bool TopViewControllerWillChange(ViewController oldViewController, ViewController newViewController, - ViewController.AnimationType animationType) + nameof(MultiplayerModeSelectionFlowCoordinator.TransitionDidStart))] + private void TransitionDidStart() { - Transform screenContainer = oldViewController != null ? oldViewController.transform.parent.parent : newViewController.transform.parent.parent; - Transform screenSystem = screenContainer.parent; - _screen.gameObject.transform.localScale = screenContainer.localScale * screenSystem.localScale.y; - _screen.transform.position = screenContainer.position + new Vector3(0, screenSystem.localScale.y * 1.15f, 0); - _screen.gameObject.SetActive(true); - - if (oldViewController is MultiplayerModeSelectionViewController) - SetInteraction(false); - if (newViewController is MultiplayerModeSelectionViewController || newViewController is ConnectionErrorDialogViewController) - SetInteraction(true); - if (newViewController is JoiningLobbyViewController && animationType == ViewController.AnimationType.None) - return false; - return true; + RefreshSwitchInteractable(); } + [AffinityPostfix] + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), + nameof(MultiplayerModeSelectionFlowCoordinator.TransitionDidFinish))] + private void TransitionDidFinish() + { + RefreshSwitchInteractable(); + } + [AffinityPrefix] [AffinityPatch(typeof(ViewControllerTransitionHelpers), nameof(ViewControllerTransitionHelpers.DoPresentTransition))] @@ -280,44 +275,60 @@ private void DoPresentTransition(ViewController toPresentViewController, ViewCon } [AffinityPrefix] - [AffinityPatch(typeof(MultiplayerUnavailableReasonMethods), - nameof(MultiplayerUnavailableReasonMethods.TryGetMultiplayerUnavailableReason))] - private void TryGetMultiplayerUnavailableReason() + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), + nameof(MultiplayerModeSelectionFlowCoordinator.TopViewControllerWillChange))] + private bool TopViewControllerWillChange(ViewController oldViewController, ViewController newViewController, + ViewController.AnimationType animationType) { - // Re-Enable interaction when the MultiplayerUnavailableReason method is called, which happens when the initial status check returns an error - if (_serverList.enabled) - SetInteraction(true); + var screenContainer = oldViewController != null ? oldViewController.transform.parent.parent : newViewController.transform.parent.parent; + var screenSystem = screenContainer.parent; + + _screen.gameObject.transform.localScale = screenContainer.localScale * screenSystem.localScale.y; + _screen.transform.position = screenContainer.position + new Vector3(0, screenSystem.localScale.y * 1.15f, 0); + _screen.gameObject.SetActive(true); + + RefreshSwitchInteractable(); + + if (newViewController is JoiningLobbyViewController && animationType == ViewController.AnimationType.None) + return false; + + return true; } [AffinityPrefix] [AffinityPatch(typeof(FlowCoordinator), nameof(FlowCoordinator.SetTitle))] private void SetTitle(ref string value, ref string ____title) { + // Keep "Multiplayer Mode Selection" as a title when the server status check is happening + // This makes it more obvious what is going on and it looks less goofy (duplicate text) if (value == Localization.Get("LABEL_CHECKING_SERVER_STATUS")) value = Localization.Get("LABEL_MULTIPLAYER_MODE_SELECTION"); - if (____title == Localization.Get("LABEL_CHECKING_SERVER_STATUS") && value == "") - SetInteraction(true); } - + #endregion #region SetInteraction - private bool _interactable = true; private bool _globalInteraction = true; - private void SetInteraction(bool value) + private void RefreshSwitchInteractable() { - _interactable = value; - _serverList.interactable = _interactable && _globalInteraction; + if (_serverList == null) + return; + + // Only allow interactions when the main view controller is active and not transitioning + var interactable = _globalInteraction + && _modeSelectionFlow.topViewController is MultiplayerModeSelectionViewController + && !_modeSelectionFlow.topViewController.isInTransition; + _serverList.interactable = interactable; } [AffinityPrefix] - [AffinityPatch(typeof(FlowCoordinator), "SetGlobalUserInteraction")] + [AffinityPatch(typeof(FlowCoordinator), nameof(FlowCoordinator.SetGlobalUserInteraction))] private void SetGlobalUserInteraction(bool value) { _globalInteraction = value; - _serverList.interactable = _interactable && _globalInteraction; + RefreshSwitchInteractable(); } #endregion From 8ca8e232b88ba8cece682e225b2e481094060b8c Mon Sep 17 00:00:00 2001 From: Roy de Jong Date: Sat, 6 Apr 2024 17:39:32 +0200 Subject: [PATCH 26/34] tweak: enable switch view animation, clean up accessors --- BeatTogether/UI/ServerSelectionController.cs | 31 ++++---------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 5a07a10..f4d4ded 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -29,26 +29,8 @@ internal class ServerSelectionController : IInitializable, IAffinity, INotifyPro { public const string ResourcePath = "BeatTogether.UI.ServerSelectionController.bsml"; - private Action _didActivate - = MethodAccessor> - .GetDelegate("DidActivate"); - - private Action _didDeactivate - = MethodAccessor> - .GetDelegate("DidDeactivate"); - - private Action _replaceTopScreenViewController - = MethodAccessor> - .GetDelegate("ReplaceTopViewController"); - - private FieldAccessor.Accessor _cancellationTokenSource - = FieldAccessor.GetAccessor(nameof(_cancellationTokenSource)); - private FloatingScreen _screen = null!; - - private MultiplayerModeSelectionFlowCoordinator _modeSelectionFlow; + private readonly MultiplayerModeSelectionFlowCoordinator _modeSelectionFlow; private readonly JoiningLobbyViewController _joiningLobbyView; private readonly NetworkConfigPatcher _networkConfig; private readonly MpStatusRepository _mpStatusRepository; @@ -116,11 +98,10 @@ private void ApplySelectedServer(ServerDetails server) SyncTemporarySelectedServer(); RefreshSwitchInteractable(); - //_cancellationTokenSource(ref _modeSelectionFlow) = new CancellationTokenSource(); - _didDeactivate(_modeSelectionFlow, false, false); - _didActivate(_modeSelectionFlow, false, true, false); - _replaceTopScreenViewController(_modeSelectionFlow, _joiningLobbyView, () => { }, - ViewController.AnimationType.None, ViewController.AnimationDirection.Vertical); + _modeSelectionFlow.DidDeactivate(false, false); + _modeSelectionFlow.DidActivate(false, true, false); + _modeSelectionFlow.ReplaceTopViewController(_joiningLobbyView, + animationDirection: ViewController.AnimationDirection.Vertical); } private void SyncSelectedServer() @@ -338,7 +319,7 @@ private void SetGlobalUserInteraction(bool value) public event PropertyChangedEventHandler? PropertyChanged; [NotifyPropertyChangedInvocator] - protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) + private void OnPropertyChanged([CallerMemberName] string? propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } From 503b7e6a2fc74a73d3f26e8a330a703e86712689 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Tue, 14 May 2024 21:09:56 +0200 Subject: [PATCH 27/34] Fix ServerSelection UI lockup --- BeatTogether/UI/ServerSelectionController.cs | 36 ++++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index f4d4ded..980fae8 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -37,6 +37,7 @@ internal class ServerSelectionController : IInitializable, IAffinity, INotifyPro private readonly ServerDetailsRegistry _serverRegistry; private readonly SiraLog _logger; private bool _isFirstActivation; + private uint _allowSelectionOnce; [UIComponent("server-list")] private ListSetting _serverList = null!; @@ -88,12 +89,6 @@ private void ApplySelectedServer(ServerDetails server) if (server is TemporaryServerDetails) return; - if (_serverRegistry.SelectedServer != server) - { - _logger.Debug($"Server changed to '{server.ServerName}': '{server.ApiUrl}'"); - _serverRegistry.SetSelectedServer(server); - } - ApplyNetworkConfig(server); SyncTemporarySelectedServer(); RefreshSwitchInteractable(); @@ -177,16 +172,15 @@ private void SyncTemporarySelectedServer() private void HandleMpStatusUpdateForUrl(string statusUrl, MpStatusData statusData) { - // Automatically set disableSsl setting from mp status data - - var targetServers = _serverRegistry.Servers + // Automatically set disableSsl setting from mp status data + var targetServers = _serverRegistry.Servers .Where((server) => server.StatusUri.Equals(statusUrl)); foreach (var targetServer in targetServers) { - var disableSsl = !statusData.useSsl; - - if (disableSsl == targetServer.DisableSsl) + var disableSsl = !statusData.useSsl; + + if (disableSsl == targetServer.DisableSsl) continue; _logger.Info($"Config update for \"{targetServer.ServerName}\": disableSsl={disableSsl}"); @@ -195,7 +189,7 @@ private void HandleMpStatusUpdateForUrl(string statusUrl, MpStatusData statusDat if (_serverRegistry.SelectedServer == targetServer) ApplyNetworkConfig(targetServer); - } + } } #endregion @@ -221,7 +215,14 @@ private void DidActivate() } } - [AffinityPrefix] + [AffinityPostfix] + [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), nameof(MultiplayerModeSelectionFlowCoordinator.PresentMasterServerUnavailableErrorDialog))] + private void PresentMasterServerUnavailableErrorDialog() + { + _allowSelectionOnce = 2; + } + + [AffinityPrefix] [AffinityPatch(typeof(MultiplayerModeSelectionFlowCoordinator), nameof(MultiplayerModeSelectionFlowCoordinator.DidDeactivate))] private void DidDeactivate(bool removedFromHierarchy) @@ -301,7 +302,12 @@ private void RefreshSwitchInteractable() var interactable = _globalInteraction && _modeSelectionFlow.topViewController is MultiplayerModeSelectionViewController && !_modeSelectionFlow.topViewController.isInTransition; - _serverList.interactable = interactable; + + // This is kinda a stupid way to do this but since this triggers twice + // when the connection error dialog comes up I have to make sure + // I set interactable to true the second time this method gets run + _serverList.interactable = interactable || _allowSelectionOnce > 0; + _allowSelectionOnce -= 1; } [AffinityPrefix] From 71e4a5cd316983ee92e126dfc39233a4dc15e5ca Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sat, 8 Jun 2024 18:54:37 +0200 Subject: [PATCH 28/34] Fix: UI lockup and UI disappearing --- BeatTogether/UI/ServerSelectionController.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 980fae8..04dcbe4 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -303,11 +303,12 @@ private void RefreshSwitchInteractable() && _modeSelectionFlow.topViewController is MultiplayerModeSelectionViewController && !_modeSelectionFlow.topViewController.isInTransition; - // This is kinda a stupid way to do this but since this triggers twice - // when the connection error dialog comes up I have to make sure - // I set interactable to true the second time this method gets run - _serverList.interactable = interactable || _allowSelectionOnce > 0; - _allowSelectionOnce -= 1; + // We have _allowSelectionOnce set to 2 and only enable the actual toggle + // the second time this runs as the first will be the status check and + // on the second time this runs + _serverList.interactable = interactable || _allowSelectionOnce == 1; + if (_allowSelectionOnce > 0) + _allowSelectionOnce -= 1; } [AffinityPrefix] From 8306a67d643bec0bfe5d099eb18439cc725b4169 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Sat, 8 Jun 2024 19:01:06 +0200 Subject: [PATCH 29/34] Ammend: Comment on RefreshSwitchInteractable --- BeatTogether/UI/ServerSelectionController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index 04dcbe4..cff87b2 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -305,7 +305,7 @@ private void RefreshSwitchInteractable() // We have _allowSelectionOnce set to 2 and only enable the actual toggle // the second time this runs as the first will be the status check and - // on the second time this runs + // on the second time this runs we'll have the actual error pop-up _serverList.interactable = interactable || _allowSelectionOnce == 1; if (_allowSelectionOnce > 0) _allowSelectionOnce -= 1; From 37ecd704f8bf37fad71f1c0cbecf29714e6dd182 Mon Sep 17 00:00:00 2001 From: Kevin Hammett Date: Sun, 8 Sep 2024 11:19:38 -0400 Subject: [PATCH 30/34] Update Instructions Update instructions for installation for 1.37.0+ --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7ecf63b..9bf742a 100644 --- a/README.md +++ b/README.md @@ -12,21 +12,21 @@ Want to support development and server costs? [Click Here](https://www.patreon.c * 10 Player lobbies ## Requirements -This version supports Beat Saber 1.29+ with mods: +This version supports Beat Saber 1.37.0+ with mods: -* BSIPA v4.1.4+ -* BeatSaberMarkupLanguage v1.6.6+ -* [MultiplayerCore v1.3.0+](https://github.com/Goobwabber/MultiplayerCore#installation) +* BSIPA v4.1.5+ +* BeatSaberMarkupLanguage v1.11.4+ +* [MultiplayerCore v1.5.0+](https://github.com/Goobwabber/MultiplayerCore#installation) -These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using Mod Assistant. +These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using [BSManager]([https://beatmods.com/#/mods](https://github.com/Zagrios/bs-manager?tab=readme-ov-file#download-and-installation ## Installation **Recommended Install:** -The easiest way to install is through [ModAssistant](https://github.com/Assistant/ModAssistant)! +The easiest way to install is through [BSManager](https://github.com/Zagrios/bs-manager?tab=readme-ov-file#download-and-installation)! (Only available for 1.37.3) -**Manual Install:** +**Manual Install (For any other version than 1.37.3)** To install, Download the latest mod from our releases. [Click Here](https://github.com/BeatTogether/BeatTogether/releases) From 890ba7cd0b1dc6f81fe32c952c7faa65c4491cdd Mon Sep 17 00:00:00 2001 From: Kevin Hammett Date: Sun, 8 Sep 2024 11:20:01 -0400 Subject: [PATCH 31/34] Fix Install Link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9bf742a..5978fac 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This version supports Beat Saber 1.37.0+ with mods: * BeatSaberMarkupLanguage v1.11.4+ * [MultiplayerCore v1.5.0+](https://github.com/Goobwabber/MultiplayerCore#installation) -These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using [BSManager]([https://beatmods.com/#/mods](https://github.com/Zagrios/bs-manager?tab=readme-ov-file#download-and-installation +These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using [BSManager]([https://beatmods.com/#/mods](https://github.com/Zagrios/bs-manager?tab=readme-ov-file#download-and-installation) ## Installation From c4a72b479ecc680a2eee3e95a163faae5c76e8dd Mon Sep 17 00:00:00 2001 From: Kevin Hammett Date: Sun, 8 Sep 2024 11:20:51 -0400 Subject: [PATCH 32/34] Fix Links (again) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5978fac..11f604d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This version supports Beat Saber 1.37.0+ with mods: * BeatSaberMarkupLanguage v1.11.4+ * [MultiplayerCore v1.5.0+](https://github.com/Goobwabber/MultiplayerCore#installation) -These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using [BSManager]([https://beatmods.com/#/mods](https://github.com/Zagrios/bs-manager?tab=readme-ov-file#download-and-installation) +These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using [BSManager](https://github.com/Zagrios/bs-manager?tab=readme-ov-file#download-and-installation) ## Installation From 2ad646c02b052f79e41b0864632b038dd4b50fab Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Mon, 23 Sep 2024 22:35:30 +0200 Subject: [PATCH 33/34] Remove unused reference --- BeatTogether/Models/ServerDetails.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/BeatTogether/Models/ServerDetails.cs b/BeatTogether/Models/ServerDetails.cs index 5e30923..8802d92 100644 --- a/BeatTogether/Models/ServerDetails.cs +++ b/BeatTogether/Models/ServerDetails.cs @@ -1,5 +1,4 @@ using System; -using System.Security.Policy; namespace BeatTogether.Models { From dce6b8eee6078f8d5db4ee6f9a28c9ef49e33ed2 Mon Sep 17 00:00:00 2001 From: EnderdracheLP Date: Mon, 23 Sep 2024 22:36:22 +0200 Subject: [PATCH 34/34] Bump BSML to 1.12.0 --- BeatTogether/BeatTogether.csproj | 5 ++++- BeatTogether/UI/ServerSelectionController.cs | 4 ++-- BeatTogether/manifest.json | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/BeatTogether/BeatTogether.csproj b/BeatTogether/BeatTogether.csproj index 923720f..8c349df 100644 --- a/BeatTogether/BeatTogether.csproj +++ b/BeatTogether/BeatTogether.csproj @@ -4,7 +4,7 @@ Library Properties BeatTogether - 2.1.2 + 2.2.1 net472 true portable @@ -44,6 +44,9 @@ $(BeatSaberDir)\Libs\0Harmony.dll False + + ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\BeatSaber.ViewSystem.dll + False $(BeatSaberDir)\Plugins\BSML.dll diff --git a/BeatTogether/UI/ServerSelectionController.cs b/BeatTogether/UI/ServerSelectionController.cs index cff87b2..fccff13 100644 --- a/BeatTogether/UI/ServerSelectionController.cs +++ b/BeatTogether/UI/ServerSelectionController.cs @@ -75,7 +75,7 @@ public void Initialize() { _screen = FloatingScreen.CreateFloatingScreen(new Vector2(90, 90), false, new Vector3(0, 3f, 4.35f), new Quaternion(0, 0, 0, 0)); - BSMLParser.instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), ResourcePath), + BSMLParser.Instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), ResourcePath), _screen.gameObject, this); (_serverList.gameObject.transform.GetChild(1) as RectTransform)!.sizeDelta = new Vector2(60, 0); _screen.GetComponent().SetRadius(140); @@ -306,7 +306,7 @@ private void RefreshSwitchInteractable() // We have _allowSelectionOnce set to 2 and only enable the actual toggle // the second time this runs as the first will be the status check and // on the second time this runs we'll have the actual error pop-up - _serverList.interactable = interactable || _allowSelectionOnce == 1; + _serverList.Interactable = interactable || _allowSelectionOnce == 1; if (_allowSelectionOnce > 0) _allowSelectionOnce -= 1; } diff --git a/BeatTogether/manifest.json b/BeatTogether/manifest.json index e85c5be..216c85a 100644 --- a/BeatTogether/manifest.json +++ b/BeatTogether/manifest.json @@ -3,12 +3,12 @@ "id": "BeatTogether", "name": "BeatTogether", "author": "Goobwabber", - "version": "2.3.0", + "version": "2.2.1", "description": "A multiplayer private server for the modding community. Supports crossplay between PC and Quest.", - "gameVersion": "1.35.0", + "gameVersion": "1.37.5", "dependsOn": { "BSIPA": "^4.3.3", - "BeatSaberMarkupLanguage": "^1.9.0", + "BeatSaberMarkupLanguage": "^1.12.0", "SiraUtil": "^3.1.7", "MultiplayerCore": "^1.5.0" }