diff --git a/LobbyCompatibility/Behaviours/ModdedLobbyFilterDropdown.cs b/LobbyCompatibility/Behaviours/ModdedLobbyFilterDropdown.cs index 0bd44ae..6743977 100644 --- a/LobbyCompatibility/Behaviours/ModdedLobbyFilterDropdown.cs +++ b/LobbyCompatibility/Behaviours/ModdedLobbyFilterDropdown.cs @@ -2,59 +2,58 @@ using TMPro; using UnityEngine; -namespace LobbyCompatibility.Behaviours +namespace LobbyCompatibility.Behaviours; + +/// +/// Used to handle any changes to the when searching for lobbies. +/// +internal class ModdedLobbyFilterDropdown : MonoBehaviour { + public ModdedLobbyFilter LobbyFilter { get; private set; } + public static ModdedLobbyFilterDropdown? Instance { get; private set; } + private TMP_Dropdown? _dropdown; + private SteamLobbyManager? _steamLobbyManager; + + public void Awake() + { + // Set default to whatever the user has configured + UpdateLobbyFilter(LobbyCompatibilityPlugin.Config?.DefaultModdedLobbyFilter.Value ?? ModdedLobbyFilter.CompatibleFirst); + + if (_dropdown != null) + _dropdown.SetValueWithoutNotify((int)LobbyFilter); + + Instance = this; + _steamLobbyManager = FindObjectOfType(); + } + + /// + /// Registers the . Required for syncing the default config with UI. + /// + /// The dropdown. + public void SetDropdown(TMP_Dropdown dropdown) + { + _dropdown = dropdown; + } + + /// + /// Called automatically when the value is updated. + /// + /// The index of the new filter type. + public void ChangeFilterType(int index) + { + UpdateLobbyFilter((ModdedLobbyFilter)index); + + if (_steamLobbyManager != null) + _steamLobbyManager.RefreshServerListButton(); + } + /// - /// Used to handle any changes to the when searching for lobbies. + /// Updates the internally. + /// This will be called when the user changes the value manually, and when the menu scene is opened/reopened. /// - internal class ModdedLobbyFilterDropdown : MonoBehaviour + /// The new to use. + private void UpdateLobbyFilter(ModdedLobbyFilter lobbyFilter) { - public ModdedLobbyFilter LobbyFilter { get; private set; } - public static ModdedLobbyFilterDropdown? Instance { get; private set; } - private TMP_Dropdown? _dropdown; - private SteamLobbyManager? _steamLobbyManager; - - public void Awake() - { - // Set default to whatever the user has configured - UpdateLobbyFilter(LobbyCompatibilityPlugin.Config?.DefaultModdedLobbyFilter.Value ?? ModdedLobbyFilter.CompatibleFirst); - - if (_dropdown != null) - _dropdown.SetValueWithoutNotify((int)LobbyFilter); - - Instance = this; - _steamLobbyManager = FindObjectOfType(); - } - - /// - /// Registers the . Required for syncing the default config with UI. - /// - /// The dropdown. - public void SetDropdown(TMP_Dropdown dropdown) - { - _dropdown = dropdown; - } - - /// - /// Called automatically when the value is updated. - /// - /// The index of the new filter type. - public void ChangeFilterType(int index) - { - UpdateLobbyFilter((ModdedLobbyFilter)index); - - if (_steamLobbyManager != null) - _steamLobbyManager.RefreshServerListButton(); - } - - /// - /// Updates the internally. - /// This will be called when the user changes the value manually, and when the menu scene is opened/reopened. - /// - /// The new to use. - private void UpdateLobbyFilter(ModdedLobbyFilter lobbyFilter) - { - LobbyFilter = lobbyFilter; - } + LobbyFilter = lobbyFilter; } }