Exemplo n.º 1
0
        private void CreateNewUserLevel(HUDTextButton sender, HUDButtonEventArgs e)
        {
            if (MainGame.Inst.Profile.AccountType == AccountType.Local)
            {
                CreateUserAndShowAnonPanel().EnsureNoError();
                return;
            }
            else if (MainGame.Inst.Profile.AccountType == AccountType.Anonymous)
            {
                ShowAnonPanel();
                HUD.ShowToast(null, L10N.T(L10NImpl.STR_SCCM_NEEDS_ACC), 40, FlatColors.Orange, FlatColors.Foreground, 2f);
                return;
            }

            var waitDialog = new HUDIconMessageBox
            {
                L10NText   = L10NImpl.STR_GENERIC_SERVER_QUERY,
                TextColor  = FlatColors.TextHUD,
                Background = HUDBackgroundDefinition.CreateRounded(FlatColors.BelizeHole, 16),

                IconColor     = FlatColors.Clouds,
                Icon          = Textures.CannonCogBig,
                RotationSpeed = 1f,

                CloseOnClick = false,
            };

            HUD.AddModal(waitDialog, false, 0.7f);

            CreateNewUserLevelInternal(waitDialog).RunAsync();
        }
Exemplo n.º 2
0
        private async Task CreateUserAndShowAnonPanel()
        {
            var waitDialog = new HUDIconMessageBox
            {
                Text      = "Contacting server",
                TextColor = FlatColors.TextHUD,

                Background = HUDBackgroundDefinition.CreateRounded(FlatColors.BelizeHole, 16),

                IconColor     = FlatColors.Clouds,
                Icon          = Textures.CannonCogBig,
                RotationSpeed = 1f,

                CloseOnClick = false,
            };

            MainGame.Inst.DispatchBeginInvoke(() => { AddModal(waitDialog, false, 0.7f); });

            await MainGame.Inst.Backend.CreateUser(MainGame.Inst.Profile);

            waitDialog.Remove();

            MainGame.Inst.DispatchBeginInvoke(() =>
            {
                if (MainGame.Inst.Profile.AccountType == AccountType.Anonymous)
                {
                    AddModal(new AnonymousAccountPanel(), true);
                }
            });
        }
Exemplo n.º 3
0
        private void OnCreateAccount(HUDTextButton sender, HUDButtonEventArgs e)
        {
            if (editUsername.Text == "" || editPassword.Text == "")
            {
                return;
            }

            if (MainGame.Inst.Profile.AccountType != AccountType.Anonymous)
            {
                return;
            }

            var waitDialog = new HUDIconMessageBox
            {
                L10NText   = L10NImpl.STR_AAP_ACCCREATING,
                TextColor  = FlatColors.TextHUD,
                Background = HUDBackgroundDefinition.CreateRounded(FlatColors.BelizeHole, 16),

                IconColor     = FlatColors.Clouds,
                Icon          = Textures.CannonCog,
                RotationSpeed = 1f,

                CloseOnClick = false,
            };

            HUD.AddModal(waitDialog, false, 0.7f);

            DoSignup(waitDialog, editUsername.Text, editPassword.Text).RunAsync();
        }
Exemplo n.º 4
0
        public void DoPlayTest()
        {
            SetMode(LevelEditorMode.Mouse);

            LevelData.UpdateAndSave(this);

            var success = LevelData.ValidateWithToasts(HUD);

            if (success)
            {
                var waitDialog = new HUDIconMessageBox
                {
                    L10NText   = L10NImpl.STR_LVLED_COMPILING,
                    TextColor  = FlatColors.TextHUD,
                    Background = HUDBackgroundDefinition.CreateRounded(FlatColors.BelizeHole, 16),

                    IconColor     = FlatColors.Clouds,
                    Icon          = Textures.CannonCogBig,
                    RotationSpeed = 1f,

                    CloseOnClick = false,
                };

                HUD.AddModal(waitDialog, false, 0.7f);

                DoCompileAndTest(waitDialog).RunAsync();
            }
        }
Exemplo n.º 5
0
        private async Task DoCompileAndTest(HUDElement spinner)
        {
            try
            {
                var lvl = await Task.Run(() => LevelData.CompileToBlueprint(HUD));

                if (lvl == null)
                {
                    return;
                }

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new LevelEditorTestConfirmPanel(lvl, LevelData), true, 0.7f);
                });
            }
            catch (Exception e)
            {
                SAMLog.Error("LEMP::DCAT", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_CPP_COMERR,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);
                });
            }
        }
Exemplo n.º 6
0
        private void OnChangePassword(HUDTextButton sender, HUDButtonEventArgs e)
        {
            if (editPassword.Text == "")
            {
                editPassword.AddHUDOperation(new HUDTextBoxBlinkOperation(Color.Red));
                return;
            }

            if (MainGame.Inst.Profile.AccountType != AccountType.Full)
            {
                return;
            }

            var waitDialog = new HUDIconMessageBox
            {
                L10NText   = L10NImpl.STR_CPP_CHANGING,
                TextColor  = FlatColors.TextHUD,
                Background = HUDBackgroundDefinition.CreateRounded(FlatColors.BelizeHole, 16),

                IconColor     = FlatColors.Clouds,
                Icon          = Textures.CannonCogBig,
                RotationSpeed = 1f,

                CloseOnClick = false,
            };

            HUD.AddModal(waitDialog, false, 0.7f);

            DoChangePassword(waitDialog, editPassword.Text).RunAsync();
        }
Exemplo n.º 7
0
        private void OnLogin(HUDTextButton sender, HUDButtonEventArgs e)
        {
            if (editUsername.Text == "")
            {
                editUsername.AddOperation(new HUDTextBoxBlinkOperation(Color.Red));
                return;
            }

            if (editPassword.Text == "")
            {
                editPassword.AddOperation(new HUDTextBoxBlinkOperation(Color.Red));
                return;
            }

            var waitDialog = new HUDIconMessageBox
            {
                L10NText   = L10NImpl.STR_AAP_LOGGINGIN,
                TextColor  = FlatColors.TextHUD,
                Background = HUDBackgroundDefinition.CreateRounded(FlatColors.BelizeHole, 16),

                IconColor     = FlatColors.Clouds,
                Icon          = Textures.CannonCogBig,
                RotationSpeed = 1f,

                CloseOnClick = false,
            };

            HUD.AddModal(waitDialog, false, 0.7f);

            DoLogin(waitDialog, editUsername.Text, editPassword.Text).RunAsync();
        }
Exemplo n.º 8
0
        private async Task <SCCMListPresenter.LoadFuncResult> QueryData(SCCMListPresenter list, int page, int reqid)
        {
            try
            {
                var r = await MainGame.Inst.Backend.QueryUserLevel(MainGame.Inst.Profile, QueryUserLevelCategory.NewLevels, string.Empty, page);

                if (r == null)
                {
                    return(SCCMListPresenter.LoadFuncResult.Error);
                }
                else
                {
                    if (r.Count == 0)
                    {
                        return(SCCMListPresenter.LoadFuncResult.LastPage);
                    }
                    else
                    {
                        MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                        {
                            if (list.IsCurrentRequest(reqid))
                            {
                                foreach (var levelmeta in r)
                                {
                                    list.AddEntry(new SCCMListElementOnlinePlayable(levelmeta));
                                }
                            }
                        });

                        return(SCCMListPresenter.LoadFuncResult.Success);
                    }
                }
            }
            catch (Exception e)
            {
                SAMLog.Error("SCCMTN::QD", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_CPP_COMERR,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);
                });

                return(SCCMListPresenter.LoadFuncResult.Error);
            }
        }
