85 lines
2.2 KiB
C#
85 lines
2.2 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace RimWorldAnimationStudio
|
|||
|
{
|
|||
|
public class Workspace : MonoBehaviour
|
|||
|
{
|
|||
|
public AnimationDef animationDef;
|
|||
|
public int stageID = 0;
|
|||
|
public bool isDirty = false;
|
|||
|
|
|||
|
public List<WorkspaceSnapShot> workspaceHistory = new List<WorkspaceSnapShot>();
|
|||
|
public int maxHistoryDepth = 100;
|
|||
|
public int historyIndex = 0;
|
|||
|
|
|||
|
public void TryToCloseApplication()
|
|||
|
{
|
|||
|
if (isDirty)
|
|||
|
{
|
|||
|
//exitDialog.Pop();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
CloseApplication();
|
|||
|
}
|
|||
|
|
|||
|
public void CloseApplication()
|
|||
|
{
|
|||
|
Application.Quit();
|
|||
|
}
|
|||
|
|
|||
|
public void GenerateLoadOptions(Defs defs)
|
|||
|
{
|
|||
|
for (int i = 0; i < defs.animationDefs.Count - 1; i++)
|
|||
|
{
|
|||
|
//Instantiate child button
|
|||
|
//button.text
|
|||
|
//buttoncallback = LoadADef(list[i]);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void TrackChanges()
|
|||
|
{
|
|||
|
if (historyIndex < workspaceHistory.Count - 1)
|
|||
|
{ workspaceHistory.RemoveRange(historyIndex + 1, workspaceHistory.Count - historyIndex); }
|
|||
|
|
|||
|
if (workspaceHistory.Any() && workspaceHistory.Count >= maxHistoryDepth)
|
|||
|
{ workspaceHistory.RemoveAt(0); }
|
|||
|
|
|||
|
WorkspaceSnapShot workspaceSnapShot = new WorkspaceSnapShot();
|
|||
|
workspaceSnapShot.animationDef = animationDef;
|
|||
|
workspaceSnapShot.stageID = stageID;
|
|||
|
|
|||
|
workspaceHistory.Add(workspaceSnapShot);
|
|||
|
|
|||
|
// track bType for actors, stageID, isdirty
|
|||
|
|
|||
|
historyIndex++;
|
|||
|
}
|
|||
|
|
|||
|
public void Undo()
|
|||
|
{
|
|||
|
historyIndex = Mathf.Clamp(historyIndex - 1, 0, workspaceHistory.Count - 1);
|
|||
|
LoadHistoricState();
|
|||
|
}
|
|||
|
|
|||
|
public void Redo()
|
|||
|
{
|
|||
|
historyIndex = Mathf.Clamp(historyIndex - 1, 0, workspaceHistory.Count - 1);
|
|||
|
LoadHistoricState();
|
|||
|
}
|
|||
|
|
|||
|
public void LoadHistoricState()
|
|||
|
{
|
|||
|
animationDef = workspaceHistory[historyIndex].animationDef;
|
|||
|
|
|||
|
// All other data
|
|||
|
}
|
|||
|
}
|
|||
|
}
|