Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made the mod list UI not show if there is a custom disconnect reason #75

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions LobbyCompatibility/Patches/MenuManagerPostfix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace LobbyCompatibility.Patches;
[HarmonyWrapSafe]
internal static class MenuManagerPostfix
{
[HarmonyPostfix]
private static void Postfix(MenuManager __instance)
[HarmonyPrefix]
private static void Prefix(MenuManager __instance)
{
// Don't run on startup screen
if (__instance.isInitScene)
Expand All @@ -30,10 +30,7 @@ private static void Postfix(MenuManager __instance)
return;

LobbyCompatibilityPlugin.Logger?.LogInfo("Initializing menu UI.");

// Set challenge moon leaderboard title text to not wrap halfway through
__instance.leaderboardHeaderText.rectTransform.offsetMax = new Vector2(2000, __instance.leaderboardHeaderText.rectTransform.offsetMax.y);


// Setup hover notification/tooltip UI
var parent = __instance.menuNotification.transform.parent;

Expand All @@ -53,6 +50,21 @@ private static void Postfix(MenuManager __instance)
modListPanelObject.transform.SetParent(parent);
var modListPanel = modListPanelObject.AddComponent<ModListPanel>();
modListPanel.SetupPanel(modListPanelNotification, lobbyListScrollView, privatePublicDescription);
}

[HarmonyPostfix]
private static void Postfix(MenuManager __instance)
{
// Don't run on startup screen
if (__instance.isInitScene)
return;

var listPanel = __instance.serverListUIContainer.transform.Find("ListPanel");
if (listPanel == null)
return;

// Set challenge moon leaderboard title text to not wrap halfway through
__instance.leaderboardHeaderText.rectTransform.offsetMax = new Vector2(2000, __instance.leaderboardHeaderText.rectTransform.offsetMax.y);

// Make refresh button a more compact image so we have space for our custom dropdown
var refreshButton = listPanel.Find("RefreshButton")?.GetComponent<Button>();
Expand Down
11 changes: 7 additions & 4 deletions LobbyCompatibility/Patches/SetLoadingScreenPrefix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ private static bool Prefix(bool isLoading, RoomEnter result, MenuManager __insta

if (result != RoomEnter.Error)
return true;

LobbyCompatibilityPlugin.Logger?.LogDebug("Error while joining! Logging Diff...");
LobbyCompatibilityPlugin.Logger?.LogDebug(
LobbyHelper.LatestLobbyDiff.PluginDiffs.Join(converter: diff => diff.GetDisplayText()));

if (!string.IsNullOrEmpty(GameNetworkManager.Instance.disconnectionReasonMessage))
return true;

__instance.MenuAudio.volume = 0.5f;
__instance.menuButtons.SetActive(true);
Expand All @@ -31,10 +38,6 @@ private static bool Prefix(bool isLoading, RoomEnter result, MenuManager __insta

if (ModListPanel.Instance != null)
ModListPanel.Instance.DisplayNotification(LobbyHelper.LatestLobbyDiff, "Error while joining...");

LobbyCompatibilityPlugin.Logger?.LogDebug("Error while joining! Logging Diff...");
LobbyCompatibilityPlugin.Logger?.LogDebug(
LobbyHelper.LatestLobbyDiff.PluginDiffs.Join(converter: diff => diff.GetDisplayText()));

return false;
}
Expand Down
Loading