rimworld-animation-studio/Assets/Scripts/GUI/DialogBoxes/SelectActorAddonsDialog.cs

216 lines
8.9 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 SelectActorAddonsDialog : DialogBox
{
public Toggle handLeftToggle;
public Toggle handRightToggle;
public Toggle sexToyToggle;
public Dropdown handLeftAnchor;
public Dropdown handRightAnchor;
public Dropdown sexToyAnchor;
public InputField handLeftAnchoringPawn;
public InputField handRightAnchoringPawn;
public InputField sexToyAnchoringPawn;
public Dropdown handLeftLayer;
public Dropdown handRightLayer;
public Dropdown sexToyLayer;
public GameObject handLeftControls;
public GameObject handRightControls;
public GameObject sexToyControls;
public override void Initialize(bool addedNewTag = false)
{
if (Workspace.animationDef == null) return;
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
if (clip?.GetActorAddon("left hand") != null)
{
switch (clip.GetActorAddon("left hand").AnchorName)
{
case "torso": handLeftAnchor.value = 1; break;
case "head": handLeftAnchor.value = 2; break;
case "groin": handLeftAnchor.value = 3; break;
case "left breast": handLeftAnchor.value = 4; break;
case "right breast": handLeftAnchor.value = 5; break;
default: handLeftAnchor.value = 0; break;
}
}
if (clip?.GetActorAddon("right hand") != null)
{
switch (clip.GetActorAddon("right hand").AnchorName)
{
case "torso": handRightAnchor.value = 1; break;
case "head": handRightAnchor.value = 2; break;
case "groin": handRightAnchor.value = 3; break;
case "left breast": handRightAnchor.value = 4; break;
case "right breast": handRightAnchor.value = 5; break;
default: handRightAnchor.value = 0; break;
}
}
if (clip?.GetActorAddon("dildo") != null)
{
switch (clip.GetActorAddon("dildo").AnchorName)
{
case "torso": sexToyAnchor.value = 1; break;
case "head": sexToyAnchor.value = 2; break;
case "groin": sexToyAnchor.value = 3; break;
case "left breast": sexToyAnchor.value = 4; break;
case "right breast": sexToyAnchor.value = 5; break;
default: sexToyAnchor.value = 0; break;
}
}
if (clip?.GetActorAddon("left hand") != null)
{
handLeftLayer.value = handLeftLayer.options.IndexOf(handLeftLayer.options.First(x => x.text == clip.GetActorAddon("left hand").Layer));
handLeftAnchoringPawn.text = clip.GetActorAddon("left hand").AnchoringActor.ToString();
}
if (clip?.GetActorAddon("right hand") != null)
{
handRightLayer.value = handRightLayer.options.IndexOf(handRightLayer.options.First(x => x.text == clip.GetActorAddon("right hand").Layer));
handRightAnchoringPawn.text = clip.GetActorAddon("right hand").AnchoringActor.ToString();
}
if (clip?.GetActorAddon("dildo") != null)
{
sexToyLayer.value = sexToyLayer.options.IndexOf(sexToyLayer.options.First(x => x.text == clip.GetActorAddon("dildo").Layer));
sexToyAnchoringPawn.text = clip.GetActorAddon("dildo").AnchoringActor.ToString();
}
handLeftToggle.isOn = clip.IsActorAddonVisible("left hand");
handRightToggle.isOn = clip.IsActorAddonVisible("right hand");
sexToyToggle.isOn = clip.IsActorAddonVisible("dildo");
//handLeftControls.SetActive(handLeftToggle.isOn);
//handRightControls.SetActive(handRightToggle.isOn);
//sexToyControls.SetActive(sexToyToggle.isOn);
}
public void OnToggleChanged()
{
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
clip.ShowOrHideActorAddon("left hand", handLeftToggle.isOn);
clip.ShowOrHideActorAddon("right hand", handRightToggle.isOn);
clip.ShowOrHideActorAddon("dildo", sexToyToggle.isOn);
//Initialize();
}
public void OnValueChanged()
{
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
if (clip?.GetActorAddon("left hand") != null)
{
switch (handLeftAnchor.value)
{
case 1: clip.GetActorAddon("left hand").AnchorName = "torso"; break;
case 2: clip.GetActorAddon("left hand").AnchorName = "head"; break;
case 3: clip.GetActorAddon("left hand").AnchorName = "groin"; break;
case 4: clip.GetActorAddon("left hand").AnchorName = "left breast"; break;
case 5: clip.GetActorAddon("left hand").AnchorName = "right breast"; break;
default: clip.GetActorAddon("left hand").AnchorName = null; break;
}
}
if (clip?.GetActorAddon("right hand") != null)
{
switch (handRightAnchor.value)
{
case 1: clip.GetActorAddon("right hand").AnchorName = "torso"; break;
case 2: clip.GetActorAddon("right hand").AnchorName = "head"; break;
case 3: clip.GetActorAddon("right hand").AnchorName = "groin"; break;
case 4: clip.GetActorAddon("right hand").AnchorName = "left breast"; break;
case 5: clip.GetActorAddon("right hand").AnchorName = "right breast"; break;
default: clip.GetActorAddon("right hand").AnchorName = null; break;
}
}
if (clip?.GetActorAddon("dildo") != null)
{
switch (sexToyAnchor.value)
{
case 1: clip.GetActorAddon("dildo").AnchorName = "torso"; break;
case 2: clip.GetActorAddon("dildo").AnchorName = "head"; break;
case 3: clip.GetActorAddon("dildo").AnchorName = "groin"; break;
case 4: clip.GetActorAddon("dildo").AnchorName = "left breast"; break;
case 5: clip.GetActorAddon("dildo").AnchorName = "right breast"; break;
default: clip.GetActorAddon("dildo").AnchorName = null; break;
}
}
//Initialize();
}
public void OnLayerChanged()
{
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
if (clip?.GetActorAddon("left hand") != null)
{ clip.GetActorAddon("left hand").Layer = handLeftLayer.options[handLeftLayer.value].text; }
if (clip?.GetActorAddon("right hand") != null)
{ clip.GetActorAddon("right hand").Layer = handRightLayer.options[handRightLayer.value].text; }
if (clip?.GetActorAddon("dildo") != null)
{ clip.GetActorAddon("dildo").Layer = sexToyLayer.options[sexToyLayer.value].text; }
//Initialize();
}
public void OnAnchoringPawnChanged()
{
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
if (clip?.GetActorAddon("left hand") != null)
{
int i = int.Parse(handLeftAnchoringPawn.text);
if (i < 0) { i = clip.GetOwningActorID(); }
i = Mathf.Clamp(i, 0, Workspace.animationDef.Actors.Count - 1);
clip.GetActorAddon("left hand").AnchoringActor = i;
handLeftAnchoringPawn.SetTextWithoutNotify(i.ToString());
}
if (clip?.GetActorAddon("right hand") != null)
{
int i = int.Parse(handRightAnchoringPawn.text);
if (i < 0) { i = clip.GetOwningActorID(); }
i = Mathf.Clamp(i, 0, Workspace.animationDef.Actors.Count - 1);
clip.GetActorAddon("right hand").AnchoringActor = i;
handRightAnchoringPawn.SetTextWithoutNotify(i.ToString());
}
if (clip?.GetActorAddon("dildo") != null)
{
int i = int.Parse(sexToyAnchoringPawn.text);
if (i < 0) { i = clip.GetOwningActorID(); }
i = Mathf.Clamp(i, 0, Workspace.animationDef.Actors.Count - 1);
clip.GetActorAddon("dildo").AnchoringActor = i;
sexToyAnchoringPawn.SetTextWithoutNotify(i.ToString());
}
}
}
}