mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Ghost frames fix plus undo redo system
This commit is contained in:
parent
591b176924
commit
b0a965e0b2
163 changed files with 948 additions and 214 deletions
|
@ -12,18 +12,18 @@ namespace RimWorldAnimationStudio
|
|||
public static AnimationDef animationDef;
|
||||
public static int stageID = 0;
|
||||
public static int actorID = 0;
|
||||
public static int keyframeID = 0;
|
||||
public static bool isDirty = false;
|
||||
public static int keyframeID = 0;
|
||||
|
||||
public static List<string> defNames = new List<string>() { "Human" };
|
||||
public static List<string> bodyParts = new List<string>() { "Penis", "Vagina", "Anus", "Breasts", "Mouth" };
|
||||
public static List<string> bodyParts = new List<string>() { "Any appendage", "Any orifice", "Penis", "Vagina", "Anus", "Breasts", "Mouth" };
|
||||
public static List<string> bodyDefTypes = new List<string>() { "Human" };
|
||||
public static List<string> sexTypes = new List<string>() { "None", "Vaginal", "Anal", "Oral", "Masturbation", "DoublePenetration", "Boobjob", "Handjob", "Footjob", "Fingering", "Scissoring", "MutualMasturbation", "Fisting", "MechImplant", "Rimming", "Fellatio", "Cunnilingus", "Sixtynine" };
|
||||
public static List<string> interactionDefTypes = new List<string>();
|
||||
|
||||
private static List<WorkspaceSnapShot> workspaceHistory = new List<WorkspaceSnapShot>();
|
||||
private static int maxHistoryDepth = 100;
|
||||
private static int historyIndex = 0;
|
||||
[SerializeField] private List<WorkspaceSnapShot> workspaceHistory = new List<WorkspaceSnapShot>();
|
||||
[SerializeField] private int historyIndex = 0;
|
||||
[SerializeField] private int maxHistoryDepth = 100;
|
||||
private bool isDirty = false;
|
||||
|
||||
public static ActorManipulationMode actorManipulationMode = ActorManipulationMode.Pan;
|
||||
|
||||
|
@ -41,6 +41,12 @@ namespace RimWorldAnimationStudio
|
|||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (isDirty)
|
||||
{ TrackChanges(); }
|
||||
}
|
||||
|
||||
public PawnKeyframe GetCurrentPawnKeyframe()
|
||||
{
|
||||
int stageTick = AnimationController.Instance.stageTick;
|
||||
|
@ -70,21 +76,26 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void TrackChanges()
|
||||
{
|
||||
Debug.Log("Test");
|
||||
Debug.Log(historyIndex + 1);
|
||||
Debug.Log(workspaceHistory.Count - historyIndex);
|
||||
|
||||
if (historyIndex < workspaceHistory.Count - 1)
|
||||
{ workspaceHistory.RemoveRange(historyIndex + 1, workspaceHistory.Count - historyIndex); }
|
||||
{ workspaceHistory.RemoveRange(historyIndex + 1, workspaceHistory.Count - historyIndex - 1); }
|
||||
|
||||
if (workspaceHistory.Any() && workspaceHistory.Count >= maxHistoryDepth)
|
||||
{ workspaceHistory.RemoveAt(0); }
|
||||
|
||||
WorkspaceSnapShot workspaceSnapShot = new WorkspaceSnapShot();
|
||||
workspaceSnapShot.animationDef = animationDef;
|
||||
workspaceSnapShot.animationDef = animationDef.Copy();
|
||||
workspaceSnapShot.stageID = stageID;
|
||||
workspaceSnapShot.actorID = actorID;
|
||||
workspaceSnapShot.keyframeID = keyframeID;
|
||||
|
||||
workspaceHistory.Add(workspaceSnapShot);
|
||||
historyIndex = workspaceHistory.Count - 1;
|
||||
|
||||
// track bType for actors, stageID, isdirty
|
||||
|
||||
historyIndex++;
|
||||
isDirty = false;
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
|
@ -95,51 +106,30 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void Redo()
|
||||
{
|
||||
historyIndex = Mathf.Clamp(historyIndex - 1, 0, workspaceHistory.Count - 1);
|
||||
historyIndex = Mathf.Clamp(historyIndex + 1, 0, workspaceHistory.Count - 1);
|
||||
LoadHistoricState();
|
||||
}
|
||||
|
||||
public void LoadHistoricState()
|
||||
{
|
||||
animationDef = workspaceHistory[historyIndex].animationDef;
|
||||
if (workspaceHistory.NullOrEmpty())
|
||||
{ Debug.LogWarning("Cannot load historic state - workspace history is empty"); return; }
|
||||
|
||||
// All other data
|
||||
animationDef = workspaceHistory[historyIndex].animationDef.Copy();
|
||||
stageID = workspaceHistory[historyIndex].stageID;
|
||||
actorID = workspaceHistory[historyIndex].actorID;
|
||||
keyframeID = workspaceHistory[historyIndex].keyframeID;
|
||||
|
||||
AnimationController.Instance.MakeTimelineDirty();
|
||||
}
|
||||
|
||||
private int lastactorCount = 0;
|
||||
private int lastStageID = 0;
|
||||
private int lastStageCount = 0;
|
||||
private int lastStageWindowSize = 0;
|
||||
|
||||
public bool AnimationTimelinesNeedUpdate()
|
||||
public void ClearHistory()
|
||||
{
|
||||
if (animationDef == null) return false;
|
||||
|
||||
bool update = false;
|
||||
|
||||
if (lastStageID != stageID)
|
||||
{ update = true; }
|
||||
|
||||
if (lastStageCount != animationDef.animationStages.Count)
|
||||
{ update = true; }
|
||||
|
||||
if (lastactorCount != animationDef.actors.Count)
|
||||
{ update = true; }
|
||||
|
||||
if (lastStageWindowSize != StageWindowSize)
|
||||
{ update = true; }
|
||||
|
||||
if (update)
|
||||
{
|
||||
lastStageID = stageID;
|
||||
lastStageCount = animationDef.animationStages.Count;
|
||||
lastactorCount = animationDef.actors.Count;
|
||||
lastStageWindowSize = StageWindowSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
workspaceHistory.Clear();
|
||||
historyIndex = 0;
|
||||
}
|
||||
|
||||
public void MakeDirty()
|
||||
{ isDirty = true; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,12 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
[Serializable]
|
||||
public class WorkspaceSnapShot
|
||||
{
|
||||
public AnimationDef animationDef;
|
||||
public int stageID = 0;
|
||||
public int actorID = 0;
|
||||
public int keyframeID = 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue