Skip to content

Commit

Permalink
Merge pull request #160 from halsafar/v1.16.3-fixes
Browse files Browse the repository at this point in the history
V1.16.3 fixes
  • Loading branch information
halsafar authored Jul 22, 2021
2 parents b76a390 + 87616a3 commit 62b84ac
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 38 deletions.
16 changes: 9 additions & 7 deletions BeatModsReleaseTemplate.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SongBrowser

6.1.7
6.2.1

[email protected],[email protected]
[email protected],[email protected], [email protected],[email protected],BS [email protected]

Adds various sorting and filtering methods to the UI. Search, favorites, ranked, and unranked filters. Sort by BeatSaver and ScoreSaber statistics. Adds PP and other extra stats to the stat panel.

Expand All @@ -12,9 +12,11 @@ https://github.com/halsafar/BeatSaberSongBrowser
**Mod**: SongBrowser v6.1.6
**Dependencies**: SongCore, BSLM, SongDataCore
**Changelog**:
- Compatibility with PlaylistManager!
- Add new sort methods: BPM, Duration.
- Fix a few rare causes of exceptions.
**Looking For**:
- We are hoping to shake out any compatiblity issues PlaylistManager.
- Improved support with PlaylistManager and BeatSaberPlaylistLib (Thanks PixelBoom).
- BeatSaver song key is now checked against search terms.
- Prevent scrolling to top of list when adding/removing favorites in all level categories except Favorites.
- Fix deleting a song when viewing a Playlist.
- Filter by mod requirements (thanks @Meivyn )
**Download**:
- https://github.com/halsafar/BeatSaberSongBrowser/releases/tag/6.2.0

13 changes: 11 additions & 2 deletions SongBrowserPlugin/DataAccess/SongBrowserModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using IPA.Utilities;
using UnityEngine;
using Logger = SongBrowser.Logging.Logger;
using CustomJSONData;
using CustomJSONData.CustomBeatmap;

namespace SongBrowser
Expand Down Expand Up @@ -496,7 +495,17 @@ private List<IPreviewBeatmapLevel> FilterRequirements(List<IPreviewBeatmapLevel>
{
var difficulty = d as CustomLevelInfoSaveData.DifficultyBeatmap;

return difficulty.customData.Get<List<object>>("_requirements")?.Count > 0;
if (difficulty == null)
{
return false;
}

if (difficulty.customData.ContainsKey("_requirements"))
{
return ((IList<object>)difficulty.customData["_requirements"]).Count > 0;
}

return false;
});

if (hasRequirements)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

using HarmonyLib;
using HMUI;
using System;
using Logger = SongBrowser.Logging.Logger;

namespace SongBrowser.HarmonyPatches
{
[HarmonyPatch(typeof(FlowCoordinator))]
[HarmonyPatch("PresentFlowCoordinator", MethodType.Normal)]
class FlowCoordinator_PresentFlowCoordinator
{
static void Postfix(FlowCoordinator flowCoordinator, Action finishedCallback = null, ViewController.AnimationDirection animationDirection = ViewController.AnimationDirection.Horizontal, bool immediately = false, bool replaceTopViewController = false)
{
var flowType = flowCoordinator.GetType();
if (flowType == typeof(SoloFreePlayFlowCoordinator))
{
Logger.Info("Initializing SongBrowser for Single Player Mode");
SongBrowser.SongBrowserApplication.Instance.HandleSoloModeSelection();
}
else if (flowType == typeof(MultiplayerLevelSelectionFlowCoordinator))
{
Logger.Info("Initializing SongBrowser for Multiplayer Mode");
SongBrowser.SongBrowserApplication.Instance.HandleMultiplayerModeSelection();
}
else if (flowType == typeof(PartyFreePlayFlowCoordinator))
{
Logger.Info("Initializing SongBrowser for Party Mode");
SongBrowser.SongBrowserApplication.Instance.HandlePartyModeSelection();
}
else if (flowType == typeof(CampaignFlowCoordinator))
{
Logger.Info("Initializing SongBrowser for Multiplayer Mode");
SongBrowser.SongBrowserApplication.Instance.HandleCampaignModeSelection();
}

return;
}
}
}
17 changes: 17 additions & 0 deletions SongBrowserPlugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Reflection;
using IPA.Loader;
using Logger = SongBrowser.Logging.Logger;
using HarmonyLib;

namespace SongBrowser
{
Expand All @@ -17,11 +18,15 @@ public class Plugin
public static Plugin Instance { get; private set; }
public static IPA.Logging.Logger Log { get; private set; }

public const string HarmonyId = "com.halsafar.BeatSaber.SongBrowserPlugin";
internal static Harmony harmony;

[Init]
public void Init(IPA.Logging.Logger logger, PluginMetadata metadata)
{
Log = logger;
VersionNumber = metadata.Version?.ToString() ?? Assembly.GetExecutingAssembly().GetName().Version.ToString(3);
harmony = new Harmony(HarmonyId);
}

[OnStart]
Expand Down Expand Up @@ -52,5 +57,17 @@ private void OnMenuSceneLoadedFresh(ScenesTransitionSetupDataSO data)
Logger.Exception("Exception on fresh menu scene change: " + e);
}
}

