public override void OnSelectableMouseDrag()
    {
        // Move object
        if (bpm.tick != 0)
        {
            base.OnSelectableMouseDrag();
        }

        if (draggingInitialBpm != null && MSE.Input.KeyboardDevice.ctrlKeyBeingPressed && Input.GetMouseButton(1))
        {
            BPM previousBpm = SongObjectHelper.GetPreviousNonInclusive(bpm.song.bpms, bpm.tick);
            if (previousBpm != null && previousBpm.anchor == null)
            {
                float desiredWorldPos;
                if (editor.services.mouseMonitorSystem.world2DPosition != null && ((Vector2)editor.services.mouseMonitorSystem.world2DPosition).y < editor.mouseYMaxLimit.position.y)
                {
                    desiredWorldPos = ((Vector2)editor.services.mouseMonitorSystem.world2DPosition).y;
                }
                else
                {
                    desiredWorldPos = editor.mouseYMaxLimit.position.y;
                }

                float desiredTime = TickFunctions.WorldYPositionToTime(desiredWorldPos);
                if (desiredTime < previousBpm.time)
                {
                    desiredTime = previousBpm.time;
                }

                BPM nextBpm = SongObjectHelper.GetNextNonInclusive(bpm.song.bpms, bpm.tick);
                if (nextBpm != null && nextBpm.anchor != null && desiredTime >= nextBpm.time)
                {
                    desiredTime = nextBpm.time - 0.01f;
                }

                double disToBpm    = TickFunctions.DisToBpm(previousBpm.tick, bpm.tick, desiredTime - previousBpm.time, bpm.song.resolution);
                uint   newBpmValue = (uint)Mathf.Ceil((float)disToBpm * 1000.0f);
                if (newBpmValue > 0)
                {
                    if (hasPushed)
                    {
                        editor.commandStack.Pop();
                    }

                    editor.commandStack.Push(new SongEditModify <BPM>(previousBpm, new BPM(previousBpm.tick, newBpmValue, previousBpm.anchor)));
                    hasPushed = true;
                }
            }
        }
    }
Example #2
0
    public override void OnSelectableMouseDrag()
    {
        // Move object
        if (bpm.tick != 0)
        {
            base.OnSelectableMouseDrag();
        }

        if (draggingInitialBpm != null && ShortcutInput.modifierInput && Input.GetMouseButton(1))
        {
            BPM previousBpm = SongObjectHelper.GetPreviousNonInclusive(bpm.song.bpms, bpm.tick);
            if (previousBpm != null && previousBpm.anchor == null)
            {
                float desiredWorldPos;
                if (Mouse.world2DPosition != null && ((Vector2)Mouse.world2DPosition).y < editor.mouseYMaxLimit.position.y)
                {
                    desiredWorldPos = ((Vector2)Mouse.world2DPosition).y;
                }
                else
                {
                    desiredWorldPos = editor.mouseYMaxLimit.position.y;
                }

                float desiredTime = TickFunctions.WorldYPositionToTime(desiredWorldPos);
                if (desiredTime < previousBpm.time)
                {
                    desiredTime = previousBpm.time;
                }

                BPM nextBpm = SongObjectHelper.GetNextNonInclusive(bpm.song.bpms, bpm.tick);
                if (nextBpm != null && nextBpm.anchor != null && desiredTime >= nextBpm.time)
                {
                    desiredTime = nextBpm.time - 0.01f;
                }

                uint newBpmValue = (uint)(Mathf.Ceil((float)TickFunctions.DisToBpm(previousBpm.tick, bpm.tick, desiredTime - previousBpm.time, bpm.song.resolution)) * 1000);
                if (newBpmValue > 0)
                {
                    previousBpm.value = newBpmValue;
                }

                editor.songObjectPoolManager.SetAllPoolsDirty();
                ChartEditor.isDirty = true;
                editor.currentSong.UpdateCache();
                editor.FixUpBPMAnchors();
            }
        }
    }