예제 #1
0
        public HUDLabel AddPreviewLine()
        {
            var scale = _target.HUD.Width / _virtualWidth;

            var x = currentVirtualX;
            var y = _padNS + currentRow * _rowHeight + currentRow * _padKey;

            var w = _virtualWidth - x - _padEW;
            var h = _rowHeight;

            var pnl = new HUDRectangle(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(x * scale, y * scale),
                Size             = new FSize(w * scale, h * scale),

                Definition = HUDBackgroundDefinition.CreateRounded(HUDKeyboard.COLOR_PREVIEW_BG, scale * 0.1f),
            };

            _target.AddElement(pnl);

            var padH = h * 0.25f;
            var padV = h * 0.1f;

            var lbl = new HUDLabel(2)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((x + padH) * scale, (y + padV) * scale),
                Size             = new FSize((w - 2 * padH) * scale, (h - 2 * padV) * scale),
                TextColor        = HUDKeyboard.COLOR_PREVIEW_TEXT,
                FontSize         = (h - 2 * padV) * scale,
                TextAlignment    = HUDAlignment.CENTERLEFT,
            };

            _target.AddElement(lbl);

            NextRow();

            return(lbl);
        }
예제 #2
0
        public GDMultiplayerGameHUD(GDGameScreen scrn, GDMultiplayerCommon mp) : base(scrn, Textures.HUDFontRegular)
        {
            AddElement(new HUDPauseButton(false, false, true));

            _backgroundRect = new HUDRectangle(-10)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = FPoint.Zero,
                Definition       = HUDBackgroundDefinition.CreateSimple(Color.Black * 0.3f),
                Size             = new FSize(100, 100),
            };
            AddElement(_backgroundRect);

            var mpcsc = new MultiplayerConnectionStateControl(mp)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(4, 4),
                TextColor        = FlatColors.Clouds,
            };

            AddElement(mpcsc);
            _cornerElements.Add(mpcsc);

            if (mp.SessionUserID == 0)
            {
                if (mp.SessionCapacity == 2)
                {
                    var lbl = new HUDLambdaLabel
                    {
                        Alignment        = HUDAlignment.TOPLEFT,
                        RelativePosition = new FPoint(4, 44),
                        Font             = Textures.HUDFontBold,
                        FontSize         = 32,
                        Size             = new FSize(200, 32),
                        TextColor        = FlatColors.Clouds,
                        AutoSize         = true,

                        Lambda = () => (mp.ConnState == SAMNetworkConnection.ConnectionState.Offline) ? "Ping: -" : $"Ping: {(int) (mp.UserConn[1].InGamePing.Value * 1000)}ms",
                    };
                    AddElement(lbl);
                    _cornerElements.Add(lbl);
                }
                else
                {
                    int idx = 0;
                    for (int i = 1; i < mp.SessionCapacity; i++)
                    {
                        int uid = i;

                        var lbl = new HUDLambdaLabel
                        {
                            Alignment        = HUDAlignment.TOPLEFT,
                            RelativePosition = new FPoint(4, 44 + 40 * idx),
                            Font             = Textures.HUDFontBold,
                            FontSize         = 32,
                            Size             = new FSize(200, 32),
                            TextColor        = Color.White,
                            AutoSize         = true,

                            Lambda = () => $"Ping[{uid}]: {(int) (mp.UserConn[uid].InGamePing.Value * 1000)}ms",
                        };
                        AddElement(lbl);
                        _cornerElements.Add(lbl);

                        idx++;
                    }
                }
            }
            else
            {
                var lbl = new HUDLambdaLabel
                {
                    Alignment        = HUDAlignment.TOPLEFT,
                    RelativePosition = new FPoint(4, 44),
                    Font             = Textures.HUDFontBold,
                    FontSize         = 32,
                    Size             = new FSize(200, 32),
                    TextColor        = Color.White,
                    AutoSize         = true,

                    Lambda = () => $"Ping: {(int) (mp.UserConn[0].InGamePing.Value * 1000)}ms",
                };

                AddElement(lbl);
                _cornerElements.Add(lbl);
            }

            _countdown = new HUDImage(100)
            {
                Alignment      = HUDAlignment.CENTER,
                Image          = Textures.TexTitleNumber[3],
                ImageAlignment = HUDImageAlignmentAlgorithm.CENTER,
                ImageScale     = HUDImageScaleAlgorithm.UNDERSCALE,

                Size = new FSize(320, 320),
            };
            AddElement(_countdown);

            var x = _cornerElements.Max(e => e.Right);
            var y = _cornerElements.Max(e => e.Bottom);

            _backgroundRect.Size = new FSize(x + 4f, y + 4f);
        }