public override void OnSelectableMouseDrag() { // Move note if (moveCheck) { if (ShortcutInput.GetInput(Shortcut.ChordSelect)) { Note[] chordNotes = note.GetChord(); editor.groupMove.SetSongObjects(chordNotes, 0); foreach (Note chordNote in chordNotes) { chordNote.Delete(); } } else { //base.OnSelectableMouseDrag(); } } else { sustain.OnSelectableMouseDrag(); } }
protected override void Update() { base.Update(); if (Input.GetMouseButton(0)) { GameObject currentMouseHover = Mouse.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 (ShortcutInput.GetInput(Shortcut.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 OnSelectableMouseDown() { if (nCon.note.song != null) { if (Input.GetMouseButton(1)) { originalDraggedNotes.Clear(); sustainDragCommands.Clear(); commandPushCount = 0; if (!GameSettings.extendedSustainsEnabled || ShortcutInput.GetInput(Shortcut.ChordSelect)) { foreach (Note chordNote in nCon.note.chord) { originalDraggedNotes.Add(chordNote.CloneAs <Note>()); } } else { originalDraggedNotes.Add(nCon.note.CloneAs <Note>()); } GenerateSustainDragCommands(); if (sustainDragCommands.Count > 0) { editor.commandStack.Push(new BatchedSongEditCommand(sustainDragCommands)); ++commandPushCount; } } } }
public override void OnSelectableMouseDrag() { if (nCon.note != null && nCon.note.song != null) { // Update sustain if (Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButton(1)) { if (!GameSettings.extendedSustainsEnabled || ShortcutInput.GetInput(Shortcut.ChordSelect)) { if (unmodifiedNotes.Count == 0) { foreach (Note chordNote in nCon.note.chord) { unmodifiedNotes.Add(new Note[] { (Note)chordNote.Clone(), chordNote }); } } ChordSustainDrag(); } else { if (unmodifiedNotes.Count == 0) { unmodifiedNotes.Add(new Note[] { (Note)nCon.note.Clone(), nCon.note }); } //unmodifiedNotes.Add(new Note[] { (Note)nCon.note.Clone(), nCon.note }); SustainDrag(); } } } }
void Controls() { 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) { uint newValue = GetValueForDecrement(); SetBpmValue(newValue); } else if (ShortcutInput.GetInputDown(Shortcut.BpmIncrease) && increment.interactable) { uint newValue = GetValueForIncrement(); SetBpmValue(newValue); } // Adjust to time rather than framerate if (incrementalTimer > AUTO_INCREMENT_WAIT_TIME && autoIncrementTimer > AUTO_INCREMENT_RATE) { if (ShortcutInput.GetInput(Shortcut.BpmDecrease) && decrement.interactable) { uint newValue = GetValueForDecrement(); SetBpmValue(newValue, true); } else if (ShortcutInput.GetInput(Shortcut.BpmIncrease) && increment.interactable) { uint newValue = GetValueForIncrement(); SetBpmValue(newValue, true); } autoIncrementTimer = 0; } // if (ShortcutInput.GetInput(Shortcut.BpmIncrease) || ShortcutInput.GetInput(Shortcut.BpmDecrease)) { incrementalTimer += Time.deltaTime; } } else { incrementalTimer = 0; } } if (ShortcutInput.GetInputDown(Shortcut.ToggleBpmAnchor) && anchorToggle.IsInteractable()) { anchorToggle.isOn = !anchorToggle.isOn; } }
protected override void Controls() { if (!GameSettings.keysModeEnabled) { if (Toolpane.currentTool == Toolpane.Tools.Starpower && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButton(0)) { if (lastPlacedSP == null) { // Check if there's a starpower already in that position int arrayPos = SongObjectHelper.FindObjectPosition(starpower, editor.currentChart.starPower); if (arrayPos != SongObjectHelper.NOTFOUND) // Found an object that matches { overwrittenSP = (Starpower)editor.currentChart.starPower[arrayPos].Clone(); } AddObject(); } else { UpdateLastPlacedSp(); } } } else if (ShortcutInput.GetInput(Shortcut.AddSongObject)) { if (ShortcutInput.GetInputDown(Shortcut.AddSongObject)) { var searchArray = editor.currentChart.starPower; int pos = SongObjectHelper.FindObjectPosition(starpower, searchArray); if (pos == SongObjectHelper.NOTFOUND) { editor.actionHistory.Insert(new ActionHistory.Add(starpower)); AddObject(); } else { editor.actionHistory.Insert(new ActionHistory.Delete(searchArray[pos])); searchArray[pos].Delete(); editor.currentSelectedObject = null; } } else if (lastPlacedSP != null) { UpdateLastPlacedSp(); } } }
void RefreshSectionHighlight() { if (!ShortcutInput.GetInput(Shortcut.SelectAllSection)) { return; } int currentSectionIndex = SongObjectHelper.GetIndexOfPrevious(editor.currentSong.sections, editor.currentTickPos); bool changed = currentSectionIndex != sectionHighlightCurrentIndex; editor.currentSelectedObject = null; sectionHighlightCurrentIndex = currentSectionIndex; for (int i = 0; Mathf.Abs(i) <= Mathf.Abs(sectionHighlightOffset); i -= (int)Mathf.Sign(sectionHighlightOffset)) { globals.AddHighlightCurrentSection(i); } }
protected override void Controls() { if (!GameSettings.keysModeEnabled) { if (Toolpane.currentTool == Toolpane.Tools.Starpower && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButton(0)) { if (lastPlacedSP == null) { AddObject(); } else { UpdateLastPlacedSp(); } } } else if (ShortcutInput.GetInput(Shortcut.AddSongObject)) { if (ShortcutInput.GetInputDown(Shortcut.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(); } } }
// 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; }
// Update is called once per frame void Update() { // Show a preview if the user will click on an object GameObject songObject = Mouse.currentSelectableUnderMouse; foreach (GameObject highlight in highlights) { highlight.SetActive(false); } bool showHighlight = (Globals.applicationMode == Globals.ApplicationMode.Editor && !Input.GetMouseButton(0) && songObject != null && ((Toolpane.currentTool == Toolpane.Tools.Cursor || Toolpane.currentTool == Toolpane.Tools.Eraser) || (Input.GetMouseButton(1) && (Toolpane.currentTool != Toolpane.Tools.Cursor || Toolpane.currentTool != Toolpane.Tools.Eraser)))); 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 (ShortcutInput.GetInput(Shortcut.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); } 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; } } } }
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; }
public override void OnSelectableMouseDown() { if (Toolpane.currentTool == Toolpane.Tools.Cursor && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0) && !Input.GetMouseButton(1)) { // Ctrl-clicking if (Globals.modifierInputActive) { if (editor.IsSelected(songObject)) { editor.RemoveFromSelectedObjects(songObject); } else { editor.AddToSelectedObjects(songObject); } } // Shift-clicking else if (Globals.secondaryInputActive) { int pos = SongObjectHelper.FindClosestPosition(this.songObject, editor.currentSelectedObjects); if (pos != SongObjectHelper.NOTFOUND) { uint min; uint max; if (editor.currentSelectedObjects[pos].tick > songObject.tick) { max = editor.currentSelectedObjects[pos].tick; min = songObject.tick; } else { min = editor.currentSelectedObjects[pos].tick; max = songObject.tick; } editor.currentSelectedObjects = SongObjectHelper.GetRangeCopy(editor.currentChart.chartObjects, min, max); } } // Regular clicking else if (!editor.IsSelected(songObject)) { if (ShortcutInput.GetInput(Shortcut.ChordSelect)) { editor.currentSelectedObjects = note.GetChord(); } else { editor.currentSelectedObject = songObject; } } } // Delete the object on erase tool else if (Globals.applicationMode == Globals.ApplicationMode.Editor && ( (Toolpane.currentTool == Toolpane.Tools.Eraser && Input.GetMouseButtonDown(0)) || (Input.GetMouseButtonDown(0) && Input.GetMouseButton(1)) || Eraser.dragging) ) { if (ShortcutInput.GetInput(Shortcut.ChordSelect)) { Note[] chordNotes = note.GetChord(); if (!Input.GetMouseButton(1)) { Debug.Log("Deleted " + note + " chord at position " + note.tick + " with eraser tool"); Eraser.dragEraseHistory.Add(new ActionHistory.Delete(chordNotes)); } else { Debug.Log("Deleted " + note + " chord at position " + note.tick + " with hold-right left-click shortcut"); editor.actionHistory.Insert(new ActionHistory.Delete(chordNotes)); } //editor.actionHistory.Insert(new ActionHistory.Delete(chordNotes)); foreach (Note chordNote in chordNotes) { chordNote.Delete(); } } else { if (!Input.GetMouseButton(1)) { Debug.Log("Deleted " + note + " at position " + note.tick + " with eraser tool"); Eraser.dragEraseHistory.Add(new ActionHistory.Delete(note)); } else { Debug.Log("Deleted " + note + " at position " + note.tick + " with hold-right left-click shortcut"); editor.actionHistory.Insert(new ActionHistory.Delete(note)); } note.Delete(); } } }
public override void OnSelectableMouseDown() { if (Toolpane.currentTool == Toolpane.Tools.Cursor && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0) && !Input.GetMouseButton(1)) { // Ctrl-clicking if (Globals.modifierInputActive) { if (editor.IsSelected(songObject)) { editor.RemoveFromSelectedObjects(songObject); } else { editor.AddToSelectedObjects(songObject); } } // Shift-clicking else if (Globals.secondaryInputActive) { int pos = SongObjectHelper.FindClosestPosition(this.songObject, editor.currentSelectedObjects); if (pos != SongObjectHelper.NOTFOUND) { uint min; uint max; if (editor.currentSelectedObjects[pos].tick > songObject.tick) { max = editor.currentSelectedObjects[pos].tick; min = songObject.tick; } else { min = editor.currentSelectedObjects[pos].tick; max = songObject.tick; } var chartObjects = editor.currentChart.chartObjects; int index, length; SongObjectHelper.GetRange(chartObjects, min, max, out index, out length); editor.SetCurrentSelectedObjects(chartObjects, index, length); } } // Regular clicking else if (!editor.IsSelected(songObject)) { if (ShortcutInput.GetInput(Shortcut.ChordSelect)) { editor.SetCurrentSelectedObjects(note.chord); } else { editor.currentSelectedObject = songObject; } } } // Delete the object on left and right click shortcut else if (Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0) && Input.GetMouseButton(1)) { if (ShortcutInput.GetInput(Shortcut.ChordSelect)) { Note[] chordNotes = note.GetChord(); if (Input.GetMouseButton(1)) { Debug.Log("Deleted " + note + " chord at position " + note.tick + " with hold-right left-click shortcut"); editor.commandStack.Push(new SongEditDelete(chordNotes)); } } else if (Input.GetMouseButton(1)) { Debug.Log("Deleted " + note + " at position " + note.tick + " with hold-right left-click shortcut"); editor.commandStack.Push(new SongEditDelete(note)); } } else { sustain.OnSelectableMouseDown(); } }