Exemplo n.º 9
0
        private async Task CreateNewUserLevelInternal(HUDElement spinner)
        {
            try
            {
                var r = await MainGame.Inst.Backend.GetNewCustomLevelID(MainGame.Inst.Profile);

                if (!r.Item1)
                {
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_CPP_COMERR,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                    });
                    return;
                }

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    MainGame.Inst.SetLevelEditorScreen(new SCCMLevelData(r.Item2, MainGame.Inst.Profile.OnlineUserID));
                });
            }
            catch (Exception e)
            {
                SAMLog.Error("SCCMLENUL::DL", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_CPP_COMERR,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);
                });
            }
        }
Exemplo n.º 10
0
        private void DoUpload(HUDIconTextButton sender, HUDButtonEventArgs e)
        {
            var waitDialog = new HUDIconMessageBox
            {
                L10NText   = L10NImpl.STR_LVLED_UPLOADING,
                TextColor  = FlatColors.TextHUD,
                Background = HUDBackgroundDefinition.CreateRounded(FlatColors.BelizeHole, 16),

                IconColor     = FlatColors.Clouds,
                Icon          = Textures.CannonCogBig,
                RotationSpeed = 1f,

                CloseOnClick = false,
            };

            HUD.AddModal(waitDialog, false, 0.7f);

            DoUploadInternal(waitDialog).RunAsync();
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            #region Footer

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

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


            AddElement(new HUDRectangle(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 3f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.Nephritis),
            });

            AddElement(new HUDRectangle(1)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 2f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.PeterRiver),
            });

            AddElement(new HUDRectangle(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 3f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.Pomegranate),
            });

            AddElement(new HUDSeperator(HUDOrientation.Vertical, 3)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(WIDTH / 3f, 0),
                Size             = new FSize(1, FOOTER_HEIGHT),

                Color = FlatColors.SeperatorHUD,
            });

            AddElement(new HUDSeperator(HUDOrientation.Vertical, 3)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(WIDTH / 3f, 0),
                Size             = new FSize(1, FOOTER_HEIGHT),

                Color = FlatColors.SeperatorHUD,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0, 77),
                Size             = new FSize(WIDTH / 3f, 40),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                L10NText      = L10NImpl.STR_HSP_LEVEL,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontRegular,
                FontSize      = 35,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0, 15),
                Size             = new FSize(WIDTH / 3f, 60),

                Text          = Level.Name,
                TextAlignment = HUDAlignment.BOTTOMCENTER,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontBold,
                FontSize      = 57,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, 77),
                Size             = new FSize(WIDTH / 3f, 40),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                L10NText      = L10NImpl.STR_HSP_MPPOINTS,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontRegular,
                FontSize      = 35,
            });

            AddElement(new HUDIncrementIndicatorLabel(profile.MultiplayerPoints.ToString(), (successScreen ? "+" : "-") + Math.Abs(_deltaPoints), 2)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, 15),
                Size             = new FSize(WIDTH / 3f, 60),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontBold,
                FontSize      = 57,
            });

            AddElement(_loadingCog = new HUDImage(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, 16),
                Size             = new FSize(WIDTH / 3f, 80),

                Image          = Textures.CannonCogBig,
                RotationSpeed  = 0.3f,
                Color          = FlatColors.TextHUD,
                ImageAlignment = HUDImageAlignment.UNDERSCALE,

                IsVisible = false,
            });

            #endregion

            #region Buttons

            AddElement(new HUDIconTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(24, FOOTER_HEIGHT + 24),
                Size             = new FSize(3.5f * GDConstants.TILE_WIDTH, 60),

                L10NText      = L10NImpl.STR_HSP_BACK,
                TextColor     = Color.White,
                Font          = Textures.HUDFontRegular,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,
                Icon          = Textures.TexIconBack,

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

                Click = (s, a) => { _server.KillSession(); _server.Stop(); GDScreen.ExitToMap(); },
            });

            if (_server.SessionUserID == 0 && _server.Mode != SAMNetworkConnection.ServerMode.Stopped && _server.Mode != SAMNetworkConnection.ServerMode.Error)
            {
                AddElement(_btnRand = new HUDIconTextButton(2)
                {
                    Alignment        = HUDAlignment.BOTTOMRIGHT,
                    RelativePosition = new FPoint(24, FOOTER_HEIGHT + 90),
                    Size             = new FSize(6f * GDConstants.TILE_WIDTH, 60),

                    L10NText      = L10NImpl.STR_HSP_RANDOMGAME,
                    TextColor     = Color.White,
                    Font          = Textures.HUDFontRegular,
                    FontSize      = 55,
                    TextAlignment = HUDAlignment.CENTER,
                    TextPadding   = 8,
                    Icon          = Textures.TexIconDice,

                    BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Wisteria, 16),
                    BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Amethyst, 16),

                    Click = (s, a) => OnRandomLevel(),
                });

                AddElement(_btnNext = new HUDIconTextButton(2)
                {
                    Alignment        = HUDAlignment.BOTTOMRIGHT,
                    RelativePosition = new FPoint(24, FOOTER_HEIGHT + 24),
                    Size             = new FSize(6f * GDConstants.TILE_WIDTH, 60),

                    L10NText      = L10NImpl.STR_HSP_NEWGAME,
                    TextColor     = Color.White,
                    Font          = Textures.HUDFontRegular,
                    FontSize      = 55,
                    TextAlignment = HUDAlignment.CENTER,
                    TextPadding   = 8,
                    Icon          = Textures.TexIconRedo,

                    BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.SunFlower, 16),
                    BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Orange, 16),

                    Click = (s, a) => OnNextLevel(),
                });
            }

            #endregion

            #region Icons

            AddElement(new HUDMultiplayerDifficultyButton(2, successScreen, 0)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(1 * ICON_MARGIN + 0 * ICON_SIZE, ICON_MARGIN),
                IsEnabled        = false,
            });

            AddElement(new HUDMultiplayerDifficultyButton(2, successScreen, 1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(3 * ICON_MARGIN + 1 * ICON_SIZE, ICON_MARGIN),
                IsEnabled        = false,
            });

            AddElement(new HUDMultiplayerDifficultyButton(2, successScreen, 2)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(5 * ICON_MARGIN + 2 * ICON_SIZE, ICON_MARGIN),
                IsEnabled        = false,
            });

            AddElement(new HUDMultiplayerDifficultyButton(2, successScreen, 3)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(7 * ICON_MARGIN + 3 * ICON_SIZE, ICON_MARGIN),
                IsEnabled        = false,
            });

            #endregion
        }
