mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-08 18:55:07 +00:00
Metronome Subdivision and More Snapping Options BUT for real this time™️ (#957)
* blargh * oopsie lol
This commit is contained in:
parent
080eb6d3c4
commit
38439f4722
6 changed files with 222 additions and 83 deletions
|
@ -4452,8 +4452,8 @@ GameObject:
|
|||
- component: {fileID: 129013733}
|
||||
- component: {fileID: 129013736}
|
||||
- component: {fileID: 129013735}
|
||||
- component: {fileID: 129013734}
|
||||
- component: {fileID: 129013737}
|
||||
- component: {fileID: 129013738}
|
||||
m_Layer: 5
|
||||
m_Name: MetronomeBTN
|
||||
m_TagString: Untagged
|
||||
|
@ -4484,62 +4484,6 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 32, y: 32}
|
||||
m_Pivot: {x: 1, y: 0.5}
|
||||
--- !u!114 &129013734
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 129013732}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 0
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.7924528, g: 0.7924528, b: 0.7924528, a: 1}
|
||||
m_PressedColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.05
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 129013735}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1861169747}
|
||||
m_TargetAssemblyTypeName: HeavenStudio.Editor.Track.Timeline, Assembly-CSharp
|
||||
m_MethodName: MetronomeToggle
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &129013735
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -4591,6 +4535,56 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
TooltipText: Metronome <color=#adadad>[M]</color>
|
||||
--- !u!114 &129013738
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 129013732}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b6238d133d620234fbd17867a344bbe4, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 0
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.7921569, g: 0.7921569, b: 0.7921569, a: 1}
|
||||
m_PressedColor: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.05
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 129013735}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
onRightClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
isHovering: 0
|
||||
isHolding: 0
|
||||
wasHolding: 0
|
||||
--- !u!1 &143407410
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -25979,7 +25973,7 @@ MonoBehaviour:
|
|||
m_HandleRect: {fileID: 1589389271}
|
||||
m_Direction: 2
|
||||
m_Value: 1
|
||||
m_Size: 0.9992818
|
||||
m_Size: 1
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
|
@ -31856,7 +31850,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 1, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 274.53052}
|
||||
m_AnchoredPosition: {x: 0, y: 113.102036}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!222 &1154875945
|
||||
|
@ -42004,8 +41998,8 @@ MonoBehaviour:
|
|||
m_TargetGraphic: {fileID: 1220118245}
|
||||
m_HandleRect: {fileID: 1220118244}
|
||||
m_Direction: 2
|
||||
m_Value: 1
|
||||
m_Size: 1
|
||||
m_Value: 1.0000002
|
||||
m_Size: 0.5712372
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
|
@ -47289,7 +47283,7 @@ MonoBehaviour:
|
|||
PlayBTN: {fileID: 1345846031}
|
||||
PauseBTN: {fileID: 9435782}
|
||||
StopBTN: {fileID: 1783491359}
|
||||
MetronomeBTN: {fileID: 129013734}
|
||||
MetronomeBTN: {fileID: 129013738}
|
||||
AutoplayBTN: {fileID: 121871281}
|
||||
SelectionsBTN: {fileID: 270008766}
|
||||
TempoChangeBTN: {fileID: 456434811}
|
||||
|
|
|
@ -81,7 +81,8 @@ namespace HeavenStudio
|
|||
public bool isPaused;
|
||||
|
||||
// Metronome tick sound enabled
|
||||
public bool metronome = false;
|
||||
public int metronome = 0;
|
||||
public bool metronomeActive = false;
|
||||
Util.MultiSound metronomeSound;
|
||||
private int _metronomeTally = 0;
|
||||
|
||||
|
@ -442,13 +443,30 @@ namespace HeavenStudio
|
|||
{
|
||||
if (songPositionInBeatsAsDouble >= Math.Ceiling(startBeat) + _metronomeTally)
|
||||
{
|
||||
// if (metronome) metronomeSound = Util.SoundByte.PlayOneShot("metronome", Math.Ceiling(startBeat) + _metronomeTally);
|
||||
if (metronome)
|
||||
if (metronomeActive)
|
||||
{
|
||||
switch (metronome)
|
||||
{
|
||||
case 0:
|
||||
metronomeSound = Util.MultiSound.Play(new List<Util.MultiSound.Sound> {
|
||||
new Util.MultiSound.Sound("metronome", Math.Ceiling(startBeat) + _metronomeTally),
|
||||
}, false, true);
|
||||
break;
|
||||
case 1:
|
||||
metronomeSound = Util.MultiSound.Play(new List<Util.MultiSound.Sound> {
|
||||
new Util.MultiSound.Sound("metronome", Math.Ceiling(startBeat) + _metronomeTally),
|
||||
new Util.MultiSound.Sound("metronome", Math.Ceiling(startBeat) + _metronomeTally + 0.5, 1.5f, 0.5f)
|
||||
}, false, true);
|
||||
break;
|
||||
case 2:
|
||||
metronomeSound = Util.MultiSound.Play(new List<Util.MultiSound.Sound> {
|
||||
new Util.MultiSound.Sound("metronome", Math.Ceiling(startBeat) + _metronomeTally),
|
||||
new Util.MultiSound.Sound("metronome", Math.Ceiling(startBeat) + _metronomeTally + 0.25, 2f, 0.3f),
|
||||
new Util.MultiSound.Sound("metronome", Math.Ceiling(startBeat) + _metronomeTally + 0.5, 1.5f, 0.5f),
|
||||
new Util.MultiSound.Sound("metronome", Math.Ceiling(startBeat) + _metronomeTally + 0.75, 2f, 0.3f)
|
||||
}, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_metronomeTally++;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace HeavenStudio.Editor
|
|||
|
||||
private Timeline timeline;
|
||||
|
||||
private static float[] CommonDenominators = { 1, 2, 3, 4, 6, 8, 12, 16 };
|
||||
private static float[] CommonDenominators = { 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, -1 };
|
||||
private int currentCommon = 3;
|
||||
private void Start()
|
||||
{
|
||||
|
@ -45,12 +45,26 @@ namespace HeavenStudio.Editor
|
|||
currentCommon = CommonDenominators.Length - 1;
|
||||
}
|
||||
|
||||
if (CommonDenominators[currentCommon] < 0)
|
||||
{
|
||||
timeline.SetSnap(1f / 65536f);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeline.SetSnap(1f / CommonDenominators[currentCommon]);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (CommonDenominators[currentCommon] < 0)
|
||||
{
|
||||
snapText.text = "Free";
|
||||
}
|
||||
else
|
||||
{
|
||||
snapText.text = $"1/{CommonDenominators[currentCommon]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -172,7 +172,7 @@ namespace HeavenStudio.Editor.Track
|
|||
public Button PlayBTN;
|
||||
public Button PauseBTN;
|
||||
public Button StopBTN;
|
||||
public Button MetronomeBTN;
|
||||
public UIButton MetronomeBTN;
|
||||
public Button AutoplayBTN;
|
||||
public Button SelectionsBTN;
|
||||
public Button TempoChangeBTN;
|
||||
|
@ -268,10 +268,18 @@ namespace HeavenStudio.Editor.Track
|
|||
{
|
||||
timelineState.SetState(CurrentTimelineState.State.ChartSection);
|
||||
});
|
||||
MetronomeBTN.onClick.AddListener(delegate
|
||||
{
|
||||
MetronomeToggle();
|
||||
});
|
||||
MetronomeBTN.onRightClick.AddListener(delegate
|
||||
{
|
||||
MetronomeCycle();
|
||||
});
|
||||
|
||||
SetTimeButtonColors(true, false, false);
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color = Color.gray;
|
||||
MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color = "009FC6".Hex2RGB();
|
||||
MetronomeBTN.transform.GetChild(2).GetComponent<Image>().color = Color.gray;
|
||||
|
||||
timelineState.SetState(CurrentTimelineState.State.Selection);
|
||||
|
@ -342,19 +350,52 @@ namespace HeavenStudio.Editor.Track
|
|||
|
||||
public void MetronomeToggle()
|
||||
{
|
||||
if (!Conductor.instance.metronome)
|
||||
Conductor.instance.metronomeActive = !Conductor.instance.metronomeActive;
|
||||
if (Conductor.instance.metronomeActive)
|
||||
{
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = "009FC6".Hex2RGB();
|
||||
MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color = "009FC6".Hex2RGB();
|
||||
MetronomeBTN.transform.GetChild(2).GetComponent<Image>().color = "009FC6".Hex2RGB();
|
||||
Conductor.instance.metronome = true;
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color;
|
||||
MetronomeBTN.transform.GetChild(2).GetComponent<Image>().color = MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color;
|
||||
}
|
||||
else
|
||||
{
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color = Color.gray;
|
||||
MetronomeBTN.transform.GetChild(2).GetComponent<Image>().color = Color.gray;
|
||||
Conductor.instance.metronome = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void MetronomeCycle()
|
||||
{
|
||||
Conductor.instance.metronome++;
|
||||
Conductor.instance.metronome %= 3;
|
||||
|
||||
switch (Conductor.instance.metronome)
|
||||
{
|
||||
case 0:
|
||||
MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color = "009FC6".Hex2RGB();
|
||||
if (Conductor.instance.metronomeActive)
|
||||
{
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = "009FC6".Hex2RGB();
|
||||
MetronomeBTN.transform.GetChild(2).GetComponent<Image>().color = "009FC6".Hex2RGB();
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color = "DB7B04".Hex2RGB();
|
||||
if (Conductor.instance.metronomeActive)
|
||||
{
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = "DB7B04".Hex2RGB();
|
||||
MetronomeBTN.transform.GetChild(2).GetComponent<Image>().color = "DB7B04".Hex2RGB();
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
MetronomeBTN.transform.GetChild(1).GetComponent<Image>().color = "3AC211".Hex2RGB();
|
||||
if (Conductor.instance.metronomeActive)
|
||||
{
|
||||
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = "3AC211".Hex2RGB();
|
||||
MetronomeBTN.transform.GetChild(2).GetComponent<Image>().color = "3AC211".Hex2RGB();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,7 +445,7 @@ namespace HeavenStudio.Editor.Track
|
|||
{
|
||||
RectTransform rectTransform = MetronomeBTN.transform.GetChild(1).GetComponent<RectTransform>();
|
||||
float rot = 0f;
|
||||
if (cond.metronome)
|
||||
if (cond.metronomeActive)
|
||||
{
|
||||
int startBeat = (int)Math.Floor(cond.songPositionInBeats - 0.5);
|
||||
float nm = cond.GetLoopPositionFromBeat(0.5f, 1f, ignoreSwing: false);
|
||||
|
@ -447,9 +488,16 @@ namespace HeavenStudio.Editor.Track
|
|||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
MetronomeCycle();
|
||||
}
|
||||
else
|
||||
{
|
||||
MetronomeToggle();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1))
|
||||
{
|
||||
|
|
54
Assets/Scripts/UI/UIButton.cs
Normal file
54
Assets/Scripts/UI/UIButton.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UI.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// This is a custom button class that inherits from the default button. This allows us to have seperate events for left and right click, utilising all of the handy features of Button.
|
||||
/// </summary>
|
||||
|
||||
public class UIButton : Button, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public UnityEngine.Events.UnityEvent onRightClick = new UnityEngine.Events.UnityEvent();
|
||||
public override void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.button == PointerEventData.InputButton.Left)
|
||||
{
|
||||
// Invoke the left click event
|
||||
base.OnPointerClick(eventData);
|
||||
}
|
||||
else if (eventData.button == PointerEventData.InputButton.Right)
|
||||
{
|
||||
// Invoke the right click event
|
||||
onRightClick.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public bool isHovering = false;
|
||||
public bool isHolding = false;
|
||||
public bool wasHolding = false;
|
||||
|
||||
public override void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
isHovering = true;
|
||||
base.OnPointerEnter(eventData);
|
||||
}
|
||||
|
||||
public override void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
isHovering = false;
|
||||
base.OnPointerExit(eventData);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Input.GetMouseButton(1) && isHovering) isHolding = true;
|
||||
if (!Input.GetMouseButton(1)) isHolding = false;
|
||||
|
||||
if (isHolding) DoStateTransition(Button.SelectionState.Pressed, false);
|
||||
if (isHolding != wasHolding) DoStateTransition(currentSelectionState, false);
|
||||
|
||||
wasHolding = isHolding;
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/UIButton.cs.meta
Normal file
11
Assets/Scripts/UI/UIButton.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b6238d133d620234fbd17867a344bbe4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue