예제 #1
0
    protected override void Update()
    {
        base.Update();
        if (currentBPM != null)
        {
            // Update inspector information
            positionText.text = "Position: " + currentBPM.tick.ToString();
            if (!Services.IsTyping)
            {
                UpdateBPMInputFieldText();
            }

            anchorToggle.isOn = currentBPM.anchor != null;

            bool interactable = !IsNextBPMAnAnchor();
            foreach (Selectable ui in AnchorAheadDisable)
            {
                ui.interactable = interactable;
            }
        }

        editor.currentSong.UpdateCache();

        if (incrementalTimer > AUTO_INCREMENT_WAIT_TIME)
        {
            autoIncrementTimer += Time.deltaTime;
        }
        else
        {
            autoIncrementTimer = 0;
        }

        if (!(ShortcutInput.GetInput(Shortcut.BpmIncrease) && ShortcutInput.GetInput(Shortcut.BpmDecrease)))    // Can't hit both at the same time
        {
            if (!Services.IsTyping && !Globals.modifierInputActive)
            {
                if (ShortcutInput.GetInputDown(Shortcut.BpmDecrease) && decrement.interactable)
                {
                    lastAutoVal = currentBPM.value;
                    decrement.onClick.Invoke();
                }
                else if (ShortcutInput.GetInputDown(Shortcut.BpmIncrease) && increment.interactable)
                {
                    lastAutoVal = currentBPM.value;
                    increment.onClick.Invoke();
                }

                // Adjust to time rather than framerate
                if (incrementalTimer > AUTO_INCREMENT_WAIT_TIME && autoIncrementTimer > AUTO_INCREMENT_RATE)
                {
                    if (ShortcutInput.GetInput(Shortcut.BpmDecrease) && decrement.interactable)
                    {
                        decrement.onClick.Invoke();
                    }
                    else if (ShortcutInput.GetInput(Shortcut.BpmIncrease) && increment.interactable)
                    {
                        increment.onClick.Invoke();
                    }

                    autoIncrementTimer = 0;
                }

                //
                if (ShortcutInput.GetInput(Shortcut.BpmIncrease) || ShortcutInput.GetInput(Shortcut.BpmDecrease))
                {
                    incrementalTimer   += Time.deltaTime;
                    ChartEditor.isDirty = true;
                }
            }
            else
            {
                incrementalTimer = 0;
            }

            // Handle key release, add in action history
            if ((ShortcutInput.GetInputUp(Shortcut.BpmIncrease) || ShortcutInput.GetInputUp(Shortcut.BpmDecrease)) && lastAutoVal != null)
            {
                incrementalTimer = 0;
                editor.actionHistory.Insert(new ActionHistory.Modify(new BPM(currentSongObject.tick, (uint)lastAutoVal), currentSongObject));
                if (anchorAdjustment != null)
                {
                    editor.actionHistory.Insert(new ActionHistory.Modify(anchorAdjustmentOriginalValue, anchorAdjustment));
                    anchorAdjustment = null;
                    anchorAdjustmentOriginalValue = null;
                }

                ChartEditor.isDirty = true;
                lastAutoVal         = null;// currentBPM.value;
            }
        }

        Controls();

        prevBPM = currentBPM;
    }