Ejemplo n.º 1
0
        private void RefreshControls()
        {
            _ctrlID.Text    = $"{_id:000000000000}";
            _ctrlName.Text  = _name;
            _ctrlSize.Text  = _size.Width + "x" + _size.Height;
            _ctrlView.Text  = FlatAlign9Helper.LETTERS[_view];
            _ctrlMusic.Text = _music < 0 ? L10N.T(L10NImpl.STR_MUSIC_NONE) : L10N.TF(L10NImpl.STR_MUSIC_INT, _music + 1);
            switch (_geometry)
            {
            case GameWrapMode.Death:
                _ctrlGeometry.L10NText = L10NImpl.STR_LVLED_CFG_WRAP_INFINITY;
                break;

            case GameWrapMode.Donut:
                _ctrlGeometry.L10NText = L10NImpl.STR_LVLED_CFG_WRAP_DONUT;
                break;

            case GameWrapMode.Reflect:
                _ctrlGeometry.L10NText = L10NImpl.STR_LVLED_CFG_WRAP_REFLECT;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 2
0
        private void OnClickFinishPrev(HUDTextButton sender, HUDButtonEventArgs args)
        {
            if (_unlockWorldNumber == 0)
            {
                MainGame.Inst.SetTutorialLevelScreen();
                return;
            }

            int missPoints = UnlockManager.PointsForUnlock(_id) - MainGame.Inst.Profile.TotalPoints;

            HUD.ShowToast("WPP::HINT", L10N.TF(L10NImpl.STR_PREV_MISS_TOAST, missPoints, _worldNumber), 32, FlatColors.Orange, FlatColors.Foreground, 4f);

            MainGame.Inst.SetWorldMapScreenZoomedOut(Levels.WORLDS_BY_NUMBER[_unlockWorldNumber]);
        }
Ejemplo 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;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void ShowScorePanel(LevelBlueprint lvl, PlayerProfile profile, HashSet <FractionDifficulty> newDifficulties, bool playerHasWon, int addPoints, int time)
        {
            ((GDGameHUD)HUD).BtnPause.IsEnabled = false;
            ((GDGameHUD)HUD).BtnSpeed.IsEnabled = false;

            GameSpeedMode = GameSpeedModes.NORMAL;

            HUD.AddModal(new HUDScorePanel(lvl, profile, newDifficulties, Difficulty, playerHasWon, addPoints, time), false);

            if (playerHasWon && (MainGame.Flavor == GDFlavor.IAB || MainGame.Flavor == GDFlavor.IAB_NOMP))
            {
                var diff = UnlockManager.GetFullUnlockState().Except(_unlocksBefore);
                foreach (var d in diff)
                {
                    if (d == Levels.WORLD_ID_ONLINE)
                    {
                        AchievementPopup.Show(L10N.T(L10NImpl.STR_ACH_UNLOCK_ONLINE));
                    }
                    if (d == Levels.WORLD_ID_MULTIPLAYER)
                    {
                        AchievementPopup.Show(L10N.T(L10NImpl.STR_ACH_UNLOCK_MULTIPLAYER));
                    }
                    if (d == Levels.WORLD_001.ID)
                    {
                        AchievementPopup.Show(L10N.TF(L10NImpl.STR_ACH_UNLOCK_WORLD, 1));
                    }
                    if (d == Levels.WORLD_002.ID)
                    {
                        AchievementPopup.Show(L10N.TF(L10NImpl.STR_ACH_UNLOCK_WORLD, 2));
                    }
                    if (d == Levels.WORLD_003.ID)
                    {
                        AchievementPopup.Show(L10N.TF(L10NImpl.STR_ACH_UNLOCK_WORLD, 3));
                    }
                    if (d == Levels.WORLD_004.ID)
                    {
                        AchievementPopup.Show(L10N.TF(L10NImpl.STR_ACH_UNLOCK_WORLD, 4));
                    }
                }
            }
        }
Ejemplo n.º 5
0
        protected override void OnPointerClick(FPoint relPositionPoint, InputState istate)
        {
            if (_rectHeader1.Contains(relPositionPoint))
            {
                var tabNext = 0;
                tabTimer = tabNext * TAB_SWITCHTIME;
            }
            else if (_rectHeader2.Contains(relPositionPoint))
            {
                var tabNext = 1;
                tabTimer = tabNext * TAB_SWITCHTIME;
            }
            else if (_rectHeader3.Contains(relPositionPoint))
            {
                var tabNext = 2;
                tabTimer = tabNext * TAB_SWITCHTIME;
            }
            else if (_rectRow1.Contains(relPositionPoint))
            {
                tabTimer = tab * TAB_SWITCHTIME;

                switch (tab)
                {
                case 0:
                    if (node.LevelData.HasCompletedExact(FractionDifficulty.DIFF_0))
                    {
                        Toast_1(L10N.TF(L10NImpl.STR_INFOTOAST_1, node.LevelData.GetTimeString(FractionDifficulty.DIFF_0, true)));
                    }
                    else
                    {
                        Toast_4(L10N.TF(L10NImpl.STR_INFOTOAST_4, FractionDifficultyHelper.GetDescription(FractionDifficulty.DIFF_0)));
                    }
                    break;

                case 1:
                    Toast_2(L10N.TF(L10NImpl.STR_INFOTOAST_2, TimeExtension.FormatMilliseconds(node.LevelData.Data[FractionDifficulty.DIFF_0].GlobalBestTime, true)));
                    break;

                case 2:
                    Toast_3(L10N.TF(L10NImpl.STR_INFOTOAST_3, PositiveOrZero(node.LevelData.Data[FractionDifficulty.DIFF_0].GlobalCompletionCount), FractionDifficultyHelper.GetDescription(FractionDifficulty.DIFF_0)));
                    break;

                default:
                    SAMLog.Error("INFD::EnumSwitch_OPC1", "value: " + tab);
                    break;
                }
            }
            else if (_rectRow2.Contains(relPositionPoint))
            {
                tabTimer = tab * TAB_SWITCHTIME;

                switch (tab)
                {
                case 0:
                    if (node.LevelData.HasCompletedExact(FractionDifficulty.DIFF_1))
                    {
                        Toast_1(L10N.TF(L10NImpl.STR_INFOTOAST_1, node.LevelData.GetTimeString(FractionDifficulty.DIFF_1, true)));
                    }
                    else
                    {
                        Toast_4(L10N.TF(L10NImpl.STR_INFOTOAST_4, FractionDifficultyHelper.GetDescription(FractionDifficulty.DIFF_1)));
                    }
                    break;

                case 1:
                    Toast_2(L10N.TF(L10NImpl.STR_INFOTOAST_2, TimeExtension.FormatMilliseconds(node.LevelData.Data[FractionDifficulty.DIFF_1].GlobalBestTime, true)));
                    break;

                case 2:
                    Toast_3(L10N.TF(L10NImpl.STR_INFOTOAST_3, PositiveOrZero(node.LevelData.Data[FractionDifficulty.DIFF_1].GlobalCompletionCount), FractionDifficultyHelper.GetDescription(FractionDifficulty.DIFF_1)));
                    break;


                default:
                    SAMLog.Error("INFD::EnumSwitch_OPC2", "value: " + tab);
                    break;
                }
            }
            else if (_rectRow3.Contains(relPositionPoint))
            {
                tabTimer = tab * TAB_SWITCHTIME;

                switch (tab)
                {
                case 0:
                    if (node.LevelData.HasCompletedExact(FractionDifficulty.DIFF_2))
                    {
                        Toast_1(L10N.TF(L10NImpl.STR_INFOTOAST_1, node.LevelData.GetTimeString(FractionDifficulty.DIFF_2, true)));
                    }
                    else
                    {
                        Toast_4(L10N.TF(L10NImpl.STR_INFOTOAST_4, FractionDifficultyHelper.GetDescription(FractionDifficulty.DIFF_2)));
                    }
                    break;

                case 1:
                    Toast_1(L10N.TF(L10NImpl.STR_INFOTOAST_2, TimeExtension.FormatMilliseconds(node.LevelData.Data[FractionDifficulty.DIFF_2].GlobalBestTime, true)));
                    break;

                case 2:
                    Toast_2(L10N.TF(L10NImpl.STR_INFOTOAST_3, PositiveOrZero(node.LevelData.Data[FractionDifficulty.DIFF_2].GlobalCompletionCount), FractionDifficultyHelper.GetDescription(FractionDifficulty.DIFF_2)));
                    break;


                default:
                    SAMLog.Error("INFD::EnumSwitch_OPC3", "value: " + tab);
                    break;
                }
            }
            else if (_rectRow4.Contains(relPositionPoint))
            {
                tabTimer = tab * TAB_SWITCHTIME;

                switch (tab)
                {
                case 0:
                    if (node.LevelData.HasCompletedExact(FractionDifficulty.DIFF_3))
                    {
                        Toast_1(L10N.TF(L10NImpl.STR_INFOTOAST_1, node.LevelData.GetTimeString(FractionDifficulty.DIFF_3, true)));
                    }
                    else
                    {
                        Toast_4(L10N.TF(L10NImpl.STR_INFOTOAST_4, FractionDifficultyHelper.GetDescription(FractionDifficulty.DIFF_3)));
                    }
                    break;

                case 1:
                    Toast_2(L10N.TF(L10NImpl.STR_INFOTOAST_2, TimeExtension.FormatMilliseconds(node.LevelData.Data[FractionDifficulty.DIFF_3].GlobalBestTime, true)));
                    break;

                case 2:
                    Toast_3(L10N.TF(L10NImpl.STR_INFOTOAST_3, PositiveOrZero(node.LevelData.Data[FractionDifficulty.DIFF_3].GlobalCompletionCount), FractionDifficultyHelper.GetDescription(FractionDifficulty.DIFF_3)));
                    break;


                default:
                    SAMLog.Error("INFD::EnumSwitch_OPC4", "value: " + tab);
                    break;
                }
            }
            else
            {
                var tabNext = (int)(tabTimer / TAB_SWITCHTIME + 1) % 3;
                tabTimer = tabNext * TAB_SWITCHTIME;
            }
        }
Ejemplo n.º 6
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            string txt = "?";

            if (_showMultiplayer)
            {
                txt = L10N.T(L10NImpl.STR_HSP_MULTIPLAYERRANKING);
            }
            else if (_focus == null)
            {
                txt = L10N.T(L10NImpl.STR_HSP_GLOBALRANKING);
            }
            else
            {
                txt = L10N.TF(L10NImpl.STR_HSP_RANKINGFOR, L10N.T(Levels.WORLD_NAMES[_focus.ID]));
            }

            AddElement(new HUDLabel(1)
            {
                TextAlignment    = (_showMultiplayer || _focus == null) ? HUDAlignment.CENTER : HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPCENTER,
                RelativePosition = new FPoint(0, 0),
                Size             = new FSize(TAB_WIDTH, TEXT_HEIGHT_REAL),

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                Text      = txt,
                TextColor = FlatColors.Clouds,
            });

            if (MainGame.Inst.Profile.HasMultiplayerGames)
            {
                if (!_showMultiplayer)
                {
                    AddElement(_btn = new HUDTextButton(1)
                    {
                        Alignment        = HUDAlignment.TOPRIGHT,
                        RelativePosition = FPoint.Zero,
                        Size             = new FSize(3.5f * GDConstants.TILE_WIDTH, 48),

                        L10NText      = L10NImpl.STR_WORLD_MULTIPLAYER,
                        TextColor     = FlatColors.Foreground,
                        Font          = Textures.HUDFontBold,
                        FontSize      = 42,
                        TextAlignment = HUDAlignment.CENTER,
                        TextPadding   = 8,

                        BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Amethyst, 16, false, true, false, false),
                        BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Wisteria, 16, false, true, false, false),

                        Click = ShowMultiplayer,

                        IsVisible = false,
                    });
                }
                else
                {
                    AddElement(_btn = new HUDTextButton(1)
                    {
                        Alignment        = HUDAlignment.TOPRIGHT,
                        RelativePosition = FPoint.Zero,
                        Size             = new FSize(3.5f * GDConstants.TILE_WIDTH, 48),

                        L10NText      = L10NImpl.STR_WORLD_SINGLEPLAYER,
                        TextColor     = FlatColors.Foreground,
                        Font          = Textures.HUDFontBold,
                        FontSize      = 42,
                        TextAlignment = HUDAlignment.CENTER,
                        TextPadding   = 8,

                        BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Amethyst, 16, false, true, false, false),
                        BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Wisteria, 16, false, true, false, false),

                        Click = ShowSingleplayer,

                        IsVisible = false,
                    });
                }
            }

            _loader = new HUDImage
            {
                RelativePosition = new FPoint(0, TEXT_HEIGHT / 2f),
                Alignment        = HUDAlignment.CENTER,
                Size             = new FSize(2 * GDConstants.TILE_WIDTH, 2 * GDConstants.TILE_WIDTH),
                Color            = FlatColors.Clouds,
                Image            = Textures.CannonCogBig,

                RotationSpeed = 0.1f,

                IsVisible = true,
            };
            AddElement(_loader);

            _table = new HUDScrollTable
            {
                RelativePosition = new FPoint(0, TEXT_HEIGHT / 2f),
                Alignment        = HUDAlignment.CENTER,
                Size             = new FSize(TAB_WIDTH, TAB_HEIGHT),

                Background       = FlatColors.BackgroundHUD2,
                Foreground       = FlatColors.TextHUD,
                LineColor        = Color.Black,
                HeaderBackground = FlatColors.Asbestos,
                HeaderForeground = Color.Black,
                ScrollThumbColor = FlatColors.Silver,
                ScrollWidth      = 16,
                ScrollHeight     = 64,
                LineWidth        = 2 * HUD.PixelWidth,
                FontSize         = 32,

                IsVisible = false,
            };
            _table.FixHeightToMultipleOfRowHeight();
            AddElement(_table);

            _table.AddColumn("", 100);
            _table.AddColumn(L10N.T(L10NImpl.STR_TAB_NAME), null);
            _table.AddColumn(L10N.T(L10NImpl.STR_TAB_POINTS), 100);
            if (!_showMultiplayer)
            {
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_TIME), 175);
            }

            LoadHighscore().EnsureNoError();
        }
