mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-23 10:05:14 +00:00
Some tempo changes improvements
This commit is contained in:
parent
5da4ceae07
commit
af24468f25
9 changed files with 297 additions and 51 deletions
|
@ -1 +1 @@
|
|||
{"bpm":125.0,"entities":[{"beat":0.0,"track":0,"length":33.0,"datamodel":"karateman/bop"},{"beat":1.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":3.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":3.5,"track":2,"length":1.0,"datamodel":"karateman/hit3"},{"beat":5.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":6.0,"track":2,"length":2.0,"datamodel":"karateman/pot"},{"beat":7.0,"track":3,"length":2.0,"datamodel":"karateman/rock"},{"beat":9.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":11.0,"track":1,"length":2.0,"datamodel":"karateman/bulb"},{"beat":13.0,"track":1,"length":4.5,"datamodel":"karateman/kick"},{"beat":17.0,"track":2,"length":2.0,"datamodel":"karateman/pot"},{"beat":19.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":19.5,"track":2,"length":1.0,"datamodel":"karateman/hit4"},{"beat":21.0,"track":0,"length":2.0,"datamodel":"karateman/pot"},{"beat":22.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":23.0,"track":2,"length":2.0,"datamodel":"karateman/pot"},{"beat":24.0,"track":3,"length":2.0,"datamodel":"karateman/ball"},{"beat":25.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":27.0,"track":1,"length":2.0,"datamodel":"karateman/bulb"},{"beat":29.0,"track":1,"length":4.0,"datamodel":"karateman/combo"}]}
|
||||
{"bpm":125.0,"entities":[{"beat":0.0,"track":0,"length":33.0,"datamodel":"karateman/bop"},{"beat":0.0,"track":3,"length":1.0,"datamodel":"gameManager/switchGame/karateman"},{"beat":1.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":3.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":3.5,"track":2,"length":1.0,"datamodel":"karateman/hit3"},{"beat":5.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":6.0,"track":2,"length":2.0,"datamodel":"karateman/pot"},{"beat":7.0,"track":3,"length":2.0,"datamodel":"karateman/rock"},{"beat":9.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":11.0,"track":1,"length":2.0,"datamodel":"karateman/bulb"},{"beat":13.0,"track":1,"length":4.5,"datamodel":"karateman/kick"},{"beat":17.0,"track":2,"length":2.0,"datamodel":"karateman/pot"},{"beat":19.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":19.5,"track":2,"length":1.0,"datamodel":"karateman/hit4"},{"beat":21.0,"track":0,"length":2.0,"datamodel":"karateman/pot"},{"beat":22.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":23.0,"track":2,"length":2.0,"datamodel":"karateman/pot"},{"beat":24.0,"track":3,"length":2.0,"datamodel":"karateman/ball"},{"beat":25.0,"track":1,"length":2.0,"datamodel":"karateman/pot"},{"beat":27.0,"track":1,"length":2.0,"datamodel":"karateman/bulb"},{"beat":29.0,"track":1,"length":4.0,"datamodel":"karateman/combo"},{"beat":33.0,"track":1,"length":1.0,"datamodel":"clappyTrio/bop"},{"beat":33.0,"track":0,"length":1.0,"datamodel":"gameManager/switchGame/clappyTrio"},{"beat":34.0,"track":1,"length":1.0,"datamodel":"clappyTrio/bop"},{"beat":35.0,"track":1,"length":1.0,"datamodel":"clappyTrio/prepare_alt"},{"beat":36.5,"track":1,"length":0.75,"datamodel":"clappyTrio/clap"},{"beat":38.5,"track":0,"length":1.0,"datamodel":"clappyTrio/prepare"},{"beat":39.0,"track":1,"length":0.25,"datamodel":"clappyTrio/clap"},{"beat":40.0,"track":1,"length":1.0,"datamodel":"clappyTrio/bop"},{"beat":41.0,"track":0,"length":1.0,"datamodel":"gameManager/switchGame/spaceball"},{"beat":42.0,"track":1,"length":2.0,"datamodel":"spaceball/shoot"},{"beat":45.0,"track":1,"length":3.0,"datamodel":"spaceball/shootHigh"},{"beat":48.0,"track":1,"length":2.0,"datamodel":"spaceball/shoot"},{"beat":50.0,"track":1,"length":2.0,"datamodel":"spaceball/shoot"},{"beat":53.0,"track":1,"length":3.0,"datamodel":"spaceball/shootHigh"},{"beat":57.0,"track":1,"length":2.0,"datamodel":"spaceball/shoot"},{"beat":59.0,"track":1,"length":2.0,"datamodel":"spaceball/shoot"},{"beat":61.0,"track":1,"length":3.0,"datamodel":"spaceball/shootHigh"},{"beat":64.0,"track":0,"length":1.0,"datamodel":"gameManager/switchGame/forkLifter"},{"beat":65.0,"track":1,"length":3.0,"datamodel":"forkLifter/pea"},{"beat":68.0,"track":0,"length":3.0,"datamodel":"forkLifter/pea"},{"beat":70.0,"track":1,"length":3.0,"datamodel":"forkLifter/pea"},{"beat":72.5,"track":2,"length":1.0,"datamodel":"forkLifter/gulp"},{"beat":73.0,"track":1,"length":2.0,"datamodel":"spaceSoccer/ball dispense"},{"beat":73.0,"track":0,"length":1.0,"datamodel":"gameManager/switchGame/spaceSoccer"},{"beat":75.0,"track":1,"length":10.0,"datamodel":"spaceSoccer/keep-up"},{"beat":85.0,"track":1,"length":3.0,"datamodel":"spaceSoccer/high kick-toe!"},{"beat":88.0,"track":1,"length":5.0,"datamodel":"spaceSoccer/keep-up"},{"beat":93.0,"track":1,"length":3.0,"datamodel":"spaceSoccer/high kick-toe!"},{"beat":96.0,"track":1,"length":4.0,"datamodel":"spaceSoccer/keep-up"}],"tempoChanges":[]}
|
|
@ -4297,6 +4297,7 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 666273484}
|
||||
- component: {fileID: 666273485}
|
||||
m_Layer: 5
|
||||
m_Name: TempoChange
|
||||
m_TagString: Untagged
|
||||
|
@ -4318,6 +4319,7 @@ RectTransform:
|
|||
- {fileID: 2127964035}
|
||||
- {fileID: 1287203020}
|
||||
- {fileID: 499528698}
|
||||
- {fileID: 983551349}
|
||||
m_Father: {fileID: 689207020}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -4326,6 +4328,26 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0.0876, y: 0}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!114 &666273485
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 666273483}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dfe88f36dac55f44dac7fe958fe3c228, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
rectTransform: {fileID: 0}
|
||||
tempoTXT: {fileID: 499528699}
|
||||
raycastRect: {fileID: 983551349}
|
||||
tempoChange:
|
||||
beat: 0
|
||||
length: 0
|
||||
tempo: 0
|
||||
hovering: 0
|
||||
--- !u!1 &678553524
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -4511,6 +4533,8 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
RefTempoChange: {fileID: 666273484}
|
||||
StartingBPM: {fileID: 1199306549}
|
||||
tempoTimelineObjs: []
|
||||
--- !u!114 &689207022
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -6366,6 +6390,81 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 954835803}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &983551348
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 983551349}
|
||||
- component: {fileID: 983551351}
|
||||
- component: {fileID: 983551350}
|
||||
m_Layer: 5
|
||||
m_Name: Raycast
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &983551349
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 983551348}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 1, w: 0}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 666273484}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0.36, y: 33.998}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!114 &983551350
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 983551348}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &983551351
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 983551348}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &991363086
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -8725,7 +8824,7 @@ RectTransform:
|
|||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0.02000001, y: 33.998}
|
||||
m_SizeDelta: {x: 0.03, y: 33.998}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!114 &1287203021
|
||||
MonoBehaviour:
|
||||
|
@ -9340,8 +9439,8 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: f86858990a87c764892672104bdaef1f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
level: {fileID: 4900000, guid: fafaeee85f4121643a0699a4de97da53, type: 3}
|
||||
music: {fileID: 8300000, guid: a0589cdba27fb254e90da17b4804c2fe, type: 3}
|
||||
level: {fileID: 4900000, guid: ad2467f171a3aee4b9be8c26e2e1a42c, type: 3}
|
||||
music: {fileID: 8300000, guid: 7d1a104c87e593f40a262ebbcb2a371b, type: 3}
|
||||
debugUI: 0
|
||||
playOnStart: 0
|
||||
editor: 1
|
||||
|
@ -11656,12 +11755,12 @@ MonoBehaviour:
|
|||
SongBeat: {fileID: 932211468}
|
||||
SongPos: {fileID: 1567318397}
|
||||
CurrentTempo: {fileID: 1783963081}
|
||||
StartingBPM: {fileID: 1199306549}
|
||||
eventObjs: []
|
||||
LayerCount: 4
|
||||
metronomeEnabled: 0
|
||||
resizable: 0
|
||||
TimelineSlider: {fileID: 770589360}
|
||||
TimelineGridSelect: {fileID: 238901181}
|
||||
TimelinePlaybackBeat: {fileID: 117889364}
|
||||
TimelineContent: {fileID: 1852819573}
|
||||
TimelineSongPosLineRef: {fileID: 580861938}
|
||||
|
@ -12795,7 +12894,7 @@ RectTransform:
|
|||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0.109999985, y: 11.84}
|
||||
m_SizeDelta: {x: 0.15, y: 11.84}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!114 &2127964036
|
||||
MonoBehaviour:
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace RhythmHeavenMania
|
|||
|
||||
songPosition = time - firstBeatOffset;
|
||||
|
||||
songPositionInBeats += (Time.deltaTime - firstBeatOffset) / secPerBeat;
|
||||
songPositionInBeats += ((Time.deltaTime * musicSource.pitch) - firstBeatOffset) / secPerBeat;
|
||||
// songPositionInBeats = Time.deltaTime / secPerBeat;
|
||||
|
||||
if (metronome)
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
public void Undo()
|
||||
{
|
||||
if (!canUndo()) return;
|
||||
if (!canUndo() || Conductor.instance.NotStopped()) return;
|
||||
|
||||
if (historyStack.Count > 0)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
public void Redo()
|
||||
{
|
||||
if (!canRedo()) return;
|
||||
if (!canRedo() || Conductor.instance.NotStopped()) return;
|
||||
|
||||
if (redoHistoryStack.Count > 0)
|
||||
{
|
||||
|
|
|
@ -13,24 +13,62 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
[Header("Components")]
|
||||
private RectTransform rectTransform;
|
||||
[SerializeField] private RectTransform RefTempoChange;
|
||||
[SerializeField] private RectTransform StartingBPM;
|
||||
|
||||
public List<TempoTimelineObj> tempoTimelineObjs = new List<TempoTimelineObj>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rectTransform = this.GetComponent<RectTransform>();
|
||||
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.tempoChanges.Count; i++)
|
||||
{
|
||||
Beatmap.TempoChange tempoChange = GameManager.instance.Beatmap.tempoChanges[i];
|
||||
AddTempoChange(false, tempoChange);
|
||||
}
|
||||
|
||||
StartingBPM.GetChild(0).GetComponent<TMP_Text>().text = GameManager.instance.Beatmap.bpm.ToString();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main))
|
||||
if (Timeline.instance.timelineState.tempoChange && !Conductor.instance.NotStopped())
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main))
|
||||
{
|
||||
AddTempoChange();
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (tempoTimelineObjs.FindAll(c => c.hovering == true).Count == 0)
|
||||
{
|
||||
AddTempoChange(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(StartingBPM, Input.mousePosition, Camera.main))
|
||||
{
|
||||
float increase = Input.mouseScrollDelta.y;
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
increase /= 100f;
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
increase *= 5f;
|
||||
|
||||
GameManager.instance.Beatmap.bpm += increase;
|
||||
StartingBPM.transform.GetChild(0).GetComponent<TMP_Text>().text = GameManager.instance.Beatmap.bpm.ToString();
|
||||
}
|
||||
|
||||
StartingBPM.GetComponent<Image>().enabled = true;
|
||||
StartingBPM.GetComponent<Button>().enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartingBPM.GetComponent<Image>().enabled = false;
|
||||
StartingBPM.GetComponent<Button>().enabled = false;
|
||||
StartingBPM.GetComponent<Button>().targetGraphic.color = Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddTempoChange()
|
||||
private void AddTempoChange(bool create, Beatmap.TempoChange tempoChange_ = null)
|
||||
{
|
||||
GameObject tempoChange = Instantiate(RefTempoChange.gameObject, this.transform);
|
||||
|
||||
|
@ -39,17 +77,29 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
tempoChange.transform.GetChild(2).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.TempoLayerCol.Hex2RGB();
|
||||
|
||||
tempoChange.SetActive(true);
|
||||
tempoChange.transform.position = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, tempoChange.transform.position.y);
|
||||
tempoChange.transform.localPosition = new Vector3(Starpelly.Mathp.Round2Nearest(tempoChange.transform.localPosition.x, 0.25f), tempoChange.transform.localPosition.y);
|
||||
|
||||
TempoTimelineObj tempoTimelineObj = tempoChange.AddComponent<TempoTimelineObj>();
|
||||
TempoTimelineObj tempoTimelineObj = tempoChange.GetComponent<TempoTimelineObj>();
|
||||
|
||||
Beatmap.TempoChange tempoC = new Beatmap.TempoChange();
|
||||
tempoC.beat = tempoChange.transform.localPosition.x;
|
||||
tempoC.tempo = GameManager.instance.Beatmap.bpm;
|
||||
if (create == true)
|
||||
{
|
||||
tempoChange.transform.position = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x + 0.08f, tempoChange.transform.position.y);
|
||||
tempoChange.transform.localPosition = new Vector3(Starpelly.Mathp.Round2Nearest(tempoChange.transform.localPosition.x, 0.25f), tempoChange.transform.localPosition.y);
|
||||
|
||||
tempoTimelineObj.tempoChange = tempoC;
|
||||
GameManager.instance.Beatmap.tempoChanges.Add(tempoC);
|
||||
Beatmap.TempoChange tempoC = new Beatmap.TempoChange();
|
||||
tempoC.beat = tempoChange.transform.localPosition.x;
|
||||
tempoC.tempo = GameManager.instance.Beatmap.bpm;
|
||||
|
||||
tempoTimelineObj.tempoChange = tempoC;
|
||||
GameManager.instance.Beatmap.tempoChanges.Add(tempoC);
|
||||
}
|
||||
else
|
||||
{
|
||||
tempoChange.transform.localPosition = new Vector3(tempoChange_.beat, tempoChange.transform.localPosition.y);
|
||||
|
||||
tempoTimelineObj.tempoChange = tempoChange_;
|
||||
}
|
||||
|
||||
tempoTimelineObjs.Add(tempoTimelineObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ using UnityEngine;
|
|||
|
||||
using TMPro;
|
||||
|
||||
using DG.Tweening;
|
||||
|
||||
namespace RhythmHeavenMania.Editor.Track
|
||||
{
|
||||
public class TempoTimelineObj : MonoBehaviour
|
||||
|
@ -11,9 +13,17 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
[Header("Components")]
|
||||
[SerializeField] private RectTransform rectTransform;
|
||||
[SerializeField] private TMP_Text tempoTXT;
|
||||
[SerializeField] private RectTransform raycastRect;
|
||||
|
||||
public Beatmap.TempoChange tempoChange;
|
||||
|
||||
private float startPosX;
|
||||
private bool moving = false;
|
||||
|
||||
public bool hovering;
|
||||
|
||||
private float lastPosX;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
|
@ -23,18 +33,63 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main))
|
||||
if (Timeline.instance.timelineState.tempoChange && !Conductor.instance.NotStopped())
|
||||
{
|
||||
float newTempo = Input.mouseScrollDelta.y;
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(raycastRect, Input.mousePosition, Camera.main))
|
||||
{
|
||||
float newTempo = Input.mouseScrollDelta.y;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
newTempo *= 5f;
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
newTempo /= 100f;
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
newTempo *= 5f;
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
newTempo /= 100f;
|
||||
|
||||
tempoChange.tempo += newTempo;
|
||||
tempoChange.tempo += newTempo;
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
startPosX = mousePos.x - transform.position.x;
|
||||
moving = true;
|
||||
lastPosX = transform.localPosition.x;
|
||||
}
|
||||
else if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
GameManager.instance.Beatmap.tempoChanges.Remove(tempoChange);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
hovering = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hovering = false;
|
||||
}
|
||||
|
||||
if (moving)
|
||||
{
|
||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
||||
transform.position = new Vector3(mousePos.x - startPosX, transform.position.y, 0);
|
||||
transform.localPosition = new Vector3(Mathf.Clamp(Starpelly.Mathp.Round2Nearest(transform.localPosition.x, 0.25f), 0, Mathf.Infinity), transform.localPosition.y);
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
if (transform.parent.GetComponent<TempoTimeline>().tempoTimelineObjs.Find(c => c.gameObject.transform.localPosition.x == this.transform.localPosition.x && c != this) != null)
|
||||
{
|
||||
transform.localPosition = new Vector3(lastPosX, transform.localPosition.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
tempoChange.beat = transform.localPosition.x;
|
||||
}
|
||||
|
||||
moving = false;
|
||||
lastPosX = transform.localPosition.x;
|
||||
}
|
||||
|
||||
UpdateTempo();
|
||||
}
|
||||
UpdateTempo();
|
||||
}
|
||||
|
||||
private void UpdateTempo()
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
[SerializeField] private TMP_Text SongBeat;
|
||||
[SerializeField] private TMP_Text SongPos;
|
||||
[SerializeField] private TMP_Text CurrentTempo;
|
||||
[SerializeField] private RectTransform StartingBPM;
|
||||
|
||||
[Header("Timeline Properties")]
|
||||
private float lastBeatPos = 0;
|
||||
|
@ -24,9 +23,42 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
public int LayerCount = 4;
|
||||
public bool metronomeEnabled;
|
||||
public bool resizable;
|
||||
private bool movingPlayback;
|
||||
public CurrentTimelineState timelineState = new CurrentTimelineState();
|
||||
|
||||
public class CurrentTimelineState
|
||||
{
|
||||
public bool selected;
|
||||
public bool tempoChange;
|
||||
public bool musicVolume;
|
||||
|
||||
public void SetState(bool selected, bool tempoChange, bool musicVolume)
|
||||
{
|
||||
if (Conductor.instance.NotStopped()) return;
|
||||
|
||||
this.selected = selected;
|
||||
this.tempoChange = tempoChange;
|
||||
this.musicVolume = musicVolume;
|
||||
|
||||
if (selected)
|
||||
instance.SelectionsBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
|
||||
else
|
||||
instance.SelectionsBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
if (tempoChange)
|
||||
instance.TempoChangeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
|
||||
else
|
||||
instance.TempoChangeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
if (musicVolume)
|
||||
instance.MusicVolumeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.white;
|
||||
else
|
||||
instance.MusicVolumeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Header("Timeline Components")]
|
||||
[SerializeField] private RectTransform TimelineSlider;
|
||||
[SerializeField] private RectTransform TimelineGridSelect;
|
||||
[SerializeField] private TMP_Text TimelinePlaybackBeat;
|
||||
[SerializeField] private RectTransform TimelineContent;
|
||||
[SerializeField] private RectTransform TimelineSongPosLineRef;
|
||||
|
@ -48,11 +80,6 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
|
||||
#region Initializers
|
||||
|
||||
public void UpdateLevelInfo()
|
||||
{
|
||||
StartingBPM.GetChild(0).GetComponent<TMP_Text>().text = GameManager.instance.Beatmap.bpm.ToString();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
instance = this;
|
||||
|
@ -116,6 +143,19 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
}
|
||||
});
|
||||
|
||||
SelectionsBTN.onClick.AddListener(delegate
|
||||
{
|
||||
timelineState.SetState(true, false, false);
|
||||
});
|
||||
TempoChangeBTN.onClick.AddListener(delegate
|
||||
{
|
||||
timelineState.SetState(false, true, false);
|
||||
});
|
||||
MusicVolumeBTN.onClick.AddListener(delegate
|
||||
{
|
||||
timelineState.SetState(false, false, true);
|
||||
});
|
||||
|
||||
Tooltip.AddTooltip(SongBeat.gameObject, "Current Beat");
|
||||
Tooltip.AddTooltip(SongPos.gameObject, "Current Time");
|
||||
Tooltip.AddTooltip(CurrentTempo.gameObject, "Current Tempo (BPM)");
|
||||
|
@ -134,7 +174,7 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
SetTimeButtonColors(true, false, false);
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
|
||||
UpdateLevelInfo();
|
||||
timelineState.SetState(true, false, false);
|
||||
}
|
||||
|
||||
public static string RandomID()
|
||||
|
@ -172,7 +212,16 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
}
|
||||
|
||||
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && CheckIfMouseInTimeline())
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && MouseInRectTransform(TimelineGridSelect))
|
||||
{
|
||||
movingPlayback = true;
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(1))
|
||||
{
|
||||
movingPlayback = false;
|
||||
}
|
||||
|
||||
if (movingPlayback)
|
||||
{
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
|
||||
TimelineSlider.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(lastMousePos.x + 0.12f, 0.25f), 0, Mathf.Infinity), TimelineSlider.transform.localPosition.y);
|
||||
|
@ -201,18 +250,6 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
TimelineContent.transform.localPosition = new Vector3(Mathf.Clamp(TimelineContent.transform.localPosition.x, Mathf.NegativeInfinity, 0), TimelineContent.transform.localPosition.y);
|
||||
|
||||
CurrentTempo.text = $" = {Conductor.instance.songBpm}";
|
||||
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(StartingBPM, Input.mousePosition, Camera.main))
|
||||
{
|
||||
float increase = Input.mouseScrollDelta.y;
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
increase /= 100f;
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
increase *= 5f;
|
||||
|
||||
GameManager.instance.Beatmap.bpm += increase;
|
||||
UpdateLevelInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private void SliderControl()
|
||||
|
@ -347,6 +384,11 @@ namespace RhythmHeavenMania.Editor.Track
|
|||
{
|
||||
return (this.gameObject.activeSelf && RectTransformUtility.RectangleContainsScreenPoint(TimelineContent.transform.parent.gameObject.GetComponent<RectTransform>(), Input.mousePosition, Camera.main));
|
||||
}
|
||||
|
||||
public bool MouseInRectTransform(RectTransform rectTransform)
|
||||
{
|
||||
return (rectTransform.gameObject.activeSelf && RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Functions
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"name": "Rhythm Heaven Mania Default Editor Theme",
|
||||
|
||||
"properties": {
|
||||
"TempoLayerCol": "f8f7ff",
|
||||
"TempoLayerCol": "6cbcc4",
|
||||
"MusicLayerCol": "a663cc",
|
||||
|
||||
"Layer1Col": "ef476f",
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"bpm":119.0,"entities":[{"beat":0.0,"track":0,"length":52.0,"datamodel":"karateman/bop"},{"beat":14.0,"track":3,"datamodel":"karateman/pot"},{"beat":22.0,"track":2,"datamodel":"karateman/pot"},{"beat":30.0,"track":1,"datamodel":"karateman/pot"},{"beat":38.0,"track":1,"length":2.0,"datamodel":"karateman/bulb"},{"beat":50.0,"track":1,"datamodel":"karateman/rock"},{"beat":56.0,"track":0,"datamodel":"karateman/bgfxon"},{"beat":58.0,"track":2,"datamodel":"karateman/pot"},{"beat":62.0,"track":0,"datamodel":"karateman/pot"},{"beat":66.0,"track":0,"datamodel":"karateman/pot"}]}
|
||||
{"bpm":119.0,"entities":[{"beat":0.0,"track":0,"length":52.0,"datamodel":"karateman/bop"},{"beat":14.0,"track":3,"datamodel":"karateman/pot"},{"beat":22.0,"track":2,"datamodel":"karateman/pot"},{"beat":30.0,"track":1,"datamodel":"karateman/pot"},{"beat":38.0,"track":1,"length":2.0,"datamodel":"karateman/bulb"},{"beat":50.0,"track":1,"datamodel":"karateman/rock"},{"beat":56.0,"track":0,"datamodel":"karateman/bgfxon"},{"beat":58.0,"track":2,"datamodel":"karateman/pot"},{"beat":62.0,"track":0,"datamodel":"karateman/pot"},{"beat":66.0,"track":0,"datamodel":"karateman/pot"},{"beat":154.0,"track":0,"length":2.0,"datamodel":"karateman/rock"}],"tempoChanges":[{"beat":136.0,"length":0.0,"tempo":150.0},{"beat":148.0,"length":0.0,"tempo":140.509811}]}
|
Loading…
Reference in a new issue