Exemplo n.º 1
0
        public virtual void Draw(float x, float y, float width, float height)
        {
            float rectWidth  = width;
            float rectHeight = height;
            float rectX      = x + rectWidth * 0.5f;
            float rectY      = y + rectHeight * 0.5f;

            Color barColor = Selected ? HighlightedBackColor : BackColor;

            if (barColor != Color.Empty)
            {
                UIMenu.DrawSprite(UIMenu.CommonTxd, UIMenu.NavBarTextureName,
                                  rectX, rectY,
                                  rectWidth, rectHeight,
                                  barColor);
            }

            if (Hovered && !Selected)
            {
                Color hoveredColor = Color.FromArgb(25, 255, 255, 255);
                UIMenu.DrawRect(rectX, rectY - 0.00138888f * 0.5f,
                                rectWidth, rectHeight - 0.00138888f,
                                hoveredColor);
            }

            if (LeftBadgeInfo != null)
            {
                DrawBadge(LeftBadgeInfo, true, x, y, width, height, out leftBadgeOffset);
            }
            else
            {
                leftBadgeOffset = 0.0f;
            }

            if (RightBadgeInfo != null)
            {
                DrawBadge(RightBadgeInfo, false, x, y, width, height, out rightBadgeOffset);
            }
            else
            {
                rightBadgeOffset = 0.0f;
            }

            SetTextCommandOptions();
            TextCommands.Display(Text, x + 0.0046875f + leftBadgeOffset, y + 0.00277776f);

            if (!String.IsNullOrEmpty(RightLabel))
            {
                SetTextCommandOptions(false);
                float labelWidth = TextCommands.GetWidth(RightLabel);

                float labelX = x + width - 0.00390625f - labelWidth - rightBadgeOffset;
                float labelY = y + 0.00277776f;

                SetTextCommandOptions(false);
                TextCommands.Display(RightLabel, labelX, labelY);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draw item.
        /// </summary>
        public override void Draw(float x, float y, float width, float height)
        {
            base.Draw(x, y, width, height);

            string selectedOption = Collection == null ?
                                (_items.Count > 0 ? _items[Index].ToString() : " ") :
                                (Collection.Count > 0 ? Collection[Index].DisplayText : " ");

            SetTextCommandOptions(false);
            float optTextWidth = TextCommands.GetWidth(selectedOption);

            GetBadgeOffsets(out _, out float badgeOffset);

            if (Selected && Enabled)
            {
                Color textColor = CurrentForeColor;
                float optTextX = x + width - 0.00390625f - optTextWidth - (0.0046875f * 1.5f) - badgeOffset;
                float optTextY = y + 0.00277776f;

                SetTextCommandOptions(false);
                TextCommands.Display(selectedOption, optTextX, optTextY);

                {
                    UIMenu.GetTextureDrawSize(UIMenu.CommonTxd, UIMenu.ArrowRightTextureName, out float w, out float h);
                    w *= 0.65f;
                    h *= 0.65f;

                    float spriteX = x + width - (0.00390625f * 1.0f) - (w * 0.5f) - badgeOffset;
                    float spriteY = y + (0.034722f * 0.5f);

                    UIMenu.DrawSprite(UIMenu.CommonTxd, UIMenu.ArrowRightTextureName, spriteX, spriteY, w, h, textColor);
                }
                {
                    UIMenu.GetTextureDrawSize(UIMenu.CommonTxd, UIMenu.ArrowLeftTextureName, out float w, out float h);
                    w *= 0.65f;
                    h *= 0.65f;

                    float spriteX = x + width - (0.00390625f * 1.0f) - (w * 0.5f) - optTextWidth - (0.0046875f * 1.5f) - badgeOffset;
                    float spriteY = y + (0.034722f * 0.5f);

                    UIMenu.DrawSprite(UIMenu.CommonTxd, UIMenu.ArrowLeftTextureName, spriteX, spriteY, w, h, textColor);
                }
            }
            else
            {
                float optTextX = x + width - 0.00390625f - optTextWidth - badgeOffset;
                float optTextY = y + 0.00277776f;// + 0.00416664f;

                SetTextCommandOptions(false);
                TextCommands.Display(selectedOption, optTextX, optTextY);
            }
        }