Ejemplo n.º 1
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            var bottomrect = bounds.ToSubRectangleSouth(25);

            {             // background
                SimpleRenderHelper.DrawSimpleRect(sbatch, bounds, FlatColors.Clouds);
                SimpleRenderHelper.DrawSimpleRect(sbatch, bottomrect, FlatColors.Concrete);
            }

            {             // name
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 32, _meta?.LevelName ?? _level?.FullName, (_meta == null) ? FlatColors.Silver : FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5, bounds.Top + (bounds.Height - 25) / 2));
            }

            {             // user
                sbatch.DrawCentered(Textures.TexHUDIconGenericUser, new FPoint(bottomrect.Left + 5 + 32 + 5, bottomrect.CenterY), 20, 20, (_meta == null) ? FlatColors.Silver : FlatColors.WetAsphalt);
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 20, (_meta == null) ? L10N.T(L10NImpl.STR_INF_YOU) : (_meta.Username ?? "Unknown"), (_meta == null) ? FlatColors.Silver : FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5 + 16, bounds.Bottom - 12.5f));
            }


            if ((_meta != null) && _meta.GridSize != SCCMLevelData.SIZES[0])             // [XL] marker
            {
                var rr = bounds.ToSubRectangleSouthWest(32, 20);
                SimpleRenderHelper.DrawSimpleRect(sbatch, rr, FlatColors.Amethyst);
                FontRenderHelper.DrawSingleLineInBox(sbatch, Textures.HUDFontRegular, "XL", rr, 0, true, FlatColors.Foreground);
            }

            {             // star counter
                var pointPos = new FPoint(bottomrect.Right - 100, bottomrect.CenterY);
                sbatch.DrawCentered(Textures.TexIconStar, pointPos, 20, 20, FlatColors.SunFlower);
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 24, (_meta == null) ? "???" : _meta.Stars.ToString(), (_meta == null) ? FlatColors.Silver : FlatColors.MidnightBlue, pointPos + new Vector2(16, 0));
            }

            SimpleRenderHelper.DrawSimpleRectOutline(sbatch, bounds, HUD.PixelWidth, Color.Black);
        }
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
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            var outerBounds = FRectangle.CreateByCenter(Position, DrawingBoundingBox);
            var innerBounds = FRectangle.CreateByCenter(Position, new FSize(INNERSIZE, INNERSIZE));

            if (!MainGame.Inst.Profile.GetLevelData(Levels.LEVEL_TUTORIAL.UniqueID).HasAnyCompleted())
            {
                var iconBounds = FRectangle.CreateByCenter(Position, new FSize(ICONSIZE + ICONSIZESWIGGLE * FloatMath.Sin(Lifetime), ICONSIZE + ICONSIZESWIGGLE * FloatMath.Sin(Lifetime)));

                FlatRenderHelper.DrawRoundedBlurPanel(sbatch, outerBounds, clickArea.IsMouseDown() ? FlatColors.ButtonPressedHUD : FlatColors.Asbestos, 0.5f * GDConstants.TILE_WIDTH);
                SimpleRenderHelper.DrawRoundedRectOutline(sbatch, outerBounds.AsInflated(1f, 1f), FlatColors.MidnightBlue, 8, 2f, 0.5f * GDConstants.TILE_WIDTH);

                sbatch.FillRectangle(innerBounds, FlatColors.Background);

                sbatch.DrawStretched(Textures.TexIconTutorial, iconBounds, Color.White * AlphaOverride);

                FontRenderHelper.DrawTextCentered(sbatch, Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH, L10N.T(_l10ndescription), FlatColors.TextHUD, Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH));
            }
            else
            {
                var iconBounds = FRectangle.CreateByCenter(Position, new FSize(ICONSIZE, ICONSIZE));

                FlatRenderHelper.DrawRoundedBlurPanel(sbatch, outerBounds, clickArea.IsMouseDown() ? FlatColors.ButtonPressedHUD : FlatColors.Asbestos, 0.5f * GDConstants.TILE_WIDTH);
                SimpleRenderHelper.DrawRoundedRectOutline(sbatch, outerBounds.AsInflated(1f, 1f), FlatColors.MidnightBlue, 8, 2f, 0.5f * GDConstants.TILE_WIDTH);

                sbatch.FillRectangle(innerBounds, FlatColors.Background);

                sbatch.DrawStretched(Textures.TexIconTutorial, iconBounds, FlatColors.Emerald * AlphaOverride);

                FontRenderHelper.DrawTextCentered(sbatch, Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH, L10N.T(_l10ndescription), FlatColors.TextHUD, Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH));
            }
        }
