generated from Distance-Modding/Template.CSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Main Menu Playlist Mode & Rate this level button (v1.1.3.0)
Refactors: * Moved some common duplicate code to new extensions class for LevelSelectMenuLogic. * Cleaned up base color handling for Personal playlists to reference a single readonly field. Also added `GetBaseColor` for use outside of the extensions class. * Moved where LevelPlaylistCompoundData was created for LevelSelectMenuLogic's tempPlaylist, so that it's done right after the tempPlaylist is created. Fixes: * Fixed PlaylistFileDeleted event assigning wrong value to name field (field is currently unused, so no functional difference). * Fixed LevelSelectMenuLogic's tempPlaylist state so that it'll always be reset when entering the Playlist Mode menu. * Also fixed the file name input field for saving/loading in Playlist Mode, so that the field doesn't remember *echoes of a past playlsit*. New Options: * Finally added options for previously always-on settings: * Enable Playlist Options menu * Enable *Visit Workshop page* button for Main Menus * Enable Playlist Mode when in the Choose Main Menu display type. * Re-introduce the *Rate this level* button in the Advanced level select menu. * Hide unused buttons in the Advanced level select menu for the Choose Main Menu display type.
- Loading branch information
1 parent
e9d0922
commit bec5a5c
Showing
23 changed files
with
873 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Distance.LevelSelectAdditions/Extensions/Assembly-CSharp/LevelSelectMenuLogic.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Distance.LevelSelectAdditions.Scripts; | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace Distance.LevelSelectAdditions.Extensions | ||
{ | ||
public static class LevelSelectMenuLogicExtensions | ||
{ | ||
public static void UpdateQuickPlaylistText(this LevelSelectMenuLogic levelSelectMenu) | ||
{ | ||
if (!levelSelectMenu.tempPlaylist_.Name_.IsEmptyPlaylistName()) | ||
{ | ||
levelSelectMenu.quickPlaylistLabel_.text = levelSelectMenu.tempPlaylist_.Name_; // Update the label showing the playlist name | ||
} | ||
|
||
// Preserve playlist name color (when not using `[c][/c] tag). | ||
levelSelectMenu.tempPlaylist_.GetBaseColor(out Color baseColor, false); | ||
levelSelectMenu.quickPlaylistLabel_.color = baseColor; | ||
} | ||
|
||
public static void UpdateBottomLeftButtonVisibility(this LevelSelectMenuLogic levelSelectMenu) | ||
{ | ||
// Make sure to always display these buttons when in Playlist Mode. | ||
if (Mod.Instance.Config.HideChooseMainMenuUnusedButtons && !levelSelectMenu.showingLevelPlaylist_) | ||
{ | ||
// Hide unused buttons when in the Choose Main Menu display type. | ||
bool isMainMenu = levelSelectMenu.displayType_ == LevelSelectMenuAbstract.DisplayType.ChooseMainMenuLevel; | ||
levelSelectMenu.createPlaylistButton_.SetActive(!isMainMenu || Mod.Instance.Config.EnableChooseMainMenuQuickPlaylist); | ||
levelSelectMenu.showLeaderboardsButton_.SetActive(!isMainMenu); | ||
} | ||
else | ||
{ | ||
levelSelectMenu.createPlaylistButton_.SetActive(true); | ||
levelSelectMenu.showLeaderboardsButton_.SetActive(true); | ||
} | ||
} | ||
|
||
public static void ResetTempPlaylistState(this LevelSelectMenuLogic levelSelectMenu) | ||
{ | ||
levelSelectMenu.tempPlaylist_.Name_ = nameof(LevelPlaylist); // restore default uninitialized name | ||
|
||
var playlistData = levelSelectMenu.tempPlaylist_.GetComponent<LevelPlaylistCompoundData>(); | ||
if (playlistData) | ||
{ | ||
playlistData.FilePath = null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
...ce.LevelSelectAdditions/Harmony/Assembly-CSharp/LevelSelectMenuLogic/ClearTempPlaylist.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
using Distance.LevelSelectAdditions.Scripts; | ||
using Distance.LevelSelectAdditions.Extensions; | ||
using HarmonyLib; | ||
|
||
namespace Distance.LevelSelectAdditions.Harmony | ||
{ | ||
/// <summary> | ||
/// Patch to stop tempPlaylist_ from preserving its previous name. This can effect using the Rename button, | ||
/// as well as the initial "QUICK PLAYLIST..." text due to the SetupLevelPlaylistVisuals patch. | ||
/// <para/> | ||
/// Also includes patch to hide unused Leaderboards (and optionally Playlist Mode) buttons when in the Choose Main Menu display type. | ||
/// </summary> | ||
[HarmonyPatch(typeof(LevelSelectMenuLogic), nameof(LevelSelectMenuLogic.ClearTempPlaylist))] | ||
internal static class LevelSelectMenuLogic__ClearTempPlaylist | ||
{ | ||
[HarmonyPostfix] | ||
internal static void Postfix(LevelSelectMenuLogic __instance) | ||
{ | ||
__instance.tempPlaylist_.Name_ = nameof(LevelPlaylist); // restore default uninitialized name | ||
__instance.ResetTempPlaylistState(); | ||
|
||
var playlistData = __instance.tempPlaylist_.GetComponent<LevelPlaylistCompoundData>(); | ||
if (playlistData) | ||
{ | ||
playlistData.FilePath = null; | ||
} | ||
// We're exiting Playlist Mode, so we need to re-evaluate bottom left button visibility. | ||
__instance.UpdateBottomLeftButtonVisibility(); | ||
} | ||
} | ||
} |
Oops, something went wrong.