64 lines
1.5 KiB
C#
64 lines
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class JobSelectorUI : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private TextMeshProUGUI _title;
|
|
[SerializeField]
|
|
private TextMeshProUGUI _description;
|
|
[SerializeField]
|
|
private Button _btnCancel;
|
|
[SerializeField]
|
|
private Button _btnOk;
|
|
|
|
[SerializeField]
|
|
private Transform _container;
|
|
[SerializeField]
|
|
private JobItemUITemplate _jobItemUItemplate;
|
|
[SerializeField]
|
|
private JobsListSO _jobs;
|
|
|
|
public void ShowJobSelectionDialog(string title, string description, Action onCancel, Action<TimeSpan> onConfirm)
|
|
{
|
|
UIManager.Instance.Freeze();
|
|
|
|
gameObject.SetActive(true);
|
|
_title.text = title;
|
|
_description.text = description;
|
|
|
|
foreach (var job in _jobs.JobPositionsList)
|
|
{
|
|
var itemUI = Instantiate(_jobItemUItemplate, _container);
|
|
itemUI.gameObject.SetActive(true);
|
|
itemUI.GetComponent<JobItemUITemplate>().SetItem((job));
|
|
}
|
|
|
|
_btnCancel.onClick.AddListener(() =>
|
|
{
|
|
onCancel?.Invoke();
|
|
Hide();
|
|
CloseDialog();
|
|
});
|
|
_btnOk.onClick.AddListener(() =>
|
|
{
|
|
Hide();
|
|
});
|
|
}
|
|
private void CloseDialog()
|
|
{
|
|
UIManager.Instance.Unfreeze();
|
|
Destroy(this);
|
|
}
|
|
|
|
private void Hide()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|