示例#1
0
 private void ChooseSaveSlot(SaveSlotInfo slot, SaveManagementLevel.SMOperation operation)
 {
   switch (operation)
   {
     case SaveManagementLevel.SMOperation.Change:
       this.GameState.SaveSlot = slot.Index;
       this.GameState.LoadSaveFile((Action) (() =>
       {
         this.GameState.Save();
         this.GameState.DoSave();
         this.GameState.SaveToCloud(true);
         this.GameState.Restart();
       }));
       break;
     case SaveManagementLevel.SMOperation.CopySource:
       this.CopySourceSlot = slot;
       this.RefreshSlotsFor(this.CopyDestLevel, SaveManagementLevel.SMOperation.CopyDestination, (Func<SaveSlotInfo, bool>) (s => this.CopySourceSlot != s));
       this.Menu.ChangeMenuLevel(this.CopyDestLevel, false);
       break;
     case SaveManagementLevel.SMOperation.CopyDestination:
       new PCSaveDevice("FEZ").Save("SaveSlot" + (object) slot.Index, (SaveAction) (writer => SaveFileOperations.Write(new CrcWriter(writer), this.CopySourceSlot.SaveData)));
       this.GameState.SaveToCloud(true);
       this.ReloadSlots();
       this.Menu.ChangeMenuLevel((MenuLevel) this, false);
       break;
     case SaveManagementLevel.SMOperation.Clear:
       new PCSaveDevice("FEZ").Delete("SaveSlot" + (object) slot.Index);
       if (this.GameState.SaveSlot == slot.Index)
       {
         this.GameState.LoadSaveFile((Action) (() =>
         {
           this.GameState.Save();
           this.GameState.DoSave();
           this.GameState.SaveToCloud(true);
           this.GameState.Restart();
         }));
         break;
       }
       else
       {
         this.ReloadSlots();
         this.Menu.ChangeMenuLevel((MenuLevel) this, false);
         break;
       }
   }
 }
示例#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();
 }
示例#3
0
 private void RefreshSlotsFor(MenuLevel level, SaveManagementLevel.SMOperation operation, Func<SaveSlotInfo, bool> condition)
 {
   level.Items.Clear();
   foreach (SaveSlotInfo saveSlotInfo in this.Slots)
   {
     SaveSlotInfo s = saveSlotInfo;
     MenuItem menuItem;
     if (saveSlotInfo.Empty)
       (menuItem = level.AddItem((string) null, (Action) (() => this.ChooseSaveSlot(s, operation)), -1)).SuffixText = (Func<string>) (() => StaticText.GetString("NewSlot"));
     else
       (menuItem = level.AddItem("SaveSlotPrefix", (Action) (() => this.ChooseSaveSlot(s, operation)), -1)).SuffixText = (Func<string>) (() => string.Format((IFormatProvider) CultureInfo.InvariantCulture, " {0} ({1:P1} - {2:dd\\.hh\\:mm})", (object) (s.Index + 1), (object) s.Percentage, (object) s.PlayTime));
     menuItem.Disabled = !condition(saveSlotInfo);
     menuItem.Selectable = condition(saveSlotInfo);
   }
   for (int index = 0; index < this.Items.Count; ++index)
   {
     if (level.Items[index].Selectable)
     {
       level.SelectedIndex = index;
       break;
     }
   }
 }