Пример #1
0
    public static void RenderHelpWindow()
    {
        if (itsOpenModule != null)
        {
            int aWidth  = 512 + (int)KGFGUIUtility.GetSkinHeight() * 2;
            int aHeight = 256 + (int)KGFGUIUtility.GetSkinHeight() * 7;

            Rect aRect = new Rect((Screen.width - aWidth) / 2, (Screen.height - aHeight) / 2, aWidth, aHeight);

            KGFGUIUtility.Window(12345689, aRect, RenderHelpWindowMethod, itsOpenModule.GetName() + " (part of KOLMICH Game Framework)");

            if (aRect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                itsOpenModule = null;
            }
        }
        else
        {
            itsOpenModule = null;
        }
    }
Пример #2
0
    private void DrawCurrentCustomGUI(float aCustomGuiWidth)
    {
        if (itsCurrentSelectedGUI == null)
        {
            return;
        }

        float aHeight = KGFGUIUtility.GetSkinHeight() + KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).margin.vertical + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.vertical;

        GUILayout.BeginArea(new Rect(aHeight, aHeight, Screen.width - aCustomGuiWidth - aHeight, Screen.height - aHeight * 2.0f));
        {
            KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBox);
            {
                if (itsCurrentSelectedGUI.GetIcon() == null)
                {
                    KGFGUIUtility.BeginWindowHeader(itsCurrentSelectedGUI.GetHeaderName(), itsDataModuleCustomGUI.itsUnknownIcon);
                }
                else
                {
                    KGFGUIUtility.BeginWindowHeader(itsCurrentSelectedGUI.GetHeaderName(), itsCurrentSelectedGUI.GetIcon());
                }
                GUILayout.FlexibleSpace();
                bool aClose = KGFGUIUtility.EndWindowHeader(true);

                //Draw the content
                if (!aClose)
                {
                    // hack to keep the window in min size
                    GUILayout.Space(0);
                    itsCurrentSelectedGUI.Render();
                }
                else
                {
                    itsCurrentSelectedGUI = null;
                }
            }
            KGFGUIUtility.EndVerticalBox();
        }
        GUILayout.EndArea();
    }
