Exemplo n.º 1
0
        public override string Show()
        {
            XJGUILayout.VerticalLayout(() =>
            {
                base.ShowTitle();

                XJGUILayout.HorizontalLayout(() =>
                {
                    int x = this.intGUIX.Show();

                    GUILayout.Label(".");

                    int y = this.intGUIY.Show();

                    GUILayout.Label(".");

                    int z = this.intGUIZ.Show();

                    GUILayout.Label(".");

                    int w = this.intGUIW.Show();

                    base.Value = x + "." + y + "." + z + "." + w;
                });
            });

            return(this.Value);
        }
Exemplo n.º 2
0
        public override string Show(string value)
        {
            int[] values = ParseIPv4Text(value);

            XJGUILayout.VerticalLayout(() =>
            {
                base.ShowTitle();

                XJGUILayout.HorizontalLayout(() =>
                {
                    value  = this.intGUIX.Show(values[0]).ToString();
                    value += ".";

                    GUILayout.Label(".");

                    value += this.intGUIY.Show(values[1]);
                    value += ".";

                    GUILayout.Label(".");

                    value += this.intGUIZ.Show(values[2]);
                    value += ".";

                    GUILayout.Label(".");

                    value += this.intGUIW.Show(values[3]);
                });
            });

            return(value);
        }
Exemplo n.º 3
0
        public virtual bool Show(params Action[] show)
        {
            // NOTE:
            // (value = true  && button = true)  => false
            // (value = true  && button = false) => true
            // (value = false && button = true)  => true
            // (value = false && button = false) => false

            XJGUILayout.VerticalLayout(() =>
            {
                string buttonContent = (this.value ? "\u25BC " : "\u25BA ") + base.Title;

                this.value = !(this.value == GUILayout.Button(buttonContent, TitleStyle));

                if (this.value)
                {
                    XJGUILayout.VerticalLayout(() =>
                    {
                        for (int i = 0; i < show.Length; i++)
                        {
                            show[i]();
                        }
                    });
                }
            }, this.value ? GUI.skin.box : null);

            return(this.value);
        }
Exemplo n.º 4
0
        public override T Show(T value)
        {
            Type enumType = value.GetType();

            string[] enumNames     = Enum.GetNames(enumType);
            int      selectedIndex = GetSelectedIndex(value, enumNames);

            XJGUILayout.HorizontalLayout(() =>
            {
                base.ShowTitle();

                if (this.Width > 0)
                {
                    GUILayout.FlexibleSpace();
                }

                if (GUILayout.Button(enumNames[selectedIndex],
                                     this.ButtonStyle,
                                     this.ButtonLayout))
                {
                    this.isEditing = !this.isEditing;
                }
            });

            if (!this.isEditing)
            {
                return(value);
            }

            XJGUILayout.HorizontalLayout(() =>
            {
                if (this.Width > 0)
                {
                    GUILayout.FlexibleSpace();
                }

                XJGUILayout.VerticalLayout(() =>
                {
                    for (int i = 0; i < enumNames.Length; i++)
                    {
                        if (i == selectedIndex)
                        {
                            continue;
                        }

                        if (GUILayout.Button(enumNames[i], ButtonLayout))
                        {
                            this.isEditing = false;
                            value          = (T)Enum.Parse(enumType, enumNames[i]);
                        }
                    }
                }, GUI.skin.box);
            });

            return(value);
        }
Exemplo n.º 5
0
        public override T Show()
        {
            XJGUILayout.HorizontalLayout(() =>
            {
                base.ShowTitle();

                if (this.ButtonWidth > 0)
                {
                    GUILayout.FlexibleSpace();
                }

                if (GUILayout.Button(this.enumNames[this.selectedIndex],
                                     this.ButtonStyle,
                                     this.ButtonLayout))
                {
                    this.isEditing = !this.isEditing;
                }
            });

            if (!this.isEditing)
            {
                return(Value);
            }

            XJGUILayout.HorizontalLayout(() =>
            {
                if (this.ButtonWidth > 0)
                {
                    GUILayout.FlexibleSpace();
                }

                XJGUILayout.VerticalLayout(() =>
                {
                    for (int i = 0; i < this.enumNames.Length; i++)
                    {
                        if (i == this.selectedIndex)
                        {
                            continue;
                        }

                        if (GUILayout.Button(this.enumNames[i], ButtonLayout))
                        {
                            this.selectedIndex = i;
                            this.isEditing     = false;
                            base.Value         = (T)Enum.Parse(this.enumType, this.enumNames[i]);
                        }
                    }
                }, GUI.skin.box);
            });

            return(this.Value);
        }