Exemplo n.º 13
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            #region Footer

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

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


            AddElement(new HUDRectangle(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 3f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.Nephritis),
            });

            AddElement(new HUDRectangle(1)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 2f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.PeterRiver),
            });

            AddElement(new HUDRectangle(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 3f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.Pomegranate),
            });

            AddElement(new HUDSeperator(HUDOrientation.Vertical, 3)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(WIDTH / 3f, 0),
                Size             = new FSize(1, FOOTER_HEIGHT),

                Color = FlatColors.SeperatorHUD,
            });

            AddElement(new HUDSeperator(HUDOrientation.Vertical, 3)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(WIDTH / 3f, 0),
                Size             = new FSize(1, FOOTER_HEIGHT),

                Color = FlatColors.SeperatorHUD,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, 77),
                Size             = new FSize(WIDTH / 3f, 40),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                L10NText      = L10NImpl.STR_HSP_TIME_YOU,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontRegular,
                FontSize      = 35,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, 15),
                Size             = new FSize(WIDTH / 3f, 60),

                Text          = TimeExtension.FormatMilliseconds(Time, false),
                TextAlignment = HUDAlignment.BOTTOMCENTER,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontBold,
                FontSize      = 57,
            });

            #endregion

            #region Buttons

            AddElement(new HUDIconTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(24, FOOTER_HEIGHT + 24),
                Size             = new FSize(3.5f * GDConstants.TILE_WIDTH, 60),

                L10NText      = L10NImpl.STR_HSP_BACK,
                TextColor     = Color.White,
                Font          = Textures.HUDFontRegular,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,
                Icon          = Textures.TexIconBack,

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

                Click = (s, a) => { MainGame.Inst.SetLevelEditorScreen(SCCMData); },
            });

            if (CanUpload)
            {
                var w = L10N.LANGUAGE == L10N.LANG_EN_US ? 3.5f : 5.0f;
                AddElement(new HUDIconTextButton(2)
                {
                    Alignment        = HUDAlignment.BOTTOMRIGHT,
                    RelativePosition = new FPoint(24, FOOTER_HEIGHT + 24),
                    Size             = new FSize(w * GDConstants.TILE_WIDTH, 60),

                    L10NText      = L10NImpl.STR_LVLED_BTN_UPLOAD,
                    TextColor     = Color.White,
                    Font          = Textures.HUDFontRegular,
                    FontSize      = 55,
                    TextAlignment = HUDAlignment.CENTER,
                    TextPadding   = 8,
                    Icon          = Textures.TexIconUpload,

                    BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Emerald, 16),
                    BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),

                    Click = DoUpload,
                });
            }
            else
            {
                var w = L10N.LANGUAGE == L10N.LANG_EN_US ? 3.5f : 5.0f;
                AddElement(new HUDIconTextButton(2)
                {
                    Alignment        = HUDAlignment.BOTTOMRIGHT,
                    RelativePosition = new FPoint(24, FOOTER_HEIGHT + 24),
                    Size             = new FSize(w * GDConstants.TILE_WIDTH, 60),

                    L10NText      = L10NImpl.STR_HSP_AGAIN,
                    TextColor     = Color.White,
                    Font          = Textures.HUDFontRegular,
                    FontSize      = 55,
                    TextAlignment = HUDAlignment.CENTER,
                    TextPadding   = 8,
                    Icon          = Textures.TexIconRedo,

                    BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Orange, 16),
                    BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.SunFlower, 16),

                    Click = (s, a) => ((GDGameScreen)HUD.Screen).RestartLevel(false),
                });
            }

            #endregion

            #region Icons

            AddElement(new HUDSCCMUploadDifficultyButton(2, CanUpload, 0)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(1 * ICON_MARGIN + 0 * ICON_SIZE, ICON_MARGIN),
                IsEnabled        = false,
            });

            AddElement(new HUDSCCMUploadDifficultyButton(2, CanUpload, 1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(3 * ICON_MARGIN + 1 * ICON_SIZE, ICON_MARGIN),
                IsEnabled        = false,
            });

            AddElement(new HUDSCCMUploadDifficultyButton(2, CanUpload, 2)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(5 * ICON_MARGIN + 2 * ICON_SIZE, ICON_MARGIN),
                IsEnabled        = false,
            });

            AddElement(new HUDSCCMUploadDifficultyButton(2, CanUpload, 3)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(7 * ICON_MARGIN + 3 * ICON_SIZE, ICON_MARGIN),
                IsEnabled        = false,
            });

            #endregion
        }
Exemplo n.º 14
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            #region Footer

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

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


            AddElement(new HUDRectangle(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 3f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.Nephritis),
            });

            AddElement(new HUDRectangle(1)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 2f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.PeterRiver),
            });

            AddElement(new HUDRectangle(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 3f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.Pomegranate),
            });


            AddElement(new HUDSeperator(HUDOrientation.Vertical, 3)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(WIDTH / 3f, 0),
                Size             = new FSize(1, FOOTER_HEIGHT),

                Color = FlatColors.SeperatorHUD,
            });

            AddElement(new HUDSeperator(HUDOrientation.Vertical, 3)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(WIDTH / 3f, 0),
                Size             = new FSize(1, FOOTER_HEIGHT),

                Color = FlatColors.SeperatorHUD,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0, 77),
                Size             = new FSize(WIDTH / 3f, 40),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                L10NText      = L10NImpl.STR_HSP_LEVEL,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontRegular,
                FontSize      = 35,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, 77),
                Size             = new FSize(WIDTH / 3f, 40),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                L10NText      = L10NImpl.STR_HSP_POINTS,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontRegular,
                FontSize      = 35,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, 77),
                Size             = new FSize(WIDTH / 3f, 40),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                L10NText      = L10NImpl.STR_HSP_TIME_BEST,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontRegular,
                FontSize      = 35,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0, 15),
                Size             = new FSize(WIDTH / 3f, 60),

                L10NText      = L10NImpl.STR_HSP_TUTORIAL,
                TextAlignment = HUDAlignment.BOTTOMCENTER,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontBold,
                FontSize      = 57,
            });

            AddElement(new HUDIncrementIndicatorLabel(profile.TotalPoints.ToString(), increasePoints == 0 ? "" : "+" + increasePoints, 2)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, 15),
                Size             = new FSize(WIDTH / 3f, 60),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontBold,
                FontSize      = 57,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, 15),
                Size             = new FSize(WIDTH / 3f, 60),

                Text          = profile.GetLevelData(Levels.LEVEL_TUTORIAL).GetTimeString(FractionDifficulty.DIFF_0, true),
                TextAlignment = HUDAlignment.BOTTOMCENTER,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontBold,
                FontSize      = 57,
            });

            #endregion

            #region Buttons

            //AddElement(btnMenu = new HUDIconTextButton(2)
            //{
            //	Alignment = HUDAlignment.BOTTOMLEFT,
            //	RelativePosition = new FPoint(24, FOOTER_HEIGHT + 24),
            //	Size = new FSize(3.5f * GDConstants.TILE_WIDTH, 60),
            //
            //	Text = "Back",
            //	TextColor = Color.White,
            //	Font = Textures.HUDFontRegular,
            //	FontSize = 55,
            //	TextAlignment = HUDAlignment.CENTER,
            //	TextPadding = 8,
            //	Icon = Textures.TexIconBack,
            //	BackgroundType = HUDBackgroundType.Rounded,
            //	Color = FlatColors.ButtonHUD,
            //	ColorPressed = FlatColors.ButtonPressedHUD,
            //});
            //btnMenu.ButtonClick += (s, a) => MainGame.Inst.SetWorldMapScreen(GDScreen.WorldBlueprint, GDScreen.Blueprint.UniqueID);


            AddElement(btnPlay = new HUDIconTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(24, FOOTER_HEIGHT + 24),
                Size             = new FSize(7f * GDConstants.TILE_WIDTH, 60),

                L10NText      = L10NImpl.STR_HSP_GETSTARTED,
                TextColor     = Color.White,
                Font          = Textures.HUDFontRegular,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,
                Icon          = Textures.TexIconNext,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Emerald, 16),

                Click = (s, a) => MainGame.Inst.SetWorldMapScreenWithTransition(Levels.WORLD_001),
            });

            #endregion

            #region Icons

            AddElement(new HUDTutorialDifficultyButton(2)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(1 * ICON_MARGIN + 0 * ICON_SIZE, ICON_MARGIN)
            });

            AddElement(new HUDTutorialDifficultyButton(2)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(3 * ICON_MARGIN + 1 * ICON_SIZE, ICON_MARGIN)
            });

            AddElement(new HUDTutorialDifficultyButton(2)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(5 * ICON_MARGIN + 2 * ICON_SIZE, ICON_MARGIN)
            });

            AddElement(new HUDTutorialDifficultyButton(2)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(7 * ICON_MARGIN + 3 * ICON_SIZE, ICON_MARGIN)
            });

            #endregion
        }