Ejemplo n.º 4
0
        protected void DrawGridProgress(IBatchRenderer sbatch)
        {
            var outerBounds = FRectangle.CreateByCenter(Position, DrawingBoundingBox);
            var innerBounds = FRectangle.CreateByCenter(Position, new FSize(INNERSIZE, INNERSIZE));

            var scoreRectSize = innerBounds.Width / 8f;

            FlatRenderHelper.DrawRoundedBlurPanel(sbatch, outerBounds, clickArea.IsMouseDown() ? FlatColors.ButtonPressedHUD : FlatColors.Asbestos, 0.5f * GDConstants.TILE_WIDTH);
            SimpleRenderHelper.DrawRoundedRectOutline(sbatch, outerBounds.AsInflated(1f, 1f), FlatColors.MidnightBlue, 8, 2f, 0.5f * GDConstants.TILE_WIDTH);

            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    var col = ColorMath.Blend(FlatColors.Background, GetCellColor(x, y), AlphaOverride);
                    sbatch.FillRectangle(new FRectangle(innerBounds.X + scoreRectSize * x, innerBounds.Y + scoreRectSize * y, scoreRectSize, scoreRectSize), col);
                }
            }

            for (int i = 0; i <= 8; i++)
            {
                sbatch.DrawLine(innerBounds.Left, innerBounds.Top + i * scoreRectSize, innerBounds.Right, innerBounds.Top + i * scoreRectSize, Color.Black * AlphaOverride, Owner.PixelWidth);
                sbatch.DrawLine(innerBounds.Left + i * scoreRectSize, innerBounds.Top, innerBounds.Left + i * scoreRectSize, innerBounds.Bottom, Color.Black * AlphaOverride, Owner.PixelWidth);
            }

            FontRenderHelper.DrawTextCentered(sbatch, Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH, L10N.T(_l10ndescription), FlatColors.TextHUD, Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH));
        }
Ejemplo n.º 5
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            var bgrect = bounds.ToSubRectangleSouth(Height * 2);

            if (_cogMovement > 0)
            {
                sbatch.DrawCentered(Textures.CannonCogBig, bounds.BottomRight - RAD_INSET - PAD_VEC * (1.5f * (1 - _cogMovement)), FONTSIZE, FONTSIZE, FlatColors.Clouds * _fadeOutAlpha * _fadeOutAlpha * _fadeOutAlpha, _rotation);
            }

            SimpleRenderHelper.DrawRoundedRect(sbatch, bgrect.AsDeflated(HUD.PixelWidth * 1), Background * _fadeOutAlpha, CORNER_RADIUS);
            SimpleRenderHelper.DrawRoundedRectOutline(sbatch, bgrect, Outline * _fadeOutAlpha, 12, HUD.PixelWidth * 2, CORNER_RADIUS);

            FontRenderHelper.DrawTextCentered(sbatch, _font, FONTSIZE, _text, Foreground * _fadeOutAlpha, bounds.Center);

            foreach (var particle in _particles)
            {
                if (particle.RemainingLifetime < PARTICLE_LIFETIME_FADE)
                {
                    sbatch.DrawCentered(Textures.TexPixel, particle.Position, particle.Size.Width, particle.Size.Height, particle.Color * (particle.RemainingLifetime / PARTICLE_LIFETIME_FADE), particle.Rotation);
                }
                else
                {
                    sbatch.DrawCentered(Textures.TexPixel, particle.Position, particle.Size.Width, particle.Size.Height, particle.Color, particle.Rotation);
                }
            }
        }
Ejemplo n.º 6
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.º 7
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            if (_l10nLangBuffer != L10N.LANGUAGE)
            {
                _l10nLangBuffer = L10N.LANGUAGE;
                recalcText      = true;
            }

            if (recalcText)
            {
                _l10nLangBuffer = L10N.LANGUAGE;
                recalcText      = false;

                if (MaxWidth == null)
                {
                    internalText.Text = DisplayText;
                }
                else
                {
                    internalText.Text = string.Join(Environment.NewLine, FontRenderHelper.WrapLinesIntoWidth(DisplayText, Font, FontSize, MaxWidth.Value, WordWrap));
                }
            }

            if (AutoSize)
            {
                Size = internalText.Size;
            }
        }
Ejemplo n.º 8
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.º 9
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            sbatch.DrawCentered(Textures.TexHUDButtonBase, Center, DIAMETER * ScaleProgress, DIAMETER * ScaleProgress, ColorMath.Blend(FlatColors.Asbestos, FlatColors.Alizarin, OffsetProgress * ScaleProgress));

            sbatch.DrawCentered(GetIcon(), Center, SIZE_ICON * ScaleProgress * IconScale, SIZE_ICON * ScaleProgress * IconScale, IsPressed ? FlatColors.WetAsphalt : FlatColors.Clouds, IconRotation);

            FontRenderHelper.DrawTextVerticallyCenteredWithBackground(sbatch, Textures.HUDFontRegular, SIZE_ICON, ButtonText, FlatColors.Clouds * FontProgress, new FPoint(CenterX + SIZE_ICON, CenterY), Color.Black * 0.5f * FontProgress);
        }
