/// <summary> /// Prompts the user to pick a saved game to load. /// Optionally the user can return to the previous menu. /// </summary> private void LoadingScreen() { Console.Clear(); Menu loadingScreen = new Menu("Choose a save file"); string[] saveFiles = Helpers.GetSaveNames(); MenuOptionWithArgs load = LoadGame; if (saveFiles != null) { foreach (string saveFile in saveFiles) { string root = @"saves/"; loadingScreen.AddEntry(saveFile.Remove(0, root.Length), this, load, new[] { saveFile, "test" }); } } //disaster if the player backs out from the load screen into the main screen coming from the start screen. //if we don't have a player, we came from the start menu if (player == null) { loadingScreen.AddEntry("Exit", this, new MenuOption(StartScreen)); } else { loadingScreen.AddEntry("Exit", this, new MenuOption(MainScreen)); } loadingScreen.Prompt(); MainScreen(); }
/// <summary> /// Prompts the user to save their game either in an existing slot or to create a 'New Save'. /// Optionally the user can 'Return' to the Main screen without performing a save. /// </summary> private void SaveScreen() { string[] saveFiles = Helpers.GetSaveNames(); Menu saveMenu = new Menu("Choose existing save or create a new one"); Menu.HasArg save = SaveGame; MenuOptionWithArgs saveOption = new MenuOptionWithArgs(SaveGame); foreach (string saveFile in saveFiles) { string root = @"saves/"; string saveName = saveFile.Remove(0, root.Length); saveMenu.AddEntry(saveName, this, saveOption, new object[] { saveName }); } saveMenu.AddEntry("New Save", this, new MenuOption(SavePrompt)); saveMenu.AddEntry("Return", this, new MenuOption(MainScreen)); saveMenu.Prompt(); }