Esempio n. 1
0
    protected override void Controls()
    {
        if (!GameSettings.keysModeEnabled)
        {
            if (Toolpane.currentTool == Toolpane.Tools.Timesignature && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0))
            {
                RecordAddActionHistory(ts, editor.currentSong.timeSignatures);

                AddObject();
            }
        }
        else if (ShortcutInput.GetInputDown(Shortcut.AddSongObject))
        {
            SongObject[] searchArray = editor.currentSong.syncTrack;
            int          pos         = SongObjectHelper.FindObjectPosition(ts, searchArray);
            if (pos == SongObjectHelper.NOTFOUND)
            {
                editor.actionHistory.Insert(new ActionHistory.Add(ts));
                AddObject();
            }
            else if (searchArray[pos].tick != 0)
            {
                editor.actionHistory.Insert(new ActionHistory.Delete(searchArray[pos]));
                searchArray[pos].Delete();
                editor.currentSelectedObject = null;
            }
        }
    }
Esempio n. 2
0
 protected override void Controls()
 {
     if (!GameSettings.keysModeEnabled)
     {
         if (Toolpane.currentTool == Toolpane.Tools.SongEvent && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0))
         {
             int pos = SongObjectHelper.FindObjectPosition(songEvent, editor.currentSong.events);
             if (pos == SongObjectHelper.NOTFOUND)
             {
                 AddObject();
             }
             // Link to the event already in
             else
             {
                 editor.currentSelectedObject = editor.currentSong.events[pos];
             }
         }
     }
     else if (ShortcutInput.GetInputDown(Shortcut.AddSongObject))
     {
         var searchArray = editor.currentSong.events;
         int pos         = SongObjectHelper.FindObjectPosition(songEvent, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.currentSelectedObject = null;
         }
     }
 }
Esempio n. 3
0
 void Controls()
 {
     if (ShortcutInput.GetInputDown(Shortcut.ToggleBpmAnchor) && anchorToggle.IsInteractable())
     {
         anchorToggle.isOn = !anchorToggle.isOn;
     }
 }
Esempio n. 4
0
 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();
             }
         }
     }
 }
Esempio n. 5
0
    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;
                }
            }
        }
    }
    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();
        }
    }
 protected override void Controls()
 {
     if (!GameSettings.keysModeEnabled)
     {
         if (Toolpane.currentTool == Toolpane.Tools.Section && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0))
         {
             Section sectionSearched = sectionSearch(section.tick);
             if (sectionSearched == null)
             {
                 AddObject();
             }
             else
             {
                 editor.currentSelectedObject = sectionSearched;
             }
         }
     }
     else if (ShortcutInput.GetInputDown(Shortcut.AddSongObject))
     {
         var searchArray = editor.currentSong.sections;
         int pos         = SongObjectHelper.FindObjectPosition(section, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.currentSelectedObject = null;
         }
     }
 }
    void Controls()
    {
        if (ShortcutInput.GetInputDown(Shortcut.ToggleNoteTap) && tapToggle.interactable)
        {
            if (tapToggle.isOn)
            {
                tapToggle.isOn = false;
            }
            else
            {
                tapToggle.isOn = true;
            }
        }

        if (ShortcutInput.GetInputDown(Shortcut.ToggleNoteForced) && forcedToggle.interactable)
        {
            if (forcedToggle.isOn)
            {
                forcedToggle.isOn = false;
            }
            else
            {
                forcedToggle.isOn = true;
            }
        }
    }
Esempio n. 9
0
    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();
        }
    }
Esempio n. 10
0
    // Update is called once per frame
    void Update()
    {
        if (ShortcutInput.GetInputDown(Shortcut.ToggleViewMode) && (Globals.applicationMode == Globals.ApplicationMode.Editor || Globals.applicationMode == Globals.ApplicationMode.Playing))
        {
            viewModeToggle.isOn = !viewModeToggle.isOn;
        }

        keysModePanel.gameObject.SetActive(Toolpane.currentTool == Toolpane.Tools.Note && GameSettings.keysModeEnabled);

        Shortcuts();
    }
Esempio n. 11
0
    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;
        }
    }