Ejemplo n.º 10
0
        private void ShowData(QueryResultRanking data)
        {
            _table.IsVisible  = true;
            _loader.IsVisible = false;
            if (_btn != null)
            {
                _btn.IsVisible = true;
            }

            bool foundyourself = false;

            for (int i = 0; i < data.ranking.Count; i++)
            {
                var r = data.ranking[i];

                var r1 = (i + 1).ToString();
                var r2 = FontRenderHelper.MakeTextSafe(_table.Font, r.username, '?');
                var r3 = r.totalscore.ToString();
                var r4 = FormatSeconds(r.totaltime);

                if (r.userid == MainGame.Inst.Profile.OnlineUserID)
                {
                    _table.AddRowWithColor(FlatColors.SunFlower, r1, r2, r3, r4);
                    foundyourself = true;
                }
                else if (r.username == "anonymous")
                {
                    _table.AddRowWithColor(FlatColors.Concrete, r1, r2, r3, r4);
                }
                else
                {
                    _table.AddRow(r1, r2, r3, r4);
                }
            }

            if (!foundyourself && data.personal.Count > 0 && MainGame.Inst.Profile.AccountType != AccountType.Local)
            {
                _table.Size = new FSize(TAB_WIDTH, TAB_HEIGHT - BOTTOM_HEIGHT);
                _table.FixHeightToMultipleOfRowHeight();

                _table.RelativePosition = new FPoint(_table.RelativePosition.X, _table.RelativePosition.Y - BOTTOM_HEIGHT / 2f);

                var r1 = data.personal[0].rank.ToString();
                var r2 = FontRenderHelper.MakeTextSafe(_table.Font, data.personal[0].username, '?');
                var r3 = data.personal[0].totalscore.ToString();
                var r4 = FormatSeconds(data.personal[0].totaltime);

                var rowp = _table.CreateSingleRowPresenter(r1, r2, r3, r4);
                rowp.Foreground = FlatColors.SunFlower;

                rowp.Size             = new FSize(TAB_WIDTH, _table.GetRowHeight());
                rowp.RelativePosition = new FPoint(0, _table.RelativeBottom + (HEIGHT - _table.RelativeBottom) / 2f);
                rowp.Alignment        = HUDAlignment.TOPCENTER;

                AddElement(rowp);
            }
        }
Ejemplo n.º 11
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            if (!Alive)
            {
                return;
            }

            FontRenderHelper.DrawTextCenteredWithScale(sbatch, Textures.LevelBackgroundFont, _scale, _text, Color, Position, _rotation + SuperRotation);
        }
Ejemplo n.º 12
0
 protected void DrawPlaceholder(IBatchRenderer sbatch, FRectangle bounds, float leftOffset, float rightOffset)
 {
     FontRenderHelper.DrawTextVerticallyCentered(
         sbatch,
         Font,
         FontSize,
         Placeholder,
         ColorPlaceholder,
         new FPoint(bounds.X + leftOffset, bounds.Y + bounds.Height / 2));
 }
Ejemplo n.º 13
0
        public void Draw()
        {
            if (!IsEnabled)
            {
                return;
            }

            debugBatch.Begin(1f, blendState: BlendState.NonPremultiplied);             //scale=1f is ok because we use no textures

            foreach (var line in lines.SelectMany(p => p.GetLines()).Where(p => p.Active()))
            {
                var columns = line.DisplayText();

                var pos = new FPoint(TEXT_OFFSET * Scale, line.PositionY * Scale);

                if (columns.Count == 0 || columns.All(string.IsNullOrWhiteSpace))
                {
                    continue;
                }

                foreach (var _text in columns)
                {
                    var text = FontRenderHelper.MakeTextSafeWithWarn(font, _text, '_');

                    var size = font.MeasureString(text) * Scale;

                    var bg = line.Background;
                    if (bg.A == 255)
                    {
                        bg = ColorMath.Fade(line.Background, line.Decay * backgroundAlpha);
                    }

                    debugBatch.FillRectangle(
                        new FRectangle(pos.X - TEXT_OFFSET * Scale, pos.Y, size.X + 2 * TEXT_OFFSET * Scale, size.Y),
                        bg);

                    debugBatch.DrawString(
                        font,
                        text,
                        pos,
                        ColorMath.Fade(line.Color, line.Decay),
                        0,
                        FPoint.Zero,
                        Scale,
                        SpriteEffects.None,
                        0);

                    pos = new FPoint(pos.X + 3 * TEXT_OFFSET * Scale + size.X, pos.Y);
                }
            }

            debugBatch.End();
        }
