public void OnExitClick() { if (DeckBuilderDeck.instance.unsavedChanges) { glassBackground.SetActive(true); YesNoBox yesNoBox = Instantiate(yesNoBoxPrefab); yesNoBox.setUp(switchToMainMenu, setGlassBackgroundActiveFalse, "Unsaved changes", "There are unsaved changes to your deck. Are you sure you want to exit?"); } else { SceneManager.LoadScene(ScenesEnum.MainMenu); } }
public void save(string deckName) { if (deckName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { YesNoBox yesNoBox = Instantiate(yesNoBoxPrefab); yesNoBox.setUp(null, "Invalid Deck Name", "The deck name " + deckName + " contains illegal characters. Please choose a different name."); yesNoBox.setNoButtonActive(false); yesNoBox.setYesButtonText("Okay"); return; } if (deckName.Length == 0) { Toaster.Instance.DoToast("Deck name cannot be empty"); return; } // put together string that will be the deck file string filePath = Application.persistentDataPath + "/decks/" + deckName + ".dek"; // create deck folder if needed string directoryPath = Application.persistentDataPath + "/decks"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(directoryPath); } Dictionary <int, int> idToAmountMap = new Dictionary <int, int>(); foreach (CardAmountPair pair in cardList) { int id = pair.cardId; int amount = pair.amount; idToAmountMap.Add(id, amount); } // save the map as a file BinaryFormatter bf = new BinaryFormatter(); FileStream fs = File.Open(filePath, FileMode.Create); bf.Serialize(fs, idToAmountMap); fs.Close(); // do on save stuff unsavedChanges = false; Toaster.Instance.DoToast("Deck Saved"); int dropdownIndex = deckNameDropdown.value; loadDeckPopUp.setup(); deckNameDropdown.SetValueWithoutNotify(dropdownIndex); }
public void loadWithSavedChangesCheck(string deckName) { if (unsavedChanges) { glassBackground.SetActive(true); YesNoBox yesNoBox = Instantiate(yesNoBoxPrefab); LoadWithSavedChangesHandler handler = new LoadWithSavedChangesHandler(); handler.deckBuilderDeck = this; handler.deckName = deckName; yesNoBox.setUp(handler, "Unsaved Changes", "There are unsaved changes to the current deck. Are you sure you want to load a new deck without saving?"); } else { load(deckName); } }
public void delete() { //string deckName = deckNameField.text; string deckName = deckNameDropdown.options[deckNameDropdown.value].text; string filePath = Application.persistentDataPath + "/decks/" + deckName + ".dek"; if (File.Exists(filePath)) { // show confirm dialouge YesNoBox yesNoBox = Instantiate(yesNoBoxPrefab); DeleteConfirmHandler handler = new DeleteConfirmHandler(); handler.deckName = deckName; handler.deckBuilder = this; yesNoBox.setUp(handler, "Delete Confirmation", "Are you sure you want to delete " + deckName + "?"); glassBackground.SetActive(true); } else { // do nothing (maybe change to error dialouge later) Debug.LogError("Deck not found " + filePath); } }
public void saveAs() { // use the deckName from the text field box string deckName = deckNameField.text.Trim(); // check if deck is legal size if (cardCount < minNumerOfCardsInDeck) { Toaster.Instance.DoToast("Deck must contain at least " + minNumerOfCardsInDeck + " cards"); return; } else if (cardCount > maxNumberOfCardsInDeck) { Toaster.Instance.DoToast("Deck must be under " + maxNumberOfCardsInDeck + " cards"); return; } // check to see if the deck already exists string filePath = Application.persistentDataPath + "/decks/" + deckName + ".dek"; if (File.Exists(filePath)) { glassBackground.SetActive(true); // if it does display a yes/no box YesNoBox yesNoBox = Instantiate(yesNoBoxPrefab); SaveConfirmHandler handler = new SaveConfirmHandler(); handler.deckBuilderDeck = this; handler.deckName = deckName; yesNoBox.setUp(handler, "Overwrite Confimation", "A deck with the name " + deckName + " already exists. Would you like to overwrite the saved deck?"); } else { // otherwise just save save(deckName); loadDeckPopUp.setToValue(deckName); } }
int SendMail(string strSubject, string strBody, int how) { MapiMessage msg = new MapiMessage(); msg.subject = strSubject; msg.noteText = strBody; msg.recips = GetRecipients(out msg.recipCount); msg.files = GetAttachments(out msg.fileCount); m_lastError = MAPISendMail(new IntPtr(0), new IntPtr(0), msg, how, 0); if (m_lastError > 1) { string samp = "MAPISendMail failed! " + GetLastError() + "MAPISendMail"; YesNoBox yesNo = new YesNoBox(samp); yesNo.ShowDialog(); //MessageBox.Show("MAPISendMail failed! " + GetLastError(), // "MAPISendMail"); } Cleanup(ref msg); return(m_lastError); }