Exemple #1
0
        private void OpenMainMenu()
        {
            if (hasOpenedMainMenu)
            {
                return;
            }

            hasOpenedMainMenu = true;

            if (Owner != null)
            {
#if XBOX
                SignedInGamer gamer = SignedInGamer.SignedInGamers[FrameworkCore.ControllingPlayer];

                Owner.AddMenu(new MainMenu());
                if (gamer != null)
                {
                    //player is signed in. load player's data.
                    FrameworkCore.players[0].commanderName = gamer.Gamertag;
                    LoadData();
                }
                else
                {
                    //unsigned player. assign random name.
                    FrameworkCore.players[0].commanderName = Helpers.GenerateName("Gamertag");
                }
#elif (WINDOWS && STEAM)
                //the steam build uses the player's Steam persona name.
                //if there's an error for whatever reason, we let the player type in any name.

                LoadData();

                string playerName = FrameworkCore.GetSteamName();

                if (playerName == null)
                {
                    FrameworkCore.players[0].commanderName = Helpers.GenerateName("Gamertag");
                    Owner.AddMenu(new NameMenu());
                }
                else
                {
                    FrameworkCore.players[0].commanderName = playerName;
                    Owner.AddMenu(new MainMenu());
                }
#else
                SaveInfo optionsData = LoadData();

                if (optionsData.playerName == null)
                {
                    FrameworkCore.players[0].commanderName = Helpers.GenerateName("Gamertag");
                }
                else
                {
                    FrameworkCore.players[0].commanderName = optionsData.playerName;
                }

                Owner.AddMenu(new NameMenu());
#endif
            }

            Deactivate();
        }