58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using KitsuneCafe.System;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace KitsuneCafe.UI
|
|
{
|
|
public readonly struct ModalElementInstance : IUiElement
|
|
{
|
|
public readonly string Title;
|
|
public readonly string Content;
|
|
|
|
private readonly ModalElement so;
|
|
public readonly VisualTreeAsset VisualTreeAsset => so.VisualTreeAsset;
|
|
|
|
public ModalElementInstance(string title, string content, ModalElement so)
|
|
{
|
|
Title = title;
|
|
Content = content;
|
|
this.so = so;
|
|
}
|
|
|
|
public VisualElement Instantiate()
|
|
{
|
|
var instance = VisualTreeAsset.CloneTree();
|
|
Configure(instance);
|
|
return instance;
|
|
}
|
|
|
|
public void Configure(VisualElement ve)
|
|
{
|
|
ve.Q<Label>(so.TitleId).text = Title;
|
|
ve.Q<Label>(so.ContentId).text = Content;
|
|
}
|
|
|
|
public IEnumerable<BaseUiEffect> GetEffectsFor(UiEvent timing)
|
|
{
|
|
return so.GetEffectsFor(timing);
|
|
}
|
|
}
|
|
|
|
[CreateAssetMenu(menuName = KitsuneCafeMenu.UiElement + "Modal")]
|
|
public class ModalElement : UiElementSo
|
|
{
|
|
[SerializeField]
|
|
private string titleId = "title";
|
|
public string TitleId => titleId;
|
|
|
|
[SerializeField]
|
|
private string contentId = "content";
|
|
public string ContentId => contentId;
|
|
|
|
public ModalElementInstance Create(string title, string content)
|
|
{
|
|
return new ModalElementInstance(title, content, this);
|
|
}
|
|
}
|
|
}
|