Ejemplo n.º 7
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            AddElement(new HUDLabel(1)
            {
                TextAlignment    = HUDAlignment.CENTER,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(0, 0),
                Size             = new FSize(WIDTH, 96),

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                L10NText  = _server.ConnType == MultiplayerConnectionType.PROXY ? L10NImpl.STR_MENU_CAP_CGAME_PROX : L10NImpl.STR_MENU_CAP_CGAME_P2P,
                TextColor = FlatColors.Clouds,
            });

            AddElement(new MultiplayerConnectionStateControl(_server)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(16, 16)
            });

            var screen = new GDGameScreen_Display(MainGame.Inst, MainGame.Inst.Graphics, _currentLevel);

            AddElement(_displayScreen = new HUDSubScreenProxyRenderer(screen)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((2 / 3f) * GDConstants.TILE_WIDTH, 3.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(6 * GDConstants.TILE_WIDTH, 3.75f * GDConstants.TILE_WIDTH),
            });


            AddElement(new HUDImageButton
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((5 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(32, 48),

                Image        = Textures.TexHUDIconChevronLeft,
                ImagePadding = 4,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 8f, true, false, true, false),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 8f, true, false, true, false),

                Click = (s, a) => ChangeID1(-1),
            });

            AddElement(_lblLevelID1 = new HUDClickableLabel
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((8 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),

                Size     = new FSize(96, 48),
                FontSize = 48,
                Font     = Textures.HUDFontRegular,

                Text          = "?",
                TextAlignment = HUDAlignment.CENTER,
                TextColor     = FlatColors.Clouds,

                Background = HUDBackgroundDefinition.CreateSimple(FlatColors.BackgroundHUD2),

                Click      = (s, a) => ChangeID1(+1),
                ClickSound = true,
            });

            AddElement(new HUDImageButton
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((17 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(32, 48),

                Image        = Textures.TexHUDIconChevronRight,
                ImagePadding = 4,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 8f, false, true, false, true),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 8f, false, true, false, true),

                Click = (s, a) => ChangeID1(+1),
            });


            AddElement(new HUDImageButton
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((24 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(32, 48),

                Image        = Textures.TexHUDIconChevronLeft,
                ImagePadding = 4,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 8f, true, false, true, false),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 8f, true, false, true, false),

                Click = (s, a) => ChangeID2(-1),
            });

            AddElement(_lblLevelID2 = new HUDClickableLabel
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((27 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),

                Size     = new FSize(96, 48),
                FontSize = 48,
                Font     = Textures.HUDFontRegular,

                Text          = "?",
                TextAlignment = HUDAlignment.CENTER,
                TextColor     = FlatColors.Clouds,

                Background = HUDBackgroundDefinition.CreateSimple(FlatColors.BackgroundHUD2),

                Click      = (s, a) => ChangeID2(+1),
                ClickSound = true,
            });

            AddElement(new HUDImageButton
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint((36 / 6f) * GDConstants.TILE_WIDTH, 2.25f * GDConstants.TILE_WIDTH),
                Size             = new FSize(32, 48),

                Image        = Textures.TexHUDIconChevronRight,
                ImagePadding = 4,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 8f, false, true, false, true),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 8f, false, true, false, true),

                Click = (s, a) => ChangeID2(+1),
            });


            AddElement(new HUDLambdaLabel
            {
                TextAlignment    = HUDAlignment.BOTTOMLEFT,
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(100 + 8, 375),
                Size             = new FSize(200, 32),

                Font     = Textures.HUDFontRegular,
                FontSize = 32,

                Lambda    = () => L10N.TF(L10NImpl.STR_MENU_MP_LOBBY_USER_FMT, _levelUserCount),
                TextColor = Color.White,
            });

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.BOTTOMLEFT,
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(100 + 8, 331),
                Size             = new FSize(200, 32),

                Font     = Textures.HUDFontRegular,
                FontSize = 32,

                L10NText  = L10NImpl.STR_MENU_MP_MUSIC,
                TextColor = Color.White,
            });

            int initialMusic = FloatMath.GetRangedIntRandom(5);

            AddElement(_music1 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(37, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 0,
                Selected         = initialMusic == 0,
            });

            AddElement(_music2 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(109, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 1,
                Selected         = initialMusic == 1,
            });

            AddElement(_music3 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(179, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 2,
                Selected         = initialMusic == 2,
            });

            AddElement(_music4 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(249, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 3,
                Selected         = initialMusic == 3,
            });

            AddElement(_music5 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(319, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 4,
                Selected         = initialMusic == 4,
            });

            AddElement(_music6 = new HUDRadioMusicButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(389, 261),
                Size             = new FSize(62, 62),
                MusicIndex       = 5,
                Selected         = initialMusic == 5,
            });

            _music1.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music2.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music3.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music4.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music5.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };
            _music6.RadioGroup = new List <HUDRadioMusicButton> {
                _music1, _music2, _music3, _music4, _music5, _music6
            };

            var initialSpeed = MainGame.Inst.Profile.LastMultiplayerHostedSpeed;

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.BOTTOMLEFT,
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(100 + 8, 221),
                Size             = new FSize(200, 32),

                Font     = Textures.HUDFontRegular,
                FontSize = 32,

                L10NText  = L10NImpl.STR_MENU_MP_GAMESPEED,
                TextColor = Color.White,
            });

            AddElement(_speed1 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(37, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.SUPERSLOW,
                Selected         = initialSpeed == GameSpeedModes.SUPERSLOW,
            });

            AddElement(_speed2 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(109, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.SLOW,
                Selected         = initialSpeed == GameSpeedModes.SLOW,
            });

            AddElement(_speed3 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(179, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.NORMAL,
                Selected         = initialSpeed == GameSpeedModes.NORMAL,
            });

            AddElement(_speed4 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(249, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.FAST,
                Selected         = initialSpeed == GameSpeedModes.FAST,
            });

            AddElement(_speed5 = new HUDRadioSpeedButton
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(319, 150),
                Size             = new FSize(62, 62),
                Speed            = GameSpeedModes.SUPERFAST,
                Selected         = initialSpeed == GameSpeedModes.SUPERFAST,
            });

            _speed1.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };
            _speed2.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };
            _speed3.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };
            _speed4.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };
            _speed5.RadioGroup = new List <HUDRadioSpeedButton> {
                _speed1, _speed2, _speed3, _speed4, _speed5
            };

            AddElement(new HUDRectangle(0)
            {
                Alignment = HUDAlignment.BOTTOMRIGHT,
                Size      = new FSize(WIDTH, FOOTER_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateRounded(FlatColors.BackgroundHUD2, 16, false, false, true, true),
            });

            AddElement(_btnCreate = new HUDIconTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 0.5f * GDConstants.TILE_WIDTH),
                Size             = new FSize(5.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH),

                Icon = null,
                IconRotationSpeed = 0.25f,

                L10NText      = L10NImpl.STR_MENU_MP_CREATE,
                TextColor     = Color.White,
                Font          = Textures.HUDFontBold,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.PeterRiver, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.BelizeHole, 16),

                Click = OnClickCreateLobby,
            });

            AddElement(new HUDTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 0.5f * GDConstants.TILE_WIDTH),
                Size             = new FSize(5.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH),

                L10NText      = L10NImpl.STR_MENU_CANCEL,
                TextColor     = Color.White,
                Font          = Textures.HUDFontBold,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Asbestos, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.MidnightBlue, 16),

                Click = OnClickCancel,
            });

            //---------------------

            if (!Levels.LEVELS.TryGetValue(MainGame.Inst.Profile.LastMultiplayerHostedLevel, out _currentLevel))
            {
                _currentLevel = Levels.LEVELS[Levels.LEVELID_1_3];
            }

            _currentWorld = Levels.WORLDS_MULTIPLAYER.FirstOrDefault(w => w.AllNodes.Any(n => n.ConnectionID == _currentLevel.UniqueID));
            if (_currentWorld == null)
            {
                _currentWorld = Levels.WORLD_001;
                _currentLevel = Levels.LEVELS[Levels.LEVELID_1_3];
            }

            UpdateLabels();
        }
