Esempio n. 1
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);
        }
Esempio 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);
        }
Esempio n. 3
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);
        }
Esempio 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);
        }
Esempio n. 5
0
        public override string Show()
        {
            XJGUILayout.HorizontalLayout(() =>
            {
                base.ShowTitle();
                base.Value = base.ShowTextField(base.Value);
            });

            return(base.Value);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public override string Show()
        {
            XJGUILayout.HorizontalLayout(() =>
            {
                base.ShowTitle(this.FieldWidth > 0 && base.Title == null);

                base.Value = GUILayout.TextField
                                 (base.Value, this.FieldWidth <= 0 ? GUILayout.ExpandWidth(true)
                                                      : GUILayout.Width(this.FieldWidth));
            });

            return(base.Value);
        }
Esempio n. 8
0
        public override bool Show()
        {
            XJGUILayout.HorizontalLayout(() =>
            {
                base.ShowTitle(base.title == null);

                GUILayout.FlexibleSpace();

                base.Value = GUILayout.Toggle(base.Value, "");
            });

            return(base.Value);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        public override T Show(T value)
        {
            XJGUILayout.VerticalLayout(() =>
            {
                base.ShowTitle();

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

            return(value);
        }
Esempio n. 11
0
    void OnGUI()
    {
        #pragma warning disable 0219

        GUILayout.Label("Press [Return] to show/hide window.");

        this.window.Show(() =>
        {
            this.tabPanel.Show
                (new TabPanel.Func("Basic", () =>
            {
                this.boolValue   = this.boolGUI.Show();
                this.stringValue = this.stringGUI.Show();
                this.intValue    = this.intGUI.Show();
                this.floatValue  = this.floatGUI.Show();
            }),
                new TabPanel.Func("Vector & Matrix", () =>
            {
                this.foldoutPanel.Show(() =>
                {
                    this.vector2Value = this.vector2GUI.Show();
                    this.vector3Value = this.vector3GUI.Show();
                    this.vector4Value = this.vector4GUI.Show();
                });

                this.vector2IntValue = this.vector2IntGUI.Show();
                this.vector3IntValue = this.vector3IntGUI.Show();

                this.matrixValue = this.matrixGUI.Show();
            }),
                new TabPanel.Func("Others", () =>
            {
                this.colorValue = this.colorGUI.Show();
                this.ipv4Value  = this.ipv4GUI.Show();
                this.enumValue  = this.enumGUI.Show();

                this.scrollPanel.Show(() =>
                {
                    GUILayout.Box("BOX", GUILayout.Width(300), GUILayout.Height(300));

                    XJGUILayout.Label("Long Text, Long Text, Long Text, Long Text, Long Text, Long Text"
                                      + "Long Text, Long Text, Long Text, Long Text, Long Text, Long Text"
                                      + "Long Text, Long Text, Long Text, Long Text, Long Text, Long Text",
                                      XJGUILayout.LabelOption.NoWrap | XJGUILayout.LabelOption.Bold);
                });
            }));
        });

        #pragma warning restore 0219
    }
Esempio n. 12
0
        public override T Show()
        {
            XJGUILayout.VerticalLayout(() =>
            {
                base.ShowTitle();

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

            return(this.Value);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        public override Matrix4x4 Show(Matrix4x4 value)
        {
            this.foldoutPanel.Show(() =>
            {
                XJGUILayout.HorizontalLayout(() =>
                {
                    value.m00 = this.floatGUIM00.Show(value.m00);
                    value.m10 = this.floatGUIM10.Show(value.m10);
                    value.m20 = this.floatGUIM20.Show(value.m20);
                    value.m30 = this.floatGUIM30.Show(value.m30);
                });

                XJGUILayout.HorizontalLayout(() =>
                {
                    value.m01 = this.floatGUIM01.Show(value.m01);
                    value.m11 = this.floatGUIM11.Show(value.m11);
                    value.m21 = this.floatGUIM21.Show(value.m21);
                    value.m31 = this.floatGUIM31.Show(value.m31);
                });

                XJGUILayout.HorizontalLayout(() =>
                {
                    value.m02 = this.floatGUIM02.Show(value.m02);
                    value.m12 = this.floatGUIM12.Show(value.m12);
                    value.m22 = this.floatGUIM22.Show(value.m22);
                    value.m32 = this.floatGUIM32.Show(value.m32);
                });

                XJGUILayout.HorizontalLayout(() =>
                {
                    value.m03 = this.floatGUIM03.Show(value.m03);
                    value.m13 = this.floatGUIM13.Show(value.m13);
                    value.m23 = this.floatGUIM23.Show(value.m23);
                    value.m33 = this.floatGUIM33.Show(value.m33);
                });
            });

            return(value);
        }
Esempio n. 18
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);
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
 public override int Show(int value)
 {
     XJGUILayout.Label("UnSupported : " + base.Title);
     return(-1);
 }
Esempio n. 21
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);
        }
Esempio n. 22
0
    private void OnGUI()
    {
        this.flexibleWindow.Show(() =>
        {
            if (UNetworkManager.singleton.NetworkType == UNetworkManager.UNetType.None)
            {
                GUILayout.Label("Connection Settings");

                UNetworkManager.singleton.networkAddress = this.ipV4GUI.Show(UNetworkManager.singleton.networkAddress);
                UNetworkManager.singleton.networkPort    = this.portGUI.Show(UNetworkManager.singleton.networkPort);

                GUILayout.Label("Start");

                XJGUILayout.HorizontalLayout(() =>
                {
                    if (GUILayout.Button("Start as Server"))
                    {
                        UNetworkManager.singleton.StartServerSafe();
                    }
                    ;

                    if (GUILayout.Button("Start as Host"))
                    {
                        UNetworkManager.singleton.StartHostSafe();
                    }
                    ;

                    if (GUILayout.Button("Start as Client"))
                    {
                        UNetworkManager.singleton.StartClientSafe();
                    }
                    ;
                });

                UNetworkManager.singleton.autoStart     = this.autoStartGUI.Show(UNetworkManager.singleton.autoStart);
                UNetworkManager.singleton.autoStartType = this.autoStartTypeGUI.Show(UNetworkManager.singleton.autoStartType);

                XJGUILayout.HorizontalLayout(() =>
                {
                    GUILayout.Label("Auto Start After : ");
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(UNetworkManager.singleton.AutoStartIntervalTick.ToString("00.00"));
                });
            }

            else
            {
                GUILayout.Label("Connection Type");
                GUILayout.Label(UNetworkManager.singleton.NetworkType.ToString());

                GUILayout.Label("Connection Info");
                GUILayout.Label("Address : " + UNetworkManager.singleton.networkAddress);
                GUILayout.Label("Port : " + UNetworkManager.singleton.networkPort);

                if (GUILayout.Button("Stop Connection"))
                {
                    UNetworkManager.singleton.Stop();
                }
            }

            GUILayout.Label("Status");

            foreach (UNetworkManager.StatusMessage statusMessage
                     in UNetworkManager.singleton.StatusMessages)
            {
                GUILayout.Label(statusMessage.time.ToLongTimeString() + " - " + statusMessage.message);
            }
        });
    }
Esempio n. 23
0
        public override Matrix4x4 Show()
        {
            this.foldoutPanel.Show(() =>
            {
                XJGUILayout.HorizontalLayout(() =>
                {
                    this.floatGUIM00.Show();
                    this.floatGUIM10.Show();
                    this.floatGUIM20.Show();
                    this.floatGUIM30.Show();
                });

                XJGUILayout.HorizontalLayout(() =>
                {
                    this.floatGUIM01.Show();
                    this.floatGUIM11.Show();
                    this.floatGUIM21.Show();
                    this.floatGUIM31.Show();
                });

                XJGUILayout.HorizontalLayout(() =>
                {
                    this.floatGUIM02.Show();
                    this.floatGUIM12.Show();
                    this.floatGUIM22.Show();
                    this.floatGUIM32.Show();
                });

                XJGUILayout.HorizontalLayout(() =>
                {
                    this.floatGUIM03.Show();
                    this.floatGUIM13.Show();
                    this.floatGUIM23.Show();
                    this.floatGUIM33.Show();
                });
            });

            base.Value = new Matrix4x4()
            {
                m00 = this.floatGUIM00.Value,
                m10 = this.floatGUIM10.Value,
                m20 = this.floatGUIM20.Value,
                m30 = this.floatGUIM30.Value,

                m01 = this.floatGUIM01.Value,
                m11 = this.floatGUIM11.Value,
                m21 = this.floatGUIM21.Value,
                m31 = this.floatGUIM31.Value,

                m02 = this.floatGUIM02.Value,
                m12 = this.floatGUIM12.Value,
                m22 = this.floatGUIM22.Value,
                m32 = this.floatGUIM32.Value,

                m03 = this.floatGUIM03.Value,
                m13 = this.floatGUIM13.Value,
                m23 = this.floatGUIM23.Value,
                m33 = this.floatGUIM33.Value,
            };

            return(base.Value);
        }