Exemplo n.º 15
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);
                }
            }
        }
Exemplo n.º 16
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            var imgWidth  = WIDTH - 2 * ELEM_MARGIN;
            var imgHeight = imgWidth * (Textures.TexLogo.Height * 1f / Textures.TexLogo.Width);

            AddElement(new HUDImage(1)
            {
                Alignment        = HUDAlignment.TOPCENTER,
                RelativePosition = new FPoint(0, ELEM_MARGIN),
                Size             = new FSize(imgWidth, imgHeight),

                Image = Textures.TexLogo,
            });

            var btn1y = ELEM_MARGIN + imgHeight;

            AddElement(new HUDTextButton(1)
            {
                TextAlignment = HUDAlignment.CENTER,
                Alignment     = HUDAlignment.TOPCENTER,

                RelativePosition = new FPoint(0, btn1y),
                Size             = new FSize(imgWidth, BUTTON_HEIGHT),

                Font     = Textures.HUDFontRegular,
                FontSize = 52,

                L10NText = L10NImpl.STR_ATTRIBUTIONS,

                TextColor   = Color.White,
                TextPadding = 16,

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

                ClickMode = HUDButton.HUDButtonClickMode.Single,
                Click     = OnClickAttributions,
            });

            var btn2y = btn1y + BUTTON_HEIGHT + ELEM_MARGIN;

            AddElement(new HUDTextButton(1)
            {
                TextAlignment = HUDAlignment.CENTER,
                Alignment     = HUDAlignment.TOPCENTER,

                RelativePosition = new FPoint(0, btn2y),
                Size             = new FSize(imgWidth, BUTTON_HEIGHT),

                Font     = Textures.HUDFontRegular,
                FontSize = 52,

                L10NText = L10NImpl.STR_UNLOCK,

                TextColor   = Color.White,
                TextPadding = 16,

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

                ClickMode = HUDButton.HUDButtonClickMode.Single,
                Click     = OnClickUnlock,
            });

            var btn3y = btn2y + BUTTON_HEIGHT + ELEM_MARGIN;

            AddElement(new HUDTextButton(1)
            {
                TextAlignment = HUDAlignment.CENTER,
                Alignment     = HUDAlignment.TOPCENTER,

                RelativePosition = new FPoint(0, btn3y),
                Size             = new FSize(imgWidth, BUTTON_HEIGHT),

                Font     = Textures.HUDFontRegular,
                FontSize = 52,

                L10NText = L10NImpl.STR_CREDPNL_HEADER,

                TextColor   = Color.White,
                TextPadding = 16,

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

                ClickMode = HUDButton.HUDButtonClickMode.Single,
                Click     = OnClickAcknowledgements,
            });

            AddElement(new TimesheetAnimationPresenter(1)
            {
                Animation = Animations.AnimationBlackForestBytesLogo,

                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(ELEM_MARGIN, ELEM_MARGIN),
                Size             = new FSize(BFB_WIDTH, BFB_WIDTH),

                Click = OnClickBFB,
            });
        }
Exemplo n.º 17
0
        public override void OnInitialize()
        {
            base.OnInitialize();

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

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

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

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                L10NText  = L10NImpl.STR_FAP_ACCOUNT,
                TextColor = FlatColors.Clouds,
            });

            AddElement(new HUDLabel(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20, 100),
                Size             = new FSize((WIDTH - 60) / 2, 80),

                Font      = Textures.HUDFontRegular,
                FontSize  = 64,
                TextColor = FlatColors.Clouds,

                L10NText = L10NImpl.STR_FAP_USERNAME,
            });

            AddElement(new HUDLabel(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20 + (WIDTH - 60) / 2 + 20, 100),
                Size             = new FSize((WIDTH - 60) / 2, 80),

                Font      = Textures.HUDFontRegular,
                FontSize  = 64,
                TextColor = FlatColors.Clouds,

                Text = MainGame.Inst.Profile.OnlineUsername,
            });

            AddElement(new HUDLabel(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20, 200),
                Size             = new FSize((WIDTH - 60) / 2, 80),

                Font      = Textures.HUDFontRegular,
                FontSize  = 64,
                TextColor = FlatColors.Clouds,

                L10NText = L10NImpl.STR_FAP_SCORE,
            });

            AddElement(new HUDLabel(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20 + (WIDTH - 60) / 2 + 20, 200),
                Size             = new FSize((WIDTH - 60) / 2, 80),

                Font      = Textures.HUDFontRegular,
                FontSize  = 64,
                TextColor = FlatColors.Clouds,

                Text = MainGame.Inst.Profile.TotalPoints.ToString(),
            });

            AddElement(new HUDTextButton(1)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(24, 32),
                Size             = new FSize(4 * GDConstants.TILE_WIDTH, 64),

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

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonHUD, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonPressedHUD, 16),

                Click = OnLogout,
            });

            AddElement(new HUDTextButton(1)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(24, 32),
                Size             = new FSize(5.5f * GDConstants.TILE_WIDTH, 64),

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

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonHUD, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonPressedHUD, 16),

                Click = OnChangePassword,
            });
        }
