mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:07:38 +02:00
Playback speed slider
This commit is contained in:
@ -352,9 +352,9 @@ namespace RhythmHeavenMania
|
||||
|
||||
public GameObject GetGame(string name)
|
||||
{
|
||||
if (name == "gameManager")
|
||||
if (name == "gameManager" || name == "countIn")
|
||||
{
|
||||
name = Beatmap.entities.FindAll(c => c.datamodel.Split(0) != "gameManager" || c.datamodel.Split(0) != "countIn").ToList()[0].datamodel.Split(0);
|
||||
name = Beatmap.entities.FindAll(c => c.datamodel.Split(0) != "gameManager" && c.datamodel.Split(0) != "countIn").ToList()[0].datamodel.Split(0);
|
||||
}
|
||||
return Resources.Load<GameObject>($"Games/{name}");
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
||||
|
||||
private void CheckIfFall(float normalizedBeat)
|
||||
{
|
||||
if (normalizedBeat > 1.05f)
|
||||
if (normalizedBeat > 1.05f && !GameManager.instance.autoplay)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("spaceSoccer/missNeutral");
|
||||
ball = null;
|
||||
|
@ -56,6 +56,12 @@ namespace RhythmHeavenMania.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
if (boxVisual.rect.width * boxVisual.transform.localScale.x >= 0.5f)
|
||||
boxVisual.transform.GetChild(1).GetComponent<TMPro.TMP_Text>().text = $"{string.Format("{0:0.000}", boxVisual.rect.width * boxVisual.transform.localScale.x)}";
|
||||
else
|
||||
boxVisual.transform.GetChild(1).GetComponent<TMPro.TMP_Text>().text = string.Empty; // i'm lazy
|
||||
|
||||
|
||||
// click
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
@ -92,6 +98,8 @@ namespace RhythmHeavenMania.Editor
|
||||
Vector2 boxStart = startPosition;
|
||||
Vector2 boxEnd = endPosition;
|
||||
|
||||
// boxEnd = new Vector2(Mathf.Clamp(boxEnd.x, -5.78f, Mathf.Infinity), boxEnd.y);
|
||||
|
||||
Vector2 boxCenter = (boxStart + boxEnd) / 2;
|
||||
boxVisual.position = boxCenter;
|
||||
|
||||
@ -134,7 +142,7 @@ namespace RhythmHeavenMania.Editor
|
||||
|
||||
private void SelectEvents()
|
||||
{
|
||||
if (!Input.GetKey(KeyCode.LeftShift)) Selections.instance.DeselectAll();
|
||||
if (!Input.GetKey(KeyCode.LeftShift) && !Timeline.instance.InteractingWithEvents()) Selections.instance.DeselectAll();
|
||||
|
||||
int selected = 0;
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace RhythmHeavenMania.Editor
|
||||
UpdateEditorStatus(true);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
public void LateUpdate()
|
||||
{
|
||||
// This is buggy
|
||||
/*if (Conductor.instance.isPlaying || Conductor.instance.isPaused)
|
||||
@ -147,7 +147,7 @@ namespace RhythmHeavenMania.Editor
|
||||
}
|
||||
|
||||
if (Timeline.instance.timelineState.selected == true)
|
||||
if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline())
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
List<TimelineEventObj> selectedEvents = Timeline.instance.eventObjs.FindAll(c => c.selected == true && c.eligibleToMove == true);
|
||||
|
||||
|
@ -156,7 +156,7 @@ namespace RhythmHeavenMania.Editor
|
||||
|
||||
public void Drag()
|
||||
{
|
||||
if (Conductor.instance.NotStopped()) return;
|
||||
if (Conductor.instance.NotStopped() || !Timeline.instance.timelineState.selected) return;
|
||||
|
||||
if (Timeline.instance.CheckIfMouseInTimeline() && dragTimes < 1)
|
||||
{
|
||||
|
@ -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