55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using BITKit.UX;
|
|
using Net.Project.B.Quest;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace Net.Like.Xue.Tokyo.UX
|
|
{
|
|
public class UXQuestList : UIToolKitPanel
|
|
{
|
|
private readonly IQuestService _questService;
|
|
protected override string DocumentPath => "ui_quest_list";
|
|
public override bool CloseWhenClickOutside => true;
|
|
public override bool AllowCursor => true;
|
|
|
|
[UXBindPath("quest-container")]
|
|
private VisualElement _questContainer;
|
|
|
|
private VisualTreeAsset _questTemplate;
|
|
|
|
private readonly Dictionary<int,VisualElement> _visualElements = new();
|
|
|
|
public UXQuestList(IUXService uxService, IQuestService questService) : base(uxService)
|
|
{
|
|
_questService = questService;
|
|
|
|
_questService.OnQuestCreatedOrUpdated += OnQuestCreatedOrUpdated;
|
|
|
|
OnInitiated += Initiated;
|
|
}
|
|
|
|
private void Initiated()
|
|
{
|
|
_questTemplate = _questContainer.Q<TemplateContainer>().templateSource;
|
|
_questContainer.Clear();
|
|
}
|
|
|
|
private void OnQuestCreatedOrUpdated(IQuestData arg1, QuestState arg2, QuestState arg3)
|
|
{
|
|
if (_visualElements.TryGetValue(arg1.Identity, out var container) is false)
|
|
{
|
|
_visualElements[arg1.Identity] = container = _questContainer.Create(_questTemplate);
|
|
}
|
|
|
|
container.Get<Label>().text = arg1.Name;
|
|
container.Get<Label>(1).text = arg1.Description;
|
|
container.Get<Label>(2).text = arg3.ToString();
|
|
}
|
|
}
|
|
|
|
}
|
|
|