Ejemplo n.º 14
0
        protected void DrawGridGreenLock(IBatchRenderer sbatch)
        {
            var outerBounds = FRectangle.CreateByCenter(Position, DrawingBoundingBox);
            var innerBounds = FRectangle.CreateByCenter(Position, new FSize(INNERSIZE, INNERSIZE));

            FlatRenderHelper.DrawRoundedBlurPanel(sbatch, outerBounds, clickArea.IsMouseDown() ? FlatColors.ButtonPressedHUD : FlatColors.Asbestos, 0.5f * GDConstants.TILE_WIDTH);
            SimpleRenderHelper.DrawRoundedRectOutline(sbatch, outerBounds.AsInflated(1f, 1f), FlatColors.MidnightBlue, 8, 2f, 0.5f * GDConstants.TILE_WIDTH);

            sbatch.FillRectangle(innerBounds, FlatColors.Background);

            sbatch.DrawCentered(Textures.TexIconLockOpen, innerBounds.Center, INNERSIZE * 0.75f, INNERSIZE * 0.75f, FlatColors.Nephritis);

            FontRenderHelper.DrawTextCentered(sbatch, Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH, L10N.T(_l10ndescription), FlatColors.TextHUD, Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH));
        }
Ejemplo n.º 15
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            var outerBounds = FRectangle.CreateByCenter(Position, DrawingBoundingBox);
            var innerBounds = FRectangle.CreateByCenter(Position, new FSize(INNERSIZE, INNERSIZE));

            FlatRenderHelper.DrawRoundedBlurPanel(sbatch, outerBounds, clickArea.IsMouseDown() ? FlatColors.ButtonPressedHUD : FlatColors.Asbestos, 0.5f * GDConstants.TILE_WIDTH);
            SimpleRenderHelper.DrawRoundedRectOutline(sbatch, outerBounds.AsInflated(1f, 1f), FlatColors.MidnightBlue, 8, 2f, 0.5f * GDConstants.TILE_WIDTH);

            sbatch.FillRectangle(innerBounds, FlatColors.Background);

            var scoreRectSize = innerBounds.Width / 8f;

            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    var bc = ((x % 2 == 0) ^ (y % 2 == 0)) ? FlatColors.Background : FlatColors.BackgroundLight;

                    if (_ustate == WorldUnlockState.OpenAndUnlocked)
                    {
                        var d = FloatMath.Sqrt((x - 3.5f) * (x - 3.5f) + (y - 3.5f) * (y - 3.5f));

                        var p = 1 - (d / 4.5f);
                        if (p < 0)
                        {
                            p = 0;
                        }

                        p *= FloatMath.PercSin(_pulseTimer * FloatMath.TAU * 0.25f);

                        bc = ColorMath.Blend(bc, FlatColors.PeterRiver, p);
                    }

                    var col = ColorMath.Blend(FlatColors.Background, bc, AlphaOverride);
                    sbatch.FillRectangle(new FRectangle(innerBounds.X + scoreRectSize * x, innerBounds.Y + scoreRectSize * y, scoreRectSize, scoreRectSize), col);
                }
            }

            sbatch.DrawStretched(Textures.TexIconNetworkBase, innerBounds, Color.White);
            sbatch.DrawStretched(Textures.TexIconNetworkVertex1, innerBounds, Color.White, VertexRotations[0]);
            sbatch.DrawStretched(Textures.TexIconNetworkVertex2, innerBounds, Color.White, VertexRotations[1]);
            sbatch.DrawStretched(Textures.TexIconNetworkVertex3, innerBounds, Color.White, VertexRotations[2]);
            sbatch.DrawStretched(Textures.TexIconNetworkVertex4, innerBounds, Color.White, VertexRotations[3]);
            sbatch.DrawStretched(Textures.TexIconNetworkVertex5, innerBounds, Color.White, VertexRotations[4]);

            sbatch.DrawRectangle(innerBounds, Color.Black, Owner.PixelWidth);

            FontRenderHelper.DrawTextCentered(sbatch, Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH, L10N.T(_l10ndescription), FlatColors.TextHUD, Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH));
        }
Ejemplo n.º 16
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            SimpleRenderHelper.DrawSimpleRect(sbatch, FRectangle.CreateByCenter(Position, DIAMETER, DIAMETER), clickAreaThis.IsMouseDown() ? FlatColors.WetAsphalt : FlatColors.Asbestos);
            SimpleRenderHelper.DrawSimpleRectOutline(sbatch, FRectangle.CreateByCenter(Position, DIAMETER, DIAMETER), 2, FlatColors.MidnightBlue);

            SimpleRenderHelper.DrawRoundedRect(sbatch, FRectangle.CreateByCenter(Position, INNER_DIAMETER, INNER_DIAMETER), Color.Black);

            FontRenderHelper.DrawTextCenteredWithBackground(
                sbatch,
                Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH,
                L10N.T(L10NImpl.STR_GLOB_OVERWORLD),
                FlatColors.TextHUD,
                Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH),
                FlatColors.BackgroundHUD2 * 0.5f);
        }
