mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
70 lines
2.6 KiB
C#
70 lines
2.6 KiB
C#
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 SelectDefNamesDialog : DialogBox
|
|
{
|
|
public override void Initialize(bool addedNewTag = false)
|
|
{
|
|
IEnumerable<string> allTags = DefaultTags.defNames.Concat(CustomTags.defNames);
|
|
string placeHolderText = "Enter new def name...";
|
|
|
|
Actor actor = Workspace.animationDef.Actors[Workspace.ActorID];
|
|
Transform contentWindow = transform.FindDeepChild("Content");
|
|
Reset();
|
|
|
|
for (int i = 0; i < allTags.Count(); i++)
|
|
{
|
|
string tag = allTags.ElementAt(i);
|
|
|
|
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
|
|
_optionToggle.Find("Text").GetComponent<Text>().text = tag;
|
|
|
|
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
|
|
toggleComp.isOn = actor.DefNames.Contains(tag);
|
|
toggleComp.onValueChanged.AddListener(delegate
|
|
{
|
|
if (toggleComp.isOn && actor.DefNames.Contains(tag) == false)
|
|
{ actor.DefNames.Add(tag); }
|
|
|
|
else if (toggleComp.isOn == false && actor.DefNames.Contains(tag))
|
|
{ actor.DefNames.Remove(tag); }
|
|
|
|
Workspace.RecordEvent("Actor def name");
|
|
});
|
|
|
|
if (CustomTags.defNames.Contains(tag))
|
|
{
|
|
Button deleteButton = _optionToggle.Find("DeleteButton").GetComponent<Button>();
|
|
deleteButton.gameObject.SetActive(true);
|
|
deleteButton.onClick.AddListener(delegate { RemoveCustomTag(ref CustomTags.defNames, tag); });
|
|
}
|
|
|
|
if (addedNewTag && i == allTags.Count() - 1)
|
|
{ toggleComp.isOn = true; }
|
|
}
|
|
|
|
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
|
|
_optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
|
|
|
|
InputField fieldComp = _optionField.GetComponent<InputField>();
|
|
fieldComp.onEndEdit.AddListener(delegate
|
|
{
|
|
AddCustomTag(fieldComp, ref DefaultTags.defNames, ref CustomTags.defNames);
|
|
AddCustomRace(fieldComp);
|
|
});
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Transform contentWindow = transform.FindDeepChild("Content");
|
|
RemoveCloneObjectsFromParent(contentWindow);
|
|
}
|
|
}
|
|
}
|