Ejemplo n.º 8
0
        public override void Update(SAMTime gameTime, InputState istate)
        {
            base.Update(gameTime, istate);

            if (_server.Mode == SAMNetworkConnection.ServerMode.Stopped || _server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                bool dc = false;

                if (_btnNext != null && _btnNext.IsEnabled)
                {
                    _btnNext.BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16);
                    _btnNext.BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16);
                    _btnNext.IsEnabled         = false;
                    dc = true;
                }
                if (_btnRand != null && _btnRand.IsEnabled)
                {
                    _btnRand.BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16);
                    _btnRand.BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16);
                    _btnRand.IsEnabled         = false;
                    dc = true;
                }

                if (_server.ConnType == MultiplayerConnectionType.P2P && dc && _server.Mode == SAMNetworkConnection.ServerMode.Stopped)
                {
                    Owner.HUD.ShowToast("HMSP:ConnStop", L10N.TF(L10NImpl.STR_MP_TIMEOUT_USER, (_server.SessionUserID == 0) ? "1" : "0"), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);
                }
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.BroadcastNewGame ||
                _server.Mode == SAMNetworkConnection.ServerMode.BeforeNewGame ||
                _server.Mode == SAMNetworkConnection.ServerMode.CreatingNewGame)
            {
                _loadingCog.IsVisible = true;
            }

            if (_server.SessionUserID == 0 && _nextLevelRandom)
            {
                if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby)
                {
                    byte[] binData = _serverHost.GetLobbySyncData();
                    _server.StartLobbySync(binData);
                }

                if (_server.Mode == SAMNetworkConnection.ServerMode.InGame)
                {
                    _preventStopOnRem();
                    MainGame.Inst.SetMultiplayerServerLevelScreen(Levels.LEVELS[_serverHost.LevelID], _serverHost.Speed, _serverHost.MusicIndex, _serverHost);
                }
            }

            if (_server.SessionUserID == 0)
            {
                if (_server.Mode == SAMNetworkConnection.ServerMode.CreatingNewGame)
                {
                    if (_nextLevelRandom)
                    {
                        SetLevelDataRandom();

                        _server.Mode = SAMNetworkConnection.ServerMode.InLobby;

                        byte[] binData = _serverHost.GetLobbySyncData();
                        _serverHost.StartLobbySync(binData);
                    }
                    else
                    {
                        _preventStopOnRem();
                        Remove();

                        HUD.AddModal(new MultiplayerRehostPanel(_server as GDMultiplayerServer), false, 0.5f, 0.5f);
                    }
                }
            }
            else
            {
                if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby)
                {
                    _preventStopOnRem();

                    Remove();
                    HUD.AddModal(new MultiplayerClientLobbyPanel(_server as GDMultiplayerClient), false, 0.5f, 0.5f);
                }
            }
        }