Ejemplo n.º 17
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.º 18
0
        protected void DrawLockSwing(IBatchRenderer sbatch)
        {
            var outerBounds = FRectangle.CreateByCenter(Position, DrawingBoundingBox);
            var innerBounds = FRectangle.CreateByCenter(Position, new FSize(INNERSIZE, INNERSIZE));

            FlatRenderHelper.DrawRoundedBlurPanel(sbatch, outerBounds, clickArea.IsMouseDown() ? FlatColors.ButtonPressedHUD : FlatColors.Asbestos, 0.5f * GDConstants.TILE_WIDTH);
            SimpleRenderHelper.DrawRoundedRectOutline(sbatch, outerBounds.AsInflated(1f, 1f), FlatColors.MidnightBlue, 8, 2f, 0.5f * GDConstants.TILE_WIDTH);

            sbatch.DrawRectangle(innerBounds, Color.Black);

            var rot = FloatMath.Sin(Lifetime * FloatMath.TAU / _swingPeriode) * FloatMath.RAD_POS_005;

            sbatch.DrawCentered(Textures.TexIconLock, innerBounds.Center, INNERSIZE * 0.75f, INNERSIZE * 0.75f, Color.White, rot);

            FontRenderHelper.DrawTextCentered(sbatch, Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH, L10N.T(_l10ndescription), FlatColors.Asbestos, Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH));
        }
Ejemplo n.º 19
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.º 20
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            if (node == null)
            {
                return;
            }

            SimpleRenderHelper.DrawRoundedRect(sbatch, bounds, Color.Black * 0.8f * progressDisplay, true, false, false, false, 16);

            sbatch.DrawLine(Position + new Vector2(0, HEADER_HEIGHT), Position + new Vector2(Width, HEADER_HEIGHT), FlatColors.MidnightBlue * progressDisplay, 2);

            sbatch.DrawLine(Position + new Vector2(1 * (Width / 3f), 0), Position + new Vector2(1 * (Width / 3f), 32), FlatColors.MidnightBlue * progressDisplay, 2);
            sbatch.DrawLine(Position + new Vector2(2 * (Width / 3f), 0), Position + new Vector2(2 * (Width / 3f), 32), FlatColors.MidnightBlue * progressDisplay, 2);

            FontRenderHelper.DrawTextCentered(sbatch, (tab == 0 ? Textures.HUDFontBold : Textures.HUDFontRegular), 32, L10N.T(_header1), (tab == 0 ? FlatColors.TextHUD : FlatColors.Asbestos) * progressDisplay, Position + new Vector2(1 * (Width / 6f), HEADER_HEIGHT / 2f));
            FontRenderHelper.DrawTextCentered(sbatch, (tab == 1 ? Textures.HUDFontBold : Textures.HUDFontRegular), 32, L10N.T(_header2), (tab == 1 ? FlatColors.TextHUD : FlatColors.Asbestos) * progressDisplay, Position + new Vector2(3 * (Width / 6f), HEADER_HEIGHT / 2f));
            FontRenderHelper.DrawTextCentered(sbatch, (tab == 2 ? Textures.HUDFontBold : Textures.HUDFontRegular), 32, L10N.T(_header3), (tab == 2 ? FlatColors.TextHUD : FlatColors.Asbestos) * progressDisplay, Position + new Vector2(5 * (Width / 6f), HEADER_HEIGHT / 2f));

            if (tab == 0)
            {
                // Best time local

                DrawInfoLine(sbatch, FractionDifficulty.DIFF_0, 0, node.LevelData.GetTimeString(FractionDifficulty.DIFF_0, true), true);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_1, 1, node.LevelData.GetTimeString(FractionDifficulty.DIFF_1, true), true);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_2, 2, node.LevelData.GetTimeString(FractionDifficulty.DIFF_2, true), true);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_3, 3, node.LevelData.GetTimeString(FractionDifficulty.DIFF_3, true), true);
            }
            else if (tab == 1)
            {
                // Best time global

                DrawInfoLine(sbatch, FractionDifficulty.DIFF_0, 0, TimeExtension.FormatMilliseconds(node.LevelData.Data[FractionDifficulty.DIFF_0].GlobalBestTime, true), true);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_1, 1, TimeExtension.FormatMilliseconds(node.LevelData.Data[FractionDifficulty.DIFF_1].GlobalBestTime, true), true);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_2, 2, TimeExtension.FormatMilliseconds(node.LevelData.Data[FractionDifficulty.DIFF_2].GlobalBestTime, true), true);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_3, 3, TimeExtension.FormatMilliseconds(node.LevelData.Data[FractionDifficulty.DIFF_3].GlobalBestTime, true), true);
            }
            else if (tab == 2)
            {
                // global count

                DrawInfoLine(sbatch, FractionDifficulty.DIFF_0, 0, PositiveOrZero(node.LevelData.Data[FractionDifficulty.DIFF_0].GlobalCompletionCount), false);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_1, 1, PositiveOrZero(node.LevelData.Data[FractionDifficulty.DIFF_1].GlobalCompletionCount), false);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_2, 2, PositiveOrZero(node.LevelData.Data[FractionDifficulty.DIFF_2].GlobalCompletionCount), false);
                DrawInfoLine(sbatch, FractionDifficulty.DIFF_3, 3, PositiveOrZero(node.LevelData.Data[FractionDifficulty.DIFF_3].GlobalCompletionCount), false);
            }
        }
