コード例 #1
0
        public override void PostDraw(SpriteBatch batch, SpriteFont font, GlyphTextRenderer tr, float alpha)
        {
            if (this.leaderboard == null)
            {
                this.InitLeaderboards();
            }
            float viewScale = SettingsManager.GetViewScale(batch.GraphicsDevice);

            if (!this.leaderboard.InError)
            {
                tr.DrawString(batch, font, string.Format(StaticText.GetString("LeaderboardEntriesCount").ToUpper(CultureInfo.InvariantCulture), (object)this.leaderboard.TotalEntries), new Vector2(125f, 620f) * viewScale, new Color(1f, 1f, 1f, alpha), (Culture.IsCJK ? 0.2f : 1.5f) * viewScale);
            }
            float num1 = this.leaderboard.InError || this.leaderboard.Reading ? 0.0f : (this.leaderboard.CanPageUp ? 1f : 0.1f);
            float num2 = this.leaderboard.InError || this.leaderboard.Reading ? 0.0f : (this.leaderboard.CanPageDown ? 1f : 0.1f);
            float num3 = Culture.IsCJK ? -15f : 0.0f;

            if (this.Items.Count > 1)
            {
                int num4 = ServiceHelper.Game.GraphicsDevice.Viewport.Width / 2 - (int)viewScale * 20;
                int y    = ServiceHelper.Game.GraphicsDevice.Viewport.Height / 2;
                this.leftArrowRect  = new Rectangle?(new Rectangle((int)((double)num4 - (double)num4 * 5.0 / 7.0 + (double)num3 - (double)viewScale * 10.0), y, (int)(40.0 * (double)viewScale), (int)(25.0 * (double)viewScale)));
                this.rightArrowRect = new Rectangle?(new Rectangle((int)((double)num4 + (double)num4 * 5.0 / 7.0 + (double)num3), y, (int)(40.0 * (double)viewScale), (int)(25.0 * (double)viewScale)));
                tr.DrawString(batch, font, "{LA}", new Vector2((float)this.leftArrowRect.Value.Left + 15f * viewScale, (float)this.leftArrowRect.Value.Top), new Color(1f, 1f, 1f, num1 * alpha), (Culture.IsCJK ? 0.2f : 1f) * viewScale);
                tr.DrawString(batch, font, "{RA}", new Vector2((float)this.rightArrowRect.Value.Left + 15f * viewScale, (float)this.rightArrowRect.Value.Top), new Color(1f, 1f, 1f, num2 * alpha), (Culture.IsCJK ? 0.2f : 1f) * viewScale);
            }
            else
            {
                LeaderboardsMenuLevel leaderboardsMenuLevel1 = this;
                LeaderboardsMenuLevel leaderboardsMenuLevel2 = this;
                LeaderboardsMenuLevel leaderboardsMenuLevel3 = this;
                Rectangle?            nullable1 = new Rectangle?();
                Rectangle?            nullable2 = nullable1;
                leaderboardsMenuLevel3.rightArrowRect = nullable2;
                Rectangle?nullable3;
                Rectangle?nullable4 = nullable3 = nullable1;
                leaderboardsMenuLevel2.rightArrowRect = nullable3;
                Rectangle?nullable5 = nullable4;
                leaderboardsMenuLevel1.leftArrowRect = nullable5;
            }
            if (!this.leaderboard.CanPageUp)
            {
                this.leftArrowRect = new Rectangle?();
            }
            if (!this.leaderboard.CanPageDown)
            {
                this.rightArrowRect = new Rectangle?();
            }
            if (!this.leaderboard.ChangingPage)
            {
                return;
            }
            tr.DrawCenteredString(batch, font, StaticText.GetString("LoadingLeaderboard"), new Color(1f, 1f, 1f, alpha), new Vector2(0.0f, 205f) * viewScale, (Culture.IsCJK ? 2f : 1f) * viewScale);
        }