Exemplo n.º 6
0
        public override float Show()
        {
            InitializeGUIStyle();

            XJGUILayout.VerticalLayout(() =>
            {
                // TextField

                XJGUILayout.HorizontalLayout(() =>
                {
                    base.ShowTitle(this.FieldWidth > 0 && base.Title == null);

                    UpdateTextFieldColor();

                    this.text = GUILayout.TextField
                                    (this.text, ValueGUI <float> .TextFieldStyle,
                                    base.FieldWidth <= 0 ? GUILayout.ExpandWidth(true)
                                                     : GUILayout.Width(base.FieldWidth));

                    // NOTE:
                    // float.TryParse("0.") return true.
                    // But need to keep user input text, because the user may input "0.x~".

                    float textFieldValue;

                    if (float.TryParse(this.text, out textFieldValue))
                    {
                        base.value = CorrectValue(textFieldValue);
                    }
                });

                // Slider

                if (!base.WithSlider)
                {
                    return;
                }

                // NOTE:
                // Need to update text when the value is updated with Slider.

                float sliderValue = (float)GUILayout.HorizontalSlider(this.Value, base.MinValue, base.MaxValue);

                if (sliderValue != this.Value)
                {
                    this.Value = sliderValue;
                }
            });

            return(this.Value);
        }
Exemplo n.º 7
0
        public override T Show()
        {
            XJGUILayout.VerticalLayout(() =>
            {
                base.ShowTitle();

                XJGUILayout.HorizontalLayout(() =>
                {
                    ShowComponentGUI();
                });
            });

            return(this.Value);
        }
Exemplo n.º 8
0
        public override T Show(T value)
        {
            XJGUILayout.VerticalLayout(() =>
            {
                base.ShowTitle();

                XJGUILayout.HorizontalLayout(() =>
                {
                    value = ShowComponents(value);
                });
            });

            return(value);
        }
Exemplo n.º 9
0
        public override T Show()
        {
            if (this.values == null || this.values.Count == 0)
            {
                GUILayout.Label("Values has no item. Return value shows default.");

                base.value = default(T);

                return(default(T));
            }

            int index = this.values.IndexOf(base.value);

            if (base.value == null || index == -1)
            {
                index      = 0;
                base.value = this.values[0];
            }

            if (this.values.Count != this.labels.Length)
            {
                UpdateLabels();
            }

            XJGUILayout.VerticalLayout(() =>
            {
                int gridx = this.GridX <= 0 ? this.values.Count : this.GridX;

                if (this.Foldout)
                {
                    this.foldoutPanel.Show(() =>
                    {
                        index = GUILayout.SelectionGrid(index, this.labels, gridx);
                    });
                }
                else
                {
                    base.ShowTitle();

                    index = GUILayout.SelectionGrid(index, this.labels, gridx);
                }

                base.value = this.values[index];
            });

            return(base.value);
        }
Exemplo n.º 10
0
        public override T Show()
        {
            XJGUILayout.VerticalLayout(() =>
            {
                XJGUILayout.HorizontalLayout(() =>
                {
                    base.ShowTitle();

                    this.text = base.ShowTextField(this.text);

                    // NOTE:
                    // float.TryParse("0.") return true.
                    // But need to keep user input text, because the user may input "0.x~".

                    float textValue;

                    if (float.TryParse(this.text, out textValue))
                    {
                        base.Value = (T)Convert.ChangeType(textValue, typeof(T));
                    }
                });

                if (!base.WithSlider)
                {
                    return;
                }

                // NOTE:
                // Need to update text when the value is updated with Slider.

                float value    = (float)Convert.ChangeType(base.Value, typeof(float));
                float minValue = (float)Convert.ChangeType(base.MinValue, typeof(float));
                float maxValue = (float)Convert.ChangeType(base.MaxValue, typeof(float));

                float sliderValue = GUILayout.HorizontalSlider(value, minValue, maxValue);

                T sliderValueT = (T)Convert.ChangeType(sliderValue, typeof(T));

                if (!sliderValueT.Equals(base.Value))
                {
                    this.Value = sliderValueT;
                }
            });

            return(base.Value);
        }
Exemplo n.º 11
0
        public virtual int Show(params Func[] show)
        {
            var labels = new string[show.Length];

            for (int i = 0; i < labels.Length; i++)
            {
                labels[i] = show[i].label;
            }

            XJGUILayout.VerticalLayout(() =>
            {
                base.ShowTitle();

                base.Value = GUILayout.Toolbar(base.Value, labels, TabStyle);

                show[base.Value].show();
            }, GUI.skin.box);

            return(base.Value);
        }