Ejemplo n.º 21
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);
            }
        }
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            sbatch.FillRectangle(bounds, _colSource.Background);

            float rowHeight = _colSource.FontSize + 2 * _colSource.LineWidth;

            // rows
            {
                float x = 0;
                for (int ci = 0; ci < _data.Count; ci++)
                {
                    if (FloatMath.IsZero(_colSource.GetColumnWidth(ci)))
                    {
                        continue;
                    }

                    FontRenderHelper.DrawTextVerticallyCentered(
                        sbatch,
                        _colSource.Font,
                        _colSource.FontSize,
                        _data[ci],
                        Foreground,
                        new FPoint(bounds.Left + x + _colSource.LineWidth * 2, bounds.Top + rowHeight / 2f));

                    x += _colSource.GetColumnWidth(ci);
                }
            }

            // scroll
            {
                sbatch.FillRectangle(new FRectangle(bounds.Right - _colSource.ScrollWidth, bounds.Top, _colSource.ScrollWidth, bounds.Height), _colSource.ScrollThumbColor);
            }

            // Vert Lines
            {
                float x = 0;
                for (int i = 0; i < _data.Count; i++)
                {
                    x += _colSource.GetColumnWidth(i);
                    sbatch.DrawLine(bounds.Left + x, bounds.Top, bounds.Left + x, bounds.Bottom, _colSource.LineColor, _colSource.LineWidth);
                }
            }

            sbatch.DrawRectangle(bounds, _colSource.LineColor, _colSource.LineWidth);
        }
Ejemplo n.º 23
0
        public override void Update(SAMTime gameTime, InputState istate)
        {
            base.Update(gameTime, istate);

            if (Mode == ServerMode.CreatingNewGame)
            {
                Screen = null;
            }
            if (Mode == ServerMode.BeforeNewGame)
            {
                Screen = null;
            }

            if (ConnType == MultiplayerConnectionType.P2P)
            {
                var btm = (BluetoothNetworkMedium)_medium;

                if (btm.Events.Count > 0)
                {
                    var evt = btm.Events.Dequeue();

                    var param = FontRenderHelper.MakeTextSafe(Textures.HUDFontRegular, evt.Param, '?');

                    switch (evt.Type)
                    {
                    case BluetoothMediumEvent.BTEvent.TryConnection:
                        MainGame.Inst.ShowToast(null, L10N.TF(L10NImpl.STR_MP_TOAST_CONN_TRY, param), 40, FlatColors.Silver, FlatColors.Foreground, 2f);
                        break;

                    case BluetoothMediumEvent.BTEvent.ConnectionFailed:
                        MainGame.Inst.ShowToast(null, L10N.TF(L10NImpl.STR_MP_TOAST_CONN_FAIL, param), 40, FlatColors.Orange, FlatColors.Foreground, 2f);
                        break;

                    case BluetoothMediumEvent.BTEvent.ConnectionSucceeded:
                        MainGame.Inst.ShowToast(null, L10N.TF(L10NImpl.STR_MP_TOAST_CONN_SUCC, param), 40, FlatColors.Emerald, FlatColors.Foreground, 2f);
                        break;

                    default:
                        SAMLog.Error("GDMPC::Update_Evt", "type = " + evt.Type);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 24
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            var outerBounds = FRectangle.CreateByCenter(Position, DrawingBoundingBox);
            var innerBounds = FRectangle.CreateByCenter(Position, new FSize(INNERSIZE, INNERSIZE));

            FlatRenderHelper.DrawRoundedBlurPanel(sbatch, outerBounds, clickArea.IsMouseDown() ? FlatColors.ButtonPressedHUD : FlatColors.Asbestos, 0.5f * GDConstants.TILE_WIDTH);
            SimpleRenderHelper.DrawRoundedRectOutline(sbatch, outerBounds.AsInflated(1f, 1f), FlatColors.MidnightBlue, 8, 2f, 0.5f * GDConstants.TILE_WIDTH);

            sbatch.FillRectangle(innerBounds, FlatColors.Background);

            var scoreRectSize = innerBounds.Width / 10f;

            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 10; y++)
                {
                    var bc = ((x % 2 == 0) ^ (y % 2 == 0)) ? FlatColors.Background : FlatColors.BackgroundLight;

                    if (_ustate == WorldUnlockState.OpenAndUnlocked)
                    {
                        var d = FloatMath.Sqrt((x - 4.5f) * (x - 4.5f) + (y - 4.5f) * (y - 4.5f));

                        var p = FloatMath.PercSin(FloatMath.PI * 3 * d / 14f - Lifetime);

                        p *= 0.25f;

                        bc = ColorMath.Blend(bc, FlatColors.PeterRiver, p);
                    }

                    var col = ColorMath.Blend(FlatColors.Background, bc, AlphaOverride);
                    sbatch.FillRectangle(new FRectangle(innerBounds.X + scoreRectSize * x, innerBounds.Y + scoreRectSize * y, scoreRectSize, scoreRectSize), col);
                }
            }

            foreach (var block in Blocks)
            {
                sbatch.FillRectangle(block.Item1.WithOrigin(Position), block.Item2);
            }

            sbatch.DrawRectangle(innerBounds, Color.Black, Owner.PixelWidth);

            FontRenderHelper.DrawTextCentered(sbatch, Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH, L10N.T(_l10ndescription), FlatColors.TextHUD, Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH));
        }
