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.

70 lines
2.3 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. namespace BSIPA_ModList.UI
  15. {
  16. internal class ModListController : CustomListViewController
  17. {
  18. public override TableCell CellForIdx(int idx)
  19. {
  20. var cell = base.CellForIdx(idx) as LevelListTableCell;
  21. var nameText = cell.GetPrivateField<TextMeshProUGUI>("_songNameText");
  22. nameText.overflowMode = TextOverflowModes.Overflow;
  23. return cell;
  24. }
  25. internal ModListFlowCoordinator flow;
  26. #pragma warning disable CS0618
  27. public void Init(ModListFlowCoordinator flow, IEnumerable<PluginLoader.PluginInfo> bsipaPlugins, IEnumerable<PluginLoader.PluginMetadata> ignoredPlugins, IEnumerable<IPlugin> ipaPlugins)
  28. {
  29. Logger.log.Debug("List Controller Init");
  30. DidActivateEvent = DidActivate;
  31. DidSelectRowEvent = DidSelectRow;
  32. rectTransform.anchorMin = new Vector2(0f, 0f);
  33. rectTransform.anchorMax = new Vector2(.4f, 1f);
  34. includePageButtons = true;
  35. this.flow = flow;
  36. reuseIdentifier = "BSIPAModListTableCell";
  37. foreach (var plugin in bsipaPlugins.Where(p => !p.Metadata.IsBare))
  38. Data.Add(new BSIPAModCell(this, plugin));
  39. foreach (var plugin in ignoredPlugins)
  40. Data.Add(new BSIPAIgnoredModCell(this, plugin));
  41. foreach (var plugin in bsipaPlugins.Where(p => p.Metadata.IsBare))
  42. Data.Add(new LibraryModCell(this, plugin));
  43. foreach (var plugin in ipaPlugins)
  44. Data.Add(new IPAModCell(this, plugin));
  45. }
  46. #pragma warning restore
  47. private void DidSelectRow(TableView view, int index)
  48. {
  49. Debug.Assert(ReferenceEquals(view.dataSource, this));
  50. (Data[index] as IClickableCell)?.OnSelect(this);
  51. }
  52. private new void DidActivate(bool first, ActivationType type)
  53. {
  54. var rt = _customListTableView.transform as RectTransform;
  55. rt.anchorMin = new Vector2(.1f, 0f);
  56. rt.anchorMax = new Vector2(.9f, 1f);
  57. }
  58. }
  59. }