mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
125 lines
3.8 KiB
C#
125 lines
3.8 KiB
C#
using BetterAmongUs.Patches;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace BetterAmongUs;
|
|
|
|
public class BetterOptionItem
|
|
{
|
|
public float StaticSpacingNum => 1f;
|
|
public float StaticSpacingNumPlus => 0.45f;
|
|
public static Dictionary<int, int> TempPlayerOptionData = [];
|
|
public static int TempPlayerOptionDataNum = 0;
|
|
public static List<BetterOptionItem> BetterOptionItems = [];
|
|
public static float SpacingNum = 0;
|
|
|
|
public int maskLayer = 20;
|
|
public int Id = 0;
|
|
public GameOptionsMenu? Tab;
|
|
public OptionBehaviour? Option;
|
|
public string? Name = "None";
|
|
public TextMeshPro? TitleText;
|
|
public GameObject? obj;
|
|
|
|
public BetterOptionItem? ThisParent;
|
|
public bool IsChild = false;
|
|
public bool IsParent => ChildrenList.Count > 0;
|
|
public List<BetterOptionItem> ChildrenList = [];
|
|
public virtual bool ShowChildrenCondition() => false;
|
|
public virtual bool SelfShowCondition() => true;
|
|
|
|
public static void UpdatePositions()
|
|
{
|
|
SpacingNum = 0f;
|
|
|
|
foreach (var item in BetterOptionItems)
|
|
{
|
|
try
|
|
{
|
|
item.obj.transform.SetLocalY(2f);
|
|
|
|
// Need to fix name not setting
|
|
if (item.ThisParent != null)
|
|
{
|
|
_ = new LateTask(() =>
|
|
{
|
|
item.obj.SetActive(item.ThisParent.ShowChildrenCondition() && item.SelfShowCondition() && item.ThisParent.Option.gameObject.active);
|
|
}, 0.005f, shoudLog: false);
|
|
if (!(item.ThisParent.ShowChildrenCondition() && item.SelfShowCondition() && item.ThisParent.Option.gameObject.active))
|
|
continue;
|
|
}
|
|
|
|
if (item is BetterOptionPlayerItem player)
|
|
{
|
|
player.Load();
|
|
}
|
|
|
|
SpacingNum += item switch
|
|
{
|
|
BetterOptionHeaderItem => 0.1f,
|
|
BetterOptionDividerItem => 0.15f,
|
|
_ => 0f,
|
|
};
|
|
|
|
item.obj.transform.SetLocalY(2f - 1f * SpacingNum);
|
|
|
|
SpacingNum += item switch
|
|
{
|
|
BetterOptionHeaderItem => 0.75f,
|
|
BetterOptionTitleItem => 0.50f,
|
|
_ => 0.45f,
|
|
};
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
GameSettingMenuPatch.BetterSettingsTab.scrollBar.SetYBoundsMax(1.5f * SpacingNum / 2);
|
|
GameSettingMenuPatch.BetterSettingsTab.scrollBar.ScrollRelative(new(0f, 0f));
|
|
}
|
|
|
|
public void SetUp(OptionBehaviour optionBehaviour)
|
|
{
|
|
SetData(optionBehaviour);
|
|
SpriteRenderer[] componentsInChildren = optionBehaviour.GetComponentsInChildren<SpriteRenderer>(true);
|
|
for (int i = 0; i < componentsInChildren.Length; i++)
|
|
{
|
|
componentsInChildren[i].material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
|
|
}
|
|
foreach (TextMeshPro textMeshPro in optionBehaviour.GetComponentsInChildren<TextMeshPro>(true))
|
|
{
|
|
textMeshPro.fontMaterial.SetFloat("_StencilComp", 3f);
|
|
textMeshPro.fontMaterial.SetFloat("_Stencil", maskLayer);
|
|
}
|
|
}
|
|
|
|
public virtual bool GetBool()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual float GetFloat()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual int GetInt()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual int GetValue()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual void SetData(OptionBehaviour optionBehaviour)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual void ValueChanged(int id, OptionBehaviour optionBehaviour)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|