[OnEnable]
public void OnEnable()
{
harmony.PatchAll(Assembly.GetExecutingAssembly());
}

[OnDisable]
public void OnDisable()
{
harmony.UnpatchAll(HarmonyId);
}
}
}
3 changes: 3 additions & 0 deletions SongBrowserPlugin/SongBrowser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
</PropertyGroup>

<ItemGroup>
<Reference Include="0Harmony">
<HintPath>D:\Games\Steam\SteamApps\common\Beat Saber\Libs\0Harmony.dll</HintPath>
</Reference>
<Reference Include="BeatSaberPlaylistsLib">
<HintPath>$(BeatSaberDir)\Libs\BeatSaberPlaylistsLib.dll</HintPath>
<Private>False</Private>
Expand Down
31 changes: 4 additions & 27 deletions SongBrowserPlugin/SongBrowserApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public void Start()
{
Logger.Trace("Start-SongBrowserApplication()");

InstallHandlers();

SongDataCore.Plugin.Songs.OnDataFinishedProcessing += OnScoreSaberDataDownloaded;

if (SongCore.Loader.AreSongsLoaded)
Expand Down Expand Up @@ -148,33 +146,12 @@ private void OnScoreSaberDataDownloaded()
}
}

/// <summary>
/// Install Our Handlers so we can react to ingame events.
/// </summary>
private void InstallHandlers()
{
// Append our own event to appropriate events so we can refresh the song list before the user sees it.
MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll<MainFlowCoordinator>().First();
Button soloFreePlayButton = Resources.FindObjectsOfTypeAll<Button>().First(x => x.name == "SoloButton");
Button partyFreePlayButton = Resources.FindObjectsOfTypeAll<Button>().First(x => x.name == "PartyButton");
Button campaignButton = Resources.FindObjectsOfTypeAll<Button>().First(x => x.name == "CampaignButton");

soloFreePlayButton.onClick.AddListener(HandleSoloModeSelection);
partyFreePlayButton.onClick.AddListener(HandlePartyModeSelection);
campaignButton.onClick.AddListener(HandleCampaignModeSelection);

// Append to the 'EditButton' in the host lobby setup, this lets us seperate out Multiplayer easily.
var hostLobbyVc = Resources.FindObjectsOfTypeAll<HostLobbySetupViewController>().First();
var editButton = hostLobbyVc.GetComponentsInChildren<Button>().First(x => x.name == "EditButton");
editButton.onClick.AddListener(HandleMultiplayerModeSelection);
}

/// <summary>
/// Handle Solo Mode
/// </summary>
/// <param name="arg1"></param>
/// <param name="arg2"></param>
private void HandleSoloModeSelection()
public void HandleSoloModeSelection()
{
Logger.Trace("HandleSoloModeSelection()");
HandleModeSelection(MainMenuViewController.MenuButton.SoloFreePlay);
Expand All @@ -186,7 +163,7 @@ private void HandleSoloModeSelection()
/// </summary>
/// <param name="arg1"></param>
/// <param name="arg2"></param>
private void HandlePartyModeSelection()
public void HandlePartyModeSelection()
{
Logger.Trace("HandlePartyModeSelection()");
HandleModeSelection(MainMenuViewController.MenuButton.Party);
Expand All @@ -198,7 +175,7 @@ private void HandlePartyModeSelection()
/// </summary>
/// <param name="arg1"></param>
/// <param name="arg2"></param>
private void HandleCampaignModeSelection()
public void HandleCampaignModeSelection()
{
Logger.Trace("HandleCampaignModeSelection()");
HandleModeSelection(MainMenuViewController.MenuButton.SoloCampaign);
Expand All @@ -211,7 +188,7 @@ private void HandleCampaignModeSelection()
/// </summary>
/// <param name="arg1"></param>
/// <param name="arg2"></param>
private void HandleMultiplayerModeSelection()
public void HandleMultiplayerModeSelection()
{
Logger.Trace("HandleCampaignModeSelection()");
HandleModeSelection(MainMenuViewController.MenuButton.Multiplayer);
Expand Down
4 changes: 2 additions & 2 deletions SongBrowserPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"$schema": "https://raw.githubusercontent.com/bsmg/BSIPA-MetadataFileSchema/master/Schema.json",
"author": "Halsafar",
"description": "Adds sort and filter features to the level selection UI.",
"gameVersion": "1.16.1",
"gameVersion": "1.16.3",
"id": "SongBrowser",
"name": "Song Browser",
"version": "6.2.1",
"version": "6.2.2",
"dependsOn": {
"SongCore": "^3.4.0",
"SongDataCore": "^1.3.8",
Expand Down

0 comments on commit 62b84ac

Please sign in to comment.