mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
v 1.0.0
This commit is contained in:
parent
0828ecd037
commit
2998865184
9821 changed files with 90 additions and 90 deletions
102
Source/Assets/Scripts/GUI/Cards/ActorAddonCard.cs
Normal file
102
Source/Assets/Scripts/GUI/Cards/ActorAddonCard.cs
Normal file
|
@ -0,0 +1,102 @@
|
|||
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 ActorAddonCard : MonoBehaviour
|
||||
{
|
||||
public string addonName;
|
||||
public Text label;
|
||||
public Toggle toggle;
|
||||
public Dropdown anchorDropdown;
|
||||
public InputField anchoringPawnField;
|
||||
public Dropdown layerDropdown;
|
||||
public ActorAddonKeyframeCard actorAddonKeyframeCard;
|
||||
|
||||
private ActorAddonDef actorAddonDef;
|
||||
|
||||
private PawnAnimationClip clip { get { return Workspace.GetCurrentPawnAnimationClip(); } }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialize(ActorAddonDef actorAddonDef, ActorAddonKeyframeCard actorAddonKeyframeCard)
|
||||
{
|
||||
this.actorAddonDef = actorAddonDef;
|
||||
this.actorAddonKeyframeCard = actorAddonKeyframeCard;
|
||||
|
||||
addonName = actorAddonDef.addonName;
|
||||
label.text = actorAddonDef.label;
|
||||
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
if (Workspace.animationDef == null || string.IsNullOrEmpty(addonName)) return;
|
||||
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{
|
||||
int i = Constants.bodyPartAnchorNames.Keys.ToList().IndexOf(clip.GetActorAddon(addonName).AnchorName);
|
||||
anchorDropdown.SetValueWithoutNotify(i);
|
||||
layerDropdown.SetValueWithoutNotify(layerDropdown.options.IndexOf(layerDropdown.options.First(x => x.text == clip.GetActorAddon(addonName).Layer)));
|
||||
anchoringPawnField.SetTextWithoutNotify(clip.GetActorAddon(addonName).AnchoringActor.ToString());
|
||||
toggle.SetIsOnWithoutNotify(clip.IsActorAddonVisible(addonName));
|
||||
|
||||
anchoringPawnField.interactable = anchorDropdown.value != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnToggleChanged()
|
||||
{
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{ clip.GetActorAddon(addonName).render = toggle.isOn; }
|
||||
|
||||
EventsManager.OnPawnKeyframeChanged(null);
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnAnchorChanged()
|
||||
{
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{ clip.GetActorAddon(addonName).AnchorName = Constants.bodyPartAnchorNames.Keys.ElementAt(anchorDropdown.value); }
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnLayerChanged()
|
||||
{
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{ clip.GetActorAddon(addonName).Layer = layerDropdown.options[layerDropdown.value].text; }
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnAnchoringPawnChanged()
|
||||
{
|
||||
if (clip?.GetActorAddon(addonName) != null)
|
||||
{
|
||||
int i = int.Parse(anchoringPawnField.text);
|
||||
|
||||
if (i < 0) { i = clip.GetOwningActorID(); }
|
||||
i = Mathf.Clamp(i, 0, Workspace.animationDef.Actors.Count - 1);
|
||||
|
||||
clip.GetActorAddon(addonName).AnchoringActor = i;
|
||||
anchoringPawnField.SetTextWithoutNotify(i.ToString());
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/GUI/Cards/ActorAddonCard.cs.meta
Normal file
11
Source/Assets/Scripts/GUI/Cards/ActorAddonCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 919aed3c4b9671c4e8dc109c7d608683
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
71
Source/Assets/Scripts/GUI/Cards/ActorAddonKeyframeCard.cs
Normal file
71
Source/Assets/Scripts/GUI/Cards/ActorAddonKeyframeCard.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
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 ActorAddonKeyframeCard : MonoBehaviour
|
||||
{
|
||||
public string addonName;
|
||||
public Text label;
|
||||
public InputField xOffsetField;
|
||||
public InputField zOffsetField;
|
||||
public InputField rotationField;
|
||||
|
||||
private ActorAddonDef actorAddonDef;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initialize(ActorAddonDef actorAddonDef)
|
||||
{
|
||||
this.actorAddonDef = actorAddonDef;
|
||||
this.addonName = actorAddonDef.addonName;
|
||||
|
||||
label.text = actorAddonDef.label + ":";
|
||||
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageTickChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onPawnKeyframeChanged.AddListener(delegate { UpdateGUI(); });
|
||||
|
||||
xOffsetField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
zOffsetField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
rotationField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnValueChanged()
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
|
||||
|
||||
keyframe.GetAddonKeyframe(addonName).PosX = float.Parse(xOffsetField.text);
|
||||
keyframe.GetAddonKeyframe(addonName).PosZ = float.Parse(zOffsetField.text);
|
||||
keyframe.GetAddonKeyframe(addonName).Rotation = float.Parse(rotationField.text);
|
||||
|
||||
Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
|
||||
Workspace.RecordEvent("Actor addon position / orientation");
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.GetCurrentPawnAnimationClip();
|
||||
|
||||
xOffsetField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).PosX.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
zOffsetField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).PosZ.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
rotationField.SetTextWithoutNotify(string.Format("{0:0.000}", clip.GetActorAddon(addonName).Rotation.Evaluate((float)Workspace.StageTick / Workspace.StageWindowSize)));
|
||||
|
||||
gameObject.SetActive(clip.GetActorAddon(addonName).render == true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8a63bb35c73985c46b65383f08d4afd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
129
Source/Assets/Scripts/GUI/Cards/ActorCard.cs
Normal file
129
Source/Assets/Scripts/GUI/Cards/ActorCard.cs
Normal file
|
@ -0,0 +1,129 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorCard : MonoBehaviour
|
||||
{
|
||||
public Toggle initiatorToggle;
|
||||
public Dropdown selectActorLayerDropdown;
|
||||
public Dropdown bodyTypeDropdown;
|
||||
public InputField bodyOffsetXField;
|
||||
public InputField bodyOffsetZField;
|
||||
public Dropdown raceDropdown;
|
||||
public InputField raceOffsetXField;
|
||||
public InputField raceOffsetZField;
|
||||
|
||||
private Actor actor { get { return Workspace.GetCurrentActor(); } }
|
||||
private PawnAnimationClip clip { get { return Workspace.GetCurrentPawnAnimationClip(); } }
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
UpdateRaceDropdown();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
// General events
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onDefNamesChanged.AddListener(delegate { UpdateRaceDropdown(); });
|
||||
|
||||
// Local events
|
||||
initiatorToggle.onValueChanged.AddListener(delegate {
|
||||
actor.initiator = initiatorToggle.isOn;
|
||||
Workspace.RecordEvent("Change in actor sex initiator status ");
|
||||
});
|
||||
|
||||
selectActorLayerDropdown.onValueChanged.AddListener(delegate {
|
||||
clip.Layer = selectActorLayerDropdown.options[selectActorLayerDropdown.value].text;
|
||||
Workspace.RecordEvent("Change in actor render layer");
|
||||
});
|
||||
|
||||
bodyTypeDropdown.onValueChanged.AddListener(delegate { OnDropdownChanged(); });
|
||||
bodyOffsetXField.onEndEdit.AddListener(delegate { OnInputFieldChanged(); });
|
||||
bodyOffsetZField.onEndEdit.AddListener(delegate { OnInputFieldChanged(); });
|
||||
|
||||
raceDropdown.onValueChanged.AddListener(delegate { OnDropdownChanged(); });
|
||||
raceOffsetXField.onEndEdit.AddListener(delegate { OnInputFieldChanged(); });
|
||||
raceOffsetZField.onEndEdit.AddListener(delegate { OnInputFieldChanged(); });
|
||||
|
||||
// Initialize
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnInputFieldChanged()
|
||||
{
|
||||
string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
|
||||
bodyType = string.IsNullOrEmpty(bodyType) ? "Male" : bodyType;
|
||||
|
||||
float.TryParse(bodyOffsetXField.text, out float x);
|
||||
float.TryParse(bodyOffsetZField.text, out float z);
|
||||
actor.BodyTypeOffset.SetOffset(bodyType, new Vector2(x, z));
|
||||
|
||||
float.TryParse(raceOffsetXField.text, out x);
|
||||
float.TryParse(raceOffsetZField.text, out z);
|
||||
actor.SetPawnRaceOffset(new Vector2(x, z));
|
||||
|
||||
Workspace.RecordEvent("Actor offset");
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnDropdownChanged()
|
||||
{
|
||||
actor.bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
|
||||
|
||||
if (raceDropdown.options[raceDropdown.value].text != actor.GetPawnRaceDef().defName)
|
||||
{ Workspace.selectedBodyPart = null; }
|
||||
|
||||
actor.SetPawnRaceDef(raceDropdown.options[raceDropdown.value].text);
|
||||
|
||||
Workspace.RecordEvent("Actor body type/race change");
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateRaceDropdown()
|
||||
{
|
||||
int index = raceDropdown.value;
|
||||
raceDropdown.ClearOptions();
|
||||
|
||||
IEnumerable<string> optionsList = DefaultTags.defNames.Concat(CustomTags.defNames);
|
||||
foreach (string defName in optionsList)
|
||||
{ raceDropdown.options.Add(new Dropdown.OptionData(defName)); }
|
||||
|
||||
raceDropdown.value = Mathf.Clamp(index, 0, raceDropdown.options.Count - 1);
|
||||
raceDropdown.captionText.text = raceDropdown.options[raceDropdown.value].text;
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
initiatorToggle.isOn = actor.Initiator;
|
||||
|
||||
string layer = clip.Layer;
|
||||
selectActorLayerDropdown.SetValueWithoutNotify(selectActorLayerDropdown.options.FindIndex(x => x.text == layer));
|
||||
|
||||
string bodyType = actor.bodyType;
|
||||
bodyTypeDropdown.SetValueWithoutNotify(bodyTypeDropdown.options.FindIndex(x => x.text == bodyType));
|
||||
|
||||
bodyOffsetXField.SetTextWithoutNotify(string.Format("{0:0.000}", actor.BodyTypeOffset.GetOffset(bodyType).x));
|
||||
bodyOffsetZField.SetTextWithoutNotify(string.Format("{0:0.000}", actor.BodyTypeOffset.GetOffset(bodyType).z));
|
||||
|
||||
bodyTypeDropdown.interactable = actor.GetPawnRaceDef().isHumanoid;
|
||||
bodyOffsetXField.interactable = actor.GetPawnRaceDef().isHumanoid;
|
||||
bodyOffsetZField.interactable = actor.GetPawnRaceDef().isHumanoid;
|
||||
|
||||
string race = actor.GetPawnRaceDef().defName;
|
||||
raceDropdown.SetValueWithoutNotify(raceDropdown.options.FindIndex(x => x.text == race));
|
||||
|
||||
raceOffsetXField.SetTextWithoutNotify(string.Format("{0:0.000}", actor.GetPawnRaceOffset().x));
|
||||
raceOffsetZField.SetTextWithoutNotify(string.Format("{0:0.000}", actor.GetPawnRaceOffset().z));
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/GUI/Cards/ActorCard.cs.meta
Normal file
11
Source/Assets/Scripts/GUI/Cards/ActorCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9731614c7527b624492dd33f9b006fcb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
87
Source/Assets/Scripts/GUI/Cards/ActorKeyframeCard.cs
Normal file
87
Source/Assets/Scripts/GUI/Cards/ActorKeyframeCard.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorKeyframeCard : Singleton<ActorKeyframeCard>
|
||||
{
|
||||
public InputField positionXField;
|
||||
public InputField positionZField;
|
||||
public InputField rotationField;
|
||||
public InputField headBobField;
|
||||
public InputField headRotationField;
|
||||
public InputField appendageRotationField;
|
||||
|
||||
public ActorAddonCard actorAddonCardPrefab;
|
||||
public ActorAddonKeyframeCard actorAddonKeyframeCardPrefab;
|
||||
|
||||
public Transform actorAddonCards;
|
||||
public Transform actorKeyframeCards;
|
||||
|
||||
public SelectActorAddonsDialog selectActorAddonsDialog;
|
||||
|
||||
private Actor actor { get { return Workspace.GetCurrentActor(); } }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageTickChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onKeyframeCountChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onPawnKeyframeChanged.AddListener(delegate { UpdateGUI(); });
|
||||
|
||||
positionXField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
positionZField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
rotationField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
headBobField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
headRotationField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
appendageRotationField.onEndEdit.AddListener(delegate { OnValueChanged(); });
|
||||
|
||||
foreach (ActorAddonDef actorAddonDef in ActorAddonDefs.allDefs)
|
||||
{
|
||||
ActorAddonKeyframeCard actorAddonKeyframeCard = Instantiate(actorAddonKeyframeCardPrefab, actorKeyframeCards);
|
||||
actorAddonKeyframeCard.Initialize(actorAddonDef);
|
||||
|
||||
ActorAddonCard actorAddonCard = Instantiate(actorAddonCardPrefab, actorAddonCards);
|
||||
actorAddonCard.Initialize(actorAddonDef, actorAddonKeyframeCard);
|
||||
|
||||
selectActorAddonsDialog.AddActorAddonCard(actorAddonCard);
|
||||
}
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnValueChanged()
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
|
||||
|
||||
keyframe.BodyOffsetX = float.Parse(positionXField.text);
|
||||
keyframe.BodyOffsetZ = float.Parse(positionZField.text);
|
||||
keyframe.BodyAngle = float.Parse(rotationField.text);
|
||||
keyframe.HeadBob = float.Parse(headBobField.text);
|
||||
keyframe.HeadAngle = float.Parse(headRotationField.text);
|
||||
keyframe.GenitalAngle = float.Parse(appendageRotationField.text);
|
||||
|
||||
Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
|
||||
Workspace.RecordEvent("Actor position / orientation");
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
ActorPosition actorPosition = actor.GetCurrentPosition();
|
||||
|
||||
positionXField.SetTextWithoutNotify(string.Format("{0:0.000}", actorPosition.bodyOffsetX));
|
||||
positionZField.SetTextWithoutNotify(string.Format("{0:0.000}", actorPosition.bodyOffsetZ));
|
||||
rotationField.SetTextWithoutNotify(string.Format("{0:0.000}", actorPosition.bodyAngle));
|
||||
headBobField.SetTextWithoutNotify(string.Format("{0:0.000}", actorPosition.headBob));
|
||||
headRotationField.SetTextWithoutNotify(string.Format("{0:0.000}", actorPosition.headAngle));
|
||||
appendageRotationField.SetTextWithoutNotify(string.Format("{0:0.000}", actorPosition.genitalAngle));
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/GUI/Cards/ActorKeyframeCard.cs.meta
Normal file
11
Source/Assets/Scripts/GUI/Cards/ActorKeyframeCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 58ad3d066d9103541806d07bc98823d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
94
Source/Assets/Scripts/GUI/Cards/AnimationControlCard.cs
Normal file
94
Source/Assets/Scripts/GUI/Cards/AnimationControlCard.cs
Normal file
|
@ -0,0 +1,94 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class AnimationControlCard : MonoBehaviour
|
||||
{
|
||||
public InputField currentTimeField;
|
||||
public InputField stageWindowLengthField;
|
||||
public InputField playBackSpeedField;
|
||||
public Button playToggleButton;
|
||||
public Slider stageTimelineSlider;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageIDChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageTickChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onAnimationToggled.AddListener(delegate { playToggleButton.image.color = Workspace.IsAnimating ? Constants.ColorGoldYellow : Constants.ColorWhite; });
|
||||
|
||||
stageTimelineSlider.onValueChanged.AddListener(delegate { OnStageTimelineSliderChange(); });
|
||||
currentTimeField.onEndEdit.AddListener(delegate { OnCurrentTimeFieldChange(); });
|
||||
stageWindowLengthField.onEndEdit.AddListener(delegate { OnStageWindowLengthFieldChange(); });
|
||||
playBackSpeedField.onEndEdit.AddListener(delegate { OnPlayBackSpeedChange(); });
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnStageTimelineSliderChange()
|
||||
{
|
||||
Workspace.StageTick = (int)stageTimelineSlider.value;
|
||||
}
|
||||
|
||||
public void OnPlayBackSpeedChange()
|
||||
{
|
||||
Workspace.PlayBackSpeed = float.Parse(playBackSpeedField.text);
|
||||
}
|
||||
|
||||
public void OnCurrentTimeFieldChange()
|
||||
{
|
||||
Workspace.StageTick = Mathf.Clamp(int.Parse(currentTimeField.text), Constants.minTick, Workspace.StageWindowSize);
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnStageWindowLengthFieldChange()
|
||||
{
|
||||
int.TryParse(stageWindowLengthField.text, out int newStageWindowSize);
|
||||
newStageWindowSize = Mathf.Clamp(newStageWindowSize, Constants.minAnimationClipLength, Constants.maxAnimationClipLength);
|
||||
|
||||
Debug.Log("Resizing animation clip length to " + newStageWindowSize.ToString() + " ticks.");
|
||||
|
||||
if (Workspace.stretchKeyframes)
|
||||
{ Workspace.GetCurrentAnimationStage().StretchStageWindow(newStageWindowSize); }
|
||||
|
||||
else
|
||||
{
|
||||
Workspace.GetCurrentAnimationStage().ResizeStageWindow(newStageWindowSize);
|
||||
|
||||
foreach (PawnAnimationClip clip in Workspace.GetCurrentAnimationStage().AnimationClips)
|
||||
{
|
||||
List<PawnKeyframe> keyframes = clip.Keyframes.Where(x => x.atTick > newStageWindowSize)?.ToList();
|
||||
|
||||
if (keyframes.NullOrEmpty())
|
||||
{ continue; }
|
||||
|
||||
foreach (PawnKeyframe keyframe in keyframes)
|
||||
{
|
||||
if (clip.Keyframes.Count <= 2)
|
||||
{ break; }
|
||||
|
||||
clip.RemovePawnKeyframe(keyframe.keyframeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Workspace.RecordEvent("Stage length");
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
stageTimelineSlider.maxValue = Workspace.StageWindowSize;
|
||||
stageTimelineSlider.SetValueWithoutNotify(Workspace.StageTick);
|
||||
currentTimeField.SetTextWithoutNotify(Workspace.StageTick.ToString());
|
||||
stageWindowLengthField.SetTextWithoutNotify(Workspace.StageWindowSize.ToString());
|
||||
playBackSpeedField.SetTextWithoutNotify(Workspace.PlayBackSpeed.ToString());
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/GUI/Cards/AnimationControlCard.cs.meta
Normal file
11
Source/Assets/Scripts/GUI/Cards/AnimationControlCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b414452bfd6c9b4bb99542a51d77468
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
Source/Assets/Scripts/GUI/Cards/AnimationDefCard.cs
Normal file
39
Source/Assets/Scripts/GUI/Cards/AnimationDefCard.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
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 AnimationDefCard : MonoBehaviour
|
||||
{
|
||||
public InputField defNameField;
|
||||
public InputField labelField;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
EventsManager.onAnimationChanged.AddListener(delegate { UpdateInputFields(); });
|
||||
|
||||
defNameField.onEndEdit.AddListener(delegate {
|
||||
Workspace.animationDef.DefName = defNameField.text;
|
||||
Workspace.MakeHistoricRecord("AnimationDef update");
|
||||
});
|
||||
|
||||
labelField.onEndEdit.AddListener(delegate {
|
||||
Workspace.animationDef.Label = labelField.text;
|
||||
Workspace.MakeHistoricRecord("AnimationDef update");
|
||||
});
|
||||
|
||||
UpdateInputFields();
|
||||
}
|
||||
|
||||
public void UpdateInputFields()
|
||||
{
|
||||
defNameField.SetTextWithoutNotify(Workspace.animationDef.DefName);
|
||||
labelField.SetTextWithoutNotify(Workspace.animationDef.Label);
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/GUI/Cards/AnimationDefCard.cs.meta
Normal file
11
Source/Assets/Scripts/GUI/Cards/AnimationDefCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e1d8f33927e6b4d44914a445362b802d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
67
Source/Assets/Scripts/GUI/Cards/StageCard.cs
Normal file
67
Source/Assets/Scripts/GUI/Cards/StageCard.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class StageCard : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public Text stageName;
|
||||
public InputField stageNameField;
|
||||
public Image banner;
|
||||
|
||||
private int stageID { get { return transform.GetSiblingIndex(); } }
|
||||
|
||||
public void Start()
|
||||
{
|
||||
EventsManager.onStageIDChanged.AddListener(delegate { Initialize(stageName.text); });
|
||||
stageNameField.onEndEdit.AddListener(delegate { OnNameChange(); });
|
||||
}
|
||||
|
||||
public void Initialize(string stageName)
|
||||
{
|
||||
this.stageName.text = stageName;
|
||||
|
||||
if (Workspace.StageID == transform.GetSiblingIndex())
|
||||
{
|
||||
banner.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
banner.gameObject.SetActive(false);
|
||||
stageNameField.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnNameChange()
|
||||
{
|
||||
stageName.text = stageNameField.text;
|
||||
stageNameField.gameObject.SetActive(false);
|
||||
|
||||
Workspace.GetCurrentAnimationStage().StageName = stageName.text;
|
||||
Workspace.RecordEvent("Stage renamed");
|
||||
}
|
||||
|
||||
public void OnMoveStage(int delta)
|
||||
{
|
||||
Workspace.animationDef.MoveAnimationStage(stageID, delta);
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.clickCount >= 2)
|
||||
{
|
||||
stageNameField.text = stageName.text;
|
||||
stageNameField.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
if (Workspace.StageID != transform.GetSiblingIndex())
|
||||
{ Workspace.RecordEvent("Stage selected"); }
|
||||
|
||||
Workspace.StageID = transform.GetSiblingIndex();
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/GUI/Cards/StageCard.cs.meta
Normal file
11
Source/Assets/Scripts/GUI/Cards/StageCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 20b2be62d5fdc4b4992cede005ec2aee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
53
Source/Assets/Scripts/GUI/Cards/StageLoopsCard.cs
Normal file
53
Source/Assets/Scripts/GUI/Cards/StageLoopsCard.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
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 StageLoopsCard : MonoBehaviour
|
||||
{
|
||||
public InputField stageLoopsNormalField;
|
||||
public InputField stageLoopsQuickField;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
EventsManager.onAnimationTimelinesChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onStageWindowSizeChanged.AddListener(delegate { UpdateGUI(); });
|
||||
|
||||
stageLoopsNormalField.onEndEdit.AddListener(delegate { OnStageLoopsNormalFieldChange(); });
|
||||
stageLoopsQuickField.onEndEdit.AddListener(delegate { OnStageLoopsFastFieldChange(); });
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void OnStageLoopsNormalFieldChange()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
Workspace.GetCurrentAnimationStage().StageLoopsNormal = int.Parse(stageLoopsNormalField.text);
|
||||
|
||||
EventsManager.OnAnimationStageChanged(Workspace.GetCurrentAnimationStage());
|
||||
Workspace.RecordEvent("Cycle count (normal)");
|
||||
}
|
||||
|
||||
public void OnStageLoopsFastFieldChange()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
Workspace.GetCurrentAnimationStage().StageLoopsQuick = int.Parse(stageLoopsQuickField.text);
|
||||
|
||||
EventsManager.OnAnimationStageChanged(Workspace.GetCurrentAnimationStage());
|
||||
Workspace.RecordEvent("Cycle count (fast)");
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
stageLoopsNormalField.SetTextWithoutNotify(Workspace.GetCurrentAnimationStage().StageLoopsNormal.ToString());
|
||||
stageLoopsQuickField.SetTextWithoutNotify(Workspace.GetCurrentAnimationStage().StageLoopsQuick.ToString());
|
||||
}
|
||||
}
|
||||
}
|
11
Source/Assets/Scripts/GUI/Cards/StageLoopsCard.cs.meta
Normal file
11
Source/Assets/Scripts/GUI/Cards/StageLoopsCard.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38691dc973d99734f8f0f2a240df73fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue