Пример #1
0
    // 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;
                }
            }
        }
    }
    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();
        }
    }
Пример #3
0
    // 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;
                }
            }
        }
    }