Example #1
0
        // automatically builds the node window
        protected void buildGUI(string lbl)
        {
            setColor();

            if (TangyTexturesEditor.mouseUp != true)
            {
                if (Event.current.type == EventType.MouseUp)
                {
                    TangyTexturesEditor.mouseUp = true;
                }
            }

            largeFont.fontSize         = LStyle.LargeFontSize;
            largeFont.normal.textColor = color;
            //setColor ();
            largeFont.alignment = TextAnchor.UpperCenter;
            labelSize           = 65;
            remainingSize       = (int)(rightSize.x - labelSize) - 5;
            float d = 30;                                     // pos of window

            if (GUI.Button(new Rect(d, 15, rightSize.x - 1.5f * d, 32), ""))
            {
                Verify();
                if (verified)
                {
                    // only allowed to click when not active
                    if (CNodeManager.status == CNodeManager.STATUS_NONE)
                    {
                        CNodeManager.status = status_after_click;

                        calculateProgressDelta(CNodeManager.size);
                        CNodeManager.calculator = this;
                    }
                }
                else
                {
                    CNodeManager.DisplayError(clickErrorMessage);
                }
            }
            size.y = 50;
            // main label
            if (debug)
            {
                lbl = "" + ID;
            }
            GUILayout.Label(lbl, largeFont, GUILayout.Width(rightSize.x));
            GUILayout.Space(5);
            if (displayParameters == null)
            {
                displayParameters = new List <Parameter> ();
                keys = rebuildDisplayParams();
            }
            int current = 0;

            foreach (Parameter p in displayParameters)
            {
                size.y += LStyle.FontSize;
                if (p.label == "")
                {
                    continue;
                }
                if (p.label.StartsWith("Color"))
                {
                    GUILayout.BeginHorizontal();                                                      // "Button" is cool!
                    displayColor.r = p.value;
                    displayColor.g = p.min;
                    displayColor.b = p.max;
//									displayColor = (Color)EditorGUILayout.ObjectField(p.label, displayColor, typeof(Color), false);
                    GUILayout.Label(p.label.Substring(5), GUILayout.Width(labelSize));
                    Color c = GUI.backgroundColor;
                    GUI.backgroundColor = Color.white;
                    displayColor        = EditorGUILayout.ColorField(displayColor, GUILayout.Width(remainingSize));
                    GUI.backgroundColor = c;
                    if (displayColor.r != p.value || displayColor.g != p.min || displayColor.b != p.max)
                    {
                        PropagateChange();
                    }
                    p.value = displayColor.r;
                    p.min   = displayColor.g;
                    p.max   = displayColor.b;


                    GUILayout.EndHorizontal();
                }
                else
                if (p.label.StartsWith("string"))
                {
                    string s2 = p.key;
                    if (s2 == null || s2.Length == 0)
                    {
                        s2 = keys[current];
                    }
                    GUILayout.Label(s2, GUILayout.Width(remainingSize + labelSize));

                    GUILayout.BeginHorizontal();                                                      // "Button" is cool!
                    string org = p.label;
                    string s   = p.label.Substring(6);

                    p.label = "string" + GUILayout.TextField(s, GUILayout.Width(remainingSize + labelSize));
                    if (!p.label.Equals(org))
                    {
                        PropagateChange();
                    }
                    GUILayout.EndHorizontal();
                }

                else
                {
                    GUILayout.BeginHorizontal();                                                      // "Button" is cool!
                    GUILayout.Label(" " + p.label, GUILayout.Width(labelSize));
                    float f = p.value;
                    p.value = GUILayout.HorizontalSlider(p.value, p.min, p.max, GUILayout.Width(remainingSize - 28));
                    GUILayout.Label("" + p.value, GUILayout.Width(28));

                    if (p.value != f)
                    {
                        PropagateChange();
                    }

                    GUILayout.EndHorizontal();
                }
                current++;
            }
            if (types.Length > 1 && displayTypes)
            {
                int t = Type;
                size.y += LStyle.FontSize;
                Type    = EditorGUILayout.Popup(Type, types, GUILayout.Width(rightSize.x));
                if (t != Type)
                {
                    PropagateChange();
                    CNodeManager.mouseUp = true;
                    //Debug.Log (t + " and " + Type);
                }
            }

            // close and help buttons
            if (GUI.Button(new Rect(rightSize.x - 20, 15, 25, 32), "X"))
            {
                CNodeManager.deleteNode(this);
            }
            if (GUI.Button(new Rect(5, 15, 25, 32), "?"))
            {
                HelpEditor.Create(helpMessage);
            }
            window.height = size.y;
        }
Example #2
0
 void About()
 {
     HelpEditor.Create(aboutMessage);
 }