Skip to content

Commit

Permalink
Add Hover Hint text to all Icon buttons SongBrowser makes.
Browse files Browse the repository at this point in the history
Adjust export playlist success language.
  • Loading branch information
halsafar committed May 28, 2021
1 parent 3002f88 commit e27e0fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions SongBrowserPlugin/Internals/BeatSaberExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public static Button CreateUIButton(this HMUI.ViewController parent, string name
Button btn = BeatSaberUI.CreateUIButton(name, parent.rectTransform, buttonTemplate, anchoredPosition, sizeDelta, onClick, buttonText);
return btn;
}
public static Button CreateIconButton(this HMUI.ViewController parent, string name, string buttonTemplate, Vector2 anchoredPosition, Vector2 sizeDelta, UnityAction onClick, Sprite icon)
public static Button CreateIconButton(this HMUI.ViewController parent, string name, string buttonTemplate, Vector2 anchoredPosition, Vector2 sizeDelta, UnityAction onClick, Sprite icon, string hint)
{
Button btn = BeatSaberUI.CreateIconButton(name, parent.rectTransform, buttonTemplate, anchoredPosition, sizeDelta, onClick, icon);
Button btn = BeatSaberUI.CreateIconButton(name, parent.rectTransform, buttonTemplate, anchoredPosition, sizeDelta, onClick, icon, hint);
return btn;
}
#endregion
Expand Down
9 changes: 4 additions & 5 deletions SongBrowserPlugin/Internals/BeatSaberUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ public static Button CreateBaseButton(String name, RectTransform parent, String
/// <param name="parent"></param>
/// <param name="buttonTemplate"></param>
/// <returns></returns>
public static Button CreateIconButton(String name, RectTransform parent, String buttonTemplate, Sprite icon)
public static Button CreateIconButton(String name, RectTransform parent, String buttonTemplate, Sprite icon, String hint)
{
Button btn = CreateBaseButton(name, parent, buttonTemplate);

UnityEngine.Object.Destroy(btn.GetComponent<HoverHint>());
GameObject.Destroy(btn.GetComponent<LocalizedHoverHint>());
BeatSaberUI.SetHoverHint(btn.transform as RectTransform, $"{name}_hoverHintText", hint);
btn.gameObject.AddComponent<ExternalComponents>().components.Add(btn.GetComponentsInChildren<LayoutGroup>().First(x => x.name == "Content"));

Transform contentTransform = btn.transform.Find("Content");
Expand Down Expand Up @@ -123,10 +122,10 @@ public static Button CreateIconButton(String name, RectTransform parent, String
/// <param name="buttonTemplate"></param>
/// <param name="iconSprite"></param>
/// <returns></returns>
public static Button CreateIconButton(String name, RectTransform parent, String buttonTemplate, Vector2 anchoredPosition, Vector2 sizeDelta, UnityAction onClick, Sprite icon)
public static Button CreateIconButton(String name, RectTransform parent, String buttonTemplate, Vector2 anchoredPosition, Vector2 sizeDelta, UnityAction onClick, Sprite icon, String hint)
{
Logger.Debug("CreateIconButton({0}, {1}, {2}, {3}, {4}", name, parent, buttonTemplate, anchoredPosition, sizeDelta);
Button btn = CreateIconButton(name, parent, buttonTemplate, icon);
Button btn = CreateIconButton(name, parent, buttonTemplate, icon, hint);

(btn.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f);
(btn.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f);
Expand Down
11 changes: 6 additions & 5 deletions SongBrowserPlugin/UI/Browser/SongBrowserUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ private void CreateOuterUi()
OnClearButtonClickEvent();
}
},
Base64Sprites.XIcon);
Base64Sprites.XIcon,
"Clear");
_clearSortFilterButton.SetButtonBackgroundActive(false);

// create SortBy button and its display
Expand Down Expand Up @@ -275,7 +276,7 @@ private void CreateOuterUi()
_randomButton = _viewController.CreateIconButton("randomButton", "PracticeButton", new Vector2(curX + (randomButtonWidth / 4.0f), clearButtonY), new Vector2(randomButtonWidth, randomButtonWidth), () =>
{
OnSortButtonClickEvent(SongSortMode.Random);
}, Base64Sprites.RandomIcon);
}, Base64Sprites.RandomIcon, "Random");
_randomButton.SetButtonBackgroundActive(false);

curX += (randomButtonWidth / 4.0f) * 2.0f;
Expand All @@ -285,7 +286,7 @@ private void CreateOuterUi()
_playlistExportButton = _viewController.CreateIconButton("playlistExportButton", "PracticeButton", new Vector2(curX + (randomButtonWidth / 4.0f), clearButtonY), new Vector2(randomButtonWidth, randomButtonWidth), () =>
{
ShowInputKeyboard(CreatePlaylistButtonPressed);
}, Base64Sprites.PlaylistIcon);
}, Base64Sprites.PlaylistIcon, "Export Playlist");
_playlistExportButton.SetButtonBackgroundActive(false);
}

Expand Down Expand Up @@ -421,7 +422,7 @@ private void CreateDeleteUI()
_deleteDialog.gameObject.SetActive(false);

Logger.Debug("Creating delete button...");
_deleteButton = BeatSaberUI.CreateIconButton("DeleteLevelButton", _beatUi.ActionButtons, "PracticeButton", Base64Sprites.DeleteIcon);
_deleteButton = BeatSaberUI.CreateIconButton("DeleteLevelButton", _beatUi.ActionButtons, "PracticeButton", Base64Sprites.DeleteIcon, "Delete Level");
_deleteButton.transform.SetAsFirstSibling();
_deleteButton.onClick.AddListener(delegate () {
HandleDeleteSelectedLevel();
Expand Down Expand Up @@ -1158,7 +1159,7 @@ private void CreatePlaylistButtonPressed(string playlistName)
}
BeatSaberPlaylistsLib.Types.IPlaylist playlist = Playlist.CreateNew(playlistName, _beatUi.GetCurrentLevelCollectionLevels());
BeatSaberPlaylistsLib.PlaylistManager.DefaultManager.RequestRefresh(Assembly.GetExecutingAssembly().FullName);
SongBrowserApplication.MainProgressBar.ShowMessage("Saved to: " + "Playlists\\SongBrowser\\" + playlist.Filename + "." + playlist.SuggestedExtension);
SongBrowserApplication.MainProgressBar.ShowMessage("Successfully Exported Playlist");
}

/// <summary>
Expand Down

0 comments on commit e27e0fd

Please sign in to comment.