Пример #3
0
    public static void Render()
    {
        if (itsInstance != null && itsInstance.itsDataModuleCustomGUI.itsBarVisible)
        {
            if (itsCustomGUIImplementations.Count == 0)
            {
                return;
            }

            GUIStyle aTogglStyle = KGFGUIUtility.GetStyleToggl(KGFGUIUtility.eStyleToggl.eTogglRadioStreched);
            GUIStyle aBoxStyle   = KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
            int      aWidth      = (int)(aTogglStyle.contentOffset.x + aTogglStyle.padding.horizontal + (KGFGUIUtility.GetSkinHeight() - aTogglStyle.padding.vertical));
            int      aHeight     = (int)(aBoxStyle.margin.top + aBoxStyle.margin.bottom + aBoxStyle.padding.top + aBoxStyle.padding.bottom
                                         + (aTogglStyle.fixedHeight + aTogglStyle.margin.top) * itsCustomGUIImplementations.Count);
            //(int)(aTogglStyle.margin.bottom + aBoxStyle.margin.vertical + aBoxStyle.padding.vertical);
            //(aTogglStyle.fixedHeight + aTogglStyle.margin.top) * itsCustomGUIImplementations.Count)

            GUILayout.BeginArea(new Rect(Screen.width - aWidth, (Screen.height - aHeight) / 2, aWidth, aHeight));
            {
                KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                {
                    GUILayout.FlexibleSpace();

                    foreach (KGFICustomGUI aCustomGUI in itsCustomGUIImplementations)
                    {
                        bool aValue;

                        if (itsCurrentSelectedGUI != null && itsCurrentSelectedGUI == aCustomGUI)
                        {
                            aValue = true;
                        }
                        else
                        {
                            aValue = false;
                        }

                        Texture2D aIcon = aCustomGUI.GetIcon();

                        if (aIcon == null)
                        {
                            aIcon = itsInstance.itsDataModuleCustomGUI.itsUnknownIcon;
                        }

                        if (aValue != KGFGUIUtility.Toggle(aValue, aIcon, KGFGUIUtility.eStyleToggl.eTogglRadioStreched))
                        {
                            if (aValue)
                            {
                                itsCurrentSelectedGUI = null;
                            }
                            else
                            {
                                itsCurrentSelectedGUI = aCustomGUI;
                            }
                        }
                    }

                    GUILayout.FlexibleSpace();
                }
                KGFGUIUtility.EndVerticalBox();

                //Draw the Custom GUI
                if (itsCurrentSelectedGUI != null)
                {
                    itsWindowRectangle = KGFGUIUtility.Window(0, itsWindowRectangle, itsInstance.DrawCurrentCustomGUI, itsCurrentSelectedGUI.GetName(), GUILayout.MinHeight(200), GUILayout.MinWidth(300));

                    // check if the window is still visible in screen
                    if (itsWindowRectangle.x < -itsWindowRectangle.width + 20)
                    {
                        itsWindowRectangle.x = -itsWindowRectangle.width + 20;
                    }
                    else if (itsWindowRectangle.x > Screen.width - 20)
                    {
                        itsWindowRectangle.x = Screen.width - 20;
                    }

                    if (itsWindowRectangle.y < -itsWindowRectangle.height + 20)
                    {
                        itsWindowRectangle.y = -itsWindowRectangle.height + 20;
                    }
                    else if (itsWindowRectangle.y > Screen.height - 20)
                    {
                        itsWindowRectangle.y = Screen.height - 20;
                    }
                }
            }
            GUILayout.EndArea();

            #region old render code

            /*
             *
             * float aButtonSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             * float aButtonSpaceVertical = Math.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             * int aBoxSpaceHorizontal = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.horizontal + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.horizontal, 24);
             * int aBoxSpaceVertical = Math.Max(KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).margin.vertical + KGFGUIUtility.GetStyleBox(KGFGUIUtility.eStyleBox.eBoxDecorated).padding.vertical, 24);
             *
             * GUILayout.BeginArea(new Rect(Screen.width - (aBoxSpaceHorizontal + aButtonSpaceHorizontal / 2),
             *                           Screen.height / 2 - ((itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceHorizontal) / 2,
             *                           aButtonSpaceHorizontal + aBoxSpaceHorizontal,
             *                           (itsCustomGUIImplementations.Count * aButtonSpaceVertical) + aBoxSpaceVertical));
             *
             * {
             *      KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated, GUILayout.MinWidth(24));
             *      {
             *              foreach(KGFICustomGUI aCustomGUI in itsCustomGUIImplementations)
             *              {
             *                      bool selected = false;
             *                      float aWidth = Mathf.Max(KGFGUIUtility.GetStyleButton(KGFGUIUtility.eStyleButton.eButton).fixedHeight, 16);
             *
             *                      if(aCustomGUI.GetIcon() != null)
             *                      {
             *                              if(KGFGUIUtility.Button(aCustomGUI.GetIcon(), KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                              {
             *                                      selected = true;
             *                              }
             *                      }
             *                      else
             *                      {
             *                              if(itsUnknownIcon != null)
             *                              {
             *                                      if(KGFGUIUtility.Button(itsUnknownIcon, KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                                      {
             *                                              selected = true;
             *                                      }
             *                              }
             *                              else
             *                              {
             *                                      if(KGFGUIUtility.Button("?", KGFGUIUtility.eStyleButton.eButton, GUILayout.Width(aWidth), GUILayout.Height(aWidth)))
             *                                      {
             *                                              selected = true;
             *                                      }
             *                              }
             *                      }
             *
             *                      // check if one of the Buttons was clicked
             *                      if(selected && aCustomGUI != itsCurrentSelectedGUI)
             *                      {
             *                              itsCurrentSelectedGUI = aCustomGUI;
             *                      }
             *                      else if(selected && aCustomGUI == itsCurrentSelectedGUI)
             *                      {
             *                              itsCurrentSelectedGUI = null;
             *                      }
             *              }
             *      }
             *      KGFGUIUtility.EndVerticalBox();
             * }
             * GUILayout.EndArea();
             *
             * //Draw the Custom GUI
             * if(itsCurrentSelectedGUI != null)
             * {
             *      itsWindowRectangle = KGFGUIUtility.Window(0, itsWindowRectangle, itsInstance.DrawCurrentCustomGUI,string.Empty, GUILayout.MinHeight(200), GUILayout.MinWidth(300));
             *
             *      // check if the window is still visible in screen
             *      if(itsWindowRectangle.x < -itsWindowRectangle.width + 20)
             *      {
             *              itsWindowRectangle.x = -itsWindowRectangle.width + 20;
             *      }
             *      else if(itsWindowRectangle.x > Screen.width - 20)
             *      {
             *              itsWindowRectangle.x = Screen.width - 20;
             *      }
             *
             *      if(itsWindowRectangle.y < -itsWindowRectangle.height + 20)
             *      {
             *              itsWindowRectangle.y = -itsWindowRectangle.height + 20;
             *      }
             *      else if(itsWindowRectangle.y > Screen.height - 20)
             *      {
             *              itsWindowRectangle.y = Screen.height - 20;
             *      }
             * }
             * }
             */
            #endregion
        }
    }