Ejemplo n.º 9
0
        public static string FormatNetworkErrorMessage(SAMNetworkConnection.ErrorType type, object data)
        {
            switch (type)
            {
            case SAMNetworkConnection.ErrorType.None:
                return(string.Empty);

            case SAMNetworkConnection.ErrorType.ProxyServerTimeout:
                return(L10N.T(STR_MP_TIMEOUT));

            case SAMNetworkConnection.ErrorType.ServerUserTimeout:
                return(L10N.T(STR_MP_TIMEOUT));

            case SAMNetworkConnection.ErrorType.UserTimeout:
                return(L10N.TF(STR_MP_TIMEOUT_USER, data));

            case SAMNetworkConnection.ErrorType.NotInLobby:
                return(L10N.T(STR_MP_NOTINLOBBY));

            case SAMNetworkConnection.ErrorType.SessionNotFound:
                return(L10N.T(STR_MP_SESSIONNOTFOUND));

            case SAMNetworkConnection.ErrorType.AuthentificationFailed:
                return(L10N.T(STR_MP_AUTHFAILED));

            case SAMNetworkConnection.ErrorType.LobbyFull:
                return(L10N.T(STR_MP_LOBBYFULL));

            case SAMNetworkConnection.ErrorType.GameVersionMismatch:
                return(L10N.TF(STR_MP_VERSIONMISMATCH, GDConstants.Version.ToString()));

            case SAMNetworkConnection.ErrorType.LevelNotFound:
                return(L10N.T(STR_MP_LEVELNOTFOUND));

            case SAMNetworkConnection.ErrorType.LevelVersionMismatch:
                return(L10N.T(STR_MP_LEVELMISMATCH));

            case SAMNetworkConnection.ErrorType.UserDisconnect:
                return(L10N.TF(STR_MP_USERDISCONNECT, data));

            case SAMNetworkConnection.ErrorType.ServerDisconnect:
                return(L10N.T(STR_MP_SERVERDISCONNECT));

            case SAMNetworkConnection.ErrorType.BluetoothAdapterNotFound:
                return(L10N.T(STR_MP_BTADAPTERNULL));

            case SAMNetworkConnection.ErrorType.BluetoothAdapterNoPermission:
                return(L10N.T(STR_MP_BTADAPTERPERMDENIED));

            case SAMNetworkConnection.ErrorType.BluetoothInternalError:
                return(L10N.T(STR_MP_INTERNAL));

            case SAMNetworkConnection.ErrorType.BluetoothNotEnabled:
                return(L10N.T(STR_MP_BTDISABLED));

            case SAMNetworkConnection.ErrorType.P2PConnectionFailed:
                return(L10N.T(STR_MP_DIRECTCONNFAIL));

            case SAMNetworkConnection.ErrorType.P2PConnectionLost:
                return(L10N.T(STR_MP_DIRECTCONNLOST));

            default:
                SAMLog.Error("L10NI::EnumSwitch_FNEM", "type = " + type);
                return(string.Empty);
            }
        }
