void TailDrag() { uint snappedChartPos; if (Mouse.world2DPosition != null && ((Vector2)Mouse.world2DPosition).y < editor.mouseYMaxLimit.position.y) { snappedChartPos = Snapable.TickToSnappedTick(starpower.song.WorldYPositionToTick(((Vector2)Mouse.world2DPosition).y), GameSettings.step, starpower.song.resolution); } else { snappedChartPos = Snapable.TickToSnappedTick(starpower.song.WorldYPositionToTick(editor.mouseYMaxLimit.position.y), GameSettings.step, starpower.song.resolution); } uint newLength = starpower.GetCappedLengthForPos(snappedChartPos); if (newLength != starpower.length) { if (wantPop) { editor.commandStack.Pop(); } editor.commandStack.Push(new SongEditModify <Starpower>(starpower, new Starpower(starpower.tick, newLength))); wantPop = true; } }
void TailDrag() { uint snappedChartPos; if (editor.services.mouseMonitorSystem.world2DPosition != null && ((Vector2)editor.services.mouseMonitorSystem.world2DPosition).y < editor.mouseYMaxLimit.position.y) { snappedChartPos = Snapable.TickToSnappedTick(starpower.song.WorldYPositionToTick(((Vector2)editor.services.mouseMonitorSystem.world2DPosition).y), Globals.gameSettings.step, starpower.song); } else { snappedChartPos = Snapable.TickToSnappedTick(starpower.song.WorldYPositionToTick(editor.mouseYMaxLimit.position.y), Globals.gameSettings.step, starpower.song); } // Cap to within the range of the song snappedChartPos = (uint)Mathf.Min(editor.maxPos, snappedChartPos); uint newLength = starpower.GetCappedLengthForPos(snappedChartPos); if (newLength != starpower.length) { if (wantPop) { editor.commandStack.Pop(); } editor.commandStack.Push(new SongEditModify <Starpower>(starpower, new Starpower(starpower.tick, newLength))); wantPop = true; } }
uint GetSnappedSustainPos() { uint snappedChartPos; Note note = nCon.note; if (Mouse.world2DPosition != null && ((Vector2)Mouse.world2DPosition).y < editor.mouseYMaxLimit.position.y) { snappedChartPos = Snapable.TickToSnappedTick(nCon.note.song.WorldYPositionToTick(((Vector2)Mouse.world2DPosition).y), GameSettings.step, note.song.resolution); } else { snappedChartPos = Snapable.TickToSnappedTick(note.song.WorldYPositionToTick(editor.mouseYMaxLimit.position.y), GameSettings.step, note.song.resolution); } return(snappedChartPos); }
uint GetSnappedSustainPos() { uint snappedChartPos; Note note = nCon.note; if (editor.services.mouseMonitorSystem.world2DPosition != null && ((Vector2)editor.services.mouseMonitorSystem.world2DPosition).y < editor.mouseYMaxLimit.position.y) { snappedChartPos = Snapable.TickToSnappedTick(nCon.note.song.WorldYPositionToTick(((Vector2)editor.services.mouseMonitorSystem.world2DPosition).y), GameSettings.step, note.song); } else { snappedChartPos = Snapable.TickToSnappedTick(note.song.WorldYPositionToTick(editor.mouseYMaxLimit.position.y), GameSettings.step, note.song); } // Cap to within the range of the song snappedChartPos = (uint)Mathf.Min(editor.maxPos, snappedChartPos); return(snappedChartPos); }
void TailDrag() { ChartEditor.isDirty = true; uint snappedChartPos; if (Mouse.world2DPosition != null && ((Vector2)Mouse.world2DPosition).y < editor.mouseYMaxLimit.position.y) { snappedChartPos = Snapable.TickToSnappedTick(starpower.song.WorldYPositionToTick(((Vector2)Mouse.world2DPosition).y), GameSettings.step, starpower.song.resolution); } else { snappedChartPos = Snapable.TickToSnappedTick(starpower.song.WorldYPositionToTick(editor.mouseYMaxLimit.position.y), GameSettings.step, starpower.song.resolution); } uint max = starpower.length; starpower.SetLengthByPos(snappedChartPos); if (starpower.length > max) { max = starpower.length; } int start, length; var notes = starpower.chart.notes; SongObjectHelper.GetRange(notes, starpower.tick, starpower.tick + max, out start, out length); for (int i = start; i < start + length; ++i) { if (notes[i].controller) { notes[i].controller.SetDirty(); } } }
// Update is called once per frame void LateUpdate() { if (!ShortcutInput.GetInput(Shortcut.SelectAllSection) || editor.currentSong.sections.Count <= 0) { sectionHighlightRealOriginIndex = SongObjectHelper.GetIndexOfPrevious(editor.currentSong.sections, editor.currentTickPos); sectionHighlightCurrentIndex = sectionHighlightRealOriginIndex; } if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { lastMouseDownPos = Input.mousePosition; } if (Globals.applicationMode == Globals.ApplicationMode.Editor) { if (scrollDelta == 0 && focused) { scrollDelta = Input.mouseScrollDelta.y; } if (Services.IsInDropDown) { scrollDelta = 0; } // Position changes scroll bar value if (scrollDelta != 0 || transform.position != prevPos || Services.HasScreenResized) { if (ShortcutInput.GetInput(Shortcut.SectionJumpMouseScroll) && editor.currentSong.sections.Count > 0) { SectionJump(scrollDelta); RefreshSectionHighlight(); } else { // Mouse scroll movement mouseScrollMovePosition.x = transform.position.x; mouseScrollMovePosition.y = transform.position.y + (scrollDelta * mouseScrollSensitivity); mouseScrollMovePosition.z = transform.position.z; transform.position = mouseScrollMovePosition; explicitChartPos = null; } if (transform.position.y < initPos.y) { transform.position = initPos; } if (Services.HasScreenResized) { StartCoroutine(resolutionChangePosHold()); } UpdateTimelineHandleBasedPos(); } else if (ShortcutInput.GetInputDown(Shortcut.SectionJumpPositive) && editor.currentSong.sections.Count > 0) { SectionJump(1); UpdateTimelineHandleBasedPos(); RefreshSectionHighlight(); } else if (ShortcutInput.GetInputDown(Shortcut.SectionJumpNegative) && editor.currentSong.sections.Count > 0) { SectionJump(-1); UpdateTimelineHandleBasedPos(); RefreshSectionHighlight(); } else if (ShortcutInput.GetGroupInput(arrowKeyShortcutGroup)) { // Arrow key controls uint currentPos; if (explicitChartPos != null) { currentPos = (uint)explicitChartPos; } else { currentPos = editor.currentTickPos; } if (arrowMoveTimer == 0 || (arrowMoveTimer > ARROW_INIT_DELAY_TIME && Time.realtimeSinceStartup > lastMoveTime + ARROW_HOLD_MOVE_ITERATION_TIME)) { uint snappedPos = currentPos; // Navigate to snapped pos ahead or behind if (ShortcutInput.GetInput(Shortcut.MoveStepPositive)) { snappedPos = Snapable.ChartIncrementStep(currentPos, GameSettings.step, editor.currentSong.resolution); } else if (ShortcutInput.GetInput(Shortcut.MoveStepNegative)) { snappedPos = Snapable.ChartDecrementStep(currentPos, GameSettings.step, editor.currentSong.resolution); } else if (ShortcutInput.GetInput(Shortcut.MoveMeasurePositive)) { snappedPos = Snapable.TickToSnappedTick(currentPos + (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong.resolution); } // Page Down else if (ShortcutInput.GetInput(Shortcut.MoveMeasureNegative)) { snappedPos = Snapable.TickToSnappedTick(currentPos - (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong.resolution); } if (editor.currentSong.TickToTime(snappedPos, editor.currentSong.resolution) <= editor.currentSong.length) { SetPosition(snappedPos); } lastMoveTime = Time.realtimeSinceStartup; } UpdateTimelineHandleBasedPos(); } // else check mouse range else if (Toolpane.mouseDownInArea && (globals.services.InToolArea && (Input.GetMouseButton(0) || Input.GetMouseButton(1)) && Input.mousePosition != lastMouseDownPos)) { if (!Toolpane.menuCancel && UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == null && Input.mousePosition.y > Camera.main.WorldToScreenPoint(editor.mouseYMaxLimit.position).y) { // Autoscroll transform.position = new Vector3(transform.position.x, transform.position.y + autoscrollSpeed * Time.deltaTime, transform.position.z); UpdateTimelineHandleBasedPos(); } else { UpdatePosBasedTimelineHandle(); } } // Scroll bar value changes position else { UpdatePosBasedTimelineHandle(); } } else if (Globals.applicationMode == Globals.ApplicationMode.Playing) { PlayingMovement(); // Update timeline handle UpdateTimelineHandleBasedPos(); if (timeline.handlePos >= 1) { editor.Stop(); } } if (Globals.applicationMode != Globals.ApplicationMode.Playing) { lastUpdatedRealTime = Time.realtimeSinceStartup; } prevPos = transform.position; }
public uint WorldPositionToSnappedTick(float worldYPos, int step) { uint chartPos = WorldYPositionToTick(worldYPos); return(Snapable.TickToSnappedTick(chartPos, step, this)); }
// Update is called once per frame void LateUpdate() { if (!MSChartEditorInput.GetInput(MSChartEditorInputActions.SelectAllSection) || editor.currentSong.sections.Count <= 0) { sectionHighlightRealOriginIndex = SongObjectHelper.GetIndexOfPrevious(editor.currentSong.sections, editor.currentTickPos); sectionHighlightCurrentIndex = sectionHighlightRealOriginIndex; } if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { lastMouseDownPos = Input.mousePosition; } if (editor.currentState == ChartEditor.State.Editor) { Vector2 middleClickDragPercentageDelta = GetMiddleClickDragPercentageDelta(); if (scrollDelta == 0 && focused) { scrollDelta = Input.mouseScrollDelta.y; } if (middleClickDragPercentageDelta != Vector2.zero) { float sign = Mathf.Sign(middleClickDragPercentageDelta.y); Texture2D cursorTexture = sign >= 0 ? dragCursorPositive : dragCursorNegative; Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.ForceSoftware); scrollDelta = middleClickDragPercentageDelta.y * c_middleClickMouseDragSensitivity; } if (Services.IsInDropDown) { scrollDelta = 0; } // Position changes scroll bar value if (scrollDelta != 0 || transform.position != prevPos || Services.HasScreenResized) { if (MSChartEditorInput.GetInput(MSChartEditorInputActions.SectionJumpMouseScroll) && editor.currentSong.sections.Count > 0) { SectionJump(scrollDelta); RefreshSectionHighlight(); } else { // Mouse scroll movement mouseScrollMovePosition.x = transform.position.x; mouseScrollMovePosition.y = transform.position.y + (scrollDelta * c_mouseScrollSensitivity); mouseScrollMovePosition.z = transform.position.z; transform.position = mouseScrollMovePosition; explicitChartPos = null; } if (transform.position.y < initPos.y) { transform.position = initPos; } if (Services.HasScreenResized) { StartCoroutine(resolutionChangePosHold()); } UpdateTimelineHandleBasedPos(); } else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.SectionJumpPositive) && editor.currentSong.sections.Count > 0) { SectionJump(1); UpdateTimelineHandleBasedPos(); RefreshSectionHighlight(); } else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.SectionJumpNegative) && editor.currentSong.sections.Count > 0) { SectionJump(-1); UpdateTimelineHandleBasedPos(); RefreshSectionHighlight(); } else if (MSChartEditorInput.GetGroupInput(arrowKeyShortcutGroup)) { // Arrow key controls uint currentPos; if (explicitChartPos != null) { currentPos = (uint)explicitChartPos; } else { currentPos = editor.currentTickPos; } if (arrowMoveTimer == 0 || (arrowMoveTimer > ARROW_INIT_DELAY_TIME && Time.realtimeSinceStartup > lastMoveTime + ARROW_HOLD_MOVE_ITERATION_TIME)) { uint snappedPos = currentPos; // Navigate to snapped pos ahead or behind if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveStepPositive)) { snappedPos = Snapable.ChartIncrementStep(currentPos, Globals.gameSettings.step, editor.currentSong); if (snappedPos == currentPos) // This can happen on really weird custom step values { ++snappedPos; } } else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveStepNegative)) { snappedPos = Snapable.ChartDecrementStep(currentPos, Globals.gameSettings.step, editor.currentSong); if (snappedPos == currentPos && snappedPos > 0) // This can happen on really weird custom step values { --snappedPos; } } else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasurePositive)) { snappedPos = Snapable.TickToSnappedTick(currentPos + (uint)(editor.currentSong.resolution * 4), Globals.gameSettings.step, editor.currentSong); } // Page Down else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasureNegative)) { snappedPos = Snapable.TickToSnappedTick(currentPos - (uint)(editor.currentSong.resolution * 4), Globals.gameSettings.step, editor.currentSong); } if (editor.currentSong.TickToTime(snappedPos, editor.currentSong.resolution) <= editor.currentSongLength) { SetPosition(snappedPos); } lastMoveTime = Time.realtimeSinceStartup; } UpdateTimelineHandleBasedPos(); } // else check mouse range else if (globals.services.InToolArea && (Input.GetMouseButton(0) || Input.GetMouseButton(1)) && Input.mousePosition != lastMouseDownPos) { if (UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == null && Input.mousePosition.y > Camera.main.WorldToScreenPoint(editor.mouseYMaxLimit.position).y) { // Autoscroll, dragging out notes/sustains etc transform.position = new Vector3(transform.position.x, transform.position.y + autoscrollSpeed * Time.deltaTime, transform.position.z); UpdateTimelineHandleBasedPos(); } else { UpdatePosBasedTimelineHandle(); } } // Scroll bar value changes position else { UpdatePosBasedTimelineHandle(); } } else if (editor.currentState == ChartEditor.State.Playing) { PlayingMovement(); // Update timeline handle UpdateTimelineHandleBasedPos(); if (timeline.handlePos >= 1) { editor.Stop(); } } if (editor.currentState != ChartEditor.State.Playing) { lastUpdatedRealTime = Time.realtimeSinceStartup; } prevPos = transform.position; }
public static uint WorldPositionToSnappedTick(this Song song, float worldYPos, int step) { uint chartPos = song.WorldYPositionToTick(worldYPos); return(Snapable.TickToSnappedTick(chartPos, step, song)); }