2022-09-15 05:17:44 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
namespace RimWorldAnimationStudio
|
|
|
|
|
{
|
|
|
|
|
public class SelectInteractionDefsDialog : DialogBox
|
|
|
|
|
{
|
2022-09-21 21:15:25 +00:00
|
|
|
|
public override void Initialize(bool addedNewTag = false)
|
2022-09-15 05:17:44 +00:00
|
|
|
|
{
|
2022-09-21 21:15:25 +00:00
|
|
|
|
IEnumerable<string> allTags = Tags.interactionDefTypes.Concat(CustomTags.interactionDefTypes);
|
|
|
|
|
string placeHolderText = "Enter new interaction def type...";
|
2022-09-15 05:17:44 +00:00
|
|
|
|
|
|
|
|
|
if (Workspace.animationDef == null) return;
|
|
|
|
|
|
|
|
|
|
Transform contentWindow = transform.FindDeepChild("Content");
|
|
|
|
|
Reset();
|
|
|
|
|
|
2022-09-21 21:15:25 +00:00
|
|
|
|
for (int i = 0; i < allTags.Count(); i++)
|
2022-09-15 05:17:44 +00:00
|
|
|
|
{
|
2022-09-21 21:15:25 +00:00
|
|
|
|
string tag = allTags.ElementAt(i);
|
2022-09-15 05:17:44 +00:00
|
|
|
|
|
|
|
|
|
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
|
2022-09-21 21:15:25 +00:00
|
|
|
|
_optionToggle.Find("Text").GetComponent<Text>().text = tag;
|
2022-09-15 05:17:44 +00:00
|
|
|
|
|
|
|
|
|
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
|
2022-09-21 21:15:25 +00:00
|
|
|
|
toggleComp.isOn = Workspace.animationDef.interactionDefTypes.Contains(tag);
|
|
|
|
|
toggleComp.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
|
|
|
|
if (toggleComp.isOn && Workspace.animationDef.interactionDefTypes.Contains(tag) == false)
|
|
|
|
|
{ Workspace.animationDef.interactionDefTypes.Add(tag); }
|
2022-09-15 05:17:44 +00:00
|
|
|
|
|
2022-09-21 21:15:25 +00:00
|
|
|
|
else if (toggleComp.isOn == false && Workspace.animationDef.interactionDefTypes.Contains(tag))
|
|
|
|
|
{ Workspace.animationDef.interactionDefTypes.Remove(tag); }
|
2022-09-19 05:35:34 +00:00
|
|
|
|
|
2022-09-21 05:40:58 +00:00
|
|
|
|
Workspace.Instance.RecordEvent("Animation InteractionDef");
|
2022-09-15 05:17:44 +00:00
|
|
|
|
});
|
2022-09-19 05:35:34 +00:00
|
|
|
|
|
2022-10-12 05:22:29 +00:00
|
|
|
|
if (CustomTags.interactionDefTypes.Contains(tag))
|
2022-09-21 21:15:25 +00:00
|
|
|
|
{
|
2022-10-12 05:22:29 +00:00
|
|
|
|
Button deleteButton = _optionToggle.Find("DeleteButton").GetComponent<Button>();
|
2022-09-21 21:15:25 +00:00
|
|
|
|
deleteButton.gameObject.SetActive(true);
|
2022-10-12 05:22:29 +00:00
|
|
|
|
deleteButton.onClick.AddListener(delegate { RemoveCustomTag(ref CustomTags.interactionDefTypes, tag); });
|
2022-09-21 21:15:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addedNewTag && i == allTags.Count() - 1)
|
2022-09-19 05:35:34 +00:00
|
|
|
|
{ toggleComp.isOn = true; }
|
2022-09-15 05:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
|
2022-09-21 21:15:25 +00:00
|
|
|
|
_optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
|
2022-09-15 05:17:44 +00:00
|
|
|
|
|
|
|
|
|
InputField fieldComp = _optionField.GetComponent<InputField>();
|
2022-09-21 21:15:25 +00:00
|
|
|
|
fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.interactionDefTypes, ref CustomTags.interactionDefTypes); });
|
2022-09-15 05:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
Transform contentWindow = transform.FindDeepChild("Content");
|
|
|
|
|
RemoveCloneObjectsFromParent(contentWindow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|