Ejemplo n.º 10
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            var prev = new GDGameScreen_Preview(MainGame.Inst, MainGame.Inst.Graphics, this, _blueprints, 0, _worldNumber);

            AddElement(_proxy = new HUDSubScreenProxyRenderer(prev)
            {
                Alignment        = HUDAlignment.TOPCENTER,
                RelativePosition = new FPoint(0, 0.5f * GDConstants.TILE_WIDTH),
                Size             = new FSize(INNER_WIDTH, INNER_HEIGHT),
            });

            AddElement(_button = new HUDTextButton
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH),
                Size             = new FSize(5.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH),

                L10NText      = L10NImpl.STR_PREV_BUYNOW,
                TextColor     = Color.White,
                Font          = Textures.HUDFontBold,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.PeterRiver, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.BelizeHole, 16),

                Click = OnClickBuy,
            });

            AddElement(new HUDTextButton
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH),
                Size             = new FSize(5.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH),

                Text          = L10N.TF(L10NImpl.STR_PREV_FINISHWORLD, _unlockWorldNumber),
                TextColor     = Color.White,
                Font          = Textures.HUDFontBold,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Turquoise, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.GreenSea, 16),

                Click = OnClickFinishPrev,
            });

            AddElement(new HUDLabel
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, 0.75f * GDConstants.TILE_WIDTH),
                Size             = new FSize(5.5f * GDConstants.TILE_WIDTH, 1.5f * GDConstants.TILE_WIDTH),

                L10NText      = L10NImpl.STR_PREV_OR,
                TextColor     = Color.White,
                Font          = Textures.HUDFontBold,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
            });

            AddElement(new HUDImage
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 0.125f * GDConstants.TILE_WIDTH),
                Size             = new FSize(0.75f * GDConstants.TILE_WIDTH, 0.75f * GDConstants.TILE_WIDTH),

                Image = Textures.TexIconScore,
            });

            AddElement(new HUDLabel
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(1.5f * GDConstants.TILE_WIDTH, 0.125f * GDConstants.TILE_WIDTH),
                Size             = new FSize(4.25f * GDConstants.TILE_WIDTH, 0.75f * GDConstants.TILE_WIDTH),

                Text          = $"{MainGame.Inst.Profile.TotalPoints} / {UnlockManager.PointsForUnlock(_id)}",
                TextColor     = Color.White,
                Font          = Textures.HUDFontBold,
                FontSize      = 50,
                TextAlignment = HUDAlignment.CENTERLEFT,
            });
        }
