Ejemplo n.º 1
0
        public override void Draw()
        {
            base.Draw();

            // Draw tooltips when paused or cursor active
            if ((GameManager.IsGamePaused || GameManager.Instance.PlayerMouseLook.cursorActive) && defaultToolTip != null)
            {
                defaultToolTip.Draw();
            }
        }
        public override void Draw()
        {
            base.Draw();

            if (GameManager.IsGamePaused)
            {
                // Draw tooltips only when paused
                if (defaultToolTip != null)
                {
                    defaultToolTip.Draw();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when screen component should draw itself.
        /// </summary>
        public virtual void Draw()
        {
            // Do nothing if disabled
            if (!enabled)
            {
                return;
            }

            // Draw background
            Rect myRect = Rectangle;

            if (backgroundTexture)
            {
                switch (backgroundTextureLayout)
                {
                case BackgroundLayout.Tile:
                    backgroundTexture.wrapMode = TextureWrapMode.Repeat;
                    GUI.DrawTextureWithTexCoords(Rectangle, backgroundTexture, new Rect(0, 0, myRect.width / backgroundTexture.width, myRect.height / backgroundTexture.height));
                    break;

                case BackgroundLayout.StretchToFill:
                    backgroundTexture.wrapMode = TextureWrapMode.Clamp;
                    GUI.DrawTexture(Rectangle, backgroundTexture, ScaleMode.StretchToFill);
                    break;

                case BackgroundLayout.ScaleToFit:
                    backgroundTexture.wrapMode = TextureWrapMode.Clamp;
                    GUI.DrawTexture(Rectangle, backgroundTexture, ScaleMode.ScaleToFit);
                    break;
                }
            }
            else if (backgroundColor != Color.clear && backgroundColorTexture != null)
            {
                Color color = GUI.color;
                GUI.color = backgroundColor;
                GUI.DrawTexture(Rectangle, backgroundColorTexture, ScaleMode.StretchToFill);
                GUI.color = color;
            }

            // Draw tooltip on mouse hover
            if (toolTip != null && mouseOverComponent && hoverTime >= toolTip.ToolTipDelay)
            {
                if (!suppressToolTip)
                {
                    toolTip.Draw(toolTipText);
                }
            }
        }
        /// <summary>
        /// Called when screen component should draw itself.
        /// </summary>
        public virtual void Draw()
        {
            // Do nothing if disabled
            if (!enabled)
            {
                return;
            }

            // Animated background textures
            if (animatedBackgroundTextures != null && animatedBackgroundTextures.Length > 0)
            {
                // Tick animation
                if (Time.realtimeSinceStartup > animationLastTickTime + animationDelay)
                {
                    if (++animationFrame >= animatedBackgroundTextures.Length)
                    {
                        animationFrame = 0;
                    }

                    animationLastTickTime = Time.realtimeSinceStartup;
                }

                // Assign current frame as background texture reference
                backgroundTexture = animatedBackgroundTextures[animationFrame];
            }

            // Calculate cutout rect
            Rect myRect = Rectangle;

            if (useRestrictedRenderArea)
            {
                Rect rect = new Rect(this.Parent.Position + this.Position, this.Size);

                Vector2 parentScale = parent.LocalScale;

                float leftCut   = Math.Max(0, rectRestrictedRenderArea.xMin - rect.xMin) * parentScale.x;
                float rightCut  = Math.Max(0, rect.xMax - rectRestrictedRenderArea.xMax) * parentScale.x;
                float topCut    = Math.Max(0, rectRestrictedRenderArea.yMin - rect.yMin) * parentScale.y;
                float bottomCut = Math.Max(0, rect.yMax - rectRestrictedRenderArea.yMax) * parentScale.y;

                myRect = new Rect(new Vector2(Rectangle.xMin + leftCut, Rectangle.yMin + topCut), new Vector2(Rectangle.width - leftCut - rightCut, Rectangle.height - topCut - bottomCut));
            }

            // Draw background colour or mouse over background colour
            if (mouseOverComponent && mouseOverBackgroundColor != Color.clear && backgroundColorTexture)
            {
                Color color = GUI.color;
                GUI.color = mouseOverBackgroundColor;
                GUI.DrawTexture(myRect, backgroundColorTexture, ScaleMode.StretchToFill);
                GUI.color = color;
            }
            else if (backgroundColor != Color.clear && backgroundColorTexture)
            {
                Color color = GUI.color;
                GUI.color = backgroundColor;
                GUI.DrawTexture(myRect, backgroundColorTexture, ScaleMode.StretchToFill);
                GUI.color = color;
            }

            // Draw background texture if present
            if (backgroundTexture)
            {
                switch (backgroundTextureLayout)
                {
                case BackgroundLayout.Tile:
                    backgroundTexture.wrapMode = TextureWrapMode.Repeat;
                    GUI.DrawTextureWithTexCoords(myRect, backgroundTexture, new Rect(0, 0, myRect.width / backgroundTexture.width, myRect.height / backgroundTexture.height));
                    break;

                case BackgroundLayout.StretchToFill:
                    backgroundTexture.wrapMode = TextureWrapMode.Clamp;
                    GUI.DrawTexture(myRect, backgroundTexture, ScaleMode.StretchToFill);
                    break;

                case BackgroundLayout.ScaleToFit:
                    backgroundTexture.wrapMode = TextureWrapMode.Clamp;
                    GUI.DrawTexture(myRect, backgroundTexture, ScaleMode.ScaleToFit);
                    break;
                }
            }

            // Draw tooltip on mouse hover
            if (toolTip != null && mouseOverComponent && hoverTime >= toolTip.ToolTipDelay)
            {
                if (!suppressToolTip)
                {
                    toolTip.Draw(toolTipText);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called when screen component should draw itself.
        /// </summary>
        public virtual void Draw()
        {
            // Do nothing if disabled
            if (!enabled)
            {
                return;
            }

            // Animated background textures
            if (animatedBackgroundTextures != null && animatedBackgroundTextures.Length > 0)
            {
                // Tick animation
                if (Time.realtimeSinceStartup > animationLastTickTime + animationDelay)
                {
                    if (++animationFrame >= animatedBackgroundTextures.Length)
                    {
                        animationFrame = 0;
                    }

                    animationLastTickTime = Time.realtimeSinceStartup;
                }

                // Assign current frame as background texture reference
                backgroundTexture = animatedBackgroundTextures[animationFrame];
            }

            // Draw background
            Rect myRect = Rectangle;

            if (backgroundTexture)
            {
                switch (backgroundTextureLayout)
                {
                case BackgroundLayout.Tile:
                    backgroundTexture.wrapMode = TextureWrapMode.Repeat;
                    GUI.DrawTextureWithTexCoords(Rectangle, backgroundTexture, new Rect(0, 0, myRect.width / backgroundTexture.width, myRect.height / backgroundTexture.height));
                    break;

                case BackgroundLayout.StretchToFill:
                    backgroundTexture.wrapMode = TextureWrapMode.Clamp;
                    GUI.DrawTexture(Rectangle, backgroundTexture, ScaleMode.StretchToFill);
                    break;

                case BackgroundLayout.ScaleToFit:
                    backgroundTexture.wrapMode = TextureWrapMode.Clamp;
                    GUI.DrawTexture(Rectangle, backgroundTexture, ScaleMode.ScaleToFit);
                    break;
                }
            }
            else if (backgroundColor != Color.clear && backgroundColorTexture != null)
            {
                Color color = GUI.color;
                GUI.color = backgroundColor;
                GUI.DrawTexture(Rectangle, backgroundColorTexture, ScaleMode.StretchToFill);
                GUI.color = color;
            }

            // Draw tooltip on mouse hover
            if (toolTip != null && mouseOverComponent && hoverTime >= toolTip.ToolTipDelay)
            {
                if (!suppressToolTip)
                {
                    toolTip.Draw(toolTipText);
                }
            }
        }