コード例 #2
0
ファイル: MenuBase.cs プロジェクト: Zeludon/FEZ
 public override void Initialize()
 {
   this.KeyboardState.IgnoreMapping = true;
   MenuBase menuBase1 = this;
   CreditsMenuLevel creditsMenuLevel1 = new CreditsMenuLevel();
   creditsMenuLevel1.Title = "Credits";
   creditsMenuLevel1.Oversized = true;
   creditsMenuLevel1.IsDynamic = true;
   CreditsMenuLevel creditsMenuLevel2 = creditsMenuLevel1;
   menuBase1.CreditsMenu = creditsMenuLevel2;
   this.StartNewGameMenu = new MenuLevel()
   {
     Title = "StartNewGameTitle",
     AButtonStarts = true,
     AButtonString = "StartNewGameWithGlyph",
     AButtonAction = new Action(this.StartNewGame)
   };
   this.StartNewGameMenu.AddItem("StartNewGameTextLine", new Action(Util.NullAction), -1);
   this.ExitToArcadeMenu = new MenuLevel()
   {
     Title = "ExitConfirmationTitle",
     AButtonString = "ExitChoiceYes",
     AButtonAction = new Action(this.ReturnToArcade)
   };
   this.ExitToArcadeMenu.AddItem("ReturnToArcadeTextLine", new Action(Util.NullAction), -1);
   MenuBase menuBase2 = this;
   LeaderboardsMenuLevel leaderboardsMenuLevel1 = new LeaderboardsMenuLevel(this);
   leaderboardsMenuLevel1.Title = "LeaderboardsTitle";
   leaderboardsMenuLevel1.Oversized = true;
   LeaderboardsMenuLevel leaderboardsMenuLevel2 = leaderboardsMenuLevel1;
   menuBase2.LeaderboardsMenu = leaderboardsMenuLevel2;
   MenuBase menuBase3 = this;
   ControlsMenuLevel controlsMenuLevel1 = new ControlsMenuLevel(this);
   controlsMenuLevel1.Title = "Controls";
   controlsMenuLevel1.Oversized = true;
   ControlsMenuLevel controlsMenuLevel2 = controlsMenuLevel1;
   menuBase3.ControlsMenu = controlsMenuLevel2;
   this.GameSettingsMenu = new MenuLevel()
   {
     Title = "GameSettings",
     BButtonString = "MenuSaveWithGlyph",
     IsDynamic = true,
     Oversized = true
   };
   this.AudioSettingsMenu = new MenuLevel()
   {
     Title = "AudioSettings",
     BButtonString = "MenuSaveWithGlyph",
     IsDynamic = true,
     Oversized = true
   };
   this.VideoSettingsMenu = new MenuLevel()
   {
     Title = "VideoSettings",
     AButtonString = "MenuApplyWithGlyph",
     IsDynamic = true,
     Oversized = true
   };
   this.VideoSettingsMenu.AddItem<string>("Resolution", new Action(this.ApplyVideo), false, (Func<string>) (() =>
   {
     DisplayMode local_0 = SettingsManager.Resolutions[this.currentResolution];
     float wD = (float) (local_0.Width / 1280);
     float hD = (float) (local_0.Height / 720);
     bool local_1 = local_0.Width % 1280 == 0 && (double) local_0.Height >= (double) wD * 720.0 && ((double) local_0.Height == (double) wD * 720.0 || !Enumerable.Any<DisplayMode>((IEnumerable<DisplayMode>) SettingsManager.Resolutions, (Func<DisplayMode, bool>) (x =>
     {
       if ((double) x.Width == (double) wD * 1280.0)
         return (double) x.Height == (double) wD * 720.0;
       else
         return false;
     }))) || local_0.Height % 720 == 0 && (double) local_0.Width >= (double) hD * 1280.0 && ((double) local_0.Width == (double) hD * 1280.0 || !Enumerable.Any<DisplayMode>((IEnumerable<DisplayMode>) SettingsManager.Resolutions, (Func<DisplayMode, bool>) (x =>
     {
       if ((double) x.Width == (double) hD * 1280.0)
         return (double) x.Height == (double) hD * 720.0;
       else
         return false;
     }))) || local_0.Width == 1920 && local_0.Height == 1080 && !Enumerable.Any<DisplayMode>((IEnumerable<DisplayMode>) SettingsManager.Resolutions, (Func<DisplayMode, bool>) (x =>
     {
       if (x.Width >= 2560)
         return x.Height >= 1440;
       else
         return false;
     })) || local_0 == SettingsManager.NativeResolution;
     return string.Concat(new object[4]
     {
       (object) local_0.Width,
       (object) "x",
       (object) local_0.Height,
       local_1 ? (object) " *" : (object) ""
     });
   }), (Action<string, int>) ((lastValue, change) =>
   {
     this.currentResolution += change;
     if (this.currentResolution == SettingsManager.Resolutions.Count)
       this.currentResolution = 0;
     if (this.currentResolution != -1)
       return;
     this.currentResolution = SettingsManager.Resolutions.Count - 1;
   }), -1).UpperCase = true;
   this.VideoSettingsMenu.AddItem<string>("ScreenMode", new Action(this.ApplyVideo), false, (Func<string>) (() =>
   {
     if (!this.isFullscreen)
       return StaticText.GetString("Windowed");
     else
       return StaticText.GetString("Fullscreen");
   }), (Action<string, int>) ((_, __) => this.isFullscreen = !this.isFullscreen), -1).UpperCase = true;
   this.VideoSettingsMenu.AddItem("ResetToDefault", new Action(this.ReturnToVideoDefault), -1);
   this.VideoSettingsMenu.OnPostDraw += (Action<SpriteBatch, SpriteFont, GlyphTextRenderer, float>) ((batch, font, tr, alpha) =>
   {
     float local_0 = this.Fonts.SmallFactor * SettingsManager.GetViewScale(batch.GraphicsDevice);
     float local_1 = (float) batch.GraphicsDevice.Viewport.Height / 2f;
     if (this.VideoSettingsMenu.SelectedIndex != 0)
       return;
     tr.DrawCenteredString(batch, this.Fonts.Small, StaticText.GetString("RecommendedResolution"), new Color(1f, 1f, 1f, alpha), new Vector2(0.0f, local_1 * 1.5f), local_0);
   });
   this.AudioSettingsMenu.AddItem<float>("SoundVolume", MenuBase.SliderAction, false, (Func<float>) (() => SettingsManager.Settings.SoundVolume), (Action<float, int>) ((lastValue, change) =>
   {
     float local_0 = (double) lastValue > 0.0500000007450581 || change >= 0 ? ((double) lastValue < 0.949999988079071 || change <= 0 ? lastValue + (float) change * 0.05f : 1f) : 0.0f;
     this.SoundManager.SoundEffectVolume = SettingsManager.Settings.SoundVolume = local_0;
   }), -1).UpperCase = true;
   this.AudioSettingsMenu.AddItem<float>("MusicVolume", MenuBase.SliderAction, false, (Func<float>) (() => SettingsManager.Settings.MusicVolume), (Action<float, int>) ((lastValue, change) =>
   {
     float local_0 = (double) lastValue > 0.0500000007450581 || change >= 0 ? ((double) lastValue < 0.949999988079071 || change <= 0 ? lastValue + (float) change * 0.05f : 1f) : 0.0f;
     this.SoundManager.MusicVolume = SettingsManager.Settings.MusicVolume = local_0;
   }), -1).UpperCase = true;
   this.AudioSettingsMenu.AddItem("ResetToDefault", new Action(this.ReturnToAudioDefault), -1);
   Language toSet = Culture.Language;
   MenuItem<Language> menuItem1 = this.GameSettingsMenu.AddItem<Language>("Language", MenuBase.SliderAction, false, (Func<Language>) (() => toSet), (Action<Language, int>) ((lastValue, change) =>
   {
     if (change < 0 && toSet == Language.English)
       toSet = Language.Korean;
     else if (change > 0 && toSet == Language.Korean)
       toSet = Language.English;
     else
       toSet += (Language) change;
   }), -1);
   this.GameSettingsMenu.AButtonString = "MenuApplyWithGlyph";
   menuItem1.Selected = (Action) (() => Culture.Language = SettingsManager.Settings.Language = toSet);
   this.GameSettingsMenu.OnReset = (Action) (() => toSet = Culture.Language);
   menuItem1.UpperCase = true;
   menuItem1.LocalizeSliderValue = true;
   menuItem1.LocalizationTagFormat = "Language{0}";
   if (this.GameState.SaveData.HasStereo3D)
     this.StereoMenuItem = this.GameSettingsMenu.AddItem(this.GameState.StereoMode ? "Stereo3DOn" : "Stereo3DOff", new Action(this.ToggleStereo), -1);
   this.VibrationMenuItem = this.GameSettingsMenu.AddItem(SettingsManager.Settings.Vibration ? "VibrationOn" : "VibrationOff", new Action(this.ToggleVibration), -1);
   this.GameSettingsMenu.AddItem("ResetToDefault", (Action) (() =>
   {
     this.ReturnToGameDefault();
     toSet = Culture.Language;
   }), -1);
   this.SaveManagementMenu = new SaveManagementLevel(this);
   this.HelpOptionsMenu = new MenuLevel()
   {
     Title = "HelpOptions"
   };
   this.HelpOptionsMenu.AddItem("Controls", (Action) (() => this.ChangeMenuLevel((MenuLevel) this.ControlsMenu, false)), -1);
   this.HelpOptionsMenu.AddItem("GameSettings", (Action) (() => this.ChangeMenuLevel(this.GameSettingsMenu, false)), -1);
   this.HelpOptionsMenu.AddItem("VideoSettings", (Action) (() =>
   {
     FezEngine.Tools.Settings s = SettingsManager.Settings;
     DisplayMode local_0 = Enumerable.FirstOrDefault<DisplayMode>((IEnumerable<DisplayMode>) SettingsManager.Resolutions, (Func<DisplayMode, bool>) (x =>
     {
       if (x.Width == s.Width)
         return x.Height == s.Height;
       else
         return false;
     })) ?? GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;
     this.currentResolution = SettingsManager.Resolutions.IndexOf(local_0);
     if (this.currentResolution == -1 || this.currentResolution >= SettingsManager.Resolutions.Count)
       this.currentResolution = 0;
     this.isFullscreen = SettingsManager.Settings.ScreenMode == ScreenMode.Fullscreen;
     this.ChangeMenuLevel(this.VideoSettingsMenu, false);
   }), -1).UpperCase = true;
   this.HelpOptionsMenu.AddItem("AudioSettings", (Action) (() => this.ChangeMenuLevel(this.AudioSettingsMenu, false)), -1);
   if (!Fez.PublicDemo)
     this.HelpOptionsMenu.AddItem("SaveManagementTitle", (Action) (() => this.ChangeMenuLevel((MenuLevel) this.SaveManagementMenu, false)), -1);
   this.SaveManagementMenu.Parent = this.HelpOptionsMenu;
   this.GameSettingsMenu.Parent = this.HelpOptionsMenu;
   this.AudioSettingsMenu.Parent = this.HelpOptionsMenu;
   this.VideoSettingsMenu.Parent = this.HelpOptionsMenu;
   this.ControlsMenu.Parent = this.HelpOptionsMenu;
   this.UnlockNeedsLIVEMenu = new MenuLevel();
   this.UnlockNeedsLIVEMenu.AddItem("UnlockNeedsLIVE", MenuBase.SliderAction, -1).Selectable = false;
   this.MenuRoot = new MenuLevel();
   this.MenuRoot.AddItem("HelpOptions", (Action) (() => this.ChangeMenuLevel(this.HelpOptionsMenu, false)), -1);
   MenuItem menuItem2 = this.MenuRoot.AddItem("Leaderboards", (Action) (() => this.ChangeMenuLevel((MenuLevel) this.LeaderboardsMenu, false)), -1);
   this.MenuRoot.AddItem("Credits", (Action) (() => this.ChangeMenuLevel((MenuLevel) this.CreditsMenu, false)), -1);
   this.CreditsMenu.Parent = this.MenuRoot;
   MenuItem menuItem3 = (MenuItem) null;
   if (this.GameState.IsTrialMode)
     menuItem3 = this.MenuRoot.AddItem("UnlockFullGame", new Action(this.UnlockFullGame), -1);
   MenuItem menuItem4 = this.MenuRoot.AddItem("ReturnToArcade", (Action) (() => this.ChangeMenuLevel(this.ExitToArcadeMenu, false)), -1);
   if (Fez.PublicDemo)
   {
     menuItem4.Disabled = true;
     menuItem2.Disabled = true;
     if (menuItem3 != null)
       menuItem3.Disabled = true;
     menuItem4.Selectable = false;
     menuItem2.Selectable = false;
     if (menuItem3 != null)
       menuItem3.Selectable = false;
   }
   this.MenuLevels = new List<MenuLevel>()
   {
     this.MenuRoot,
     this.UnlockNeedsLIVEMenu,
     this.StartNewGameMenu,
     this.HelpOptionsMenu,
     this.AudioSettingsMenu,
     this.VideoSettingsMenu,
     this.GameSettingsMenu,
     this.ExitToArcadeMenu,
     (MenuLevel) this.LeaderboardsMenu,
     (MenuLevel) this.ControlsMenu,
     (MenuLevel) this.CreditsMenu,
     (MenuLevel) this.SaveManagementMenu
   };
   foreach (MenuLevel menuLevel in this.MenuLevels)
   {
     if (menuLevel != this.MenuRoot && menuLevel.Parent == null)
       menuLevel.Parent = this.MenuRoot;
   }
   this.nextMenuLevel = this.EndGameMenu ? (MenuLevel) this.CreditsMenu : this.MenuRoot;
   this.GameState.DynamicUpgrade += new Action(this.DynamicUpgrade);
   this.PostInitialize();
   base.Initialize();
 }