Skip to content

Commit

Permalink
Make ModdedLobbyFilterDropdown namespace consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
legoandmars authored Feb 4, 2024
1 parent 15aa9f5 commit 13a3d5c
Showing 1 changed file with 49 additions and 50 deletions.
99 changes: 49 additions & 50 deletions LobbyCompatibility/Behaviours/ModdedLobbyFilterDropdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,58 @@
using TMPro;
using UnityEngine;

namespace LobbyCompatibility.Behaviours
namespace LobbyCompatibility.Behaviours;

/// <summary>
/// Used to handle any changes to the <see cref="ModdedLobbyFilter"/> when searching for lobbies.
/// </summary>
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<SteamLobbyManager>();
}

/// <summary>
/// Registers the <see cref="TMP_Dropdown"/>. Required for syncing the default config with UI.
/// </summary>
/// <param name="dropdown"> The dropdown. </param>
public void SetDropdown(TMP_Dropdown dropdown)
{
_dropdown = dropdown;
}

/// <summary>
/// Called automatically when the <see cref="TMP_Dropdown"/> value is updated.
/// </summary>
/// <param name="index"> The index of the new filter type. </param>
public void ChangeFilterType(int index)
{
UpdateLobbyFilter((ModdedLobbyFilter)index);

if (_steamLobbyManager != null)
_steamLobbyManager.RefreshServerListButton();
}

/// <summary>
/// Used to handle any changes to the <see cref="ModdedLobbyFilter"/> when searching for lobbies.
/// Updates the <see cref="ModdedLobbyFilter"/> internally.
/// This will be called when the user changes the value manually, and when the menu scene is opened/reopened.
/// </summary>
internal class ModdedLobbyFilterDropdown : MonoBehaviour
/// <param name="lobbyFilter"> The new <see cref="ModdedLobbyFilter"/> to use. </param>
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<SteamLobbyManager>();
}

/// <summary>
/// Registers the <see cref="TMP_Dropdown"/>. Required for syncing the default config with UI.
/// </summary>
/// <param name="dropdown"> The dropdown. </param>
public void SetDropdown(TMP_Dropdown dropdown)
{
_dropdown = dropdown;
}

/// <summary>
/// Called automatically when the <see cref="TMP_Dropdown"/> value is updated.
/// </summary>
/// <param name="index"> The index of the new filter type. </param>
public void ChangeFilterType(int index)
{
UpdateLobbyFilter((ModdedLobbyFilter)index);

if (_steamLobbyManager != null)
_steamLobbyManager.RefreshServerListButton();
}

/// <summary>
/// Updates the <see cref="ModdedLobbyFilter"/> internally.
/// This will be called when the user changes the value manually, and when the menu scene is opened/reopened.
/// </summary>
/// <param name="lobbyFilter"> The new <see cref="ModdedLobbyFilter"/> to use. </param>
private void UpdateLobbyFilter(ModdedLobbyFilter lobbyFilter)
{
LobbyFilter = lobbyFilter;
}
LobbyFilter = lobbyFilter;
}
}

0 comments on commit 13a3d5c

Please sign in to comment.