Esempio n. 12
0
    void Controls()
    {
        if (ShortcutInput.GetInputDown(Shortcut.ToggleExtendedSustains))
        {
            ToggleExtendedSustains();
            editor.globals.services.notificationBar.PushNotification("EXTENDED SUSTAINS TOGGLED " + Services.BoolToStrOnOff(GameSettings.extendedSustainsEnabled), 2, true);
        }

        else if (ShortcutInput.GetInputDown(Shortcut.ToggleMouseMode))
        {
            ToggleMouseLockMode();
            editor.globals.services.notificationBar.PushNotification("KEYS MODE TOGGLED " + Services.BoolToStrOnOff(GameSettings.keysModeEnabled), 2, true);
        }
    }
 // Update is called once per frame
 void Update()
 {
     // Shortcuts
     if (!Services.IsTyping && !Globals.modifierInputActive)
     {
         if (ShortcutInput.GetInputDown(Shortcut.ToolNoteHold))
         {
             buttons[0].onClick.Invoke();
         }
         else if (ShortcutInput.GetInputDown(Shortcut.ToolNoteBurst))
         {
             buttons[1].onClick.Invoke();
         }
     }
 }
    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();
            }
        }
    }
Esempio n. 15
0
    void Shortcuts()
    {
        if (ShortcutInput.GetInputDown(Shortcut.ToolSelectCursor))
        {
            SetCursor();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.ToolSelectEraser))
        {
            eraserSelect.onClick.Invoke();
        }

        // else if (Input.GetKeyDown(KeyCode.L))
        // groupSelect.onClick.Invoke();

        else if (ShortcutInput.GetInputDown(Shortcut.ToolSelectNote))
        {
            noteSelect.onClick.Invoke();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.ToolSelectStarpower))
        {
            starpowerSelect.onClick.Invoke();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.ToolSelectBpm))
        {
            bpmSelect.onClick.Invoke();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.ToolSelectTimeSignature))
        {
            timeSignatureSelect.onClick.Invoke();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.ToolSelectSection))
        {
            sectionSelect.onClick.Invoke();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.ToolSelectEvent))
        {
            eventSelect.onClick.Invoke();
        }
    }
    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);
        }
    }
Esempio n. 17
0
 void Shortcuts()
 {
     if (ShortcutInput.GetInputDown(Shortcut.NoteSetNatural))
     {
         setNoteNatural.onClick.Invoke();
     }
     else if (ShortcutInput.GetInputDown(Shortcut.NoteSetStrum))
     {
         setNoteStrum.onClick.Invoke();
     }
     else if (ShortcutInput.GetInputDown(Shortcut.NoteSetHopo))
     {
         setNoteHopo.onClick.Invoke();
     }
     else if (ShortcutInput.GetInputDown(Shortcut.NoteSetTap))
     {
         setNoteTap.onClick.Invoke();
     }
 }
Esempio n. 18
0
    new void LateUpdate()
    {
        if (Mouse.world2DPosition != null && Input.mousePosition.y < Camera.main.WorldToScreenPoint(editor.mouseYMaxLimit.position).y)
        {
            pastePos = objectSnappedChartPos;
        }
        else
        {
            pastePos = editor.currentSong.WorldPositionToSnappedTick(strikeline.position.y, GameSettings.step);
        }

        transform.position = new Vector3(transform.position.x, editor.currentSong.TickToWorldYPosition(pastePos), transform.position.z);

        if (ShortcutInput.GetInputDown(Shortcut.ClipboardPaste))
        {
            Paste(pastePos);
            groupSelectTool.reset();
        }
    }
