Ejemplo n.º 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;
        }
    }
Ejemplo n.º 2
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
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// OnGUI renders the demo window
 /// </summary>
 private void OnGUI()
 {
     KGFGUIUtility.Window(0, CalculateWindowSize(), RenderTutorialWindow, "Please examine the KGFSkinTutorial1 script");             //Renders the window using the KGFGUIUtility
 }