/// <summary> /// The event for when the LoadGame button is pressed /// </summary> public async Task LoadGame() { FileOperations.SelectLoadLocation(); /* * At this point the value of SaveLocation could either be a valid path or "Cancelled" */ //Checking the save location isn't cancelled, if it is then do nothing if (FileOperations.SaveLocation != "Cancelled") { //If the save location isn't a txt file, return and do nothing if (!FileOperations.SaveLocation.EndsWith(".txt")) { PopupHelper.ShowPopup("FAILED", "Nice try, the save file must be a text file"); return; } string loadResponse = await FileOperations.LoadData(); //Try to load the file if (loadResponse.StartsWith("Failed")) { //Loading the file failed PopupHelper.ShowPopup("FAILED", loadResponse.Replace("Failed", "")); } else { //Try to parse the loadResponse List <GameSaveClass> parseResponse = LoadData.CreateData(loadResponse); if (parseResponse.Count() == 1) { //The parsed data only contains one entry, the load has failed PopupHelper.ShowPopup("FAILED", "Beep Boop, data not recognised"); } else { //Load checks have passed, launch the game GameViewModel.LoadList = parseResponse; _events.PublishOnUIThread(new LoadGameEvent()); PopupHelper.ShowPopup("LOADED", "Woop! Your game has been loaded"); } } } }