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 -43
View File
@@ -1,6 +1,5 @@
#nullable enable
using System.Collections.Generic;
using System.Threading.Tasks;
using AibisDream.Framework;
using UnityEngine;
@@ -10,7 +9,6 @@ namespace AibisDream
{
public class OptionView : DialoguePresenterBase
{
private HashSet<string> _selectedIds = new();
[SerializeField] private DefaultOptions defaultOptions;
[SerializeField] private CenterOptions centerOptions;
[SerializeField] private OnelineOptions onelineOptions;
@@ -31,7 +29,6 @@ namespace AibisDream
{
return YarnTask.CompletedTask;
}
public void LoadBubbles(BubbleSlotGroupData data)
{
defaultViewType = data.dialogViewType;
@@ -44,7 +41,7 @@ namespace AibisDream
var options = DialogOption.GeneOptions(dialogueOptions, optionId =>
{
optionSelectedSource.TrySetResult(optionId);
}, _selectedIds);
});
var viewType = GetCurrentViewType(options);
@@ -101,45 +98,6 @@ namespace AibisDream
return optionViewType;
}
// --------------------------- 生命周期方法 ---------------------------
private void OnEnable()
{
RegisterEvent();
}
private void OnDisable()
{
UnRegisterEvent();
}
private void RegisterEvent()
{
// 进入游戏或者进入下一个Yarn的时候清空
EnumEventSystem.Global.Register(GameLoopEnum.GameStart, ClearSelectedIds);
EnumEventSystem.Global.Register(EventEnum.NextYarn, ClearSelectedIds);
// 选择选项的时候记录
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, RecordSelectedId);
}
private void UnRegisterEvent()
{
EnumEventSystem.Global.UnRegister(GameLoopEnum.GameStart, ClearSelectedIds);
EnumEventSystem.Global.UnRegister(EventEnum.NextYarn, ClearSelectedIds);
EnumEventSystem.Global.UnRegister<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, RecordSelectedId);
}
private void ClearSelectedIds()
{
_selectedIds.Clear();
}
private void RecordSelectedId(LineInfo lineInfo)
{
_selectedIds.Add(lineInfo.lineId);
}
public void HideDialog()
{
defaultOptions.HideOptions();