Exemplo n.º 1
0
 void Controls()
 {
     if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleStarpowerDrumsFillActivation) && drumFillToggle.gameObject.activeSelf && drumFillToggle.interactable)
     {
         drumFillToggle.isOn = !drumFillToggle.isOn;
     }
 }
 protected override void Controls()
 {
     if (!GameSettings.keysModeEnabled)
     {
         if (Input.GetMouseButtonDown(0))
         {
             int pos = SongObjectHelper.FindObjectPosition(chartEvent, editor.currentChart.events);
             if (pos == SongObjectHelper.NOTFOUND)
             {
                 AddObject();
             }
             // Link to the event already in
             else
             {
                 editor.selectedObjectsManager.currentSelectedObject = editor.currentChart.events[pos];
             }
         }
     }
     else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.AddSongObject))
     {
         var searchArray = editor.currentChart.events;
         int pos         = SongObjectHelper.FindObjectPosition(chartEvent, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.selectedObjectsManager.currentSelectedObject = null;
         }
     }
 }
    public override void Update()
    {
        base.Update();

        ChartEditor editor = ChartEditor.Instance;

        if (!audioStarted)
        {
            float audioPlayPoint = playFromTime + editor.services.totalSongAudioOffset;
            float currentTime    = editor.services.currentAudioTime;
            if (currentTime >= audioPlayPoint && currentTime > 0)
            {
                editor.PlayAudio(currentTime);
                audioStarted = true;
            }
        }

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.StepIncrease))
        {
            GameSettings.snappingStep.Increment();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.StepDecrease))
        {
            GameSettings.snappingStep.Decrement();
        }

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.PlayPause) || MSChartEditorInput.GetInputDown(MSChartEditorInputActions.StartGameplay))
        {
            editor.Stop();
        }
    }
Exemplo n.º 4
0
    static bool GetPadPressedInput(Note.DrumPad drumFret, LaneInfo laneInfo, Dictionary <Note.DrumPad, MSChartEditorInputActions> inputsToCheck, Dictionary <int, Dictionary <Note.DrumPad, MSChartEditorInputActions?> > laneCountOverridesDict)
    {
        if (laneCountOverridesDict != null)
        {
            Dictionary <Note.DrumPad, MSChartEditorInputActions?> inputOverrideDict;
            MSChartEditorInputActions?overrideInput;

            if (laneCountOverridesDict.TryGetValue(laneInfo.laneCount, out inputOverrideDict) && inputOverrideDict.TryGetValue(drumFret, out overrideInput))
            {
                bool inputFound = false;

                if (overrideInput != null)
                {
                    inputFound = MSChartEditorInput.GetInputDown((MSChartEditorInputActions)overrideInput);
                }

                return(inputFound);
            }
        }

        MSChartEditorInputActions input;

        if (inputsToCheck.TryGetValue(drumFret, out input))
        {
            return(MSChartEditorInput.GetInputDown(input));
        }

        return(false);
    }