Пример #4
0
    private static void RenderHelpWindowMethod(int theWindowID)
    {
        GUILayout.BeginHorizontal();
        {
            GUILayout.FlexibleSpace();
            KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible, GUILayout.ExpandHeight(true));
            {
                KGFGUIUtility.BeginHorizontalPadding();
                {
                    KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop, GUILayout.ExpandWidth(true));
                    {
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(KGFGUIUtility.GetLogo(), GUILayout.Height(50));
                        GUILayout.FlexibleSpace();
                    }
                    KGFGUIUtility.EndHorizontalBox();

                    KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                    {
                        GUILayout.Label(itsCopyrightText, GUILayout.ExpandWidth(true));
                    }
                    KGFGUIUtility.EndHorizontalBox();

                    GUILayout.Space(KGFGUIUtility.GetSkinHeight());

                    KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop, GUILayout.ExpandWidth(true));
                    {
                        KGFGUIUtility.Label(itsOpenModule.GetName() + " version:", KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
                        KGFGUIUtility.Label(itsOpenModule.GetCurrentVersion().ToString(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
                        GUILayout.FlexibleSpace();
                        KGFGUIUtility.Label("req. KGFCore version:", KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
                        KGFGUIUtility.Label(itsOpenModule.GetRequiredCoreVersion().ToString(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
                    }
                    KGFGUIUtility.EndHorizontalBox();

                    KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkBottom, GUILayout.ExpandWidth(true));
                    {
                        KGFGUIUtility.BeginVerticalPadding();
                        {
                            if (KGFGUIUtility.Button(KGFGUIUtility.GetHelpIcon(), "documentation", KGFGUIUtility.eStyleButton.eButtonLeft, GUILayout.ExpandWidth(true)))
                            {
                                Application.OpenURL("http://www.kolmich.at/documentation/" + itsOpenModule.GetDocumentationPath());
                                itsOpenModule = null;
                            }

                            /*
                             * if(KGFGUIUtility.Button("user documentation", KGFGUIUtility.eStyleButton.eButtonMiddle, GUILayout.ExpandWidth(true)))
                             * {
                             *      Application.OpenURL("http://www.kolmich.at/documentation/frames.html");
                             *      itsOpenModule = null;
                             * }
                             */
                            if (KGFGUIUtility.Button(KGFGUIUtility.GetHelpIcon(), "forum", KGFGUIUtility.eStyleButton.eButtonMiddle, GUILayout.ExpandWidth(true)))
                            {
                                Application.OpenURL("http://www.kolmich.at/forum/" + itsOpenModule.GetForumPath());
                                itsOpenModule = null;
                            }
                            if (KGFGUIUtility.Button(KGFGUIUtility.GetHelpIcon(), "homepage", KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.ExpandWidth(true)))
                            {
                                Application.OpenURL("http://www.kolmich.at");
                                itsOpenModule = null;
                            }
                        }
                        KGFGUIUtility.EndVerticalPadding();
                    }
                    KGFGUIUtility.EndHorizontalBox();
                }
                KGFGUIUtility.EndHorizontalPadding();
            }
            KGFGUIUtility.EndVerticalBox();
            GUILayout.FlexibleSpace();
        }
        GUILayout.EndHorizontal();
    }
Пример #5
0
    public void Render()
    {
        if (itsEntrys.Count <= itsMaxVisibleItems)
        {
            itsHeight = (uint)itsEntrys.Count * (uint)KGFGUIUtility.GetSkinHeight();
        }
        else
        {
            itsHeight = itsMaxVisibleItems * (uint)KGFGUIUtility.GetSkinHeight();
        }

        if (itsVisible)
        {
            GUILayout.BeginHorizontal(GUILayout.Width(itsWidth));
            {
                KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxLeft);
                {
                    if (itsTitle != string.Empty)
                    {
                        KGFGUIUtility.Label(itsTitle, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox, GUILayout.ExpandWidth(true));
                    }
                    else
                    {
                        KGFGUIUtility.Label(itsCurrentSelected, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox, GUILayout.ExpandWidth(true));
                    }
                }
                KGFGUIUtility.EndHorizontalBox();

                if (itsIcon == null)
                {
                    if (KGFGUIUtility.Button("v", KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.ExpandWidth(false)))
                    {
                        if (itsOpenInstance != this)
                        {
                            itsOpenInstance    = this;
                            itsCorrectedOffset = false;
                        }
                        else
                        {
                            itsOpenInstance    = null;
                            itsCorrectedOffset = false;
                        }
                    }
                }
                else
                {
                    if (KGFGUIUtility.Button(itsIcon, KGFGUIUtility.eStyleButton.eButtonRight, GUILayout.ExpandWidth(false)))
                    {
                        if (itsOpenInstance != this)
                        {
                            itsOpenInstance    = this;
                            itsCorrectedOffset = false;
                        }
                        else
                        {
                            itsOpenInstance    = null;
                            itsCorrectedOffset = false;
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();

            if (Event.current.type == EventType.Repaint)
            {
                itsLastRect = GUILayoutUtility.GetLastRect();
            }
            else
            {
                Vector3 aMousePosition = Input.mousePosition;
                aMousePosition.y = Screen.height - aMousePosition.y;

                if (itsLastRect.Contains(aMousePosition))
                {
                    itsHover = true;
                }
                else
                {
                    if (KGFGUIDropDown.itsOpenInstance != this)
                    {
                        itsHover = false;
                    }
                }
            }
        }
    }