/// <summary> /// saves all information that the user entered into the menu /// </summary> public void saveSettings() { // TODO : covert HelperSetter to ValidationHelper StringFunct setEcoName = new StringFunct(ecoEditor.setName); bool a = HelperValidator.setName(ecoNameTextBox, errorObj, setEcoName); IntFunct setAPPC = new IntFunct(ecoEditor.setAbilityPointsPerCreature); bool b = HelperValidator.setIntegerFunct(abilityPtsPerCreatTextBox, setAPPC, errorObj); IntFunct setCommBits = new IntFunct(ecoEditor.setCommBits); bool c = HelperValidator.setIntegerFunct(commBitsText, setCommBits, errorObj); IntFunct setDistinctPheno = new IntFunct(ecoEditor.setDistinctPhenotypeNum); bool d = HelperValidator.setIntegerFunct(distinctPhenoText, setDistinctPheno, errorObj); // saves tentative resource options to Ecosystem object ecoEditor.saveResourceOptions(); // TODO : don't forget to call EcosystemEditor save methods /** call methods to save ecoEditor data to actual Ecosystem object **/ // saves tentative resource options to Ecosystem object ecoEditor.saveResourceOptions(); ecoEditor.saveFoundersToSpecies(); ecoEditor.addCurrentPopulationToEcosystem(); ecoEditor.saveMap(); }
// parses string to integer and passes it to a function, sends error message to error game object public static bool setIntegerFunct(GameObject go, IntFunct setInt, GameObject errorObj) { bool valid = false; string text = go.GetComponent <Text>().text; int intVal; if (text.Equals("")) { string errorText = "Empty input error."; Debug.LogError(errorText); errorObj.GetComponent <Text>().text = errorText; errorObj.SetActive(true); } else if (text.Contains(".")) { string errorText = "Floating point given instead of integer."; Debug.LogError(errorText); errorObj.GetComponent <Text>().text = errorText; errorObj.SetActive(true); } else if (Int32.TryParse(text, out intVal)) { setInt(intVal); valid = true; } else { string errorText = "Error parsing integer from string."; Debug.LogError(errorText); Debug.LogError(text); errorObj.GetComponent <Text>().text = errorText; errorObj.SetActive(true); } return(valid); }