Esempio n. 19
0
    public override void OnServiceUpdate()
    {
        if (editor.currentChart.note_count != prevNoteCount)
        {
            noteCount.text = "Notes: " + editor.currentChart.note_count.ToString();
        }

        if (GameSettings.step != prevSnappingStep)
        {
            UpdateSnappingStepText();
        }

        // Shortcuts
        if (ShortcutInput.GetInputDown(Shortcut.ToggleClap))
        {
            clapToggle.isOn = !clapToggle.isOn;
        }

        prevNoteCount = editor.currentChart.note_count;
    }
 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();
         }
     }
 }
    protected override void Controls()
    {
        if (!GameSettings.keysModeEnabled)
        {
            if (Toolpane.currentTool == Toolpane.Tools.SongEvent && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0))
            {
                int pos = SongObjectHelper.FindObjectPosition(chartEvent, editor.currentChart.events);
                if (pos == SongObjectHelper.NOTFOUND)
                {
                    //RecordAddActionHistory(chartEvent, editor.currentChart.events);

                    AddObject();
                }
                // Link to the event already in
                else
                {
                    editor.currentSelectedObject = editor.currentChart.events[pos];
                }
            }
        }
        else if (ShortcutInput.GetInputDown(Shortcut.AddSongObject))
        {
            var searchArray = editor.currentChart.events;
            int pos         = SongObjectHelper.FindObjectPosition(chartEvent, searchArray);
            if (pos == SongObjectHelper.NOTFOUND)
            {
                editor.actionHistory.Insert(new ActionHistory.Add(chartEvent));
                AddObject();
            }
            else
            {
                editor.actionHistory.Insert(new ActionHistory.Delete(searchArray[pos]));
                searchArray[pos].Delete();
                editor.currentSelectedObject = null;
            }
        }
    }
Esempio n. 22
0
 protected override void Controls()
 {
     if (!GameSettings.keysModeEnabled)
     {
         if (Toolpane.currentTool == Toolpane.Tools.Timesignature && Globals.applicationMode == Globals.ApplicationMode.Editor && Input.GetMouseButtonDown(0))
         {
             AddObject();
         }
     }
     else if (ShortcutInput.GetInputDown(Shortcut.AddSongObject))
     {
         IList <SyncTrack> searchArray = editor.currentSong.syncTrack;
         int pos = SongObjectHelper.FindObjectPosition(ts, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else if (searchArray[pos].tick != 0)
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.currentSelectedObject = null;
         }
     }
 }