Exemplo n.º 18
0
        private async Task DoSignup(HUDElement spinner, string username, string password)
        {
            try
            {
                var profile = MainGame.Inst.Profile;

                var r = await MainGame.Inst.Backend.UpgradeUser(profile, username, password);

                switch (r.Item1)
                {
                case UpgradeResult.Success:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(3, 1, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_ACCCREATED,
                            TextColor    = FlatColors.TextHUD,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),
                            CloseOnClick = true,
                        }, true);

                        Remove();
                    });
                    break;

                case UpgradeResult.UsernameTaken:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_USERTAKEN,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                    });
                    break;

                case UpgradeResult.AlreadyFullAcc:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_ALREADYCREATED,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case UpgradeResult.InternalError:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(10, 2, 0.3f)
                        {
                            Text         = r.Item2,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case UpgradeResult.NoConnection:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_NOCOM,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case UpgradeResult.AuthError:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_AAP_AUTHERROR,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                SAMLog.Error("CreateAccount", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText     = L10NImpl.STR_AAP_COULDNOTCREATE,
                        TextColor    = FlatColors.Clouds,
                        Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                        CloseOnClick = true,
                    }, true);

                    Remove();
                });
            }
        }
		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 = L10NImpl.STR_MENU_CAP_SEARCH,
				TextColor = FlatColors.Clouds,
			});

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

			AddElement(new HUDImage
			{
				Alignment = HUDAlignment.CENTER,
				RelativePosition = new FPoint(0, (-FOOTER_HEIGHT/2) + (96/2f)),
				Image = Textures.CannonCogBig,
				RotationSpeed = 0.35f,
				Color = FlatColors.Clouds,
				Size = new FSize(192, 192)
			});

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

				Definition = HUDBackgroundDefinition.CreateRounded(FlatColors.BackgroundHUD2, 16, false, false, true, true),
			});
			
			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,
			});
		}
Exemplo n.º 20
0
        private async Task DoLogin(HUDElement spinner, string username, string password)
        {
            try
            {
                var profile = MainGame.Inst.Profile;

                var r = await MainGame.Inst.Backend.MergeLogin(profile, username, password);

                var verifyResult = r.Item1;

                if (verifyResult != VerifyResult.Success)
                {
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        var text = "???";
                        if (verifyResult == VerifyResult.InternalError)
                        {
                            text = r.Item2;
                        }
                        if (verifyResult == VerifyResult.WrongPassword)
                        {
                            text = L10N.T(L10NImpl.STR_AAP_WRONGPW);
                        }
                        if (verifyResult == VerifyResult.WrongUsername)
                        {
                            text = L10N.T(L10NImpl.STR_AAP_USERNOTFOUND);
                        }
                        if (verifyResult == VerifyResult.NoConnection)
                        {
                            text = L10N.T(L10NImpl.STR_AAP_NOCOM);
                        }

                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            Text       = text,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);

                        Remove();
                    });
                    return;
                }

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();

                    MainGame.Inst.SetOverworldScreenCopy(HUD.Screen as GDOverworldScreen);
                    var screen = MainGame.Inst.GetCurrentScreen();
                    screen?.HUD?.AddModal(new HUDFadeOutInfoBox(3, 1, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_AAP_LOGINSUCCESS,
                        TextColor  = FlatColors.TextHUD,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),

                        CloseOnClick = true,
                    }, true);

                    Remove();
                });
            }
            catch (Exception e)
            {
                SAMLog.Error("Login", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_AAP_NOLOGIN,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);

                    Remove();
                });
            }
        }
Exemplo n.º 21
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  = L10NImpl.STR_CREDPNL_HEADER,
                TextColor = FlatColors.SunFlower,
            });

            for (int i = 0; i < Attributions.CREDITS.Length; i++)
            {
                var dd = Attributions.CREDITS[i];
                if (dd == null)
                {
                    continue;
                }

                var btn = new HUDTextButton(1)
                {
                    TextAlignment    = HUDAlignment.CENTERLEFT,
                    Alignment        = HUDAlignment.TOPLEFT,
                    RelativePosition = new FPoint(LINE_OFFSET, 96 + i * 38),
                    Size             = new FSize(LINE_WIDTH, 32),

                    Font     = Textures.HUDFontRegular,
                    FontSize = 32,

                    Text = dd.Item1,

                    TextColor   = FlatColors.Clouds,
                    TextPadding = 16,

                    BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.MidnightBlue, 8),
                    BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Wisteria, 8),

                    ClickMode = HUDButton.HUDButtonClickMode.Single,
                };

                var lbl = new HUDLabel(1)
                {
                    TextAlignment    = HUDAlignment.CENTERLEFT,
                    Alignment        = HUDAlignment.TOPRIGHT,
                    RelativePosition = new FPoint(LINE_OFFSET, 96 + i * 38),
                    Size             = new FSize(LINE_WIDTH, 32),

                    Font     = Textures.HUDFontBold,
                    FontSize = 32,

                    Text = dd.Item3,

                    TextColor = FlatColors.Clouds,
                };

                if (!string.IsNullOrWhiteSpace(dd.Item2))
                {
                    btn.ButtonClick += (s, a) =>
                    {
                        HUD.ShowToast(null, dd.Item2, 32, FlatColors.Silver, FlatColors.Foreground, 3f);
                        MainGame.Inst.GDBridge.OpenURL(dd.Item2);
                    };
                }

                AddElement(lbl);
                AddElement(btn);
            }


            if (MainGame.Inst.Profile.EffectsEnabled)
            {
                AddParticles();
            }
        }
Exemplo n.º 22
0
        public override void OnInitialize()
        {
            base.OnInitialize();

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

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                L10NText  = L10NImpl.STR_MENU_CAP_LOBBY,
                TextColor = FlatColors.Clouds,
            });

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

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 0 * 32),
                Size             = new FSize(INFO_C1_WIDTH, 32),
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                L10NText         = L10NImpl.STR_MENU_MP_LOBBY_PING,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 1 * 32),
                Size             = new FSize(INFO_C1_WIDTH, 32),
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                L10NText         = L10NImpl.STR_MENU_MP_LOBBY_USER,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 2 * 32),
                Size             = new FSize(INFO_C1_WIDTH, 32),
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                L10NText         = L10NImpl.STR_MENU_MP_LOBBY_LEVEL,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 3 * 32),
                Size             = new FSize(INFO_C1_WIDTH, 32),
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                L10NText         = L10NImpl.STR_MENU_MP_LOBBY_MUSIC,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 4 * 32),
                Size             = new FSize(INFO_C1_WIDTH, 32),
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                L10NText         = L10NImpl.STR_MENU_MP_LOBBY_SPEED,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 5 * 32),
                Size             = new FSize(INFO_C1_WIDTH, 32),
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                L10NText         = L10NImpl.STR_MENU_MP_LOBBY_COLOR,
                TextColor        = FlatColors.Clouds,
            });



            AddElement(new HUDLambdaLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 0 * 32),
                Size             = new FSize(INFO_C2_WIDTH, 32),
                MaxWidth         = INFO_C2_WIDTH,
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                Lambda           = () => $"{(int)(_server.ProxyPing.Value * 1000)}ms",
                WordWrap         = HUDWordWrap.Ellipsis,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLambdaLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 1 * 32),
                Size             = new FSize(INFO_C2_WIDTH, 32),
                MaxWidth         = INFO_C2_WIDTH,
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                Lambda           = () => $"{_server.SessionCount} / {_server.SessionCapacity}",
                WordWrap         = HUDWordWrap.Ellipsis,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLambdaLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 2 * 32),
                Size             = new FSize(INFO_C2_WIDTH, 32),
                MaxWidth         = INFO_C2_WIDTH,
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                Lambda           = () => _server.LevelID != null ? Levels.LEVELS[_server.LevelID.Value].FullName : ("?"),
                WordWrap         = HUDWordWrap.Ellipsis,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLambdaLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 3 * 32),
                Size             = new FSize(INFO_C2_WIDTH, 32),
                MaxWidth         = INFO_C2_WIDTH,
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                Lambda           = () => _server.MusicIndex != null ? (_server.MusicIndex.Value + 1).ToString() : "?",
                WordWrap         = HUDWordWrap.Ellipsis,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(new HUDLambdaLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 4 * 32),
                Size             = new FSize(INFO_C2_WIDTH, 32),
                MaxWidth         = INFO_C2_WIDTH,
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                Lambda           = () => _server.Speed != null ? Fmt(_server.Speed.Value) : "?",
                WordWrap         = HUDWordWrap.Ellipsis,
                TextColor        = FlatColors.Clouds,
            });

            AddElement(_lblFraction = new HUDLambdaLabel
            {
                TextAlignment    = HUDAlignment.CENTERLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 5 * 32),
                Size             = new FSize(INFO_C2_WIDTH, 32),
                MaxWidth         = INFO_C2_WIDTH,
                Font             = Textures.HUDFontRegular,
                FontSize         = 32,
                Lambda           = () => fracName != null ? fracName : "?",
                WordWrap         = HUDWordWrap.Ellipsis,
                TextColor        = FlatColors.Clouds,
            });


            AddElement(new HUDImage
            {
                Image         = Textures.CannonCogBig,
                RotationSpeed = 0.3f,
                Color         = FlatColors.BackgroundHUD2,

                Size = new FSize(196, 196),

                Alignment        = HUDAlignment.CENTER,
                RelativePosition = new FPoint(WIDTH / 4f, -64)
            });

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

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

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

                L10NText      = L10NImpl.STR_MENU_DISCONNECT,
                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,
            });
        }
