Beispiel #1
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();
            }
        }
    }
    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();
            }
        }
    }