Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            serialized.Update();
            Color prev_color = GUI.backgroundColor;

            GUILayout.Space(5f);
            Rect           rect       = GUILayoutUtility.GetRect(200, 60, GUILayout.ExpandWidth(true));
            HelmController controller = target as HelmController;

            if (keyboard.DoKeyboardEvents(rect, controller))
            {
                Repaint();
            }

            keyboard.DrawKeyboard(rect, controller.GetPressedNotes());
            GUILayout.Space(5f);
            GUI.backgroundColor = prev_color;

            EditorGUILayout.IntSlider(channel, 0, Utils.kMaxChannels - 1);
            GUILayout.Space(5f);

            float height       = parameterList.GetHeight(controller);
            Rect  keyzonesRect = GUILayoutUtility.GetRect(minWidth, height, GUILayout.ExpandWidth(true));

            parameterList.DrawParameters(keyzonesRect, controller, serialized);
            GUILayout.Space(10.0f);
            serialized.ApplyModifiedProperties();
        }
Ejemplo n.º 2
0
 public HelmParameter(HelmController par, Param param)
 {
     parent    = par;
     parameter = param;
     if (scaleType == ScaleType.kByPercent)
     {
         paramValue_ = parent.GetParameterPercent(parameter);
     }
     else
     {
         paramValue_ = parent.GetParameterValue(parameter);
     }
 }
Ejemplo n.º 3
0
        public void DrawParameters(Rect rect, HelmController controller, SerializedObject serialized)
        {
            GUI.BeginGroup(rect);
            DrawParameterList(controller, serialized, rect.width);
            Rect buttonRect = new Rect(rect.width / 4, 0, rect.width / 2, addButtonHeight);

            if (GUI.Button(buttonRect, "Add Parameter Control"))
            {
                Undo.RecordObject(controller, "Add Parameter Control");
                controller.AddEmptyParameter();
            }

            GUI.EndGroup();
        }
Ejemplo n.º 4
0
        int GetChannel()
        {
            HelmController controller = GetComponent <HelmController>();

            if (controller)
            {
                return(controller.channel);
            }

            HelmSequencer sequencer = GetComponent <HelmSequencer>();

            if (sequencer)
            {
                return(sequencer.channel);
            }

            return(0);
        }
Ejemplo n.º 5
0
 public HelmParameter(HelmController par)
 {
     parent = par;
 }
Ejemplo n.º 6
0
 public HelmParameter()
 {
     parent = null;
 }
Ejemplo n.º 7
0
        void DrawParameterList(HelmController controller, SerializedObject serialized, float width)
        {
            GUIStyle style = new GUIStyle(GUI.skin.button);

            style.padding  = new RectOffset(0, 0, 0, 0);
            style.fontSize = buttonHeight - 4;
            int y       = addButtonHeight + sliderBuffer;
            int extra_y = (rowHeight - buttonHeight) / 3;

            HelmParameter remove = null;

            int paramIndex = 0;

            foreach (HelmParameter synthParameter in controller.synthParameters)
            {
                Rect buttonRect = new Rect(0, y + extra_y, buttonHeight, buttonHeight);
                Rect paramRect  = new Rect(buttonRect.xMax, y + extra_y, parameterWidth, buttonHeight);
                Rect scaleRect  = new Rect(paramRect.xMax, y + extra_y, scaleWidth, buttonHeight);
                Rect sliderRect = new Rect(scaleRect.xMax + sliderBuffer, y + extra_y,
                                           width - scaleRect.xMax - sliderBuffer, buttonHeight);

                if (GUI.Button(buttonRect, "X", style))
                {
                    remove = synthParameter;
                }

                Param param = (Param)EditorGUI.EnumPopup(paramRect, synthParameter.parameter);
                HelmParameter.ScaleType scale = (HelmParameter.ScaleType)EditorGUI.EnumPopup(scaleRect, synthParameter.scaleType);

                if (param != synthParameter.parameter)
                {
                    Undo.RecordObject(controller, "Change Parameter Control");
                    synthParameter.parameter = param;

                    if (scale == HelmParameter.ScaleType.kByPercent)
                    {
                        controller.SetParameterAtIndex(paramIndex, controller.GetParameterPercent(param));
                    }
                    else
                    {
                        controller.SetParameterAtIndex(paramIndex, controller.GetParameterValue(param));
                    }
                }

                if (scale != synthParameter.scaleType)
                {
                    Undo.RecordObject(controller, "Change Parameter Scale Type");
                    synthParameter.scaleType = scale;
                    float min = synthParameter.GetMinimumRange();
                    float max = synthParameter.GetMaximumRange();
                    float val = controller.GetParameterAtIndex(paramIndex);

                    if (synthParameter.scaleType == HelmParameter.ScaleType.kByPercent)
                    {
                        val = Mathf.Clamp((val - min) / (max - min), 0.0f, 1.0f);
                    }
                    else
                    {
                        val = Mathf.Lerp(min, max, val);
                    }

                    controller.SetParameterAtIndex(paramIndex, val);
                }

                SerializedProperty paramProperty = serialized.FindProperty("synthParamValue" + paramIndex);

                if (synthParameter.scaleType == HelmParameter.ScaleType.kByPercent)
                {
                    EditorGUI.Slider(sliderRect, paramProperty, 0.0f, 1.0f, "");
                }
                else
                {
                    EditorGUI.Slider(sliderRect, paramProperty,
                                     synthParameter.GetMinimumRange(), synthParameter.GetMaximumRange(), "");
                }

                y += rowHeight;

                paramIndex++;
            }

            if (remove != null)
            {
                Undo.RecordObject(controller, "Remove Parameter Control");
                controller.RemoveParameter(remove);
            }

            controller.UpdateAllParameters();
        }
Ejemplo n.º 8
0
 public int GetHeight(HelmController controller)
 {
     return(addButtonHeight + rowHeight * controller.synthParameters.Count + sliderBuffer);
 }
Ejemplo n.º 9
0
 // Start is called before the first frame update
 void Start()
 {
     controller = FindObjectOfType <AudioHelm.HelmController>();
 }