using UnityEngine;

namespace Wizard.Dialog.Setting;

public class ItemButton : Item
{
	[SerializeField]
	private UISprite _sprite;

	[SerializeField]
	private UIButton _button;

	[SerializeField]
	private UILabel _label;

	[SerializeField]
	private UISprite _spriteOnButton;

	[SerializeField]
	private BoxCollider _collider;

	[SerializeField]
	private GameObject _separatorLineObj;

	[SerializeField]
	private UILabel _subLabel;

	private void Awake()
	{
		_label.text = string.Empty;
		_separatorLineObj.SetActive(value: false);
	}

	public void SetSpritePos(Vector3 localPos)
	{
		_sprite.transform.localPosition = localPos;
	}

	public void SetLabelPos(Vector3 localPos)
	{
		_label.transform.localPosition = localPos;
	}

	public void SetSubLabelPos(Vector3 localPos)
	{
		_subLabel.transform.localPosition = localPos;
	}

	public void SetValue(string text)
	{
		_label.text = text;
	}

	public void SetSubLabelText(string text)
	{
		_subLabel.text = text;
	}

	public string GetValue()
	{
		return _label.text;
	}

	public void SetSpriteName(string spriteName, bool isMakePixelPerfect, bool isCollisionResize)
	{
		_sprite.spriteName = spriteName;
		_button.normalSprite = spriteName;
		if (isMakePixelPerfect)
		{
			_sprite.MakePixelPerfect();
		}
		if (isCollisionResize)
		{
			_collider.size = new Vector3(_sprite.width, _sprite.height);
		}
	}

	public void SetSpriteNameOnPress(string spriteName)
	{
		_button.pressedSprite = spriteName;
	}

	public void SetSpriteOnButtonName(string spriteName, bool isMakePixelPerfect)
	{
		_spriteOnButton.spriteName = spriteName;
		if (isMakePixelPerfect)
		{
			_spriteOnButton.MakePixelPerfect();
		}
	}

	public void SetSpriteOnButtonPos(Vector3 localPos)
	{
		_spriteOnButton.transform.localPosition = localPos;
	}

	public void SetActive_SpriteOnButton(bool isActive)
	{
		if (_spriteOnButton.gameObject.activeSelf != isActive)
		{
			_spriteOnButton.gameObject.SetActive(isActive);
		}
	}

	public override void AddChangeCallback(EventDelegate.Callback callback)
	{
		EventDelegate.Add(_button.onClick, callback);
	}

	public override void SetActive_SeparatorLine(bool isActive)
	{
		_separatorLineObj.SetActive(isActive);
	}

	public void SetToGrey(bool isGrey)
	{
		UIManager.SetObjectToGrey(base.gameObject, isGrey);
		UIManager.SetObjectToGrey(_separatorLineObj, b: false);
		_button.enabled = !isGrey;
	}
}