Ejemplo n.º 11
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            string txt = "?";

            switch (_mode)
            {
            case HighscoreCategory.GlobalPoints:
                txt = L10N.T(L10NImpl.STR_HSP_GLOBALRANKING);
                break;

            case HighscoreCategory.WorldPoints:
                txt = L10N.TF(L10NImpl.STR_HSP_RANKINGFOR, L10N.T(Levels.WORLD_NAMES[_focus.ID]));
                break;

            case HighscoreCategory.MultiplayerPoints:
                txt = L10N.T(L10NImpl.STR_HSP_MULTIPLAYERRANKING);
                break;

            case HighscoreCategory.CustomLevelStars:
                txt = L10N.T(L10NImpl.STR_HSP_STARRANKING);
                break;

            case HighscoreCategory.CustomLevelPoints:
                txt = L10N.T(L10NImpl.STR_HSP_SCCMRANKING);
                break;

            default:
                SAMLog.Error("HP::EnumSwitch_OI", "_mode: " + _mode);
                break;
            }

            AddElement(new HUDLabel(1)
            {
                TextAlignment    = (txt.Length > 24) ? HUDAlignment.CENTERLEFT : HUDAlignment.CENTER,
                Alignment        = HUDAlignment.TOPCENTER,
                RelativePosition = new FPoint(0, 0),
                Size             = new FSize(TAB_WIDTH, TEXT_HEIGHT_REAL),

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                Text      = txt,
                TextColor = FlatColors.Clouds,
            });

            AddElement(_btnPrev = new HUDImageButton(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = FPoint.Zero,
                Size             = new FSize(72, 72),

                Image          = GetModeIcon(NextCategory(_mode, false)),
                ImageColor     = GetModeColor(NextCategory(_mode, false)),
                ImagePadding   = 8,
                ImageAlignment = HUDImageAlignmentAlgorithm.CENTER,
                ImageScale     = HUDImageScaleAlgorithm.UNDERSCALE,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 16, true, false, false, false),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 16, true, false, false, false),

                Click = (s, e) => SwitchMode(false),

                IsVisible = false,
            });

            AddElement(_btnNext = new HUDImageButton(1)
            {
                Alignment        = HUDAlignment.TOPRIGHT,
                RelativePosition = FPoint.Zero,
                Size             = new FSize(72, 72),

                Image          = GetModeIcon(NextCategory(_mode, true)),
                ImageColor     = GetModeColor(NextCategory(_mode, true)),
                ImagePadding   = 8,
                ImageAlignment = HUDImageAlignmentAlgorithm.CENTER,
                ImageScale     = HUDImageScaleAlgorithm.UNDERSCALE,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonHUD, 16, false, true, false, false),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.ButtonPressedHUD, 16, false, true, false, false),

                Click = (s, e) => SwitchMode(true),

                IsVisible = false,
            });

            _loader = new HUDImage
            {
                RelativePosition = new FPoint(0, TEXT_HEIGHT / 2f),
                Alignment        = HUDAlignment.CENTER,
                Size             = new FSize(2 * GDConstants.TILE_WIDTH, 2 * GDConstants.TILE_WIDTH),
                Color            = FlatColors.Clouds,
                Image            = Textures.CannonCogBig,

                RotationSpeed = 0.1f,

                IsVisible = true,
            };
            AddElement(_loader);

            _table = new HUDScrollTable
            {
                RelativePosition = new FPoint(0, TEXT_HEIGHT / 2f),
                Alignment        = HUDAlignment.CENTER,
                Size             = new FSize(TAB_WIDTH, TAB_HEIGHT),

                Background       = FlatColors.BackgroundHUD2,
                Foreground       = FlatColors.TextHUD,
                LineColor        = Color.Black,
                HeaderBackground = FlatColors.Asbestos,
                HeaderForeground = Color.Black,
                ScrollThumbColor = FlatColors.Silver,
                ScrollWidth      = 16,
                ScrollHeight     = 64,
                LineWidth        = 2 * HUD.PixelWidth,
                FontSize         = 32,

                IsVisible = false,
            };
            _table.FixHeightToMultipleOfRowHeight();
            AddElement(_table);

            switch (_mode)
            {
            case HighscoreCategory.GlobalPoints:
                _table.AddColumn("", 100);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_NAME), null);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_POINTS), 100);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_TIME), 175);
                break;

            case HighscoreCategory.WorldPoints:
                _table.AddColumn("", 100);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_NAME), null);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_POINTS), 100);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_TIME), 175);
                break;

            case HighscoreCategory.MultiplayerPoints:
                _table.AddColumn("", 100);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_NAME), null);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_POINTS), 100);
                break;

            case HighscoreCategory.CustomLevelStars:
                _table.AddColumn("", 100);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_NAME), null);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_STARS), 100);
                break;

            case HighscoreCategory.CustomLevelPoints:
                _table.AddColumn("", 100);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_NAME), null);
                _table.AddColumn(L10N.T(L10NImpl.STR_TAB_POINTS), 100);
                break;

            default:
                SAMLog.Error("HP::EnumSwitch_OI2", "_mode: " + _mode);
                break;
            }

            LoadHighscore().EnsureNoError();
        }