|
@@ -8,6 +8,8 @@ using VRUI;
|
|
|
using SongBrowserPlugin.DataAccess;
|
|
|
using System.IO;
|
|
|
using SongLoaderPlugin;
|
|
|
+using System.Security.Cryptography;
|
|
|
+using System.Text;
|
|
|
|
|
|
namespace SongBrowserPlugin.UI
|
|
|
{
|
|
@@ -18,6 +20,9 @@ namespace SongBrowserPlugin.UI
|
|
|
{
|
|
|
// Logging
|
|
|
public const String Name = "SongBrowserUI";
|
|
|
+
|
|
|
+ private const float SEGMENT_PERCENT = 0.1f;
|
|
|
+
|
|
|
private Logger _log = new Logger(Name);
|
|
|
|
|
|
// Beat Saber UI Elements
|
|
@@ -28,6 +33,8 @@ namespace SongBrowserPlugin.UI
|
|
|
private StandardLevelSelectionNavigationController _levelSelectionNavigationController;
|
|
|
private StandardLevelListTableView _levelListTableView;
|
|
|
private RectTransform _tableViewRectTransform;
|
|
|
+ private Button _tableViewPageUpButton;
|
|
|
+ private Button _tableViewPageDownButton;
|
|
|
|
|
|
// New UI Elements
|
|
|
private List<SongSortButton> _sortButtonGroup;
|
|
@@ -35,7 +42,11 @@ namespace SongBrowserPlugin.UI
|
|
|
private String _addFavoriteButtonText = null;
|
|
|
private SimpleDialogPromptViewController _simpleDialogPromptViewControllerPrefab;
|
|
|
private SimpleDialogPromptViewController _deleteDialog;
|
|
|
- private Button _deleteButton;
|
|
|
+ private Button _deleteButton;
|
|
|
+ private Button _pageUpTenPercent;
|
|
|
+ private Button _pageDownTenPercent;
|
|
|
+ private SearchKeyboardViewController _searchViewController;
|
|
|
+
|
|
|
|
|
|
// Debug
|
|
|
private int _sortButtonLastPushedIndex = 0;
|
|
@@ -119,74 +130,63 @@ namespace SongBrowserPlugin.UI
|
|
|
|
|
|
try
|
|
|
{
|
|
|
+ // Gather some transforms and templates to use.
|
|
|
+ RectTransform sortButtonTransform = this._levelSelectionNavigationController.transform as RectTransform;
|
|
|
+ RectTransform otherButtonTransform = this._levelDetailViewController.transform as RectTransform;
|
|
|
+ Button sortButtonTemplate = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "PlayButton"));
|
|
|
+ Button otherButtonTemplate = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "QuitButton"));
|
|
|
+
|
|
|
// Resize some of the UI
|
|
|
_tableViewRectTransform = _levelListViewController.GetComponentsInChildren<RectTransform>().First(x => x.name == "TableViewContainer");
|
|
|
_tableViewRectTransform.sizeDelta = new Vector2(0f, -20f);
|
|
|
_tableViewRectTransform.anchoredPosition = new Vector2(0f, -2.5f);
|
|
|
|
|
|
- RectTransform _pageUp = _tableViewRectTransform.GetComponentsInChildren<RectTransform>().First(x => x.name == "PageUpButton");
|
|
|
- _pageUp.anchoredPosition = new Vector2(0f, -1f);
|
|
|
+ _tableViewPageUpButton = _tableViewRectTransform.GetComponentsInChildren<Button>().First(x => x.name == "PageUpButton");
|
|
|
+ (_tableViewPageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -1f);
|
|
|
+
|
|
|
+ _tableViewPageDownButton = _tableViewRectTransform.GetComponentsInChildren<Button>().First(x => x.name == "PageDownButton");
|
|
|
+ (_tableViewPageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 1f);
|
|
|
|
|
|
- RectTransform _pageDown = _tableViewRectTransform.GetComponentsInChildren<RectTransform>().First(x => x.name == "PageDownButton");
|
|
|
- _pageDown.anchoredPosition = new Vector2(0f, 1f);
|
|
|
-
|
|
|
// Create Sorting Songs By-Buttons
|
|
|
_log.Debug("Creating sort by buttons...");
|
|
|
-
|
|
|
- RectTransform rect = this._levelSelectionNavigationController.transform as RectTransform;
|
|
|
+
|
|
|
Sprite arrowIcon = SongBrowserApplication.Instance.CachedIcons["ArrowIcon"];
|
|
|
|
|
|
- System.Action<SongSortMode> onSortButtonClickEvent = delegate (SongSortMode sortMode) {
|
|
|
- _log.Debug("Sort button - {0} - pressed.", sortMode.ToString());
|
|
|
- SongBrowserModel.LastSelectedLevelId = null;
|
|
|
-
|
|
|
- if (_model.Settings.sortMode == sortMode)
|
|
|
- {
|
|
|
- _model.ToggleInverting();
|
|
|
- }
|
|
|
-
|
|
|
- _model.Settings.sortMode = sortMode;
|
|
|
- _model.Settings.Save();
|
|
|
-
|
|
|
- UpdateSongList();
|
|
|
- RefreshSongList();
|
|
|
- };
|
|
|
-
|
|
|
- Button sortButtonTemplate = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "PlayButton"));
|
|
|
- Button otherButtonTemplate = Resources.FindObjectsOfTypeAll<Button>().First(x => (x.name == "QuitButton"));
|
|
|
-
|
|
|
- float fontSize = 2.75f;
|
|
|
- float buttonWidth = 17.0f;
|
|
|
+ float fontSize = 2.5f;
|
|
|
+ float buttonWidth = 14.0f;
|
|
|
float buttonHeight = 5.0f;
|
|
|
float buttonX = 68.0f;
|
|
|
float buttonY = 74.5f;
|
|
|
|
|
|
string[] buttonNames = new string[]
|
|
|
{
|
|
|
- "Favorite", "Song", "Author", "Original", "Newest", "PlayCount", "Random"
|
|
|
+ "Favorite", "Song", "Author", "Original", "Newest", "Plays", "Random", "Search"
|
|
|
};
|
|
|
|
|
|
SongSortMode[] sortModes = new SongSortMode[]
|
|
|
{
|
|
|
- SongSortMode.Favorites, SongSortMode.Default, SongSortMode.Author, SongSortMode.Original, SongSortMode.Newest, SongSortMode.PlayCount, SongSortMode.Random
|
|
|
+ SongSortMode.Favorites, SongSortMode.Default, SongSortMode.Author, SongSortMode.Original, SongSortMode.Newest, SongSortMode.PlayCount, SongSortMode.Random, SongSortMode.Search
|
|
|
+ };
|
|
|
+
|
|
|
+ System.Action<SongSortMode>[] onClickEvents = new Action<SongSortMode>[]
|
|
|
+ {
|
|
|
+ onSortButtonClickEvent, onSortButtonClickEvent, onSortButtonClickEvent, onSortButtonClickEvent, onSortButtonClickEvent, onSortButtonClickEvent, onSortButtonClickEvent, onSearchButtonClickEvent
|
|
|
};
|
|
|
|
|
|
_sortButtonGroup = new List<SongSortButton>();
|
|
|
for (int i = 0; i < buttonNames.Length; i++)
|
|
|
{
|
|
|
- _sortButtonGroup.Add(UIBuilder.CreateSortButton(rect, sortButtonTemplate, arrowIcon, buttonNames[i], fontSize, buttonX, buttonY, buttonWidth, buttonHeight, sortModes[i], onSortButtonClickEvent));
|
|
|
+ _sortButtonGroup.Add(UIBuilder.CreateSortButton(sortButtonTransform, sortButtonTemplate, arrowIcon, buttonNames[i], fontSize, buttonX, buttonY, buttonWidth, buttonHeight, sortModes[i], onClickEvents[i]));
|
|
|
buttonX -= buttonWidth;
|
|
|
}
|
|
|
|
|
|
// Creaate Add to Favorites Button
|
|
|
- _log.Debug("Creating add to favorites button...");
|
|
|
-
|
|
|
- RectTransform transform = this._levelDetailViewController.transform as RectTransform;
|
|
|
- _addFavoriteButton = UIBuilder.CreateUIButton(transform, otherButtonTemplate);
|
|
|
+ _log.Debug("Creating add to favorites button...");
|
|
|
+ _addFavoriteButton = UIBuilder.CreateUIButton(otherButtonTransform, otherButtonTemplate);
|
|
|
(_addFavoriteButton.transform as RectTransform).anchoredPosition = new Vector2(40f, 5.75f);
|
|
|
(_addFavoriteButton.transform as RectTransform).sizeDelta = new Vector2(10f, 10f);
|
|
|
UIBuilder.SetButtonText(ref _addFavoriteButton, _addFavoriteButtonText);
|
|
|
- UIBuilder.SetButtonTextSize(ref _addFavoriteButton, 3);
|
|
|
+ UIBuilder.SetButtonTextSize(ref _addFavoriteButton, fontSize);
|
|
|
UIBuilder.SetButtonIconEnabled(ref _addFavoriteButton, false);
|
|
|
_addFavoriteButton.onClick.RemoveAllListeners();
|
|
|
_addFavoriteButton.onClick.AddListener(delegate () {
|
|
@@ -204,20 +204,29 @@ namespace SongBrowserPlugin.UI
|
|
|
|
|
|
// Create delete button
|
|
|
_log.Debug("Creating delete button...");
|
|
|
-
|
|
|
- transform = this._levelDetailViewController.transform as RectTransform;
|
|
|
- _deleteButton = UIBuilder.CreateUIButton(transform, otherButtonTemplate);
|
|
|
+ _deleteButton = UIBuilder.CreateUIButton(otherButtonTransform, otherButtonTemplate);
|
|
|
(_deleteButton.transform as RectTransform).anchoredPosition = new Vector2(46f, 0f);
|
|
|
(_deleteButton.transform as RectTransform).sizeDelta = new Vector2(15f, 5f);
|
|
|
UIBuilder.SetButtonText(ref _deleteButton, "Delete");
|
|
|
- UIBuilder.SetButtonTextSize(ref _deleteButton, 3);
|
|
|
+ UIBuilder.SetButtonTextSize(ref _deleteButton, fontSize);
|
|
|
UIBuilder.SetButtonIconEnabled(ref _deleteButton, false);
|
|
|
_deleteButton.onClick.RemoveAllListeners();
|
|
|
_deleteButton.onClick.AddListener(delegate () {
|
|
|
HandleDeleteSelectedLevel();
|
|
|
});
|
|
|
|
|
|
- RefreshUI();
|
|
|
+ // Create fast scroll buttons
|
|
|
+ _pageUpTenPercent = UIBuilder.CreatePageButton(sortButtonTransform, otherButtonTemplate, arrowIcon, 15, 67.5f, 6.0f, 5.5f, 1.5f, 1.5f, 180);
|
|
|
+ _pageUpTenPercent.onClick.AddListener(delegate () {
|
|
|
+ this.JumpSongList(-1, SEGMENT_PERCENT);
|
|
|
+ });
|
|
|
+
|
|
|
+ _pageDownTenPercent = UIBuilder.CreatePageButton(sortButtonTransform, otherButtonTemplate, arrowIcon, 15, 0.5f, 6.0f, 5.5f, 1.5f, 1.5f, 0);
|
|
|
+ _pageDownTenPercent.onClick.AddListener(delegate () {
|
|
|
+ this.JumpSongList(1, SEGMENT_PERCENT);
|
|
|
+ });
|
|
|
+
|
|
|
+ RefreshSortButtonUI();
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -226,6 +235,38 @@ namespace SongBrowserPlugin.UI
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ private void onSortButtonClickEvent(SongSortMode sortMode)
|
|
|
+ {
|
|
|
+ _log.Debug("Sort button - {0} - pressed.", sortMode.ToString());
|
|
|
+ SongBrowserModel.LastSelectedLevelId = null;
|
|
|
+
|
|
|
+ if (_model.Settings.sortMode == sortMode)
|
|
|
+ {
|
|
|
+ _model.ToggleInverting();
|
|
|
+ }
|
|
|
+
|
|
|
+ _model.Settings.sortMode = sortMode;
|
|
|
+ _model.Settings.Save();
|
|
|
+
|
|
|
+ UpdateSongList();
|
|
|
+ RefreshSongList();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Saerch button clicked.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sortMode"></param>
|
|
|
+ private void onSearchButtonClickEvent(SongSortMode sortMode)
|
|
|
+ {
|
|
|
+ _model.Settings.sortMode = sortMode;
|
|
|
+ _model.Settings.Save();
|
|
|
+
|
|
|
+ this.ShowSearchKeyboard();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
/// Adjust UI based on level selected.
|
|
|
/// Various ways of detecting if a level is not properly selected. Seems most hit the first one.
|
|
|
/// </summary>
|
|
@@ -247,6 +288,7 @@ namespace SongBrowserPlugin.UI
|
|
|
SongBrowserModel.LastSelectedLevelId = level.levelID;
|
|
|
|
|
|
RefreshAddFavoriteButton(level.levelID);
|
|
|
+ RefreshQuickScrollButtons();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -289,23 +331,146 @@ namespace SongBrowserPlugin.UI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- IStandardLevel level = this._levelListViewController.selectedLevel;
|
|
|
+ string customSongsPath = Path.Combine(Environment.CurrentDirectory, "CustomSongs");
|
|
|
+ IStandardLevel level = this._levelListViewController.selectedLevel;
|
|
|
SongLoaderPlugin.OverrideClasses.CustomLevel customLevel = _model.LevelIdToCustomSongInfos[level.levelID];
|
|
|
+ string songPath = customLevel.customSongInfo.path;
|
|
|
+ bool isZippedSong = false;
|
|
|
|
|
|
viewController.DismissModalViewController(null, false);
|
|
|
- _log.Debug("Deleting: {0}", customLevel.customSongInfo.path);
|
|
|
-
|
|
|
- FileAttributes attr = File.GetAttributes(customLevel.customSongInfo.path);
|
|
|
- if (attr.HasFlag(FileAttributes.Directory))
|
|
|
- Directory.Delete(customLevel.customSongInfo.path);
|
|
|
+ _log.Debug("Deleting: {0}", songPath);
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(songPath) && songPath.Contains("/.cache/"))
|
|
|
+ {
|
|
|
+ isZippedSong = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isZippedSong)
|
|
|
+ {
|
|
|
+ DirectoryInfo songHashDir = Directory.GetParent(songPath);
|
|
|
+ _log.Debug("Deleting zipped song cache: {0}", songHashDir.FullName);
|
|
|
+ Directory.Delete(songHashDir.FullName, true);
|
|
|
+
|
|
|
+ foreach (string file in Directory.GetFiles(customSongsPath, "*.zip"))
|
|
|
+ {
|
|
|
+ string hash = CreateMD5FromFile(file);
|
|
|
+ if (hash != null)
|
|
|
+ {
|
|
|
+ if (hash == songHashDir.Name)
|
|
|
+ {
|
|
|
+ _log.Debug("Deleting zipped song: {0}", file);
|
|
|
+ File.Delete(file);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
else
|
|
|
- File.Delete(customLevel.customSongInfo.path);
|
|
|
+ {
|
|
|
+ FileAttributes attr = File.GetAttributes(songPath);
|
|
|
+ if (attr.HasFlag(FileAttributes.Directory))
|
|
|
+ {
|
|
|
+ _log.Debug("Deleting song: {0}", songPath);
|
|
|
+ Directory.Delete(songPath, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SongLoaderPlugin.SongLoader.Instance.RemoveSongWithPath(songPath);
|
|
|
+ this.UpdateSongList();
|
|
|
+ this.RefreshSongList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Create MD5 of a file.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="path"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static string CreateMD5FromFile(string path)
|
|
|
+ {
|
|
|
+ string hash = "";
|
|
|
+ if (!File.Exists(path)) return null;
|
|
|
+ using (MD5 md5 = MD5.Create())
|
|
|
+ {
|
|
|
+ using (var stream = File.OpenRead(path))
|
|
|
+ {
|
|
|
+ byte[] hashBytes = md5.ComputeHash(stream);
|
|
|
|
|
|
- SongLoaderPlugin.SongLoader.Instance.RemoveSongWithPath(customLevel.customSongInfo.path);
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ foreach (byte hashByte in hashBytes)
|
|
|
+ {
|
|
|
+ sb.Append(hashByte.ToString("X2"));
|
|
|
+ }
|
|
|
+
|
|
|
+ hash = sb.ToString();
|
|
|
+ return hash;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
+ /// Display the search keyboard
|
|
|
+ /// </summary>
|
|
|
+ void ShowSearchKeyboard()
|
|
|
+ {
|
|
|
+ if (_searchViewController == null)
|
|
|
+ {
|
|
|
+ _searchViewController = UIBuilder.CreateViewController<SearchKeyboardViewController>("SearchKeyboardViewController");
|
|
|
+ _searchViewController.searchButtonPressed += SearchViewControllerSearchButtonPressed;
|
|
|
+ _searchViewController.backButtonPressed += SearchViewControllerbackButtonPressed;
|
|
|
+ }
|
|
|
+
|
|
|
+ _levelListViewController.navigationController.PresentModalViewController(_searchViewController, null, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Handle back button event from search keyboard.
|
|
|
+ /// </summary>
|
|
|
+ private void SearchViewControllerbackButtonPressed()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Handle search.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="searchFor"></param>
|
|
|
+ private void SearchViewControllerSearchButtonPressed(string searchFor)
|
|
|
+ {
|
|
|
+ _log.Debug("Searching for \"{0}\"...", searchFor);
|
|
|
+
|
|
|
+ _model.Settings.searchTerms.Insert(0, searchFor);
|
|
|
+ _model.Settings.Save();
|
|
|
+ SongBrowserModel.LastSelectedLevelId = null;
|
|
|
+ this.UpdateSongList();
|
|
|
+ this.RefreshSongList();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Make big jumps in the song list.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="numJumps"></param>
|
|
|
+ private void JumpSongList(int numJumps, float segmentPercent)
|
|
|
+ {
|
|
|
+ int totalSize = _model.SortedSongList.Count;
|
|
|
+ int segmentSize = (int)(totalSize * segmentPercent);
|
|
|
+
|
|
|
+ TableView tableView = ReflectionUtil.GetPrivateField<TableView>(_levelListTableView, "_tableView");
|
|
|
+ HashSet<int> rows = tableView.GetPrivateField<HashSet<int>>("_selectedRows");
|
|
|
+ int listSegment = (rows.First() / segmentSize);
|
|
|
+ int newSegment = listSegment + numJumps;
|
|
|
+ int newRow = 0;
|
|
|
+ if (newSegment > 0)
|
|
|
+ {
|
|
|
+ newRow = Math.Min(newSegment * segmentSize, totalSize - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ _log.Debug("ListSegment: {0}, newRow: {1}", listSegment, newRow);
|
|
|
+
|
|
|
+ this.SelectAndScrollToLevel(_levelListTableView, _model.SortedSongList[newRow].levelID);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
/// Add/Remove song from favorites depending on if it already exists.
|
|
|
/// </summary>
|
|
|
private void ToggleSongInFavorites()
|
|
@@ -330,6 +495,18 @@ namespace SongBrowserPlugin.UI
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
+ /// Update interactive state of the quick scroll buttons.
|
|
|
+ /// </summary>
|
|
|
+ private void RefreshQuickScrollButtons()
|
|
|
+ {
|
|
|
+ // Refresh the fast scroll buttons
|
|
|
+ _pageUpTenPercent.interactable = _tableViewPageUpButton.interactable;
|
|
|
+ _pageUpTenPercent.gameObject.SetActive(_tableViewPageUpButton.IsActive());
|
|
|
+ _pageDownTenPercent.interactable = _tableViewPageDownButton.interactable;
|
|
|
+ _pageDownTenPercent.gameObject.SetActive(_tableViewPageDownButton.IsActive());
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
/// Helper to quickly refresh add to favorites button
|
|
|
/// </summary>
|
|
|
/// <param name="levelId"></param>
|
|
@@ -356,18 +533,14 @@ namespace SongBrowserPlugin.UI
|
|
|
/// <summary>
|
|
|
/// Adjust the UI colors.
|
|
|
/// </summary>
|
|
|
- public void RefreshUI()
|
|
|
+ public void RefreshSortButtonUI()
|
|
|
{
|
|
|
// So far all we need to refresh is the sort buttons.
|
|
|
foreach (SongSortButton sortButton in _sortButtonGroup)
|
|
|
{
|
|
|
UIBuilder.SetButtonBorder(ref sortButton.Button, Color.black);
|
|
|
- //UIBuilder.SetButtonIconEnabled(ref sortButton.Button, false);
|
|
|
if (sortButton.SortMode == _model.Settings.sortMode)
|
|
|
{
|
|
|
- //UIBuilder.SetButtonIcon(ref sortButton.Button, SongBrowserApplication.Instance.CachedIcons["ArrowIcon"]);
|
|
|
- //UIBuilder.SetButtonIconEnabled(ref sortButton.Button, true);
|
|
|
-
|
|
|
if (_model.InvertingResults)
|
|
|
{
|
|
|
UIBuilder.SetButtonBorder(ref sortButton.Button, Color.red);
|
|
@@ -395,12 +568,13 @@ namespace SongBrowserPlugin.UI
|
|
|
}
|
|
|
|
|
|
StandardLevelSO[] levels = _model.SortedSongList.ToArray();
|
|
|
+ foreach (StandardLevelSO level in levels)
|
|
|
+ _log.Debug(level.levelID);
|
|
|
StandardLevelListViewController songListViewController = this._levelSelectionFlowCoordinator.GetPrivateField<StandardLevelListViewController>("_levelListViewController");
|
|
|
- StandardLevelListTableView _songListTableView = songListViewController.GetComponentInChildren<StandardLevelListTableView>();
|
|
|
- ReflectionUtil.SetPrivateField(_songListTableView, "_levels", levels);
|
|
|
+ ReflectionUtil.SetPrivateField(_levelListTableView, "_levels", levels);
|
|
|
ReflectionUtil.SetPrivateField(songListViewController, "_levels", levels);
|
|
|
- TableView tableView = ReflectionUtil.GetPrivateField<TableView>(_songListTableView, "_tableView");
|
|
|
- tableView.ReloadData();
|
|
|
+ TableView tableView = ReflectionUtil.GetPrivateField<TableView>(_levelListTableView, "_tableView");
|
|
|
+ tableView.ReloadData();
|
|
|
|
|
|
String selectedLevelID = null;
|
|
|
if (SongBrowserModel.LastSelectedLevelId != null)
|
|
@@ -410,15 +584,19 @@ namespace SongBrowserPlugin.UI
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- selectedLevelID = levels.FirstOrDefault().levelID;
|
|
|
+ if (levels.Length > 0)
|
|
|
+ {
|
|
|
+ selectedLevelID = levels.FirstOrDefault().levelID;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (levels.Any(x => x.levelID == selectedLevelID))
|
|
|
+ // HACK, seems like if 6 or less items scrolling to row causes the song list to disappear.
|
|
|
+ if (levels.Length > 6 && !String.IsNullOrEmpty(selectedLevelID) && levels.Any(x => x.levelID == selectedLevelID))
|
|
|
{
|
|
|
- SelectAndScrollToLevel(_songListTableView, selectedLevelID);
|
|
|
+ SelectAndScrollToLevel(_levelListTableView, selectedLevelID);
|
|
|
}
|
|
|
-
|
|
|
- RefreshUI();
|
|
|
+
|
|
|
+ RefreshSortButtonUI();
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -455,10 +633,8 @@ namespace SongBrowserPlugin.UI
|
|
|
/// </summary>
|
|
|
public void LateUpdate()
|
|
|
{
|
|
|
- if (this._levelListViewController.isInViewControllerHierarchy)
|
|
|
- {
|
|
|
- CheckDebugUserInput();
|
|
|
- }
|
|
|
+ if (!this._levelListViewController.isActiveAndEnabled) return;
|
|
|
+ CheckDebugUserInput();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -467,7 +643,9 @@ namespace SongBrowserPlugin.UI
|
|
|
private void CheckDebugUserInput()
|
|
|
{
|
|
|
try
|
|
|
- {
|
|
|
+ {
|
|
|
+ bool isShiftKeyDown = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
|
|
|
+
|
|
|
// back
|
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
|
{
|
|
@@ -481,6 +659,11 @@ namespace SongBrowserPlugin.UI
|
|
|
_sortButtonGroup[_sortButtonLastPushedIndex].Button.onClick.Invoke();
|
|
|
}
|
|
|
|
|
|
+ if (Input.GetKeyDown(KeyCode.S))
|
|
|
+ {
|
|
|
+ onSortButtonClickEvent(SongSortMode.Search);
|
|
|
+ }
|
|
|
+
|
|
|
// select current sort mode again (toggle inverting)
|
|
|
if (Input.GetKeyDown(KeyCode.Y))
|
|
|
{
|
|
@@ -496,7 +679,13 @@ namespace SongBrowserPlugin.UI
|
|
|
}
|
|
|
_deleteButton.onClick.Invoke();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ // accept delete
|
|
|
+ if (Input.GetKeyDown(KeyCode.B) && _deleteDialog.isInViewControllerHierarchy)
|
|
|
+ {
|
|
|
+ _deleteDialog.GetPrivateField<TextMeshProButton>("_okButton").button.onClick.Invoke();
|
|
|
+ }
|
|
|
+
|
|
|
// c,v can be used to get into a song
|
|
|
if (Input.GetKeyDown(KeyCode.C))
|
|
|
{
|
|
@@ -511,17 +700,23 @@ namespace SongBrowserPlugin.UI
|
|
|
}
|
|
|
|
|
|
// change song index
|
|
|
- if (Input.GetKeyDown(KeyCode.N))
|
|
|
+ if (isShiftKeyDown && Input.GetKeyDown(KeyCode.N))
|
|
|
+ {
|
|
|
+ _pageUpTenPercent.onClick.Invoke();
|
|
|
+ }
|
|
|
+ else if (Input.GetKeyDown(KeyCode.N))
|
|
|
{
|
|
|
_lastRow = (_lastRow - 1) != -1 ? (_lastRow - 1) % this._model.SortedSongList.Count : 0;
|
|
|
-
|
|
|
this.SelectAndScrollToLevel(_levelListTableView, _model.SortedSongList[_lastRow].levelID);
|
|
|
}
|
|
|
|
|
|
- if (Input.GetKeyDown(KeyCode.M))
|
|
|
+ if (isShiftKeyDown && Input.GetKeyDown(KeyCode.M))
|
|
|
+ {
|
|
|
+ _pageDownTenPercent.onClick.Invoke();
|
|
|
+ }
|
|
|
+ else if (Input.GetKeyDown(KeyCode.M))
|
|
|
{
|
|
|
_lastRow = (_lastRow + 1) % this._model.SortedSongList.Count;
|
|
|
-
|
|
|
this.SelectAndScrollToLevel(_levelListTableView, _model.SortedSongList[_lastRow].levelID);
|
|
|
}
|
|
|
|