Files
YachtDice/Assets/Scripts/UI/CategoryRowView.cs
T
horooko bee20fd1f8 [Refactor] Add folder-based namespaces to all C# scripts
Wrap all 39 scripts and 6 test files in namespaces matching their folder
structure (e.g. Assets/Scripts/Dice/ → YachtDice.Dice). Add cross-namespace
using directives where types are referenced across modules. Set rootNamespace
in both .asmdef files (YachtDice, YachtDice.Tests).

Namespace mapping:
- YachtDice.Dice — Dice, DiceRoller
- YachtDice.Economy — CurrencyBank
- YachtDice.Game — GameManager, DiceManager, DebugGameInput
- YachtDice.Inventory — InventoryController/Model/SlotView/View
- YachtDice.Modifiers — ModifierData/Effect/Enums/Pipeline/Runtime/Target
- YachtDice.Persistence — SaveData, SaveSystem
- YachtDice.Scoring — CategoryScorer, ScoreResult, ScoringSystem, YachtCategory
- YachtDice.Shop — ShopCatalog/Controller/ItemView/Model/View
- YachtDice.UI — CategoryRowView, DicePanelView, GameController, GameInfoView, ScoreCardView
- YachtDice.Editor — ModifierAssetCreator
- YachtDice.Tests — all test files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:06:57 +07:00

95 lines
2.5 KiB
C#

using System;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using YachtDice.Scoring;
namespace YachtDice.UI
{
public sealed class CategoryRowView : MonoBehaviour
{
[Header("UI Elements")]
[SerializeField] private TMP_Text categoryNameText;
[SerializeField] private TMP_Text previewText;
[SerializeField] private TMP_Text recordedScoreText;
[SerializeField] private Button selectButton;
[SerializeField] private Image background;
[Header("Colors")]
[SerializeField] private Color normalColor = new Color(0.95f, 0.95f, 0.95f, 1f);
[SerializeField] private Color usedColor = new Color(0.75f, 0.75f, 0.75f, 1f);
[SerializeField] private Color previewPositiveColor = new Color(0.85f, 1f, 0.85f, 1f);
[SerializeField] private Color previewZeroColor = new Color(1f, 0.88f, 0.88f, 1f);
private YachtCategory category;
private bool isUsed;
public event Action<YachtCategory> OnCategorySelected;
public void Initialize(YachtCategory cat, string displayName)
{
category = cat;
isUsed = false;
categoryNameText.text = displayName;
previewText.text = "";
recordedScoreText.text = "-";
selectButton.onClick.AddListener(HandleClick);
SetInteractable(false);
background.color = normalColor;
}
public void ShowPreview(int previewScore)
{
if (isUsed) return;
previewText.text = previewScore.ToString();
background.color = previewScore > 0 ? previewPositiveColor : previewZeroColor;
}
public void HidePreview()
{
if (isUsed) return;
previewText.text = "";
background.color = normalColor;
}
public void SetRecordedScore(int score)
{
isUsed = true;
recordedScoreText.text = score.ToString();
previewText.text = "";
SetInteractable(false);
background.color = usedColor;
}
public void SetInteractable(bool interactable)
{
if (isUsed)
{
selectButton.interactable = false;
return;
}
selectButton.interactable = interactable;
}
public void ResetRow()
{
isUsed = false;
previewText.text = "";
recordedScoreText.text = "-";
SetInteractable(false);
background.color = normalColor;
}
private void HandleClick()
{
OnCategorySelected?.Invoke(category);
}
private void OnDestroy()
{
selectButton.onClick.RemoveListener(HandleClick);
}
}
}