2022-01-22 10:44:19 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
2023-06-10 19:17:06 +00:00
|
|
|
using Jukebox;
|
|
|
|
using Jukebox.Legacy;
|
2022-01-22 10:44:19 +00:00
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
using HeavenStudio.Editor.Track;
|
2022-01-28 02:50:57 +00:00
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Editor.Commands
|
2022-01-22 10:44:19 +00:00
|
|
|
{
|
|
|
|
public class Selection : IAction
|
|
|
|
{
|
2022-01-23 03:40:53 +00:00
|
|
|
List<TimelineEventObj> eventObjs;
|
2022-01-28 02:50:57 +00:00
|
|
|
List<TimelineEventObj> lastEventObjs;
|
2022-01-23 03:40:53 +00:00
|
|
|
|
|
|
|
public Selection(List<TimelineEventObj> eventObjs)
|
|
|
|
{
|
|
|
|
this.eventObjs = eventObjs;
|
|
|
|
}
|
|
|
|
|
2022-01-22 10:44:19 +00:00
|
|
|
public void Execute()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Redo()
|
|
|
|
{
|
2022-01-28 02:50:57 +00:00
|
|
|
for (int i = 0; i < lastEventObjs.Count; i++)
|
2022-01-23 03:40:53 +00:00
|
|
|
{
|
2022-01-28 02:50:57 +00:00
|
|
|
Selections.instance.ShiftClickSelect(lastEventObjs[i]);
|
2022-01-23 03:40:53 +00:00
|
|
|
}
|
2022-01-22 10:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Undo()
|
|
|
|
{
|
2022-01-28 02:50:57 +00:00
|
|
|
lastEventObjs = eventObjs;
|
2022-01-23 03:40:53 +00:00
|
|
|
for (int i = 0; i < eventObjs.Count; i++)
|
|
|
|
{
|
|
|
|
Selections.instance.ShiftClickSelect(eventObjs[i]);
|
|
|
|
}
|
2022-01-22 10:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// I spent 7 hours trying to fix this instead of sleeping, which would've probably worked better.
|
|
|
|
// I'll go fuck myself later I'm just glad it works
|
|
|
|
// I give massive props to people who code undo/redo systems
|
|
|
|
// -- Starpelly
|
|
|
|
|
|
|
|
public class Move : IAction
|
|
|
|
{
|
|
|
|
public List<Pos> pos = new List<Pos>();
|
|
|
|
|
|
|
|
public class Pos
|
|
|
|
{
|
|
|
|
public TimelineEventObj eventObj;
|
|
|
|
|
|
|
|
public Vector2 lastPos_;
|
|
|
|
public Vector3 previousPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Move(List<TimelineEventObj> eventObjs)
|
|
|
|
{
|
|
|
|
pos.Clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < eventObjs.Count; i++)
|
|
|
|
{
|
|
|
|
Pos p = new Pos();
|
|
|
|
p.eventObj = eventObjs[i];
|
2022-09-18 20:48:14 +00:00
|
|
|
p.lastPos_ = eventObjs[i].moveStartPos;
|
2022-01-22 10:44:19 +00:00
|
|
|
p.previousPos = eventObjs[i].transform.localPosition;
|
|
|
|
this.pos.Add(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Redo()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < pos.Count; i++)
|
|
|
|
{
|
|
|
|
EnsureEventObj(i);
|
|
|
|
pos[i].eventObj.transform.localPosition = pos[i].previousPos;
|
2022-01-23 07:01:59 +00:00
|
|
|
pos[i].eventObj.entity.beat = pos[i].eventObj.transform.localPosition.x;
|
2022-01-22 10:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Undo()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < pos.Count; i++)
|
|
|
|
{
|
|
|
|
EnsureEventObj(i);
|
|
|
|
pos[i].eventObj.transform.localPosition = pos[i].lastPos_;
|
2022-01-23 07:01:59 +00:00
|
|
|
pos[i].eventObj.entity.beat = pos[i].eventObj.transform.localPosition.x;
|
2022-01-22 10:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void EnsureEventObj(int id)
|
|
|
|
{
|
|
|
|
if (pos[id].eventObj == null)
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
pos[id].eventObj = Timeline.instance.eventObjs.Find(c => c.eventObjID == pos[id].eventObj.eventObjID);
|
2022-01-22 10:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-23 03:40:53 +00:00
|
|
|
public class Place : IAction
|
|
|
|
{
|
|
|
|
TimelineEventObj eventObj;
|
2022-01-28 02:50:57 +00:00
|
|
|
TimelineEventObj deletedObj;
|
2022-01-23 03:40:53 +00:00
|
|
|
|
|
|
|
public Place(TimelineEventObj eventObj)
|
|
|
|
{
|
|
|
|
this.eventObj = eventObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Redo()
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
deletedObj = Timeline.instance.AddEventObject(deletedObj.entity.datamodel, false, new Vector3((float) deletedObj.entity.beat, -deletedObj.entity["track"] * Timeline.instance.LayerHeight()), deletedObj.entity, true);
|
2022-01-23 03:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Undo()
|
|
|
|
{
|
2022-01-28 02:50:57 +00:00
|
|
|
deletedObj = eventObj;
|
2022-01-23 03:40:53 +00:00
|
|
|
Selections.instance.Deselect(eventObj);
|
|
|
|
Timeline.instance.DestroyEventObject(eventObj.entity);
|
2023-06-10 19:17:06 +00:00
|
|
|
// RiqEntity e = deletedObjs[i].entity;
|
2022-01-23 03:40:53 +00:00
|
|
|
// Timeline.instance.AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * Timeline.instance.LayerHeight()), e, true, e.eventObj.eventObjID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-22 10:44:19 +00:00
|
|
|
public class Deletion : IAction
|
|
|
|
{
|
|
|
|
List<TimelineEventObj> eventObjs;
|
|
|
|
List<TimelineEventObj> deletedObjs;
|
|
|
|
|
|
|
|
public Deletion(List<TimelineEventObj> eventObjs)
|
|
|
|
{
|
|
|
|
this.eventObjs = eventObjs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
{
|
|
|
|
deletedObjs = eventObjs;
|
|
|
|
for (int i = 0; i < eventObjs.Count; i++)
|
|
|
|
{
|
|
|
|
Selections.instance.Deselect(eventObjs[i]);
|
|
|
|
Timeline.instance.DestroyEventObject(eventObjs[i].entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Redo()
|
|
|
|
{
|
|
|
|
deletedObjs = eventObjs;
|
|
|
|
for (int i = 0; i < eventObjs.Count; i++)
|
|
|
|
{
|
|
|
|
Selections.instance.Deselect(eventObjs[i]);
|
|
|
|
Timeline.instance.DestroyEventObject(eventObjs[i].entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Undo()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < deletedObjs.Count; i++)
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
RiqEntity e = deletedObjs[i].entity;
|
|
|
|
eventObjs[i] = Timeline.instance.AddEventObject(e.datamodel, false, new Vector3((float)e.beat, -e["track"] * Timeline.instance.LayerHeight()), e, true);
|
2022-01-22 10:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-08 16:50:23 +00:00
|
|
|
|
|
|
|
public class Duplicate : IAction
|
|
|
|
{
|
|
|
|
List<TimelineEventObj> eventObjs;
|
|
|
|
List<TimelineEventObj> copiedObjs;
|
|
|
|
|
|
|
|
public Duplicate(List<TimelineEventObj> eventObjs)
|
|
|
|
{
|
|
|
|
this.eventObjs = eventObjs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Redo()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < copiedObjs.Count; i++)
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
RiqEntity e = copiedObjs[i].entity;
|
|
|
|
eventObjs[i] = Timeline.instance.AddEventObject(e.datamodel, false, new Vector3((float)e.beat, -e["track"] * Timeline.instance.LayerHeight()), e, true);
|
2022-07-08 16:50:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Undo()
|
|
|
|
{
|
|
|
|
copiedObjs = eventObjs;
|
|
|
|
for (int i = 0; i < eventObjs.Count; i++)
|
|
|
|
{
|
|
|
|
Selections.instance.Deselect(eventObjs[i]);
|
|
|
|
Timeline.instance.DestroyEventObject(eventObjs[i].entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-22 10:44:19 +00:00
|
|
|
}
|