Exemple #1
0
        public override void Draw(GUIEvent guievent)
        {
            var rect = new Vector4(0, 0, 500, 150).CenterPos(GUI.Context.baseRect.Size());

            GUILayout.BeginArea(rect, GUIStyle.Current.DockContentColor, GUIOption.Border(null));
            {
                rect.W = GUILayout.s_svLineHeight;
                GUI.Rect(rect, GUIStyle.Current.ColorActiveD);
                GUILayout.Text(title);
                GUILayout.Text(info, (Vector4?)null, GUIOption.Width(480));

                var off = GUILayout.s_ctx.currentLayout.Offset;

                GUILayout.Space(120 - off.Y);

                bool hascancel = m_callbackCancel != null;
                GUILayout.BeginHorizontal();
                if (!hascancel)
                {
                    GUILayout.Indent(200);
                    if (GUILayout.Button(buttonConfirm, GUIOption.Width(100), GUIOption.Border()))
                    {
                        if (m_callbackConfirm != null)
                        {
                            m_callbackConfirm.Invoke();
                        }
                        OnDestroy();
                    }
                }
                else
                {
                    GUILayout.Indent(150);
                    if (GUILayout.Button(buttonConfirm, GUIOption.Width(100), GUIOption.Border()))
                    {
                        if (m_callbackConfirm != null)
                        {
                            m_callbackConfirm.Invoke();
                        }
                        OnDestroy();
                    }
                    if (GUILayout.Button(buttonCancel, GUIOption.Width(100), GUIOption.Border()))
                    {
                        if (m_callbackCancel != null)
                        {
                            m_callbackCancel.Invoke();
                        }
                        OnDestroy();
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
        }
Exemple #2
0
        public sealed override void Draw(GUIEvent guievent)
        {
            var rect = new Vector4(0, 0, m_size.X, m_size.Y).CenterPos(GUI.Context.baseRect.Size());

            GUILayout.BeginArea(rect, GUIStyle.Current.BackgroundColor, GUIOption.Border());

            GUILayout.Text(m_title);

            OnDraw();

            GUILayout.EndArea();
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="scrolltype"></param>
        /// <param name="options">GUIOption.With GUIOption.Height</param>
        /// <returns></returns>
        public static Vector2 BeginScrollView(Vector2 pos, GUIScrollType scrolltype = GUIScrollType.Vertical, params GUIOption[] options)
        {
            GUIOption optWidth  = null;
            GUIOption optHeight = null;

            if (options != null)
            {
                foreach (var opt in options)
                {
                    if (opt.type == GUIOption.GUIOptionType.width)
                    {
                        optWidth = opt; continue;
                    }
                    if (opt.type == GUIOption.GUIOptionType.height)
                    {
                        optHeight = opt; continue;
                    }
                }
            }

            var sizeremain = SizeRemain;

            if (optWidth != null)
            {
                sizeremain.X = optWidth.IntValue;
            }
            if (optHeight != null)
            {
                sizeremain.Y = optHeight.IntValue;
            }

            var rect       = new Vector4(s_ctx.currentLayout.Offset, sizeremain.X, sizeremain.Y);
            var rectab     = GetRectAbsolute(rect);
            var scrollView = GUI.GetScrollView(rectab);

            BeginContainer(rectab, null, GUIOption.Border(GUIStyle.Current.BackgroundColorS));

            return(scrollView.Draw(rectab, pos, scrolltype));
        }
Exemple #4
0
        private void SampleText()
        {
            m_sampleTextTabIndex = GUILayout.TabView(m_sampleTextTabIndex, m_sampleTextTabList, (index) =>
            {
                if (index == 0)
                {
                    //GUI
                    GUILayout.Text("GUI.DrawChar");
                    var rect = GUI.GetRectAbsolute(new Vector4(5, 30, 20, 20));
                    GUI.RectA(rect, RigelColor.White);
                    GUI.TextA(rect, new Vector2(-3, -3), "R", RigelColor.Black);
                    rect.X += 25;
                    GUI.RectA(rect, RigelColor.White);
                    GUI.TextA(rect, new Vector2(13, 10), "R", RigelColor.Black);

                    GUILayout.Space(30);

                    GUILayout.Text("GUI.DrawTextA");

                    rect = new Vector4(rect.X - 25, rect.Y + 50, 50, 30);
                    GUI.RectA(rect, RigelColor.White);
                    GUI.TextA(rect, new Vector2(-5, -3), "ABCDEFGHI", RigelColor.Black);
                    GUI.TextA(rect, new Vector2(5, 20), "ZXVBNMGHGJ", RigelColor.Black);

                    GUILayout.Space(35);

                    GUILayout.Text("GUI.DrawText (With Group)");
                    GUI.BeginGroup(new Vector4(5, 140, 135, 50), RigelColor.White);
                    {
                        GUI.Text(new Vector4(-10, -3, 140, 30), "HELLOWORLD!", GUIStyle.Current.ColorActive);
                        var rectg = new Vector4(50, 20, 100, 25);
                        GUI.Rect(rectg, RigelColor.Black);
                        GUI.Text(rectg, "HELLO WORLD!", GUIStyle.Current.ColorActive);
                    }
                    GUI.EndGroup();

                    //GUILayout
                    GUILayout.Space(55);
                    GUILayout.Text("GUILayout Text");
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Text("DefaultText");
                        GUILayout.Text("Text with Border", null, null, 3, GUIOption.Border(GUIStyle.Current.ColorActiveD));
                        GUILayout.Text("TextWithColor", GUIStyle.Current.ColorActiveD);
                        GUILayout.Text("TextWithBG", GUI.Context.Color, GUIStyle.Current.ColorActiveD);
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.Text("Text Width");
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Text("100px", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100));
                        GUILayout.Text("50px", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(50));
                        GUILayout.Text("20px", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(10));
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.Text("Horizontal Alignment");
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Text("Align Center", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignHCenter);
                        GUILayout.Text("Align Center", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignHLeft);
                        GUILayout.Text("Align Right", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignHRight);
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.Text("Vertical Alignment");
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.SetLineHeight(30);
                        GUILayout.Text("Line Height 30", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignHCenter);

                        GUILayout.Text("Align Top", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignVTop);
                        GUILayout.Text("Align Center", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignVCenter);
                        GUILayout.Text("Align Bottom", GUI.Context.Color, GUIStyle.Current.ColorActiveD, GUIOption.Width(100), GUIOption.AlignVBottom);

                        GUILayout.RestoreLineHeight();
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.TextBlock(m_sampleLongText);
                }
            });
        }
Exemple #5
0
        public sealed override void Draw(GUIEvent guievent)
        {
            m_hedaerRect.Z = m_size.X;
            m_pos.X        = (int)m_pos.X;
            m_pos.Y        = (int)m_pos.Y;

            var rect = new Vector4(m_pos, m_size.X, m_size.Y);

            GUILayout.BeginContainer(rect, GUIStyle.Current.BackgroundColor, GUIOption.Border());
            {
                bool headerover = GUIUtility.RectContainsCheck(GUILayout.GetRectAbsolute(m_hedaerRect), GUI.Event.Pointer);
                GUILayout.Rect(m_hedaerRect, headerover ? GUIStyle.Current.ColorActive : GUIStyle.Current.ColorActiveD);
                GUILayout.BeginHorizontal();
                GUILayout.Text(m_title);
                if (m_dialogCloseable)
                {
                    GUILayout.Indent((int)(rect.Z - GUILayout.CurrentLayout.Offset.X - 24));
                    if (GUILayout.Button("X", GUIStyle.Current.ColorActiveD, GUIOption.Width(23)))
                    {
                        OnDestroy();
                    }
                }
                GUILayout.EndHorizontal();

                var contentrect = GUILayout.Context.currentArea.Rect;
                contentrect.Y += m_hedaerRect.W;
                contentrect.Z -= 1;
                contentrect.W -= (m_hedaerRect.W + 1);

                GUILayout.BeginContainer(contentrect);
                {
                    OnDraw();
                }
                GUILayout.EndContainer();

                //for optimize
                bool onmove = false;
                if (m_dialogMoveable && m_dragMove.OnDrag(headerover))
                {
                    m_pos += GUI.Event.DragOffset;

                    m_pos.X = Mathf.Clamp(m_pos.X, 0, GUI.Context.baseRect.Z);
                    m_pos.Y = Mathf.Clamp(m_pos.Y, 0, GUI.Context.baseRect.W);
                    onmove  = true;
                }
                if (m_dialogRezieable && !onmove)
                {
                    var rectResize = GUILayout.Context.currentArea.Rect;
                    rectResize.Y += (rectResize.W - 3);
                    rectResize.X += rectResize.Z - 3;
                    rectResize.Z  = 6;
                    rectResize.W  = 6;

                    if (m_dragResizeHV.OnDrag(rectResize))
                    {
                        m_size  += GUI.Event.DragOffset;
                        m_size.Y = Mathf.Clamp(m_size.Y, m_dialogMinSize.Y, m_dialogMaxSize.Y);
                        m_size.X = Mathf.Clamp(m_size.X, m_dialogMinSize.X, m_dialogMaxSize.X);
                    }
                }
            }

            //var grect = new Vector4(0, 0, 100, 30);
            //GUI.DrawRect(grect, RigelColor.Green);
            //GUI.DrawText(grect, "GUITEXT", RigelColor.White);
            //GUI.Button(grect, "GUIBUTTON");
            //GUI.DrawBorder(grect, 2, RigelColor.Green);

            GUILayout.EndContainer();
        }