Esempio n. 23
0
    protected override void Update()
    {
        if (prevChart != editor.currentChart || prevSong != editor.currentSong)
        {
            reset();
        }
        if (Globals.applicationMode == Globals.ApplicationMode.Editor)
        {
            UpdateSnappedPos();

            // Update the corner positions
            if (Input.GetMouseButtonDown(0) && Mouse.world2DPosition != null)
            {
                initWorld2DPos       = (Vector2)Mouse.world2DPosition;
                initWorld2DPos.y     = editor.currentSong.TickToWorldYPosition(objectSnappedChartPos);
                startWorld2DChartPos = objectSnappedChartPos;

                Color col = Color.green;
                col.a = draggingArea.color.a;

                if (Globals.secondaryInputActive)
                {
                    addMode = true;
                }
                else if (Globals.modifierInputActive)
                {
                    addMode = false;
                    col     = Color.red;
                    col.a   = draggingArea.color.a;
                }
                else
                {
                    addMode = true;
                    data    = new List <ChartObject>();
                    area    = new Clipboard.SelectionArea(new Rect(), startWorld2DChartPos, endWorld2DChartPos);
                }

                draggingArea.color = col;

                userDraggingSelectArea = true;
            }

            if (Input.GetMouseButton(0) && Mouse.world2DPosition != null)
            {
                endWorld2DPos   = (Vector2)Mouse.world2DPosition;
                endWorld2DPos.y = editor.currentSong.TickToWorldYPosition(objectSnappedChartPos);

                endWorld2DChartPos = objectSnappedChartPos;
            }

            UpdateSelectionAreaVisual(transform, initWorld2DPos, endWorld2DPos);
            UpdateSelectionAreaVisual(selectedArea, area);

            // User has finished creating a selection area
            if (Input.GetMouseButtonUp(0) && userDraggingSelectArea)
            {
                if (startWorld2DChartPos > endWorld2DChartPos)
                {
                    if (addMode)
                    {
                        AddToSelection(ScanArea(initWorld2DPos, endWorld2DPos, endWorld2DChartPos, startWorld2DChartPos));

                        area += new Clipboard.SelectionArea(initWorld2DPos, endWorld2DPos, endWorld2DChartPos, startWorld2DChartPos);
                    }
                    else
                    {
                        RemoveFromSelection(ScanArea(initWorld2DPos, endWorld2DPos, endWorld2DChartPos, startWorld2DChartPos));

                        area -= new Clipboard.SelectionArea(initWorld2DPos, endWorld2DPos, endWorld2DChartPos, startWorld2DChartPos);
                    }
                }
                else
                {
                    if (addMode)
                    {
                        AddToSelection(ScanArea(initWorld2DPos, endWorld2DPos, startWorld2DChartPos, endWorld2DChartPos));

                        area += new Clipboard.SelectionArea(initWorld2DPos, endWorld2DPos, startWorld2DChartPos, endWorld2DChartPos);
                    }
                    else
                    {
                        RemoveFromSelection(ScanArea(initWorld2DPos, endWorld2DPos, startWorld2DChartPos, endWorld2DChartPos));

                        area -= new Clipboard.SelectionArea(initWorld2DPos, endWorld2DPos, startWorld2DChartPos, endWorld2DChartPos);
                    }
                }
                selfAreaDisable();
                userDraggingSelectArea = false;
            }

            // Handle copy and cut functions
            if (data.Count > 0)
            {
                if (ShortcutInput.GetInputDown(Shortcut.ClipboardCut))
                {
                    Cut();
                }
                else if (ShortcutInput.GetInputDown(Shortcut.ClipboardCopy))
                {
                    Copy(data, area);
                }
            }
        }

        prevSong  = editor.currentSong;
        prevChart = editor.currentChart;

        editor.SetCurrentSelectedObjects(data);
    }
    // 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;
    }
    void Shortcuts()
    {
        if (ShortcutInput.GetInputDown(Shortcut.PlayPause))
        {
            if (applicationMode == ApplicationMode.Editor && services.CanPlay())
            {
                editor.Play();
            }
            else if (applicationMode == ApplicationMode.Playing)
            {
                editor.Stop();
            }
        }

        else if (ShortcutInput.GetInputDown(Shortcut.StepIncrease))
        {
            GameSettings.snappingStep.Increment();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.StepDecrease))
        {
            GameSettings.snappingStep.Decrement();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.Delete) && editor.currentSelectedObjects.Count > 0)
        {
            editor.Delete();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.ToggleMetronome))
        {
            services.ToggleMetronome();
            services.notificationBar.PushNotification("METRONOME TOGGLED " + Services.BoolToStrOnOff(GameSettings.metronomeActive), 2, true);
        }

        if (!modifierInputActive)
        {
            if (editor.inputManager.mainGamepad.GetButtonPressed(GamepadInput.Button.Start))
            {
                if (applicationMode != ApplicationMode.Playing)
                {
                    editor.StartGameplay();
                }
                else
                {
                    editor.Stop();
                }
            }
        }

        if (ShortcutInput.GetInputDown(Shortcut.FileSave))
        {
            editor._Save();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.FileSaveAs))
        {
            editor.SaveAs();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.FileLoad))
        {
            editor.Load();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.FileNew))
        {
            editor.New();
        }

        else if (ShortcutInput.GetInputDown(Shortcut.SelectAll))
        {
            services.toolpanelController.SetCursor();
            HighlightAll();
        }
        else if (ShortcutInput.GetInputDown(Shortcut.SelectAllSection))
        {
            services.toolpanelController.SetCursor();
            HighlightCurrentSection();
        }

        if (!Input.GetMouseButton(0) && !Input.GetMouseButton(1))
        {
            bool success = false;

            if (ShortcutInput.GetInputDown(Shortcut.ActionHistoryUndo))
            {
                if (!editor.commandStack.isAtStart && editor.services.CanUndo())
                {
                    editor.UndoWrapper();
                    success = true;
                }
            }
            else if (ShortcutInput.GetInputDown(Shortcut.ActionHistoryRedo))
            {
                if (!editor.commandStack.isAtEnd && editor.services.CanRedo())
                {
                    editor.RedoWrapper();
                    success = true;
                }
            }

            if (success)
            {
                EventSystem.current.SetSelectedGameObject(null);
                groupSelect.reset();
                TimelineHandler.externalUpdate = true;
            }
        }

        if (editor.currentSelectedObjects.Count > 0)
        {
            if (ShortcutInput.GetInputDown(Shortcut.ClipboardCut))
            {
                editor.Cut();
            }
            else if (ShortcutInput.GetInputDown(Shortcut.ClipboardCopy))
            {
                editor.Copy();
            }
        }
    }
    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();
        }
    }
Esempio n. 27
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;
                }
            }
        }
    }
Esempio n. 28
0
    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;
    }
Esempio n. 29
0
    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();
            }
        }
    }