internal static void Postfix(ref GameObject __result, string levelPlaylistPath) { LevelPlaylistCompoundData data = __result.gameObject.AddComponent <LevelPlaylistCompoundData>(); data.FilePath = levelPlaylistPath; data.Playlist = __result.GetComponent <LevelPlaylist>(); }
public static bool IsResourcesPlaylist(this LevelPlaylist playlist) { LevelPlaylistCompoundData data = playlist.gameObject.GetComponent <LevelPlaylistCompoundData>(); if (!data) { return(true); } string path = new FileInfo(data.FilePath).FullName.UniformPathName(); string resourcesPath = new DirectoryInfo(Path.Combine(Application.dataPath, "Resources")).FullName.UniformPathName(); return(path.StartsWith(resourcesPath, StringComparison.InvariantCultureIgnoreCase)); }
internal static void Postfix(LevelGridGrid __instance) { if (!Mod.Instance.Config.EnableDeletePlaylistButton) { return; } LevelPlaylist playlist = __instance.playlist_; LevelPlaylistCompoundData data = playlist.GetComponent <LevelPlaylistCompoundData>(); if (data && !playlist.IsResourcesPlaylist()) { G.Sys.MenuPanelManager_.SetBottomLeftActionButton(InternalResources.Constants.INPUT_DELETE_PLAYLIST, "DELETE PLAYLIST"); } }
internal static void Postfix(LevelGridGrid __instance) { if (!Mod.Instance.Config.EnableDeletePlaylistButton) { return; } LevelPlaylist playlist = __instance.playlist_; LevelPlaylistCompoundData data = playlist.GetComponent <LevelPlaylistCompoundData>(); if (data && !playlist.IsResourcesPlaylist() && G.Sys.InputManager_.GetKeyUp(InternalResources.Constants.INPUT_DELETE_PLAYLIST)) { MessageBox.Create($"Are you sure you want to remove [u]{playlist.Name_}[/u]?", "DELETE PLAYLIST") .SetButtons(MessageButtons.YesNo) .OnConfirm(() => { try { FileEx.Delete(data.FilePath); playlist.Destroy(); Object.DestroyImmediate(data.gameObject); } catch (System.Exception e) { Mod.Instance.Logger.Exception(e); } finally { G.Sys.MenuPanelManager_.Pop(); __instance.levelGridMenu_.CreateEntries(); } }) .Show(); } }