Ejemplo n.º 1
0
        public override void OnDisplayTab()
        {
            EditorUtility.SetDirty(midiTweak.ConfigSettings);

            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label("Key Bindings (Midi / Keyboard)", EditorStyles.boldLabel);

            for (int i = 0; i < midiTweak.ConfigKeyBindings.Bindings.Length; i++)
            {
                KeyBinding getBinding = midiTweak.ConfigKeyBindings.Bindings[i];

                DrawInputDrawer(getBinding.Name, getBinding, i);
            }

            GUILayout.Space(10);

            GUILayout.BeginVertical(EditorStyles.helpBox);

            GUILayout.Label("General", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            GUILayout.Label("MIDI start zoom (%)", GUILayout.MaxWidth(240));
            midiTweak.ConfigSettings.BaseZoomRange = EditorGUILayout.IntField(midiTweak.ConfigSettings.BaseZoomRange, GUILayout.MaxWidth(50));
            midiTweak.ConfigSettings.BaseZoomRange = (int)GUILayout.HorizontalSlider(midiTweak.ConfigSettings.BaseZoomRange, 0, 100);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            GUILayout.Label("MIDI zoom button Increment (%)", GUILayout.MaxWidth(240));
            midiTweak.ConfigSettings.ZoomIncrementAmount = EditorGUILayout.IntField(midiTweak.ConfigSettings.ZoomIncrementAmount, GUILayout.MaxWidth(50));
            midiTweak.ConfigSettings.ZoomIncrementAmount = (int)GUILayout.HorizontalSlider(midiTweak.ConfigSettings.ZoomIncrementAmount, 0, 100);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            midiTweak.ConfigSettings.ResetToDefaultZoomOnFreeze = GUILayout.Toggle(midiTweak.ConfigSettings.ResetToDefaultZoomOnFreeze, " Reset to initial zoom on freeze");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            midiTweak.ConfigSettings.RequireRecenterOnFreeze = GUILayout.Toggle(midiTweak.ConfigSettings.RequireRecenterOnFreeze, " Require recenter on freeze");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            midiTweak.ConfigSettings.LimitInputToMidiAssignments = GUILayout.Toggle(midiTweak.ConfigSettings.LimitInputToMidiAssignments, " Limit midi input to midi assignments");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            midiTweak.ConfigSettings.KeepChangesAfterSceneLoad = GUILayout.Toggle(midiTweak.ConfigSettings.KeepChangesAfterSceneLoad, " Keep changes after scene load");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            midiTweak.ConfigSettings.SaveSceneOnMidiAssignment = GUILayout.Toggle(midiTweak.ConfigSettings.SaveSceneOnMidiAssignment, " Auto save scene when changes are made to the parameter storage");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            midiTweak.ConfigSettings.instantiateInGameTweakMenuOnPlay = GUILayout.Toggle(midiTweak.ConfigSettings.instantiateInGameTweakMenuOnPlay, " Instantiate the tweaking menu on play");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            midiTweak.ConfigSettings.displayInGameTweakMenuOnPlay = GUILayout.Toggle(midiTweak.ConfigSettings.displayInGameTweakMenuOnPlay, " Display in-game tweak menu on play");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            midiTweak.ConfigSettings.midiActivationTolerance = (EMidiActivationTolerance)EditorGUILayout.EnumPopup("Midi Activation Tolerance", midiTweak.ConfigSettings.midiActivationTolerance);
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.Space(10);

            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label("Debug", EditorStyles.boldLabel);

            midiTweak.ConfigSettings.DebugDisplayMidiInputs = EditorGUILayout.Toggle("Display midi input info", midiTweak.ConfigSettings.DebugDisplayMidiInputs);

            if (midiTweak.ConfigSettings.DebugDisplayMidiInputs)
            {
                DisplayInputMasterDebug();
            }

            GUILayout.EndVertical();
            GUILayout.EndVertical();
        }
Ejemplo n.º 2
0
        private void DrawInputDrawer(string _inputName, KeyBinding _inputBinding, int _index)
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            GUILayout.Label(_inputName.ToString(), GUILayout.MinWidth(175));
            GUILayout.Label(string.Format("Assigned to: {0}", _inputBinding.ReturnAssignmentStatus()), GUILayout.MinWidth(150));

            if (midiTweak.EditorInputProcessor.KeyAssignmentRequest == _inputBinding)
            {
                if (Event.current.keyCode != KeyCode.None)
                {
                    if (Event.current.keyCode == KeyCode.Escape)
                    {
                        midiTweak.EditorInputProcessor.StopListening();
                    }
                    else
                    {
                        foreach (KeyCode keyCode in System.Enum.GetValues(typeof(KeyCode)))
                        {
                            if (Event.current.keyCode == keyCode)
                            {
                                EditorUtility.SetDirty(midiTweak.ConfigKeyBindings);

                                _inputBinding.AssignKeyBoardInput(keyCode);
                                ClearDuplicateKeyBindings(keyCode, _index);
                                midiTweak.EditorInputProcessor.StopListening();
                            }
                        }
                    }
                }

                if (midiTweak.EditorInputProcessor.LastConfirmedMidiKey != 0)
                {
                    EditorUtility.SetDirty(midiTweak.ConfigKeyBindings);

                    _inputBinding.AssignMidiInput(midiTweak.EditorInputProcessor.LastConfirmedMidiKey);
                    ClearDuplicateMidiBindings(midiTweak.EditorInputProcessor.LastConfirmedMidiKey, _index);
                    midiTweak.EditorInputProcessor.StopListening();
                }

                if (GUILayout.Button("Assigning", GUILayout.MinWidth(100)))
                {
                }
            }
            else
            {
                if (_inputBinding.HasAssignedInput() == false)
                {
                    if (GUILayout.Button("Assign", GUILayout.MinWidth(100)))
                    {
                        midiTweak.EditorInputProcessor.StartListeningForInput(EInputType.KeyboardMidi, EInputTarget.MidiButton, _inputBinding);
                    }
                }
                else
                {
                    if (GUILayout.Button("UnAssign", GUILayout.MinWidth(100)))
                    {
                        EditorUtility.SetDirty(midiTweak.ConfigKeyBindings);

                        _inputBinding.ClearInput();
                    }
                }
            }

            GUILayout.EndHorizontal();
        }