feat(dialog): 重构选项已选状态视觉表现

This commit is contained in:
2026-05-25 18:43:23 +08:00
parent 7e579a2eb0
commit db5fbb0cb8
5 changed files with 15 additions and 142 deletions
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Collections.Generic;
using AibisDream.Framework;
@@ -15,7 +15,6 @@ namespace AibisDream
private DialogueOption _option;
public bool IsAvailable => _option.IsAvailable;
public bool IsSelected { get; private set; }
public string Line => _option.Line.TextWithoutCharacterName.Text;
public CharacterVo Character => _option.Line.GetCharacterVo();
@@ -51,21 +50,6 @@ namespace AibisDream
return dialogueOptions
.Select(item => new DialogOption { _option = item, _onOptionSelected = onOptionSelected }).ToArray();
}
public static DialogOption[] GeneOptions(DialogueOption[] dialogueOptions, Action<int> onOptionSelected, HashSet<string> selectedIds)
{
var options = new List<DialogOption>();
foreach (var item in dialogueOptions)
{
var option = new DialogOption { _option = item, _onOptionSelected = onOptionSelected };
if (selectedIds.Contains(option._option.TextID))
{
option.IsSelected = true;
}
options.Add(option);
}
return options.ToArray();
}
}
[Serializable]
@@ -11,11 +11,12 @@ namespace AibisDream
[SerializeField] private TMP_Text text;
[SerializeField] private BaseButton button;
[SerializeField] private Image arrow;
[SerializeField] private Image selectedSign;
[Header("颜色配置")]
[SerializeField] private ColorBlock colorBlock;
[Header("已选择颜色")]
[SerializeField] private Color selectedColor;
private DialogOption _option;
public void Init()
@@ -35,8 +36,6 @@ namespace AibisDream
return;
}
selectedSign.gameObject.SetActive(option.IsSelected);
text.SetText(option.Line);
button.onClick.AddListener(() =>
{
@@ -72,11 +71,15 @@ namespace AibisDream
}
}
private Color GetNormalColor()
{
return colorBlock.normalColor;
}
private void SetColor(Color color)
{
arrow.color = color;
text.color = color;
selectedSign.color = color;
}
}
}