using TMPro; using UnityEngine; using UnityEngine.UI; namespace DDD { public class ItemSlotUi : MonoBehaviour, IInventorySlotUi { [SerializeField] private Button _button; [SerializeField] private Image _icon; [SerializeField] private TextMeshProUGUI _countText; [SerializeField] private Image _markImage; [SerializeField] private Sprite _checkSprite; [SerializeField] private Sprite _xSprite; [SerializeField] private Sprite _emptyFoodSprite; [SerializeField] private Sprite _emptyDrinkSprite; public ItemViewModel Model { get; private set; } public void Initialize(ItemViewModel model) { Model = model; _button.onClick.AddListener(() => { RestaurantEvents.ItemSlotSelectedEvent.Model = Model; EventBus.Broadcast(RestaurantEvents.ItemSlotSelectedEvent); }); if (model != null) { _icon.sprite = model.Icon; _countText.text = model.Count?.ToString() ?? string.Empty; _countText.gameObject.SetActive(true); _markImage.gameObject.SetActive(false); _button.interactable = true; } else { _countText.gameObject.SetActive(false); _markImage.gameObject.SetActive(true); _button.interactable = false; } } public void UpdateCount(int newCount) { _countText.text = newCount.ToString(); } public void SetMark(bool registered) { //_markImage.sprite = registered ? _checkSprite : _xSprite; _countText.gameObject.SetActive(false); _markImage.gameObject.SetActive(true); } public void ClearMark() { _countText.gameObject.SetActive(true); _markImage.gameObject.SetActive(false); } public void SetEmptyFood() { _icon.sprite = _emptyFoodSprite; _markImage.gameObject.SetActive(false); } public void SetEmptyDrink() { _icon.sprite = _emptyDrinkSprite; _markImage.gameObject.SetActive(false); } } }