Exemplo n.º 5
0
 protected override void Controls()
 {
     if (!Globals.gameSettings.keysModeEnabled)
     {
         if (Input.GetMouseButtonDown(0))
         {
             Section sectionSearched = sectionSearch(section.tick);
             if (sectionSearched == null)
             {
                 AddObject();
             }
             else
             {
                 editor.selectedObjectsManager.currentSelectedObject = sectionSearched;
             }
         }
     }
     else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.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.selectedObjectsManager.currentSelectedObject = null;
         }
     }
 }
    void Controls()
    {
        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleNoteTap) && tapToggle.interactable)
        {
            if (tapToggle.isOn)
            {
                tapToggle.isOn = false;
            }
            else
            {
                tapToggle.isOn = true;
            }
        }

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleNoteForced) && forcedToggle.interactable)
        {
            if (forcedToggle.isOn)
            {
                forcedToggle.isOn = false;
            }
            else
            {
                forcedToggle.isOn = true;
            }
        }
    }
    void Shortcuts()
    {
        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleMetronome))
        {
            services.ToggleMetronome();
            services.notificationBar.PushNotification("METRONOME TOGGLED " + Services.BoolToStrOnOff(GameSettings.metronomeActive), 2, true);
        }

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.FileSave))
        {
            editor._Save();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.FileSaveAs))
        {
            editor.SaveAs();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.FileLoad))
        {
            editor.Load();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.FileNew))
        {
            editor.New();
        }
    }
    void Controls()
    {
        if (!(MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmIncrease) && MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmDecrease)))    // Can't hit both at the same time
        {
            if (!Services.IsTyping && !Globals.modifierInputActive)
            {
                if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.BpmDecrease) && decrement.interactable)
                {
                    uint newValue = GetValueForDecrement();
                    SetBpmValue(newValue);
                }
                else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.BpmIncrease) && increment.interactable)
                {
                    uint newValue = GetValueForIncrement();
                    SetBpmValue(newValue);
                }

                // Adjust to time rather than framerate
                if (incrementInputHoldTime > AUTO_INCREMENT_WAIT_TIME && autoIncrementTimer > AUTO_INCREMENT_RATE)
                {
                    if (MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmDecrease) && decrement.interactable)
                    {
                        uint newValue = GetValueForDecrement();
                        SetBpmValue(newValue, true);
                    }
                    else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmIncrease) && increment.interactable)
                    {
                        uint newValue = GetValueForIncrement();
                        SetBpmValue(newValue, true);
                    }

                    autoIncrementTimer = 0;
                }

                //
                if (MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmIncrease) || MSChartEditorInput.GetInput(MSChartEditorInputActions.BpmDecrease))
                {
                    incrementInputHoldTime += Time.deltaTime;
                }
                else
                {
                    incrementInputHoldTime = 0;
                }
            }
            else
            {
                incrementInputHoldTime = 0;
            }
        }

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleBpmAnchor) && anchorToggle.IsInteractable())
        {
            anchorToggle.isOn = !anchorToggle.isOn;
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleViewMode) && (editor.currentState == ChartEditor.State.Editor || editor.currentState == ChartEditor.State.Playing))
        {
            viewModeToggle.isOn = !viewModeToggle.isOn;
        }

        keysModePanel.gameObject.SetActive(editor.toolManager.currentToolId == EditorObjectToolManager.ToolID.Note && GameSettings.keysModeEnabled);

        Shortcuts();
    }
Exemplo n.º 10
0
    void Controls()
    {
        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleExtendedSustains))
        {
            ToggleExtendedSustains();
            editor.globals.services.notificationBar.PushNotification("EXTENDED SUSTAINS TOGGLED " + Services.BoolToStrOnOff(GameSettings.extendedSustainsEnabled), 2, true);
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleMouseMode))
        {
            ToggleMouseLockMode();
            editor.globals.services.notificationBar.PushNotification("KEYS MODE TOGGLED " + Services.BoolToStrOnOff(GameSettings.keysModeEnabled), 2, true);
        }
    }
Exemplo n.º 11
0
    protected virtual void Update()
    {
        MovementController.cancel = true;

        bool exitInput = MSChartEditorInput.GetInputDown(MSChartEditorInputActions.CloseMenu) && !editor.uiServices.popupBlockerEnabled;

        if (
            exitInput ||
            (Input.GetMouseButtonDown(0) && !RectTransformUtility.RectangleContainsScreenPoint(mouseArea, editor.uiServices.GetUIMousePosition())) ||
            editor.errorManager.HasErrorToDisplay()
            )
        {
            Disable();
        }
    }
