mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Improved undo redo function and timelines
This commit is contained in:
parent
1af7f41d63
commit
e36ef6a368
372 changed files with 4086 additions and 211 deletions
|
@ -6,7 +6,7 @@ using UnityEngine.EventSystems;
|
|||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorBody : MonoBehaviour, IPointerClickHandler, IDragHandler
|
||||
public class ActorBody : MonoBehaviour, IPointerClickHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public int actorID;
|
||||
public string bodyType = "Male";
|
||||
|
@ -78,6 +78,11 @@ namespace RimWorldAnimationStudio
|
|||
clip.BuildSimpleCurves();
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
Workspace.Instance.RecordEvent("Actor position / orientation");
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
Workspace.actorID = actorID;
|
||||
|
|
|
@ -6,7 +6,7 @@ using UnityEngine.EventSystems;
|
|||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorBodyPart : MonoBehaviour, IDragHandler, IPointerClickHandler
|
||||
public class ActorBodyPart : MonoBehaviour, IPointerClickHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public SpriteRenderer bodyPartRenderer;
|
||||
public ActorBody parent;
|
||||
|
@ -82,6 +82,11 @@ namespace RimWorldAnimationStudio
|
|||
clip.BuildSimpleCurves();
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
Workspace.Instance.RecordEvent("Actor position / orientation");
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
Workspace.actorID = parent.actorID;
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace RimWorldAnimationStudio
|
|||
bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString();
|
||||
}
|
||||
|
||||
public void UpdateAnimationDef()
|
||||
public void OnValueChanged()
|
||||
{
|
||||
if (Workspace.animationDef == null || isDirty) return;
|
||||
|
||||
|
@ -65,10 +65,10 @@ namespace RimWorldAnimationStudio
|
|||
default: actor.requiredGender = null; break;
|
||||
}
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Actor body type offset data");
|
||||
}
|
||||
|
||||
public void OpenSelectBodyPartsDialog()
|
||||
/*public void OpenSelectBodyPartsDialog()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
|
@ -99,7 +99,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
if (dialog != null)
|
||||
{ dialog[0].Initialize(actor); dialog[0].Pop(); }
|
||||
}
|
||||
}*/
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace RimWorldAnimationStudio
|
|||
Workspace.Instance.GetPawnAnimationClip(Workspace.actorID).BuildSimpleCurves();
|
||||
isDirty = true;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Actor position / orientation");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 329a2ecc35813f94fa879c7f434c8fb7
|
||||
guid: b7e9565ba13ac2e469767bcfad7da5d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
|
@ -68,5 +68,37 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
BroadcastMessage("UpdateGhostFrames");
|
||||
}
|
||||
|
||||
public void OnMoveTimeline(int delta)
|
||||
{
|
||||
int? siblingIndex = transform.parent.GetComponentsInChildren<AnimationTimeline>()?.ToList()?.IndexOf(this);
|
||||
int? siblingCount = transform.parent.GetComponentsInChildren<AnimationTimeline>()?.ToList()?.Count();
|
||||
|
||||
if (siblingIndex != null && siblingCount != null && MoveAnimationTimeline(siblingIndex.Value, delta))
|
||||
{
|
||||
//siblingIndex = Mathf.Clamp(siblingCount.Value + delta, 0, siblingCount.Value - 1);
|
||||
transform.SetSiblingIndex(transform.GetSiblingIndex() + delta);
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveAnimationTimeline(int startIndex, int delta)
|
||||
{
|
||||
if (startIndex + delta < 0 || startIndex + delta >= Workspace.animationDef.animationStages[Workspace.stageID].animationClips.Count)
|
||||
{ return false; }
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[startIndex];
|
||||
Workspace.animationDef.actors[startIndex] = Workspace.animationDef.actors[startIndex + delta];
|
||||
Workspace.animationDef.actors[startIndex + delta] = actor;
|
||||
|
||||
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(startIndex);
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex] = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex + delta];
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].animationClips[startIndex + delta] = clip;
|
||||
|
||||
Workspace.actorID = startIndex + delta;
|
||||
|
||||
Workspace.Instance.RecordEvent("Timeline move");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
70
Assets/Scripts/GUI/DialogBoxes/ConsoleMessagesDialog.cs
Normal file
70
Assets/Scripts/GUI/DialogBoxes/ConsoleMessagesDialog.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
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.ColorGoldYellow;
|
||||
logMessage.color = Constants.ColorGoldYellow;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/GUI/DialogBoxes/ConsoleMessagesDialog.cs.meta
Normal file
11
Assets/Scripts/GUI/DialogBoxes/ConsoleMessagesDialog.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c62f9942e9d933848913ee2b28f65791
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
54
Assets/Scripts/GUI/DialogBoxes/SelectActorLayerDialog.cs
Normal file
54
Assets/Scripts/GUI/DialogBoxes/SelectActorLayerDialog.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
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 OnEnable()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
Transform contentWindow = transform.FindDeepChild("Content");
|
||||
Reset();
|
||||
|
||||
for (int i = 0; i < Workspace.actorLayers.Count; i++)
|
||||
{
|
||||
string actorLayer = Workspace.actorLayers[i];
|
||||
|
||||
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
|
||||
_optionToggle.Find("Text").GetComponent<Text>().text = actorLayer;
|
||||
|
||||
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
|
||||
toggleComp.isOn = Workspace.Instance.GetCurrentPawnAnimationClip().layer == actorLayer;
|
||||
toggleComp.onValueChanged.AddListener(delegate {
|
||||
|
||||
PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
|
||||
|
||||
if (clip != null)
|
||||
{ clip.layer = actorLayer; }
|
||||
|
||||
Workspace.Instance.RecordEvent("Actor layer set");
|
||||
});
|
||||
|
||||
toggleComp.group = contentWindow.GetComponent<ToggleGroup>();
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Transform contentWindow = transform.FindDeepChild("Content");
|
||||
RemoveCloneObjectsFromParent(contentWindow);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce4b68a13ad01b14f97697ab310a74d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -10,9 +10,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectBodyDefTypesDialog : DialogBox
|
||||
{
|
||||
private Actor actor;
|
||||
|
||||
public void Start()
|
||||
public void OnEnable()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
@ -27,18 +25,12 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
Workspace.bodyDefTypes.Add(field.text);
|
||||
|
||||
Initialize(null, true);
|
||||
Initialize(true);
|
||||
}
|
||||
|
||||
public void Initialize(Actor actor = null, bool addedNewTag = false)
|
||||
public void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
if (actor != null)
|
||||
{ this.actor = actor; }
|
||||
|
||||
if (actor == null)
|
||||
{ actor = this.actor; }
|
||||
|
||||
if (actor == null) return;
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
||||
foreach (string bodyDefType in actor.bodyDefTypes)
|
||||
{
|
||||
|
@ -66,7 +58,7 @@ namespace RimWorldAnimationStudio
|
|||
else if (toggleComp.isOn == false && actor.bodyDefTypes.Contains(bodyDefType))
|
||||
{ actor.bodyDefTypes.Remove(bodyDefType); }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Actor bodyDef type");
|
||||
});
|
||||
|
||||
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
|
||||
|
|
|
@ -10,9 +10,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectBodyPartsDialog : DialogBox
|
||||
{
|
||||
private Actor actor;
|
||||
|
||||
public void Start()
|
||||
public void OnEnable()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
@ -30,18 +28,12 @@ namespace RimWorldAnimationStudio
|
|||
Debug.Log("Add new body part: " + field.text);
|
||||
Workspace.bodyParts.Add(field.text);
|
||||
|
||||
Initialize(null, true);
|
||||
Initialize(true);
|
||||
}
|
||||
|
||||
public void Initialize(Actor actor = null, bool addedNewTag = false)
|
||||
public void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
if (actor != null)
|
||||
{ this.actor = actor; }
|
||||
|
||||
if (actor == null)
|
||||
{ actor = this.actor; }
|
||||
|
||||
if (actor == null) return;
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
||||
foreach (string bodyPart in actor.requiredGenitals)
|
||||
{
|
||||
|
@ -69,7 +61,7 @@ namespace RimWorldAnimationStudio
|
|||
else if (toggleComp.isOn == false && actor.requiredGenitals.Contains(bodyPart))
|
||||
{ actor.requiredGenitals.Remove(bodyPart); }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Actor required body part");
|
||||
});
|
||||
|
||||
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
|
||||
|
|
|
@ -10,10 +10,9 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectDefNamesDialog : DialogBox
|
||||
{
|
||||
private Actor actor;
|
||||
|
||||
public void Start()
|
||||
public void OnEnable()
|
||||
{
|
||||
Debug.Log("enabled");
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
@ -27,18 +26,12 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
Workspace.defNames.Add(field.text);
|
||||
|
||||
Initialize(null, true);
|
||||
Initialize(true);
|
||||
}
|
||||
|
||||
public void Initialize(Actor actor = null, bool addedNewTag = false)
|
||||
public void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
if (actor != null)
|
||||
{ this.actor = actor; }
|
||||
|
||||
if (actor == null)
|
||||
{ actor = this.actor; }
|
||||
|
||||
if (actor == null) return;
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
||||
foreach (string defName in actor.defNames)
|
||||
{
|
||||
|
@ -66,7 +59,7 @@ namespace RimWorldAnimationStudio
|
|||
else if (toggleComp.isOn == false && actor.defNames.Contains(defName))
|
||||
{ actor.defNames.Remove(defName); }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Actor def name");
|
||||
});
|
||||
|
||||
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectInteractionDefsDialog : DialogBox
|
||||
{
|
||||
public void Start()
|
||||
public void OnEnable()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace RimWorldAnimationStudio
|
|||
else if (toggleComp.isOn == false && Workspace.animationDef.interactionDefTypes.Contains(interactionDefType))
|
||||
{ Workspace.animationDef.interactionDefTypes.Remove(interactionDefType); }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Animation InteractionDef");
|
||||
});
|
||||
|
||||
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectSexTypesDialog : DialogBox
|
||||
{
|
||||
public void Start()
|
||||
public void OnEnable()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace RimWorldAnimationStudio
|
|||
else if (toggleComp.isOn == false && Workspace.animationDef.sexTypes.Contains(sexType))
|
||||
{ Workspace.animationDef.sexTypes.Remove(sexType); }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Animation sex type");
|
||||
});
|
||||
|
||||
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectSoundDefDialog : DialogBox
|
||||
{
|
||||
public void Start()
|
||||
public void OnEnable()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace RimWorldAnimationStudio
|
|||
if (keyframe != null)
|
||||
{ keyframe.soundEffect = soundDef; }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Keyframe sound effect");
|
||||
});
|
||||
|
||||
toggleComp.group = contentWindow.GetComponent<ToggleGroup>();
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace RimWorldAnimationStudio
|
|||
if (eventData.clickCount >= 2)
|
||||
{ AnimationController.Instance.stageTick = keyframe.atTick.Value; }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
//Workspace.Instance.RecordEvent("Keyframe selected");
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
|
@ -126,7 +126,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
interactable = false;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Keyframe tick");
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
@ -145,7 +145,7 @@ namespace RimWorldAnimationStudio
|
|||
else
|
||||
{ handleImage.color = Constants.ColorWhite; }
|
||||
|
||||
string soundDef = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID).soundEffect;
|
||||
string soundDef = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID)?.soundEffect;
|
||||
|
||||
if (soundDef != null && soundDef != "" && soundDef != "None")
|
||||
{ soundIcon.SetActive(true); }
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
if (keyframe != null)
|
||||
{ keyframe.quiver = GetComponent<Toggle>().isOn; }
|
||||
|
||||
Workspace.Instance.RecordEvent("Actor quiver");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
30
Assets/Scripts/GUI/SelectActorLayerButton.cs
Normal file
30
Assets/Scripts/GUI/SelectActorLayerButton.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class SelectActorLayerButton : MonoBehaviour
|
||||
{
|
||||
private Text text;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
text = GetComponentInChildren<Text>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
|
||||
|
||||
if (clip != null)
|
||||
{ text.text = clip.layer; }
|
||||
|
||||
else
|
||||
{ text.text = "Pawn"; }
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/GUI/SelectActorLayerButton.cs.meta
Normal file
11
Assets/Scripts/GUI/SelectActorLayerButton.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 329a2ecc35813f94fa879c7f434c8fb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -19,7 +19,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].stageName = stageName.text;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Stage renamed");
|
||||
}
|
||||
|
||||
public void OnMoveStage(int delta)
|
||||
|
@ -62,9 +62,10 @@ namespace RimWorldAnimationStudio
|
|||
stageNameField.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
Workspace.stageID = transform.GetSiblingIndex();
|
||||
if (Workspace.stageID != transform.GetSiblingIndex())
|
||||
{ Workspace.Instance.RecordEvent("Stage selected"); }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.stageID = transform.GetSiblingIndex();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue