Ejemplo n.º 1
0
        protected override void OnBeforeRecalculatePosition()
        {
            base.OnBeforeRecalculatePosition();

            bool fschanged = false;

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (_fsizeCache != _fontSize)
            {
                _fontScale = FontRenderHelper.GetFontScale(Font, FontSize);

                _fsizeCache = _fontSize;

                fschanged = true;
            }

            if (_textCache != _text || fschanged)
            {
                Size = (Font.MeasureString(_text) * _fontScale).ToFSize();

                _textCache = _text;
            }

            _fontVOffset = FontRenderHelper.GetFontVCenterOffset(Font) * _fontScale;
        }
Ejemplo n.º 2
0
        protected override void OnBeforeRecalculatePosition()
        {
            base.OnBeforeRecalculatePosition();

            bool fschanged = false;

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (_fsizeCache != _fontSize)
            {
                _fontScale = FontRenderHelper.GetFontScale(Font, FontSize);

                _fsizeCache = _fontSize;

                fschanged = true;
            }

            if (_textCache != _text || fschanged)
            {
                try
                {
                    Size = (Font.MeasureString(_text) * _fontScale).ToFSize();
                }
                catch (Exception e)
                {
                    SAMLog.Error("RAWTXT:Measure", $"Measure string failed for text: '{_text}' (prev: '{_textCache}')" + "\n" + e);
                    return;
                }

                _textCache = _text;
            }

            _fontVOffset = FontRenderHelper.GetFontVCenterOffset(Font) * _fontScale;
        }
Ejemplo n.º 3
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.º 4
0
        public BackgroundText(GDGameScreen scrn, BackgroundTextBlueprint blueprint) : base(scrn, GDConstants.ORDER_GAME_BACKGROUNDTEXT)
        {
            var pos = new FPoint(blueprint.X, blueprint.Y);

            Blueprint = blueprint;

            _rotation = FloatMath.ToRadians(blueprint.Rotation);
            _bounds   = new FRotatedRectangle(pos, blueprint.Width, blueprint.Height, _rotation);

            Position = pos;

            DrawingBoundingBox = _bounds.OuterSize;

            _text  = FontRenderHelper.MakeTextSafe(Textures.LevelBackgroundFont, L10N.T(blueprint.L10NText), '_');
            _scale = FontRenderHelper.GetFontScale(Textures.LevelBackgroundFont, _text, _bounds.Size);

            if ((Blueprint.Config & BackgroundTextBlueprint.CONFIG_SHAKE) == BackgroundTextBlueprint.CONFIG_SHAKE)
            {
                AddOperation(new ShakeTextOperation());
            }

            if ((Blueprint.Config & BackgroundTextBlueprint.CONFIG_ONLYD1) == BackgroundTextBlueprint.CONFIG_ONLYD1)
            {
                if (scrn.Difficulty != FractionDifficulty.DIFF_0)
                {
                    Alive = false;
                }
            }

            if ((Blueprint.Config & BackgroundTextBlueprint.CONFIG_ONLY_UNCLEARED) == BackgroundTextBlueprint.CONFIG_ONLY_UNCLEARED)
            {
                if (MainGame.Inst.Profile.GetLevelData(scrn.Blueprint).HasCompletedOrBetter(scrn.Difficulty))
                {
                    Alive = false;
                }
            }

            if ((Blueprint.Config & BackgroundTextBlueprint.CONFIG_REDFLASH) == BackgroundTextBlueprint.CONFIG_REDFLASH)
            {
                AddOperation(new RedFlashTextOperation());
            }

            if (scrn.IsPreview)
            {
                Alive = false;
            }
        }
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);
            }
        }