Exemplo n.º 23
0
        public override void OnInitialize()
        {
            base.OnInitialize();

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

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

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

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                L10NText  = L10NImpl.STR_CPP_CHANGEPW,
                TextColor = FlatColors.Clouds,
            });

            AddElement(new HUDLabel(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20, 100),
                Size             = new FSize((WIDTH - 60) / 2, 80),

                Font      = Textures.HUDFontRegular,
                FontSize  = 64,
                TextColor = FlatColors.Clouds,

                L10NText = L10NImpl.STR_CPP_USERNAME,
            });

            AddElement(new HUDLabel(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20 + (WIDTH - 60) / 2 + 20, 100),
                Size             = new FSize((WIDTH - 60) / 2, 80),

                Font      = Textures.HUDFontRegular,
                FontSize  = 64,
                TextColor = FlatColors.Clouds,

                Text = MainGame.Inst.Profile.OnlineUsername,
            });

            AddElement(editPassword = new HUDIconTextBox(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20, 200),
                Size             = new FSize(WIDTH - 40, 80),

                Font     = Textures.HUDFontRegular,
                FontSize = 40,

                Placeholder = L10N.T(L10NImpl.STR_CPP_NEWPW),
                IsPassword  = true,

                BackgoundCornerSize = 8,
                ColorPadLeft        = FlatColors.ControlHighlight,
                WidthPadLeft        = 80,
                IconColor           = FlatColors.Asbestos,
                Icon     = Textures.TexHUDIconPassword,
                IconSize = new FSize(50, 50),
            });

            AddElement(new HUDTextButton(1)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(24, 32),
                Size             = new FSize((WIDTH - 2 * 24), 64),

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

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonHUD, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonPressedHUD, 16),

                Click = OnChangePassword,
            });
        }
Exemplo n.º 24
0
        private async Task DoChangePassword(HUDElement spinner, string newPassword)
        {
            try
            {
                var profile = MainGame.Inst.Profile;

                var r = await MainGame.Inst.Backend.ChangePassword(profile, newPassword);

                switch (r.Item1)
                {
                case ChangePasswordResult.Success:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(3, 1, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_CPP_CHANGED,
                            TextColor    = FlatColors.TextHUD,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),
                            CloseOnClick = true,
                        }, true);

                        Remove();
                    });
                    break;

                case ChangePasswordResult.InternalError:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(10, 2, 0.3f)
                        {
                            Text         = r.Item2,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case ChangePasswordResult.NoConnection:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_CPP_COMERR,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                case ChangePasswordResult.AuthError:
                    MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                    {
                        spinner.Remove();
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText     = L10NImpl.STR_CPP_AUTHERR,
                            TextColor    = FlatColors.Clouds,
                            Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                            CloseOnClick = true,
                        }, true);
                        Remove();
                    });
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                SAMLog.Error("ChangePassword", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText     = L10NImpl.STR_CPP_CHANGEERR,
                        TextColor    = FlatColors.Clouds,
                        Background   = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),
                        CloseOnClick = true,
                    }, true);

                    Remove();
                });
            }
        }
Exemplo n.º 25
0
        private async Task DoUploadInternal(HUDElement spinner)
        {
            try
            {
                byte[] binData;
                using (var ms = new MemoryStream())
                    using (var bw = new BinaryWriter(ms))
                    {
                        Level.BinarySerialize(bw, true, GDConstants.LevelIntVersion, MainGame.Inst.Profile.OnlineUserID, SCCMData.OnlineID);
                        binData = ms.ToArray();
                    }

                var result = await MainGame.Inst.Backend.UploadUserLevel(MainGame.Inst.Profile, Level, SCCMData, binData, Time);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();

                    switch (result)
                    {
                    case UploadResult.InternalError:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_INTERNAL,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.NoConnection:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_CPP_COMERR,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.FileTooBig:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_FILETOOBIG,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.WrongUserID:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_WRONGUSER,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.LevelIDNotFound:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_LIDNOTFOUND,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.InvalidName:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_INVALIDNAME,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.DuplicateName:
                        HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLUPLD_ERR_DUPLNAME,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                            CloseOnClick = true,
                        }, true);
                        break;

                    case UploadResult.AlreadyUploaded:
                    case UploadResult.Success:
                        SCCMUtils.UpgradeLevel(SCCMData, binData);

                        MainGame.Inst.GetCurrentScreen().HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                        {
                            L10NText   = L10NImpl.STR_LVLED_UPLOAD_FIN,
                            TextColor  = FlatColors.Clouds,
                            Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Nephritis, 16),

                            CloseOnClick = true,
                        }, true);

                        MainGame.Inst.SetOverworldScreenWithSCCM(SCCMMainPanel.SCCMTab.MyLevels);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                });
            }
            catch (Exception e)
            {
                SAMLog.Error("SCCMUSP::DUI", e);

                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    spinner.Remove();
                    HUD.AddModal(new HUDFadeOutInfoBox(5, 2, 0.3f)
                    {
                        L10NText   = L10NImpl.STR_CPP_COMERR,
                        TextColor  = FlatColors.Clouds,
                        Background = HUDBackgroundDefinition.CreateRounded(FlatColors.Alizarin, 16),

                        CloseOnClick = true,
                    }, true);
                });
            }
        }