Exemplo n.º 12
0
        public override int Show(params Action[] guiAction)
        {
            if (TabPanel.ButtonStyle == null)
            {
                TabPanel.ButtonStyle = new GUIStyle(GUI.skin.button);

                TabPanel.ButtonStyle.onNormal.background
                    = XJGUILayout.Generate1x1Texture(Color.clear);
            }

            XJGUILayout.VerticalLayout((Action)(() =>
            {
                base.ShowTitle();

                base.Value = GUILayout.Toolbar(base.Value, this.Labels, TabPanel.ButtonStyle);

                guiAction[base.Value]();
            }));

            return(base.Value);
        }
Exemplo n.º 13
0
        public override bool Show(params Action[] guiActions)
        {
            if (FoldoutPanel.ButtonStyle == null)
            {
                FoldoutPanel.ButtonStyle = new GUIStyle(GUI.skin.label);
            }

            FoldoutPanel.ButtonStyle.fontStyle        = base.boldTitle ? FontStyle.Bold : FontStyle.Normal;
            FoldoutPanel.ButtonStyle.normal.textColor = base.TitleColor == null ?
                                                        GUI.skin.label.normal.textColor : (Color)base.TitleColor;

            // NOTE:
            // (value = true  && button = true)  => false
            // (value = true  && button = false) => true
            // (value = false && button = true)  => true
            // (value = false && button = false) => false

            XJGUILayout.VerticalLayout(() =>
            {
                string buttonContent = (base.Value ? "\u25BC " : "\u25BA ") + base.Title;

                base.Value = !(base.Value == GUILayout.Button(buttonContent, FoldoutPanel.ButtonStyle));

                if (base.Value)
                {
                    XJGUILayout.VerticalLayout(() =>
                    {
                        for (int i = 0; i < guiActions.Length; i++)
                        {
                            guiActions[i]();
                        }
                    });
                }
            }, base.Value ? GUI.skin.box : null);

            return(base.Value);
        }
Exemplo n.º 14
0
        public override IList <T> Show()
        {
            if (this.Value != null && this.guis.Length != this.Value.Count)
            {
                UpdateGUIs();
            }

            XJGUILayout.VerticalLayout(() =>
            {
                if (this.Title != null)
                {
                    this.foldOutPanel.Show(delegate()
                    {
                        ShowComponentGUI();
                    });
                }
                else
                {
                    ShowComponentGUI();
                }
            });

            return(this.Value);
        }
Exemplo n.º 15
0
        public override T Show()
        {
            if (EnumGUI <T> .ButtonStyle == null)
            {
                EnumGUI <T> .ButtonStyle        = new GUIStyle(GUI.skin.button);
                EnumGUI <T> .ButtonStyle.normal = GUI.skin.button.active;
            }

            // Selected Element

            XJGUILayout.HorizontalLayout(() =>
            {
                base.ShowTitle();

                string buttonContent = this.enumNames[this.selectedIndex];
                GUIStyle buttonStyle = this.isEditing ? EnumGUI <T> .ButtonStyle : GUI.skin.button;

                if (this.ButtonWidth > 0)
                {
                    GUILayout.FlexibleSpace();
                }

                bool buttonPressed = this.ButtonWidth <= 0 ?
                                     GUILayout.Button(buttonContent, buttonStyle) :
                                     GUILayout.Button(buttonContent, buttonStyle, GUILayout.Width(this.ButtonWidth));

                if (buttonPressed)
                {
                    this.isEditing = !this.isEditing;
                }
            });

            if (!this.isEditing)
            {
                return(this.Value);
            }

            // Other Element

            XJGUILayout.HorizontalLayout(() =>
            {
                if (this.ButtonWidth > 0)
                {
                    GUILayout.FlexibleSpace();
                }

                XJGUILayout.VerticalLayout(() =>
                {
                    for (int i = 0; i < this.enumNames.Length; i++)
                    {
                        if (i == this.selectedIndex)
                        {
                            continue;
                        }

                        string buttonContent = this.enumNames[i];

                        bool buttonPressed = this.ButtonWidth <= 0 ?
                                             GUILayout.Button(buttonContent) :
                                             GUILayout.Button(buttonContent, GUILayout.Width(this.ButtonWidth));

                        if (buttonPressed)
                        {
                            this.selectedIndex = i;
                            this.isEditing     = false;
                            base.value         = (T)Enum.Parse(this.enumType, this.enumNames[i]);
                        }
                    }
                }, GUI.skin.box);
            });

            return(base.Value);
        }