using BepInEx;
using KKAPI.Utilities;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
namespace KKAPI.Maker.UI
{
///
/// Custom control that displays a toggle
///
public class MakerToggle : BaseEditableGuiEntry
{
private static Transform _toggleCopy;
///
/// Create a new custom control. Create and register it in .
///
/// Text shown next to the checkbox
/// Category the control will be created under
/// Plugin that owns the control
public MakerToggle(MakerCategory category, string displayName, BaseUnityPlugin owner) : this(category, displayName, false, owner) { }
///
/// Create a new custom control. Create and register it in .
///
/// Text shown next to the checkbox
/// Category the control will be created under
/// Initial value of the toggle
/// Plugin that owns the control
public MakerToggle(MakerCategory category, string displayName, bool initialValue, BaseUnityPlugin owner) : base(category, initialValue, owner)
{
DisplayName = displayName;
}
///
/// Text shown next to the checkbox
///
public string DisplayName { get; }
///
protected internal override void Initialize()
{
}
///
protected override GameObject OnCreateControl(Transform subCategoryList)
{
var tr = Object.Instantiate(GameObject.Find("CharaCustom/CustomControl/CanvasMain/SubMenu/SubMenuFace/Scroll View/Viewport/Content/Category/CategoryTop/SameSettingEyes"), subCategoryList, false);
var tgl = tr.GetComponentInChildren();
tgl.onValueChanged.ActuallyRemoveAllListeners();
tgl.onValueChanged.AddListener(SetValue);
BufferedValueChanged.Subscribe(b => tgl.isOn = b);
var text = tr.GetComponentInChildren();
text.text = DisplayName;
text.color = TextColor;
SetTextAutosize(text);
return tr.gameObject;
}
}
}