mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Remove and save custom tags
This commit is contained in:
parent
e36ef6a368
commit
2f3f807911
264 changed files with 1118 additions and 498 deletions
|
@ -10,66 +10,57 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectInteractionDefsDialog : DialogBox
|
||||
{
|
||||
public void OnEnable()
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
IEnumerable<string> allTags = Tags.interactionDefTypes.Concat(CustomTags.interactionDefTypes);
|
||||
string placeHolderText = "Enter new interaction def type...";
|
||||
|
||||
public void AddInteractionDef(InputField field)
|
||||
{
|
||||
if (field?.text == null || field.text == "")
|
||||
{ return; }
|
||||
|
||||
if (Workspace.interactionDefTypes.Contains(field.text))
|
||||
{ field.text = ""; return; }
|
||||
|
||||
Workspace.interactionDefTypes.Add(field.text);
|
||||
|
||||
Initialize(true);
|
||||
}
|
||||
|
||||
public void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
foreach (string interactionDefType in Workspace.animationDef.interactionDefTypes)
|
||||
{
|
||||
if (Workspace.interactionDefTypes.Contains(interactionDefType) == false)
|
||||
{ Workspace.interactionDefTypes.Add(interactionDefType); }
|
||||
}
|
||||
|
||||
Transform contentWindow = transform.FindDeepChild("Content");
|
||||
Reset();
|
||||
|
||||
for (int i = 0; i < Workspace.interactionDefTypes.Count; i++)
|
||||
for (int i = 0; i < allTags.Count(); i++)
|
||||
{
|
||||
string interactionDefType = Workspace.interactionDefTypes[i];
|
||||
string tag = allTags.ElementAt(i);
|
||||
|
||||
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
|
||||
_optionToggle.Find("Text").GetComponent<Text>().text = interactionDefType;
|
||||
_optionToggle.Find("Text").GetComponent<Text>().text = tag;
|
||||
|
||||
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
|
||||
toggleComp.isOn = Workspace.animationDef.interactionDefTypes.Contains(interactionDefType);
|
||||
toggleComp.onValueChanged.AddListener(delegate {
|
||||
|
||||
if (toggleComp.isOn && Workspace.animationDef.interactionDefTypes.Contains(interactionDefType) == false)
|
||||
{ Workspace.animationDef.interactionDefTypes.Add(interactionDefType); }
|
||||
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); }
|
||||
|
||||
else if (toggleComp.isOn == false && Workspace.animationDef.interactionDefTypes.Contains(interactionDefType))
|
||||
{ Workspace.animationDef.interactionDefTypes.Remove(interactionDefType); }
|
||||
else if (toggleComp.isOn == false && Workspace.animationDef.interactionDefTypes.Contains(tag))
|
||||
{ Workspace.animationDef.interactionDefTypes.Remove(tag); }
|
||||
|
||||
Workspace.Instance.RecordEvent("Animation InteractionDef");
|
||||
});
|
||||
|
||||
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
|
||||
Button deleteButton = _optionToggle.Find("DeleteButton").GetComponent<Button>();
|
||||
if (deleteButton != null && CustomTags.interactionDefTypes.Contains(tag))
|
||||
{
|
||||
deleteButton.gameObject.SetActive(true);
|
||||
deleteButton.onClick.AddListener(delegate
|
||||
{
|
||||
CustomTags.interactionDefTypes.Remove(tag);
|
||||
ApplicationManager.Instance.SaveCustomArrays();
|
||||
Initialize();
|
||||
});
|
||||
}
|
||||
|
||||
if (addedNewTag && i == allTags.Count() - 1)
|
||||
{ toggleComp.isOn = true; }
|
||||
}
|
||||
|
||||
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
|
||||
_optionField.Find("Placeholder").GetComponent<Text>().text = "Enter new interaction def type...";
|
||||
_optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
|
||||
|
||||
InputField fieldComp = _optionField.GetComponent<InputField>();
|
||||
fieldComp.onEndEdit.AddListener(delegate { AddInteractionDef(fieldComp); });
|
||||
fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.interactionDefTypes, ref CustomTags.interactionDefTypes); });
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue