Ejemplo n.º 1
0
 private AchievementPopup(SpriteFont font, string text)
 {
     _font   = font;
     _height = PAD + FONTSIZE + PAD;
     _width  = PAD + FontRenderHelper.MeasureStringCached(font, text, FONTSIZE).Width + PAD;
     _text   = text;
 }
Ejemplo n.º 2
0
        public override void OnInitialize()
        {
            var px = master.RelativeCenter.X - DIAMETER / 2;
            var py = master.RelativeCenter.Y + SettingsButton.DIAMETER / 2 - DIAMETER;

            py += MARGIN_Y;

            RelativePosition = new FPoint(px, py);

            var bounds = FontRenderHelper.MeasureStringCached(Textures.HUDFontRegular, ButtonText);
            var scale  = FontRenderHelper.GetFontScale(Textures.HUDFontRegular, SIZE_ICON);

            Slave.Size = bounds * scale;

            Owner.AddElement(Slave);
        }
Ejemplo n.º 3
0
        protected void DrawText(IBatchRenderer sbatch, FRectangle bounds, float leftOffset, float rightOffset)
        {
            var maxWidth = bounds.Width - leftOffset - rightOffset - CursorWidth - Font.Spacing;
            var dispText = Text;

            if (IsPassword)
            {
                if (_forceShowLastChar && dispText.Length > 0)
                {
                    dispText = new string('*', dispText.Length - 1) + dispText[dispText.Length - 1];
                }
                else
                {
                    dispText = new string('*', dispText.Length);
                }
            }

            var textBounds = FontRenderHelper.MeasureStringCached(Font, dispText, FontSize);

            while (dispText.Length > 0 && textBounds.Width > maxWidth)
            {
                dispText   = Text.Substring(1);
                textBounds = FontRenderHelper.MeasureStringCached(Font, dispText, FontSize);
            }

            FontRenderHelper.DrawTextVerticallyCentered(
                sbatch,
                Font,
                FontSize,
                dispText,
                ColorText,
                new FPoint(bounds.X + leftOffset, bounds.Y + bounds.Height / 2));

            if (IsFocused && (int)(_cursorBlinkTimer / CURSOR_BLINK_TIME) % 2 == 0)
            {
                SimpleRenderHelper.DrawSimpleRect(
                    sbatch,
                    new FRectangle(
                        bounds.X + leftOffset + textBounds.Width + Font.Spacing,
                        bounds.Y + bounds.Height / 2 - FontSize / 2,
                        CursorWidth,
                        FontSize),
                    ColorText);
            }
        }
Ejemplo n.º 4
0
        private void Open()
        {
            isOpened = true;

            if (this.GDHUD().GDOwner.CanPause)
            {
                this.GDHUD().GDOwner.IsPaused = true;
            }

            var t1 = L10N.T(L10NImpl.STR_PAUS_RESUME);
            var t2 = L10N.T(L10NImpl.STR_PAUS_RESTART);
            var t3 = L10N.T(L10NImpl.STR_PAUS_EXIT);

            var w1 = FontRenderHelper.MeasureStringCached(Textures.HUDFontBold, t1, 40f);
            var w2 = FontRenderHelper.MeasureStringCached(Textures.HUDFontBold, t2, 40f);
            var w3 = FontRenderHelper.MeasureStringCached(Textures.HUDFontBold, t3, 40f);

            var w = FloatMath.Max(w1.Width, w2.Width, w3.Width);

            int cnt = (_showResume ? 1 : 0) + (_showRestart ? 1 : 0) + (_showExit ? 1 : 0);

            var m   = new List <HUDPauseMenuButton>();
            int idx = 0;
            int dep = -1;

            if (_showResume)
            {
                m.Add(new HUDPauseMenuButton(this, t1, w, dep--, idx++, cnt, OnResume));
            }
            if (_showRestart)
            {
                m.Add(new HUDPauseMenuButton(this, t2, w, dep--, idx++, cnt, OnRestart));
            }
            if (_showExit)
            {
                m.Add(new HUDPauseMenuButton(this, t3, w, dep--, idx++, cnt, OnExit));
            }

            subMenu = m.ToArray();

            Owner.AddElements(subMenu);
        }
Ejemplo n.º 5
0
        public override void OnInitialize()
        {
            if (orientation == SSBOrientation.V)
            {
                var px = master.RelativeCenter.X - DIAMETER / 2;
                var py = master.RelativeCenter.Y + SettingsButton.DIAMETER / 2 - DIAMETER;

                py += MARGIN_FIRST;

                RelativePosition = new FPoint(px, py);

                var bounds = FontRenderHelper.MeasureStringCached(Textures.HUDFontRegular, ButtonText);
                var scale  = FontRenderHelper.GetFontScale(Textures.HUDFontRegular, SIZE_ICON);
                Slave.Size = bounds * scale;
                Owner.AddElement(Slave);

                Slave.IsEnabled = !string.IsNullOrWhiteSpace(ButtonText);
            }
            else if (orientation == SSBOrientation.H)
            {
                var px = master.RelativeCenter.X - DIAMETER / 2;
                var py = master.RelativeCenter.Y - DIAMETER / 2;

                py += MARGIN_FIRST;

                RelativePosition = new FPoint(px, py);

                var bounds = FontRenderHelper.MeasureStringCached(Textures.HUDFontRegular, ButtonText);
                bounds = bounds.Rotate90();

                var scale = FontRenderHelper.GetFontScale(Textures.HUDFontRegular, SIZE_ICON);
                Slave.Size = bounds * scale;
                Owner.AddElement(Slave);

                Slave.IsEnabled = !string.IsNullOrWhiteSpace(ButtonText);
            }
        }