-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
GameplaySetup.cs
51 lines (45 loc) · 2.19 KB
/
GameplaySetup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using BeatSaberMarkupLanguage.Attributes;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using TMPro;
using UnityEngine;
namespace BeatSaberMarkupLanguage.GameplaySetup
{
public class GameplaySetup : PersistentSingleton<GameplaySetup>
{
private GameplaySetupViewController gameplaySetupViewController;
[UIValue("vanilla-items")]
private List<Transform> vanillaItems = new List<Transform>();
[UIValue("mod-menus")]
private List<object> menus = new List<object>();
internal void Setup()
{
if (menus.Count == 0) return;
gameplaySetupViewController = Resources.FindObjectsOfTypeAll<GameplaySetupViewController>().First();
gameplaySetupViewController.transform.Find("HeaderPanel").GetComponentInChildren<TextMeshProUGUI>().fontSize = 4;
vanillaItems.Clear();
foreach(Transform transform in gameplaySetupViewController.transform)
{
if (transform.name != "HeaderPanel")
vanillaItems.Add(transform);
}
(gameplaySetupViewController.transform.Find("HeaderPanel") as RectTransform).sizeDelta = new Vector2(90, 6);
(gameplaySetupViewController.transform.Find("TextSegmentedControl") as RectTransform).anchoredPosition = new Vector2(0, -13);
BSMLParser.instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "BeatSaberMarkupLanguage.Views.gameplay-setup.bsml"), gameplaySetupViewController.gameObject, this);
}
public void AddTab(string name, string resource, object host)
{
if (menus.Any(x => (x as GameplaySetupMenu).name == name))
return;
menus.Add(new GameplaySetupMenu(name, resource, host, Assembly.GetCallingAssembly()));
}
/// <summary>Warning, for now it will not be removed until fresh menu scene reload</summary>
public void RemoveTab(string name)
{
IEnumerable<object> menu = menus.Where(x => (x as GameplaySetupMenu).name == name);
if (menu.Count() > 0)
menus.Remove(menu.FirstOrDefault());
}
}
}