Ejemplo n.º 25
0
        private void DrawInfoLine(IBatchRenderer sbatch, FractionDifficulty d, int idx, string strTime, bool colorize)
        {
            var p1 = Position + new Vector2(32, HEADER_HEIGHT + 40 + 56 * idx);
            var p2 = Position + new Vector2(64, HEADER_HEIGHT + 40 + 56 * idx);
            var p3 = Position + new Vector2(224, HEADER_HEIGHT + 40 + 56 * idx);

            var ic = (node.LevelData.HasCompletedOrBetter(d) ? FractionDifficultyHelper.GetColor(d) : FlatColors.Concrete) * progressDisplay;
            var tc = (node.LevelData.HasCompletedOrBetter(d) ? FlatColors.TextHUD : FlatColors.Asbestos) * progressDisplay;

            if (colorize && node.LevelData.Data[d].GlobalBestUserID >= 0 && node.LevelData.Data[d].GlobalBestUserID == MainGame.Inst.Profile.OnlineUserID)
            {
                tc = FlatColors.SunFlower * progressDisplay;
            }

            sbatch.DrawCentered(Textures.TexCircle, p1, 48, 48, FlatColors.WetAsphalt * progressDisplay);
            sbatch.DrawCentered(FractionDifficultyHelper.GetIcon(d), p1, 32, 32, ic);
            FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontRegular, 32, FractionDifficultyHelper.GetDescription(d), tc, p2);
            FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontRegular, 32, strTime, tc, p3);
        }
Ejemplo n.º 26
0
 private void InternalDraw(IBatchRenderer sbatch, FRectangle bounds, string textBase, string textAlt)
 {
     if (Icon != null)
     {
         var b = Icon.Size().Underfit(bounds.Size, IconPadding);
         sbatch.DrawCentered(Icon, bounds.Center, b.Width, b.Height, HUDKeyboard.COLOR_TEXT);
     }
     else
     {
         if (!string.IsNullOrEmpty(textBase))
         {
             FontRenderHelper.DrawTextCentered(sbatch, HUD.DefaultFont, TextSize, textBase, HUDKeyboard.COLOR_TEXT, bounds.Center);
         }
         if (!string.IsNullOrEmpty(textAlt))
         {
             FontRenderHelper.DrawTextTopRight(sbatch, HUD.DefaultFont, TextSizeAlt, textAlt, HUDKeyboard.COLOR_ALT, bounds.TopRight + new Vector2(-TextAltPadding, 0));
         }
     }
 }
