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,69 +10,58 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectBodyPartsDialog : DialogBox
|
||||
{
|
||||
public void OnEnable()
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
IEnumerable<string> allTags = Tags.bodyParts.Concat(CustomTags.interactionDefTypes);
|
||||
string placeHolderText = "Enter new body part name...";
|
||||
|
||||
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(true);
|
||||
}
|
||||
|
||||
public void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
||||
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++)
|
||||
Transform _appendageToggle = AddCloneObjectToParent(contentWindow).transform;
|
||||
_appendageToggle.Find("Text").GetComponent<Text>().text = "Any appendage";
|
||||
|
||||
Toggle appendageToggleComp = _appendageToggle.GetComponent<Toggle>();
|
||||
appendageToggleComp.isOn = actor.isFucking;
|
||||
appendageToggleComp.onValueChanged.AddListener(delegate { actor.isFucking = appendageToggleComp.isOn; Workspace.Instance.RecordEvent("Actor required body part");});
|
||||
|
||||
Transform _orificeToggle = AddCloneObjectToParent(contentWindow).transform;
|
||||
_orificeToggle.Find("Text").GetComponent<Text>().text = "Any orifice";
|
||||
|
||||
Toggle orificeToggleComp = _orificeToggle.GetComponent<Toggle>();
|
||||
orificeToggleComp.isOn = actor.isFucked;
|
||||
orificeToggleComp.onValueChanged.AddListener(delegate { actor.isFucked = orificeToggleComp.isOn; Workspace.Instance.RecordEvent("Actor required body part"); });
|
||||
|
||||
for (int i = 0; i < allTags.Count(); i++)
|
||||
{
|
||||
string bodyPart = Workspace.bodyParts[i];
|
||||
string tag = allTags.ElementAt(i);
|
||||
|
||||
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
|
||||
_optionToggle.Find("Text").GetComponent<Text>().text = bodyPart;
|
||||
_optionToggle.Find("Text").GetComponent<Text>().text = tag;
|
||||
|
||||
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); }
|
||||
toggleComp.isOn = actor.requiredGenitals.Contains(tag);
|
||||
toggleComp.onValueChanged.AddListener(delegate
|
||||
{
|
||||
if (toggleComp.isOn && actor.requiredGenitals.Contains(tag) == false)
|
||||
{ actor.requiredGenitals.Add(tag); }
|
||||
|
||||
else if (toggleComp.isOn == false && actor.requiredGenitals.Contains(bodyPart))
|
||||
{ actor.requiredGenitals.Remove(bodyPart); }
|
||||
else if (toggleComp.isOn == false && actor.requiredGenitals.Contains(tag))
|
||||
{ actor.requiredGenitals.Remove(tag); }
|
||||
|
||||
Workspace.Instance.RecordEvent("Actor required body part");
|
||||
});
|
||||
|
||||
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
|
||||
if (addedNewTag && i == allTags.Count() - 1)
|
||||
{ toggleComp.isOn = true; }
|
||||
}
|
||||
|
||||
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
|
||||
_optionField.Find("Placeholder").GetComponent<Text>().text = "Enter new body part name...";
|
||||
_optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
|
||||
|
||||
InputField fieldComp = _optionField.GetComponent<InputField>();
|
||||
fieldComp.onEndEdit.AddListener(delegate { AddBodyPart(fieldComp); });
|
||||
fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.bodyParts, ref CustomTags.bodyParts); });
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue