This commit is contained in:
AbstractConcept 2022-12-09 11:40:08 -06:00
parent 0828ecd037
commit 2998865184
9821 changed files with 90 additions and 90 deletions

View file

@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class ConsoleMessagesDialog : MonoBehaviour
{
public bool isExpanded = false;
public GameObject consoleWindow;
public Transform logContent;
public Text stackTrace;
public Text currentMessage;
public Text logMessagePrefab;
public int maxMessages = 500;
private int currentMessages = 0;
public void Start()
{
Application.logMessageReceived += LogMessage;
}
public void ToggleExpand()
{
isExpanded = !isExpanded;
consoleWindow.SetActive(isExpanded);
}
public void LogMessage(string logString, string stackTrace, LogType type)
{
if (currentMessages > maxMessages) return;
currentMessages++;
currentMessage.text = logString;
Text logMessage = Instantiate(logMessagePrefab, logContent);
logMessage.text = logString;
logMessage.GetComponent<Button>().onClick.AddListener(delegate { OpenStackTrace(stackTrace); });
if (type == LogType.Warning)
{
currentMessage.color = Constants.ColorRichOrange;
logMessage.color = Constants.ColorRichOrange;
}
else if (type == LogType.Exception || type == LogType.Error)
{
currentMessage.color = Constants.ColorRed;
logMessage.color = Constants.ColorRed;
}
else
{
currentMessage.color = Constants.ColorDarkGrey;
logMessage.color = Constants.ColorDarkGrey;
}
}
public void OpenStackTrace(string stackTrace)
{
this.stackTrace.text = stackTrace;
}
}
}

View file

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

View file

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class DialogBox : MonoBehaviour
{
public List<GameObject> cloneObjects;
protected virtual void OnEnable()
{
Initialize();
}
public void Pop()
{
Initialize();
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;
}
public void AddCustomTag(InputField field, ref List<string> tags, ref List<string> customTags)
{
if (field?.text == null || field.text == "")
{ return; }
if (tags.Contains(field.text) || customTags.Contains(field.text))
{ field.text = ""; return; }
customTags.Add(field.text);
ApplicationManager.Instance.SaveCustomArrays();
Initialize(true);
}
public void RemoveCustomTag(ref List<string> customTags, string tag)
{
customTags.Remove(tag);
ApplicationManager.Instance.SaveCustomArrays();
Initialize();
}
public void AddCustomRace(InputField field)
{
if (field?.text == null || field.text == "")
{ return; }
PawnRaceDefs.AddDef(new PawnRaceDef(field.text));
ApplicationManager.Instance.SavePawnRaceDefs();
Initialize(true);
}
public virtual void Initialize(bool addedNewTag = false) { }
}
}

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,150 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using SFB;
using System.IO;
namespace RimWorldAnimationStudio
{
public class RaceSettingsDialog : DialogBox
{
public Dropdown raceSelectDropdown;
public Transform raceSettingsWindow;
public Toggle isHumanoidToggle;
public InputField scaleField;
protected override void OnEnable()
{
raceSelectDropdown.ClearOptions();
raceSelectDropdown.AddOptions(DefaultTags.defNames.Concat(CustomTags.defNames).ToList());
base.OnEnable();
}
public override void Initialize(bool addedNewTag = false)
{
Reset();
PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
if (pawnRaceDef == null) return;
isHumanoidToggle.SetIsOnWithoutNotify(pawnRaceDef.isHumanoid);
Text bodyGraphicsTitle = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
bodyGraphicsTitle.text = "Body graphic filepaths";
List<string> allTags = pawnRaceDef.isHumanoid ? DefaultTags.bodyTypes : new List<string>() { "None" };
foreach (string bodyType in allTags)
{
string _bodyType = bodyType;
if (pawnRaceDef.isHumanoid)
{
Text bodyTypeTitle = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
bodyTypeTitle.text = bodyType;
}
for (int i = 2; i >= 0; i--)
{
CardinalDirection facing = (CardinalDirection)i;
GameObject filepath = AddCloneObjectToParent(raceSettingsWindow, 0);
filepath.GetComponent<Text>().text = facing.ToString();
filepath.transform.Find("FilepathButton").GetComponent<Button>().onClick.AddListener(delegate
{
SetBodyTypeGraphicPath(pawnRaceDef, facing, _bodyType);
});
filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = pawnRaceDef.GetBodyTypeGraphicPath(facing, _bodyType);
}
AddCloneObjectToParent(raceSettingsWindow, 3);
}
if (pawnRaceDef.isHumanoid)
{
Text headGraphics = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
headGraphics.text = "Head graphic filepaths";
for (int i = 2; i >= 0; i--)
{
CardinalDirection facing = (CardinalDirection)i;
GameObject filepath = AddCloneObjectToParent(raceSettingsWindow, 0);
filepath.GetComponent<Text>().text = facing.ToString();
filepath.transform.Find("FilepathButton").GetComponent<Button>().onClick.AddListener(delegate
{
SetHeadGraphicPath(pawnRaceDef, facing);
});
filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = pawnRaceDef.GetHeadGraphicPath(facing);
}
AddCloneObjectToParent(raceSettingsWindow, 3);
}
scaleField.text = string.Format("{0:0.000}", pawnRaceDef.scale);
}
public void Reset()
{
RemoveCloneObjectsFromParent(raceSettingsWindow);
}
public void SetIsHumanoid()
{
PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
if (pawnRaceDef == null) return;
pawnRaceDef.isHumanoid = isHumanoidToggle.isOn;
Initialize();
}
public void SetHeadGraphicPath(PawnRaceDef pawnRaceDef, CardinalDirection direction)
{
var paths = StandaloneFileBrowser.OpenFilePanel("Select texture File", "", "png", false);
if (paths == null || paths.Any() == false || File.Exists(paths[0]) == false)
{ Debug.LogWarning("Selected file was null or invalid"); return; }
pawnRaceDef.SetHeadGraphicPath(paths[0], direction);
Initialize();
}
public void SetBodyTypeGraphicPath(PawnRaceDef pawnRaceDef, CardinalDirection direction, string bodyType)
{
var paths = StandaloneFileBrowser.OpenFilePanel("Select texture File", "", "png", false);
if (paths == null || paths.Any() == false || File.Exists(paths[0]) == false)
{ Debug.LogWarning("Selected file was null or invalid"); return; }
pawnRaceDef.SetBodyTypeGraphicPath(paths[0], direction, bodyType);
Initialize();
}
public PawnRaceDef GetCurrentRaceDef()
{
string pawnRaceDefName = raceSelectDropdown.value < raceSelectDropdown.options.Count ? raceSelectDropdown.options[raceSelectDropdown.value].text : "Human";
if (pawnRaceDefName == null || pawnRaceDefName == "") pawnRaceDefName = "Human";
return PawnRaceDefs.GetNamed(pawnRaceDefName);
}
public void SetRaceScale()
{
PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
if (pawnRaceDef == null) return;
float scale = float.Parse(scaleField.text);
pawnRaceDef.scale = Mathf.Clamp(scale, 0.01f, 100f);
scaleField.text = string.Format("{0:0.000}", pawnRaceDef.scale);
}
}
}

View file

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

View file

@ -0,0 +1,20 @@
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 SelectActorAddonsDialog : DialogBox
{
private List<ActorAddonCard> actorAddonCards = new List<ActorAddonCard>();
public void AddActorAddonCard(ActorAddonCard actorAddonCard)
{
actorAddonCards.Add(actorAddonCard);
}
}
}

View file

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

View file

@ -0,0 +1,49 @@
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 SelectActorLayerDialog : DialogBox
{
public void Initialize()
{
if (Workspace.animationDef == null) return;
Transform contentWindow = transform.FindDeepChild("Content");
Reset();
for (int i = 0; i < DefaultTags.actorLayers.Count; i++)
{
string actorLayer = DefaultTags.actorLayers[i];
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
_optionToggle.Find("Text").GetComponent<Text>().text = actorLayer;
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
toggleComp.isOn = Workspace.GetCurrentPawnAnimationClip().Layer == actorLayer;
toggleComp.onValueChanged.AddListener(delegate {
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
if (clip != null)
{ clip.Layer = actorLayer; }
Workspace.RecordEvent("Actor layer set");
});
toggleComp.group = contentWindow.GetComponent<ToggleGroup>();
}
}
public void Reset()
{
Transform contentWindow = transform.FindDeepChild("Content");
RemoveCloneObjectsFromParent(contentWindow);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce4b68a13ad01b14f97697ab310a74d9
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(AnimationDefs 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,66 @@
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
{
public override void Initialize(bool addedNewTag = false)
{
IEnumerable<string> allTags = DefaultTags.bodyDefTypes.Concat(CustomTags.bodyDefTypes);
string placeHolderText = "Enter new body def type...";
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.BodyDefTypes.Contains(tag);
toggleComp.onValueChanged.AddListener(delegate
{
if (toggleComp.isOn && actor.BodyDefTypes.Contains(tag) == false)
{ actor.BodyDefTypes.Add(tag); }
else if (toggleComp.isOn == false && actor.BodyDefTypes.Contains(tag))
{ actor.BodyDefTypes.Remove(tag); }
Workspace.RecordEvent("Actor bodyDef type");
});
if (CustomTags.bodyDefTypes.Contains(tag))
{
Button deleteButton = _optionToggle.Find("DeleteButton").GetComponent<Button>();
deleteButton.gameObject.SetActive(true);
deleteButton.onClick.AddListener(delegate { RemoveCustomTag(ref CustomTags.bodyDefTypes, 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.bodyDefTypes, ref CustomTags.bodyDefTypes); });
}
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,80 @@
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
{
public override void Initialize(bool addedNewTag = false)
{
IEnumerable<string> allTags = DefaultTags.bodyParts.Concat(CustomTags.bodyParts);
string placeHolderText = "Enter new body part name...";
Actor actor = Workspace.animationDef.Actors[Workspace.ActorID];
Transform contentWindow = transform.FindDeepChild("Content");
Reset();
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.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.RecordEvent("Actor required body part"); });
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.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(tag))
{ actor.RequiredGenitals.Remove(tag); }
Workspace.RecordEvent("Actor required body part");
});
if (CustomTags.bodyParts.Contains(tag))
{
Button deleteButton = _optionToggle.Find("DeleteButton").GetComponent<Button>();
deleteButton.gameObject.SetActive(true);
deleteButton.onClick.AddListener(delegate { RemoveCustomTag(ref CustomTags.bodyParts, 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.bodyParts, ref CustomTags.bodyParts); });
}
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,74 @@
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);
EventsManager.OnDefNamesChanged();
});
}
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);
EventsManager.OnDefNamesChanged();
});
}
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,67 @@
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 override void Initialize(bool addedNewTag = false)
{
IEnumerable<string> allTags = DefaultTags.interactionDefTypes.Concat(CustomTags.interactionDefTypes);
string placeHolderText = "Enter new interaction def type...";
if (Workspace.animationDef == null) return;
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 = 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(tag))
{ Workspace.animationDef.InteractionDefTypes.Remove(tag); }
Workspace.RecordEvent("Animation InteractionDef");
});
if (CustomTags.interactionDefTypes.Contains(tag))
{
Button deleteButton = _optionToggle.Find("DeleteButton").GetComponent<Button>();
deleteButton.gameObject.SetActive(true);
deleteButton.onClick.AddListener(delegate { RemoveCustomTag(ref CustomTags.interactionDefTypes, 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.interactionDefTypes, ref CustomTags.interactionDefTypes); });
}
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,67 @@
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 override void Initialize(bool addedNewTag = false)
{
IEnumerable<string> allTags = DefaultTags.sexTypes.Concat(CustomTags.sexTypes);
string placeHolderText = "Enter new sex type...";
if (Workspace.animationDef == null) return;
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 = Workspace.animationDef.SexTypes.Contains(tag);
toggleComp.onValueChanged.AddListener(delegate
{
if (toggleComp.isOn && Workspace.animationDef.SexTypes.Contains(tag) == false)
{ Workspace.animationDef.SexTypes.Add(tag); }
else if (toggleComp.isOn == false && Workspace.animationDef.SexTypes.Contains(tag))
{ Workspace.animationDef.SexTypes.Remove(tag); }
Workspace.RecordEvent("Animation sex type");
});
if (CustomTags.sexTypes.Contains(tag))
{
Button deleteButton = _optionToggle.Find("DeleteButton").GetComponent<Button>();
deleteButton.gameObject.SetActive(true);
deleteButton.onClick.AddListener(delegate { RemoveCustomTag(ref CustomTags.sexTypes, 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.sexTypes, ref CustomTags.sexTypes); });
}
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:

View file

@ -0,0 +1,68 @@
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 SelectSoundDefDialog : DialogBox
{
public override void Initialize(bool addedNewTag = false)
{
IEnumerable<string> allTags = DefaultTags.soundDefs.Concat(CustomTags.soundDefs);
string placeHolderText = "Enter new sound def...";
if (Workspace.animationDef == null) return;
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 = Workspace.GetCurrentOrPreviousKeyframe(Workspace.ActorID)?.SoundEffect == tag;
toggleComp.onValueChanged.AddListener(delegate
{
PawnKeyframe keyframe = Workspace.GetCurrentOrPreviousKeyframe(Workspace.ActorID);
if (keyframe != null)
{ keyframe.SoundEffect = tag; }
Workspace.RecordEvent("Keyframe sound effect");
});
if (CustomTags.soundDefs.Contains(tag))
{
Button deleteButton = _optionToggle.Find("DeleteButton").GetComponent<Button>();
deleteButton.gameObject.SetActive(true);
deleteButton.onClick.AddListener(delegate { RemoveCustomTag(ref CustomTags.soundDefs, tag); });
}
if (addedNewTag && i == allTags.Count() - 1)
{ toggleComp.isOn = true; }
toggleComp.group = contentWindow.GetComponent<ToggleGroup>();
}
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.soundDefs, ref CustomTags.soundDefs); });
}
public void Reset()
{
Transform contentWindow = transform.FindDeepChild("Content");
RemoveCloneObjectsFromParent(contentWindow);
}
}
}

View file

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