/// <summary> /// Updates the state of the LoadGameManager and changes to the game if the conditions are met. /// by the stack screen manager /// </summary> /// <param name="gametime"></param> public void Update(GameTime gametime) { if (mGameLoaded) { mGameLoaded = false; } if (sResolutionChanged) { sResolutionChanged = false; } switch (sPressed) { case "None": return; case "Skirmish": mLevel = new Skirmish(mGraphics, ref mDirector, mContent, mScreenManager, LevelType.Skirmish); mGameScreen = mLevel.GameScreen; mUi = mLevel.Ui; mNewGame = true; break; case "TechDemo": mLevel = new TechDemo(mGraphics, ref mDirector, mContent, mScreenManager, LevelType.Techdemo); mGameScreen = mLevel.GameScreen; mUi = mLevel.Ui; mNewGame = true; break; case "Tutorial": mLevel = new Tutorial(mGraphics, ref mDirector, mContent, mScreenManager, LevelType.Tutorial); mGameScreen = mLevel.GameScreen; mUi = mLevel.Ui; mNewGame = true; break; case "Save1": mName = XSerializer.GetSaveNames()[0]; break; case "Save2": mName = XSerializer.GetSaveNames()[1]; break; case "Save3": mName = XSerializer.GetSaveNames()[2]; break; case "Save4": mName = XSerializer.GetSaveNames()[3]; break; case "Save5": mName = XSerializer.GetSaveNames()[4]; break; case "ReturnToMainMenu": int width; int height; if (GlobalVariables.IsFullScreen) { width = mGame.mGraphicsAdapter.CurrentDisplayMode.Width; height = mGame.mGraphicsAdapter.CurrentDisplayMode.Height; } else { width = GlobalVariables.ResolutionList[GlobalVariables.ChosenResolution].Item1; height = GlobalVariables.ResolutionList[GlobalVariables.ChosenResolution].Item2; } mScreenManager.AddScreen(new MainMenuManagerScreen(screenResolution: new Vector2(width, height), screenManager: mScreenManager, director: ref mDirector, showSplash: false, game: mGame)); break; default: throw new InvalidGenericArgumentException( "Somehow the LoadGameManagerScreen was assigned to a button that he should not have been assigned to. Cannot handle" + "this State"); } //This means a save has to be loaded if (mName != "") { var levelToBe = XSerializer.Load(mName, false); if (levelToBe.IsPresent()) { mLevel = (ILevel)levelToBe.Get(); mLevel.ReloadContent(mContent, mGraphics, ref mDirector, mScreenManager); mGameScreen = mLevel.GameScreen; mUi = mLevel.Ui; //Remove all screens above this screen, of course this only works if this screen is really on the bottom of the stack for (var i = mScreenManager.GetScreenCount() - 1; i > 1; i--) { mScreenManager.RemoveScreen(); } mScreenManager.AddScreen(mGameScreen); mScreenManager.AddScreen(mUi); mDirector.GetStoryManager.SetScreenManager(mScreenManager); mGameLoaded = true; mName = ""; GlobalVariables.mGameIsPaused = false; } } else if (mNewGame) { //Remove all screens above this screen, of course this only works if this screen is really on the bottom of the stack for (var i = mScreenManager.GetScreenCount() - 1; i > 0; i--) { mScreenManager.RemoveScreen(); } mScreenManager.AddScreen(mGameScreen); mScreenManager.AddScreen(mUi); mGameLoaded = true; mNewGame = false; GlobalVariables.mGameIsPaused = false; } sPressed = "None"; }
/// <summary> /// Updates the state of the pause menu and changes the screen that is currently being displayed /// by the stack screen manager. /// </summary> /// <param name="gametime"></param> public void Update(GameTime gametime) { if (sPausedAgain) { mScreenManager.AddScreen(mGamePauseScreen); sPausedAgain = false; } if (sSaved) { mSaveGameScreen = new SaveGameScreen(mScreenResolution) { mMenuOpacity = 1f }; sPressed = "Save Game"; Console.WriteLine("Save Screen Updated"); sSaved = false; } switch (mScreenState) { case EScreen.GameScreen: break; case EScreen.GamePauseScreen: if (sPressed == "Resume") { mScreenManager.RemoveScreen(); mScreenManager.RemoveScreen(); sPressed = "None"; sPausedAgain = true; } if (sPressed == "Save Game") { SwitchScreen(EScreen.SaveGameScreen, mGamePauseScreen, mSaveGameScreen, gametime); } if (sPressed == "Statistics") { SwitchScreen(EScreen.StatisticsScreen, mGamePauseScreen, mStatisticsScreen, gametime); } if (sPressed == "Main Menu") { mDirector.GetStoryManager.Level.GameScreen.Unload(); mDirector.GetClock = new Clock(); mDirector.GetIdGenerator = new IdGenerator(); mDirector.GetInputManager.RemoveEverythingFromInputManager(); mDirector.GetStoryManager = new StoryManager(mDirector); mDirector.GetStoryManager.SetScreenManager(mScreenManager); mDirector.GetPathManager = new PathManager(); mDirector.GetDistributionDirector = new DistributionDirector(mDirector); mDirector.GetMilitaryManager = new MilitaryManager(mDirector); mDirector.GetDeathManager = new DeathManager(); mDirector.GetActionManager = new ActionManager(); for (var i = 0; i < mScreenManager.GetScreenCount() - 1; i++) { mScreenManager.RemoveScreen(); } } break; case EScreen.SaveGameScreen: if (sPressed == "Back") { SwitchScreen(EScreen.GamePauseScreen, mSaveGameScreen, mGamePauseScreen, gametime); } if (sPressed == "Save Game") { mScreenManager.RemoveScreen(); mScreenManager.AddScreen(mSaveGameScreen); // SwitchScreen(EScreen.SaveGameScreen, mSaveGameScreen, mSaveGameScreen, gametime); // SwitchScreen(EScreen.SaveGameScreen, mGamePauseScreen, mSaveGameScreen, gametime); sPressed = "None"; } if (sPressed == "Save1") { mGameSaveStrings = XSerializer.GetSaveNames(); var path = @"%USERPROFILE%\Saved Games\Singularity\Saves"; if (mGameSaveStrings.Length >= 1) { path = Environment.ExpandEnvironmentVariables(path); path = path + @"\" + mGameSaveStrings[0]; } if (File.Exists(path)) { File.Delete(path); } SaveGame(); } if (sPressed == "Save2") { mGameSaveStrings = XSerializer.GetSaveNames(); var path = @"%USERPROFILE%\Saved Games\Singularity\Saves"; if (mGameSaveStrings.Length >= 2) { path = Environment.ExpandEnvironmentVariables(path); path = path + @"\" + mGameSaveStrings[1]; } if (File.Exists(path)) { File.Delete(path); } SaveGame(); } if (sPressed == "Save3") { mGameSaveStrings = XSerializer.GetSaveNames(); var path = @"%USERPROFILE%\Saved Games\Singularity\Saves"; if (mGameSaveStrings.Length >= 3) { path = Environment.ExpandEnvironmentVariables(path); path = path + @"\" + mGameSaveStrings[2]; } if (File.Exists(path)) { File.Delete(path); } SaveGame(); } if (sPressed == "Save4") { mGameSaveStrings = XSerializer.GetSaveNames(); var path = @"%USERPROFILE%\Saved Games\Singularity\Saves"; if (mGameSaveStrings.Length >= 4) { path = Environment.ExpandEnvironmentVariables(path); path = path + @"\" + mGameSaveStrings[3]; } if (File.Exists(path)) { File.Delete(path); } SaveGame(); } if (sPressed == "Save5") { mGameSaveStrings = XSerializer.GetSaveNames(); var path = @"%USERPROFILE%\Saved Games\Singularity\Saves"; if (mGameSaveStrings.Length >= 5) { path = Environment.ExpandEnvironmentVariables(path); path = path + @"\" + mGameSaveStrings[4]; } if (File.Exists(path)) { File.Delete(path); } SaveGame(); } break; case EScreen.StatisticsScreen: if (sPressed == "Back") { SwitchScreen(EScreen.GamePauseScreen, mStatisticsScreen, mGamePauseScreen, gametime); } break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Loads any content specific to this screen. /// </summary> /// <param name="content">Content Manager that should handle the content loading</param> public override void LoadContent(ContentManager content) { base.LoadContent(content); mButtonVerticalCenter = mLibSans20.MeasureString("Gg").Y / 2; mSelectorPosition = new Vector2(mMenuBoxPosition.X + 22, mButtonTopPadding + mButtonVerticalCenter); mSelectorTriangle = content.Load <Texture2D>("SelectorTriangle"); mGameSaveStrings = XSerializer.GetSaveNames(); switch (mGameSaveStrings.Length) { case 0: mSave1 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 0; break; case 1: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 1; mSave1.ButtonReleased += LoadGameManagerScreen.OnSave1Released; break; case 2: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 2; mSave1.ButtonReleased += LoadGameManagerScreen.OnSave1Released; mSave2.ButtonReleased += LoadGameManagerScreen.OnSave2Released; break; case 3: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button(mGameSaveStrings[2].Remove(mGameSaveStrings[2].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 3; mSave1.ButtonReleased += LoadGameManagerScreen.OnSave1Released; mSave2.ButtonReleased += LoadGameManagerScreen.OnSave2Released; mSave3.ButtonReleased += LoadGameManagerScreen.OnSave3Released; break; case 4: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button(mGameSaveStrings[2].Remove(mGameSaveStrings[2].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button(mGameSaveStrings[3].Remove(mGameSaveStrings[3].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 4; mSave1.ButtonReleased += LoadGameManagerScreen.OnSave1Released; mSave2.ButtonReleased += LoadGameManagerScreen.OnSave2Released; mSave3.ButtonReleased += LoadGameManagerScreen.OnSave3Released; mSave4.ButtonReleased += LoadGameManagerScreen.OnSave4Released; break; case 5: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button(mGameSaveStrings[2].Remove(mGameSaveStrings[2].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button(mGameSaveStrings[3].Remove(mGameSaveStrings[3].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button(mGameSaveStrings[4].Remove(mGameSaveStrings[4].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 5; mSave1.ButtonReleased += LoadGameManagerScreen.OnSave1Released; mSave2.ButtonReleased += LoadGameManagerScreen.OnSave2Released; mSave3.ButtonReleased += LoadGameManagerScreen.OnSave3Released; mSave4.ButtonReleased += LoadGameManagerScreen.OnSave4Released; mSave5.ButtonReleased += LoadGameManagerScreen.OnSave5Released; break; default: //Just load 5 saves, if by any chance there are more than 5 saves. It means that the player has added more saves and knows what he does...I hope... //TODO: Spawn Textbox informing the player that there are only 5 slots but more saves mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button(mGameSaveStrings[2].Remove(mGameSaveStrings[2].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button(mGameSaveStrings[3].Remove(mGameSaveStrings[3].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button(mGameSaveStrings[4].Remove(mGameSaveStrings[4].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 5; break; } mMBackButton = new Button(mBackString, mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 250), new Color(new Vector3(.9137f, .9058f, .8314f))); mMButtonList.Add(mMBackButton); mMButtonList.Add(mSave1); mMButtonList.Add(mSave2); mMButtonList.Add(mSave3); mMButtonList.Add(mSave4); mMButtonList.Add(mSave5); mMBackButton.ButtonReleased += MainMenuManagerScreen.OnBackButtonReleased; mMBackButton.ButtonHovering += OnBackHover; mSave1.ButtonHovering += OnSave1; mSave2.ButtonHovering += OnSave2; mSave3.ButtonHovering += OnSave3; mSave4.ButtonHovering += OnSave4; mSave5.ButtonHovering += OnSave5; Loaded = true; }
/// <summary> /// Loads any content specific to this screen. /// </summary> /// <param name="content">Content Manager that should handle the content loading</param> public void LoadContent(ContentManager content) { mLibSans36 = content.Load <SpriteFont>("LibSans36"); mLibSans20 = content.Load <SpriteFont>("LibSans20"); mButtonVerticalCenter = mLibSans20.MeasureString("Gg").Y / 2; mSelectorPosition = new Vector2(mMenuBoxPosition.X + 22, mButtonTopPadding + mButtonVerticalCenter); mSelectorTriangle = content.Load <Texture2D>("SelectorTriangle"); mGameSaveStrings = XSerializer.GetSaveNames(); switch (mGameSaveStrings.Length) { case 0: mSave1 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 0; break; case 1: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 1; break; case 2: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 2; break; case 3: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button(mGameSaveStrings[2].Remove(mGameSaveStrings[2].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 3; break; case 4: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button(mGameSaveStrings[2].Remove(mGameSaveStrings[2].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button(mGameSaveStrings[3].Remove(mGameSaveStrings[3].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button("Empty Slot", mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 4; break; case 5: mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button(mGameSaveStrings[2].Remove(mGameSaveStrings[2].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button(mGameSaveStrings[3].Remove(mGameSaveStrings[3].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button(mGameSaveStrings[4].Remove(mGameSaveStrings[4].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 5; break; default: //Just load 5 saves, if by any chance there are more than 5 saves. It means that the player has added more saves and knows what he does...I hope... //TODO: Spawn Textbox informing the player that there are only 5 slots but more saves mSave1 = new Button(mGameSaveStrings[0].Remove(mGameSaveStrings[0].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave2 = new Button(mGameSaveStrings[1].Remove(mGameSaveStrings[1].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 50), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave3 = new Button(mGameSaveStrings[2].Remove(mGameSaveStrings[2].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 100), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave4 = new Button(mGameSaveStrings[3].Remove(mGameSaveStrings[3].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 150), new Color(new Vector3(.9137f, .9058f, .8314f))); mSave5 = new Button(mGameSaveStrings[4].Remove(mGameSaveStrings[4].Length - 4), mLibSans20, new Vector2(mButtonLeftPadding, mButtonTopPadding + 200), new Color(new Vector3(.9137f, .9058f, .8314f))); Saves = 5; break; } // First make a dummy version of BackButton to determine it's dimensions for centering purposes. mBackButton = new Button(mBackString, mLibSans20, new Vector2(0, 0), Color.White); var backButtonPosX = mMenuBoxPosition.X + (mMenuBoxSize.X / 2) - (mBackButton.Size.X / 2); var backButtonPosY = mMenuBoxPosition.Y + mMenuBoxSize.Y - mBackButton.Size.Y - BottomPadding; mBackButton = new Button(mBackString, mLibSans20, new Vector2(backButtonPosX, backButtonPosY), Color.White) { Opacity = 0 }; mButtonList.Add(mBackButton); mButtonList.Add(mSave1); mButtonList.Add(mSave2); mButtonList.Add(mSave3); mButtonList.Add(mSave4); mButtonList.Add(mSave5); mBackButton.ButtonReleased += GamePauseManagerScreen.OnBackButtonReleased; mSave1.ButtonReleased += GamePauseManagerScreen.OnSave1ButtonReleased; mSave2.ButtonReleased += GamePauseManagerScreen.OnSave2ButtonReleased; mSave3.ButtonReleased += GamePauseManagerScreen.OnSave3ButtonReleased; mSave4.ButtonReleased += GamePauseManagerScreen.OnSave4ButtonReleased; mSave5.ButtonReleased += GamePauseManagerScreen.OnSave5ButtonReleased; mBackButton.ButtonHovering += OnBackHover; mSave1.ButtonHovering += OnSave1; mSave2.ButtonHovering += OnSave2; mSave3.ButtonHovering += OnSave3; mSave4.ButtonHovering += OnSave4; mSave5.ButtonHovering += OnSave5; Loaded = true; }