mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:17:38 +02:00
Playback speed slider
This commit is contained in:
@ -75,6 +75,7 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
public Button SelectionsBTN;
|
||||
public Button TempoChangeBTN;
|
||||
public Button MusicVolumeBTN;
|
||||
public Slider PlaybackSpeed;
|
||||
|
||||
public static Timeline instance { get; private set; }
|
||||
|
||||
@ -182,6 +183,8 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
Tooltip.AddTooltip(TempoChangeBTN.gameObject, "Tool: Tempo Change <color=#adadad>[2]</color>");
|
||||
Tooltip.AddTooltip(MusicVolumeBTN.gameObject, "Tool: Music Volume <color=#adadad>[3]</color>");
|
||||
|
||||
Tooltip.AddTooltip(PlaybackSpeed.gameObject, "The preview's playback speed. Right click to reset to 1.0");
|
||||
|
||||
SetTimeButtonColors(true, false, false);
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
|
||||
@ -526,6 +529,23 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
return LayersRect.rect.height / 4;
|
||||
}
|
||||
|
||||
public void SetPlaybackSpeed(float speed)
|
||||
{
|
||||
float spd = Mathp.Round2Nearest(speed, 0.25f);
|
||||
PlaybackSpeed.transform.GetChild(3).GetComponent<TMP_Text>().text = $"Playback Speed: {spd}x";
|
||||
Conductor.instance.musicSource.pitch = spd;
|
||||
PlaybackSpeed.value = spd;
|
||||
}
|
||||
|
||||
public void ResetPlaybackSpeed()
|
||||
{
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
PlaybackSpeed.transform.GetChild(3).GetComponent<TMP_Text>().text = $"Playback Speed: 1.0x";
|
||||
PlaybackSpeed.value = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
|
@ -26,6 +26,7 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
[SerializeField] private RectTransform resizeGraphic;
|
||||
[SerializeField] private RectTransform leftDrag;
|
||||
[SerializeField] private RectTransform rightDrag;
|
||||
private GameObject moveTemp;
|
||||
|
||||
[Header("Properties")]
|
||||
public Beatmap.Entity entity;
|
||||
@ -59,6 +60,16 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
}
|
||||
|
||||
lastMovePos = transform.localPosition;
|
||||
|
||||
moveTemp = new GameObject();
|
||||
moveTemp.transform.SetParent(this.transform.parent);
|
||||
|
||||
bool visible = rectTransform.IsVisibleFrom(Camera.main);
|
||||
for (int i = 0; i < this.transform.childCount; i++)
|
||||
{
|
||||
if (i != 4)
|
||||
this.transform.GetChild(i).gameObject.SetActive(visible);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -77,7 +88,8 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
{
|
||||
for (int i = 0; i < this.transform.childCount; i++)
|
||||
{
|
||||
// this.transform.GetChild(i).gameObject.SetActive(visible);
|
||||
if (transform.GetChild(i).gameObject != selectedImage)
|
||||
this.transform.GetChild(i).gameObject.SetActive(visible);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,12 +99,6 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
|
||||
SetColor(GetTrack());
|
||||
|
||||
if (Conductor.instance.NotStopped())
|
||||
{
|
||||
Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (selected)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
@ -115,9 +121,15 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
outline.GetChild(i).GetComponent<Image>().color = new Color32(0, 0, 0, 51);
|
||||
}
|
||||
|
||||
if (Conductor.instance.NotStopped())
|
||||
{
|
||||
Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!resizing)
|
||||
{
|
||||
if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline() && Timeline.instance.timelineState.selected)
|
||||
if (Input.GetMouseButtonUp(0) && Timeline.instance.timelineState.selected)
|
||||
{
|
||||
if (Timeline.instance.eventObjs.FindAll(c => c.mouseHovering).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.moving).Count == 0 && !BoxSelection.instance.selecting && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0)
|
||||
{
|
||||
@ -136,15 +148,18 @@ namespace RhythmHeavenMania.Editor.Track
|
||||
|
||||
// lastPos_ = transform.localPosition;
|
||||
|
||||
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
|
||||
// this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
// this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
|
||||
moveTemp.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
moveTemp.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(moveTemp.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(moveTemp.transform.localPosition.y));
|
||||
|
||||
if (lastPos != transform.localPosition)
|
||||
if (lastPos != moveTemp.transform.localPosition)
|
||||
{
|
||||
OnMove();
|
||||
this.transform.DOLocalMove(new Vector3(Mathf.Clamp(Mathp.Round2Nearest(moveTemp.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(moveTemp.transform.localPosition.y)), 0.15f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
|
||||
lastPos = this.transform.localPosition;
|
||||
lastPos = moveTemp.transform.localPosition;
|
||||
}
|
||||
}
|
||||
else if (resizingLeft)
|
||||
|
Reference in New Issue
Block a user