add special marker operations to the undo/redo system

fix bugs with special marker operations
This commit is contained in:
minenice55 2023-10-05 20:28:11 -04:00
parent 40acf4eb28
commit d1c1518b24
10 changed files with 378 additions and 88 deletions

View file

@ -17,8 +17,6 @@ namespace HeavenStudio.Editor
private int maxItems = 128;
private void Awake()
{
Instance = this;

View file

@ -0,0 +1,238 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Jukebox;
using HeavenStudio.Editor.Track;
using Newtonsoft.Json;
using UnityEditor;
using UnityEngine.Timeline;
namespace HeavenStudio.Editor.Commands
{
public class AddMarker : ICommand
{
private RiqEntity placedEntityData;
private Guid placedEventID;
private int placedTimes = 0;
private SpecialTimeline.HoveringTypes type;
public AddMarker(RiqEntity placedEntityData, Guid placedEventID, SpecialTimeline.HoveringTypes type)
{
this.placedEntityData = placedEntityData.DeepCopy();
this.placedEventID = placedEventID;
this.type = type;
}
public void Execute()
{
if (placedTimes > 0)
{
var entity = placedEntityData.DeepCopy();
entity.guid = placedEventID;
switch (type)
{
case SpecialTimeline.HoveringTypes.TempoChange:
GameManager.instance.Beatmap.TempoChanges.Add(entity);
SpecialTimeline.instance.AddTempoChange(false, entity);
break;
case SpecialTimeline.HoveringTypes.VolumeChange:
GameManager.instance.Beatmap.VolumeChanges.Add(entity);
SpecialTimeline.instance.AddVolumeChange(false, entity);
break;
case SpecialTimeline.HoveringTypes.SectionChange:
GameManager.instance.Beatmap.SectionMarkers.Add(entity);
SpecialTimeline.instance.AddChartSection(false, entity);
break;
}
GameManager.instance.SortEventsList();
}
placedTimes++;
}
public void Undo()
{
RiqEntity createdEntity = null;
switch (type)
{
case SpecialTimeline.HoveringTypes.TempoChange:
createdEntity = GameManager.instance.Beatmap.TempoChanges.Find(x => x.guid == placedEventID);
break;
case SpecialTimeline.HoveringTypes.VolumeChange:
createdEntity = GameManager.instance.Beatmap.VolumeChanges.Find(x => x.guid == placedEventID);
break;
case SpecialTimeline.HoveringTypes.SectionChange:
createdEntity = GameManager.instance.Beatmap.SectionMarkers.Find(x => x.guid == placedEventID);
break;
}
if (createdEntity != null)
{
placedEntityData = createdEntity.DeepCopy();
var marker = SpecialTimeline.instance.specialTimelineObjs[createdEntity.guid];
switch (type)
{
case SpecialTimeline.HoveringTypes.TempoChange:
GameManager.instance.Beatmap.TempoChanges.Remove(createdEntity);
break;
case SpecialTimeline.HoveringTypes.VolumeChange:
GameManager.instance.Beatmap.VolumeChanges.Remove(createdEntity);
break;
case SpecialTimeline.HoveringTypes.SectionChange:
GameManager.instance.Beatmap.SectionMarkers.Remove(createdEntity);
break;
}
SpecialTimeline.instance.specialTimelineObjs.Remove(createdEntity.guid);
GameObject.Destroy(marker.gameObject);
GameManager.instance.SortEventsList();
}
}
}
public class DeleteMarker : ICommand
{
private RiqEntity deletedEntityData;
private Guid deletedEventID;
private SpecialTimeline.HoveringTypes type;
public DeleteMarker(Guid deletedEventID, SpecialTimeline.HoveringTypes type)
{
this.deletedEventID = deletedEventID;
this.type = type;
}
public void Execute()
{
RiqEntity deletedEntity = null;
switch (type)
{
case SpecialTimeline.HoveringTypes.TempoChange:
deletedEntity = GameManager.instance.Beatmap.TempoChanges.Find(x => x.guid == deletedEventID);
break;
case SpecialTimeline.HoveringTypes.VolumeChange:
deletedEntity = GameManager.instance.Beatmap.VolumeChanges.Find(x => x.guid == deletedEventID);
break;
case SpecialTimeline.HoveringTypes.SectionChange:
deletedEntity = GameManager.instance.Beatmap.SectionMarkers.Find(x => x.guid == deletedEventID);
break;
}
if (deletedEntity != null)
{
var marker = SpecialTimeline.instance.specialTimelineObjs[deletedEntity.guid];
deletedEntityData = deletedEntity.DeepCopy();
deletedEntityData.guid = deletedEntity.guid;
switch (type)
{
case SpecialTimeline.HoveringTypes.TempoChange:
GameManager.instance.Beatmap.TempoChanges.Remove(deletedEntity);
break;
case SpecialTimeline.HoveringTypes.VolumeChange:
GameManager.instance.Beatmap.VolumeChanges.Remove(deletedEntity);
break;
case SpecialTimeline.HoveringTypes.SectionChange:
GameManager.instance.Beatmap.SectionMarkers.Remove(deletedEntity);
break;
}
SpecialTimeline.instance.specialTimelineObjs.Remove(deletedEntity.guid);
GameObject.Destroy(marker.gameObject);
GameManager.instance.SortEventsList();
}
}
public void Undo()
{
if (deletedEntityData != null)
{
switch (type)
{
case SpecialTimeline.HoveringTypes.TempoChange:
GameManager.instance.Beatmap.TempoChanges.Add(deletedEntityData);
SpecialTimeline.instance.AddTempoChange(false, deletedEntityData);
break;
case SpecialTimeline.HoveringTypes.VolumeChange:
GameManager.instance.Beatmap.VolumeChanges.Add(deletedEntityData);
SpecialTimeline.instance.AddVolumeChange(false, deletedEntityData);
break;
case SpecialTimeline.HoveringTypes.SectionChange:
GameManager.instance.Beatmap.SectionMarkers.Add(deletedEntityData);
SpecialTimeline.instance.AddChartSection(false, deletedEntityData);
break;
}
deletedEntityData = null;
}
}
}
public class MoveMarker : ICommand
{
private Guid entityId;
private double newBeat, lastBeat;
private SpecialTimeline.HoveringTypes type;
public MoveMarker(Guid entityId, double newBeat, SpecialTimeline.HoveringTypes type)
{
this.entityId = entityId;
this.newBeat = newBeat;
this.type = type;
}
public void Execute()
{
RiqEntity movedEntity = null;
switch (type)
{
case SpecialTimeline.HoveringTypes.TempoChange:
movedEntity = GameManager.instance.Beatmap.TempoChanges.Find(x => x.guid == entityId);
break;
case SpecialTimeline.HoveringTypes.VolumeChange:
movedEntity = GameManager.instance.Beatmap.VolumeChanges.Find(x => x.guid == entityId);
break;
case SpecialTimeline.HoveringTypes.SectionChange:
movedEntity = GameManager.instance.Beatmap.SectionMarkers.Find(x => x.guid == entityId);
break;
}
if (movedEntity != null)
{
lastBeat = movedEntity.beat;
movedEntity.beat = newBeat;
}
}
public void Undo()
{
RiqEntity movedEntity = null;
switch (type)
{
case SpecialTimeline.HoveringTypes.TempoChange:
movedEntity = GameManager.instance.Beatmap.TempoChanges.Find(x => x.guid == entityId);
break;
case SpecialTimeline.HoveringTypes.VolumeChange:
movedEntity = GameManager.instance.Beatmap.VolumeChanges.Find(x => x.guid == entityId);
break;
case SpecialTimeline.HoveringTypes.SectionChange:
movedEntity = GameManager.instance.Beatmap.SectionMarkers.Find(x => x.guid == entityId);
break;
}
if (movedEntity != null)
{
movedEntity.beat = lastBeat;
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7052872845575e443816f75abb8e7e49
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -30,8 +30,8 @@ public class SectionDialog : Dialog
public void SetSectionObj(SectionTimelineObj sectionObj)
{
this.sectionObj = sectionObj;
sectionName.text = sectionObj.chartSection["sectionName"];
challengeEnable.isOn = sectionObj.chartSection["startPerfect"];
sectionName.text = sectionObj.chartEntity["sectionName"];
challengeEnable.isOn = sectionObj.chartEntity["startPerfect"];
}
public void DeleteSection()
@ -41,20 +41,19 @@ public class SectionDialog : Dialog
Editor.instance.inAuthorativeMenu = false;
}
if (sectionObj == null) return;
GameManager.instance.Beatmap.SectionMarkers.Remove(sectionObj.chartSection);
sectionObj.DeleteObj();
}
public void ChangeSectionName(string name)
{
if (sectionObj == null) return;
sectionObj.chartSection["sectionName"] = name;
sectionObj.chartEntity["sectionName"] = name;
sectionObj.UpdateLabel();
}
public void SetSectionChallenge()
{
if (sectionObj == null) return;
sectionObj.chartSection["startPerfect"] = challengeEnable.isOn;
sectionObj.chartEntity["startPerfect"] = challengeEnable.isOn;
}
}

View file

@ -21,7 +21,7 @@ namespace HeavenStudio.Editor.Track
[Header("Components")]
private RectTransform rectTransform;
public List<SpecialTimelineObj> specialTimelineObjs = new List<SpecialTimelineObj>();
public Dictionary<Guid, SpecialTimelineObj> specialTimelineObjs = new();
[System.Flags]
public enum HoveringTypes
@ -48,7 +48,7 @@ namespace HeavenStudio.Editor.Track
{
ClearSpecialTimeline();
GameManager.instance.SortEventsList();
bool first = true;
foreach (var tempoChange in GameManager.instance.Beatmap.TempoChanges)
{
@ -110,7 +110,7 @@ namespace HeavenStudio.Editor.Track
public void FixObjectsVisibility()
{
foreach (SpecialTimelineObj obj in specialTimelineObjs)
foreach (SpecialTimelineObj obj in specialTimelineObjs.Values)
{
obj.SetVisibility(Timeline.instance.timelineState.currentState);
}
@ -118,7 +118,7 @@ namespace HeavenStudio.Editor.Track
public void ClearSpecialTimeline()
{
foreach (SpecialTimelineObj obj in specialTimelineObjs)
foreach (SpecialTimelineObj obj in specialTimelineObjs.Values)
{
Destroy(obj.gameObject);
}
@ -126,7 +126,16 @@ namespace HeavenStudio.Editor.Track
}
public void AddTempoChange(bool create, RiqEntity tempoChange_ = null, bool first = false)
{
{
if (create)
{
foreach (var e in GameManager.instance.Beatmap.TempoChanges)
{
if (Timeline.instance.MousePos2BeatSnap > e.beat - Timeline.instance.snapInterval && Timeline.instance.MousePos2BeatSnap < e.beat + Timeline.instance.snapInterval)
return;
}
}
GameObject tempoChange = Instantiate(RefTempoChange.gameObject, this.transform);
tempoChange.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.TempoLayerCol.Hex2RGB();
@ -136,35 +145,46 @@ namespace HeavenStudio.Editor.Track
tempoChange.SetActive(true);
TempoTimelineObj tempoTimelineObj = tempoChange.GetComponent<TempoTimelineObj>();
tempoTimelineObj.type = HoveringTypes.TempoChange;
if (create == true)
if (create)
{
float lastTempo = Conductor.instance.GetBpmAtBeat(tempoChange.transform.localPosition.x);
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
{
lastTempo = lastTempo * 2f;
lastTempo *= 2f;
}
else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
{
lastTempo = lastTempo / 2f;
lastTempo /= 2f;
}
RiqEntity tempoC = GameManager.instance.Beatmap.AddNewTempoChange(Timeline.instance.MousePos2BeatSnap, lastTempo);
tempoTimelineObj.tempoChange = tempoC;
tempoTimelineObj.chartEntity = tempoC;
CommandManager.Instance.AddCommand(new Commands.AddMarker(tempoC, tempoC.guid, HoveringTypes.TempoChange));
}
else
{
tempoTimelineObj.tempoChange = tempoChange_;
tempoTimelineObj.chartEntity = tempoChange_;
tempoTimelineObj.first = first;
}
tempoTimelineObj.SetVisibility(Timeline.instance.timelineState.currentState);
specialTimelineObjs.Add(tempoTimelineObj);
specialTimelineObjs.Add(tempoTimelineObj.chartEntity.guid, tempoTimelineObj);
Timeline.instance.FitToSong();
}
public void AddVolumeChange(bool create, RiqEntity volumeChange_ = null, bool first = false)
{
{
if (create)
{
foreach (var e in GameManager.instance.Beatmap.VolumeChanges)
{
if (Timeline.instance.MousePos2BeatSnap > e.beat - Timeline.instance.snapInterval && Timeline.instance.MousePos2BeatSnap < e.beat + Timeline.instance.snapInterval)
return;
}
}
GameObject volumeChange = Instantiate(RefVolumeChange.gameObject, this.transform);
volumeChange.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.MusicLayerCol.Hex2RGB();
@ -174,25 +194,36 @@ namespace HeavenStudio.Editor.Track
volumeChange.SetActive(true);
VolumeTimelineObj volumeTimelineObj = volumeChange.GetComponent<VolumeTimelineObj>();
volumeTimelineObj.type = HoveringTypes.VolumeChange;
if (create == true)
if (create)
{
RiqEntity volumeC = GameManager.instance.Beatmap.AddNewVolumeChange(Timeline.instance.MousePos2BeatSnap, 100f);
volumeTimelineObj.volumeChange = volumeC;
volumeTimelineObj.chartEntity = volumeC;
GameManager.instance.Beatmap.VolumeChanges.Add(volumeC);
CommandManager.Instance.AddCommand(new Commands.AddMarker(volumeC, volumeC.guid, HoveringTypes.VolumeChange));
}
else
{
volumeTimelineObj.volumeChange = volumeChange_;
volumeTimelineObj.chartEntity = volumeChange_;
volumeTimelineObj.first = first;
}
volumeTimelineObj.SetVisibility(Timeline.instance.timelineState.currentState);
specialTimelineObjs.Add(volumeTimelineObj);
specialTimelineObjs.Add(volumeTimelineObj.chartEntity.guid, volumeTimelineObj);
}
public void AddChartSection(bool create, RiqEntity chartSection_ = null)
{
{
if (create)
{
foreach (var e in GameManager.instance.Beatmap.SectionMarkers)
{
if (Timeline.instance.MousePos2BeatSnap > e.beat - Timeline.instance.snapInterval && Timeline.instance.MousePos2BeatSnap < e.beat + Timeline.instance.snapInterval)
return;
}
}
GameObject chartSection = Instantiate(RefSectionChange.gameObject, this.transform);
chartSection.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.SectionLayerCol.Hex2RGB();
@ -203,28 +234,26 @@ namespace HeavenStudio.Editor.Track
chartSection.SetActive(true);
SectionTimelineObj sectionTimelineObj = chartSection.GetComponent<SectionTimelineObj>();
sectionTimelineObj.type = HoveringTypes.SectionChange;
if (create == true)
if (create)
{
RiqEntity sectionC = GameManager.instance.Beatmap.AddNewSectionMarker(Timeline.instance.MousePos2BeatSnap, "New Section");
sectionTimelineObj.chartSection = sectionC;
sectionTimelineObj.chartEntity = sectionC;
GameManager.instance.Beatmap.SectionMarkers.Add(sectionC);
CommandManager.Instance.AddCommand(new Commands.AddMarker(sectionC, sectionC.guid, HoveringTypes.SectionChange));
}
else
{
sectionTimelineObj.chartSection = chartSection_;
sectionTimelineObj.chartEntity = chartSection_;
}
sectionTimelineObj.SetVisibility(Timeline.instance.timelineState.currentState);
specialTimelineObjs.Add(sectionTimelineObj);
specialTimelineObjs.Add(sectionTimelineObj.chartEntity.guid, sectionTimelineObj);
//auto-open the dialog
sectionTimelineObj.OnRightClick();
}
public bool InteractingWithEvents()
{
return specialTimelineObjs.FindAll(c => c.hovering == true).Count > 0 || specialTimelineObjs.FindAll(c => c.moving == true).Count > 0;
if (create)
sectionTimelineObj.OnRightClick();
}
}
}

View file

@ -16,8 +16,6 @@ namespace HeavenStudio.Editor.Track
[SerializeField] private GameObject chartLine;
[SerializeField] private SectionDialog sectionDialog;
public RiqEntity chartSection;
new private void Update()
{
base.Update();
@ -31,8 +29,9 @@ namespace HeavenStudio.Editor.Track
public void UpdateLabel()
{
sectionLabel.text = chartSection["sectionName"];
SetX(chartSection);
sectionLabel.text = chartEntity["sectionName"];
if (!moving)
SetX(chartEntity);
}
public override void Init()
@ -55,16 +54,19 @@ namespace HeavenStudio.Editor.Track
}
}
public override bool OnMove(float beat)
public override bool OnMove(float beat, bool final = false)
{
foreach (RiqEntity sectionChange in GameManager.instance.Beatmap.SectionMarkers)
{
if (this.chartSection == sectionChange)
if (this.chartEntity == sectionChange)
continue;
if (beat > sectionChange.beat - Timeline.instance.snapInterval && beat < sectionChange.beat + Timeline.instance.snapInterval)
return false;
}
this.chartSection.beat = beat;
if (final)
CommandManager.Instance.AddCommand(new Commands.MoveMarker(chartEntity.guid, beat, type));
else
SetX(beat);
return true;
}

View file

@ -18,10 +18,13 @@ namespace HeavenStudio.Editor.Track
private float startPosX;
private float lastPosX;
public SpecialTimeline.HoveringTypes type;
public bool moving = false;
public bool hovering;
public bool first = false;
public RiqEntity chartEntity;
private void Start()
{
rectTransform = GetComponent<RectTransform>();
@ -58,6 +61,7 @@ namespace HeavenStudio.Editor.Track
transform.localPosition = new Vector3(lastPosX, transform.localPosition.y);*/
moving = false;
OnMove(Timeline.instance.MousePos2BeatSnap, true);
lastPosX = transform.localPosition.x;
}
}
@ -82,6 +86,11 @@ namespace HeavenStudio.Editor.Track
rectTransform.anchoredPosition = new Vector2((float)entity.beat * Timeline.instance.PixelsPerBeat, rectTransform.anchoredPosition.y);
}
public void SetX(float beat)
{
rectTransform.anchoredPosition = new Vector2(beat * Timeline.instance.PixelsPerBeat, rectTransform.anchoredPosition.y);
}
public void StartMove()
{
if (first) return;
@ -94,18 +103,19 @@ namespace HeavenStudio.Editor.Track
public void DeleteObj()
{
if (first) return;
transform.parent.GetComponent<SpecialTimeline>().specialTimelineObjs.Remove(this);
Destroy(this.gameObject);
CommandManager.Instance.AddCommand(new Commands.DeleteMarker(chartEntity.guid, type));
// transform.parent.GetComponent<SpecialTimeline>().specialTimelineObjs.Remove(this);
// Destroy(this.gameObject);
}
//events
public virtual void Init() {}
public virtual void OnLeftClick() {}
public virtual void OnRightClick() {}
public virtual bool OnMove(float beat)
public virtual void Init() { }
public virtual void OnLeftClick() { }
public virtual void OnRightClick() { }
public virtual bool OnMove(float beat, bool final = false)
{
return true;
}
public virtual void SetVisibility(Timeline.CurrentTimelineState.State state) {}
public virtual void SetVisibility(Timeline.CurrentTimelineState.State state) { }
}
}

View file

@ -16,8 +16,6 @@ namespace HeavenStudio.Editor.Track
[SerializeField] private TMP_Text tempoTXT;
[SerializeField] private GameObject tempoLine;
public RiqEntity tempoChange;
new private void Update()
{
base.Update();
@ -33,11 +31,11 @@ namespace HeavenStudio.Editor.Track
if (Input.GetKey(KeyCode.LeftControl))
newTempo *= 0.01f;
tempoChange["tempo"] += newTempo;
chartEntity["tempo"] += newTempo;
//make sure tempo is positive
if (tempoChange["tempo"] < 1)
tempoChange["tempo"] = 1;
if (chartEntity["tempo"] < 1)
chartEntity["tempo"] = 1;
if (first && newTempo != 0)
Timeline.instance.UpdateStartingBPMText();
@ -51,8 +49,9 @@ namespace HeavenStudio.Editor.Track
private void UpdateTempo()
{
tempoTXT.text = tempoChange["tempo"].ToString("F") + $" BPM";
SetX(tempoChange);
tempoTXT.text = chartEntity["tempo"].ToString("F") + $" BPM";
if (!moving)
SetX(chartEntity);
}
public override void Init()
@ -71,21 +70,23 @@ namespace HeavenStudio.Editor.Track
if (first) return;
if (Timeline.instance.timelineState.currentState == Timeline.CurrentTimelineState.State.TempoChange)
{
GameManager.instance.Beatmap.TempoChanges.Remove(tempoChange);
DeleteObj();
}
}
public override bool OnMove(float beat)
public override bool OnMove(float beat, bool final = false)
{
foreach (var tempoChange in GameManager.instance.Beatmap.TempoChanges)
{
if (this.tempoChange == tempoChange)
if (this.chartEntity == tempoChange)
continue;
if (beat > tempoChange.beat - Timeline.instance.snapInterval && beat < tempoChange.beat + Timeline.instance.snapInterval)
return false;
}
this.tempoChange.beat = beat;
if (final)
CommandManager.Instance.AddCommand(new Commands.MoveMarker(chartEntity.guid, beat, type));
else
SetX(beat);
return true;
}

View file

@ -16,8 +16,6 @@ namespace HeavenStudio.Editor.Track
[SerializeField] private TMP_Text volumeTXT;
[SerializeField] private GameObject volumeLine;
public RiqEntity volumeChange;
new private void Update()
{
base.Update();
@ -33,10 +31,10 @@ namespace HeavenStudio.Editor.Track
if (Input.GetKey(KeyCode.LeftControl))
newVolume *= 0.01f;
volumeChange["volume"] += newVolume;
chartEntity["volume"] += newVolume;
//make sure volume is positive
volumeChange["volume"] = Mathf.Clamp(volumeChange["volume"], 0, 100);
chartEntity["volume"] = Mathf.Clamp(chartEntity["volume"], 0, 100);
if (first && newVolume != 0)
Timeline.instance.UpdateStartingVolText();
@ -47,8 +45,9 @@ namespace HeavenStudio.Editor.Track
private void UpdateVolume()
{
volumeTXT.text = $"{volumeChange["volume"].ToString("F")}%";
SetX(volumeChange);
volumeTXT.text = $"{chartEntity["volume"].ToString("F")}%";
if (!moving)
SetX(chartEntity);
}
public override void Init()
@ -67,21 +66,23 @@ namespace HeavenStudio.Editor.Track
if (first) return;
if (Timeline.instance.timelineState.currentState == Timeline.CurrentTimelineState.State.MusicVolume)
{
GameManager.instance.Beatmap.VolumeChanges.Remove(volumeChange);
DeleteObj();
}
}
public override bool OnMove(float beat)
public override bool OnMove(float beat, bool final = false)
{
foreach (var volumeChange in GameManager.instance.Beatmap.VolumeChanges)
{
if (this.volumeChange == volumeChange)
if (this.chartEntity == volumeChange)
continue;
if (beat > volumeChange.beat - Timeline.instance.snapInterval && beat < volumeChange.beat + Timeline.instance.snapInterval)
return false;
}
this.volumeChange.beat = beat;
if (final)
CommandManager.Instance.AddCommand(new Commands.MoveMarker(chartEntity.guid, beat, type));
else
SetX(beat);
return true;
}

View file

@ -186,7 +186,7 @@ namespace HeavenStudio.Editor.Track
public float rightSide => (TimelineScroll.viewport.rect.width / PixelsPerBeat) + leftSide;
private Vector2 lastScreenSize;
public static Timeline instance { get; private set; }
[HideInInspector]
@ -243,25 +243,25 @@ namespace HeavenStudio.Editor.Track
TimelineSlider.GetChild(3).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
TimelineSongPosLineRef.GetComponent<Image>().color = EditorTheme.theme.properties.CurrentTimeMarkerCol.Hex2RGB();
PlayBTN.onClick.AddListener(delegate
PlayBTN.onClick.AddListener(delegate
{
if (Conductor.instance.isPaused)
PlayCheck(false);
else
PlayCheck(true);
PlayCheck(true);
});
PauseBTN.onClick.AddListener(delegate
PauseBTN.onClick.AddListener(delegate
{
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
PlayCheck(false);
PlayCheck(false);
});
StopBTN.onClick.AddListener(delegate
StopBTN.onClick.AddListener(delegate
{
if (Conductor.instance.isPlaying || Conductor.instance.isPaused)
PlayCheck(true);
PlayCheck(true);
});
MetronomeBTN.onClick.AddListener(delegate
MetronomeBTN.onClick.AddListener(delegate
{
MetronomeToggle();
});
@ -503,7 +503,7 @@ namespace HeavenStudio.Editor.Track
#region Keyboard Shortcuts
if ((!userIsEditingInputField) && Editor.instance.isShortcutsEnabled)
{
if (Input.GetKeyDown(KeyCode.Space))
{
if (Input.GetKey(KeyCode.LeftShift))
@ -624,7 +624,7 @@ namespace HeavenStudio.Editor.Track
public static float GetScaleModifier()
{
Camera cam = Editor.instance.EditorCamera;
return Mathf.Pow(cam.pixelWidth/1280f, 1f) * Mathf.Pow(cam.pixelHeight/720f, 0f);
return Mathf.Pow(cam.pixelWidth / 1280f, 1f) * Mathf.Pow(cam.pixelHeight / 720f, 0f);
}
public Vector2 LayerCornersToDist()
@ -656,7 +656,7 @@ namespace HeavenStudio.Editor.Track
{
Stop(PlaybackBeat);
}
}
else
{
@ -707,7 +707,7 @@ namespace HeavenStudio.Editor.Track
// timelineSlider.value = 0;
if (TimelineSongPosLine != null)
Destroy(TimelineSongPosLine.gameObject);
Destroy(TimelineSongPosLine.gameObject);
GameManager.instance.Stop(time);
@ -733,10 +733,11 @@ namespace HeavenStudio.Editor.Track
PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
}
else
{ PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
{
PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
PauseBTN.enabled = false;
}
if (stopEnabled)
{
StopBTN.enabled = true;
@ -1153,7 +1154,7 @@ namespace HeavenStudio.Editor.Track
// Failsafe against empty string.
if (String.IsNullOrEmpty(FirstBeatOffset.text))
FirstBeatOffset.text = "0";
// Convert ms to s.
double newOffset = Convert.ToDouble(FirstBeatOffset.text) / 1000f;
@ -1175,7 +1176,7 @@ namespace HeavenStudio.Editor.Track
// Failsafe against empty string.
if (String.IsNullOrEmpty(text))
text = "120";
var newBPM = Convert.ToDouble(text);
// Failsafe against negative BPM.
@ -1189,7 +1190,7 @@ namespace HeavenStudio.Editor.Track
newBPM = System.Math.Round(newBPM, 4);
RiqEntity tempoChange = GameManager.instance.Beatmap.TempoChanges[0];
tempoChange["tempo"] = (float) newBPM;
tempoChange["tempo"] = (float)newBPM;
GameManager.instance.Beatmap.TempoChanges[0] = tempoChange;
// In case the newBPM ended up differing from the inputted string.
@ -1208,7 +1209,7 @@ namespace HeavenStudio.Editor.Track
// Failsafe against empty string.
if (String.IsNullOrEmpty(StartingVolumeSpecialVolume.text))
StartingVolumeSpecialVolume.text = "100";
var newVol = Convert.ToInt32(StartingVolumeSpecialVolume.text);
newVol = Mathf.Clamp(newVol, 0, 100);
@ -1224,7 +1225,7 @@ namespace HeavenStudio.Editor.Track
#region Commands
public void Move()
{
{
}
public void Undo()