You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.4 KiB

  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using CustomUI.BeatSaber;
  5. using CustomUI.Utilities;
  6. using HMUI;
  7. using IPA.Loader;
  8. using IPA.Old;
  9. using UnityEngine;
  10. using VRUI;
  11. using IPA.Loader.Features;
  12. using TMPro;
  13. using BSIPA_ModList.UI.ViewControllers;
  14. using UnityEngine.UI;
  15. namespace BSIPA_ModList.UI
  16. {
  17. internal class ModListController : CustomListViewController
  18. {
  19. public override TableCell CellForIdx(int idx)
  20. {
  21. var cell = base.CellForIdx(idx) as LevelListTableCell;
  22. var nameText = cell.GetPrivateField<TextMeshProUGUI>("_songNameText");
  23. nameText.overflowMode = TextOverflowModes.Overflow;
  24. return cell;
  25. }
  26. internal ModListFlowCoordinator flow;
  27. #pragma warning disable CS0618
  28. public void Init(ModListFlowCoordinator flow, IEnumerable<PluginLoader.PluginInfo> bsipaPlugins, IEnumerable<PluginLoader.PluginMetadata> ignoredPlugins, IEnumerable<IPlugin> ipaPlugins)
  29. {
  30. Logger.log.Debug("List Controller Init");
  31. DidActivateEvent = DidActivate;
  32. DidSelectRowEvent = DidSelectRow;
  33. rectTransform.anchorMin = new Vector2(0f, 0f);
  34. rectTransform.anchorMax = new Vector2(.4f, 1f);
  35. includePageButtons = true;
  36. this.flow = flow;
  37. reuseIdentifier = "BSIPAModListTableCell";
  38. foreach (var plugin in bsipaPlugins.Where(p => !p.Metadata.IsBare))
  39. Data.Add(new BSIPAModCell(this, plugin));
  40. foreach (var plugin in ignoredPlugins)
  41. Data.Add(new BSIPAIgnoredModCell(this, plugin));
  42. foreach (var plugin in bsipaPlugins.Where(p => p.Metadata.IsBare))
  43. Data.Add(new LibraryModCell(this, plugin));
  44. foreach (var plugin in ipaPlugins)
  45. Data.Add(new IPAModCell(this, plugin));
  46. }
  47. #pragma warning restore
  48. private void DidSelectRow(TableView view, int index)
  49. {
  50. Debug.Assert(ReferenceEquals(view.dataSource, this));
  51. (Data[index] as IClickableCell)?.OnSelect(this);
  52. }
  53. private new void DidActivate(bool first, ActivationType type)
  54. {
  55. var rt = _customListTableView.transform as RectTransform;
  56. rt.anchorMin = new Vector2(.1f, 0f);
  57. rt.anchorMax = new Vector2(.9f, 1f);
  58. _customListTableView.gameObject.GetComponent<ScrollRect>().scrollSensitivity = 0f;
  59. }
  60. }
  61. }