public override void HandleInput(InputState input) { if (input.CurrentGamePadStates[(int)PlayerIndex.One].Buttons.Y == ButtonState.Pressed && input.PreviousGamePadStates[(int)PlayerIndex.One].Buttons.Y == ButtonState.Released) { const string message = "Are you sure you want to delete this file?"; MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true); confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted; ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer); } base.HandleInput(input); }
public override void HandleInput(InputState input) { if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Back) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Back)) { this.ExitScreen(); } if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Delete) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Delete)) { const string message = "Are you sure you want to delete this file?"; MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true); confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted; ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer); } base.HandleInput(input); }
void ConfirmQuitMessageBoxAccepted_Invert(IAsyncResult result) { if (Guide.EndShowKeyboardInput(KeyboardResult) == "CumBucket") { LoadingScreen.Load(ScreenManager, true, PlayerIndex.One, new InvertTest()); } else { const string message = "Wrong Password!!!"; MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true); confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted_Invert; ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer); } }
void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e) { const string message = "Don't forget to save before exiting session"; MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true); confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted; ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer); }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreens) { if (KeyboardResult != null && KeyboardResult.IsCompleted) { input = Guide.EndShowKeyboardInput(KeyboardResult); //for debug string path = @"c:\Users\Alex\Desktop\LevelCreationSoftware\LevelCreationSoftware\LevelCreationSoftware\bin\x86\Debug\Content\" + input + ".txt"; string listPath = @"c:\Users\Alex\Desktop\LevelCreationSoftware\LevelCreationSoftware\LevelCreationSoftware\bin\x86\Debug\Content\LevelLayouts.txt"; //string path = "Content\\" + input + ".txt"; //string listPath = "Content\\LevelLayouts.txt"; List<string> levelList = new List<string>(); if (File.Exists(listPath)) { using (StreamReader sr = new StreamReader(listPath)) { while (sr.Peek() > 0) { string line = sr.ReadLine(); if (line == input) { const string message = "Needs a Different Name!"; MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true); confirmQuitMessageBox.Accepted += ConfirmNameChangeMessageBoxAccepted; ScreenManager.AddScreen(confirmQuitMessageBox, PlayerIndex.One); KeyboardResult = null; break; } } sr.Close(); } } if (KeyboardResult != null && KeyboardResult.IsCompleted) { SavedName = input; if (File.Exists(path)) { File.Delete(path); } using (StreamWriter sw = new StreamWriter(path)) { for (int i = 0; i < Tiles.Count; i++) { sw.WriteLine(Tiles[i].position.X.ToString() + "," + Tiles[i].position.Y.ToString() + "," + Tiles[i].type.ToString() + "," + Tiles[i].objectNumber.ToString() + "," + Tiles[i].layerNumber.ToString() + ",Tile"); } for (int i = 0; i < Backgrounds.Count; i++) { sw.WriteLine(Backgrounds[i].position.X.ToString() + "," + Backgrounds[i].position.Y.ToString() + "," + Backgrounds[i].type.ToString() + "," + Backgrounds[i].objectNumber.ToString() + "," + Backgrounds[i].layerNumber.ToString() + ",Background"); } sw.Close(); } levelList.Clear(); if (File.Exists(listPath)) { using (StreamReader sr = new StreamReader(listPath)) { while (sr.Peek() > 0) { levelList.Add(sr.ReadLine()); } sr.Close(); } File.Delete(listPath); } using (StreamWriter sw = new StreamWriter(listPath)) { for (int i = 0; i < levelList.Count; i++) { sw.WriteLine(levelList[i]); } sw.WriteLine(input); } KeyboardResult = null; } } base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreens); }