blargh
This commit is contained in:
parent
f3c5e7b3e6
commit
bb640c96a5
|
@ -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)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
timeline.SetSnap(1f / CommonDenominators[currentCommon]);
|
||||
if (CommonDenominators[currentCommon] < 0)
|
||||
{
|
||||
timeline.SetSnap(1f / 65536f);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeline.SetSnap(1f / CommonDenominators[currentCommon]);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
snapText.text = $"1/{CommonDenominators[currentCommon]}";
|
||||
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);
|
||||
|
@ -448,7 +489,14 @@ namespace HeavenStudio.Editor.Track
|
|||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
MetronomeToggle();
|
||||
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