Exemplo n.º 12
0
 // Update is called once per frame
 void Update()
 {
     // Shortcuts
     if (!Services.IsTyping && !Globals.modifierInputActive)
     {
         if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolNoteHold))
         {
             buttons[0].onClick.Invoke();
         }
         else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolNoteBurst))
         {
             buttons[1].onClick.Invoke();
         }
     }
 }
    void Controls()
    {
        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleNoteTap) && tapToggle.interactable)
        {
            tapToggle.isOn = !tapToggle.isOn;
        }

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleNoteForced) && forcedToggle.interactable)
        {
            forcedToggle.isOn = !forcedToggle.isOn;
        }

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleNoteCymbal) && cymbalToggle.interactable)
        {
            cymbalToggle.isOn = !cymbalToggle.isOn;
        }
    }
    void Shortcuts()
    {
        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolSelectCursor))
        {
            cursorSelect.onClick.Invoke();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolSelectEraser))
        {
            eraserSelect.onClick.Invoke();
        }

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

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolSelectNote))
        {
            noteSelect.onClick.Invoke();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolSelectStarpower))
        {
            starpowerSelect.onClick.Invoke();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolSelectBpm))
        {
            bpmSelect.onClick.Invoke();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolSelectTimeSignature))
        {
            timeSignatureSelect.onClick.Invoke();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolSelectSection))
        {
            sectionSelect.onClick.Invoke();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToolSelectEvent))
        {
            eventSelect.onClick.Invoke();
        }
    }
    public static bool GetPadPressedInput(Note.DrumPad drumFret, LaneInfo laneInfo)
    {
        Dictionary <Note.DrumPad, MSChartEditorInputActions?> inputOverrideDict;
        MSChartEditorInputActions?overrideInput;

        if (laneCountGamepadOverridesDict.TryGetValue(laneInfo.laneCount, out inputOverrideDict) && inputOverrideDict.TryGetValue(drumFret, out overrideInput))
        {
            bool inputFound = false;

            if (overrideInput != null)
            {
                inputFound = MSChartEditorInput.GetInputDown((MSChartEditorInputActions)overrideInput);
            }

            return(inputFound);
        }

        switch (drumFret)
        {
        case Note.DrumPad.Red:
            return(MSChartEditorInput.GetInputDown(MSChartEditorInputActions.DrumPadRed));

        case Note.DrumPad.Yellow:
            return(MSChartEditorInput.GetInputDown(MSChartEditorInputActions.DrumPadYellow));

        case Note.DrumPad.Blue:
            return(MSChartEditorInput.GetInputDown(MSChartEditorInputActions.DrumPadBlue));

        case Note.DrumPad.Orange:
            return(MSChartEditorInput.GetInputDown(MSChartEditorInputActions.DrumPadOrange));

        case Note.DrumPad.Green:
            return(MSChartEditorInput.GetInputDown(MSChartEditorInputActions.DrumPadGreen));

        case Note.DrumPad.Kick:
            return(MSChartEditorInput.GetInputDown(MSChartEditorInputActions.DrumPadKick));

        default:
            Debug.LogError("Unhandled note type for drum input: " + drumFret);
            break;
        }

        return(false);
    }
 void Shortcuts()
 {
     if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.NoteSetNatural))
     {
         setNoteNatural.onClick.Invoke();
     }
     else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.NoteSetStrum))
     {
         setNoteStrum.onClick.Invoke();
     }
     else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.NoteSetHopo))
     {
         setNoteHopo.onClick.Invoke();
     }
     else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.NoteSetTap))
     {
         setNoteTap.onClick.Invoke();
     }
 }
    new void LateUpdate()
    {
        if (editor.services.mouseMonitorSystem.world2DPosition != null && Input.mousePosition.y < Camera.main.WorldToScreenPoint(editor.mouseYMaxLimit.position).y)
        {
            pastePos = objectSnappedChartPos;
        }
        else
        {
            pastePos = editor.currentSong.WorldPositionToSnappedTick(strikeline.position.y, Globals.gameSettings.step);
        }

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

        if (!Services.IsTyping && MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ClipboardPaste))
        {
            Paste(pastePos);
            groupSelectTool.reset();
        }
    }
Exemplo n.º 18
0
    public override void OnServiceUpdate()
    {
        if (editor.currentChart.note_count != prevNoteCount)
        {
            noteCount.text = "Notes: " + editor.currentChart.note_count.ToString();
        }

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

        // Shortcuts
        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleClap))
        {
            clapToggle.isOn = !clapToggle.isOn;
        }

        prevNoteCount = editor.currentChart.note_count;
    }
Exemplo n.º 19
0
    protected virtual void Update()
    {
        MovementController.cancel = true;

        bool exitInput            = MSChartEditorInput.GetInputDown(MSChartEditorInputActions.CloseMenu) && !editor.uiServices.popupBlockerEnabled;
        bool clickedOutSideWindow = Input.GetMouseButtonDown(0) && !RectTransformUtility.RectangleContainsScreenPoint(mouseArea, editor.uiServices.GetUIMousePosition());

        if (clickedOutSideWindow)
        {
            var         mouseMonitor         = editor.services.mouseMonitorSystem;
            var         uiUnderMouse         = mouseMonitor.GetUIRaycastableUnderPointer();
            DisplayMenu menu                 = uiUnderMouse ? uiUnderMouse.GetComponentInParent <DisplayMenu>() : null;
            bool        clickingObjectInMenu = menu && menu == this;

            clickedOutSideWindow &= !clickingObjectInMenu;
        }

        if (exitInput || clickedOutSideWindow || editor.errorManager.HasErrorToDisplay())
        {
            Disable();
        }
    }
Exemplo n.º 20
0
 // Update is called once per frame
 void Update()
 {
     if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.CloseMenu))
     {
         Close(false);
     }
     else
     {
         InputAction conflict;
         IInputMap   attemptedInput;
         if (!device.Connected || rebinder.TryMap(out conflict, out attemptedInput))
         {
             Close(true);
         }
         else if (conflict != null)
         {
             inputConflictEvent.Fire(conflict);
             conflictNotificationText.text    = string.Format(conflictFormatStr, attemptedInput.GetInputStr(), conflict.properties.displayName);
             conflictNotificationText.enabled = true;
         }
     }
 }
 protected override void Controls()
 {
     if (!Globals.gameSettings.keysModeEnabled)
     {
         if (Input.GetMouseButton(0))
         {
             if (lastPlacedSP == null)
             {
                 AddObject();
             }
             else
             {
                 UpdateLastPlacedSp();
             }
         }
     }
     else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.AddSongObject))
     {
         if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.AddSongObject))
         {
             var searchArray = editor.currentChart.starPower;
             int pos         = SongObjectHelper.FindObjectPosition(starpower, searchArray);
             if (pos == SongObjectHelper.NOTFOUND)
             {
                 AddObject();
             }
             else
             {
                 editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             }
         }
         else if (lastPlacedSP != null)
         {
             UpdateLastPlacedSp();
         }
     }
 }
Exemplo n.º 22
0
 protected override void Controls()
 {
     if (!GameSettings.keysModeEnabled)
     {
         if (Input.GetMouseButtonDown(0))
         {
             AddObject();
         }
     }
     else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.AddSongObject))
     {
         IList <SyncTrack> searchArray = editor.currentSong.syncTrack;
         int pos = SongObjectHelper.FindObjectPosition(bpm, searchArray);
         if (pos == SongObjectHelper.NOTFOUND)
         {
             AddObject();
         }
         else if (searchArray[pos].tick != 0)
         {
             editor.commandStack.Push(new SongEditDelete(searchArray[pos]));
             editor.selectedObjectsManager.currentSelectedObject = null;
         }
     }
 }
    public override void OnServiceUpdate()
    {
        var currentSong  = editor.currentSong;
        var currentChart = editor.currentChart;

        // Update strings
        {
            int currentNoteCount        = currentChart.note_count;
            int currentSpCount          = currentChart.starPower.Count;
            int currentLocalEventCount  = currentChart.events.Count;
            int currentBpmCount         = currentSong.bpms.Count;
            int currentTsCount          = currentSong.timeSignatures.Count;
            int currentSecCount         = currentSong.sections.Count;
            int currentGlobalEventCount = currentSong.events.Count;

            if (currentNoteCount != prevNoteCount)
            {
                noteCount.text = "Notes: " + currentNoteCount.ToString();
            }

            if (currentSpCount != prevSpCount)
            {
                spCount.text = "Starpower: " + currentSpCount.ToString();
            }

            if (currentLocalEventCount != prevLocalEventCount)
            {
                localEventsCount.text = "Local Events: " + currentLocalEventCount.ToString();
            }

            if (currentBpmCount != prevBpmCount)
            {
                bpmCount.text = "BPM: " + currentBpmCount.ToString();
            }

            if (currentTsCount != prevTsCount)
            {
                tsCount.text = "Timesignatures: " + currentTsCount.ToString();
            }

            if (currentSecCount != prevSecCount)
            {
                sectionCount.text = "Sections: " + currentSecCount.ToString();
            }

            if (currentGlobalEventCount != prevGlobalEventCount)
            {
                globalEventsCount.text = "Global Events: " + currentGlobalEventCount.ToString();
            }

            int stepValue = Globals.gameSettings.step;

            if (stepValue != prevSnappingStep)
            {
                UpdateSnappingStepText();
            }

            var   bpm      = editor.currentSong.GetPrevBPM(editor.currentTickPos);
            float bpmValue = bpm.value / 1000.0f;
            float stepFac  = SongConfig.FULL_STEP / SongConfig.STANDARD_BEAT_RESOLUTION;
            float stepNps  = bpmValue / TickFunctions.SECONDS_PER_MINUTE * (stepValue / stepFac);
            stepNpsDisplay.text = string.Format("NPS ({2} bpm @ 1/{0}): {1}nps", stepValue, stepNps.ToString("n2"), bpmValue);

            prevNoteCount        = currentNoteCount;
            prevSpCount          = currentSpCount;
            prevLocalEventCount  = currentLocalEventCount;
            prevBpmCount         = currentBpmCount;
            prevTsCount          = currentTsCount;
            prevSecCount         = currentSecCount;
            prevGlobalEventCount = currentGlobalEventCount;
        }

        // Shortcuts
        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ToggleClap))
        {
            clapToggle.isOn = !clapToggle.isOn;
        }
    }