Exemplo n.º 26
0
        public override void OnInitialize()
        {
            base.OnInitialize();

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

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

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

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                L10NText  = L10NImpl.STR_AAP_HEADER,
                TextColor = FlatColors.Clouds,
            });

            AddElement(editUsername = new HUDIconTextBox(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20, 100),
                Size             = new FSize(WIDTH - 40, 80),

                Font     = Textures.HUDFontRegular,
                FontSize = 40,

                Placeholder = L10N.T(L10NImpl.STR_AAP_USERNAME),
                MaxLength   = 16,

                BackgoundCornerSize = 8,
                ColorPadLeft        = FlatColors.ControlHighlight,
                WidthPadLeft        = 80,
                IconColor           = FlatColors.Asbestos,
                Icon     = Textures.TexHUDIconUser,
                IconSize = new FSize(50, 50),
            });

            AddElement(editPassword = new HUDIconTextBox(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20, 200),
                Size             = new FSize(WIDTH - 40, 80),

                Font     = Textures.HUDFontRegular,
                FontSize = 40,

                Placeholder = L10N.T(L10NImpl.STR_AAP_PASSWORD),
                IsPassword  = true,

                BackgoundCornerSize = 8,
                ColorPadLeft        = FlatColors.ControlHighlight,
                WidthPadLeft        = 80,
                IconColor           = FlatColors.Asbestos,
                Icon     = Textures.TexHUDIconPassword,
                IconSize = new FSize(50, 50),
            });

            AddElement(new HUDTextButton(1)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(24, 32),
                Size             = new FSize((WIDTH - 3 * 24) / 2, 64),

                L10NText          = L10NImpl.STR_AAP_CREATEACCOUNT,
                TextColor         = Color.White,
                Font              = Textures.HUDFontRegular,
                FontSize          = 55,
                TextAlignment     = HUDAlignment.CENTER,
                TextPadding       = 8,
                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonHUD, 16f),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonPressedHUD, 16f),

                Click = OnCreateAccount,
            });

            AddElement(new HUDTextButton(1)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(24, 32),
                Size             = new FSize((WIDTH - 3 * 24) / 2, 64),

                L10NText          = L10NImpl.STR_AAP_LOGIN,
                TextColor         = Color.White,
                Font              = Textures.HUDFontRegular,
                FontSize          = 55,
                TextAlignment     = HUDAlignment.CENTER,
                TextPadding       = 8,
                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonHUD, 16f),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonPressedHUD, 16f),

                Click = OnLogin,
            });
        }
Exemplo n.º 27
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();
        }
Exemplo n.º 28
0
        public override void OnInitialize()
        {
            base.OnInitialize();

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

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                L10NText  = L10NImpl.STR_MENU_CAP_MULTIPLAYER,
                TextColor = FlatColors.Clouds,
            });

            AddElement(new HUDSeperator(HUDOrientation.Horizontal)
            {
                Alignment        = HUDAlignment.TOPCENTER,
                RelativePosition = new FPoint(0, 100),
                Size             = new FSize(WIDTH, 1),
                SeperatorWidth   = 2,
                Color            = FlatColors.BackgroundHUD2,
            });

            AddElement(new HUDSeperator(HUDOrientation.Vertical)
            {
                Alignment        = HUDAlignment.CENTER,
                RelativePosition = new FPoint(0, 50),
                Size             = new FSize(1, HEIGHT - 100),
                SeperatorWidth   = 2,
                Color            = FlatColors.BackgroundHUD2,
            });

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.TOPLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(12, 112),
                Size             = new FSize(300, 32),

                Font     = Textures.HUDFontBold,
                FontSize = 32,

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

            AddElement(new HUDLabel
            {
                TextAlignment    = HUDAlignment.TOPLEFT,
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(WIDTH / 2 + 12, 112),
                Size             = new FSize(300, 32),

                Font     = Textures.HUDFontBold,
                FontSize = 32,

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

            AddElement(new HUDImage
            {
                Alignment        = HUDAlignment.TOPCENTER,
                Image            = Textures.TexIconBluetoothClassic,
                Size             = new FSize(128, 128),
                Color            = ColorMath.Blend(Color.White, FlatColors.BackgroundHUD, 0.5f),
                RelativePosition = new FPoint(-WIDTH / 4f, (100 + 12 + 32 + 12) + (HEIGHT - (100 + 12 + 32 + 12) - (32 + 64 + 32 + 64 + 32)) / 2 - 64)
            });

            AddElement(new HUDImage
            {
                Alignment        = HUDAlignment.TOPCENTER,
                Image            = Textures.TexIconInternet,
                Size             = new FSize(128, 128),
                Color            = ColorMath.Blend(Color.White, FlatColors.BackgroundHUD, 0.5f),
                RelativePosition = new FPoint(+WIDTH / 4f, (100 + 12 + 32 + 12) + (HEIGHT - (100 + 12 + 32 + 12) - (32 + 64 + 32 + 64 + 32)) / 2 - 64)
            });

            AddElement(new HUDTextButton
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint((WIDTH / 2 - 320) / 2, 128),
                Size             = new FSize(320, 64),

                L10NText      = L10NImpl.STR_MENU_MP_JOIN,
                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 = OnClickJoinBluetooth,
            });

            AddElement(new HUDTextButton
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint((WIDTH / 2 - 320) / 2, 128),
                Size             = new FSize(320, 64),

                L10NText      = L10NImpl.STR_MENU_MP_JOIN,
                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 = OnClickJoinOnline,
            });

            if (_ustate == WorldUnlockState.OpenAndUnlocked)
            {
                AddElement(new HUDTextButton
                {
                    Alignment        = HUDAlignment.BOTTOMLEFT,
                    RelativePosition = new FPoint((WIDTH / 2 - 320) / 2, 32),
                    Size             = new FSize(320, 64),

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

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

                    Click = OnClickHostBluetooth,
                });

                AddElement(new HUDTextButton
                {
                    Alignment        = HUDAlignment.BOTTOMRIGHT,
                    RelativePosition = new FPoint((WIDTH / 2 - 320) / 2, 32),
                    Size             = new FSize(320, 64),

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

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

                    Click = OnClickHostOnline,
                });
            }
            else
            {
                AddElement(new HUDTextButton
                {
                    Alignment        = HUDAlignment.BOTTOMLEFT,
                    RelativePosition = new FPoint((WIDTH / 2 - 320) / 2, 32),
                    Size             = new FSize(320, 64),

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

                    BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16),
                    BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.WetAsphalt, 16),

                    Click = OnClickUnlock,
                });

                AddElement(new HUDTextButton
                {
                    Alignment        = HUDAlignment.BOTTOMRIGHT,
                    RelativePosition = new FPoint((WIDTH / 2 - 320) / 2, 32),
                    Size             = new FSize(320, 64),

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

                    BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16),
                    BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.WetAsphalt, 16),

                    Click = OnClickUnlock,
                });
            }
        }
