Skip to content

Commit

Permalink
Multiplayer seems to be working, as far as I can test with one person
Browse files Browse the repository at this point in the history
  • Loading branch information
bookdude13 committed Jan 9, 2025
1 parent 7f3b8a2 commit 10c077c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@

namespace SRPlaylistManager.Harmony
{
// TODO update tooltip

[HarmonyPatch(typeof(MultiplayerFavoritesController), nameof(MultiplayerFavoritesController.OnPointerDown), new Type[] { typeof(PointerEventData) })]
public class Patch_MultiplayerFavoritesController_OnPointerDown
{
public static bool Prefix(PointerEventData eventData)
public static bool Prefix(MultiplayerFavoritesController __instance, PointerEventData eventData)
{
// There isn't a SynthUIButton for this, it's handled directly...

SRPlaylistManager.Instance?.Log("MP Favorites Toggle OnPointerDown");

__instance.tooltip = "Select Playlists";

// Treat the click as the end to the hover, to hide the tooltip
//__instance.OnPointerExit(eventData);
__instance.isHovered = false;

SRPlaylistManager.Instance?.OnToggleMultiplayerPlaylistButton();

// Stop normal favorites triggering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ namespace SRPlaylistManager.Harmony
[HarmonyPatch(typeof(MultiplayerFavoritesController), nameof(MultiplayerFavoritesController.OnPointerEnter), new Type[] { typeof(PointerEventData) })]
public class Patch_MultiplayerFavoritesController_OnPointerEnter
{
public static void Prefix(MultiplayerFavoritesController __instance, PointerEventData eventData)
{
// Override tooltip text before any logic runs
__instance.tooltip = "Select Playlists";
}

public static void Postfix(MultiplayerFavoritesController __instance, PointerEventData eventData)
{
// Override tooltip text
// Make sure the tooltip stays overwritten after logic runs
__instance.tooltip = "Select Playlists";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Patch_SongSelectionManager_PlayPreviewAudio
public static void Prefix()
{
// Force some UI refreshing on first load. This was the first hook I could make work.
PlaylistManagementController.GetInstance.TryDisplayCorrectRemoveFavoriteButton();
PlaylistManagementController.GetInstance?.TryDisplayCorrectRemoveFavoriteButton();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ private ScrollablePanel CreatePlaylistPanel(GameObject toHide)
return panel;
}

protected virtual Vector3 GetPanelOffset() => Vector3.zero;

public void OpenMenu()
{
var playlists = playlistService.GetPlaylists();
Expand Down Expand Up @@ -92,6 +94,9 @@ public void OpenMenu()
if (playlistPanel == null)
{
playlistPanel = CreatePlaylistPanel(viewToHide);

// Offset panel as needed
playlistPanel.Panel.transform.localPosition += GetPanelOffset();
}

// Add items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class MultiplayerPlaylistMenuMonoBehavior : AbstractPlaylistMenuMonoBehav
{
public MultiplayerPlaylistMenuMonoBehavior(IntPtr ptr) : base(ptr) { }

private Vector3 _panelOffset = new Vector3(0f, 0f, 2f);
protected override Vector3 GetPanelOffset() => _panelOffset;

protected override GameObject GetToggledView()
{
// Find good parent so the panel can be seen
Expand Down

0 comments on commit 10c077c

Please sign in to comment.