Ejemplo n.º 27
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.º 28
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            var bottomrect = bounds.ToSubRectangleSouth(25);

            SimpleRenderHelper.DrawSimpleRect(sbatch, bounds, FlatColors.Clouds);
            SimpleRenderHelper.DrawSimpleRect(sbatch, bottomrect, FlatColors.Concrete);

            FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 32, _data.Name, FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5, bounds.Top + (bounds.Height - 25) / 2));
            FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 20, MainGame.Inst.Profile.OnlineUsername, FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5 + 16, bounds.Bottom - 12.5f));

            sbatch.DrawCentered(Textures.TexHUDIconGenericUser, new FPoint(bottomrect.Left + 5 + 32 + 5, bottomrect.CenterY), 20, 20, FlatColors.WetAsphalt);

            if (_data.Size != SCCMLevelData.SIZES[0])
            {
                var rr = bounds.ToSubRectangleSouthWest(32, 20);
                SimpleRenderHelper.DrawSimpleRect(sbatch, rr, FlatColors.Amethyst);
                FontRenderHelper.DrawSingleLineInBox(sbatch, Textures.HUDFontRegular, "XL", rr, 0, true, FlatColors.Foreground);
            }

            SimpleRenderHelper.DrawSimpleRectOutline(sbatch, bounds, HUD.PixelWidth, Color.Black);
        }
Ejemplo n.º 29
0
        protected override void OnDraw(IBatchRenderer sbatch)
        {
            SimpleRenderHelper.DrawSimpleRect(sbatch, FRectangle.CreateByCenter(Position, DIAMETER, DIAMETER), clickAreaThis.IsMouseDown() ? FlatColors.WetAsphalt : FlatColors.Asbestos);
            SimpleRenderHelper.DrawSimpleRectOutline(sbatch, FRectangle.CreateByCenter(Position, DIAMETER, DIAMETER), 2, FlatColors.MidnightBlue);

            SimpleRenderHelper.DrawRoundedRect(sbatch, FRectangle.CreateByCenter(Position, INNER_DIAMETER, INNER_DIAMETER), NodeEnabled ? ColorMath.Blend(Color.Black, FlatColors.Background, ColorOverdraw) : FlatColors.Asbestos);

            FontRenderHelper.DrawTextCenteredWithBackground(
                sbatch,
                Textures.HUDFontBold, 0.9f * GDConstants.TILE_WIDTH,
                L10N.T(Levels.WORLD_NAMES[Target.ID]),
                FlatColors.TextHUD,
                Position + new Vector2(0, 2.25f * GDConstants.TILE_WIDTH),
                FlatColors.BackgroundHUD2 * 0.5f);

            if (!NodeEnabled)
            {
                var scale = 1 + FloatMath.Sin(Lifetime) * 0.05f;
                sbatch.DrawCentered(Textures.TexIconLock, Position, INNER_DIAMETER * scale, INNER_DIAMETER * scale, Color.Black);
            }
        }
Ejemplo n.º 30
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            var bottomrect = bounds.ToSubRectangleSouth(25);

            {             // background
                SimpleRenderHelper.DrawSimpleRect(sbatch, bounds, FlatColors.Clouds);
                SimpleRenderHelper.DrawSimpleRect(sbatch, bottomrect, FlatColors.Concrete);
            }

            {             // difficulty
                var tex = (PersonalBest == null) ? Textures.TexDifficultyLineNone : FractionDifficultyHelper.GetIcon(PersonalBest.Value);
                var col = (PersonalBest == null) ? FlatColors.Silver : FractionDifficultyHelper.GetColor(PersonalBest.Value);
                sbatch.DrawCentered(tex, new FPoint(bounds.Left + 5 + 16, bounds.Top + (Height - 25 - 32) / 2 + 16), 32, 32, col);
            }

            {             // name
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 32, _meta.LevelName, FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5, bounds.Top + (bounds.Height - 25) / 2));
            }

            {             // user
                sbatch.DrawCentered(Textures.TexHUDIconGenericUser, new FPoint(bottomrect.Left + 5 + 32 + 5, bottomrect.CenterY), 20, 20, FlatColors.WetAsphalt);
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 20, _meta.Username ?? "Unknown", FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5 + 16, bounds.Bottom - 12.5f));
            }


            if (_meta.GridSize != SCCMLevelData.SIZES[0])             // [XL] marker
            {
                var rr = bounds.ToSubRectangleSouthWest(32, 20);
                SimpleRenderHelper.DrawSimpleRect(sbatch, rr, FlatColors.Amethyst);
                FontRenderHelper.DrawSingleLineInBox(sbatch, Textures.HUDFontRegular, "XL", rr, 0, true, FlatColors.Foreground);
            }

            {             // star counter
                var pointPos = new FPoint(bottomrect.Right - 100, bottomrect.CenterY);
                sbatch.DrawCentered(Textures.TexIconStar, pointPos, 20, 20, FlatColors.SunFlower);
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 24, _meta.Stars.ToString(), FlatColors.MidnightBlue, pointPos + new Vector2(16, 0));
            }

            SimpleRenderHelper.DrawSimpleRectOutline(sbatch, bounds, HUD.PixelWidth, Color.Black);
        }