Skip to content

Commit

Permalink
Merge pull request #5 from bookdude13/remastered
Browse files Browse the repository at this point in the history
Remastered + UI revamp
  • Loading branch information
bookdude13 authored Jan 9, 2025
2 parents 5630b5d + 10c077c commit 7f293b3
Show file tree
Hide file tree
Showing 29 changed files with 985 additions and 538 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "SRModCore"]
path = SRModCore
url = [email protected]:bookdude13/SRModCore
8 changes: 0 additions & 8 deletions CopyToSR.bat

This file was deleted.

18 changes: 0 additions & 18 deletions PrepareRelease.bat

This file was deleted.

1 change: 1 addition & 0 deletions SRModCore
Submodule SRModCore added at 5e0e8b

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using HarmonyLib;
using System;
using Il2CppUtil.Controller;
using UnityEngine.EventSystems;

namespace SRPlaylistManager.Harmony
{

[HarmonyPatch(typeof(MultiplayerFavoritesController), nameof(MultiplayerFavoritesController.OnPointerDown), new Type[] { typeof(PointerEventData) })]
public class Patch_MultiplayerFavoritesController_OnPointerDown
{
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
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using HarmonyLib;
using System;
using Il2CppUtil.Controller;
using UnityEngine.EventSystems;

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)
{
// Make sure the tooltip stays overwritten after logic runs
__instance.tooltip = "Select Playlists";
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,64 @@
using HarmonyLib;
using Synth.SongSelection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using Il2CppTMPro;
using Il2CppUtil.Controller;
using Il2Cpp;
using SRModCore;
using UnityEngine;
using Util.Controller;
using static MelonLoader.MelonLogger;

namespace SRPlaylistManager.Harmony
{
[HarmonyPatch(typeof(PlaylistManagementController), nameof(PlaylistManagementController.TryDisplayCorrectRemoveFavoriteButton))]
public class Patch_PlaylistManagementController_TryDisplayCorrectRemoveFavoriteButton
{
public static void Postfix(GameObject ___pf_RemoveFromPlaylistButton, GameObject ___pf_SongAddFavoriteButton)
public static void Prefix(PlaylistManagementController __instance)
{
// Override the remove button text
___pf_RemoveFromPlaylistButton?.GetComponentInChildren<TMP_Text>(true)?.SetText("Playlist", true);
SetupToggleButton(__instance.pf_RemoveFromPlaylistButton);
SetupToggleButton(__instance.pf_SongAddFavoriteButton);

// TODO figure out how to do the heart visible or not based on if in _any_ playlist

//// Override the remove button text
//var btnText = __instance.pf_RemoveFromPlaylistButton?.GetComponentInChildren<TMP_Text>(true);
//SRPlaylistManager.Instance.Log("Remove favorite btn text: " + btnText);
//btnText?.SetText("Playlist", true);

//// Also add in our own behavior
//var button = __instance.pf_RemoveFromPlaylistButton?.GetComponentInChildren<SynthUIButton>();
//SRPlaylistManager.Instance.Log("Remove favorite btn: " + button);
//button.WhenClicked = new UnityEngine.Events.UnityEvent();
//button.WhenClicked.AddListener(new Action(() => { SRPlaylistManager.Instance.OnToggleMainMenuPlaylistButton(); }));

// Hide icon. Still off-center, but not as obviously a different button :)
___pf_SongAddFavoriteButton?.transform.Find("Icon")?.gameObject.SetActive(false);
//__instance.pf_SongAddFavoriteButton?.transform.Find("Icon")?.gameObject.SetActive(false);
}

private static void SetupToggleButton(GameObject buttonGO)
{
if (buttonGO == null)
return;

// Override the remove button text
var btnTexts = buttonGO.GetComponentsInChildren<TMP_Text>(true);
foreach (var btnText in btnTexts)
{
btnText?.SetText("Select Playlists", true);
}

// Make sure the tooltip doesn't linger when we open up the playlist selection
var button = buttonGO.GetComponentInChildren<SynthUIButton>();
button.hideTooltipOnClick = true;

// Also add in our own behavior
if (button != null)
{
button.WhenClicked = new UnityEngine.Events.UnityEvent();
button.WhenClicked.AddListener(new Action(() => {
// Toggle playlist selection
SRPlaylistManager.Instance.OnToggleMainMenuPlaylistButton();
}));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using HarmonyLib;
using Il2CppSynth.SongSelection;
using Il2CppUtil.Controller;

namespace SRPlaylistManager.Harmony
{
[HarmonyPatch(typeof(SongSelectionManager), nameof(SongSelectionManager.PlayPreviewAudio))]
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();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using HarmonyLib;
using Synth.SongSelection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Util.Controller;
using Il2CppSynth.SongSelection;

namespace SRPlaylistManager.Harmony
{
Expand All @@ -14,7 +8,7 @@ public class Patch_SongSelectionManager_ToggleFavorite
{
public static bool Prefix()
{
SRPlaylistManager.Instance?.OnTogglePlaylistButton();
SRPlaylistManager.Instance?.OnToggleMainMenuPlaylistButton();

// Don't follow the normal "Add/Remove Favorites" logic
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
using HarmonyLib;
using Synth.SongSelection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using Util.Controller;
using Il2CppSynth.SongSelection;
using SRModCore;

namespace SRPlaylistManager.Harmony
{
[HarmonyPatch(typeof(SongSelectionManager), "UpdateFavoriteButtonState")]
public class Patch_SongSelectionManager_UpdateFavoriteButtonState
{
public static bool Prefix(TMP_Text ___favoriteBtnLabel)
public static bool Prefix(SongSelectionManager __instance)
{
// Don't follow the normal text changes
// TODO better text and do translation
___favoriteBtnLabel.SetText("Playlist", true);
__instance.favoriteBtn.toolTipLabelNormal = "Select Playlists";
__instance.favoriteBtn.toolTipLabelSelected = "Select Playlists";

return false;
__instance.favoriteBtn.synthUIButton.SetText("Select Playlists");

// TODO set state based on if the current song is in _any_ playlist, not just favorites?

return true;
}
}
}
2 changes: 1 addition & 1 deletion SRPlaylistManager/Models/PanelItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace SRPlaylistManager.Models
{
internal interface PanelItem
public interface PanelItem
{
GameObject Setup(GameObject item);
}
Expand Down
Loading

0 comments on commit 7f293b3

Please sign in to comment.