Exemplo n.º 29
0
        public override void OnInitialize()
        {
            base.OnInitialize();

            #region Header

            AddElement(new HUDLabel
            {
                Alignment        = HUDAlignment.TOPCENTER,
                RelativePosition = new FPoint(0, 0),
                Size             = new FSize(WIDTH, 48),

                TextAlignment = HUDAlignment.CENTER,
                Text          = _level.FullName,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontBold,
                FontSize      = 48,
            });

            #endregion

            #region Icons

            AddElement(_diffButton0 = new EnhancedHUDDifficultyButton(2, FractionDifficulty.DIFF_0, () => SelectDiff(FractionDifficulty.DIFF_0))
            {
                Active   = MainGame.Inst.Profile.HasCustomLevelBeaten(_level.CustomMeta_LevelID, FractionDifficulty.DIFF_0),
                Selected = FractionDifficulty.DIFF_0 == SelectedDifficulty,

                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(1 * ICON_MARGIN + 0 * ICON_SIZE, ICON_MARGIN + 32)
            });

            AddElement(_diffButton1 = new EnhancedHUDDifficultyButton(2, FractionDifficulty.DIFF_1, () => SelectDiff(FractionDifficulty.DIFF_1))
            {
                Active   = MainGame.Inst.Profile.HasCustomLevelBeaten(_level.CustomMeta_LevelID, FractionDifficulty.DIFF_1),
                Selected = FractionDifficulty.DIFF_1 == SelectedDifficulty,

                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(3 * ICON_MARGIN + 1 * ICON_SIZE, ICON_MARGIN + 32)
            });

            AddElement(_diffButton2 = new EnhancedHUDDifficultyButton(2, FractionDifficulty.DIFF_2, () => SelectDiff(FractionDifficulty.DIFF_2))
            {
                Active   = MainGame.Inst.Profile.HasCustomLevelBeaten(_level.CustomMeta_LevelID, FractionDifficulty.DIFF_2),
                Selected = FractionDifficulty.DIFF_2 == SelectedDifficulty,

                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(5 * ICON_MARGIN + 2 * ICON_SIZE, ICON_MARGIN + 32)
            });

            AddElement(_diffButton3 = new EnhancedHUDDifficultyButton(2, FractionDifficulty.DIFF_3, () => SelectDiff(FractionDifficulty.DIFF_3))
            {
                Active   = MainGame.Inst.Profile.HasCustomLevelBeaten(_level.CustomMeta_LevelID, FractionDifficulty.DIFF_3),
                Selected = FractionDifficulty.DIFF_3 == SelectedDifficulty,

                Alignment        = HUDAlignment.TOPLEFT,
                Size             = new FSize(ICON_SIZE, ICON_SIZE),
                RelativePosition = new FPoint(7 * ICON_MARGIN + 3 * ICON_SIZE, ICON_MARGIN + 32)
            });

            #endregion

            #region Buttons

            AddElement(new HUDIconTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(24, 3.50f * TW),
                Size             = new FSize(3.5f * TW, 60),

                L10NText      = L10NImpl.STR_HSP_BACK,
                TextColor     = Color.White,
                Font          = Textures.HUDFontRegular,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,
                Icon          = Textures.TexIconBack,

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

                Click = (s, a) => MainGame.Inst.SetOverworldScreenWithSCCM(SCCMMainPanel.SCCMTab.Hot),
            });

            AddElement(new HUDIconTextButton(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(24, 3.50f * TW),
                Size             = new FSize(3.5f * TW, 60),

                L10NText      = L10NImpl.STR_HSP_AGAIN,
                TextColor     = Color.White,
                Font          = Textures.HUDFontRegular,
                FontSize      = 55,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,
                Icon          = Textures.TexIconRedo,

                BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Orange, 16),
                BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.SunFlower, 16),

                Click = (s, a) => Replay(SelectedDifficulty),
            });

            #endregion

            #region Footer

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

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

            AddElement(new HUDRectangle(2)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 3f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.Nephritis),
            });

            AddElement(new HUDRectangle(1)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 2f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.PeterRiver),
            });

            AddElement(new HUDRectangle(2)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(0, FOOTER_HEIGHT - FOOTER_COLBAR_HEIGHT),
                Size             = new FSize(WIDTH / 3f, FOOTER_COLBAR_HEIGHT),

                Definition = HUDBackgroundDefinition.CreateSimple(FlatColors.Pomegranate),
            });

            AddElement(new HUDSeperator(HUDOrientation.Vertical, 3)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(WIDTH / 3f, 0),
                Size             = new FSize(1, FOOTER_HEIGHT),

                Color = FlatColors.SeperatorHUD,
            });

            AddElement(new HUDSeperator(HUDOrientation.Vertical, 3)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(WIDTH / 3f, 0),
                Size             = new FSize(1, FOOTER_HEIGHT),

                Color = FlatColors.SeperatorHUD,
            });

            AddElement(new HUDLabel(2)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, 77),
                Size             = new FSize(WIDTH / 3f, 40),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                L10NText      = L10NImpl.STR_HSP_POINTS,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontRegular,
                FontSize      = 35,
            });

            AddElement(new HUDIncrementIndicatorLabel(MainGame.Inst.Profile.ScoreSCCM.ToString(), "", 2)
            {
                Alignment        = HUDAlignment.BOTTOMCENTER,
                RelativePosition = new FPoint(0, 16),
                Size             = new FSize(WIDTH / 3f, 60),

                TextAlignment = HUDAlignment.BOTTOMCENTER,
                TextColor     = FlatColors.TextHUD,
                Font          = Textures.HUDFontBold,
                FontSize      = 57,
            });

            #endregion
        }
Exemplo n.º 30
0
        public override void OnInitialize()
        {
            base.OnInitialize();

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

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

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

                Font     = Textures.HUDFontBold,
                FontSize = 64,

                L10NText  = L10NImpl.STR_AAP_HEADER,
                TextColor = FlatColors.Clouds,
            });

            AddElement(new HUDLabel(1)
            {
                Alignment        = HUDAlignment.TOPLEFT,
                RelativePosition = new FPoint(20, 100),
                Size             = new FSize(WIDTH - 40, 200),

                Font          = Textures.HUDFontRegular,
                FontSize      = 32,
                TextColor     = ColorMath.Blend(FlatColors.Clouds, FlatColors.Background, 0.2f),
                WordWrap      = HUDWordWrap.WrapByWordTrusted,
                MaxWidth      = WIDTH - 40,
                TextAlignment = HUDAlignment.CENTER,

                L10NText = L10NImpl.STR_ACCOUNT_REMINDER,
            });

            AddElement(_buttonYes = new HUDTextButton(1)
            {
                Alignment        = HUDAlignment.BOTTOMLEFT,
                RelativePosition = new FPoint(24, 32),
                Size             = new FSize((WIDTH - 3 * 24) / 2, 64),

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

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

                Click = OnClickYes,
            });

            AddElement(new HUDTextButton(1)
            {
                Alignment        = HUDAlignment.BOTTOMRIGHT,
                RelativePosition = new FPoint(24, 32),
                Size             = new FSize((WIDTH - 3 * 24) / 2, 64),

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

                BackgroundNormal  = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonHUD, 16f),
                BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.ButtonPressedHUD, 16f),

                Click = OnClickNo,
            });
        }