Пример #1
0
        /// <summary>
        /// Updates the editing object with this editor's values.
        /// </summary>
        public void UpdateObject()
        {
            if (editingObject == null)
            {
                return;
            }

            // TODO: this part seems a bit ugly. Can we do better here?
            string collection = "";

            if (collectionDropdown.currentlySelected == 0)
            {
                collection = CallNumberCollection.Regular;
            }
            else if (collectionDropdown.currentlySelected == 1)
            {
                collection = CallNumberCollection.OversizedPlus;
            }
            else if (collectionDropdown.currentlySelected == 2)
            {
                collection = CallNumberCollection.OversizedPlusPlus;
            }

            editingObject.collection = collection;
            editingObject.isSideA    = sideDropdown.currentlySelected == 0;

            // We check if all fields are properly set up. If not we don't update the
            // ranges.
            bool allValid = true;

            allValid &= !startInputField.validationText.isActiveAndEnabled;
            allValid &= !endInputField.validationText.isActiveAndEnabled;

            if (!allValid)
            {
                return;
            }

            // This is called every single time we edit the field.
            // We want to create new call numbers each time, to validate the input.
            CallNumber begin = new CallNumber(startInputField.inputField.text);
            CallNumber end   = new CallNumber(endInputField.inputField.text);

            // Check if there is any change
            bool changed = !(begin.ToString().Equals(editingObject.GetBegin().ToString()) &&
                             end.ToString().Equals(editingObject.GetEnd().ToString()));

            allValid &= editingObject.SetBegin(begin);
            allValid &= editingObject.SetEnd(end);

            if (allValid && changed)
            {
                ActionManager.shared.Push();
            }

            warningIcon.gameObject.SetActive(!allValid);
        }
Пример #2
0
 /// <summary>
 /// Returns whether the call range has one side missing.
 /// </summary>
 /// <returns><c>true</c>, if incomplete, <c>false</c> otherwise.</returns>
 public bool IsIncomplete()
 {
     return(string.IsNullOrEmpty(begin.ToString()) || string.IsNullOrEmpty(end.ToString()));
 }