protected override void Update() { base.Update(); if (Input.GetMouseButton(0)) { GameObject currentMouseHover = editor.services.mouseMonitorSystem.currentSelectableUnderMouse; if (currentMouseHover) { SongObjectController soController = currentMouseHover.GetComponent <SongObjectController>(); if (soController && soController.GetSongObject() != null) // Dunno why song object would ever be null, but may as well be safe { SongObject songObject = soController.GetSongObject(); if (MSChartEditorInput.GetInput(MSChartEditorInputActions.ChordSelect) && songObject.classID == (int)SongObject.ID.Note) { foreach (Note note in ((Note)songObject).chord) { dragEraseHistory.Add(note); } } else if ((songObject.classID != (int)SongObject.ID.BPM && songObject.classID != (int)SongObject.ID.TimeSignature) || songObject.tick != 0) { dragEraseHistory.Add(songObject); } ExecuteCurrentDeletes(); } } } if (Input.GetMouseButtonUp(0)) { dragEraseHistory.Clear(); } }
public override void OnSelectableMouseDrag() { // Move note if (moveCheck) { if (MSChartEditorInput.GetInput(MSChartEditorInputActions.ChordSelect)) { Note[] chordNotes = note.GetChord(); editor.groupMove.StartMoveAction(chordNotes, 0); foreach (Note chordNote in chordNotes) { chordNote.Delete(); } } else { //base.OnSelectableMouseDrag(); } } else { sustain.OnSelectableMouseDrag(); } }
public static bool GetFretInput(Note.GuitarFret fret) { switch (fret) { case Note.GuitarFret.Green: return(MSChartEditorInput.GetInput(MSChartEditorInputActions.GuitarFretGreen)); case Note.GuitarFret.Red: return(MSChartEditorInput.GetInput(MSChartEditorInputActions.GuitarFretRed)); case Note.GuitarFret.Yellow: return(MSChartEditorInput.GetInput(MSChartEditorInputActions.GuitarFretYellow)); case Note.GuitarFret.Blue: return(MSChartEditorInput.GetInput(MSChartEditorInputActions.GuitarFretBlue)); case Note.GuitarFret.Orange: return(MSChartEditorInput.GetInput(MSChartEditorInputActions.GuitarFretOrange)); case Note.GuitarFret.Open: return(false); default: Debug.LogError("Unhandled note type for guitar input: " + fret); break; } return(false); }
void Controls() { if (!(MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmIncrease) && MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmDecrease))) // Can't hit both at the same time { if (!Services.IsTyping && !Globals.modifierInputActive) { if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.BpmDecrease) && decrement.interactable) { uint newValue = GetValueForDecrement(); SetBpmValue(newValue); } else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.BpmIncrease) && increment.interactable) { uint newValue = GetValueForIncrement(); SetBpmValue(newValue); } // Adjust to time rather than framerate if (incrementInputHoldTime > AUTO_INCREMENT_WAIT_TIME && autoIncrementTimer > AUTO_INCREMENT_RATE) { if (MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmDecrease) && decrement.interactable) { uint newValue = GetValueForDecrement(); SetBpmValue(newValue, true); } else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmIncrease) && increment.interactable) { uint newValue = GetValueForIncrement(); SetBpmValue(newValue, true); } autoIncrementTimer = 0; } // if (MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmIncrease) || MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmDecrease)) { incrementInputHoldTime += Time.deltaTime; } else { incrementInputHoldTime = 0; } } else { incrementInputHoldTime = 0; } } if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleBpmAnchor) && anchorToggle.IsInteractable()) { anchorToggle.isOn = !anchorToggle.isOn; } }
void RefreshSectionHighlight() { if (!MSChartEditorInput.GetInput(MSChartEditorInputActions.SelectAllSection)) { return; } int currentSectionIndex = SongObjectHelper.GetIndexOfPrevious(editor.currentSong.sections, editor.currentTickPos); bool changed = currentSectionIndex != sectionHighlightCurrentIndex; editor.selectedObjectsManager.currentSelectedObject = null; sectionHighlightCurrentIndex = currentSectionIndex; for (int i = 0; Mathf.Abs(i) <= Mathf.Abs(sectionHighlightOffset); i -= (int)Mathf.Sign(sectionHighlightOffset)) { editor.selectedObjectsManager.AddHighlightCurrentSection(Globals.viewMode, i); } }
void DeleteSongObject(SongObjectController soController) { if (soController && soController.GetSongObject() != null) // Dunno why song object would ever be null, but may as well be safe { SongObject songObject = soController.GetSongObject(); if (MSChartEditorInput.GetInput(MSChartEditorInputActions.ChordSelect) && songObject.classID == (int)SongObject.ID.Note) { foreach (Note note in ((Note)songObject).chord) { dragEraseHistory.Add(note); } } else if ((songObject.classID != (int)SongObject.ID.BPM && songObject.classID != (int)SongObject.ID.TimeSignature) || songObject.tick != 0) { dragEraseHistory.Add(songObject); } ExecuteCurrentDeletes(); } }
public override void OnSelectableMouseDown() { if (nCon.note.song != null) { if (Input.GetMouseButton(1)) { { uint snappedSustainPos = GetSnappedSustainPos(); if (snappedSustainPos == nCon.note.tick) // Only assigned if we're clicking on the note itself, otherwise we can modify the sustain instantly. { initialDraggingSnappedPos = snappedSustainPos; } } originalDraggedNotes.Clear(); sustainDragCommands.Clear(); commandPushCount = 0; if (!GameSettings.extendedSustainsEnabled || MSChartEditorInput.GetInput(MSChartEditorInputActions.ChordSelect)) { foreach (Note chordNote in nCon.note.chord) { originalDraggedNotes.Add(chordNote.CloneAs <Note>()); } } else { originalDraggedNotes.Add(nCon.note.CloneAs <Note>()); } GenerateSustainDragCommands(false); if (sustainDragCommands.Count > 0) { editor.commandStack.Push(new BatchedSongEditCommand(sustainDragCommands)); ++commandPushCount; } } } }
protected override void Controls() { if (!Globals.gameSettings.keysModeEnabled) { if (Input.GetMouseButton(0)) { if (lastPlacedSP == null) { AddObject(); } else { UpdateLastPlacedSp(); } } } else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.AddSongObject)) { if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.AddSongObject)) { var searchArray = editor.currentChart.starPower; int pos = SongObjectHelper.FindObjectPosition(starpower, searchArray); if (pos == SongObjectHelper.NOTFOUND) { AddObject(); } else { editor.commandStack.Push(new SongEditDelete(searchArray[pos])); } } else if (lastPlacedSP != null) { UpdateLastPlacedSp(); } } }
public override void OnSelectableMouseDown() { if (editor.toolManager.currentToolId == EditorObjectToolManager.ToolID.Cursor && editor.currentState == ChartEditor.State.Editor && Input.GetMouseButtonDown(0) && !Input.GetMouseButton(1)) { var selectedObjectsManager = editor.selectedObjectsManager; // Ctrl-clicking if (Globals.modifierInputActive) { if (selectedObjectsManager.IsSelected(songObject)) { selectedObjectsManager.RemoveFromSelectedObjects(songObject); } else { selectedObjectsManager.AddToSelectedObjects(songObject); } return; } // Shift-clicking if (Globals.secondaryInputActive) { int pos = SongObjectHelper.FindClosestPosition(this.songObject, editor.selectedObjectsManager.currentSelectedObjects); if (pos != SongObjectHelper.NOTFOUND) { uint min; uint max; if (editor.selectedObjectsManager.currentSelectedObjects[pos].tick > songObject.tick) { max = editor.selectedObjectsManager.currentSelectedObjects[pos].tick; min = songObject.tick; } else { min = editor.selectedObjectsManager.currentSelectedObjects[pos].tick; max = songObject.tick; } var chartObjects = editor.currentChart.chartObjects; int index, length; SongObjectHelper.GetRange(chartObjects, min, max, out index, out length); selectedObjectsManager.SetCurrentSelectedObjects(chartObjects, index, length); return; } } // Regular clicking if (!selectedObjectsManager.IsSelected(songObject)) { if (MSChartEditorInput.GetInput(MSChartEditorInputActions.ChordSelect)) { selectedObjectsManager.SetCurrentSelectedObjects(note.chord); } else { selectedObjectsManager.currentSelectedObject = songObject; } return; } } // Delete the object on left and right click shortcut else if (editor.currentState == ChartEditor.State.Editor && Input.GetMouseButtonDown(0) && Input.GetMouseButton(1)) { if (MSChartEditorInput.GetInput(MSChartEditorInputActions.ChordSelect)) { Note[] chordNotes = note.GetChord(); if (Input.GetMouseButton(1)) { if (SustainController.SustainDraggingInProgress) { editor.commandStack.Pop(); // Cancel the last sustain drag action } Debug.Log("Deleted " + note + " chord at position " + note.tick + " with hold-right left-click shortcut"); editor.commandStack.Push(new SongEditDelete(chordNotes)); SustainController.ResetSustainDragData(); } } else if (Input.GetMouseButton(1)) { if (SustainController.SustainDraggingInProgress) { editor.commandStack.Pop(); // Cancel the last sustain drag action } Debug.Log("Deleted " + note + " at position " + note.tick + " with hold-right left-click shortcut"); editor.commandStack.Push(new SongEditDelete(note)); SustainController.ResetSustainDragData(); } } else { sustain.OnSelectableMouseDown(); } }
// Update is called once per frame public override void SystemUpdate() { ChartEditor editor = ChartEditor.Instance; // Show a preview if the user will click on an object GameObject songObject = editor.services.mouseMonitorSystem.currentSelectableUnderMouse; foreach (GameObject highlight in highlights) { highlight.SetActive(false); } var currentTool = editor.toolManager.currentToolId; bool validTool = currentTool == EditorObjectToolManager.ToolID.Cursor || currentTool == EditorObjectToolManager.ToolID.Eraser; bool previewDelete = Input.GetMouseButton(1) && (currentTool != EditorObjectToolManager.ToolID.Cursor || currentTool != EditorObjectToolManager.ToolID.Eraser); bool showHighlight = !Input.GetMouseButton(0) && songObject != null && (validTool || previewDelete); if (!showHighlight) { return; } // Change the shared material of the highlight if (Input.GetMouseButton(1)) { if (songObject && songObject.GetComponent <SustainController>()) { return; } else { hoverHighlightRen.sharedMaterial.color = new Color(Color.red.r, Color.red.g, Color.red.b, initColor.a); } } else { hoverHighlightRen.sharedMaterial.color = initColor; } if (showHighlight) { songObjects.Clear(); if (MSChartEditorInput.GetInput(MSChartEditorInputActions.ChordSelect)) { // Check if we're over a note NoteController nCon = songObject.GetComponent <NoteController>(); if (nCon) { foreach (Note note in nCon.note.chord) { songObjects.Add(note.controller.gameObject); } } else { SustainController sCon = songObject.GetComponent <SustainController>(); if (sCon) { foreach (Note note in sCon.nCon.note.chord) { songObjects.Add(note.controller.sustain.gameObject); } } } } else { songObjects.Add(songObject); } // Activate, position and scale highlights for (int i = 0; i < songObjects.Count; ++i) { if (i < highlights.Length) { highlights[i].SetActive(true); highlights[i].transform.position = songObjects[i].transform.position; Vector3 scale = songObjects[i].transform.localScale; Collider col3d = songObjects[i].GetComponent <Collider>(); Collider2D col = songObjects[i].GetComponent <Collider2D>(); if (col3d) { scale = col3d.bounds.size; } else { scale = col.bounds.size; } if (scale.z == 0) { scale.z = 0.1f; } highlights[i].transform.localScale = scale; } } } }
// 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, GameSettings.step, editor.currentSong); } else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveStepNegative)) { snappedPos = Snapable.ChartDecrementStep(currentPos, GameSettings.step, editor.currentSong); } else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasurePositive)) { snappedPos = Snapable.TickToSnappedTick(currentPos + (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong); } // Page Down else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasureNegative)) { snappedPos = Snapable.TickToSnappedTick(currentPos - (uint)(editor.currentSong.resolution * 4), 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; }