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);
            }
        }
Esempio n. 2
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;
            }
        }
Esempio n. 3
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;
                    }
                }
            }
        }