Exemplo n.º 24
0
    public override void Update()
    {
        base.Update();

        ChartEditor editor   = ChartEditor.Instance;
        Services    services = editor.services;

        Globals.ViewMode viewMode = Globals.viewMode;

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.StepIncrease))
        {
            Globals.gameSettings.snappingStep.Increment();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.StepDecrease))
        {
            Globals.gameSettings.snappingStep.Decrement();
        }

        if (editor.groupMove.movementInProgress)
        {
            return;
        }

        if (services.CanPlay())
        {
            if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.PlayPause))
            {
                editor.Play();
                return;
            }
            else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.StartGameplay))
            {
                editor.StartGameplay();
                return;
            }
        }

        if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.Delete) && editor.selectedObjectsManager.currentSelectedObjects.Count > 0)
        {
            editor.Delete();
        }

        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.SelectAll))
        {
            editor.toolManager.ChangeTool(EditorObjectToolManager.ToolID.Cursor);
            editor.selectedObjectsManager.SelectAllInView(viewMode);
        }
        else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.SelectAllSection))
        {
            editor.toolManager.ChangeTool(EditorObjectToolManager.ToolID.Cursor);
            editor.selectedObjectsManager.HighlightCurrentSection(viewMode);
        }

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

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

            if (success)
            {
                EventSystem.current.SetSelectedGameObject(null);
                editor.groupSelect.reset();
                TimelineHandler.Repaint();
            }
        }

        if (editor.selectedObjectsManager.currentSelectedObjects.Count > 0)
        {
            if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ClipboardCut))
            {
                editor.Cut();
            }
            else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ClipboardCopy))
            {
                editor.Copy();
            }
        }
    }
    // Update is called once per frame
    void LateUpdate()
    {
        if (!MSChartEditorInput.GetInput(MSChartEditorInputActions.SelectAllSection) || editor.currentSong.sections.Count <= 0)
        {
            sectionHighlightRealOriginIndex = SongObjectHelper.GetIndexOfPrevious(editor.currentSong.sections, editor.currentTickPos);
            sectionHighlightCurrentIndex    = sectionHighlightRealOriginIndex;
        }

        if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
        {
            lastMouseDownPos = Input.mousePosition;
        }

        if (editor.currentState == ChartEditor.State.Editor)
        {
            Vector2 middleClickDragPercentageDelta = GetMiddleClickDragPercentageDelta();

            if (scrollDelta == 0 && focused)
            {
                scrollDelta = Input.mouseScrollDelta.y;
            }

            if (middleClickDragPercentageDelta != Vector2.zero)
            {
                float sign = Mathf.Sign(middleClickDragPercentageDelta.y);

                Texture2D cursorTexture = sign >= 0 ? dragCursorPositive : dragCursorNegative;
                Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.ForceSoftware);

                scrollDelta = middleClickDragPercentageDelta.y * c_middleClickMouseDragSensitivity;
            }

            if (Services.IsInDropDown)
            {
                scrollDelta = 0;
            }

            // Position changes scroll bar value
            if (scrollDelta != 0 || transform.position != prevPos || Services.HasScreenResized)
            {
                if (MSChartEditorInput.GetInput(MSChartEditorInputActions.SectionJumpMouseScroll) && editor.currentSong.sections.Count > 0)
                {
                    SectionJump(scrollDelta);
                    RefreshSectionHighlight();
                }
                else
                {
                    // Mouse scroll movement
                    mouseScrollMovePosition.x = transform.position.x;
                    mouseScrollMovePosition.y = transform.position.y + (scrollDelta * c_mouseScrollSensitivity);
                    mouseScrollMovePosition.z = transform.position.z;
                    transform.position        = mouseScrollMovePosition;
                    explicitChartPos          = null;
                }

                if (transform.position.y < initPos.y)
                {
                    transform.position = initPos;
                }

                if (Services.HasScreenResized)
                {
                    StartCoroutine(resolutionChangePosHold());
                }

                UpdateTimelineHandleBasedPos();
            }
            else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.SectionJumpPositive) && editor.currentSong.sections.Count > 0)
            {
                SectionJump(1);
                UpdateTimelineHandleBasedPos();
                RefreshSectionHighlight();
            }
            else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.SectionJumpNegative) && editor.currentSong.sections.Count > 0)
            {
                SectionJump(-1);
                UpdateTimelineHandleBasedPos();
                RefreshSectionHighlight();
            }
            else if (MSChartEditorInput.GetGroupInput(arrowKeyShortcutGroup))
            {
                // Arrow key controls
                uint currentPos;
                if (explicitChartPos != null)
                {
                    currentPos = (uint)explicitChartPos;
                }
                else
                {
                    currentPos = editor.currentTickPos;
                }

                if (arrowMoveTimer == 0 || (arrowMoveTimer > ARROW_INIT_DELAY_TIME && Time.realtimeSinceStartup > lastMoveTime + ARROW_HOLD_MOVE_ITERATION_TIME))
                {
                    uint snappedPos = currentPos;
                    // Navigate to snapped pos ahead or behind
                    if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveStepPositive))
                    {
                        snappedPos = Snapable.ChartIncrementStep(currentPos, GameSettings.step, editor.currentSong);
                    }
                    else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveStepNegative))
                    {
                        snappedPos = Snapable.ChartDecrementStep(currentPos, GameSettings.step, editor.currentSong);
                    }
                    else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasurePositive))
                    {
                        snappedPos = Snapable.TickToSnappedTick(currentPos + (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong);
                    }
                    // Page Down
                    else if (MSChartEditorInput.GetInput(MSChartEditorInputActions.MoveMeasureNegative))
                    {
                        snappedPos = Snapable.TickToSnappedTick(currentPos - (uint)(editor.currentSong.resolution * 4), GameSettings.step, editor.currentSong);
                    }

                    if (editor.currentSong.TickToTime(snappedPos, editor.currentSong.resolution) <= editor.currentSongLength)
                    {
                        SetPosition(snappedPos);
                    }

                    lastMoveTime = Time.realtimeSinceStartup;
                }

                UpdateTimelineHandleBasedPos();
            }
            // else check mouse range
            else if (globals.services.InToolArea && (Input.GetMouseButton(0) || Input.GetMouseButton(1)) && Input.mousePosition != lastMouseDownPos)
            {
                if (UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == null &&
                    Input.mousePosition.y > Camera.main.WorldToScreenPoint(editor.mouseYMaxLimit.position).y)
                {
                    // Autoscroll, dragging out notes/sustains etc
                    transform.position = new Vector3(transform.position.x, transform.position.y + autoscrollSpeed * Time.deltaTime, transform.position.z);
                    UpdateTimelineHandleBasedPos();
                }
                else
                {
                    UpdatePosBasedTimelineHandle();
                }
            }
            // Scroll bar value changes position
            else
            {
                UpdatePosBasedTimelineHandle();
            }
        }
        else if (editor.currentState == ChartEditor.State.Playing)
        {
            PlayingMovement();

            // Update timeline handle
            UpdateTimelineHandleBasedPos();

            if (timeline.handlePos >= 1)
            {
                editor.Stop();
            }
        }

        if (editor.currentState != ChartEditor.State.Playing)
        {
            lastUpdatedRealTime = Time.realtimeSinceStartup;
        }

        prevPos = transform.position;
    }
 public static bool GetStrumInput()
 {
     return(MSChartEditorInput.GetInputDown(MSChartEditorInputActions.GuitarStrumDown) || MSChartEditorInput.GetInputDown(MSChartEditorInputActions.GuitarStrumUp));
 }
Exemplo n.º 27
0
    protected override void Update()
    {
        if (prevChart != editor.currentChart || prevSong != editor.currentSong)
        {
            reset();
        }
        if (editor.currentState == ChartEditor.State.Editor)
        {
            UpdateSnappedPos();

            // Update the corner positions
            if (Input.GetMouseButtonDown(0) && editor.services.mouseMonitorSystem.world2DPosition != null)
            {
                initWorld2DPos       = (Vector2)editor.services.mouseMonitorSystem.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) && editor.services.mouseMonitorSystem.world2DPosition != null)
            {
                endWorld2DPos   = (Vector2)editor.services.mouseMonitorSystem.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 (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ClipboardCut))
                {
                    Cut();
                }
                else if (MSChartEditorInput.GetInputDown(MSChartEditorInputActions.ClipboardCopy))
                {
                    Copy(data, area);
                }
            }
        }

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

        editor.selectedObjectsManager.SetCurrentSelectedObjects(data);
    }