Exemplo 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;
            }
        }
    }
Exemplo 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;
         }
     }
 }
Exemplo n.º 3
0
 void Controls()
 {
     if (ShortcutInput.GetInputDown(Shortcut.ToggleBpmAnchor) && anchorToggle.IsInteractable())
     {
         anchorToggle.isOn = !anchorToggle.isOn;
     }
 }
 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;
            }
        }
    }
Exemplo n.º 6
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();
    }
Exemplo n.º 7
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;
        }
    }
Exemplo n.º 8
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();
            }
        }
    }
Exemplo n.º 11
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();
        }
    }
Exemplo n.º 12
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();
     }
 }
Exemplo n.º 13
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();
        }
    }
Exemplo n.º 14
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;
            }
        }
    }
Exemplo n.º 17
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;
         }
     }
 }
Exemplo n.º 18
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;
    }
Exemplo n.º 20
0
    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();
            }
        }
    }
Exemplo n.º 21
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;
    }