Improved adding and removal of anim events

This commit is contained in:
AbstractConcept 2022-09-17 19:06:33 -05:00
parent f0d46df3d6
commit 8523abf957
276 changed files with 1401 additions and 5422 deletions

View file

@ -0,0 +1,36 @@
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 DialogBox : MonoBehaviour
{
public List<GameObject> cloneObjects;
public void Pop()
{
gameObject.SetActive(gameObject.activeSelf == false);
}
public void RemoveCloneObjectsFromParent(Transform parent)
{
for (int i = 0; i < parent.childCount; i++)
{ Destroy(parent.transform.GetChild(i).gameObject); }
}
public GameObject AddCloneObjectToParent(Transform parent, int i = 0)
{
GameObject cloneObject = null;
if (cloneObjects != null && cloneObjects.Count > i)
{ cloneObject = Instantiate(cloneObjects[i], parent); }
return cloneObject;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a554bad525e79e4fb3dea0d391daf48
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,36 @@
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 SelectAnimationDialog : DialogBox
{
public void Initialize(Defs defs)
{
Transform contentWindow = transform.FindDeepChild("Content");
Reset();
for (int i = 0; i < defs.animationDefs.Count; i++)
{
AnimationDef animationDef = defs.animationDefs[i];
Transform _optionButton = AddCloneObjectToParent(contentWindow).transform;
_optionButton.Find("Text").GetComponent<Text>().text = animationDef.defName;
Button buttonComp = _optionButton.GetComponent<Button>();
buttonComp.onClick.AddListener(delegate { Pop(); ApplicationManager.Instance.LoadAnimation(animationDef); });
}
}
public void Reset()
{
Transform contentWindow = transform.FindDeepChild("Content");
RemoveCloneObjectsFromParent(contentWindow);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6db038d692d34c441b171c72c78e0066
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,87 @@
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 SelectBodyDefTypesDialog : DialogBox
{
private Actor actor;
public void Start()
{
Initialize();
}
public void AddBodyDefType(InputField field)
{
Debug.Log("Attempting to add new body def type");
if (field?.text == null || field.text == "")
{ Debug.LogWarning("Input field is null"); return; }
if (Workspace.bodyDefTypes.Contains(field.text))
{ Debug.LogWarning("Body def type is null"); field.text = ""; return; }
Debug.Log("Added new body type def: " + field.text);
Workspace.bodyDefTypes.Add(field.text);
Initialize();
}
public void Initialize(Actor actor = null)
{
if (actor != null)
{ this.actor = actor; }
if (actor == null)
{ actor = this.actor; }
if (actor == null) return;
foreach (string bodyDefType in actor.bodyDefTypes)
{
if (Workspace.bodyDefTypes.Contains(bodyDefType) == false)
{ Workspace.bodyDefTypes.Add(bodyDefType); }
}
Transform contentWindow = transform.FindDeepChild("Content");
Reset();
for (int i = 0; i < Workspace.bodyDefTypes.Count; i++)
{
string bodyDefType = Workspace.bodyDefTypes[i];
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
_optionToggle.Find("Text").GetComponent<Text>().text = bodyDefType;
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
toggleComp.isOn = actor.bodyDefTypes.Contains(bodyDefType);
toggleComp.onValueChanged.AddListener(delegate {
if (toggleComp.isOn && actor.bodyDefTypes.Contains(bodyDefType) == false)
{ actor.bodyDefTypes.Add(bodyDefType); }
else if (toggleComp.isOn == false && actor.bodyDefTypes.Contains(bodyDefType))
{ actor.bodyDefTypes.Remove(bodyDefType); }
});
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
_optionField.Find("Placeholder").GetComponent<Text>().text = "Enter new body def type...";
InputField fieldComp = _optionField.GetComponent<InputField>();
fieldComp.onEndEdit.AddListener(delegate { AddBodyDefType(fieldComp); });
}
public void Reset()
{
Transform contentWindow = transform.FindDeepChild("Content");
RemoveCloneObjectsFromParent(contentWindow);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b66fb83b0bed5a0438f6fbe11f0c35e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,87 @@
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 SelectBodyPartsDialog : DialogBox
{
private Actor actor;
public void Start()
{
Initialize();
}
public void AddBodyPart(InputField field)
{
Debug.Log("Attempting to add new body part");
if (field?.text == null || field.text == "")
{ Debug.LogWarning("Input field is null"); return; }
if (Workspace.bodyParts.Contains(field.text))
{ Debug.LogWarning("Body part is null"); field.text = ""; return; }
Debug.Log("Add new body part: " + field.text);
Workspace.bodyParts.Add(field.text);
Initialize();
}
public void Initialize(Actor actor = null)
{
if (actor != null)
{ this.actor = actor; }
if (actor == null)
{ actor = this.actor; }
if (actor == null) return;
foreach (string bodyPart in actor.requiredGenitals)
{
if (Workspace.bodyParts.Contains(bodyPart) == false)
{ Workspace.bodyParts.Add(bodyPart); }
}
Transform contentWindow = transform.FindDeepChild("Content");
Reset();
for (int i = 0; i < Workspace.bodyParts.Count; i++)
{
string bodyPart = Workspace.bodyParts[i];
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
_optionToggle.Find("Text").GetComponent<Text>().text = bodyPart;
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
toggleComp.isOn = actor.requiredGenitals.Contains(bodyPart);
toggleComp.onValueChanged.AddListener(delegate {
if (toggleComp.isOn && actor.requiredGenitals.Contains(bodyPart) == false)
{ actor.requiredGenitals.Add(bodyPart); }
else if (toggleComp.isOn == false && actor.requiredGenitals.Contains(bodyPart))
{ actor.requiredGenitals.Remove(bodyPart); }
});
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
_optionField.Find("Placeholder").GetComponent<Text>().text = "Enter new body part name...";
InputField fieldComp = _optionField.GetComponent<InputField>();
fieldComp.onEndEdit.AddListener(delegate { AddBodyPart(fieldComp); });
}
public void Reset()
{
Transform contentWindow = transform.FindDeepChild("Content");
RemoveCloneObjectsFromParent(contentWindow);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 459a1b2a918e12f468445853ea5821e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,87 @@
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
{
private Actor actor;
public void Start()
{
Initialize();
}
public void AddDefName(InputField field)
{
Debug.Log("Attempting to add new def name");
if (field?.text == null || field.text == "")
{ Debug.LogWarning("Input field is null"); return; }
if (Workspace.defNames.Contains(field.text))
{ Debug.LogWarning("Def name is null"); field.text = ""; return; }
Debug.Log("Added new def name: " + field.text);
Workspace.defNames.Add(field.text);
Initialize();
}
public void Initialize(Actor actor = null)
{
if (actor != null)
{ this.actor = actor; }
if (actor == null)
{ actor = this.actor; }
if (actor == null) return;
foreach (string defName in actor.defNames)
{
if (Workspace.defNames.Contains(defName) == false)
{ Workspace.defNames.Add(defName); }
}
Transform contentWindow = transform.FindDeepChild("Content");
Reset();
for (int i = 0; i < Workspace.defNames.Count; i++)
{
string defName = Workspace.defNames[i];
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
_optionToggle.Find("Text").GetComponent<Text>().text = defName;
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
toggleComp.isOn = actor.defNames.Contains(defName);
toggleComp.onValueChanged.AddListener(delegate {
if (toggleComp.isOn && actor.defNames.Contains(defName) == false)
{ actor.defNames.Add(defName); }
else if (toggleComp.isOn == false && actor.defNames.Contains(defName))
{ actor.defNames.Remove(defName); }
});
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
_optionField.Find("Placeholder").GetComponent<Text>().text = "Enter new def name...";
InputField fieldComp = _optionField.GetComponent<InputField>();
fieldComp.onEndEdit.AddListener(delegate { AddDefName(fieldComp); });
}
public void Reset()
{
Transform contentWindow = transform.FindDeepChild("Content");
RemoveCloneObjectsFromParent(contentWindow);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9842b9e0fd45d4643af5bed7ba2de307
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,76 @@
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
{
public void Start()
{
Initialize();
}
public void AddBodyPart(InputField field)
{
if (field?.text == null || field.text == "")
{ return; }
if (Workspace.bodyParts.Contains(field.text))
{ field.text = ""; return; }
Workspace.interactionDefTypes.Add(field.text);
Initialize();
}
public void Initialize()
{
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.bodyParts.Count; i++)
{
string interactionDefType = Workspace.interactionDefTypes[i];
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
_optionToggle.Find("Text").GetComponent<Text>().text = interactionDefType;
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); }
else if (toggleComp.isOn == false && Workspace.animationDef.interactionDefTypes.Contains(interactionDefType))
{ Workspace.animationDef.interactionDefTypes.Remove(interactionDefType); }
});
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
_optionField.Find("Placeholder").GetComponent<Text>().text = "Enter new interaction def type...";
InputField fieldComp = _optionField.GetComponent<InputField>();
fieldComp.onEndEdit.AddListener(delegate { AddBodyPart(fieldComp); });
}
public void Reset()
{
Transform contentWindow = transform.FindDeepChild("Content");
RemoveCloneObjectsFromParent(contentWindow);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cace588a3682dc649b94355d8eee4a77
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,76 @@
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 SelectSexTypesDialog : DialogBox
{
public void Start()
{
Initialize();
}
public void AddSexType(InputField field)
{
if (field?.text == null || field.text == "")
{ return; }
if (Workspace.bodyParts.Contains(field.text))
{ field.text = ""; return; }
Workspace.sexTypes.Add(field.text);
Initialize();
}
public void Initialize()
{
if (Workspace.animationDef == null) return;
foreach (string sexType in Workspace.animationDef.sexTypes)
{
if (Workspace.sexTypes.Contains(sexType) == false)
{ Workspace.sexTypes.Add(sexType); }
}
Transform contentWindow = transform.FindDeepChild("Content");
Reset();
for (int i = 0; i < Workspace.bodyParts.Count; i++)
{
string sexType = Workspace.sexTypes[i];
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
_optionToggle.Find("Text").GetComponent<Text>().text = sexType;
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
toggleComp.isOn = Workspace.animationDef.sexTypes.Contains(sexType);
toggleComp.onValueChanged.AddListener(delegate {
if (toggleComp.isOn && Workspace.animationDef.sexTypes.Contains(sexType) == false)
{ Workspace.animationDef.sexTypes.Add(sexType); }
else if (toggleComp.isOn == false && Workspace.animationDef.sexTypes.Contains(sexType))
{ Workspace.animationDef.sexTypes.Remove(sexType); }
});
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
_optionField.Find("Placeholder").GetComponent<Text>().text = "Enter new sex type...";
InputField fieldComp = _optionField.GetComponent<InputField>();
fieldComp.onEndEdit.AddListener(delegate { AddSexType(fieldComp); });
}
public void Reset()
{
Transform contentWindow = transform.FindDeepChild("Content");
RemoveCloneObjectsFromParent(contentWindow);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d4b7a5a5ddb7d744b726c3c13e2fc5e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: